cip-dev.lists.cip-project.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 5.10.y-cip 0/7] CANFD Improvement
@ 2022-12-13 17:23 Biju Das
  2022-12-13 17:23 ` [PATCH 5.10.y-cip 1/7] can: rcar_canfd: rcar_canfd_handle_global_receive(): fix IRQ storm on global FIFO receive Biju Das
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: Biju Das @ 2022-12-13 17:23 UTC (permalink / raw)
  To: cip-dev, Nobuhiro Iwamatsu, Pavel Machek
  Cc: Chris Paterson, Biju Das, Prabhakar Mahadev Lad

This patch series aims to fix IRQ storm issue as well as
some enhancements to Renesas CANFD driver.

Biju Das (6):
  can: rcar_canfd: rcar_canfd_handle_global_receive(): fix IRQ storm on
    global FIFO receive
  can: rcar_canfd: Use devm_reset_control_get_optional_exclusive
  can: rcar_canfd: rcar_canfd_probe: Add struct rcar_canfd_hw_info to
    driver data
  can: rcar_canfd: Add shared_global_irqs to struct rcar_canfd_hw_info
  can: rcar_canfd: Add postdiv to struct rcar_canfd_hw_info
  can: rcar_canfd: Add multi_channel_irqs to struct rcar_canfd_hw_info

Geert Uytterhoeven (1):
  can: rcar_canfd: Add missing ECC error checks for channels 2-7

 drivers/net/can/rcar/rcar_canfd.c | 92 +++++++++++++++++--------------
 1 file changed, 51 insertions(+), 41 deletions(-)

-- 
2.25.1



^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH 5.10.y-cip 1/7] can: rcar_canfd: rcar_canfd_handle_global_receive(): fix IRQ storm on global FIFO receive
  2022-12-13 17:23 [PATCH 5.10.y-cip 0/7] CANFD Improvement Biju Das
@ 2022-12-13 17:23 ` Biju Das
  2022-12-13 17:23 ` [PATCH 5.10.y-cip 2/7] can: rcar_canfd: Add missing ECC error checks for channels 2-7 Biju Das
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Biju Das @ 2022-12-13 17:23 UTC (permalink / raw)
  To: cip-dev, Nobuhiro Iwamatsu, Pavel Machek
  Cc: Chris Paterson, Biju Das, Prabhakar Mahadev Lad

commit 702de2c21eed04c67cefaaedc248ef16e5f6b293 upstream.

We are seeing an IRQ storm on the global receive IRQ line under heavy
CAN bus load conditions with both CAN channels enabled.

Conditions:

The global receive IRQ line is shared between can0 and can1, either of
the channels can trigger interrupt while the other channel's IRQ line
is disabled (RFIE).

When global a receive IRQ interrupt occurs, we mask the interrupt in
the IRQ handler. Clearing and unmasking of the interrupt is happening
in rx_poll(). There is a race condition where rx_poll() unmasks the
interrupt, but the next IRQ handler does not mask the IRQ due to
NAPIF_STATE_MISSED flag (e.g.: can0 RX FIFO interrupt is disabled and
can1 is triggering RX interrupt, the delay in rx_poll() processing
results in setting NAPIF_STATE_MISSED flag) leading to an IRQ storm.

This patch fixes the issue by checking IRQ active and enabled before
handling the IRQ on a particular channel.

Fixes: dd3bd23eb438 ("can: rcar_canfd: Add Renesas R-Car CAN FD driver")
Suggested-by: Marc Kleine-Budde <mkl@pengutronix.de>
Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
Link: https://lore.kernel.org/all/20221025155657.1426948-2-biju.das.jz@bp.renesas.com
Cc: stable@vger.kernel.org
[mkl: adjust commit message]
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
[biju: removed gpriv from RCANFD_RFCC_RFIE macro]
Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/net/can/rcar/rcar_canfd.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/net/can/rcar/rcar_canfd.c b/drivers/net/can/rcar/rcar_canfd.c
index feba57833cdc..f93b44ae4121 100644
--- a/drivers/net/can/rcar/rcar_canfd.c
+++ b/drivers/net/can/rcar/rcar_canfd.c
@@ -1106,11 +1106,13 @@ static void rcar_canfd_handle_global_receive(struct rcar_canfd_global *gpriv, u3
 {
 	struct rcar_canfd_channel *priv = gpriv->ch[ch];
 	u32 ridx = ch + RCANFD_RFFIFO_IDX;
-	u32 sts;
+	u32 sts, cc;
 
 	/* Handle Rx interrupts */
 	sts = rcar_canfd_read(priv->base, RCANFD_RFSTS(ridx));
-	if (likely(sts & RCANFD_RFSTS_RFIF)) {
+	cc = rcar_canfd_read(priv->base, RCANFD_RFCC(ridx));
+	if (likely(sts & RCANFD_RFSTS_RFIF &&
+		   cc & RCANFD_RFCC_RFIE)) {
 		if (napi_schedule_prep(&priv->napi)) {
 			/* Disable Rx FIFO interrupts */
 			rcar_canfd_clear_bit(priv->base,
-- 
2.25.1



^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 5.10.y-cip 2/7] can: rcar_canfd: Add missing ECC error checks for channels 2-7
  2022-12-13 17:23 [PATCH 5.10.y-cip 0/7] CANFD Improvement Biju Das
  2022-12-13 17:23 ` [PATCH 5.10.y-cip 1/7] can: rcar_canfd: rcar_canfd_handle_global_receive(): fix IRQ storm on global FIFO receive Biju Das
