From patchwork Tue Jun 11 11:32:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 13693496 Received: from mail-wm1-f45.google.com (mail-wm1-f45.google.com [209.85.128.45]) (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 F1A3C17545; Tue, 11 Jun 2024 11:32:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718105538; cv=none; b=OOetfJeuBNr5sCU3q1ej+2FzCnClaDwmomtt/qCkdzH26Yn9anJX4NWHkAj9TeBQNGGkGL5p6U+vM9tJEbQWFPKIP9HzweFaMLadxD5CGdbigsJy+XlbyrdNKrWWLgHg3WHF7/vmLWA+fKekrzHf6ZoYnp2IP3Khuym+WJKcF1Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718105538; c=relaxed/simple; bh=KYM3RpgXB+bRDfX9kBzzB6kmbYZ7NlFFZJ/83yFFCno=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=AiEaRW1W58WOyWvL22E8itiBBO7/lNifl/JnFlsB0F2H9yS9xOXvq6jYSwVXzC5GpAikQybFRsBiIiB2fObLeza3CCsK+EbJtRHt8Dt/BXu8DWc1j4yl7sx0dLOSkN7pUvhqnxk/JYky6wCKBrFpjyS4cNNlW9aAjNuwzcn2ZcM= 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=FAc5JQ78; arc=none smtp.client-ip=209.85.128.45 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="FAc5JQ78" Received: by mail-wm1-f45.google.com with SMTP id 5b1f17b1804b1-42133f8432aso6788635e9.3; Tue, 11 Jun 2024 04:32:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718105535; x=1718710335; 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=clrALCvP0Lnnrc9ChxXlKIuUYraQmBIpiwyzFSMJ4E0=; b=FAc5JQ78H4IKd4zPPq9+X3TuRBwduBAW9SHyNpMbDJN9ddmePRBb4YCfkj7P/rT5Mj J0gwqOEnHidAJ2edTh69YPac0DyE+sCUoNtGTYWpc0VVF1UNsBdiZDyBoW1PX+3uTZCh RXAAqeqC/HSBraBA/8h4DeigXQXYJjCnnMKgFbrlQLzz0N0W4RJQHwLIzNrJJGMTnAWq 3jfBq6T0r26vXl9H4AFtPx1x6BJFB7am8lu0pySqpEvl1gFn0lUCB9VeqFKN4ksPbKlp oLjPnPp0FIbJxvmv1b1pWdtxdlBTLHKSzw3LzJ0mr5w6py7+YeyyA4ymmiGaD+l7A1OV Md8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718105535; x=1718710335; 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=clrALCvP0Lnnrc9ChxXlKIuUYraQmBIpiwyzFSMJ4E0=; b=u0BvGVKqn8d2l1mPKBMeDrhCx+u/2WkcnFnKT+5SHEEIlcy1RseC30wyEjWi19IU1J J/JZBd49Zqj02CFHXMwfLR4XRRKDPAEbvth4m8zMycSrzneyOSbF6B826IbbEdHFYZJd ZWZ3gJQYv0iUprQt6RlSTpcJ0kuSh5DAqJAv5UZ6T1OaFlTS1OEkBga51GCCegMVOlAM aB0C0J+8Be4GpF/zK/hwQouOxxN48we1riak2sEzFUGCXItvgl5pR5+xcMAIZkNwcvYv 4X8Hhsj3FZ/o/5Egwa5s+G+ymmeGK+ehuZoyegs94N5NZRqsVrH80oqM1UNhpLDj6KE9 qrng== X-Forwarded-Encrypted: i=1; AJvYcCXwiiZvkkSbfABQSYV9vXVou0wSlvSUf1TXNr63MUJNVmrV3RzBMY/SgQa/KT2vbnBPDg4K7jMRu7PfvuVgxQZfFCh8NrRdyrQIP+DBOyW3p7a0EPNs5UKEvUdFQWQqgAVqwEq2DQ/0PUX6OKKHvxvXG5hwYh4SkaA/NbqYVqqVCFHF2Zg= X-Gm-Message-State: AOJu0YxHS7Y4UYb8K7WDvnw5++Qa2zv6KGFjj9H79KwjdXrvjWcko1Lu r1XoeFhbafVq4ZxP543ANS0VKPsOb5tRxUBHCys/DNbsIZ9ecqiG X-Google-Smtp-Source: AGHT+IF+Sk9O/o2G+14IsflJT/qS0GW5V1JplYzYscWpyvFgu3n0dSPLYPpPIR8X135O1QOsOuxJ4Q== X-Received: by 2002:a05:600c:500e:b0:421:81b8:13e5 with SMTP id 5b1f17b1804b1-42218313ademr34350675e9.3.1718105535244; Tue, 11 Jun 2024 04:32:15 -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-4227467990csm2473505e9.1.2024.06.11.04.32.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Jun 2024 04:32:14 -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 , =?utf-8?q?=C3=81lvaro_Fern=C3=A1n?= =?utf-8?q?dez_Rojas?= , linux-mips@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v6 1/5] mips: bmips: BCM6358: make sure CBR is correctly set Date: Tue, 11 Jun 2024 13:32:04 +0200 Message-ID: <20240611113209.8142-2-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240611113209.8142-1-ansuelsmth@gmail.com> References: <20240611113209.8142-1-ansuelsmth@gmail.com> Precedence: bulk X-Mailing-List: linux-mips@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 It was discovered that some device have CBR address set to 0 causing kernel panic when arch_sync_dma_for_cpu_all is called. This was notice in situation where the system is booted from TP1 and BMIPS_GET_CBR() returns 0 instead of a valid address and !!(read_c0_brcm_cmt_local() & (1 << 31)); not failing. The current check whether RAC flush should be disabled or not are not enough hence lets check if CBR is a valid address or not. Fixes: ab327f8acdf8 ("mips: bmips: BCM6358: disable RAC flush for TP1") Signed-off-by: Christian Marangi Acked-by: Florian Fainelli --- arch/mips/bmips/setup.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/mips/bmips/setup.c b/arch/mips/bmips/setup.c index ec180ab92eaa..66a8ba19c287 100644 --- a/arch/mips/bmips/setup.c +++ b/arch/mips/bmips/setup.c @@ -110,7 +110,8 @@ static void bcm6358_quirks(void) * RAC flush causes kernel panics on BCM6358 when booting from TP1 * because the bootloader is not initializing it properly. */ - bmips_rac_flush_disable = !!(read_c0_brcm_cmt_local() & (1 << 31)); + bmips_rac_flush_disable = !!(read_c0_brcm_cmt_local() & (1 << 31)) || + !!BMIPS_GET_CBR(); } static void bcm6368_quirks(void) From patchwork Tue Jun 11 11:32:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 13693497 Received: from mail-wm1-f41.google.com (mail-wm1-f41.google.com [209.85.128.41]) (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 8AB5E17B4FE; Tue, 11 Jun 2024 11:32:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718105540; cv=none; b=W6OZikJPa3N3Qu1dSgpq862FXJ9ZU+CX9zE6ET3G+ePhzjrQIHpf5MpolDl6QV8LR8BP2FQ6mZ0TCEVTyo27O0CsqWffyn4WDmazqL3YQHbSLD59CBGaL6QDhEJU2hsuJsG4frfg/Fv6UNb0DoJeWs/VzYiqlfQj/EaIlOFtmNE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718105540; c=relaxed/simple; bh=96fjUGXbzrw3k5xl5NUqCMW2L7GOt6QRlWz3M6YrZiI=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=e19cVVheS/6VCwbj/pH5Hh1ESXLanO/9m4/fjNvKUl7AWeUS8TShgvqbGKJXrhWcF5NBfWq4/ODUDQk8acix7FPbxqq/fBiG09/ZfnSXUB8rNOExnCsUWoe39uT82Tc9yqZLxzTbPJlb+yw/qKGiW+rEMRiyWlELBRTGFCmE0sc= 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=FclkEEvJ; arc=none smtp.client-ip=209.85.128.41 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="FclkEEvJ" Received: by mail-wm1-f41.google.com with SMTP id 5b1f17b1804b1-4217990f8baso29010725e9.2; Tue, 11 Jun 2024 04:32:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718105537; x=1718710337; 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=6B1NQaDMHjP+qp3yd7SriWtlaqA+mWbOie0xS43jhQU=; b=FclkEEvJ2Av9jKTjs83SlJZ/fm2TCvoYNvAnfzeM5/vAt3orE2QYF3N65s83KSRL/l seNhaLGqcmQfuoVShVMaKNPBGb9MljzNLc4TFZi/IfwLPiBsQkoOHLHRX34Cm8oR757R sSet/LDfPe4QkEfekLuiL09WE/PS8bF5lPrZzoQg/NZ9s/xy1rUYj8apSDQirVNgQ4Ax rxbH4lzZ5rqV90oxgfNGz+OW0RgGcllqsETsu4TvLgM9TEYYcgK5QOTTqlVj9UecuLie AdyrZYp/4QHAS/z/SECh4DxI9PubxFp83s/9NtCzI09KCVIUBG44jCseA62ghC/Dm65l baEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718105537; x=1718710337; 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=6B1NQaDMHjP+qp3yd7SriWtlaqA+mWbOie0xS43jhQU=; b=rnICC+nuz66GsdZc1Bthl0g6ojQKS8uvbqlpu4wTrbOAIODEYmeR4OYNHfeTa5BP9j +6Pq95eIgfPQyqoRMHHiABvfTt+WunpFwgNbF5ko/TPIgF+M5gic6GJXumrTy1hYVN/r wDDHJcfOhxdmrRdYLBNHffdRZNv1pb43jfLpJtY0P4Mzu8hhC69o35hLu6G59mmHHq2g GIvBTVQDBpIGUPzxQOo6H2owsxYAWHik7bg4mw1Hm7d7DpzMNnu8NjKzWeqSttw0YDuK 8e4rIkIr6k/NnVxNw1GM6dWtH0wRAMn7esThCTH7UdnxnuQ1giLeEArF7UfPCSUwvcth HcBw== X-Forwarded-Encrypted: i=1; AJvYcCVa7VBQh2b0EeaVly9QY7bhA7eNr+8YVVyulD7DL1nVTOFSgWUg7ZdL3zsM64+Ho1XjyM0cvBWQ3c4t3dnFU0RU818uxHAfm7nisNi8FeIb/z3E8QLHrRtmZpL3nOdH97w2jh8l6IPiHfB65AMCVLseZdBD0k/dDG3gi3vkvuThpipPGow= X-Gm-Message-State: AOJu0YzSpFyCQ0XFkWjeKCKQLUEQMAcWzNF1j0Wh5LuZzOUrkYvfduWx wXxafgH6bLA70gLTpPvPa8wiASV67adBJ+ZPaxiQh4i+/Xrg2Y0U X-Google-Smtp-Source: AGHT+IGyMiLtimJxjO1eIM08Ovj4/mMb4wqZrpQO4GJumeaDPqHKcjxArBKjSPVsIMmq0YyI5EVFEg== X-Received: by 2002:a05:600c:350f:b0:422:1163:4488 with SMTP id 5b1f17b1804b1-42211635440mr36385425e9.25.1718105536600; Tue, 11 Jun 2024 04:32:16 -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-4227467990csm2473505e9.1.2024.06.11.04.32.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Jun 2024 04:32:15 -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 , =?utf-8?q?=C3=81lvaro_Fern=C3=A1n?= =?utf-8?q?dez_Rojas?= , linux-mips@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v6 2/5] mips: bmips: rework and cache CBR addr handling Date: Tue, 11 Jun 2024 13:32:05 +0200 Message-ID: <20240611113209.8142-3-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240611113209.8142-1-ansuelsmth@gmail.com> References: <20240611113209.8142-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. Acked-by: Florian Fainelli Signed-off-by: Christian Marangi --- arch/mips/bcm47xx/prom.c | 3 +++ 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, 15 insertions(+), 4 deletions(-) diff --git a/arch/mips/bcm47xx/prom.c b/arch/mips/bcm47xx/prom.c index 58fb7c2dc3b8..10bdd3e366ae 100644 --- a/arch/mips/bcm47xx/prom.c +++ b/arch/mips/bcm47xx/prom.c @@ -33,6 +33,7 @@ #include #include #include +#include #include #include #include "bcm47xx_private.h" @@ -110,6 +111,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 Tue Jun 11 11:32:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 13693498 Received: from mail-lj1-f180.google.com (mail-lj1-f180.google.com [209.85.208.180]) (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 240A017B432; Tue, 11 Jun 2024 11:32:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718105541; cv=none; b=HDzaZFF8StPG8vNyAxlHw5LyiCuqd8A0C5zBf1oz4YWx1tyBHBPcAdSsfJZaRIAhl5sMi4xb1ZsDLjvltCVoD0muc8YjB4rtI1iA2HklYn5/idWSAqossdBCmvMIrOCLnE+On6tgw17zXvVFZjBaX3i11AhAWPIUr/wsE/k7ces= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718105541; c=relaxed/simple; bh=gv41QnGuL3jI/gVRVtnJx1R2yj7C3H+kX785mmi4vKw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=VpTOa3H1pAVe3KZ4F06bBoZ3FcNasx/QMoXt1torWu67zx+iKh/XX91WG/n12/ZE+U5LwGeEmjID72+BnZA5P8U7TZiNkzfGWxKHsz0Q49+PFqgbaLIuBfRmzCvPQlKZGr4plXBevs2Q4n1gruYOtrQjZN0u7E2Pj3qvnasKA/Y= 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=QN4UGpph; arc=none smtp.client-ip=209.85.208.180 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="QN4UGpph" Received: by mail-lj1-f180.google.com with SMTP id 38308e7fff4ca-2eaae2a6dc1so108615261fa.0; Tue, 11 Jun 2024 04:32:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718105538; x=1718710338; 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=QN4UGpphMgQeoRL7jYmMnAoi7YmFwYyENl48C2LEkwIggDGE27lsG7SfPWlj+xb0o+ q146fKSa/o7WrDUQm37PF5b6NgC994Ic+qHDWAf8Bxv9ve27AAWhBTJxhQVirgsbQx3y 9neoSz1nU6fhtHnG4+Zbcw6msNQXvtvXnIxdz/Z3gSJ6CRQuiTRujcXWflQo7B/urJ5a C3gWxpmLsePEHDxaiM7syoXK9VOTFQtj071jZJhMRJ/7AvKKnQ66CpgL0TY+fpihgAOV 1B9KcZoj8P27Flm73QrOQZedd+fwCXo9WyK1/pY5myIZn7eQGvuy2cWITlv7HWkukJXq BkSQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718105538; x=1718710338; 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=eMbUtjb57pQb9f7RUUG4ivYWzHKZddMLKmRgYnQfdhtvFAG4d1c9wgSl5Cbv5g2m94 CAgkMr2jmX+NXLoYuviaC+X+9AYut2TlGThU2omOitO0x+Ix9Hq9uEdfr4r1Xn8A215k 0jhDoUhyFfZD0aTGXNi7VvuEuQCDH971mWchOmMcmCmb80VKGbdJ2NSBWte05tBpNiNf oRMi9RK+WapI1RxPZCTB/JWR4En8P4T/QOiMEj2G2bzz9HKlMGvt7QjZ+PJ2wgPGVByZ GNZKg7ImDTU2HTad+wRBwQB4lskhNBvE2FCfOm0/5ZvDm0TMKHpNlLu1c62yPzxfST3B jI0g== X-Forwarded-Encrypted: i=1; AJvYcCWI5rlkA+B3BhK1tCvU7d1FrT7RU/hOLKAKyNEkTNbXE9dF9BcFbSoOTEsI6I87Y1Ig0lNDtlqZUozycsKzj+j7ELC7aG1segZUdqcvqcB98TgPHADQx1kIvNnIpn1b/LjHkRE1y2VIPD2WT88z3CFprLuyFu3FVDkMTEtLKYj3XlIaiJA= X-Gm-Message-State: AOJu0YxQqR3QxkGTFnQMZa22nj/fzOvA/LtcPeL6wqfa1lPCfjq3nt9n t0ExzF3wd+dLTpH4zSGv/tJrMHOFie/4RimhWQdQcAnsNuyhS73p X-Google-Smtp-Source: AGHT+IEXq1yuRAnXyUBpgYoMbndq1AzH96Xgtj1NJLXOb5I98HHRuDqTssxZikN/xDiSziax3zcFig== X-Received: by 2002:a2e:a418:0:b0:2eb:e7dd:1f88 with SMTP id 38308e7fff4ca-2ebe7dd2244mr42073671fa.25.1718105537886; Tue, 11 Jun 2024 04:32:17 -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-4227467990csm2473505e9.1.2024.06.11.04.32.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Jun 2024 04:32:17 -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 , =?utf-8?q?=C3=81lvaro_Fern=C3=A1n?= =?utf-8?q?dez_Rojas?= , linux-mips@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Conor Dooley Subject: [PATCH v6 3/5] dt-bindings: mips: brcm: Document brcm,bmips-cbr-reg property Date: Tue, 11 Jun 2024 13:32:06 +0200 Message-ID: <20240611113209.8142-4-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240611113209.8142-1-ansuelsmth@gmail.com> References: <20240611113209.8142-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 --- .../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 Tue Jun 11 11:32:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 13693499 Received: from mail-wm1-f53.google.com (mail-wm1-f53.google.com [209.85.128.53]) (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 F367517BB34; Tue, 11 Jun 2024 11:32:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718105542; cv=none; b=bfMPski6dbTzP7eEcB0zdGjWI6o+rvtu8oLDLp/naPqW1aIGJoaT8hROqMf+o5I4UiOXAR7V843bGtesdbV8fum5oH4XEK6ZhXsxvhG5gXSKwyFJmt3sqScy4Vcm1vAhp0cpxRnzwjj+9zDH0DOWleoGREfb0qy6/eF4V8mTIZ4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718105542; c=relaxed/simple; bh=gjN79ppeuDgEdXtGgZv95JiQxwKZq+yKjWg+0of9O4I=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ptGsXcBKtz3nXEI30l1ZZGhrUzV/IuiZLI01x9uzvLy+97h3hae4cGvYn9Toq5UCllya05u2d8IeEHWNAbscBnSml+3rodsCFY9ozV17AcO6SE6trodHelFuhBZ3/ZSl79Q0EScStlH/laear/BADWJ0K8RQ9YhV7/iYLCmnMTY= 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=SXoVRNs6; arc=none smtp.client-ip=209.85.128.53 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="SXoVRNs6" Received: by mail-wm1-f53.google.com with SMTP id 5b1f17b1804b1-42172ab4b60so30495685e9.0; Tue, 11 Jun 2024 04:32:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718105539; x=1718710339; 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=SXoVRNs6Ndenbr4QklfC5dJRSIxeBvLyih70b8wUjFIV8wbJfyG0+i/0yE47yf8Uyo 0AHQF08v7zafgKpfw7n9/RTCpQEhd/84CorVNaSElQvwM3033gDqzCpuByB1xViYfezi hbxy/aW32VyRKJVaBYa0q6WrFEIZOb3NqH8Z+m8wSRL6vCVjdBKDNr7/U/mIpLFhc/NZ wgbI3mS4mVhT885FU3amydck3SzJ7sVZ/CHwz/BetSV54vDkCM8NnDxkvQN3PIVCxlgu rGGkhCCl/TZh7jukxxx7A41ZIcdSl6kEVOA/bwWBFIoQ8UPOB5x+v2jcKYiP3JqMKxU7 zntA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718105539; x=1718710339; 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=ABgixQtLzuXZARgdGUisZj7VuCMOMlaytYoxY7vwaGQika18O6mcdEsetILqHZzDzz K/S2gvLJ/PkbeYYo6K31aLBzMN+/wm3L0u4ZEgo/DeRH24JrEUrqO8/leCVDZGySw8pS LiSaNp5bPC4wVE2exGT8kBNjbewbpCf4BHWbUIvCFFDWKuqxRVJr2vTG9EO/2jiLTuQU VbpTckwRugalMgYsD3IYnoPYIG/69Yz4YM2lhneuMsRXgZLK1+423CRT1mWyN/0ZZI2C vzvvj+HQCv8ST/sDdgvf0+9URjc6AIzmqzQ+UyTjQgfJmNBuTS4vA4OgmSz6B8EOGIQv tqYA== X-Forwarded-Encrypted: i=1; AJvYcCV0xxRKsgXX0zmDLtMyYJxFWMsVibwxvezsODTlUtrqlPwMZ2rWVz3Us2/tG64NYzKDOWrgB9Na8LgjvhHVQ2UIKug/BQfJMDWO/RL40ZqGK99ekP+szpal47siREPoL0laPy1wOQA2xcHAlKMvxegQW8Fiz1w3UFLlBz2u12XY1AMPfRo= X-Gm-Message-State: AOJu0YyebQpRuwATpILW5dQjx3MiY0vWCebqqIkJ6+Kj+KIlH99tzAV8 fIiisirFqZbKuXnJlgpYPV1x8NNzkZX3KRljg7ngzpwiZnOBVGN4 X-Google-Smtp-Source: AGHT+IGoEpHx30CljJ4XSzkjcNVYajHcqgxCLQW9MSOTWpsGTqC3JX/Dv4Hfrfx08attDnLhrbMgmg== X-Received: by 2002:a05:600c:19d2:b0:421:8045:6221 with SMTP id 5b1f17b1804b1-42180456a56mr60233545e9.30.1718105539345; Tue, 11 Jun 2024 04:32:19 -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-4227467990csm2473505e9.1.2024.06.11.04.32.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Jun 2024 04:32:18 -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 , =?utf-8?q?=C3=81lvaro_Fern=C3=A1n?= =?utf-8?q?dez_Rojas?= , linux-mips@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v6 4/5] mips: bmips: setup: make CBR address configurable Date: Tue, 11 Jun 2024 13:32:07 +0200 Message-ID: <20240611113209.8142-5-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240611113209.8142-1-ansuelsmth@gmail.com> References: <20240611113209.8142-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 Tue Jun 11 11:32:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 13693500 Received: from mail-wm1-f46.google.com (mail-wm1-f46.google.com [209.85.128.46]) (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 53B7017C20D; Tue, 11 Jun 2024 11:32:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718105544; cv=none; b=iYXVVGMD7LPM9LaIfX44ZPH4YQzeIxpkZxZzT4Hpj8fkoQ8v4X0L2zFpz0OryPOuU3mZlXNimpp/KQcmvEdrfOvy3yN5UiI/S2pip2PhrAy9iGZgHjaaFPDPT8V6U41yV7hQzyNU/hjceRkr3ePpjiy2f61FGZONXWwwO1j1vec= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718105544; c=relaxed/simple; bh=wTDGlpwvDV/tYVSnvnYnjRhtXn8bRII9NTQtrKlKeew=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=lphvQ3xbuC11kojOypYP/rqcMWJDpuECWY8XWwZFomFmX37o2V9B0HlUYaTiqHCZmr2rmLeQ+4sl3z9zjuOgL3yt9wyOlC5/pbiGwO7eHgbocksap/apzfdhuW00gLbz3WCBTOdO5J+duFPAdPfMS6JQRNhI7/CH0MLsSWpmFck= 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=e1FKzCg9; arc=none smtp.client-ip=209.85.128.46 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="e1FKzCg9" Received: by mail-wm1-f46.google.com with SMTP id 5b1f17b1804b1-4217926991fso29620705e9.3; Tue, 11 Jun 2024 04:32:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718105541; x=1718710341; 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=DUr5nSYv5tY7HQINi2nTpc/x5kG6Ztbr9RxJD3fNnUU=; b=e1FKzCg99nHZM03/ks5kViLDnq+mSXthPv//GiKV99qg/c6A8WQanVHTgvZCyigUyl JwCHmMBY6WYpsd6qYvrPWwOShSMy3TzfakI3My0tZSep63smFuOUX5dSzlMG71Q7pG+E pkAQytPoZ00jJJcgQLRo7B5sOl4U1M14JX9Xsq+vLk7BzMmFcNHhwqb5NaYqn2wVTZVa 9SDqCgFK6gG3o+muAP7YSUG+etXt8mXUIwk0rN3osO8s1qiU6BOR71WJ+x6MES1T6lz6 dMuGp53teUUE5f8AlwjcVfKcrKOw1YxgvnFTQgWihsJQ5NzUvOtSLAEa2p+z5JRoX8Go iAIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718105541; x=1718710341; 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=DUr5nSYv5tY7HQINi2nTpc/x5kG6Ztbr9RxJD3fNnUU=; b=kcl+u3F1slM3f15GB/WWedOlgKJWJ1W5xa3FFUTYMYIKgCE8SBzeP8vWVYzt5ixE+n u1eTp8kTsDpjovYfdTUpLNroJHxqgzDf84SWVH5DV3owb+k6T6FXEpYDTiXAYnLR/ZrZ t0SuWrh8BKhWGdng2tudUfy/u7cgdlbJ9ztZmGgAkVSBabok6HugL21VseIOrPBFUxFZ mFsZXaTthEBdynKNvcroM9qk2XEqXKIrJ4sgsxVyy5YZNEFBTaBcChG7bjgWmiPWlsNJ xE8Gs2d+yv95nLxD7fcMARjt8DQ4RmrhiHcJ+LmPWmjaYhdrvn0Ee9BOI8NPzpUaNj+C cqRA== X-Forwarded-Encrypted: i=1; AJvYcCWubeiJYvaYBnJHXRuZmGC+1y4d8Y81Re5MAQ79pDQD4l9IgJmjSWLmrDNhUzF7YBikSum2A81exLlPBJGpn5i8p4PaQ6OimgEtPwKzTl+oxTOVDI2SZBUmqkqDtwBj+6P0Xv9q2pnionKeYCGap6t44aSSjlJS9DYKpIdQUTMR6yG8hEU= X-Gm-Message-State: AOJu0YxlScOsFH0Fp6m3TICM9juZp1xSXZqFIgnGd4I8CNQPuxq3EAjh Z3n5yER+hKJonSaCcF22nHpV9sOKrwnghaByGBgPdZjXbE/CSOMjco/SqQ== X-Google-Smtp-Source: AGHT+IHknZho3WwfJIZcfYix14c2tO11q1f1ovDFm6NviLABNMYl+fM8KHPpVL5yeiD3xRWqRerNiQ== X-Received: by 2002:a05:600c:1d1d:b0:422:5a9c:fdb7 with SMTP id 5b1f17b1804b1-4225a9cffc6mr13062365e9.29.1718105540603; Tue, 11 Jun 2024 04:32:20 -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-4227467990csm2473505e9.1.2024.06.11.04.32.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Jun 2024 04:32:20 -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 , =?utf-8?q?=C3=81lvaro_Fern=C3=A1n?= =?utf-8?q?dez_Rojas?= , linux-mips@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Cc: =?utf-8?q?Daniel_Gonz=C3=A1lez_Cabanelas?= Subject: [PATCH v6 5/5] mips: bmips: enable RAC on BMIPS4350 Date: Tue, 11 Jun 2024 13:32:08 +0200 Message-ID: <20240611113209.8142-6-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240611113209.8142-1-ansuelsmth@gmail.com> References: <20240611113209.8142-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 ] Acked-by: Florian Fainelli Signed-off-by: Christian Marangi --- arch/mips/kernel/smp-bmips.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/arch/mips/kernel/smp-bmips.c b/arch/mips/kernel/smp-bmips.c index 20e2fb10022d..e30342af8d91 100644 --- a/arch/mips/kernel/smp-bmips.c +++ b/arch/mips/kernel/smp-bmips.c @@ -598,6 +598,7 @@ asmlinkage void __weak plat_wired_tlb_setup(void) void bmips_cpu_setup(void) { void __iomem __maybe_unused *cbr = bmips_cbr_addr; + u32 __maybe_unused rac_addr; u32 __maybe_unused cfg; switch (current_cpu_type()) { @@ -626,6 +627,23 @@ void bmips_cpu_setup(void) __raw_readl(cbr + BMIPS_RAC_ADDRESS_RANGE); break; + case CPU_BMIPS4350: + 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()) {