All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 0/6] R-Car CAN FD driver enhancements
@ 2022-10-27  8:21 Biju Das
  2022-10-27  8:21 ` [PATCH v3 1/6] can: rcar_canfd: rcar_canfd_probe: Add struct rcar_canfd_hw_info to driver data Biju Das
                   ` (5 more replies)
  0 siblings, 6 replies; 15+ messages in thread
From: Biju Das @ 2022-10-27  8:21 UTC (permalink / raw)
  To: Wolfgang Grandegger, Marc Kleine-Budde, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni
  Cc: Biju Das, Vincent Mailhol, Stefan Mätje, Ulrich Hecht,
	Lad Prabhakar, Christophe JAILLET, linux-can, netdev,
	Geert Uytterhoeven, Fabrizio Castro, Chris Paterson,
	linux-renesas-soc

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, dedicated channel tx
and error interrupts, separate global rx and error interrupts compared
to shared irq for R-Car. it does not s 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. Currently all the HW differences are handled by comparing
with chip_id enum.

This patch series aims to replace chip_id with struct rcar_canfd_hw_info
to handle the HW feature differences and driver data present
on both IPs.

The changes are trivial and tested on RZ/G2L SMARC EVK.

This patch series depend upon[1]
[1] https://lore.kernel.org/linux-renesas-soc/20221025155657.1426948-1-biju.das.jz@bp.renesas.com/T/#t

v2->v3:
 * Replaced data type of max_channels from unsigned int->u8 to save memory.
 * Replaced data type of postdiv from unsigned int->u8 to save memory.
v1->v2:
 * Updated commit description for R-Car V3U SoC detection using
   driver data.
 * Replaced data type of max_channels from u32->unsigned int.
 * Replaced multi_global_irqs->shared_global_irqs to make it
   positive checks.
 * Replaced clk_postdiv->postdiv driver data variable.
 * Simplified the calcualtion for fcan_freq.
 * Replaced info->has_gerfl to gpriv->info->has_gerfl and wrapped
   the ECC error flag checks inside a single if statement.
 * Added Rb tag from Geert patch#1,#2,#3 and #5

Biju Das (6):
  can: rcar_canfd: rcar_canfd_probe: Add struct rcar_canfd_hw_info to
    driver data
  can: rcar_canfd: Add max_channels to struct rcar_canfd_hw_info
  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
  can: rcar_canfd: Add has_gerfl_eef to struct rcar_canfd_hw_info

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

-- 
2.25.1


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

* [PATCH v3 1/6] can: rcar_canfd: rcar_canfd_probe: Add struct rcar_canfd_hw_info to driver data
  2022-10-27  8:21 [PATCH v3 0/6] R-Car CAN FD driver enhancements Biju Das
@ 2022-10-27  8:21 ` Biju Das
  2022-10-27  8:21 ` [PATCH v3 2/6] can: rcar_canfd: Add max_channels to struct rcar_canfd_hw_info Biju Das
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 15+ messages in thread
From: Biju Das @ 2022-10-27  8:21 UTC (permalink / raw)
  To: Wolfgang Grandegger, Marc Kleine-Budde, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni
  Cc: Biju Das, Vincent Mailhol, Stefan Mätje, Ulrich Hecht,
	Lad Prabhakar, Christophe JAILLET, linux-can, netdev,
	Geert Uytterhoeven, Chris Paterson, Biju Das, linux-renesas-soc

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>
---
v2->v3:
 * No change
v1->v2:
 * Updated commit description for R-Car V3U SoC detection using
   driver data.
 * Added Rb tag from Geert.
---
 drivers/net/can/rcar/rcar_canfd.c | 43 +++++++++++++++++++++----------
 1 file changed, 30 insertions(+), 13 deletions(-)

diff --git a/drivers/net/can/rcar/rcar_canfd.c b/drivers/net/can/rcar/rcar_canfd.c
index a0dd6044830b..5660bf0cd755 100644
--- a/drivers/net/can/rcar/rcar_canfd.c
+++ b/drivers/net/can/rcar/rcar_canfd.c
@@ -523,6 +523,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 */
@@ -548,7 +552,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;
 	u32 max_channels;
 };
 
@@ -591,10 +595,22 @@ 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,
+};
+
+static const struct rcar_canfd_hw_info r8a779a0_hw_info = {
+	.chip_id = RENESAS_R8A779A0,
+};
+
 /* Helper functions */
 static inline bool is_v3u(struct rcar_canfd_global *gpriv)
 {
-	return gpriv->chip_id == RENESAS_R8A779A0;
+	return gpriv->info == &r8a779a0_hw_info;
 }
 
 static inline u32 reg_v3u(struct rcar_canfd_global *gpriv,
@@ -1701,6 +1717,7 @@ static const struct ethtool_ops rcar_canfd_ethtool_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;
@@ -1723,7 +1740,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;
@@ -1823,6 +1840,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;
@@ -1831,13 +1849,12 @@ 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;
 	int max_channels;
 	char name[9] = "channelX";
 	int i;
 
-	chip_id = (uintptr_t)of_device_get_match_data(&pdev->dev);
-	max_channels = chip_id == RENESAS_R8A779A0 ? 8 : 2;
+	info = of_device_get_match_data(&pdev->dev);
+	max_channels = info->chip_id == RENESAS_R8A779A0 ? 8 : 2;
 
 	if (of_property_read_bool(pdev->dev.of_node, "renesas,no-can-fd"))
 		fdmode = false;			/* Classical CAN only mode */
@@ -1850,7 +1867,7 @@ static int rcar_canfd_probe(struct platform_device *pdev)
 		of_node_put(of_child);
 	}
 