@ 2022-12-13 17:23 ` Biju Das
  2022-12-13 17:23 ` [PATCH 5.10.y-cip 3/7] can: rcar_canfd: Use devm_reset_control_get_optional_exclusive Biju Das
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Biju Das @ 2022-12-13 17:23 UTC (permalink / raw)
  To: cip-dev, Nobuhiro Iwamatsu, Pavel Machek
  Cc: Chris Paterson, Biju Das, Prabhakar Mahadev Lad

From: Geert Uytterhoeven <geert+renesas@glider.be>

commit 8b043dfb3dc7c32f9c2c0c93e3c2de346ee5e358 upstream.

When introducing support for R-Car V3U, which has 8 instead of 2
channels, the ECC error bitmask was extended to take into account the
extra channels, but rcar_canfd_global_error() was not updated to act
upon the extra bits.

Replace the RCANFD_GERFL_EEF[01] macros by a new macro that takes the
channel number, fixing R-Car V3U while simplifying the code.

Fixes: 45721c406dcf50d4 ("can: rcar_canfd: Add support for r8a779a0 SoC")
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Reviewed-by: Biju Das <biju.das.jz@bp.renesas.com>
Link: https://lore.kernel.org/all/4edb2ea46cc64d0532a08a924179827481e14b4f.1666951503.git.geert+renesas@glider.be
Cc: stable@vger.kernel.org
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
[biju: removed V3U changes and updated RCANFD_GERFL_ERR macro]
Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
---
 drivers/net/can/rcar/rcar_canfd.c | 15 +++++----------
 1 file changed, 5 insertions(+), 10 deletions(-)

diff --git a/drivers/net/can/rcar/rcar_canfd.c b/drivers/net/can/rcar/rcar_canfd.c
index f93b44ae4121..a44277f31f69 100644
--- a/drivers/net/can/rcar/rcar_canfd.c
+++ b/drivers/net/can/rcar/rcar_canfd.c
@@ -79,15 +79,14 @@ enum rcanfd_chip_id {
 #define RCANFD_GSTS_GNOPM		(BIT(0) | BIT(1) | BIT(2) | BIT(3))
 
 /* RSCFDnCFDGERFL / RSCFDnGERFL */
-#define RCANFD_GERFL_EEF1		BIT(17)
-#define RCANFD_GERFL_EEF0		BIT(16)
+#define RCANFD_GERFL_EEF(ch)		BIT(16 + (ch))
 #define RCANFD_GERFL_CMPOF		BIT(3)	/* CAN FD only */
 #define RCANFD_GERFL_THLES		BIT(2)
 #define RCANFD_GERFL_MES		BIT(1)
 #define RCANFD_GERFL_DEF		BIT(0)
 
-#define RCANFD_GERFL_ERR(gpriv, x)	((x) & (RCANFD_GERFL_EEF1 |\
-					RCANFD_GERFL_EEF0 | RCANFD_GERFL_MES |\
+#define RCANFD_GERFL_ERR(gpriv, x)	((x) & (RCANFD_GERFL_EEF(1) |\
+					RCANFD_GERFL_EEF(0) | RCANFD_GERFL_MES |\
 					(gpriv->fdmode ?\
 					 RCANFD_GERFL_CMPOF : 0)))
 
@@ -881,12 +880,8 @@ static void rcar_canfd_global_error(struct net_device *ndev)
 	u32 ridx = ch + RCANFD_RFFIFO_IDX;
 
 	gerfl = rcar_canfd_read(priv->base, RCANFD_GERFL);
