memory: tegra: Add MC error logging support for Tegra264 SoC
Subsystems (2)
v6 cover memory: tegra: Add MC error logging support for Tegra264 SoC
In Tegra264, different components from memory subsystems like Memory Controller Fabric (MCF), HUB, HUB Common (HUBC), Side Band Shim (SBS) and MC Channels have different interrupt lines for receiving memory controller error interrupts. This patch set includes changes to add support and enable Memory Controller error logging for Tegra264.
Ketan Patil (4):
memory: tegra: Group error handling related registers
memory: tegra: Group register and fields
memory: tegra: Add support for multiple IRQs
memory: tegra: Add MC error logging support for Tegra264
---
Changes in v6:
- Updated copyright year and commit message.
- Removed redundant mc_ prefix from few structs.
- Grouped the masks and bits next to the associated registers which were missed in previous revision.
- Separated out Tegra264 specific registers from previous SoC registers.
- Reduced variables in mcf_log_fault, hub_log_fault functions.
Changes in v5:
- Updated commit message to clarify the need of grouping of mc-err registers and support for multiple interrupts, so that it can support Tegra264.
Changes in v4:
- Fixed typo in variable name
- Added MC instance aperture mapping for hubc registers and corrected irq handler function to read from respective mc aperture.
Changes in v3:
- Fixed compilation error with W=1 build
Changes in v2:
- Fixed warning due to use of uninitialized variable by returning back from the function
- Removed unnecessary extern declaration of tegra264_mc_ops
- Updated tegra20_mc_irq_handlers, tegra264_mc_irq_handlers and tegra264_mc_ops to static
drivers/memory/tegra/mc.c | 112 ++++++--- drivers/memory/tegra/mc.h | 162 ++++++++---- drivers/memory/tegra/tegra114.c | 16 +- drivers/memory/tegra/tegra124.c | 36 ++- drivers/memory/tegra/tegra186.c | 30 ++- drivers/memory/tegra/tegra194.c | 20 +- drivers/memory/tegra/tegra20.c | 33 ++- drivers/memory/tegra/tegra210.c | 19 +- drivers/memory/tegra/tegra234.c | 20 +- drivers/memory/tegra/tegra264.c | 428 +++++++++++++++++++++++++++++++- drivers/memory/tegra/tegra30.c | 16 +- include/soc/tegra/mc.h | 38 ++- 12 files changed, 785 insertions(+), 145 deletions(-)
Signature · 1 line
2.17.1
PATCH v6 1/4 memory: tegra: Group error handling related registers
Group MC error related registers into a struct as they could have SoC specific values. Tegra264 has different register offsets than the existing devices and so in order to add support for Tegra264 we need to first make this change.
--- drivers/memory/tegra/mc.c | 47 ++++++++++++++++++++++----------- drivers/memory/tegra/mc.h | 16 +---------- drivers/memory/tegra/tegra114.c | 3 ++- drivers/memory/tegra/tegra124.c | 4 ++- drivers/memory/tegra/tegra186.c | 3 ++- drivers/memory/tegra/tegra194.c | 3 ++- drivers/memory/tegra/tegra20.c | 3 ++- drivers/memory/tegra/tegra210.c | 3 ++- drivers/memory/tegra/tegra234.c | 3 ++- drivers/memory/tegra/tegra30.c | 3 ++- include/soc/tegra/mc.h | 22 ++++++++++++++- 11 files changed, 71 insertions(+), 39 deletions(-)
drivers/memory/tegra/mc.c +32 -15
@@ -1,6 +1,6 @@// SPDX-License-Identifier: GPL-2.0-only /* -* Copyright (C) 2014-2025 NVIDIA CORPORATION. All rights reserved. +* Copyright (C) 2014-2026 NVIDIA CORPORATION. All rights reserved. */ #include <linux/clk.h>
@@ -56,6 +56,23 @@ static const struct of_device_id tegra_mc_of_match[] = { };MODULE_DEVICE_TABLE (of, tegra_mc_of_match); +const struct tegra_mc_regs tegra20_mc_regs = { + .cfg_channel_enable =0xdf8 , + .err_status =0x08 , + .err_add =0x0c , + .err_add_hi =0x11fc , + .err_vpr_status =0x654 , + .err_vpr_add =0x658 , + .err_sec_status =0x67c , + .err_sec_add =0x680 , + .err_mts_status =0x9b0 , + .err_mts_add =0x9b4 , + .err_gen_co_status =0xc00 , + .err_gen_co_add =0xc04 , + .err_route_status =0x9c0 , + .err_route_add =0x9c4 , +}; +static void tegra_mc_devm_action_put_device (void *data) {struct tegra_mc *mc = data;
@@ -600,37 +617,37 @@ irqreturn_t tegra30_mc_handle_irq(int irq, void *data)switch (intmask) {case MC_INT_DECERR_VPR : - status_reg =MC_ERR_VPR_STATUS ; - addr_reg =MC_ERR_VPR_ADR ; + status_reg = mc->soc->regs->err_vpr_status; + addr_reg = mc->soc->regs->err_vpr_add;break ;case MC_INT_SECERR_SEC : - status_reg =MC_ERR_SEC_STATUS ; - addr_reg =MC_ERR_SEC_ADR ; + status_reg = mc->soc->regs->err_sec_status; + addr_reg = mc->soc->regs->err_sec_add;break ;case MC_INT_DECERR_MTS : - status_reg =MC_ERR_MTS_STATUS ; - addr_reg =MC_ERR_MTS_ADR ; + status_reg = mc->soc->regs->err_mts_status; + addr_reg = mc->soc->regs->err_mts_add;break ;case MC_INT_DECERR_GENERALIZED_CARVEOUT : - status_reg =MC_ERR_GENERALIZED_CARVEOUT_STATUS ; - addr_reg =MC_ERR_GENERALIZED_CARVEOUT_ADR ; + status_reg = mc->soc->regs->err_gen_co_status; + addr_reg = mc->soc->regs->err_gen_co_add;break ;case MC_INT_DECERR_ROUTE_SANITY : - status_reg =MC_ERR_ROUTE_SANITY_STATUS ; - addr_reg =MC_ERR_ROUTE_SANITY_ADR ; + status_reg = mc->soc->regs->err_route_status; + addr_reg = mc->soc->regs->err_route_add;break ;default : - status_reg =MC_ERR_STATUS ; - addr_reg =MC_ERR_ADR ; + status_reg = mc->soc->regs->err_status; + addr_reg = mc->soc->regs->err_add;#ifdef CONFIG_PHYS_ADDR_T_64BIT if (mc->soc->has_addr_hi_reg) - addr_hi_reg =MC_ERR_ADR_HI ; + addr_hi_reg = mc->soc->regs->err_add_hi;#endif break ; }
@@ -883,7 +900,7 @@ static void tegra_mc_num_channel_enabled(struct tegra_mc *mc)unsigned int i;u32 value; - value =mc_ch_readl (mc,0 ,MC_EMEM_ADR_CFG_CHANNEL_ENABLE ); + value =mc_ch_readl (mc,0 , mc->soc->regs->cfg_channel_enable);if (value <=0 ) { mc->num_channels = mc->soc->num_channels;return ;
drivers/memory/tegra/mc.h +1 -15
@@ -1,6 +1,6 @@/* SPDX-License-Identifier: GPL-2.0-only */ /* -* Copyright (C) 2014-2025 NVIDIA CORPORATION. All rights reserved. +* Copyright (C) 2014-2026 NVIDIA CORPORATION. All rights reserved. */ #ifndef MEMORY_TEGRA_MC_H
@@ -14,8 +14,6 @@#define MC_INTSTATUS 0x00#define MC_INTMASK 0x04 -#define MC_ERR_STATUS 0x08 -#define MC_ERR_ADR 0x0c#define MC_GART_ERROR_REQ 0x30#define MC_EMEM_ADR_CFG 0x54#define MC_DECERR_EMEM_OTHERS_STATUS 0x58
@@ -43,19 +41,7 @@#define MC_EMEM_ARB_OVERRIDE 0xe8#define MC_TIMING_CONTROL_DBG 0xf8#define MC_TIMING_CONTROL 0xfc -#define MC_ERR_VPR_STATUS 0x654 -#define MC_ERR_VPR_ADR 0x658 -#define MC_ERR_SEC_STATUS 0x67c -#define MC_ERR_SEC_ADR 0x680 -#define MC_ERR_MTS_STATUS 0x9b0 -#define MC_ERR_MTS_ADR 0x9b4 -#define MC_ERR_ROUTE_SANITY_STATUS 0x9c0 -#define MC_ERR_ROUTE_SANITY_ADR 0x9c4 -#define MC_ERR_GENERALIZED_CARVEOUT_STATUS 0xc00 -#define MC_ERR_GENERALIZED_CARVEOUT_ADR 0xc04 -#define MC_EMEM_ADR_CFG_CHANNEL_ENABLE 0xdf8#define MC_GLOBAL_INTSTATUS 0xf24 -#define MC_ERR_ADR_HI 0x11fc#define MC_INT_DECERR_ROUTE_SANITY BIT(20)#define MC_INT_DECERR_GENERALIZED_CARVEOUT BIT(17)
drivers/memory/tegra/tegra114.c +2 -1
@@ -1,6 +1,6 @@// SPDX-License-Identifier: GPL-2.0-only /* -* Copyright (C) 2014 NVIDIA CORPORATION. All rights reserved. +* Copyright (C) 2014-2026 NVIDIA CORPORATION. All rights reserved. */ #include <linux/of.h>
@@ -1114,4 +1114,5 @@ const struct tegra_mc_soc tegra114_mc_soc = { .resets = tegra114_mc_resets, .num_resets = ARRAY_SIZE(tegra114_mc_resets), .ops = &tegra30_mc_ops, + .regs = &tegra20_mc_regs, };
drivers/memory/tegra/tegra124.c +3 -1
@@ -1,6 +1,6 @@// SPDX-License-Identifier: GPL-2.0-only /* -* Copyright (C) 2014 NVIDIA CORPORATION. All rights reserved. +* Copyright (C) 2014-2026 NVIDIA CORPORATION. All rights reserved. */ #include <linux/of.h>
@@ -1275,6 +1275,7 @@ const struct tegra_mc_soc tegra124_mc_soc = { .num_resets = ARRAY_SIZE(tegra124_mc_resets), .icc_ops = &tegra124_mc_icc_ops, .ops = &tegra30_mc_ops, + .regs = &tegra20_mc_regs, };#endif /* CONFIG_ARCH_TEGRA_124_SOC */
@@ -1307,5 +1308,6 @@ const struct tegra_mc_soc tegra132_mc_soc = { .num_resets = ARRAY_SIZE(tegra124_mc_resets), .icc_ops = &tegra124_mc_icc_ops, .ops = &tegra30_mc_ops, + .regs = &tegra20_mc_regs, };#endif /* CONFIG_ARCH_TEGRA_132_SOC */
drivers/memory/tegra/tegra186.c +2 -1
@@ -1,6 +1,6 @@// SPDX-License-Identifier: GPL-2.0-only /* -* Copyright (C) 2017-2025 NVIDIA CORPORATION. All rights reserved. +* Copyright (C) 2017-2026 NVIDIA CORPORATION. All rights reserved. */ #include <linux/io.h>
@@ -914,5 +914,6 @@ const struct tegra_mc_soc tegra186_mc_soc = { .ops = &tegra186_mc_ops, .ch_intmask = 0x0000000f, .global_intstatus_channel_shift = 0, + .regs = &tegra20_mc_regs, };#endif
drivers/memory/tegra/tegra194.c +2 -1
@@ -1,6 +1,6 @@// SPDX-License-Identifier: GPL-2.0-only /* -* Copyright (C) 2017-2021 NVIDIA CORPORATION. All rights reserved. +* Copyright (C) 2017-2026 NVIDIA CORPORATION. All rights reserved. */ #include <soc/tegra/mc.h>
@@ -1358,4 +1358,5 @@ const struct tegra_mc_soc tegra194_mc_soc = { .icc_ops = &tegra_mc_icc_ops, .ch_intmask = 0x00000f00, .global_intstatus_channel_shift = 8, + .regs = &tegra20_mc_regs, };
drivers/memory/tegra/tegra20.c +2 -1
@@ -1,6 +1,6 @@// SPDX-License-Identifier: GPL-2.0-only /* -* Copyright (C) 2012 NVIDIA CORPORATION. All rights reserved. +* Copyright (C) 2012-2026 NVIDIA CORPORATION. All rights reserved. */ #include <linux/bitfield.h>
@@ -778,4 +778,5 @@ const struct tegra_mc_soc tegra20_mc_soc = { .num_resets = ARRAY_SIZE(tegra20_mc_resets), .icc_ops = &tegra20_mc_icc_ops, .ops = &tegra20_mc_ops, + .regs = &tegra20_mc_regs, };
drivers/memory/tegra/tegra210.c +2 -1
@@ -1,6 +1,6 @@// SPDX-License-Identifier: GPL-2.0-only /* -* Copyright (C) 2015 NVIDIA CORPORATION. All rights reserved. +* Copyright (C) 2015-2026 NVIDIA CORPORATION. All rights reserved. */ #include <dt-bindings/memory/tegra210-mc.h>
@@ -1287,4 +1287,5 @@ const struct tegra_mc_soc tegra210_mc_soc = { .resets = tegra210_mc_resets, .num_resets = ARRAY_SIZE(tegra210_mc_resets), .ops = &tegra30_mc_ops, + .regs = &tegra20_mc_regs, };
drivers/memory/tegra/tegra234.c +2 -1
@@ -1,6 +1,6 @@// SPDX-License-Identifier: GPL-2.0-only /* -* Copyright (C) 2022-2023, NVIDIA CORPORATION. All rights reserved. +* Copyright (C) 2022-2026, NVIDIA CORPORATION. All rights reserved. */ #include <soc/tegra/mc.h>
@@ -1152,4 +1152,5 @@ const struct tegra_mc_soc tegra234_mc_soc = {* supported. */ .num_carveouts = 32, + .regs = &tegra20_mc_regs, };
drivers/memory/tegra/tegra30.c +2 -1
@@ -1,6 +1,6 @@// SPDX-License-Identifier: GPL-2.0-only /* -* Copyright (C) 2014 NVIDIA CORPORATION. All rights reserved. +* Copyright (C) 2014-2026 NVIDIA CORPORATION. All rights reserved. */ #include <linux/device.h>
@@ -1400,4 +1400,5 @@ const struct tegra_mc_soc tegra30_mc_soc = { .num_resets = ARRAY_SIZE(tegra30_mc_resets), .icc_ops = &tegra30_mc_icc_ops, .ops = &tegra30_mc_ops, + .regs = &tegra20_mc_regs, };
include/soc/tegra/mc.h +21 -1
@@ -1,6 +1,6 @@/* SPDX-License-Identifier: GPL-2.0-only */ /* -* Copyright (C) 2014 NVIDIA Corporation +* Copyright (C) 2014-2026 NVIDIA Corporation */ #ifndef __SOC_TEGRA_MC_H__
@@ -168,6 +168,23 @@ struct tegra_mc_ops {int (*probe_device)(struct tegra_mc *mc,struct device *dev); }; +struct tegra_mc_regs { +unsigned int cfg_channel_enable; +unsigned int err_status; +unsigned int err_add; +unsigned int err_add_hi; +unsigned int err_vpr_status; +unsigned int err_vpr_add; +unsigned int err_sec_status; +unsigned int err_sec_add; +unsigned int err_mts_status; +unsigned int err_mts_add; +unsigned int err_gen_co_status; +unsigned int err_gen_co_add; +unsigned int err_route_status; +unsigned int err_route_add; +}; +struct tegra_mc_soc {const struct tegra_mc_client *clients;unsigned int num_clients;
@@ -196,6 +213,7 @@ struct tegra_mc_soc {const struct tegra_mc_icc_ops *icc_ops;const struct tegra_mc_ops *ops; +const struct tegra_mc_regs *regs; };struct tegra_mc {
@@ -256,4 +274,6 @@ tegra_mc_get_carveout_info(struct tegra_mc *mc, unsigned int id, }#endif +extern const struct tegra_mc_regs tegra20_mc_regs; +#endif /* __SOC_TEGRA_MC_H__ */
Signature · 1 line
2.17.1
PATCH v6 2/4 memory: tegra: Group register and fields
In reply to Ketan PatilThe current register definitions are not in sorted order. Sort these registers according to their address. Put bit fields and masks of the corresponding registers below the register definitions to clearly identify which fields belongs to which registers.
--- drivers/memory/tegra/mc.h | 62 +++++++++++++++++++++------------------ 1 file changed, 33 insertions(+), 29 deletions(-)
drivers/memory/tegra/mc.h +33 -29
@@ -13,13 +13,35 @@#include <soc/tegra/mc.h> #define MC_INTSTATUS 0x00 +/* Bit field of MC_INTSTATUS register */ +#define MC_INT_DECERR_EMEM BIT(6) +#define MC_INT_INVALID_GART_PAGE BIT(7) +#define MC_INT_SECURITY_VIOLATION BIT(8) +#define MC_INT_ARBITRATION_EMEM BIT(9) +#define MC_INT_INVALID_SMMU_PAGE BIT(10) +#define MC_INT_INVALID_APB_ASID_UPDATE BIT(11) +#define MC_INT_DECERR_VPR BIT(12) +#define MC_INT_SECERR_SEC BIT(13) +#define MC_INT_DECERR_MTS BIT(16) +#define MC_INT_DECERR_GENERALIZED_CARVEOUT BIT(17) +#define MC_INT_DECERR_ROUTE_SANITY BIT(20) +#define MC_INTMASK 0x04#define MC_GART_ERROR_REQ 0x30#define MC_EMEM_ADR_CFG 0x54 +#define MC_EMEM_ADR_CFG_EMEM_NUMDEV BIT(0) +#define MC_DECERR_EMEM_OTHERS_STATUS 0x58#define MC_SECURITY_VIOLATION_STATUS 0x74#define MC_EMEM_ARB_CFG 0x90 +#define MC_EMEM_ARB_CFG_CYCLES_PER_UPDATE (x) ((x) & 0x1ff) +#define MC_EMEM_ARB_CFG_CYCLES_PER_UPDATE_MASK 0x1ff +#define MC_EMEM_ARB_OUTSTANDING_REQ 0x94 +#define MC_EMEM_ARB_OUTSTANDING_REQ_HOLDOFF_OVERRIDE BIT(30) +#define MC_EMEM_ARB_OUTSTANDING_REQ_LIMIT_ENABLE BIT(31) +#define MC_EMEM_ARB_OUTSTANDING_REQ_MAX_MASK 0x1ff +#define MC_EMEM_ARB_TIMING_RCD 0x98#define MC_EMEM_ARB_TIMING_RP 0x9c#define MC_EMEM_ARB_TIMING_RC 0xa0
@@ -39,45 +61,27 @@#define MC_EMEM_ARB_MISC1 0xdc#define MC_EMEM_ARB_RING1_THROTTLE 0xe0#define MC_EMEM_ARB_OVERRIDE 0xe8 +#define MC_EMEM_ARB_OVERRIDE_EACK_MASK 0x3 +#define MC_TIMING_CONTROL_DBG 0xf8#define MC_TIMING_CONTROL 0xfc +#define MC_TIMING_UPDATE BIT(0) +#define MC_GLOBAL_INTSTATUS 0xf24 -#define MC_INT_DECERR_ROUTE_SANITY BIT(20) -#define MC_INT_DECERR_GENERALIZED_CARVEOUT BIT(17) -#define MC_INT_DECERR_MTS BIT(16) -#define MC_INT_SECERR_SEC BIT(13) -#define MC_INT_DECERR_VPR BIT(12) -#define MC_INT_INVALID_APB_ASID_UPDATE BIT(11) -#define MC_INT_INVALID_SMMU_PAGE BIT(10) -#define MC_INT_ARBITRATION_EMEM BIT(9) -#define MC_INT_SECURITY_VIOLATION BIT(8) -#define MC_INT_INVALID_GART_PAGE BIT(7) -#define MC_INT_DECERR_EMEM BIT(6) +/* Bit field of MC_ERR_STATUS_0 register */ +#define MC_ERR_STATUS_RW BIT(16) +#define MC_ERR_STATUS_SECURITY BIT(17) +#define MC_ERR_STATUS_NONSECURE BIT(25) +#define MC_ERR_STATUS_WRITABLE BIT(26) +#define MC_ERR_STATUS_READABLE BIT(27)#define MC_ERR_STATUS_TYPE_SHIFT 28#define MC_ERR_STATUS_TYPE_INVALID_SMMU_PAGE (0x6 << 28)#define MC_ERR_STATUS_TYPE_MASK (0x7 << 28) -#define MC_ERR_STATUS_READABLE BIT(27) -#define MC_ERR_STATUS_WRITABLE BIT(26) -#define MC_ERR_STATUS_NONSECURE BIT(25) +#define MC_ERR_STATUS_ADR_HI_SHIFT 20#define MC_ERR_STATUS_ADR_HI_MASK 0x3 -#define MC_ERR_STATUS_SECURITY BIT(17) -#define MC_ERR_STATUS_RW BIT(16) - -#define MC_EMEM_ADR_CFG_EMEM_NUMDEV BIT(0) - -#define MC_EMEM_ARB_CFG_CYCLES_PER_UPDATE (x) ((x) & 0x1ff) -#define MC_EMEM_ARB_CFG_CYCLES_PER_UPDATE_MASK 0x1ff - -#define MC_EMEM_ARB_OUTSTANDING_REQ_MAX_MASK 0x1ff -#define MC_EMEM_ARB_OUTSTANDING_REQ_HOLDOFF_OVERRIDE BIT(30) -#define MC_EMEM_ARB_OUTSTANDING_REQ_LIMIT_ENABLE BIT(31) - -#define MC_EMEM_ARB_OVERRIDE_EACK_MASK 0x3 - -#define MC_TIMING_UPDATE BIT(0)#define MC_BROADCAST_CHANNEL ~0
Signature · 1 line
2.17.1
PATCH v6 3/4 memory: tegra: Add support for multiple IRQs
In reply to Ketan PatilAdd support to handle multiple MC interrupts lines, as supported by Tegra264. Turn the single IRQ handler callback into a counted array to allow specifying a separate handler for each interrupt.
--- drivers/memory/tegra/mc.c | 34 +++++++++++++++++++++------------ drivers/memory/tegra/mc.h | 1 + drivers/memory/tegra/tegra186.c | 3 ++- drivers/memory/tegra/tegra20.c | 7 ++++++- include/soc/tegra/mc.h | 6 ++++-- 5 files changed, 35 insertions(+), 16 deletions(-)
drivers/memory/tegra/mc.c +22 -12
@@ -398,6 +398,10 @@ unsigned int tegra_mc_get_emem_device_count(struct tegra_mc *mc) }EXPORT_SYMBOL_GPL (tegra_mc_get_emem_device_count); +const irq_handler_t tegra30_mc_irq_handlers[] = { + tegra30_mc_handle_irq +}; + #if defined(CONFIG_ARCH_TEGRA_3x_SOC) || \ defined(CONFIG_ARCH_TEGRA_114_SOC) || \ defined(CONFIG_ARCH_TEGRA_124_SOC) || \
@@ -551,7 +555,8 @@ int tegra30_mc_probe(struct tegra_mc *mc)const struct tegra_mc_ops tegra30_mc_ops = { .probe = tegra30_mc_probe, - .handle_irq = tegra30_mc_handle_irq, + .handle_irq = tegra30_mc_irq_handlers, + .num_interrupts =ARRAY_SIZE (tegra30_mc_irq_handlers), };#endif
@@ -953,25 +958,30 @@ static int tegra_mc_probe(struct platform_device *pdev)tegra_mc_num_channel_enabled (mc);if (mc->soc->ops && mc->soc->ops->handle_irq) { - mc->irq =platform_get_irq (pdev,0 ); -if (mc->irq <0 ) -return mc->irq; +unsigned int i;WARN (!mc->soc->client_id_mask,"missing client ID mask for this SoC\n" ); +for (i =0 ; i < mc->soc->ops->num_interrupts; i++) { +int irq; + + irq =platform_get_irq (pdev, i); +if (irq <0 ) +return irq; + + err =devm_request_irq (&pdev->dev, irq, mc->soc->ops->handle_irq[i],0 , +dev_name (&pdev->dev), mc); +if (err <0 ) { +dev_err (&pdev->dev,"failed to request IRQ#%u: %d\n" , irq, err); +return err; + } + } +if (mc->soc->num_channels)mc_ch_writel (mc,MC_BROADCAST_CHANNEL , mc->soc->intmask,MC_INTMASK );else mc_writel (mc, mc->soc->intmask,MC_INTMASK ); - - err =devm_request_irq (&pdev->dev, mc->irq, mc->soc->ops->handle_irq,0 , -dev_name (&pdev->dev), mc); -if (err <0 ) { -dev_err (&pdev->dev,"failed to request IRQ#%u: %d\n" , mc->irq, - err); -return err; - } }if (mc->soc->reset_ops) {
drivers/memory/tegra/mc.h +1 -0
@@ -193,6 +193,7 @@ extern const struct tegra_mc_ops tegra186_mc_ops;#endif irqreturn_t tegra30_mc_handle_irq (int irq,void *data); +extern const irq_handler_t tegra30_mc_irq_handlers[];extern const char *const tegra_mc_status_names[32 ];extern const char *const tegra_mc_error_names[8 ];
drivers/memory/tegra/tegra186.c +2 -1
@@ -174,7 +174,8 @@ const struct tegra_mc_ops tegra186_mc_ops = { .remove = tegra186_mc_remove, .resume = tegra186_mc_resume, .probe_device = tegra186_mc_probe_device, - .handle_irq = tegra30_mc_handle_irq, + .handle_irq = tegra30_mc_irq_handlers, + .num_interrupts = 1, };#if defined(CONFIG_ARCH_TEGRA_186_SOC )
drivers/memory/tegra/tegra20.c +6 -1
@@ -761,9 +761,14 @@ static irqreturn_t tegra20_mc_handle_irq(int irq, void *data)return IRQ_HANDLED ; } +static const irq_handler_t tegra20_mc_irq_handlers[] = { + tegra20_mc_handle_irq +}; +static const struct tegra_mc_ops tegra20_mc_ops = { .probe = tegra20_mc_probe, - .handle_irq = tegra20_mc_handle_irq, + .handle_irq = tegra20_mc_irq_handlers, + .num_interrupts =ARRAY_SIZE (tegra20_mc_irq_handlers), };const struct tegra_mc_soc tegra20_mc_soc = {
include/soc/tegra/mc.h +4 -2
@@ -10,10 +10,11 @@#include <linux/debugfs.h> #include <linux/err.h> #include <linux/interconnect-provider.h> +#include <linux/interrupt.h> #include <linux/irq.h> #include <linux/reset-controller.h> -#include <linux/types.h> #include <linux/tegra-icc.h> +#include <linux/types.h> struct clk ;struct device ;
@@ -164,8 +165,9 @@ struct tegra_mc_ops {int (*probe)(struct tegra_mc *mc);void (*remove)(struct tegra_mc *mc);int (*resume)(struct tegra_mc *mc); -irqreturn_t (*handle_irq)(int irq,void *data);int (*probe_device)(struct tegra_mc *mc,struct device *dev); +const irq_handler_t *handle_irq; +unsigned int num_interrupts; };struct tegra_mc_regs {
Signature · 1 line
2.17.1
PATCH v6 4/4 memory: tegra: Add MC error logging support for Tegra264
In reply to Ketan PatilIn Tegra264, different components from memory subsystems like Memory Controller Fabric (MCF), HUB, HUB Common (HUBC), Side Band Shim (SBS) and channels have different interrupt lines for receiving memory controller error interrupts.
Add support for logging memory controller errors on Tegra264.
- Add MC error handling flow for MCF, HUB, HUBC, SBS and channels.
- Each of these components have different interrupt lines for MC error.
- Register interrupt handlers for interrupts from these different MC components.
- There is no global interrupt status register in Tegra264 unlike older Tegra chips.
- There are common interrupt status registers in case of MCF, HUB, HUBC from which figure out the slice number or hub number responsible for generating interrupt and then read interrupt status register to find out type of violation.
- Introduce new SoC specific fields in tegra_mc_soc like interrupt mask values for MCF, HUB, HUBC etc., which are SoC specific.
--- drivers/memory/tegra/mc.c | 35 +-- drivers/memory/tegra/mc.h | 83 ++++++- drivers/memory/tegra/tegra114.c | 13 +- drivers/memory/tegra/tegra124.c | 32 ++- drivers/memory/tegra/tegra186.c | 24 +- drivers/memory/tegra/tegra194.c | 17 +- drivers/memory/tegra/tegra20.c | 23 +- drivers/memory/tegra/tegra210.c | 16 +- drivers/memory/tegra/tegra234.c | 17 +- drivers/memory/tegra/tegra264.c | 428 +++++++++++++++++++++++++++++++- drivers/memory/tegra/tegra30.c | 13 +- include/soc/tegra/mc.h | 10 +- 12 files changed, 648 insertions(+), 63 deletions(-)
drivers/memory/tegra/mc.c +20 -15
@@ -597,16 +597,16 @@ irqreturn_t tegra30_mc_handle_irq(int irq, void *data) }/* mask all interrupts to avoid flooding */ - status =mc_ch_readl (mc, channel,MC_INTSTATUS ) & mc->soc->intmask; + status =mc_ch_readl (mc, channel,MC_INTSTATUS ) & mc->soc->intmasks[0 ].mask; }else { - status =mc_readl (mc,MC_INTSTATUS ) & mc->soc->intmask; + status =mc_readl (mc,MC_INTSTATUS ) & mc->soc->intmasks[0 ].mask; }if (!status)return IRQ_NONE ;for_each_set_bit (bit, &status,32 ) { -const char *error = tegra_mc_status_names[bit] ?:"unknown" ; +const char *error = tegra20_mc_status_names[bit] ?:"unknown" ;const char *client ="unknown" , *desc;const char *direction, *secure;u32 status_reg, addr_reg;
@@ -669,9 +669,11 @@ irqreturn_t tegra30_mc_handle_irq(int irq, void *data) addr =mc_ch_readl (mc, channel, addr_hi_reg); else addr =mc_readl (mc, addr_hi_reg); - }else { + }else if (mc->soc->mc_addr_hi_mask) { addr = ((value >>MC_ERR_STATUS_ADR_HI_SHIFT ) & -MC_ERR_STATUS_ADR_HI_MASK ); + mc->soc->mc_addr_hi_mask); + }else { +WARN_ON (1 ); } addr <<=32 ; }
@@ -696,11 +698,11 @@ irqreturn_t tegra30_mc_handle_irq(int irq, void *data) } } - type = (value &MC_ERR_STATUS_TYPE_MASK ) >> + type = (value & mc->soc->mc_err_status_type_mask) >>MC_ERR_STATUS_TYPE_SHIFT ; - desc = tegra_mc_error_names[type]; + desc = tegra20_mc_error_names[type]; -switch (value &MC_ERR_STATUS_TYPE_MASK ) { +switch (value & mc->soc->mc_err_status_type_mask) {case MC_ERR_STATUS_TYPE_INVALID_SMMU_PAGE : perm[0 ] =' ' ; perm[1 ] ='[' ;
@@ -753,7 +755,7 @@ irqreturn_t tegra30_mc_handle_irq(int irq, void *data)return IRQ_HANDLED ; } -const char *const tegra_mc_status_names[32 ] = { +const char *const tegra20_mc_status_names[32 ] = { [1 ] ="External interrupt" , [6 ] ="EMEM address decode error" , [7 ] ="GART page fault" ,
@@ -766,9 +768,10 @@ const char *const tegra_mc_status_names[32] = { [16] = "MTS carveout violation", [17] = "Generalized carveout violation", [20] = "Route Sanity error", + [21] = "GIC_MSI error", }; -const char *const tegra_mc_error_names[8 ] = { +const char *const tegra20_mc_error_names[8 ] = { [2 ] ="EMEM decode error" , [3 ] ="TrustZone violation" , [4 ] ="Carveout violation" ,
@@ -977,11 +980,13 @@ static int tegra_mc_probe(struct platform_device *pdev) } } -if (mc->soc->num_channels) -mc_ch_writel (mc,MC_BROADCAST_CHANNEL , mc->soc->intmask, -MC_INTMASK ); -else -mc_writel (mc, mc->soc->intmask,MC_INTMASK ); +for (i =0 ; i < mc->soc->num_intmasks; i++) { +if (mc->soc->num_channels) +mc_ch_writel (mc,MC_BROADCAST_CHANNEL , mc->soc->intmasks[i].mask, + mc->soc->intmasks[i].reg); +else +mc_writel (mc, mc->soc->intmasks[i].mask, mc->soc->intmasks[i].reg); + } }if (mc->soc->reset_ops) {
drivers/memory/tegra/mc.h +77 -6
113 lines not on this page · raw message
drivers/memory/tegra/tegra114.c +11 -2
@@ -1101,6 +1101,14 @@ static const struct tegra_mc_reset tegra114_mc_resets[] = { TEGRA114_MC_RESET(VI, 0x200, 0x204, 17), }; +static const struct tegra_mc_intmask tegra114_mc_intmasks[] = { + { + .reg =MC_INTMASK , + .mask =MC_INT_INVALID_SMMU_PAGE |MC_INT_SECURITY_VIOLATION | +MC_INT_DECERR_EMEM , + }, +}; +const struct tegra_mc_soc tegra114_mc_soc = { .clients = tegra114_mc_clients, .num_clients =ARRAY_SIZE (tegra114_mc_clients),
@@ -1108,11 +1116,12 @@ const struct tegra_mc_soc tegra114_mc_soc = { .atom_size = 32, .client_id_mask = 0x7f, .smmu = &tegra114_smmu_soc, - .intmask = MC_INT_INVALID_SMMU_PAGE | MC_INT_SECURITY_VIOLATION | - MC_INT_DECERR_EMEM, + .intmasks = tegra114_mc_intmasks, + .num_intmasks = ARRAY_SIZE(tegra114_mc_intmasks), .reset_ops = &tegra_mc_reset_ops_common, .resets = tegra114_mc_resets, .num_resets = ARRAY_SIZE(tegra114_mc_resets), .ops = &tegra30_mc_ops, .regs = &tegra20_mc_regs, + .mc_err_status_type_mask = (0x7 << 28), };
drivers/memory/tegra/tegra124.c +26 -6
@@ -1258,6 +1258,15 @@ static const struct tegra_smmu_soc tegra124_smmu_soc = { .num_asids = 128, }; +static const struct tegra_mc_intmask tegra124_mc_intmasks[] = { + { + .reg =MC_INTMASK , + .mask =MC_INT_DECERR_MTS |MC_INT_SECERR_SEC |MC_INT_DECERR_VPR | +MC_INT_INVALID_APB_ASID_UPDATE |MC_INT_INVALID_SMMU_PAGE | +MC_INT_SECURITY_VIOLATION |MC_INT_DECERR_EMEM , + }, +}; +const struct tegra_mc_soc tegra124_mc_soc = { .clients = tegra124_mc_clients, .num_clients =ARRAY_SIZE (tegra124_mc_clients),
@@ -1267,15 +1276,16 @@ const struct tegra_mc_soc tegra124_mc_soc = { .smmu = &tegra124_smmu_soc, .emem_regs = tegra124_mc_emem_regs, .num_emem_regs = ARRAY_SIZE(tegra124_mc_emem_regs), - .intmask =MC_INT_DECERR_MTS |MC_INT_SECERR_SEC |MC_INT_DECERR_VPR | -MC_INT_INVALID_APB_ASID_UPDATE |MC_INT_INVALID_SMMU_PAGE | - MC_INT_SECURITY_VIOLATION | MC_INT_DECERR_EMEM, + .intmasks = tegra124_mc_intmasks, + .num_intmasks = ARRAY_SIZE(tegra124_mc_intmasks), .reset_ops = &tegra_mc_reset_ops_common, .resets = tegra124_mc_resets, .num_resets = ARRAY_SIZE(tegra124_mc_resets), .icc_ops = &tegra124_mc_icc_ops, .ops = &tegra30_mc_ops, .regs = &tegra20_mc_regs, + .mc_addr_hi_mask = 0x3, + .mc_err_status_type_mask = (0x7 << 28), };#endif /* CONFIG_ARCH_TEGRA_124_SOC */
@@ -1293,6 +1303,15 @@ static const struct tegra_smmu_soc tegra132_smmu_soc = { .num_asids = 128, }; +static const struct tegra_mc_intmask tegra132_mc_intmasks[] = { + { + .reg =MC_INTMASK , + .mask =MC_INT_DECERR_MTS |MC_INT_SECERR_SEC |MC_INT_DECERR_VPR | +MC_INT_INVALID_APB_ASID_UPDATE |MC_INT_INVALID_SMMU_PAGE | +MC_INT_SECURITY_VIOLATION |MC_INT_DECERR_EMEM , + }, +}; +const struct tegra_mc_soc tegra132_mc_soc = { .clients = tegra124_mc_clients, .num_clients =ARRAY_SIZE (tegra124_mc_clients),
@@ -1300,14 +1319,15 @@ const struct tegra_mc_soc tegra132_mc_soc = { .atom_size = 32, .client_id_mask = 0x7f, .smmu = &tegra132_smmu_soc, - .intmask =MC_INT_DECERR_MTS |MC_INT_SECERR_SEC |MC_INT_DECERR_VPR | -MC_INT_INVALID_APB_ASID_UPDATE |MC_INT_INVALID_SMMU_PAGE | - MC_INT_SECURITY_VIOLATION | MC_INT_DECERR_EMEM, + .intmasks = tegra132_mc_intmasks, + .num_intmasks = ARRAY_SIZE(tegra132_mc_intmasks), .reset_ops = &tegra_mc_reset_ops_common, .resets = tegra124_mc_resets, .num_resets = ARRAY_SIZE(tegra124_mc_resets), .icc_ops = &tegra124_mc_icc_ops, .ops = &tegra30_mc_ops, .regs = &tegra20_mc_regs, + .mc_addr_hi_mask = 0x3, + .mc_err_status_type_mask = (0x7 << 28), };#endif /* CONFIG_ARCH_TEGRA_132_SOC */
drivers/memory/tegra/tegra186.c +17 -7
@@ -23,7 +23,7 @@#define MC_SID_STREAMID_SECURITY_WRITE_ACCESS_DISABLED BIT(16)#define MC_SID_STREAMID_SECURITY_OVERRIDE BIT(8) -static int tegra186_mc_probe (struct tegra_mc *mc) +int tegra186_mc_probe (struct tegra_mc *mc) {struct platform_device *pdev =to_platform_device (mc->dev);struct resource *res;
@@ -76,7 +76,7 @@ static int tegra186_mc_probe(struct tegra_mc *mc)return 0 ; } -static void tegra186_mc_remove (struct tegra_mc *mc) +void tegra186_mc_remove (struct tegra_mc *mc) {of_platform_depopulate (mc->dev); }
@@ -124,7 +124,7 @@ static void tegra186_mc_client_sid_override(struct tegra_mc *mc, }#endif -static int tegra186_mc_probe_device (struct tegra_mc *mc,struct device *dev) +int tegra186_mc_probe_device (struct tegra_mc *mc,struct device *dev) {#if IS_ENABLED (CONFIG_IOMMU_API )struct of_phandle_args args;
@@ -154,7 +154,7 @@ static int tegra186_mc_probe_device(struct tegra_mc *mc, struct device *dev)return 0 ; } -static int tegra186_mc_resume (struct tegra_mc *mc) +int tegra186_mc_resume (struct tegra_mc *mc) {#if IS_ENABLED (CONFIG_IOMMU_API )unsigned int i;
@@ -903,18 +903,28 @@ static const struct tegra_mc_client tegra186_mc_clients[] = { }, }; +static const struct tegra_mc_intmask tegra186_mc_intmasks[] = { + { + .reg =MC_INTMASK , + .mask =MC_INT_DECERR_GENERALIZED_CARVEOUT |MC_INT_DECERR_MTS | +MC_INT_SECERR_SEC |MC_INT_DECERR_VPR | +MC_INT_SECURITY_VIOLATION |MC_INT_DECERR_EMEM , + }, +}; +const struct tegra_mc_soc tegra186_mc_soc = { .num_clients =ARRAY_SIZE (tegra186_mc_clients), .clients = tegra186_mc_clients, .num_address_bits =40 , .num_channels =4 , .client_id_mask =0xff , - .intmask =MC_INT_DECERR_GENERALIZED_CARVEOUT |MC_INT_DECERR_MTS | -MC_INT_SECERR_SEC |MC_INT_DECERR_VPR | -MC_INT_SECURITY_VIOLATION |MC_INT_DECERR_EMEM , + .intmasks = tegra186_mc_intmasks, + .num_intmasks =ARRAY_SIZE (tegra186_mc_intmasks), .ops = &tegra186_mc_ops, .ch_intmask =0x0000000f , .global_intstatus_channel_shift =0 , .regs = &tegra20_mc_regs, + .mc_addr_hi_mask =0x3 , + .mc_err_status_type_mask = (0x7 <<28 ), };#endif
drivers/memory/tegra/tegra194.c +13 -4
@@ -1343,20 +1343,29 @@ static const struct tegra_mc_client tegra194_mc_clients[] = { }, }; +static const struct tegra_mc_intmask tegra194_mc_intmasks[] = { + { + .reg =MC_INTMASK , + .mask =MC_INT_DECERR_ROUTE_SANITY |MC_INT_DECERR_GENERALIZED_CARVEOUT | +MC_INT_DECERR_MTS |MC_INT_SECERR_SEC |MC_INT_DECERR_VPR | +MC_INT_SECURITY_VIOLATION |MC_INT_DECERR_EMEM , + }, +}; +const struct tegra_mc_soc tegra194_mc_soc = { .num_clients =ARRAY_SIZE (tegra194_mc_clients), .clients = tegra194_mc_clients, .num_address_bits =40 , .num_channels =16 , .client_id_mask =0xff , - .intmask =MC_INT_DECERR_ROUTE_SANITY | -MC_INT_DECERR_GENERALIZED_CARVEOUT |MC_INT_DECERR_MTS | -MC_INT_SECERR_SEC |MC_INT_DECERR_VPR | -MC_INT_SECURITY_VIOLATION |MC_INT_DECERR_EMEM , + .intmasks = tegra194_mc_intmasks, + .num_intmasks =ARRAY_SIZE (tegra194_mc_intmasks), .has_addr_hi_reg = true, .ops = &tegra186_mc_ops, .icc_ops = &tegra_mc_icc_ops, .ch_intmask =0x00000f00 , .global_intstatus_channel_shift =8 , .regs = &tegra20_mc_regs, + .mc_addr_hi_mask =0x3 , + .mc_err_status_type_mask = (0x7 <<28 ), };
drivers/memory/tegra/tegra20.c +16 -7
@@ -695,12 +695,12 @@ static irqreturn_t tegra20_mc_handle_irq(int irq, void *data)unsigned int bit;/* mask all interrupts to avoid flooding */ - status =mc_readl (mc,MC_INTSTATUS ) & mc->soc->intmask; + status =mc_readl (mc,MC_INTSTATUS ) & mc->soc->intmasks[0 ].mask;if (!status)return IRQ_NONE ;for_each_set_bit (bit, &status,32 ) { -const char *error = tegra_mc_status_names[bit]; +const char *error = tegra20_mc_status_names[bit];const char *direction ="read" , *secure ="" ;const char *client, *desc;phys_addr_t addr;
@@ -713,7 +713,7 @@ static irqreturn_t tegra20_mc_handle_irq(int irq, void *data) value =mc_readl (mc, reg); id = value & mc->soc->client_id_mask; - desc = tegra_mc_error_names[2 ]; + desc = tegra20_mc_error_names[2 ];if (value &BIT (31 )) direction ="write" ;
@@ -724,7 +724,7 @@ static irqreturn_t tegra20_mc_handle_irq(int irq, void *data) value =mc_readl (mc, reg); id = (value >>1 ) & mc->soc->client_id_mask; - desc = tegra_mc_error_names[2 ]; + desc = tegra20_mc_error_names[2 ];if (value &BIT (0 )) direction ="write" ;
@@ -736,7 +736,7 @@ static irqreturn_t tegra20_mc_handle_irq(int irq, void *data) id = value & mc->soc->client_id_mask; type = (value &BIT (30 )) ?4 :3 ; - desc = tegra_mc_error_names[type]; + desc = tegra20_mc_error_names[type]; secure ="secure " ;if (value &BIT (31 ))
@@ -771,17 +771,26 @@ static const struct tegra_mc_ops tegra20_mc_ops = { .num_interrupts = ARRAY_SIZE(tegra20_mc_irq_handlers), }; +static const struct tegra_mc_intmask tegra20_mc_intmasks[] = { + { + .reg =MC_INTMASK , + .mask =MC_INT_SECURITY_VIOLATION |MC_INT_INVALID_GART_PAGE | +MC_INT_DECERR_EMEM , + }, +}; +const struct tegra_mc_soc tegra20_mc_soc = { .clients = tegra20_mc_clients, .num_clients =ARRAY_SIZE (tegra20_mc_clients), .num_address_bits =32 , .client_id_mask =0x3f , - .intmask =MC_INT_SECURITY_VIOLATION |MC_INT_INVALID_GART_PAGE | -MC_INT_DECERR_EMEM , + .intmasks = tegra20_mc_intmasks, + .num_intmasks =ARRAY_SIZE (tegra20_mc_intmasks), .reset_ops = &tegra20_mc_reset_ops, .resets = tegra20_mc_resets, .num_resets =ARRAY_SIZE (tegra20_mc_resets), .icc_ops = &tegra20_mc_icc_ops, .ops = &tegra20_mc_ops, .regs = &tegra20_mc_regs, + .mc_err_status_type_mask = (0x7 <<28 ), };
drivers/memory/tegra/tegra210.c +13 -3
@@ -1273,6 +1273,15 @@ static const struct tegra_mc_reset tegra210_mc_resets[] = { TEGRA210_MC_RESET(TSECB, 0x970, 0x974, 13), }; +static const struct tegra_mc_intmask tegra210_mc_intmasks[] = { + { + .reg =MC_INTMASK , + .mask =MC_INT_DECERR_MTS |MC_INT_SECERR_SEC |MC_INT_DECERR_VPR | +MC_INT_INVALID_APB_ASID_UPDATE |MC_INT_INVALID_SMMU_PAGE | +MC_INT_SECURITY_VIOLATION |MC_INT_DECERR_EMEM , + }, +}; +const struct tegra_mc_soc tegra210_mc_soc = { .clients = tegra210_mc_clients, .num_clients =ARRAY_SIZE (tegra210_mc_clients),
@@ -1280,12 +1289,13 @@ const struct tegra_mc_soc tegra210_mc_soc = { .atom_size = 64, .client_id_mask = 0xff, .smmu = &tegra210_smmu_soc, - .intmask =MC_INT_DECERR_MTS |MC_INT_SECERR_SEC |MC_INT_DECERR_VPR | -MC_INT_INVALID_APB_ASID_UPDATE |MC_INT_INVALID_SMMU_PAGE | - MC_INT_SECURITY_VIOLATION | MC_INT_DECERR_EMEM, + .intmasks = tegra210_mc_intmasks, + .num_intmasks = ARRAY_SIZE(tegra210_mc_intmasks), .reset_ops = &tegra_mc_reset_ops_common, .resets = tegra210_mc_resets, .num_resets = ARRAY_SIZE(tegra210_mc_resets), .ops = &tegra30_mc_ops, .regs = &tegra20_mc_regs, + .mc_addr_hi_mask = 0x3, + .mc_err_status_type_mask = (0x7 << 28), };
drivers/memory/tegra/tegra234.c +13 -4
@@ -1132,16 +1132,23 @@ static const struct tegra_mc_icc_ops tegra234_mc_icc_ops = { .set = tegra234_mc_icc_set, }; +static const struct tegra_mc_intmask tegra234_mc_intmasks[] = { + { + .reg =MC_INTMASK , + .mask =MC_INT_DECERR_ROUTE_SANITY |MC_INT_DECERR_GENERALIZED_CARVEOUT | +MC_INT_DECERR_MTS |MC_INT_SECERR_SEC |MC_INT_DECERR_VPR | +MC_INT_SECURITY_VIOLATION |MC_INT_DECERR_EMEM , + }, +}; +const struct tegra_mc_soc tegra234_mc_soc = { .num_clients =ARRAY_SIZE (tegra234_mc_clients), .clients = tegra234_mc_clients, .num_address_bits =40 , .num_channels =16 , .client_id_mask =0x1ff , - .intmask =MC_INT_DECERR_ROUTE_SANITY | -MC_INT_DECERR_GENERALIZED_CARVEOUT |MC_INT_DECERR_MTS | -MC_INT_SECERR_SEC |MC_INT_DECERR_VPR | -MC_INT_SECURITY_VIOLATION |MC_INT_DECERR_EMEM , + .intmasks = tegra234_mc_intmasks, + .num_intmasks =ARRAY_SIZE (tegra234_mc_intmasks), .has_addr_hi_reg = true, .ops = &tegra186_mc_ops, .icc_ops = &tegra234_mc_icc_ops,
@@ -1153,4 +1160,6 @@ const struct tegra_mc_soc tegra234_mc_soc = {*/ .num_carveouts = 32, .regs = &tegra20_mc_regs, + .mc_addr_hi_mask = 0x3, + .mc_err_status_type_mask = (0x7 << 28), };
drivers/memory/tegra/tegra264.c +422 -6
462 lines not on this page · raw message
drivers/memory/tegra/tegra30.c +11 -2
@@ -1384,6 +1384,14 @@ static const struct tegra_mc_icc_ops tegra30_mc_icc_ops = { .set = tegra30_mc_icc_set, }; +static const struct tegra_mc_intmask tegra30_mc_intmasks[] = { + { + .reg =MC_INTMASK , + .mask =MC_INT_INVALID_SMMU_PAGE |MC_INT_SECURITY_VIOLATION | +MC_INT_DECERR_EMEM , + }, +}; +const struct tegra_mc_soc tegra30_mc_soc = { .clients = tegra30_mc_clients, .num_clients =ARRAY_SIZE (tegra30_mc_clients),
@@ -1393,12 +1401,13 @@ const struct tegra_mc_soc tegra30_mc_soc = { .smmu = &tegra30_smmu_soc, .emem_regs = tegra30_mc_emem_regs, .num_emem_regs = ARRAY_SIZE(tegra30_mc_emem_regs), - .intmask = MC_INT_INVALID_SMMU_PAGE | MC_INT_SECURITY_VIOLATION | - MC_INT_DECERR_EMEM, + .intmasks = tegra30_mc_intmasks, + .num_intmasks = ARRAY_SIZE(tegra30_mc_intmasks), .reset_ops = &tegra_mc_reset_ops_common, .resets = tegra30_mc_resets, .num_resets = ARRAY_SIZE(tegra30_mc_resets), .icc_ops = &tegra30_mc_icc_ops, .ops = &tegra30_mc_ops, .regs = &tegra20_mc_regs, + .mc_err_status_type_mask = (0x7 << 28), };
include/soc/tegra/mc.h +9 -1
@@ -187,6 +187,11 @@ struct tegra_mc_regs {unsigned int err_route_add; }; +struct tegra_mc_intmask { +u32 reg; +u32 mask; +}; +struct tegra_mc_soc {const struct tegra_mc_client *clients;unsigned int num_clients;
@@ -204,7 +209,6 @@ struct tegra_mc_soc {const struct tegra_smmu_soc *smmu; -u32 intmask;u32 ch_intmask;u32 global_intstatus_channel_shift;bool has_addr_hi_reg;
@@ -216,6 +220,10 @@ struct tegra_mc_soc {const struct tegra_mc_icc_ops *icc_ops;const struct tegra_mc_ops *ops;const struct tegra_mc_regs *regs; +unsigned int mc_addr_hi_mask; +unsigned int mc_err_status_type_mask; +const struct tegra_mc_intmask *intmasks; +const unsigned int num_intmasks; };struct tegra_mc {
Signature · 1 line
2.17.1
Krzysztof Kozlowski
maintainerRe: [PATCH v6 4/4] memory: tegra: Add MC error logging support for Tegra264
Quoted 60 lines · Ketan Patil
In Tegra264, different components from memory subsystems like Memory Controller Fabric (MCF), HUB, HUB Common (HUBC), Side Band Shim (SBS) and channels have different interrupt lines for receiving memory controller error interrupts.
Add support for logging memory controller errors on Tegra264.
- Add MC error handling flow for MCF, HUB, HUBC, SBS and channels.
- Each of these components have different interrupt lines for MC error.
- Register interrupt handlers for interrupts from these different MC components.
- There is no global interrupt status register in Tegra264 unlike older Tegra chips.
- There are common interrupt status registers in case of MCF, HUB, HUBC from which figure out the slice number or hub number responsible for generating interrupt and then read interrupt status register to find out type of violation.
- Introduce new SoC specific fields integra_mc_soclike interrupt mask values for MCF, HUB, HUBC etc., which are SoC specific.Signed-off-by Ketan Patil <[email protected]>--- drivers/memory/tegra/mc.c | 35 +-- drivers/memory/tegra/mc.h | 83 ++++++- drivers/memory/tegra/tegra114.c | 13 +- drivers/memory/tegra/tegra124.c | 32 ++- drivers/memory/tegra/tegra186.c | 24 +- drivers/memory/tegra/tegra194.c | 17 +- drivers/memory/tegra/tegra20.c | 23 +- drivers/memory/tegra/tegra210.c | 16 +- drivers/memory/tegra/tegra234.c | 17 +- drivers/memory/tegra/tegra264.c | 428 +++++++++++++++++++++++++++++++- drivers/memory/tegra/tegra30.c | 13 +- include/soc/tegra/mc.h | 10 +- 12 files changed, 648 insertions(+), 63 deletions(-)drivers/memory/tegra/mc.c +3
-3@@ -597,16 +597,16 @@ irqreturn_t tegra30_mc_handle_irq(int irq, void *data) }/* mask all interrupts to avoid flooding */ - status =mc_ch_readl (mc, channel,MC_INTSTATUS ) & mc->soc->intmask; + status =mc_ch_readl (mc, channel,MC_INTSTATUS ) & mc->soc->intmasks[0 ].mask; }else { - status =mc_readl (mc,MC_INTSTATUS ) & mc->soc->intmask; + status =mc_readl (mc,MC_INTSTATUS ) & mc->soc->intmasks[0 ].mask; }if (!status)return IRQ_NONE ;for_each_set_bit (bit, &status,32 ) { -const char *error = tegra_mc_status_names[bit] ?:"unknown" ; +const char *error = tegra20_mc_status_names[bit] ?:"unknown" ;const char *client ="unknown" , *desc;const char *direction, *secure;u32 status_reg, addr_reg;
drivers/memory/tegra/mc.c irqreturn_t tegra30_mc_handle_irq(int irq, void *data) · line 676
Quoted 10 lines
drivers/memory/tegra/mc.c +4
-2@@ -669,9 +669,11 @@ irqreturn_t tegra30_mc_handle_irq(int irq, void *data) addr =mc_ch_readl (mc, channel, addr_hi_reg); else addr =mc_readl (mc, addr_hi_reg); - }else { + }else if (mc->soc->mc_addr_hi_mask) { addr = ((value >>MC_ERR_STATUS_ADR_HI_SHIFT ) & -MC_ERR_STATUS_ADR_HI_MASK ); + mc->soc->mc_addr_hi_mask); + }else { +WARN_ON (1 );
You should handle it correctly instead. WARN reboots some systems and this does not look like really impossible path, which would justify it.
Quoted 7 lines
drivers/memory/tegra/mc.c +0
-0} addr <<=32 ; }@@ -696,11 +698,11 @@ irqreturn_t tegra30_mc_handle_irq(int irq, void *data) } }
...
Quoted 17 lines
drivers/memory/tegra/mc.c +7
-2+ +#define ERR_GENERALIZED_APERTURE_ID_SHIFT 0 +#define ERR_GENERALIZED_APERTURE_ID_MASK 0x1F +#define ERR_GENERALIZED_CARVEOUT_APERTURE_ID_SHIFT 5 +#define ERR_GENERALIZED_CARVEOUT_APERTURE_ID_MASK 0x1F +static inline u32 tegra_mc_scale_percents (u64 val,unsigned int percents) { val = val * percents;@@ -187,15 +255,18 @@ extern const struct tegra_mc_ops tegra30_mc_ops;#if defined(CONFIG_ARCH_TEGRA_186_SOC ) || \ defined(CONFIG_ARCH_TEGRA_194_SOC ) || \ - defined(CONFIG_ARCH_TEGRA_234_SOC ) || \ - defined(CONFIG_ARCH_TEGRA_264_SOC ) + defined(CONFIG_ARCH_TEGRA_234_SOC )extern const struct tegra_mc_ops tegra186_mc_ops;
drivers/memory/tegra/mc.c extern const struct tegra_mc_ops tegra30_mc_ops; · line 267
Quoted 10 lines
drivers/memory/tegra/mc.c +4
-2#endif irqreturn_t tegra30_mc_handle_irq (int irq,void *data);extern const irq_handler_t tegra30_mc_irq_handlers[]; -extern const char *const tegra_mc_status_names[32 ]; -extern const char *const tegra_mc_error_names[8 ]; +extern const char *const tegra20_mc_status_names[32 ]; +extern const char *const tegra20_mc_error_names[8 ]; +int tegra186_mc_probe (struct tegra_mc *mc); +int tegra186_mc_probe_device (struct tegra_mc *mc,struct device *dev);
This is such a confusing design... Function declared in mc.h header, defined in a MODULE but used in a driver which can only be built in, because it depends on some ARCH_foo stuf. If I deciphered it correctly this fails and needs EXPORT_SYMBOL_GPL, but maybe I deciphered it wrong, because code is confusing. Your drivers Makefile should not have ARCH_TEGRA_FOO, but dedicated entries so the state of each driver is obvious by reading Kconfig of this directory - it is built-in or tristate.
drivers/memory/tegra/mc.c extern const struct tegra_mc_ops tegra30_mc_ops; · line 270
Quoted 3 lines
drivers/memory/tegra/mc.c +2
-0+int tegra186_mc_resume (struct tegra_mc *mc); +void tegra186_mc_remove (struct tegra_mc *mc);
_mc {
Best regards,
Krzysztof
Re: [PATCH v6 4/4] memory: tegra: Add MC error logging support for Tegra264
Quoted 68 lines · Krzysztof Kozlowski
External email: Use caution opening links or attachments
Quoted 64 lines · Ketan Patil
In Tegra264, different components from memory subsystems like Memory Controller Fabric (MCF), HUB, HUB Common (HUBC), Side Band Shim (SBS) and channels have different interrupt lines for receiving memory controller error interrupts.
Add support for logging memory controller errors on Tegra264.
- Add MC error handling flow for MCF, HUB, HUBC, SBS and channels.
- Each of these components have different interrupt lines for MC error.
- Register interrupt handlers for interrupts from these different MC components.
- There is no global interrupt status register in Tegra264 unlike older Tegra chips.
- There are common interrupt status registers in case of MCF, HUB, HUBC from which figure out the slice number or hub number responsible for generating interrupt and then read interrupt status register to find out type of violation.
- Introduce new SoC specific fields integra_mc_soclike interrupt mask values for MCF, HUB, HUBC etc., which are SoC specific.Signed-off-by Ketan Patil <[email protected]>--- drivers/memory/tegra/mc.c | 35 +-- drivers/memory/tegra/mc.h | 83 ++++++- drivers/memory/tegra/tegra114.c | 13 +- drivers/memory/tegra/tegra124.c | 32 ++- drivers/memory/tegra/tegra186.c | 24 +- drivers/memory/tegra/tegra194.c | 17 +- drivers/memory/tegra/tegra20.c | 23 +- drivers/memory/tegra/tegra210.c | 16 +- drivers/memory/tegra/tegra234.c | 17 +- drivers/memory/tegra/tegra264.c | 428 +++++++++++++++++++++++++++++++- drivers/memory/tegra/tegra30.c | 13 +- include/soc/tegra/mc.h | 10 +- 12 files changed, 648 insertions(+), 63 deletions(-)drivers/memory/tegra/mc.c +3
-4@@ -597,16 +597,16 @@ irqreturn_t tegra30_mc_handle_irq(int irq, void *data) }/* mask all interrupts to avoid flooding */ - status =mc_ch_readl (mc, channel,MC_INTSTATUS ) & mc->soc->intmask; + status =mc_ch_readl (mc, channel,MC_INTSTATUS ) & mc->soc->intmasks[0 ].mask; }else { - status =mc_readl (mc,MC_INTSTATUS ) & mc->soc->intmask; + status =mc_readl (mc,MC_INTSTATUS ) & mc->soc->intmasks[0 ].mask; }if (!status)return IRQ_NONE ;for_each_set_bit (bit, &status,32 ) { -const char *error = tegra_mc_status_names[bit] ?:"unknown" ; +const char *error = tegra20_mc_status_names[bit] ?:"unknown" ;const char *client ="unknown" , *desc;const char *direction, *secure;u32 status_reg, addr_reg;@@ -669,9 +669,11 @@ irqreturn_t tegra30_mc_handle_irq(int irq, void *data) addr =mc_ch_readl (mc, channel, addr_hi_reg); else addr =mc_readl (mc, addr_hi_reg); - }else {
Quoted 8 lines
drivers/memory/tegra/mc.c irqreturn_t tegra30_mc_handle_irq(int irq, void *data) · line 676
Quoted 6 lines
drivers/memory/tegra/mc.c +4
-1+ }else if (mc->soc->mc_addr_hi_mask) { addr = ((value >>MC_ERR_STATUS_ADR_HI_SHIFT ) & -MC_ERR_STATUS_ADR_HI_MASK ); + mc->soc->mc_addr_hi_mask); + }else { +WARN_ON (1 );You should handle it correctly instead. WARN reboots some systems and this does not look like really impossible path, which would justify it.
Yes, I am taking care of this in the next revision.
Quoted 29 lines
Quoted 8 lines
drivers/memory/tegra/mc.c +0
-0} addr <<=32 ; }@@ -696,11 +698,11 @@ irqreturn_t tegra30_mc_handle_irq(int irq, void *data) } }...
Quoted 19 lines
drivers/memory/tegra/mc.c +7
-2+ +#define ERR_GENERALIZED_APERTURE_ID_SHIFT 0 +#define ERR_GENERALIZED_APERTURE_ID_MASK 0x1F +#define ERR_GENERALIZED_CARVEOUT_APERTURE_ID_SHIFT 5 +#define ERR_GENERALIZED_CARVEOUT_APERTURE_ID_MASK 0x1F +static inline u32 tegra_mc_scale_percents (u64 val,unsigned int percents) { val = val * percents;@@ -187,15 +255,18 @@ extern const struct tegra_mc_ops tegra30_mc_ops;#if defined(CONFIG_ARCH_TEGRA_186_SOC ) || \ defined(CONFIG_ARCH_TEGRA_194_SOC ) || \ - defined(CONFIG_ARCH_TEGRA_234_SOC ) || \ - defined(CONFIG_ARCH_TEGRA_264_SOC ) + defined(CONFIG_ARCH_TEGRA_234_SOC )extern const struct tegra_mc_ops tegra186_mc_ops;#endif
Quoted 15 lines
drivers/memory/tegra/mc.c extern const struct tegra_mc_ops tegra30_mc_ops; · line 267
Quoted 8 lines
drivers/memory/tegra/mc.c +4
-2irqreturn_t tegra30_mc_handle_irq (int irq,void *data);extern const irq_handler_t tegra30_mc_irq_handlers[]; -extern const char *const tegra_mc_status_names[32 ]; -extern const char *const tegra_mc_error_names[8 ]; +extern const char *const tegra20_mc_status_names[32 ]; +extern const char *const tegra20_mc_error_names[8 ]; +int tegra186_mc_probe (struct tegra_mc *mc); +int tegra186_mc_probe_device (struct tegra_mc *mc,struct device *dev);This is such a confusing design... Function declared in
mc.hheader, defined in a MODULE but used in a driver which can only be built in, because it depends on someARCH_foostuf. If I deciphered it correctly this fails and needsEXPORT_SYMBOL_GPL, but maybe I deciphered it wrong, because code is confusing. Your driversMakefileshould not haveARCH_TEGRA_FOO, but dedicated entries so the state of each driver is obvious by readingKconfigof this directory - it is built-in or tristate.
I am re-working the series to avoid making these functions public.
Quoted 9 lines
drivers/memory/tegra/mc.c extern const struct tegra_mc_ops tegra30_mc_ops; · line 270
Quoted 4 lines
drivers/memory/tegra/mc.c +2
-0+int tegra186_mc_resume (struct tegra_mc *mc); +void tegra186_mc_remove (struct tegra_mc *mc);
_mc{Best regards,
Krzysztof
Thanks
Quoted 6 lines · Ketan Patil
In Tegra264, different components from memory subsystems like Memory Controller Fabric (MCF), HUB, HUB Common (HUBC), Side Band Shim (SBS) and MC Channels have different interrupt lines for receiving memory controller error interrupts. This patch set includes changes to add support and enable Memory Controller error logging for Tegra264.
Quoted 6 lines
Ketan Patil (4):
memory: tegra: Group error handling related registers
memory: tegra: Group register and fields
memory: tegra: Add support for multiple IRQs
memory: tegra: Add MC error logging support for Tegra264
For the series ...
Thanks
Jon
Signature · 1 line
nvpublic