From patchwork Sat May 11 13:03:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 13662385 Received: from mail-lj1-f171.google.com (mail-lj1-f171.google.com [209.85.208.171]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 961C050A63; Sat, 11 May 2024 13:04:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715432653; cv=none; b=YQvzQwKOoHmP8OTP00HmQtULDGM5LsqYcX2Y2cPUEgviLEJ1VtdcvJ+DI4BenA9mH53ruQ+V0gB4QiEyTo5gP6SlNl4+f/cTZXpLJuVAgFUhi6O1ke9SNhCbY5aILkiDbd7EQqwrVitbp0Mu9fw1wOGkl8sBy+4+jhZFDw1dCMc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715432653; c=relaxed/simple; bh=dLf+sRfTEbzgn8sbcR5eeaVA/W0uDh3WvKW0ze/SR1c=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=doGZMQ4wNIgS5vxyKfOrrjGzo3AyvQjD2Snfh0XFyhhXYdFXFqnYa++RI5qjes3dlw8BSqDyNMDZNvnt3MZNX0Nmdw8PCMLkQglUr/ZGEUC4zf0mLAYl1SJFxLoCN3lIJ7uFf/ABwxMaO8iYUEGm0NJMc8oETa5+S+Y94Sha0i8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=KzUn2RWJ; arc=none smtp.client-ip=209.85.208.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="KzUn2RWJ" Received: by mail-lj1-f171.google.com with SMTP id 38308e7fff4ca-2e0b2ddc5d1so39202881fa.3; Sat, 11 May 2024 06:04:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1715432650; x=1716037450; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=dnHwdZLA5DykwWleNIsiGbLVxAuo8Ou7t0lUWcNVJ00=; b=KzUn2RWJt5RPbQGt7NpkDoheWJKLpjTVMFYz9/L3I4mT62Qym9NZx00AKyEap4qS5R cU4+ave0x+pdr0T19eJchmPeztlRluowtyyMVi5OxHZ1eVYkD7CH8fwJ2NFfycnUFjXC C7m9P8PjOh0onskhHCSdTZYrfe60TvaPzRd+3hy+3TufMv06lY4iBt601pta/22Tx83z 9U7eLxyJQIV5V7+P37tSob70s5y6zZXmaeZDWYWMHBtjIWBcvOkp5vJe5EbzmYEM/gw5 uZrDE2xK/+P7+qwqJGe/sIhZ7tpPFMjNZg0gHaJJL649bZgvO4/RBBRTSm6KcQ1UA+It l28g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715432650; x=1716037450; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=dnHwdZLA5DykwWleNIsiGbLVxAuo8Ou7t0lUWcNVJ00=; b=uN6Nd0UBIkYY/3CQnHscAyj9OCVtTHCRLFkCzL1rXlGEMJcxomUqZ/sbWLtKVIR2e7 bDxzK5C52wTXZAo8XRjd2NJ9bxDUAtQQx7UkxB9j+RAxey7zGf9VetpyQU9HEaMGo/Bc i07xUJo4psuB6kXXdoOXGNt6s9UG8hg3KaV/1yMSYsS3ZYUIuJUF4aQlx98pU/5LtObx M/nMJesu4fMaC7Nkh//ZOO9RFZr58wJXlCQPKzPTgpBjzOyWV+cchAkXzoxx8xHHXkoV bEZKOixepvtYuZem+jcnUa1slMP6BuoB90YOWTaEyMJPs8EZHmEN+qOUh6OBsLWe5V78 hV1Q== X-Forwarded-Encrypted: i=1; AJvYcCUrRR4/Hek6AMyHINGmKpU2uOeZNIVxgSeRJJzWzOgYhF/Rbb1J7REkAmrBwhQ6oUttrDh3q6dSwNq0FFneBFMCJwLVfntj/FAqxTUy7sonn8EV6SYU85uSeFVTnhm44y3FIJ+FFgh2YSLdYxPL6lUjP5h/W6QtBJfgRXLRl6uLy+Eit1E= X-Gm-Message-State: AOJu0YyETyp0mwUJxkJcR26XIcxw13VDZ8wDbX8sjJRelkRr88zTf/+c JMJ0WhG9/3FNoJR/PPgTowzN4GkHTDdGoY5GUiP0KB8lX28DKQgU X-Google-Smtp-Source: AGHT+IGy4K49ZD4rNb4xaUU0Ykb2AdsAiZgzWu26IW3wBkyRN54KZb7y05wbQpmohBt66J90HvHgQw== X-Received: by 2002:a05:651c:22f:b0:2e2:113c:cbab with SMTP id 38308e7fff4ca-2e51ff530b0mr40565031fa.21.1715432649320; Sat, 11 May 2024 06:04:09 -0700 (PDT) Received: from localhost.localdomain (93-34-90-105.ip49.fastwebnet.it. [93.34.90.105]) by smtp.googlemail.com with ESMTPSA id 5b1f17b1804b1-42010ca475asm15995495e9.16.2024.05.11.06.04.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 11 May 2024 06:04:08 -0700 (PDT) From: Christian Marangi To: Hauke Mehrtens , =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= , Thomas Bogendoerfer , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Florian Fainelli , Broadcom internal kernel review list , Christian Marangi , linux-mips@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v5 1/4] mips: bmips: rework and cache CBR addr handling Date: Sat, 11 May 2024 15:03:45 +0200 Message-ID: <20240511130349.23409-2-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240511130349.23409-1-ansuelsmth@gmail.com> References: <20240511130349.23409-1-ansuelsmth@gmail.com> Precedence: bulk X-Mailing-List: linux-mips@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Rework the handling of the CBR address and cache it. This address doesn't change and can be cached instead of reading the register every time. This is in preparation of permitting to tweak the CBR address in DT with broken SoC or bootloader. bmips_cbr_addr is defined in smp-bmips.c to keep compatibility with legacy brcm47xx/brcm63xx and generic BMIPS target. Signed-off-by: Christian Marangi Acked-by: Florian Fainelli --- arch/mips/bcm47xx/prom.c | 2 ++ arch/mips/bcm63xx/prom.c | 3 +++ arch/mips/bmips/dma.c | 2 +- arch/mips/bmips/setup.c | 4 +++- arch/mips/include/asm/bmips.h | 1 + arch/mips/kernel/smp-bmips.c | 6 ++++-- 6 files changed, 14 insertions(+), 4 deletions(-) diff --git a/arch/mips/bcm47xx/prom.c b/arch/mips/bcm47xx/prom.c index 99a1ba5394e0..49fe4c535161 100644 --- a/arch/mips/bcm47xx/prom.c +++ b/arch/mips/bcm47xx/prom.c @@ -109,6 +109,8 @@ static __init void prom_init_mem(void) void __init prom_init(void) { + /* Cache CBR addr before CPU/DMA setup */ + bmips_cbr_addr = BMIPS_GET_CBR(); prom_init_mem(); setup_8250_early_printk_port(CKSEG1ADDR(BCM47XX_SERIAL_ADDR), 0, 0); } diff --git a/arch/mips/bcm63xx/prom.c b/arch/mips/bcm63xx/prom.c index c3a2ea62c5c3..f21dd168171a 100644 --- a/arch/mips/bcm63xx/prom.c +++ b/arch/mips/bcm63xx/prom.c @@ -22,6 +22,9 @@ void __init prom_init(void) { u32 reg, mask; + /* Cache CBR addr before CPU/DMA setup */ + bmips_cbr_addr = BMIPS_GET_CBR(); + bcm63xx_cpu_init(); /* stop any running watchdog */ diff --git a/arch/mips/bmips/dma.c b/arch/mips/bmips/dma.c index 3779e7855bd7..2bc9c0d4402f 100644 --- a/arch/mips/bmips/dma.c +++ b/arch/mips/bmips/dma.c @@ -9,7 +9,7 @@ bool bmips_rac_flush_disable; void arch_sync_dma_for_cpu_all(void) { - void __iomem *cbr = BMIPS_GET_CBR(); + void __iomem *cbr = bmips_cbr_addr; u32 cfg; if (boot_cpu_type() != CPU_BMIPS3300 && diff --git a/arch/mips/bmips/setup.c b/arch/mips/bmips/setup.c index 66a8ba19c287..dba789ec75b3 100644 --- a/arch/mips/bmips/setup.c +++ b/arch/mips/bmips/setup.c @@ -111,7 +111,7 @@ static void bcm6358_quirks(void) * because the bootloader is not initializing it properly. */ bmips_rac_flush_disable = !!(read_c0_brcm_cmt_local() & (1 << 31)) || - !!BMIPS_GET_CBR(); + !!bmips_cbr_addr; } static void bcm6368_quirks(void) @@ -144,6 +144,8 @@ static void __init bmips_init_cfe(void) void __init prom_init(void) { + /* Cache CBR addr before CPU/DMA setup */ + bmips_cbr_addr = BMIPS_GET_CBR(); bmips_init_cfe(); bmips_cpu_setup(); register_bmips_smp_ops(); diff --git a/arch/mips/include/asm/bmips.h b/arch/mips/include/asm/bmips.h index 581a6a3c66e4..3a1cdfddb987 100644 --- a/arch/mips/include/asm/bmips.h +++ b/arch/mips/include/asm/bmips.h @@ -81,6 +81,7 @@ extern char bmips_smp_movevec[]; extern char bmips_smp_int_vec[]; extern char bmips_smp_int_vec_end[]; +extern void __iomem *bmips_cbr_addr; extern int bmips_smp_enabled; extern int bmips_cpu_offset; extern cpumask_t bmips_booted_mask; diff --git a/arch/mips/kernel/smp-bmips.c b/arch/mips/kernel/smp-bmips.c index b3dbf9ecb0d6..555a5b449ca8 100644 --- a/arch/mips/kernel/smp-bmips.c +++ b/arch/mips/kernel/smp-bmips.c @@ -46,6 +46,8 @@ int bmips_smp_enabled = 1; int bmips_cpu_offset; cpumask_t bmips_booted_mask; unsigned long bmips_tp1_irqs = IE_IRQ1; +/* CBR addr doesn't change and we can cache it */ +void __iomem *bmips_cbr_addr __read_mostly; #define RESET_FROM_KSEG0 0x80080800 #define RESET_FROM_KSEG1 0xa0080800 @@ -518,7 +520,7 @@ static void bmips_set_reset_vec(int cpu, u32 val) info.val = val; bmips_set_reset_vec_remote(&info); } else { - void __iomem *cbr = BMIPS_GET_CBR(); + void __iomem *cbr = bmips_cbr_addr; if (cpu == 0) __raw_writel(val, cbr + BMIPS_RELO_VECTOR_CONTROL_0); @@ -591,7 +593,7 @@ asmlinkage void __weak plat_wired_tlb_setup(void) void bmips_cpu_setup(void) { - void __iomem __maybe_unused *cbr = BMIPS_GET_CBR(); + void __iomem __maybe_unused *cbr = bmips_cbr_addr; u32 __maybe_unused cfg; switch (current_cpu_type()) { From patchwork Sat May 11 13:03:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 13662386 Received: from mail-wm1-f49.google.com (mail-wm1-f49.google.com [209.85.128.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4B52551005; Sat, 11 May 2024 13:04:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715432653; cv=none; b=VabldPFpKgI6R0qVxA8dJ2SSPFTivg3WlzOv4b1x4mVGZECtt1pXW64U/GA+9B6lNQrtzQJ1ZLz6RzT3mYUEkLQnKF98DFgNgbkUBdXrbVMFt/zgjXMSQHykweRzj3rY285Eh51NLRbi7Jx9JI8qhmf7tLLo3cDhasUIhzyryl8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715432653; c=relaxed/simple; bh=gv41QnGuL3jI/gVRVtnJx1R2yj7C3H+kX785mmi4vKw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Fu9jQn5zVQsnbb59iog0qzKiwhBgj/iNt9JfyreJT9SAb2qwRadKKWYVWXe36Yn6Bx5ZIYUwnbtc2Gx4iEF8Z14pqScRcvgVfNT+sGvYjdcQ8rw7lpds7y4GTmz1teZRSdpCRMuMsAjhoYZmSspFP712ULxnpS92G8HU8yh6Kz4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=fyMUOt4l; arc=none smtp.client-ip=209.85.128.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="fyMUOt4l" Received: by mail-wm1-f49.google.com with SMTP id 5b1f17b1804b1-4200ee47de7so3826075e9.2; Sat, 11 May 2024 06:04:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1715432650; x=1716037450; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=uTcgQRsbJEb2Rnar/XuE9VELae9XVv3MdL87p5ovNkU=; b=fyMUOt4leRQvBRQ280+OEB4frCXW+zjUrP+hHH2il9XdOgAihUnzJv4f9HWEH3ttMk iIKe0DTVI6W9UjKdAMm/xyHtbNj/JxnwLNHYsPx9EOdtPLAGwzeI6bILupbj1GhT1qr2 rjghwCOLdZb3mevU5czZ+mO/pxVtvENGzoqkOQ3akjFHT3DA4KJNjvAQn9fz8a/V5vr6 nwWI4QWiGDSP7EDlhJeRmFjjgHJ4Qk+VOt8/SPbXwEhdRZHedGNV3+cY8BLMcng1Tr7v cZKx71SO2kfw+/P6yA4dJSFaPHvdkMa/fcnDkc8aAtdEVIVlDECGBAbbMZ4OSl7SWCWI NFSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715432650; x=1716037450; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=uTcgQRsbJEb2Rnar/XuE9VELae9XVv3MdL87p5ovNkU=; b=TWmWoY2uVSi5og8HE98WuEvh33M1OG4w3A8LsND1m5MKeW1iyr16P/L84d5UGPOMf6 GfFslYgQ/EJYOKsf5ss/DcbK9ABoWLwTfYjZfnXlrKciTV/E0qrFLIQK93P7qDYkl7f+ g1Js1Mv13qjOCW1yDK6Ikir1Mo0DVrFeyJ7An9Q7OdWxss0ZW9D8wHE0pph0Uy3Yk8H8 VvKnNWbqu8PFtKmcwAFI79HuWXQ2RxJjD9M6r8bcYGEfqG34Tc1yEr63SxuwPnxXeHdi PCoKki46Cn5ZiAYVHS/BEfijdq7z+S5qctGz8sUO+DlOPH61WY2T++y5aaiZhCBW+ifN uCqg== X-Forwarded-Encrypted: i=1; AJvYcCWLJfOG3E4EAKZQ4IgywuD6RIr0uacWh+odhDVuiDlaa/SjS/5mHNMKOkl+qHxz/vEMw+d38+C1RGzKZs0jJiHX9X+URj7SfyqtfTzC6qAk5Oyo1wq2e1+AuBAVKRbJEQdhWuO/EGiQU9XhJp3uSlGktErk1Av/LY7hVEj8mr6pVfsH6zY= X-Gm-Message-State: AOJu0YzeOd/LOH48Q5uemLDx65UFIL4tDC453H82vW7kiLhT1YCXADw8 ZuCAfAOgpeKHU2D30uc+tA+yoAd8MxucIeSt/Ctkp1xD6qUtRSQj X-Google-Smtp-Source: AGHT+IE24mPtjzj/F9wod1AL9GtMA8zMb6O7tyNQp6M/AXNlr4c+qFI5OHx5ifPupKKK1NayapBrZA== X-Received: by 2002:a05:600c:358d:b0:420:66e:f5c with SMTP id 5b1f17b1804b1-420066e0f77mr24934275e9.14.1715432650601; Sat, 11 May 2024 06:04:10 -0700 (PDT) Received: from localhost.localdomain (93-34-90-105.ip49.fastwebnet.it. [93.34.90.105]) by smtp.googlemail.com with ESMTPSA id 5b1f17b1804b1-42010ca475asm15995495e9.16.2024.05.11.06.04.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 11 May 2024 06:04:10 -0700 (PDT) From: Christian Marangi To: Hauke Mehrtens , =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= , Thomas Bogendoerfer , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Florian Fainelli , Broadcom internal kernel review list , Christian Marangi , linux-mips@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Conor Dooley Subject: [PATCH v5 2/4] dt-bindings: mips: brcm: Document brcm,bmips-cbr-reg property Date: Sat, 11 May 2024 15:03:46 +0200 Message-ID: <20240511130349.23409-3-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240511130349.23409-1-ansuelsmth@gmail.com> References: <20240511130349.23409-1-ansuelsmth@gmail.com> Precedence: bulk X-Mailing-List: linux-mips@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Document brcm,bmips-cbr-reg property. Some SoC suffer from a BUG where CBR(Core Base Register) address might be badly or never initialized by the Bootloader or reading it from co-processor registers, if the system boots from secondary CPU, results in invalid address. The CBR address is always the same on the SoC. Usage of this property is to give an address also in these broken configuration/bootloader. Signed-off-by: Christian Marangi Acked-by: Conor Dooley Reviewed-by: Rob Herring (Arm) Acked-by: Florian Fainelli --- .../devicetree/bindings/mips/brcm/soc.yaml | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/Documentation/devicetree/bindings/mips/brcm/soc.yaml b/Documentation/devicetree/bindings/mips/brcm/soc.yaml index 975945ca2888..0cc634482a6a 100644 --- a/Documentation/devicetree/bindings/mips/brcm/soc.yaml +++ b/Documentation/devicetree/bindings/mips/brcm/soc.yaml @@ -55,6 +55,16 @@ properties: under the "cpus" node. $ref: /schemas/types.yaml#/definitions/uint32 + brcm,bmips-cbr-reg: + description: Reference address of the CBR. + Some SoC suffer from a BUG where CBR(Core Base Register) + address might be badly or never initialized by the Bootloader + or reading it from co-processor registers, if the system boots + from secondary CPU, results in invalid address. + The CBR address is always the same on the SoC hence it + can be provided in DT to handle these broken case. + $ref: /schemas/types.yaml#/definitions/uint32 + patternProperties: "^cpu@[0-9]$": type: object @@ -64,6 +74,20 @@ properties: required: - mips-hpt-frequency +if: + properties: + compatible: + contains: + enum: + - brcm,bcm6358 + - brcm,bcm6368 + +then: + properties: + cpus: + required: + - brcm,bmips-cbr-reg + additionalProperties: true examples: From patchwork Sat May 11 13:03:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 13662387 Received: from mail-lj1-f178.google.com (mail-lj1-f178.google.com [209.85.208.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 781C351C3B; Sat, 11 May 2024 13:04:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715432655; cv=none; b=YVgIES8ZrhxjpvEtBFzlikm/xDNw511PFugsuFAdaUQ3o+U4pdEybb1pGTvB8VlMxvrE9RI37S9N+JmLiE9IXdh6UuZUjPdxo0fOS2h6r1f1u2VIdD03jkWXCMe001o+w1qhmLGwkZ2mu8VtUHiGndYjYPbO58LL0Q6Pl1AtcJQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715432655; c=relaxed/simple; bh=gjN79ppeuDgEdXtGgZv95JiQxwKZq+yKjWg+0of9O4I=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=mz/bWg4W2p7GJhMBgbHAQp8+5zFykAz5bG2ih1UFn4qW1DCtU0lXaNUyU7DgXSBGEnk8tlv93pQR94XnI0eBfLdgCR17P1w/uZ4tlnOUCMZ3A49hz2AKosu1c55bN0nMwf1Gh3q4R4MRyBBFLRGQb3DiWHtUQ7xrNcLij4wNPyM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=EHO4HHx5; arc=none smtp.client-ip=209.85.208.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="EHO4HHx5" Received: by mail-lj1-f178.google.com with SMTP id 38308e7fff4ca-2e4939c5323so35643431fa.2; Sat, 11 May 2024 06:04:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1715432652; x=1716037452; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=YNOjp4zLTWeiYUMIKl1XAdQRfTNfHRMQuegu2k2+92k=; b=EHO4HHx5NZ5t4SWrkKds3B4gRgJzB+SZiFrjOeyZAW6wb9IVXqMMENB7XIVgklS1iE koXPAT5wJbvPFCF6YFlurcCZeFAqfF4JfPn07d6DRtXc0vKTbMjlKJnOJo8lWJmhCMc9 xUtqjlt5yJLRVZ0D113L3KOQCXK0IsIFa6Ooqbv6E5EnBjmXecKxdU5BpKrBUYI8X7NZ pXv0P3pEZ2r8BwpyueJnbQU65By9ykQdp48nyA1dCTNlWBI2sTDq5tx2jRajWlDxSa/H 3cRUXNrMUhfX94tsOTQ08nMhjR8Nl0LjCPpypJ7DplhXp7zI1DZY3/2v7NoWyxOkoRjh YeQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715432652; x=1716037452; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=YNOjp4zLTWeiYUMIKl1XAdQRfTNfHRMQuegu2k2+92k=; b=j+Jj7sfWXdywzKdKcdeRmwLnW2eumnplONl/Yk/mwXjDi9X5Ofqk4xil/N69N1dOJX iZ1ZdaUMstExlP29hldVuuzXZXbv59dgtQDz7pVLgXxesauMNRpuX2EJreY7D643rrv4 JWeXTu8mB4ecMBi2cCl0nlL6W8vGwcwmD4hfZ5h9J1PPFHBT/jSBLt7ccBv7CG3G4Xuv CqGSQR/BWr5OY8VyJBpBkzkCh8tZuSN3oE/dkBiyFS8ztPQ9Ceh5bXu1N05Bm4fs7HHK ZZN0IqrEnZbX/QvluxJkmh35sJhJI3KaHuWjPHuydpglczB1GSeXoPFh4PF1CCTC1Gju p/tw== X-Forwarded-Encrypted: i=1; AJvYcCW/lXzPVuGg+uF5fmE0eMD/YVk5E/2YEABUZX4rvwyDIxSuRRhvUQzRj+n+LfvHVtjnKnNgRjwFrkh+LAMENwaEM9nvrKPGggOe1R2h8TDEywXckG5IWzjQJNfQqGqkslCDGth1JMe487x2Jm1iHHU/xtPiDcPmoWhsH4veJbapb2UwIvM= X-Gm-Message-State: AOJu0YwDbiAFXa7EhMi/uNBvaoLzM8/vpto/7Qr+GUs95h10ZbX6EEjG 1LHGic8lEcZBB3E+k4SM/+AKsWQ5CFjkiJL4UYn4IMD3GGjsnUim X-Google-Smtp-Source: AGHT+IFK7U6umFCQPR5k7qTHydTHBaabWqYSzySJYm0rRdoWGKmvxAMLSBOAwNx6VHSH3bIF60VQQQ== X-Received: by 2002:a05:651c:b13:b0:2e1:a8ca:6166 with SMTP id 38308e7fff4ca-2e5205c37a2mr55614381fa.43.1715432651568; Sat, 11 May 2024 06:04:11 -0700 (PDT) Received: from localhost.localdomain (93-34-90-105.ip49.fastwebnet.it. [93.34.90.105]) by smtp.googlemail.com with ESMTPSA id 5b1f17b1804b1-42010ca475asm15995495e9.16.2024.05.11.06.04.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 11 May 2024 06:04:11 -0700 (PDT) From: Christian Marangi To: Hauke Mehrtens , =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= , Thomas Bogendoerfer , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Florian Fainelli , Broadcom internal kernel review list , Christian Marangi , linux-mips@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v5 3/4] mips: bmips: setup: make CBR address configurable Date: Sat, 11 May 2024 15:03:47 +0200 Message-ID: <20240511130349.23409-4-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240511130349.23409-1-ansuelsmth@gmail.com> References: <20240511130349.23409-1-ansuelsmth@gmail.com> Precedence: bulk X-Mailing-List: linux-mips@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Add support to provide CBR address from DT to handle broken SoC/Bootloader that doesn't correctly init it. This permits to use the RAC flush even in these condition. To provide a CBR address from DT, the property "brcm,bmips-cbr-reg" needs to be set in the "cpus" node. On DT init, this property presence will be checked and will set the bmips_cbr_addr value accordingly. Also bmips_rac_flush_disable will be set to false as RAC flush can be correctly supported. The CBR address from DT will overwrite the cached one and the one set in the CBR register will be ignored. Also the DT CBR address is validated on being outside DRAM window. Signed-off-by: Christian Marangi Acked-by: Florian Fainelli --- arch/mips/bmips/setup.c | 24 +++++++++++++++++++++++- arch/mips/kernel/smp-bmips.c | 6 +++++- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/arch/mips/bmips/setup.c b/arch/mips/bmips/setup.c index dba789ec75b3..c7d83f0c7b05 100644 --- a/arch/mips/bmips/setup.c +++ b/arch/mips/bmips/setup.c @@ -205,13 +205,35 @@ void __init plat_mem_setup(void) void __init device_tree_init(void) { struct device_node *np; + u32 addr; unflatten_and_copy_device_tree(); /* Disable SMP boot unless both CPUs are listed in DT and !disabled */ np = of_find_node_by_name(NULL, "cpus"); - if (np && of_get_available_child_count(np) <= 1) + if (!np) + return; + + if (of_get_available_child_count(np) <= 1) bmips_smp_enabled = 0; + + /* Check if DT provide a CBR address */ + if (of_property_read_u32(np, "brcm,bmips-cbr-reg", &addr)) + goto exit; + + /* Make sure CBR address is outside DRAM window */ + if (addr >= (u32)memblock_start_of_DRAM() && + addr < (u32)memblock_end_of_DRAM()) { + WARN(1, "DT CBR %x inside DRAM window. Ignoring DT CBR.\n", + addr); + goto exit; + } + + bmips_cbr_addr = (void __iomem *)addr; + /* Since CBR is provided by DT, enable RAC flush */ + bmips_rac_flush_disable = false; + +exit: of_node_put(np); } diff --git a/arch/mips/kernel/smp-bmips.c b/arch/mips/kernel/smp-bmips.c index 555a5b449ca8..20e2fb10022d 100644 --- a/arch/mips/kernel/smp-bmips.c +++ b/arch/mips/kernel/smp-bmips.c @@ -46,7 +46,11 @@ int bmips_smp_enabled = 1; int bmips_cpu_offset; cpumask_t bmips_booted_mask; unsigned long bmips_tp1_irqs = IE_IRQ1; -/* CBR addr doesn't change and we can cache it */ +/* + * CBR addr doesn't change and we can cache it. + * For broken SoC/Bootloader CBR addr might also be provided via DT + * with "brcm,bmips-cbr-reg" in the "cpus" node. + */ void __iomem *bmips_cbr_addr __read_mostly; #define RESET_FROM_KSEG0 0x80080800 From patchwork Sat May 11 13:03:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 13662388 Received: from mail-wm1-f42.google.com (mail-wm1-f42.google.com [209.85.128.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 53A7053368; Sat, 11 May 2024 13:04:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715432656; cv=none; b=l+6pmfykZWIrXv2vWdf2j+IdemI2hE7VOI/y+/y3LPjYh1Q+VpwBEAR9oX8N0Jp841gCnqno9cJ9tdUvWIstyctsSF4ZWdgpFFtLmegSdr+PvwdkZIXdyhGXw+SBykn22NhgGOaJApd6+LTOg70uqGkgIDGU9Kigbrv3RQDkIEo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715432656; c=relaxed/simple; bh=yxOj5YfSwj2DTCNzCutbgmJ5WuKiiT3kbxTl71R4Wu4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=UO7S1wnTqNZa4YwSwpQEwj99AB7Q0Mt4PK/Qcpj7XvJW8+Vrh7fDzrfQuVV/vv/w4xiUmN1WmKT7eT4IEbzVZBSVP3kmmY1FW0LxyfjPbAg/6sx7yHEdrZHmHZGEhqUXqTgUDqGITQoQyD4bJ/qjRjUefuCBjuUS4GK5kd9L/Js= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=RcO22sk9; arc=none smtp.client-ip=209.85.128.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="RcO22sk9" Received: by mail-wm1-f42.google.com with SMTP id 5b1f17b1804b1-4200ee47de7so3826155e9.2; Sat, 11 May 2024 06:04:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1715432653; x=1716037453; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=CrwA2vIrlWfZjdips+U6g09WGPgGGcS7uLLAmHynIVM=; b=RcO22sk9GxqkwZ3rck1Uwsj9MCll4+QgD/Q15jfXjqZpDbtJ+Oepj6hTiSpBWaT/1z 75p/NOabouYwV90TrlLfxHJHqMMTBdnEDJyv38bPz3TR9Ft+VlHjNekwFlrAL2PvODgG SQ7Tq6+/v2ZyiTD0U+1fGek/xqP09XIlFo0+MS7/OcWiZtSsp0Qx3xAHrHc0ebhRByaJ JmtwnsAgbFt0KI4UWrLR+W9YDLECzNmFhg1y1uzcCkVwExPvUygI0jDPfdsrcIGR7HXQ g/jqjpBGMff+3supla9V4+1lWr17MyniwGSbQRhE6fs0U/NOvbG7wNnNU5p1vipUUIH8 f1ug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715432653; x=1716037453; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=CrwA2vIrlWfZjdips+U6g09WGPgGGcS7uLLAmHynIVM=; b=totQPlaEJhe5CnhhNefhXv7NjAiXfT9rbJH3Lisk8GLpvXZu8TUm0wFqQeMIAK56iu d4rvwFuDpC804/SoDYo/KHiVKnnbNYVn/KcTFdGXM8Da76UP1hNkY8gF0w1fSvr0oK+P u2d9aya2SGPeM9GQpIHJ582ZFZY6OFrSQLimyLWo/vksXUdm+9ji/4pB/pPOc/FRkmiP anzRMD3LSffZVzIkIlRvdWY6wMYFVzDoh1unGQ3KnANxn6wnTpYMurAEMQZ6New4+VQY rDTSjw/NYI//bRwPJXEFfPHJzaKMXZJu+xLX+BmMJr26pgJCDTiO7F6T6VPenb+Mrzn2 4qmA== X-Forwarded-Encrypted: i=1; AJvYcCVs6TY97YuvMdfqjkEt/mzK0VfFlH64RfUYFOq65HF6CmXWugPiVtY6OxgNsL2OGuEERs4gXGlfG9e5wTPCEV+PctZG0jmKKeWkRoKD4svmL0lCgKijhqP95xfe13EC0FkINEX7FFCp+Zv/P+mpxsDncmwHnP2Zbi/Y8TVdegGShFTMojU= X-Gm-Message-State: AOJu0YxzyYYiBVmClSx5S0D1mXgGdMGL2TV5hdVYR6Jt+BLInMehZAja wpF+NG+JUfMu9UirD4PGBmk51YLh9FiuWDZ4bhp2cBI0hHB1o3Sb X-Google-Smtp-Source: AGHT+IH6zVREnewqTrqvb/pUGLF8t9A9Pi6KWKq0s48v6RX42K/A72ugZcftF2KiD4CDa4ZO3tSsYg== X-Received: by 2002:a05:600c:4286:b0:418:fe93:22d0 with SMTP id 5b1f17b1804b1-41feaa397f7mr35465605e9.11.1715432652606; Sat, 11 May 2024 06:04:12 -0700 (PDT) Received: from localhost.localdomain (93-34-90-105.ip49.fastwebnet.it. [93.34.90.105]) by smtp.googlemail.com with ESMTPSA id 5b1f17b1804b1-42010ca475asm15995495e9.16.2024.05.11.06.04.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 11 May 2024 06:04:12 -0700 (PDT) From: Christian Marangi To: Hauke Mehrtens , =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= , Thomas Bogendoerfer , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Florian Fainelli , Broadcom internal kernel review list , Christian Marangi , linux-mips@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Cc: =?utf-8?q?Daniel_Gonz=C3=A1lez_Cabanelas?= , =?utf-8?q?=C3=81lvaro_Fern=C3=A1ndez_Rojas?= Subject: [PATCH v5 4/4] mips: bmips: enable RAC on BMIPS4350 Date: Sat, 11 May 2024 15:03:48 +0200 Message-ID: <20240511130349.23409-5-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240511130349.23409-1-ansuelsmth@gmail.com> References: <20240511130349.23409-1-ansuelsmth@gmail.com> Precedence: bulk X-Mailing-List: linux-mips@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Daniel González Cabanelas The data RAC is left disabled by the bootloader in some SoCs, at least in the core it boots from. Enabling this feature increases the performance up to +30% depending on the task. Signed-off-by: Daniel González Cabanelas Signed-off-by: Álvaro Fernández Rojas [ rework code and reduce code duplication ] Signed-off-by: Christian Marangi Acked-by: Florian Fainelli --- arch/mips/kernel/smp-bmips.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/arch/mips/kernel/smp-bmips.c b/arch/mips/kernel/smp-bmips.c index 20e2fb10022d..52324738cbb3 100644 --- a/arch/mips/kernel/smp-bmips.c +++ b/arch/mips/kernel/smp-bmips.c @@ -626,6 +626,23 @@ void bmips_cpu_setup(void) __raw_readl(cbr + BMIPS_RAC_ADDRESS_RANGE); break; + case CPU_BMIPS4350: + u32 rac_addr = BMIPS_RAC_CONFIG_1; + + if (!(read_c0_brcm_cmt_local() & (1 << 31))) + rac_addr = BMIPS_RAC_CONFIG; + + /* Enable data RAC */ + cfg = __raw_readl(cbr + rac_addr); + __raw_writel(cfg | 0xf, cbr + rac_addr); + __raw_readl(cbr + rac_addr); + + /* Flush stale data out of the readahead cache */ + cfg = __raw_readl(cbr + BMIPS_RAC_CONFIG); + __raw_writel(cfg | 0x100, cbr + BMIPS_RAC_CONFIG); + __raw_readl(cbr + BMIPS_RAC_CONFIG); + break; + case CPU_BMIPS4380: /* CBG workaround for early BMIPS4380 CPUs */ switch (read_c0_prid()) {