-	if ((gerfl & RCANFD_GERFL_EEF0) && (ch == 0)) {
-		netdev_dbg(ndev, "Ch0: ECC Error flag\n");
-		stats->tx_dropped++;
-	}
-	if ((gerfl & RCANFD_GERFL_EEF1) && (ch == 1)) {
-		netdev_dbg(ndev, "Ch1: ECC Error flag\n");
+	if (gerfl & RCANFD_GERFL_EEF(ch)) {
+		netdev_dbg(ndev, "Ch%u: ECC Error flag\n", ch);
 		stats->tx_dropped++;
 	}
 	if (gerfl & RCANFD_GERFL_MES) {
-- 
2.25.1



^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 5.10.y-cip 3/7] can: rcar_canfd: Use devm_reset_control_get_optional_exclusive
  2022-12-13 17:23 [PATCH 5.10.y-cip 0/7] CANFD Improvement Biju Das
  2022-12-13 17:23 ` [PATCH 5.10.y-cip 1/7] can: rcar_canfd: rcar_canfd_handle_global_receive(): fix IRQ storm on global FIFO receive Biju Das
  2022-12-13 17:23 ` [PATCH 5.10.y-cip 2/7] can: rcar_canfd: Add missing ECC error checks for channels 2-7 Biju Das
@ 2022-12-13 17:23 ` Biju Das
  2022-12-13 17:23 ` [PATCH 5.10.y-cip 4/7] can: rcar_canfd: rcar_canfd_probe: Add struct rcar_canfd_hw_info to driver data Biju Das
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Biju Das @ 2022-12-13 17:23 UTC (permalink / raw)
  To: cip-dev, Nobuhiro Iwamatsu, Pavel Machek
  Cc: Chris Paterson, Biju Das, Prabhakar Mahadev Lad

commit 68399ff574e4faf42b8d85da9339ca3ee2892cc7 upstream.

Replace devm_reset_control_get_exclusive->devm_reset_control_
get_optional_exclusive so that we can avoid unnecessary
SoC specific check in probe().

Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Link: https://lore.kernel.org/all/20221025155657.1426948-4-biju.das.jz@bp.renesas.com
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
---
 drivers/net/can/rcar/rcar_canfd.c | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/drivers/net/can/rcar/rcar_canfd.c b/drivers/net/can/rcar/rcar_canfd.c
index a44277f31f69..e485efc00b49 100644
--- a/drivers/net/can/rcar/rcar_canfd.c
+++ b/drivers/net/can/rcar/rcar_canfd.c
@@ -1805,17 +1805,17 @@ static int rcar_canfd_probe(struct platform_device *pdev)
 	gpriv->fdmode = fdmode;
 	gpriv->chip_id = chip_id;
 
-	if (gpriv->chip_id == RENESAS_RZG2L) {
-		gpriv->rstc1 = devm_reset_control_get_exclusive(&pdev->dev, "rstp_n");
-		if (IS_ERR(gpriv->rstc1))
-			return dev_err_probe(&pdev->dev, PTR_ERR(gpriv->rstc1),
-					     "failed to get rstp_n\n");
-
-		gpriv->rstc2 = devm_reset_control_get_exclusive(&pdev->dev, "rstc_n");
-		if (IS_ERR(gpriv->rstc2))
-			return dev_err_probe(&pdev->dev, PTR_ERR(gpriv->rstc2),
-					     "failed to get rstc_n\n");
-	}
+	gpriv->rstc1 = devm_reset_control_get_optional_exclusive(&pdev->dev,
+								 "rstp_n");
+	if (IS_ERR(gpriv->rstc1))
+		return dev_err_probe(&pdev->dev, PTR_ERR(gpriv->rstc1),
+				     "failed to get rstp_n\n");
+
+	gpriv->rstc2 = devm_reset_control_get_optional_exclusive(&pdev->dev,
+								 "rstc_n");
+	if (IS_ERR(gpriv->rstc2))
+		return dev_err_probe(&pdev->dev, PTR_ERR(gpriv->rstc2),
+				     "failed to get rstc_n\n");
 
 	/* Peripheral clock */
 	gpriv->clkp = devm_clk_get(&pdev->dev, "fck");
-- 
2.25.1



^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 5.10.y-cip 4/7] can: rcar_canfd: rcar_canfd_probe: Add struct rcar_canfd_hw_info to driver data
  2022-12-13 17:23 [PATCH 5.10.y-cip 0/7] CANFD Improvement Biju Das
                   ` (2 preceding siblings ...)
  2022-12-13 17:23 ` [PATCH 5.10.y-cip 3/7] can: rcar_canfd: Use devm_reset_control_get_optional_exclusive Biju Das
