From patchwork Tue Jun 11 11:35:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 13693502 Received: from mail-pf1-f180.google.com (mail-pf1-f180.google.com [209.85.210.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 7F84517C228; Tue, 11 Jun 2024 11:36:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718105761; cv=none; b=ePigo5K71TE5Kw3pe6/c8DnLdbok1JeNSlgYcL0fi5BeeCWjEr5g+zeWQWLYDjxbcROKFycGS6o5qRcHKqKox65ZzDbjS1O6ioN4pQM6g7Z/GyBO7Oyu+zZLF1CS6q37IFIT2d4X0uldfGQrnDNzu+EjJfIgyb7bugdAnR8P/6o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718105761; c=relaxed/simple; bh=KYM3RpgXB+bRDfX9kBzzB6kmbYZ7NlFFZJ/83yFFCno=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=kd0bQw1wm1A3l5bbRP2jZOpVhsEbcsdk7wOuqvjRfQkPJPECsvHbnVL8avkdAc49ESkJQ9WViTzgV1vl5Xvc8HDFDvbYKyajEVQt5WqbbIunSjTEB6D4Nj8pKWtbapsyEuCnxvUf1UyNlsfxMJZi1duAXjzru0FokKYgdV38DvA= 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=mc9S6Vtr; arc=none smtp.client-ip=209.85.210.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="mc9S6Vtr" Received: by mail-pf1-f180.google.com with SMTP id d2e1a72fcca58-70436ac8882so880027b3a.2; Tue, 11 Jun 2024 04:36:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718105760; x=1718710560; 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=mc9S6VtrDphZhvkHJOgiYj4CWHwDb3Y3IM0nnFJxCDaeie3RwLNTZMULiORuHQMBuq p6xb0StMQuy9gcwmH/xZm0+rkZSWtgBgW/M/VY+vDPoArZbgkDZ3V7oDyOkBajn65T3O H/qPFEJOXMvTIaN9hasQBZ1YmLsrqnnvEkE/0MpQnarH3FvxkLPw4MT5ZoBpgu9aVcvh JstlA771ZCpwna7vNp53TWUMSzZO7TrcVzx5+w1pkvveumASLClF4/EL1vPVhxl6eG61 v+ObjDNWWe49t9Tec2KHwnpQ1ARc80KGmSghNs7/btBuXJmEurT8UZmQNKbS3uIfFCud 4sEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718105760; x=1718710560; 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=lKiYQBPSJuSJi8Om791zys2rzQs2CRSXHLQztWy5WN9eSDriXD+Fe5ensbiJZlN+zN HxTRnPI/nhzjk8mE7pkmuiNPOlLsH7r+qsyoDTmv17GID/1GdvvYASR1YDsLgg5NTco7 1GOtq5mzOWFYzUqfGDZSkSVPy87maUXDnKgR3MT41mJ++Wi8gpV5zT9UYNdMKK708XYM 8KR+gWA1yTFaNkSjL6r7ZFjz4+EJbBJB2T7jcfiev1EpyHocs0PX5VBjzNcH0ODRuLkk yve8zJan2NDXgwiYhEnR6uvykMrEky3eZu1qdSmCJjZYdbSbgy1EYpoY5Gyho87MTLo1 sweA== X-Forwarded-Encrypted: i=1; AJvYcCVsMdJ43Z+YGMDQC11cNECqoR6//1QL3N3cgtzHQDNbxN7LpazObasyOR6nYKMBxNtZaqzsC3BpJZnTh7qyUj5UG6cdSziqXrl8sd5ywZetL9xIYKJjHWx84cWmfqtT2gvoODX3v6LKnropKVBkBcpHXZ/ob7O5yB+60V+Qb5ptNAcmI3s= X-Gm-Message-State: AOJu0YwC+2vbKi01+Ng6ang6ViVOMkKY5FX/ydEVJruyepCss0x8kq1w dGAMsEdmCV747htJT4s3dVCqUHZF0JelSJH01Tqpsdgt7TtXFd2KR3u8uw== X-Google-Smtp-Source: AGHT+IFS7qqa5BjwWxrUZHcauoz6IUBA6J0UALV/0YdBX2gXADkms4Nrp989ino9yjbn+rkYr7kMhA== X-Received: by 2002:a05:6a20:9151:b0:1b5:fd58:30e8 with SMTP id adf61e73a8af0-1b5fd586289mr7258770637.18.1718105759749; Tue, 11 Jun 2024 04:35:59 -0700 (PDT) Received: from localhost.localdomain (93-34-90-105.ip49.fastwebnet.it. [93.34.90.105]) by smtp.googlemail.com with ESMTPSA id 98e67ed59e1d1-2c2dd785762sm6705086a91.37.2024.06.11.04.35.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Jun 2024 04:35:59 -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 v7 1/5] mips: bmips: BCM6358: make sure CBR is correctly set Date: Tue, 11 Jun 2024 13:35:33 +0200 Message-ID: <20240611113538.9004-2-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240611113538.9004-1-ansuelsmth@gmail.com> References: <20240611113538.9004-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:35:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 13693503 Received: from mail-pj1-f51.google.com (mail-pj1-f51.google.com [209.85.216.51]) (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 A5A0017CA05; Tue, 11 Jun 2024 11:36:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718105765; cv=none; b=Z0R1ijYLYhORspJVutyOEPJsoyZf6+T2MeMQE7BzuqjOXPKINkt2FhAuHTCRSvUiXfWpjlswkxDkQNsiSbwBGssx1ymNGSWmR2STP5fhVa9xl2RVERzTxpIMZFSdHEZsLyReUie9Yu7CWEZ4g/JbGoFwnqoEB1eB1b31B6iCkm4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718105765; c=relaxed/simple; bh=96fjUGXbzrw3k5xl5NUqCMW2L7GOt6QRlWz3M6YrZiI=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jGsQSNKFdLMrOn+deyVTSzdtD9jK24wb2rXLbewGsbZESirjAO02xgp3aiRvbAPG0upkg9qsANRuWEi3ib961Qa+K/x0fkyLkRMusb8RQFFUD3tBknIXaD1/J1H5EHat+T2QGh1+f5Iy3C/bTE6MfyRE3vQJSWghnT12D7fG3l4= 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=eNrC/Eo8; arc=none smtp.client-ip=209.85.216.51 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="eNrC/Eo8" Received: by mail-pj1-f51.google.com with SMTP id 98e67ed59e1d1-2c1def9b4b3so877337a91.0; Tue, 11 Jun 2024 04:36:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718105763; x=1718710563; 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=eNrC/Eo8J6SqeF96aISjOy0z0g18RD2tSXT+FPj/yMdzk/ehp6U+hfk3w0bvDmGRoe XpNzqQQkZgh71L5D8ZtPQHovJrYPOrTD2Txi9J6mP8o5bhv8FWgBobpFa1bJrimMRsJX fZGQhWn8DDMCirflwLdxYH7QXnfRrd2iwVJBooUOTJ2GIaKI1FFIhha+w8xc9KOgAT9f Ck0hWW1TGWlWnXu2Hz2N68JWdB8HbGWn/hIeH6yC5HrMowfAKbSuxzrg2lEsdthwOBVw iiwoTOcs4O/GpW6SyiJdietTGoNYAaPtlTEEuYoApNCwJGGN7JAwCNkeSK1gian+eB13 jluQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718105763; x=1718710563; 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=XGZ8iuuN97z70BDVKS1zy9qF/UDV+wrFSO8kPGQH/4pDNVBaGCnqZ/L0L95RpPstfD xPcgt0c3offOvrvRsYLSyEYrKBRAja+vImjhYFJfqGfMDKh69uMb/JWCBnBXNab2R3sk GDKXQanolV16cb//ynqzPstDTfhup2AOtxs4zrMctqHpToXay/JEalgZwIve98s/H7Tl jW46UvZgUsUN6tjMJuOqBrM4eDY06D4n38jQDHAnft9rvEjyRVpzYnX/f1KxouZhJ+N+ opRRICa+ITEcXWiQy6qcpx+zZUlq4IWDI+396m9fMNXpXvSZGtKXzIt+Q8ZtsSvO9QU9 sIog== X-Forwarded-Encrypted: i=1; AJvYcCVgTLLUKuZcY0cEoomqXFaOR6tqvwzAs/pPTPaXg9wOqPJN1340k9j6+lsxXBTqHugE8XZ23kMTEohxvI/9CgPrBvbi8CT9yA0/S1XaGhgenI5xHvPBXdHXVYacxtqLIqQZw9TptzFZ0n4+lVyUJ8l3Sa8loLO83hyHcIoIbeLtvKPYKrg= X-Gm-Message-State: AOJu0Yy1oUyq7i0xc9U2l/72QjCLFmkvG8ZDKZHXtkSUE6RXA2YfgcEC sQ7WH511bxSk2bvoA1JKx2Yxh0SmUeHddu7ZficR/uB8n3VWwJP0 X-Google-Smtp-Source: AGHT+IH+QFfeJzg3SwJBv0yxSrEZhSpvFHi/ea9dnKyOBCzGUE/0iaBFQ4k1uM8ptZcVVQWbcr0kQw== X-Received: by 2002:a17:90a:ad98:b0:2c2:def4:6520 with SMTP id 98e67ed59e1d1-2c2def466ebmr8302982a91.38.1718105762888; Tue, 11 Jun 2024 04:36:02 -0700 (PDT) Received: from localhost.localdomain (93-34-90-105.ip49.fastwebnet.it. [93.34.90.105]) by smtp.googlemail.com with ESMTPSA id 98e67ed59e1d1-2c2dd785762sm6705086a91.37.2024.06.11.04.36.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Jun 2024 04:36:02 -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 v7 2/5] mips: bmips: rework and cache CBR addr handling Date: Tue, 11 Jun 2024 13:35:34 +0200 Message-ID: <20240611113538.9004-3-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240611113538.9004-1-ansuelsmth@gmail.com> References: <20240611113538.9004-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:35:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 13693504 Received: from mail-pj1-f47.google.com (mail-pj1-f47.google.com [209.85.216.47]) (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 DA69B17D34B; Tue, 11 Jun 2024 11:36:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718105768; cv=none; b=rJxrD6n9X3Qz2WQ/4fWJM9BN9ecjwwI+0wHfkEGyWGAXwy719nDB1T96jm5De4cmYWUkw+asO4L9cx4a3igolsajQG4+9Xe0T2zqitDCzivPu9cm+JqqoFUNWc1uE5sOjtZ/3zLTIDWCu4qBBT7l0CPcTCi7cOv6udISK7TeALo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718105768; c=relaxed/simple; bh=h+vhXAhkOCpSj5Kv8dcb58y7LBKSabqi9wb7z+oKe4A=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=UdE4Kzpxa6Z8aXR0qfcT+1l3XPx0PbGcBwXtB39KwGAv8VcxKBGxY2OtV5DYMjDUjaP6swzTT9osjKdDlX4rURS6XcxvWqacwOpDBvqAjQlMmhPkcqnoYzxarvuZiy0wHqkOREFn2V7lsry9HtsM2Rqky7//6LBPnZA4eucL9N0= 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=NRM+dW2A; arc=none smtp.client-ip=209.85.216.47 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="NRM+dW2A" Received: by mail-pj1-f47.google.com with SMTP id 98e67ed59e1d1-2c2ecbc109fso2194255a91.1; Tue, 11 Jun 2024 04:36:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718105766; x=1718710566; 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=CtbIuDbi1rFp385y8o4NUYKHVeIOAyZ2XdjR6SSW7u0=; b=NRM+dW2AjGpItINxXwdXZHvZvCwZUkhwR1SFwn9UFfnufAbAdBvQsWGcF1JvOa2W5i 99ATOJH+Nu1ThgttrEiQvsr9NFt/6J+uM1dDtQWqGmy17v2bCErH1p9VEUBKU9sZnon8 sCZCgP41dA41DSHc6zfsavMsEx72aA+Bk+sNKrsE8FJoCqCzsaAqUdZwBZh9St2fAVv6 HToxQxU1CzrdUSLw/VdKhe8E9ErbR6RzRuGMi2gguO8zmCGNa329v9WdoNIV3StMQ7m6 n5a+poCDNoYRG/7O/I32fRJNcONB3XrZ1iztVqdmqMmuTjv3PaKJl8E827z3X1NCPwRx VQ+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718105766; x=1718710566; 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=CtbIuDbi1rFp385y8o4NUYKHVeIOAyZ2XdjR6SSW7u0=; b=TUeNjeIiA2kUuRBE2fJMbGGvYQycDhZnlTS0kfX9LmFdcRFQeo0uilYuIlZjP2w3j3 e8ecBKzQrsaWQL0ESNJh0BS/Nk87c8lb5TANYjC5XE7dE6H5fhfAKp8w8QNtmkIdUAg5 a9ZjTw/S0i4fsKAcFmuQk8SiVh/dbWMbrTyFntFsa19Q9gILy08cM5eusMfz+zK9GRqW 0BOzPZqt+u9Ws6bknI5N5BG14wxFE43Q4z+/zqOR9iJyY0cDOaKJeqFZjN2HrljbOf89 FqhQhNz9oJzWoNrk9gXrDwva/oWCslJGq+daFLHvPuGsYRQD7I8RPzgVVD6mF2mIaYCd LIrw== X-Forwarded-Encrypted: i=1; AJvYcCUi9H3Pwruhz4APVis7YwKwK/RCM+CIVGiFKSlU7X56ehpNLoCv3HoVGqd2bPEdv9vEqDCHjko6Y91zOmSdW3yE4UbHNiRSLfQbkXua6vttmyUTYWn819yiG0Z7lO1kCorfWIM2Q3ATolt3+TgwGme47Xf2U+yZccVtjhyJA8skIhhZprU= X-Gm-Message-State: AOJu0YxIsmksNSvsHZBXF439MuU1vXwjySGrIGLPCqNfS4PDQ0TYV8V0 dWGE0X9luuMfNFGSKq4CTQ2SzBo82tELJ3bqTyXyMjciqynaDDzE X-Google-Smtp-Source: AGHT+IGPTCSC1q1VukMuRNWxpATn8r6NtmLJpdNRuhapoT4TaQ0Ev64loRYcE7t5Fv9tbm1mA7ScdQ== X-Received: by 2002:a17:90b:515:b0:2c2:792c:b618 with SMTP id 98e67ed59e1d1-2c2bcc6335dmr10568487a91.33.1718105766139; Tue, 11 Jun 2024 04:36:06 -0700 (PDT) Received: from localhost.localdomain (93-34-90-105.ip49.fastwebnet.it. [93.34.90.105]) by smtp.googlemail.com with ESMTPSA id 98e67ed59e1d1-2c2dd785762sm6705086a91.37.2024.06.11.04.36.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Jun 2024 04:36:05 -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 v7 3/5] dt-bindings: mips: brcm: Document brcm,bmips-cbr-reg property Date: Tue, 11 Jun 2024 13:35:35 +0200 Message-ID: <20240611113538.9004-4-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240611113538.9004-1-ansuelsmth@gmail.com> References: <20240611113538.9004-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 Tue Jun 11 11:35:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 13693505 Received: from mail-pj1-f48.google.com (mail-pj1-f48.google.com [209.85.216.48]) (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 0A6F117D370; Tue, 11 Jun 2024 11:36:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718105771; cv=none; b=Oa9Pekzdy37W7QPXFTkHgoc2SUdLNhnIVfgD8mS1z8XunRt49QgxAwPcn0pdBJr+CJYYmJWFSrkTBfTT/tVZ3i0MWIkqygTfPRP/Mfb+rJpQjx3N8tPmoxVehVksqx06mfFYp9mPG6666eUiYyCF1EkRcAx7cwVSD94DdrpjILA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718105771; c=relaxed/simple; bh=gjN79ppeuDgEdXtGgZv95JiQxwKZq+yKjWg+0of9O4I=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=UL0cK9YCi40tCX9nCmkhltByllGW/PQXOOoFMeHrua/7h/2H+Qcx8KAlkSUY0GhybEjC6uLxpyl2dqGh7F2M8GhlEQ4xAImSpPo9lcqMOBexJpeD1u2/JrNG/mbv66S4/L6PxOO/7DVdGB+K3H9YE2FQDIvOM1bEnGn9oFVp3Qo= 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=eoE6Sp7K; arc=none smtp.client-ip=209.85.216.48 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="eoE6Sp7K" Received: by mail-pj1-f48.google.com with SMTP id 98e67ed59e1d1-2c2dee9d9a1so2178164a91.3; Tue, 11 Jun 2024 04:36:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718105769; x=1718710569; 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=eoE6Sp7KBxwS9ZPTu9beKs3JFaNVKATg95YSt6DWT9J8buuzHTpaNdHwUjNQw8R6Qi 7IXsY2OLNDEhVWp5XzoGGyUTCFjcGUZ+uh05N9t6E1LT/psL5lrwkQ7J3vmlfrQOypNK i+xdVs6KxbBbumC2Fhw3keLlzGHWWvhJ6rF9Sta+zTaySeNmIkhMQRbQJEJhX++Ibmze +qmtbayksB4pCqft7fGhhU2zZDhIo5F0tc8i5dBUyJgFdwpHIyj9t5NHT01YtKV6f9C4 LDPjuuM+RnHz666+scXV1fESqJ/5PCfEy4JsdWcSXsRsD2ETiHSToalLkCDuLKKanVzr GXyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718105769; x=1718710569; 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=pIPzA0mlj3O2ezZyosaMNDIHNSiNmR656QqVjjsRa5Fg9Rp5Jnkgq0Q6hAnt6RygzC 7IvaRMZA1guOcw+pu0FP17HmPRqE0+F/k+5QvfoaayrXhJ5CTJTs1X/ebrkFDCDbnzI1 6eyheH+cv2FhkML1mQcTn4uOd1/AKnBUND7qWdpoFNY+1Ul1BMocuZMCEz6m4NdB7vpH UQA//1ZY6kZGXT48zaI4gQeJNnBMjdGp0eskT3iBJDD7em9bvJD8R2dWAf75dKFm5CTO ltWZj1kBbM0VqJvjb9gcGBBO4zYMEg897wvlpFJv2DZrK4p84SRbTsiYI8CH7wP4G2cB Hr5w== X-Forwarded-Encrypted: i=1; AJvYcCV8uGlxcntKC5pftSJm74knB936AEadnoIwkAcJMK8KRh5a3q+nEWv41VKHncGaicyB2yERPCbJqcNWNZc7eh6NDVyDld5+grCpkN6r6/LiQPQqXwQgS4WoYTpN1IVoCFBt7VZrA2+3zOACMm/oiTV+Ao0GAzt+1l0gBfs4RUA3dDDsI04= X-Gm-Message-State: AOJu0YxRP1OaVFT007dxX4xmdhCwoKl5kVk7KZGaQdBkyqYFcF5ijz37 Hnv8Lg31xpARuoq7ZSyXMPpRg4LKomXMf2pzsm4EWlcncvUxiiWXJtnEWw== X-Google-Smtp-Source: AGHT+IFEoZuq+CeA7n3YPIP/l4GMR/Lw0oqJS+PHSt43uJR6SgRSc8XH5+cV90gZczv7YeogOEupyg== X-Received: by 2002:a17:90b:4a51:b0:2c2:e790:a54d with SMTP id 98e67ed59e1d1-2c2e790a6b2mr7170006a91.23.1718105769260; Tue, 11 Jun 2024 04:36: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 98e67ed59e1d1-2c2dd785762sm6705086a91.37.2024.06.11.04.36.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Jun 2024 04:36: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 , =?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 v7 4/5] mips: bmips: setup: make CBR address configurable Date: Tue, 11 Jun 2024 13:35:36 +0200 Message-ID: <20240611113538.9004-5-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240611113538.9004-1-ansuelsmth@gmail.com> References: <20240611113538.9004-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:35:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 13693506 Received: from mail-pj1-f46.google.com (mail-pj1-f46.google.com [209.85.216.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 38F5217D88D; Tue, 11 Jun 2024 11:36:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718105774; cv=none; b=jsc9iKVQ+CK6IeW2/tnLITtWIRVc75953eUQsibFHUVwD2cRlDNaFFSA9o5C0404JoSLPmsN4ELXj3BRZ6BbIefSLb1uet2n7z7Q8rYFrA+egQfvGttW8oOednWlbxBQrxMbPZ7WSgv58o1b8RzFrZuBTonyP2G/Br9sh7jrvjk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718105774; c=relaxed/simple; bh=wTDGlpwvDV/tYVSnvnYnjRhtXn8bRII9NTQtrKlKeew=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=gbrXlbOszd4SgE8xnU2MVno4i0oJakTOVr3JerJJxiPHBbMjn0kF7h8gHoUn6v/rzidoRsP8DScjyZSfNMXCOdoLqZD8IqCAWxnEssZWYrCsG11SsuZ/WKcbQr6zqRcN33IHMGLxIUEfMhCQ6a5X9QcQ0g6aQl69H7uov0NeMn4= 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=Wzhjc4T8; arc=none smtp.client-ip=209.85.216.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="Wzhjc4T8" Received: by mail-pj1-f46.google.com with SMTP id 98e67ed59e1d1-2c1def9b4b3so877489a91.0; Tue, 11 Jun 2024 04:36:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718105772; x=1718710572; 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=Wzhjc4T82qH4VjRs02s20i0NcFre+WGiDWRWKXncK0NY1BD5wNMxsw5AcbgYgfElbe KqKhF15BGzgRKugM2l9FuK22iDBzcOKqXEc1DSiKlnPykV5BqC7xy7uBEDhqaGTjl7vs EcVi4NVGUAir1Or/bL99zJa4i3fA5e02m57o9AZF7zG7F1qqcPqm7A5PvUVkt3GZvpMr EXH9nK6tO8hMOIBGQjk9LGDlYZxQMcD0ClwGcyklCHTw9YB6o3KGnhA18PwRK/UP8d82 L+iqNXj/nEa7AbxTONI8LNsP1B+2leLaIk8hSY3P6ITsik+bVigBbT/h8xgOi5Hvbj/I TZrQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718105772; x=1718710572; 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=UySFLjtfIyz5CFUze72ZHAS2qKmyoYhNjDzPJzkm8OGPvp+GNN9oiO+j64v1heMl/F 3RFpZ1HM82S3KEBudR9uPxSXQMabQTzETN5tCuvKStHJ9lekrdYnKBdLTDNODoiBVkf7 Qxu0hbfj8Uvbtj68RdQJ9XrJyxshxB1axIB9PXMj4gybv5gTCzx8VUnCHD9wp/ekj4Ae SUzhdviBnDmcbcidxYKGsWMNcqi72vxmB/ItnRUkTXGdDq701qR7KjcZHUECXJ+z1dYF J/zR2qRI81OFk/P6G1L18u+J+nkTftoLXAFp9ayyPcoHn56rEL755JAyxFSTbacMugwV 8Z4A== X-Forwarded-Encrypted: i=1; AJvYcCWvgLPnGUjytWkA28hblAmTQwZKv+U84vEuAHh6orC0Ns1XZMzgsxeecVHfA3P5OPKlv5ejI35q7cWj1m8H1Pqqqiw2WHtZIKBLFehae19h5ko6nFvCsMj2f2hqWdplim0yNZBP6O7FmzyTHZX8S2YNicfzFZd3PBzgJJRx4OqGaGBUfYc= X-Gm-Message-State: AOJu0Yz+gmzSKRu7e4AA63rrC6/TAqp4e8v1wYd/bd5Y9ULvOj+P+BLO eBf1bzG0Fht9c82Kf5UehXSKuZEmOevTyXVCiRDEa7UgSwkgZhsL X-Google-Smtp-Source: AGHT+IFUGwaFivizDf0SnGE18XoE7bi8+5EJ03/BzizEhUoZRYPWIZ4N2Kjf0iQkk+nU04BWSQDNgQ== X-Received: by 2002:a17:90b:4f8c:b0:2c3:195d:8cc1 with SMTP id 98e67ed59e1d1-2c3195d8deamr3897147a91.37.1718105772537; Tue, 11 Jun 2024 04:36: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 98e67ed59e1d1-2c2dd785762sm6705086a91.37.2024.06.11.04.36.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Jun 2024 04:36: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 , =?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 v7 5/5] mips: bmips: enable RAC on BMIPS4350 Date: Tue, 11 Jun 2024 13:35:37 +0200 Message-ID: <20240611113538.9004-6-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240611113538.9004-1-ansuelsmth@gmail.com> References: <20240611113538.9004-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()) {