-	if (chip_id != RENESAS_RZG2L) {
+	if (info->chip_id != RENESAS_RZG2L) {
 		ch_irq = platform_get_irq_byname_optional(pdev, "ch_int");
 		if (ch_irq < 0) {
 			/* For backward compatibility get irq by index */
@@ -1884,7 +1901,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->max_channels = max_channels;
 
 	gpriv->rstc1 = devm_reset_control_get_optional_exclusive(&pdev->dev,
@@ -1922,7 +1939,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_RZG2L)
+	if (gpriv->fcan == RCANFD_CANFDCLK && info->chip_id != RENESAS_RZG2L)
 		/* CANFD clock is further divided by (1/2) within the IP */
 		fcan_freq /= 2;
 
@@ -1934,7 +1951,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_RZG2L) {
+	if (info->chip_id != RENESAS_RZG2L) {
 		err = devm_request_irq(&pdev->dev, ch_irq,
 				       rcar_canfd_channel_interrupt, 0,
 				       "canfd.ch_int", gpriv);
@@ -2087,9 +2104,9 @@ static SIMPLE_DEV_PM_OPS(rcar_canfd_pm_ops, rcar_canfd_suspend,
 			 rcar_canfd_resume);
 
 static const __maybe_unused 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 },
-	{ .compatible = "renesas,r8a779a0-canfd", .data = (void *)RENESAS_R8A779A0 },
+	{ .compatible = "renesas,rcar-gen3-canfd", .data = &rcar_gen3_hw_info },
+	{ .compatible = "renesas,rzg2l-canfd", .data = &rzg2l_hw_info },
+	{ .compatible = "renesas,r8a779a0-canfd", .data = &r8a779a0_hw_info },
 	{ }
 };
 
-- 
2.25.1


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

* [PATCH v3 2/6] can: rcar_canfd: Add max_channels to struct rcar_canfd_hw_info
  2022-10-27  8:21 [PATCH v3 0/6] R-Car CAN FD driver enhancements Biju Das
  2022-10-27  8:21 ` [PATCH v3 1/6] can: rcar_canfd: rcar_canfd_probe: Add struct rcar_canfd_hw_info to driver data Biju Das
@ 2022-10-27  8:21 ` Biju Das
  2022-10-27  8:21 ` [PATCH v3 3/6] can: rcar_canfd: Add shared_global_irqs " Biju Das
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 15+ messages in thread
From: Biju Das @ 2022-10-27  8:21 UTC (permalink / raw)
  To: Wolfgang Grandegger, Marc Kleine-Budde, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni
  Cc: Biju Das, Vincent Mailhol, Stefan Mätje, Ulrich Hecht,
	Lad Prabhakar, Christophe JAILLET, linux-can, netdev,
	Geert Uytterhoeven, Chris Paterson, Biju Das, linux-renesas-soc

R-Car V3U supports a maximum of 8 channels whereas rest of the SoCs
support 2 channels.

Add max_channels variable to struct rcar_canfd_hw_info to handle this
difference.

Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
v2->v3:
 * Replaced data type of max_channels from unsigned int->u8 to save memory.
v1->v2:
 * Replaced data type of max_channels from u32->unsigned int.
 * Added Rb tag from Geert.
---
 drivers/net/can/rcar/rcar_canfd.c | 30 +++++++++++++++---------------
 1 file changed, 15 insertions(+), 15 deletions(-)

diff --git a/drivers/net/can/rcar/rcar_canfd.c b/drivers/net/can/rcar/rcar_canfd.c
index 5660bf0cd755..255cb0825f13 100644
--- a/drivers/net/can/rcar/rcar_canfd.c
+++ b/drivers/net/can/rcar/rcar_canfd.c
@@ -525,6 +525,7 @@ struct rcar_canfd_global;
 
 struct rcar_canfd_hw_info {
 	enum rcanfd_chip_id chip_id;
+	u8 max_channels;
 };
 
 /* Channel priv data */
@@ -553,7 +554,6 @@ struct rcar_canfd_global {
 	struct reset_control *rstc1;
 	struct reset_control *rstc2;
 	const struct rcar_canfd_hw_info *info;
-	u32 max_channels;
 };
 
 /* CAN FD mode nominal rate constants */
@@ -597,14 +597,17 @@ 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,
+	.max_channels = 2,
 };
 
 static const struct rcar_canfd_hw_info rzg2l_hw_info = {
 	.chip_id = RENESAS_RZG2L,
+	.max_channels = 2,
 };
 
 static const struct rcar_canfd_hw_info r8a779a0_hw_info = {
 	.chip_id = RENESAS_R8A779A0,
+	.max_channels = 8,
 };
 
 /* Helper functions */
@@ -738,7 +741,7 @@ static int rcar_canfd_reset_controller(struct rcar_canfd_global *gpriv)
 	rcar_canfd_set_mode(gpriv);
 
 	/* Transition all Channels to reset mode */
-	for_each_set_bit(ch, &gpriv->channels_mask, gpriv->max_channels) {
+	for_each_set_bit(ch, &gpriv->channels_mask, gpriv->info->max_channels) {
 		rcar_canfd_clear_bit(gpriv->base,
 				     RCANFD_CCTR(ch), RCANFD_CCTR_CSLPR);
 
@@ -779,7 +782,7 @@ static void rcar_canfd_configure_controller(struct rcar_canfd_global *gpriv)
 	rcar_canfd_set_bit(gpriv->base, RCANFD_GCFG, cfg);
 
 	/* Channel configuration settings */
-	for_each_set_bit(ch, &gpriv->channels_mask, gpriv->max_channels) {
+	for_each_set_bit(ch, &gpriv->channels_mask, gpriv->info->max_channels) {
 		rcar_canfd_set_bit(gpriv->base, RCANFD_CCTR(ch),
 				   RCANFD_CCTR_ERRD);
 		rcar_canfd_update_bit(gpriv->base, RCANFD_CCTR(ch),
@@ -1163,7 +1166,7 @@ static irqreturn_t rcar_canfd_global_err_interrupt(int irq, void *dev_id)
 	struct rcar_canfd_global *gpriv = dev_id;
 	u32 ch;
 
-	for_each_set_bit(ch, &gpriv->channels_mask, gpriv->max_channels)
+	for_each_set_bit(ch, &gpriv->channels_mask, gpriv->info->max_channels)
 		rcar_canfd_handle_global_err(gpriv, ch);
 
 	return IRQ_HANDLED;
@@ -1195,7 +1198,7 @@ static irqreturn_t rcar_canfd_global_receive_fifo_interrupt(int irq, void *dev_i
 	struct rcar_canfd_global *gpriv = dev_id;
 	u32 ch;
 
-	for_each_set_bit(ch, &gpriv->channels_mask, gpriv->max_channels)
+	for_each_set_bit(ch, &gpriv->channels_mask, gpriv->info->max_channels)
 		rcar_canfd_handle_global_receive(gpriv, ch);
 
 	return IRQ_HANDLED;
@@ -1209,7 +1212,7 @@ static irqreturn_t rcar_canfd_global_interrupt(int irq, void *dev_id)
 	/* Global error interrupts still indicate a condition specific
 	 * to a channel. RxFIFO interrupt is a global interrupt.
 	 */
-	for_each_set_bit(ch, &gpriv->channels_mask, gpriv->max_channels) {
+	for_each_set_bit(ch, &gpriv->channels_mask, gpriv->info->max_channels) {
 		rcar_canfd_handle_global_err(gpriv, ch);
 		rcar_canfd_handle_global_receive(gpriv, ch);
 	}
@@ -1305,7 +1308,7 @@ static irqreturn_t rcar_canfd_channel_interrupt(int irq, void *dev_id)
 	u32 ch;
 
 	/* Common FIFO is a per channel resource */
-	for_each_set_bit(ch, &gpriv->channels_mask, gpriv->max_channels) {
+	for_each_set_bit(ch, &gpriv->channels_mask, gpriv->info->max_channels) {
 		rcar_canfd_handle_channel_err(gpriv, ch);
 		rcar_canfd_handle_channel_tx(gpriv, ch);
 	}
@@ -1849,17 +1852,15 @@ 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 */
-	int max_channels;
 	char name[9] = "channelX";
 	int i;
 
 	info = of_device_get_match_data(&pdev->dev);
-	max_channels = info->chip_id == RENESAS_R8A779A0 ? 8 : 2;
 
 	if (of_property_read_bool(pdev->dev.of_node, "renesas,no-can-fd"))
 		fdmode = false;			/* Classical CAN only mode */
 
-	for (i = 0; i < max_channels; ++i) {
+	for (i = 0; i < info->max_channels; ++i) {
 		name[7] = '0' + i;
 		of_child = of_get_child_by_name(pdev->dev.of_node, name);
 		if (of_child && of_device_is_available(of_child))
@@ -1902,7 +1903,6 @@ static int rcar_canfd_probe(struct platform_device *pdev)
 	gpriv->channels_mask = channels_mask;
 	gpriv->fdmode = fdmode;
 	gpriv->info = info;
-	gpriv->max_channels = max_channels;
 
 	gpriv->rstc1 = devm_reset_control_get_optional_exclusive(&pdev->dev,
 								 "rstp_n");
@@ -2017,7 +2017,7 @@ static int rcar_canfd_probe(struct platform_device *pdev)
 	rcar_canfd_configure_controller(gpriv);
 
 	/* Configure per channel attributes */
-	for_each_set_bit(ch, &gpriv->channels_mask, max_channels) {
+	for_each_set_bit(ch, &gpriv->channels_mask, info->max_channels) {
 		/* Configure Channel's Rx fifo */
 		rcar_canfd_configure_rx(gpriv, ch);
 
@@ -2043,7 +2043,7 @@ static int rcar_canfd_probe(struct platform_device *pdev)
 		goto fail_mode;
 	}
 
-	for_each_set_bit(ch, &gpriv->channels_mask, max_channels) {
+	for_each_set_bit(ch, &gpriv->channels_mask, info->max_channels) {
 		err = rcar_canfd_channel_probe(gpriv, ch, fcan_freq);
 		if (err)
 			goto fail_channel;
@@ -2055,7 +2055,7 @@ static int rcar_canfd_probe(struct platform_device *pdev)
 	return 0;
 
 fail_channel:
-	for_each_set_bit(ch, &gpriv->channels_mask, max_channels)
+	for_each_set_bit(ch, &gpriv->channels_mask, info->max_channels)
 		rcar_canfd_channel_remove(gpriv, ch);
 fail_mode:
 	rcar_canfd_disable_global_interrupts(gpriv);
@@ -2076,7 +2076,7 @@ static int rcar_canfd_remove(struct platform_device *pdev)
 	rcar_canfd_reset_controller(gpriv);
 	rcar_canfd_disable_global_interrupts(gpriv);
 
-	for_each_set_bit(ch, &gpriv->channels_mask, gpriv->max_channels) {
+	for_each_set_bit(ch, &gpriv->channels_mask, gpriv->info->max_channels) {
 		rcar_canfd_disable_channel_interrupts(gpriv->ch[ch]);
 		rcar_canfd_channel_remove(gpriv, ch);
 	}
-- 
2.25.1


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

* [PATCH v3 3/6] can: rcar_canfd: Add shared_global_irqs to struct rcar_canfd_hw_info
  2022-10-27  8:21 [PATCH v3 0/6] R-Car CAN FD driver enhancements Biju Das
  2022-10-27  8:21 ` [PATCH v3 1/6] can: rcar_canfd: rcar_canfd_probe: Add struct rcar_canfd_hw_info to driver data Biju Das
  2022-10-27  8:21 ` [PATCH v3 2/6] can: rcar_canfd: Add max_channels to struct rcar_canfd_hw_info Biju Das
@ 2022-10-27  8:21 ` Biju Das
  2022-10-27  8:21 ` [PATCH v3 4/6] can: rcar_canfd: Add postdiv " Biju Das
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 15+ messages in thread
From: Biju Das @ 2022-10-27  8:21 UTC (permalink / raw)
  To: Wolfgang Grandegger, Marc Kleine-Budde, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni
  Cc: Biju Das, Vincent Mailhol, Stefan Mätje, Ulrich Hecht,
	Lad Prabhakar, Christophe JAILLET, linux-can, netdev,
	Geert Uytterhoeven, Chris Paterson, Biju Das, linux-renesas-soc

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>
---
v2->v3:
 * No change
v1->v2:
 * Replaced multi_global_irqs->shared_global_irqs to make it
   positive checks.
 * Added Rb tag from Geert.
---
 drivers/net/can/rcar/rcar_canfd.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/net/can/rcar/rcar_canfd.c b/drivers/net/can/rcar/rcar_canfd.c
index 255cb0825f13..c8d44dc36515 100644
--- a/drivers/net/can/rcar/rcar_canfd.c
+++ b/drivers/net/can/rcar/rcar_canfd.c
@@ -526,6 +526,8 @@ struct rcar_canfd_global;
 struct rcar_canfd_hw_info {
 	enum rcanfd_chip_id chip_id;
 	u8 max_channels;
+	/* hardware features */
+	unsigned shared_global_irqs:1;	/* Has shared global irqs */
 };
 
 /* Channel priv data */
@@ -598,6 +600,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,
 	.max_channels = 2,
+	.shared_global_irqs = 1,
 };
 
 static const struct rcar_canfd_hw_info rzg2l_hw_info = {
@@ -608,6 +611,7 @@ static const struct rcar_canfd_hw_info rzg2l_hw_info = {
 static const struct rcar_canfd_hw_info r8a779a0_hw_info = {
 	.chip_id = RENESAS_R8A779A0,
 	.max_channels = 8,
+	.shared_global_irqs = 1,
 };
 
 /* Helper functions */
@@ -1868,7 +1872,7 @@ static int rcar_canfd_probe(struct platform_device *pdev)
 		of_node_put(of_child);
 	}
 
-	if (info->chip_id != RENESAS_RZG2L) {
+	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 */
@@ -1951,7 +1955,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_RZG2L) {
+	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] 15+ messages in thread

* [PATCH v3 4/6] can: rcar_canfd: Add postdiv to struct rcar_canfd_hw_info
  2022-10-27  8:21 [PATCH v3 0/6] R-Car CAN FD driver enhancements Biju Das
                   ` (2 preceding siblings ...)
  2022-10-27  8:21 ` [PATCH v3 3/6] can: rcar_canfd: Add shared_global_irqs " Biju Das
@ 2022-10-27  8:21 ` Biju Das
  2022-10-28  9:31   ` Geert Uytterhoeven
  2022-10-27  8:21 ` [PATCH v3 5/6] can: rcar_canfd: Add multi_channel_irqs " Biju Das
  2022-10-27  8:21 ` [PATCH v3 6/6] can: rcar_canfd: Add has_gerfl_eef " Biju Das
  5 siblings, 1 reply; 15+ messages in thread
From: Biju Das @ 2022-10-27  8:21 UTC (permalink / raw)
  To: Wolfgang Grandegger, Marc Kleine-Budde, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni
  Cc: Biju Das, Vincent Mailhol, Stefan Mätje, Ulrich Hecht,
	Lad Prabhakar, Christophe JAILLET, linux-can, netdev,
	Geert Uytterhoeven, Chris Paterson, Biju Das, linux-renesas-soc

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>
---
v2->v3:
 * Replaced data type of postdiv from unsigned int->u8 to save memory.
v1->v2:
 * Replaced clk_postdiv->postdiv driver data variable.
 * Simplified the calculation for fcan_freq.
---
 drivers/net/can/rcar/rcar_canfd.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/net/can/rcar/rcar_canfd.c b/drivers/net/can/rcar/rcar_canfd.c
index c8d44dc36515..bc5df7a39f91 100644
--- a/drivers/net/can/rcar/rcar_canfd.c
+++ b/drivers/net/can/rcar/rcar_canfd.c
@@ -526,6 +526,7 @@ struct rcar_canfd_global;
 struct rcar_canfd_hw_info {
 	enum rcanfd_chip_id chip_id;
 	u8 max_channels;
+	u8 postdiv;
 	/* hardware features */
 	unsigned shared_global_irqs:1;	/* Has shared global irqs */
 };
@@ -600,17 +601,20 @@ 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,
 	.max_channels = 2,
+	.postdiv = 2,
 	.shared_global_irqs = 1,
 };
 
 static const struct rcar_canfd_hw_info rzg2l_hw_info = {
 	.chip_id = RENESAS_RZG2L,
+	.postdiv = 1,
 	.max_channels = 2,
 };
 
 static const struct rcar_canfd_hw_info r8a779a0_hw_info = {
 	.chip_id = RENESAS_R8A779A0,
 	.max_channels = 8,
+	.postdiv = 2,
 	.shared_global_irqs = 1,
 };
 
@@ -1943,9 +1947,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_RZG2L)
+	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] 15+ messages in thread

* [PATCH v3 5/6] can: rcar_canfd: Add multi_channel_irqs to struct rcar_canfd_hw_info
  2022-10-27  8:21 [PATCH v3 0/6] R-Car CAN FD driver enhancements Biju Das
                   ` (3 preceding siblings ...)
  2022-10-27  8:21 ` [PATCH v3 4/6] can: rcar_canfd: Add postdiv " Biju Das
@ 2022-10-27  8:21 ` Biju Das
  2022-10-27  8:21 ` [PATCH v3 6/6] can: rcar_canfd: Add has_gerfl_eef " Biju Das
  5 siblings, 0 replies; 15+ messages in thread
From: Biju Das @ 2022-10-27  8:21 UTC (permalink / raw)
  To: Wolfgang Grandegger, Marc Kleine-Budde, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni
  Cc: Biju Das, Vincent Mailhol, Stefan Mätje, Ulrich Hecht,
	Lad Prabhakar, Christophe JAILLET, linux-can, netdev,
	Geert Uytterhoeven, Chris Paterson, Biju Das, linux-renesas-soc

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>
---
v2->v3:
 * No change.
v1->v2:
 * Added Rb tag from Geert.
---
 drivers/net/can/rcar/rcar_canfd.c | 16 ++++------------
 1 file changed, 4 insertions(+), 12 deletions(-)

diff --git a/drivers/net/can/rcar/rcar_canfd.c b/drivers/net/can/rcar/rcar_canfd.c
index bc5df7a39f91..f8eafb132b39 100644
--- a/drivers/net/can/rcar/rcar_canfd.c
+++ b/drivers/net/can/rcar/rcar_canfd.c
@@ -41,12 +41,6 @@
 
 #define RCANFD_DRV_NAME			"rcar_canfd"
 
-enum rcanfd_chip_id {
-	RENESAS_RCAR_GEN3 = 0,
-	RENESAS_RZG2L,
-	RENESAS_R8A779A0,
-};
-
 /* Global register bits */
 
 /* RSCFDnCFDGRMCFG */
@@ -524,11 +518,11 @@ enum rcar_canfd_fcanclk {
 struct rcar_canfd_global;
 
 struct rcar_canfd_hw_info {
-	enum rcanfd_chip_id chip_id;
 	u8 max_channels;
 	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 */
@@ -599,20 +593,18 @@ 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,
 	.max_channels = 2,
 	.postdiv = 2,
 	.shared_global_irqs = 1,
 };
 
 static const struct rcar_canfd_hw_info rzg2l_hw_info = {
-	.chip_id = RENESAS_RZG2L,
-	.postdiv = 1,
 	.max_channels = 2,
+	.postdiv = 1,
+	.multi_channel_irqs = 1,
 };
 
 static const struct rcar_canfd_hw_info r8a779a0_hw_info = {
-	.chip_id = RENESAS_R8A779A0,
 	.max_channels = 8,
 	.postdiv = 2,
 	.shared_global_irqs = 1,
@@ -1751,7 +1743,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] 15+ messages in thread

* [PATCH v3 6/6] can: rcar_canfd: Add has_gerfl_eef to struct rcar_canfd_hw_info
  2022-10-27  8:21 [PATCH v3 0/6] R-Car CAN FD driver enhancements Biju Das
                   ` (4 preceding siblings ...)
  2022-10-27  8:21 ` [PATCH v3 5/6] can: rcar_canfd: Add multi_channel_irqs " Biju Das
@ 2022-10-27  8:21 ` Biju Das
  2022-10-28 10:12   ` Geert Uytterhoeven
  5 siblings, 1 reply; 15+ messages in thread
From: Biju Das @ 2022-10-27  8:21 UTC (permalink / raw)
  To: Wolfgang Grandegger, Marc Kleine-Budde, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni
  Cc: Biju Das, Vincent Mailhol, Stefan Mätje, Ulrich Hecht,
	Lad Prabhakar, Christophe JAILLET, linux-can, netdev,
	Geert Uytterhoeven, Chris Paterson, Biju Das, linux-renesas-soc

R-Car has ECC error flags in global error interrupts whereas it is
not available on RZ/G2L.

Add has_gerfl_eef to struct rcar_canfd_hw_info so that rcar_canfd_
global_error() will process ECC errors only for R-Car.

whilst, this patch fixes the below checkpatch warnings
  CHECK: Unnecessary parentheses around 'ch == 0'
  CHECK: Unnecessary parentheses around 'ch == 1'

Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
---
v2->v3:
 * No change.
v1->v2:
 * Replaced info->has_gerfl to gpriv->info->has_gerfl and wrapped
   the ECC error flag check within single if statement.
---
 drivers/net/can/rcar/rcar_canfd.c | 19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)

diff --git a/drivers/net/can/rcar/rcar_canfd.c b/drivers/net/can/rcar/rcar_canfd.c
index f8eafb132b39..00242eac377d 100644
--- a/drivers/net/can/rcar/rcar_canfd.c
+++ b/drivers/net/can/rcar/rcar_canfd.c
@@ -523,6 +523,7 @@ struct rcar_canfd_hw_info {
 	/* hardware features */
 	unsigned shared_global_irqs:1;	/* Has shared global irqs */
 	unsigned multi_channel_irqs:1;	/* Has multiple channel irqs */
+	unsigned has_gerfl_eef:1;	/* Has ECC Error Flag */
 };
 
 /* Channel priv data */
@@ -596,6 +597,7 @@ static const struct rcar_canfd_hw_info rcar_gen3_hw_info = {
 	.max_channels = 2,
 	.postdiv = 2,
 	.shared_global_irqs = 1,
+	.has_gerfl_eef = 1,
 };
 
 static const struct rcar_canfd_hw_info rzg2l_hw_info = {
@@ -608,6 +610,7 @@ static const struct rcar_canfd_hw_info r8a779a0_hw_info = {
 	.max_channels = 8,
 	.postdiv = 2,
 	.shared_global_irqs = 1,
+	.has_gerfl_eef = 1,
 };
 
 /* Helper functions */
@@ -955,13 +958,15 @@ 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");
-		stats->tx_dropped++;
+	if (gpriv->info->has_gerfl_eef) {
+		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");
+			stats->tx_dropped++;
+		}
 	}
 	if (gerfl & RCANFD_GERFL_MES) {
 		sts = rcar_canfd_read(priv->base,
-- 
2.25.1


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

* Re: [PATCH v3 4/6] can: rcar_canfd: Add postdiv to struct rcar_canfd_hw_info
  2022-10-27  8:21 ` [PATCH v3 4/6] can: rcar_canfd: Add postdiv " Biju Das
@ 2022-10-28  9:31   ` Geert Uytterhoeven
  2022-10-28  9:36     ` Biju Das
  0 siblings, 1 reply; 15+ messages in thread
From: Geert Uytterhoeven @ 2022-10-28  9:31 UTC (permalink / raw)
  To: biju.das.jz
  Cc: Wolfgang Grandegger, Marc Kleine-Budde, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Vincent Mailhol,
	Stefan Mätje, Ulrich Hecht, Lad Prabhakar,
	Christophe JAILLET, linux-can, netdev, Geert Uytterhoeven,
	Chris Paterson, Biju Das, linux-renesas-soc

Hi Biju,

On Thu, Oct 27, 2022 at 10:22 AM Biju Das <biju.das.jz@bp.renesas.com> wrote:
> 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>
> ---
> v2->v3:
>  * Replaced data type of postdiv from unsigned int->u8 to save memory.

Thanks for the update!

> --- a/drivers/net/can/rcar/rcar_canfd.c
> +++ b/drivers/net/can/rcar/rcar_canfd.c
> @@ -1943,9 +1947,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_RZG2L)
> +       if (gpriv->fcan == RCANFD_CANFDCLK)
>                 /* CANFD clock is further divided by (1/2) within the IP */

may be further divided?

> -               fcan_freq /= 2;
> +               fcan_freq /= info->postdiv;
>
>         addr = devm_platform_ioremap_resource(pdev, 0);
>         if (IS_ERR(addr)) {

Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

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

* RE: [PATCH v3 4/6] can: rcar_canfd: Add postdiv to struct rcar_canfd_hw_info
  2022-10-28  9:31   ` Geert Uytterhoeven
@ 2022-10-28  9:36     ` Biju Das
  0 siblings, 0 replies; 15+ messages in thread
From: Biju Das @ 2022-10-28  9:36 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Wolfgang Grandegger, Marc Kleine-Budde, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Vincent Mailhol,
	Stefan Mätje, Ulrich Hecht, Prabhakar Mahadev Lad,
	Christophe JAILLET, linux-can, netdev, Geert Uytterhoeven,
	Chris Paterson, Biju Das, linux-renesas-soc

Hi Geert,

Thanks for the feedback.

> Subject: Re: [PATCH v3 4/6] can: rcar_canfd: Add postdiv to struct
> rcar_canfd_hw_info
> 
> Hi Biju,
> 
> On Thu, Oct 27, 2022 at 10:22 AM Biju Das <biju.das.jz@bp.renesas.com>
> wrote:
> > 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>
> > ---
> > v2->v3:
> >  * Replaced data type of postdiv from unsigned int->u8 to save
> memory.
> 
> Thanks for the update!
> 
> > --- a/drivers/net/can/rcar/rcar_canfd.c
> > +++ b/drivers/net/can/rcar/rcar_canfd.c
> > @@ -1943,9 +1947,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_RZG2L)
> > +       if (gpriv->fcan == RCANFD_CANFDCLK)
> >                 /* CANFD clock is further divided by (1/2) within
> the
> > IP */
> 
> may be further divided?

Yes, It make sense. Will send v4 with this change.
/* CANFD clock may be further divided by (1/2) within the IP */

Cheers,
Biju

> 
> > -               fcan_freq /= 2;
> > +               fcan_freq /= info->postdiv;
> >
> >         addr = devm_platform_ioremap_resource(pdev, 0);
> >         if (IS_ERR(addr)) {
> 
> Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
> 
> Gr{oetje,eeting}s,
> 
>                         Geert
> 
> --
> Geert Uytterhoeven -- There's lots of Linux beyond ia32 --
> geert@linux-m68k.org
> 
> In personal conversations with technical people, I call myself a
> hacker. But when I'm talking to journalists I just say "programmer" or
> something like that.
>                                 -- Linus Torvalds

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

* Re: [PATCH v3 6/6] can: rcar_canfd: Add has_gerfl_eef to struct rcar_canfd_hw_info
  2022-10-27  8:21 ` [PATCH v3 6/6] can: rcar_canfd: Add has_gerfl_eef " Biju Das
@ 2022-10-28 10:12   ` Geert Uytterhoeven
  2022-10-28 10:22     ` Biju Das
  2022-10-28 10:24     ` Marc Kleine-Budde
  0 siblings, 2 replies; 15+ messages in thread
From: Geert Uytterhoeven @ 2022-10-28 10:12 UTC (permalink / raw)
  To: biju.das.jz
  Cc: Wolfgang Grandegger, Marc Kleine-Budde, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Vincent Mailhol,
	Stefan Mätje, Ulrich Hecht, Lad Prabhakar,
	Christophe JAILLET, linux-can, netdev, Geert Uytterhoeven,
	Chris Paterson, Biju Das, linux-renesas-soc

Hi Biju,

On Thu, Oct 27, 2022 at 10:22 AM Biju Das <biju.das.jz@bp.renesas.com> wrote:
> R-Car has ECC error flags in global error interrupts whereas it is
> not available on RZ/G2L.
>
> Add has_gerfl_eef to struct rcar_canfd_hw_info so that rcar_canfd_
> global_error() will process ECC errors only for R-Car.
>
> whilst, this patch fixes the below checkpatch warnings
>   CHECK: Unnecessary parentheses around 'ch == 0'
>   CHECK: Unnecessary parentheses around 'ch == 1'
>
> Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>

Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>

> --- a/drivers/net/can/rcar/rcar_canfd.c
> +++ b/drivers/net/can/rcar/rcar_canfd.c
> @@ -955,13 +958,15 @@ 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");
> -               stats->tx_dropped++;
> +       if (gpriv->info->has_gerfl_eef) {
> +               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");
> +                       stats->tx_dropped++;
> +               }

BTW, this fails to check the ECC error flags for channels 2-7 on R-Car
V3U, which is a pre-existing problem.  As that is a bug, I have sent
a fix[1], which unfortunately conflicts with your patch. Sorry for that.

>         }
>         if (gerfl & RCANFD_GERFL_MES) {
>                 sts = rcar_canfd_read(priv->base,

[1] "[PATCH] can: rcar_canfd: Add missing ECC error checks for channels 2-7"
    https://lore.kernel.org/r/4edb2ea46cc64d0532a08a924179827481e14b4f.1666951503.git.geert+renesas@glider.be

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

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

* RE: [PATCH v3 6/6] can: rcar_canfd: Add has_gerfl_eef to struct rcar_canfd_hw_info
  2022-10-28 10:12   ` Geert Uytterhoeven
@ 2022-10-28 10:22     ` Biju Das
  2022-10-28 10:24     ` Marc Kleine-Budde
  1 sibling, 0 replies; 15+ messages in thread
From: Biju Das @ 2022-10-28 10:22 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Wolfgang Grandegger, Marc Kleine-Budde, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Vincent Mailhol,
	Stefan Mätje, Ulrich Hecht, Prabhakar Mahadev Lad,
	Christophe JAILLET, linux-can, netdev, Geert Uytterhoeven,
	Chris Paterson, Biju Das, linux-renesas-soc

Hi Geert,

> Subject: Re: [PATCH v3 6/6] can: rcar_canfd: Add has_gerfl_eef to
> struct rcar_canfd_hw_info
> 
> Hi Biju,
> 
> On Thu, Oct 27, 2022 at 10:22 AM Biju Das <biju.das.jz@bp.renesas.com>
> wrote:
> > R-Car has ECC error flags in global error interrupts whereas it is
> not
> > available on RZ/G2L.
> >
> > Add has_gerfl_eef to struct rcar_canfd_hw_info so that rcar_canfd_
> > global_error() will process ECC errors only for R-Car.
> >
> > whilst, this patch fixes the below checkpatch warnings
> >   CHECK: Unnecessary parentheses around 'ch == 0'
> >   CHECK: Unnecessary parentheses around 'ch == 1'
> >
> > Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
> 
> Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
> 
> > --- a/drivers/net/can/rcar/rcar_canfd.c
> > +++ b/drivers/net/can/rcar/rcar_canfd.c
> > @@ -955,13 +958,15 @@ 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");
> > -               stats->tx_dropped++;
> > +       if (gpriv->info->has_gerfl_eef) {
> > +               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");
> > +                       stats->tx_dropped++;
> > +               }
> 
> BTW, this fails to check the ECC error flags for channels 2-7 on R-Car
> V3U, which is a pre-existing problem.  As that is a bug, I have sent a
> fix[1], which unfortunately conflicts with your patch. Sorry for that.
> 
> >         }
> >         if (gerfl & RCANFD_GERFL_MES) {
> >                 sts = rcar_canfd_read(priv->base,
> 
> [1] "[PATCH] can: rcar_canfd: Add missing ECC error checks for
> channels 2-7"

OK. I will rebase with this patch.

Cheers,
Biju

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

* Re: [PATCH v3 6/6] can: rcar_canfd: Add has_gerfl_eef to struct rcar_canfd_hw_info
  2022-10-28 10:12   ` Geert Uytterhoeven
  2022-10-28 10:22     ` Biju Das
@ 2022-10-28 10:24     ` Marc Kleine-Budde
  2022-10-28 10:53       ` Biju Das
  1 sibling, 1 reply; 15+ messages in thread
From: Marc Kleine-Budde @ 2022-10-28 10:24 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: biju.das.jz, Wolfgang Grandegger, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Vincent Mailhol, Stefan Mätje,
	Ulrich Hecht, Lad Prabhakar, Christophe JAILLET, linux-can,
	netdev, Geert Uytterhoeven, Chris Paterson, Biju Das,
	linux-renesas-soc

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

On 28.10.2022 12:12:22, Geert Uytterhoeven wrote:
> Hi Biju,
> 
> On Thu, Oct 27, 2022 at 10:22 AM Biju Das <biju.das.jz@bp.renesas.com> wrote:
> > R-Car has ECC error flags in global error interrupts whereas it is
> > not available on RZ/G2L.
> >
> > Add has_gerfl_eef to struct rcar_canfd_hw_info so that rcar_canfd_
> > global_error() will process ECC errors only for R-Car.
> >
> > whilst, this patch fixes the below checkpatch warnings
> >   CHECK: Unnecessary parentheses around 'ch == 0'
> >   CHECK: Unnecessary parentheses around 'ch == 1'
> >
> > Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
> 
> Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
> 
> > --- a/drivers/net/can/rcar/rcar_canfd.c
> > +++ b/drivers/net/can/rcar/rcar_canfd.c
> > @@ -955,13 +958,15 @@ 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");
> > -               stats->tx_dropped++;
> > +       if (gpriv->info->has_gerfl_eef) {
> > +               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");
> > +                       stats->tx_dropped++;
> > +               }
> 
> BTW, this fails to check the ECC error flags for channels 2-7 on R-Car
> V3U, which is a pre-existing problem.  As that is a bug, I have sent
> a fix[1], which unfortunately conflicts with your patch. Sorry for that.

I'll add Geert's fix to can/main and upstream via net/main. Please
re-spin this series after net/main has been merged to net-next/main.

This way we'll avoid a merge conflict.

Marc

-- 
Pengutronix e.K.                 | Marc Kleine-Budde           |
Embedded Linux                   | https://www.pengutronix.de  |
Vertretung West/Dortmund         | Phone: +49-231-2826-924     |
Amtsgericht Hildesheim, HRA 2686 | Fax:   +49-5121-206917-5555 |

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

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

* RE: [PATCH v3 6/6] can: rcar_canfd: Add has_gerfl_eef to struct rcar_canfd_hw_info
  2022-10-28 10:24     ` Marc Kleine-Budde
@ 2022-10-28 10:53       ` Biju Das
  2022-10-31 14:57         ` Biju Das
  0 siblings, 1 reply; 15+ messages in thread
From: Biju Das @ 2022-10-28 10:53 UTC (permalink / raw)
  To: Marc Kleine-Budde, Geert Uytterhoeven
  Cc: Wolfgang Grandegger, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Vincent Mailhol, Stefan Mätje,
	Ulrich Hecht, Prabhakar Mahadev Lad, Christophe JAILLET,
	linux-can, netdev, Geert Uytterhoeven, Chris Paterson, Biju Das,
	linux-renesas-soc

Hi Marc,

Thanks for the feedback.

> Subject: Re: [PATCH v3 6/6] can: rcar_canfd: Add has_gerfl_eef to
> struct rcar_canfd_hw_info
> 
> On 28.10.2022 12:12:22, Geert Uytterhoeven wrote:
> > Hi Biju,
> >
> > On Thu, Oct 27, 2022 at 10:22 AM Biju Das
> <biju.das.jz@bp.renesas.com> wrote:
> > > R-Car has ECC error flags in global error interrupts whereas it is
> > > not available on RZ/G2L.
> > >
> > > Add has_gerfl_eef to struct rcar_canfd_hw_info so that rcar_canfd_
> > > global_error() will process ECC errors only for R-Car.
> > >
> > > whilst, this patch fixes the below checkpatch warnings
> > >   CHECK: Unnecessary parentheses around 'ch == 0'
> > >   CHECK: Unnecessary parentheses around 'ch == 1'
> > >
> > > Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
> >
> > Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
> >
> > > --- a/drivers/net/can/rcar/rcar_canfd.c
> > > +++ b/drivers/net/can/rcar/rcar_canfd.c
> > > @@ -955,13 +958,15 @@ 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");
> > > -               stats->tx_dropped++;
> > > +       if (gpriv->info->has_gerfl_eef) {
> > > +               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");
> > > +                       stats->tx_dropped++;
> > > +               }
> >
> > BTW, this fails to check the ECC error flags for channels 2-7 on R-
> Car
> > V3U, which is a pre-existing problem.  As that is a bug, I have sent
> a
> > fix[1], which unfortunately conflicts with your patch. Sorry for
> that.
> 
> I'll add Geert's fix to can/main and upstream via net/main. Please re-
> spin this series after net/main has been merged to net-next/main.
> 
> This way we'll avoid a merge conflict.

Agreed.

Cheers,
Biju

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

* RE: [PATCH v3 6/6] can: rcar_canfd: Add has_gerfl_eef to struct rcar_canfd_hw_info
  2022-10-28 10:53       ` Biju Das
@ 2022-10-31 14:57         ` Biju Das
  2022-10-31 15:17           ` Marc Kleine-Budde
  0 siblings, 1 reply; 15+ messages in thread
From: Biju Das @ 2022-10-31 14:57 UTC (permalink / raw)
  To: Marc Kleine-Budde, Geert Uytterhoeven
  Cc: Wolfgang Grandegger, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Vincent Mailhol, Stefan Mätje,
	Ulrich Hecht, Prabhakar Mahadev Lad, Christophe JAILLET,
	linux-can, netdev, Geert Uytterhoeven, Chris Paterson, Biju Das,
	linux-renesas-soc

Hi Marc,

> Subject: RE: [PATCH v3 6/6] can: rcar_canfd: Add has_gerfl_eef to
> struct rcar_canfd_hw_info
> 
> Hi Marc,
> 
> Thanks for the feedback.
> 
> > Subject: Re: [PATCH v3 6/6] can: rcar_canfd: Add has_gerfl_eef to
> > struct rcar_canfd_hw_info
> >
> > On 28.10.2022 12:12:22, Geert Uytterhoeven wrote:
> > > Hi Biju,
> > >
> > > On Thu, Oct 27, 2022 at 10:22 AM Biju Das
> > <biju.das.jz@bp.renesas.com> wrote:
> > > > R-Car has ECC error flags in global error interrupts whereas it
> is
> > > > not available on RZ/G2L.
> > > >
> > > > Add has_gerfl_eef to struct rcar_canfd_hw_info so that
> rcar_canfd_
> > > > global_error() will process ECC errors only for R-Car.
> > > >
> > > > whilst, this patch fixes the below checkpatch warnings
> > > >   CHECK: Unnecessary parentheses around 'ch == 0'
> > > >   CHECK: Unnecessary parentheses around 'ch == 1'
> > > >
> > > > Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
> > >
> > > Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
> > >
> > > > --- a/drivers/net/can/rcar/rcar_canfd.c
> > > > +++ b/drivers/net/can/rcar/rcar_canfd.c
> > > > @@ -955,13 +958,15 @@ 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");
> > > > -               stats->tx_dropped++;
> > > > +       if (gpriv->info->has_gerfl_eef) {
> > > > +               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");
> > > > +                       stats->tx_dropped++;
> > > > +               }
> > >
> > > BTW, this fails to check the ECC error flags for channels 2-7 on
> R-
> > Car
> > > V3U, which is a pre-existing problem.  As that is a bug, I have
> sent
> > a
> > > fix[1], which unfortunately conflicts with your patch. Sorry for
> > that.
> >
> > I'll add Geert's fix to can/main and upstream via net/main. Please
> re-
> > spin this series after net/main has been merged to net-next/main.
> >
> > This way we'll avoid a merge conflict.

Is it OK, if I send all other patches ie, patch#1 to patch#5 in [1] and later
once net/main merged to net-next/main, will send patch#6?

Please let me know.

[1] https://lore.kernel.org/linux-renesas-soc/20221027082158.95895-1-biju.das.jz@bp.renesas.com/T/#t

Cheers,
Biju

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

* Re: RE: [PATCH v3 6/6] can: rcar_canfd: Add has_gerfl_eef to struct rcar_canfd_hw_info
  2022-10-31 14:57         ` Biju Das
@ 2022-10-31 15:17           ` Marc Kleine-Budde
  0 siblings, 0 replies; 15+ messages in thread
From: Marc Kleine-Budde @ 2022-10-31 15:17 UTC (permalink / raw)
  To: Biju Das
  Cc: Geert Uytterhoeven, Wolfgang Grandegger, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Vincent Mailhol,
	Stefan Mätje, Ulrich Hecht, Prabhakar Mahadev Lad,
	Christophe JAILLET, linux-can, netdev, Geert Uytterhoeven,
	Chris Paterson, Biju Das, linux-renesas-soc

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

On 31.10.2022 14:57:43, Biju Das wrote:
[...]

> > > This way we'll avoid a merge conflict.
> 
> Is it OK, if I send all other patches ie, patch#1 to patch#5 in [1] and later
> once net/main merged to net-next/main, will send patch#6?
> 
> Please let me know.

I picked patches 1...5 for can-next/main.

regards,
Marc

-- 
Pengutronix e.K.                 | Marc Kleine-Budde           |
Embedded Linux                   | https://www.pengutronix.de  |
Vertretung West/Dortmund         | Phone: +49-231-2826-924     |
Amtsgericht Hildesheim, HRA 2686 | Fax:   +49-5121-206917-5555 |

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

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

end of thread, other threads:[~2022-10-31 15:17 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-27  8:21 [PATCH v3 0/6] R-Car CAN FD driver enhancements Biju Das
2022-10-27  8:21 ` [PATCH v3 1/6] can: rcar_canfd: rcar_canfd_probe: Add struct rcar_canfd_hw_info to driver data Biju Das
2022-10-27  8:21 ` [PATCH v3 2/6] can: rcar_canfd: Add max_channels to struct rcar_canfd_hw_info Biju Das
2022-10-27  8:21 ` [PATCH v3 3/6] can: rcar_canfd: Add shared_global_irqs " Biju Das
2022-10-27  8:21 ` [PATCH v3 4/6] can: rcar_canfd: Add postdiv " Biju Das
2022-10-28  9:31   ` Geert Uytterhoeven
2022-10-28  9:36     ` Biju Das
2022-10-27  8:21 ` [PATCH v3 5/6] can: rcar_canfd: Add multi_channel_irqs " Biju Das
2022-10-27  8:21 ` [PATCH v3 6/6] can: rcar_canfd: Add has_gerfl_eef " Biju Das
2022-10-28 10:12   ` Geert Uytterhoeven
2022-10-28 10:22     ` Biju Das
2022-10-28 10:24     ` Marc Kleine-Budde
2022-10-28 10:53       ` Biju Das
2022-10-31 14:57         ` Biju Das
2022-10-31 15:17           ` Marc Kleine-Budde

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.