@ 2022-12-13 17:23 ` Biju Das
  2022-12-13 17:23 ` [PATCH 5.10.y-cip 5/7] can: rcar_canfd: Add shared_global_irqs to struct rcar_canfd_hw_info Biju Das
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Biju Das @ 2022-12-13 17:23 UTC (permalink / raw)
  To: cip-dev, Nobuhiro Iwamatsu, Pavel Machek
  Cc: Chris Paterson, Biju Das, Prabhakar Mahadev Lad

commit ce7c5382758b13dd4dfa2eb2f4989f9a27c58ffe upstream.

The CAN FD IP found on RZ/G2L SoC has some HW features different to that
of R-Car. For example, it has multiple resets and multiple IRQs for global
and channel interrupts. Also, it does not have ECC error flag registers
and clk post divider present on R-Car. Similarly, R-Car V3U has 8 channels
whereas other SoCs has only 2 channels.

This patch adds the struct rcar_canfd_hw_info to take care of the
HW feature differences and driver data present on both IPs. It also
replaces the driver data chip type with struct rcar_canfd_hw_info by
moving chip type to it.

Whilst started using driver data instead of chip_id for detecting
R-Car V3U SoCs.

Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Link: https://lore.kernel.org/all/20221027082158.95895-2-biju.das.jz@bp.renesas.com
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
[biju: Removed V3U SoC related changes]
Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
---
 drivers/net/can/rcar/rcar_canfd.c | 35 +++++++++++++++++++++----------
 1 file changed, 24 insertions(+), 11 deletions(-)

diff --git a/drivers/net/can/rcar/rcar_canfd.c b/drivers/net/can/rcar/rcar_canfd.c
index e485efc00b49..5727189094d6 100644
--- a/drivers/net/can/rcar/rcar_canfd.c
+++ b/drivers/net/can/rcar/rcar_canfd.c
@@ -494,6 +494,10 @@ enum rcar_canfd_fcanclk {
 
 struct rcar_canfd_global;
 
+struct rcar_canfd_hw_info {
+	enum rcanfd_chip_id chip_id;
+};
+
 /* Channel priv data */
 struct rcar_canfd_channel {
 	struct can_priv can;			/* Must be the first member */
@@ -520,7 +524,7 @@ struct rcar_canfd_global {
 	bool fdmode;			/* CAN FD or Classical CAN only mode */
 	struct reset_control *rstc1;
 	struct reset_control *rstc2;
-	enum rcanfd_chip_id chip_id;
+	const struct rcar_canfd_hw_info *info;
 };
 
 /* CAN FD mode nominal rate constants */
@@ -562,6 +566,14 @@ static const struct can_bittiming_const rcar_canfd_bittiming_const = {
 	.brp_inc = 1,
 };
 
+static const struct rcar_canfd_hw_info rcar_gen3_hw_info = {
+	.chip_id = RENESAS_RCAR_GEN3,
+};
+
+static const struct rcar_canfd_hw_info rzg2l_hw_info = {
+	.chip_id = RENESAS_RZG2L,
+};
+
 /* Helper functions */
 static inline void rcar_canfd_update(u32 mask, u32 val, u32 __iomem *reg)
 {
@@ -1625,6 +1637,7 @@ static const struct net_device_ops rcar_canfd_netdev_ops = {
 static int rcar_canfd_channel_probe(struct rcar_canfd_global *gpriv, u32 ch,
 				    u32 fcan_freq)
 {
+	const struct rcar_canfd_hw_info *info = gpriv->info;
 	struct platform_device *pdev = gpriv->pdev;
 	struct rcar_canfd_channel *priv;
 	struct net_device *ndev;
@@ -1646,7 +1659,7 @@ static int rcar_canfd_channel_probe(struct rcar_canfd_global *gpriv, u32 ch,
 	priv->can.clock.freq = fcan_freq;
 	dev_info(&pdev->dev, "can_clk rate is %u\n", priv->can.clock.freq);
 
-	if (gpriv->chip_id == RENESAS_RZG2L) {
+	if (info->chip_id == RENESAS_RZG2L) {
 		char *irq_name;
 		int err_irq;
 		int tx_irq;
@@ -1745,6 +1758,7 @@ static void rcar_canfd_channel_remove(struct rcar_canfd_global *gpriv, u32 ch)
 
 static int rcar_canfd_probe(struct platform_device *pdev)
 {
+	const struct rcar_canfd_hw_info *info;
 	void __iomem *addr;
 	u32 sts, ch, fcan_freq;
 	struct rcar_canfd_global *gpriv;
@@ -1753,9 +1767,8 @@ static int rcar_canfd_probe(struct platform_device *pdev)
 	int err, ch_irq, g_irq;
 	int g_err_irq, g_recc_irq;
 	bool fdmode = true;			/* CAN FD only mode - default */
-	enum rcanfd_chip_id chip_id;
 
-	chip_id = (uintptr_t)of_device_get_match_data(&pdev->dev);
+	info = of_device_get_match_data(&pdev->dev);
 
 	if (of_property_read_bool(pdev->dev.of_node, "renesas,no-can-fd"))
 		fdmode = false;			/* Classical CAN only mode */
@@ -1768,7 +1781,7 @@ static int rcar_canfd_probe(struct platform_device *pdev)
 	if (of_child && of_device_is_available(of_child))
 		channels_mask |= BIT(1);	/* Channel 1 */
 
-	if (chip_id == RENESAS_RCAR_GEN3) {
+	if (info->chip_id == RENESAS_RCAR_GEN3) {
 		ch_irq = platform_get_irq_byname_optional(pdev, "ch_int");
 		if (ch_irq < 0) {
 			/* For backward compatibility get irq by index */
@@ -1803,7 +1816,7 @@ static int rcar_canfd_probe(struct platform_device *pdev)
 	gpriv->pdev = pdev;
 	gpriv->channels_mask = channels_mask;
 	gpriv->fdmode = fdmode;
-	gpriv->chip_id = chip_id;
+	gpriv->info = info;
 
 	gpriv->rstc1 = devm_reset_control_get_optional_exclusive(&pdev->dev,
 								 "rstp_n");
@@ -1845,7 +1858,7 @@ static int rcar_canfd_probe(struct platform_device *pdev)
 	}
 	fcan_freq = clk_get_rate(gpriv->can_clk);
 
-	if (gpriv->fcan == RCANFD_CANFDCLK && gpriv->chip_id == RENESAS_RCAR_GEN3)
+	if (gpriv->fcan == RCANFD_CANFDCLK && info->chip_id == RENESAS_RCAR_GEN3)
 		/* CANFD clock is further divided by (1/2) within the IP */
 		fcan_freq /= 2;
 
@@ -1857,7 +1870,7 @@ static int rcar_canfd_probe(struct platform_device *pdev)
 	gpriv->base = addr;
 
 	/* Request IRQ that's common for both channels */
-	if (gpriv->chip_id == RENESAS_RCAR_GEN3) {
+	if (info->chip_id == RENESAS_RCAR_GEN3) {
 		err = devm_request_irq(&pdev->dev, ch_irq,
 				       rcar_canfd_channel_interrupt, 0,
 				       "canfd.ch_int", gpriv);
@@ -2009,9 +2022,9 @@ static int __maybe_unused rcar_canfd_resume(struct device *dev)
 static SIMPLE_DEV_PM_OPS(rcar_canfd_pm_ops, rcar_canfd_suspend,
 			 rcar_canfd_resume);
 
-static const struct of_device_id rcar_canfd_of_table[] = {
-	{ .compatible = "renesas,rcar-gen3-canfd", .data = (void *)RENESAS_RCAR_GEN3 },
-	{ .compatible = "renesas,rzg2l-canfd", .data = (void *)RENESAS_RZG2L },
+static const __maybe_unused struct of_device_id rcar_canfd_of_table[] = {
+	{ .compatible = "renesas,rcar-gen3-canfd", .data = &rcar_gen3_hw_info },
+	{ .compatible = "renesas,rzg2l-canfd", .data = &rzg2l_hw_info },
 	{ }
 };
 
-- 
2.25.1



^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 5.10.y-cip 5/7] can: rcar_canfd: Add shared_global_irqs to struct rcar_canfd_hw_info
  2022-12-13 17:23 [PATCH 5.10.y-cip 0/7] CANFD Improvement Biju Das
                   ` (3 preceding siblings ...)
  2022-12-13 17:23 ` [PATCH 5.10.y-cip 4/7] can: rcar_canfd: rcar_canfd_probe: Add struct rcar_canfd_hw_info to driver data Biju Das
@ 2022-12-13 17:23 ` Biju Das
  2022-12-13 17:23 ` [PATCH 5.10.y-cip 6/7] can: rcar_canfd: Add postdiv " Biju Das
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Biju Das @ 2022-12-13 17:23 UTC (permalink / raw)
  To: cip-dev, Nobuhiro Iwamatsu, Pavel Machek
  Cc: Chris Paterson, Biju Das, Prabhakar Mahadev Lad

commit 841645cfc773cdd0a21c67357c53845f2e972f91 upstream.

RZ/G2L has separate IRQ lines for receive FIFO and global error interrupt
whereas R-Car has shared IRQ line.

Add shared_global_irqs to struct rcar_canfd_hw_info to select the driver to
choose between shared and separate irq registration for global
interrupts.

Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Link: https://lore.kernel.org/all/20221027082158.95895-4-biju.das.jz@bp.renesas.com
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
---
 drivers/net/can/rcar/rcar_canfd.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/net/can/rcar/rcar_canfd.c b/drivers/net/can/rcar/rcar_canfd.c
index 5727189094d6..6480e8835dc6 100644
--- a/drivers/net/can/rcar/rcar_canfd.c
+++ b/drivers/net/can/rcar/rcar_canfd.c
@@ -496,6 +496,8 @@ struct rcar_canfd_global;
 
 struct rcar_canfd_hw_info {
 	enum rcanfd_chip_id chip_id;
+	/* hardware features */
+	unsigned shared_global_irqs:1;	/* Has shared global irqs */
 };
 
 /* Channel priv data */
@@ -568,6 +570,7 @@ static const struct can_bittiming_const rcar_canfd_bittiming_const = {
 
 static const struct rcar_canfd_hw_info rcar_gen3_hw_info = {
 	.chip_id = RENESAS_RCAR_GEN3,
+	.shared_global_irqs = 1,
 };
 
 static const struct rcar_canfd_hw_info rzg2l_hw_info = {
@@ -1781,7 +1784,7 @@ static int rcar_canfd_probe(struct platform_device *pdev)
 	if (of_child && of_device_is_available(of_child))
 		channels_mask |= BIT(1);	/* Channel 1 */
 
-	if (info->chip_id == RENESAS_RCAR_GEN3) {
+	if (info->shared_global_irqs) {
 		ch_irq = platform_get_irq_byname_optional(pdev, "ch_int");
 		if (ch_irq < 0) {
 			/* For backward compatibility get irq by index */
@@ -1870,7 +1873,7 @@ static int rcar_canfd_probe(struct platform_device *pdev)
 	gpriv->base = addr;
 
 	/* Request IRQ that's common for both channels */
-	if (info->chip_id == RENESAS_RCAR_GEN3) {
+	if (info->shared_global_irqs) {
 		err = devm_request_irq(&pdev->dev, ch_irq,
 				       rcar_canfd_channel_interrupt, 0,
 				       "canfd.ch_int", gpriv);
-- 
2.25.1



^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 5.10.y-cip 6/7] can: rcar_canfd: Add postdiv to struct rcar_canfd_hw_info
  2022-12-13 17:23 [PATCH 5.10.y-cip 0/7] CANFD Improvement Biju Das
                   ` (4 preceding siblings ...)
  2022-12-13 17:23 ` [PATCH 5.10.y-cip 5/7] can: rcar_canfd: Add shared_global_irqs to struct rcar_canfd_hw_info Biju Das
@ 2022-12-13 17:23 ` Biju Das
  2022-12-13 17:23 ` [PATCH 5.10.y-cip 7/7] can: rcar_canfd: Add multi_channel_irqs " Biju Das
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Biju Das @ 2022-12-13 17:23 UTC (permalink / raw)
  To: cip-dev, Nobuhiro Iwamatsu, Pavel Machek
  Cc: Chris Paterson, Biju Das, Prabhakar Mahadev Lad

commit a1dcfbdfd1d0f7843f381f7c58cc87a0f8c11f6c upstream.

R-Car has a clock divider for CAN FD clock within the IP, whereas
it is not available on RZ/G2L.

Add postdiv variable to struct rcar_canfd_hw_info to take care of this
difference.

Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Link: https://lore.kernel.org/all/20221027082158.95895-5-biju.das.jz@bp.renesas.com
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
[biju: Dropped RCar V3U related changes]
Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
---
 drivers/net/can/rcar/rcar_canfd.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/net/can/rcar/rcar_canfd.c b/drivers/net/can/rcar/rcar_canfd.c
index 6480e8835dc6..fa0b3de0b628 100644
--- a/drivers/net/can/rcar/rcar_canfd.c
+++ b/drivers/net/can/rcar/rcar_canfd.c
@@ -496,6 +496,7 @@ struct rcar_canfd_global;
 
 struct rcar_canfd_hw_info {
 	enum rcanfd_chip_id chip_id;
+	u8 postdiv;
 	/* hardware features */
 	unsigned shared_global_irqs:1;	/* Has shared global irqs */
 };
@@ -570,11 +571,13 @@ static const struct can_bittiming_const rcar_canfd_bittiming_const = {
 
 static const struct rcar_canfd_hw_info rcar_gen3_hw_info = {
 	.chip_id = RENESAS_RCAR_GEN3,
+	.postdiv = 2,
 	.shared_global_irqs = 1,
 };
 
 static const struct rcar_canfd_hw_info rzg2l_hw_info = {
 	.chip_id = RENESAS_RZG2L,
+	.postdiv = 1,
 };
 
 /* Helper functions */
@@ -1861,9 +1864,9 @@ static int rcar_canfd_probe(struct platform_device *pdev)
 	}
 	fcan_freq = clk_get_rate(gpriv->can_clk);
 
-	if (gpriv->fcan == RCANFD_CANFDCLK && info->chip_id == RENESAS_RCAR_GEN3)
+	if (gpriv->fcan == RCANFD_CANFDCLK)
 		/* CANFD clock is further divided by (1/2) within the IP */
-		fcan_freq /= 2;
+		fcan_freq /= info->postdiv;
 
 	addr = devm_platform_ioremap_resource(pdev, 0);
 	if (IS_ERR(addr)) {
-- 
2.25.1



^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 5.10.y-cip 7/7] can: rcar_canfd: Add multi_channel_irqs to struct rcar_canfd_hw_info
  2022-12-13 17:23 [PATCH 5.10.y-cip 0/7] CANFD Improvement Biju Das
                   ` (5 preceding siblings ...)
  2022-12-13 17:23 ` [PATCH 5.10.y-cip 6/7] can: rcar_canfd: Add postdiv " Biju Das
@ 2022-12-13 17:23 ` Biju Das
  2022-12-13 18:52 ` [PATCH 5.10.y-cip 0/7] CANFD Improvement Pavel Machek
  2022-12-16  9:39 ` Pavel Machek
  8 siblings, 0 replies; 10+ messages in thread
From: Biju Das @ 2022-12-13 17:23 UTC (permalink / raw)
  To: cip-dev, Nobuhiro Iwamatsu, Pavel Machek
  Cc: Chris Paterson, Biju Das, Prabhakar Mahadev Lad

commit ea6ff7792203ad6786bda75d1dabf33311c8bef4 upstream.

RZ/G2L has separate IRQ lines for tx and error interrupt for each
channel whereas R-Car has a combined IRQ line for all the channel
specific tx and error interrupts.

Add multi_channel_irqs to struct rcar_canfd_hw_info to select the
driver to choose between combined and separate irq registration for
channel interrupts. This patch also removes enum rcanfd_chip_id and
chip_id from both struct rcar_canfd_hw_info, as it is unused.

Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Link: https://lore.kernel.org/all/20221027082158.95895-6-biju.das.jz@bp.renesas.com
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
[biju: Removed RCar V3U related changes]
Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
---
 drivers/net/can/rcar/rcar_canfd.c | 12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)

diff --git a/drivers/net/can/rcar/rcar_canfd.c b/drivers/net/can/rcar/rcar_canfd.c
index fa0b3de0b628..987a899d4527 100644
--- a/drivers/net/can/rcar/rcar_canfd.c
+++ b/drivers/net/can/rcar/rcar_canfd.c
@@ -41,11 +41,6 @@
 
 #define RCANFD_DRV_NAME			"rcar_canfd"
 
-enum rcanfd_chip_id {
-	RENESAS_RCAR_GEN3 = 0,
-	RENESAS_RZG2L,
-};
-
 /* Global register bits */
 
 /* RSCFDnCFDGRMCFG */
@@ -495,10 +490,10 @@ enum rcar_canfd_fcanclk {
 struct rcar_canfd_global;
 
 struct rcar_canfd_hw_info {
-	enum rcanfd_chip_id chip_id;
 	u8 postdiv;
 	/* hardware features */
 	unsigned shared_global_irqs:1;	/* Has shared global irqs */
+	unsigned multi_channel_irqs:1;	/* Has multiple channel irqs */
 };
 
 /* Channel priv data */
@@ -570,14 +565,13 @@ static const struct can_bittiming_const rcar_canfd_bittiming_const = {
 };
 
 static const struct rcar_canfd_hw_info rcar_gen3_hw_info = {
-	.chip_id = RENESAS_RCAR_GEN3,
 	.postdiv = 2,
 	.shared_global_irqs = 1,
 };
 
 static const struct rcar_canfd_hw_info rzg2l_hw_info = {
-	.chip_id = RENESAS_RZG2L,
 	.postdiv = 1,
+	.multi_channel_irqs = 1,
 };
 
 /* Helper functions */
@@ -1665,7 +1659,7 @@ static int rcar_canfd_channel_probe(struct rcar_canfd_global *gpriv, u32 ch,
 	priv->can.clock.freq = fcan_freq;
 	dev_info(&pdev->dev, "can_clk rate is %u\n", priv->can.clock.freq);
 
-	if (info->chip_id == RENESAS_RZG2L) {
+	if (info->multi_channel_irqs) {
 		char *irq_name;
 		int err_irq;
 		int tx_irq;
-- 
2.25.1



^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH 5.10.y-cip 0/7] CANFD Improvement
  2022-12-13 17:23 [PATCH 5.10.y-cip 0/7] CANFD Improvement Biju Das
                   ` (6 preceding siblings ...)
  2022-12-13 17:23 ` [PATCH 5.10.y-cip 7/7] can: rcar_canfd: Add multi_channel_irqs " Biju Das
@ 2022-12-13 18:52 ` Pavel Machek
  2022-12-16  9:39 ` Pavel Machek
  8 siblings, 0 replies; 10+ messages in thread
From: Pavel Machek @ 2022-12-13 18:52 UTC (permalink / raw)
  To: Biju Das
  Cc: cip-dev, Nobuhiro Iwamatsu, Pavel Machek, Chris Paterson,
	Prabhakar Mahadev Lad

[-- Attachment #1: Type: text/plain, Size: 391 bytes --]

Hi!

> This patch series aims to fix IRQ storm issue as well as
> some enhancements to Renesas CANFD driver.

Series looks ok to me, I can apply it if it passes testing and if
there are no other comments.

Best regards,
								Pavel
-- 
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 5.10.y-cip 0/7] CANFD Improvement
  2022-12-13 17:23 [PATCH 5.10.y-cip 0/7] CANFD Improvement Biju Das
                   ` (7 preceding siblings ...)
  2022-12-13 18:52 ` [PATCH 5.10.y-cip 0/7] CANFD Improvement Pavel Machek
@ 2022-12-16  9:39 ` Pavel Machek
  8 siblings, 0 replies; 10+ messages in thread
From: Pavel Machek @ 2022-12-16  9:39 UTC (permalink / raw)
  To: Biju Das
  Cc: cip-dev, Nobuhiro Iwamatsu, Pavel Machek, Chris Paterson,
	Prabhakar Mahadev Lad

[-- Attachment #1: Type: text/plain, Size: 315 bytes --]

Hi!

> This patch series aims to fix IRQ storm issue as well as
> some enhancements to Renesas CANFD driver.

Thank you, applied.

Best regards,
								Pavel
-- 
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2022-12-16  9:39 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-13 17:23 [PATCH 5.10.y-cip 0/7] CANFD Improvement Biju Das
2022-12-13 17:23 ` [PATCH 5.10.y-cip 1/7] can: rcar_canfd: rcar_canfd_handle_global_receive(): fix IRQ storm on global FIFO receive Biju Das
2022-12-13 17:23 ` [PATCH 5.10.y-cip 2/7] can: rcar_canfd: Add missing ECC error checks for channels 2-7 Biju Das
2022-12-13 17:23 ` [PATCH 5.10.y-cip 3/7] can: rcar_canfd: Use devm_reset_control_get_optional_exclusive Biju Das
2022-12-13 17:23 ` [PATCH 5.10.y-cip 4/7] can: rcar_canfd: rcar_canfd_probe: Add struct rcar_canfd_hw_info to driver data Biju Das
2022-12-13 17:23 ` [PATCH 5.10.y-cip 5/7] can: rcar_canfd: Add shared_global_irqs to struct rcar_canfd_hw_info Biju Das
2022-12-13 17:23 ` [PATCH 5.10.y-cip 6/7] can: rcar_canfd: Add postdiv " Biju Das
2022-12-13 17:23 ` [PATCH 5.10.y-cip 7/7] can: rcar_canfd: Add multi_channel_irqs " Biju Das
2022-12-13 18:52 ` [PATCH 5.10.y-cip 0/7] CANFD Improvement Pavel Machek
2022-12-16  9:39 ` Pavel Machek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).