linux-can.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next 0/39] pull-request: can-next 2022-12-12
@ 2022-12-12 11:30 Marc Kleine-Budde
  2022-12-12 11:30 ` [PATCH net-next 01/39] can: kvaser_usb: kvaser_usb_set_bittiming(): fix redundant initialization warning for err Marc Kleine-Budde
                   ` (38 more replies)
  0 siblings, 39 replies; 43+ messages in thread
From: Marc Kleine-Budde @ 2022-12-12 11:30 UTC (permalink / raw)
  To: netdev; +Cc: davem, kuba, linux-can, kernel

Hello Jakub, hello David,

this is a pull request of 39 patches for net-next/master.

The first 2 patches are by me fix a warning and coding style in the
kvaser_usb driver.

Vivek Yadav's patch sorts the includes of the m_can driver.

Biju Das contributes 5 patches for the rcar_canfd driver improve the
support for different IP core variants.

Jean Delvare's patch for the ctucanfd drops the dependency on
COMPILE_TEST.

Vincent Mailhol's patch sorts the includes of the etas_es58x driver.

Haibo Chen's contributes 2 patches that add i.MX93 support to the
flexcan driver.

Lad Prabhakar's patch updates the dt-bindings documentation of the
rcar_canfd driver.

Minghao Chi's patch converts the c_can platform driver to
devm_platform_get_and_ioremap_resource().

In the next 7 patches Vincent Mailhol adds devlink support to the
etas_es58x driver to report firmware, bootloader and hardware version.

Xu Panda's patch converts a strncpy() -> strscpy() in the ucan driver.

Ye Bin's patch removes a useless parameter from the AF_CAN protocol.

The next 2 patches by Vincent Mailhol and remove unneeded or unused
pointers to struct usb_interface in device's priv struct in the ucan
and gs_usb driver.

Vivek Yadav's patch cleans up the usage of the RAM initialization in
the m_can driver.

A patch by me add support for SO_MARK to the AF_CAN protocol.

Geert Uytterhoeven's patch fixes the number of CAN channels in the
rcan_canfd bindings documentation.

In the last 11 patches Markus Schneider-Pargmann optimizes the
register access in the t_can driver and cleans up the tcan glue
driver.

regards,
Marc

---

The following changes since commit dd8b3a802b64adf059a49a68f1bdca7846e492fc:

  Merge tag 'ipsec-next-2022-12-09' of git://git.kernel.org/pub/scm/linux/kernel/git/klassert/ipsec-next (2022-12-09 20:06:35 -0800)

are available in the Git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/mkl/linux-can-next.git tags/linux-can-next-for-6.2-20221212

for you to fetch changes up to 47bf2b2393ea1aacdefbe4e9d643599e057bb3a2:

  Merge patch series "can: m_can: Optimizations for tcan and peripheral chips" (2022-12-12 12:01:26 +0100)

----------------------------------------------------------------
linux-can-next-for-6.2-20221212

----------------------------------------------------------------
Biju Das (5):
      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

Geert Uytterhoeven (1):
      dt-bindings: can: renesas,rcar-canfd: Fix number of channels for R-Car V3U

Haibo Chen (2):
      can: flexcan: add auto stop mode for IMX93 to support wakeup
      dt-bindings: can: fsl,flexcan: add imx93 compatible

Jean Delvare (1):
      can: ctucanfd: Drop obsolete dependency on COMPILE_TEST

Lad Prabhakar (1):
      dt-bindings: can: renesas,rcar-canfd: Document RZ/Five SoC

Marc Kleine-Budde (7):
      can: kvaser_usb: kvaser_usb_set_bittiming(): fix redundant initialization warning for err
      can: kvaser_usb: kvaser_usb_set_{,data}bittiming(): remove empty lines in variable declaration
      Merge patch series "R-Car CAN FD driver enhancements"
      Merge patch series "can: etas_es58x: report firmware, bootloader and hardware version"
      Merge patch series "can: usb: remove pointers to struct usb_interface in device's priv structures"
      can: raw: add support for SO_MARK
      Merge patch series "can: m_can: Optimizations for tcan and peripheral chips"

Markus Schneider-Pargmann (11):
      can: m_can: Eliminate double read of TXFQS in tx_handler
      can: m_can: Avoid reading irqstatus twice
      can: m_can: Read register PSR only on error
      can: m_can: Count TXE FIFO getidx in the driver
      can: m_can: Count read getindex in the driver
      can: m_can: Batch acknowledge transmit events
      can: m_can: Batch acknowledge rx fifo
      can: tcan4x5x: Remove invalid write in clear_interrupts
      can: tcan4x5x: Fix use of register error status mask
      can: tcan4x5x: Fix register range of first two blocks
      can: tcan4x5x: Specify separate read/write ranges

Minghao Chi (1):
      can: c_can: use devm_platform_get_and_ioremap_resource()

Vincent Mailhol (10):
      can: etas_es58x: sort the includes by alphabetic order
      can: etas_es58x: add devlink support
      can: etas_es58x: add devlink port support
      USB: core: export usb_cache_string()
      net: devlink: add DEVLINK_INFO_VERSION_GENERIC_FW_BOOTLOADER
      can: etas_es58x: export product information through devlink_ops::info_get()
      can: etas_es58x: remove es58x_get_product_info()
      Documentation: devlink: add devlink documentation for the etas_es58x driver
      can: ucan: remove unused ucan_priv::intf
      can: gs_usb: remove gs_can::iface

Vivek Yadav (2):
      can: m_can: sort header inclusion alphabetically
      can: m_can: Call the RAM init directly from m_can_chip_config

Xu Panda (1):
      can: ucan: use strscpy() to instead of strncpy()

Ye Bin (1):
      net: af_can: remove useless parameter 'err' in 'can_rx_register()'

 .../devicetree/bindings/net/can/fsl,flexcan.yaml   |   1 +
 .../bindings/net/can/renesas,rcar-canfd.yaml       | 135 ++++++------
 Documentation/networking/devlink/devlink-info.rst  |   5 +
 Documentation/networking/devlink/etas_es58x.rst    |  36 ++++
 MAINTAINERS                                        |   1 +
 drivers/net/can/c_can/c_can_platform.c             |   3 +-
 drivers/net/can/ctucanfd/Kconfig                   |   2 +-
 drivers/net/can/flexcan/flexcan-core.c             |  37 +++-
 drivers/net/can/flexcan/flexcan.h                  |   2 +
 drivers/net/can/m_can/m_can.c                      | 130 ++++++++----
 drivers/net/can/m_can/m_can.h                      |  16 +-
 drivers/net/can/m_can/m_can_platform.c             |   6 +-
 drivers/net/can/m_can/tcan4x5x-core.c              |  18 +-
 drivers/net/can/m_can/tcan4x5x-regmap.c            |  47 ++++-
 drivers/net/can/rcar/rcar_canfd.c                  |  85 +++++---
 drivers/net/can/usb/Kconfig                        |   1 +
 drivers/net/can/usb/etas_es58x/Makefile            |   2 +-
 drivers/net/can/usb/etas_es58x/es581_4.c           |   4 +-
 drivers/net/can/usb/etas_es58x/es58x_core.c        | 104 ++++-----
 drivers/net/can/usb/etas_es58x/es58x_core.h        |  58 ++++-
 drivers/net/can/usb/etas_es58x/es58x_devlink.c     | 235 +++++++++++++++++++++
 drivers/net/can/usb/etas_es58x/es58x_fd.c          |   4 +-
 drivers/net/can/usb/gs_usb.c                       |  29 +--
 drivers/net/can/usb/kvaser_usb/kvaser_usb_core.c   |   4 +-
 drivers/net/can/usb/ucan.c                         |   7 +-
 drivers/usb/core/message.c                         |   1 +
 drivers/usb/core/usb.h                             |   1 -
 include/linux/usb.h                                |   1 +
 include/net/devlink.h                              |   2 +
 net/can/af_can.c                                   |   3 +-
 net/can/raw.c                                      |   1 +
 31 files changed, 696 insertions(+), 285 deletions(-)
 create mode 100644 Documentation/networking/devlink/etas_es58x.rst
 create mode 100644 drivers/net/can/usb/etas_es58x/es58x_devlink.c



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

* [PATCH net-next 01/39] can: kvaser_usb: kvaser_usb_set_bittiming(): fix redundant initialization warning for err
  2022-12-12 11:30 [PATCH net-next 0/39] pull-request: can-next 2022-12-12 Marc Kleine-Budde
@ 2022-12-12 11:30 ` Marc Kleine-Budde
  2022-12-12 12:20   ` patchwork-bot+netdevbpf
  2022-12-12 11:30 ` [PATCH net-next 02/39] can: kvaser_usb: kvaser_usb_set_{,data}bittiming(): remove empty lines in variable declaration Marc Kleine-Budde
                   ` (37 subsequent siblings)
  38 siblings, 1 reply; 43+ messages in thread
From: Marc Kleine-Budde @ 2022-12-12 11:30 UTC (permalink / raw)
  To: netdev
  Cc: davem, kuba, linux-can, kernel, Marc Kleine-Budde,
	Jimmy Assarsson, Anssi Hannula

The variable err is initialized, but the initialized value is
Overwritten before it is read. Fix the warning by not initializing the
variable err at all.

Fixes: 39d3df6b0ea8 ("can: kvaser_usb: Compare requested bittiming parameters with actual parameters in do_set_{,data}_bittiming")
Cc: Jimmy Assarsson <extja@kvaser.com>
Cc: Anssi Hannula <anssi.hannula@bitwise.fi>
Link: https://lore.kernel.org/all/20221031114513.81214-1-mkl@pengutronix.de
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 drivers/net/can/usb/kvaser_usb/kvaser_usb_core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/can/usb/kvaser_usb/kvaser_usb_core.c b/drivers/net/can/usb/kvaser_usb/kvaser_usb_core.c
index 3a2bfaad1406..b17c4d8c6cf9 100644
--- a/drivers/net/can/usb/kvaser_usb/kvaser_usb_core.c
+++ b/drivers/net/can/usb/kvaser_usb/kvaser_usb_core.c
@@ -541,7 +541,7 @@ static int kvaser_usb_set_bittiming(struct net_device *netdev)
 	int tseg1 = bt->prop_seg + bt->phase_seg1;
 	int tseg2 = bt->phase_seg2;
 	int sjw = bt->sjw;
-	int err = -EOPNOTSUPP;
+	int err;
 
 	busparams.bitrate = cpu_to_le32(bt->bitrate);
 	busparams.sjw = (u8)sjw;

base-commit: dd8b3a802b64adf059a49a68f1bdca7846e492fc
-- 
2.35.1



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

* [PATCH net-next 02/39] can: kvaser_usb: kvaser_usb_set_{,data}bittiming(): remove empty lines in variable declaration
  2022-12-12 11:30 [PATCH net-next 0/39] pull-request: can-next 2022-12-12 Marc Kleine-Budde
  2022-12-12 11:30 ` [PATCH net-next 01/39] can: kvaser_usb: kvaser_usb_set_bittiming(): fix redundant initialization warning for err Marc Kleine-Budde
@ 2022-12-12 11:30 ` Marc Kleine-Budde
  2022-12-12 11:30 ` [PATCH net-next 03/39] can: rcar_canfd: rcar_canfd_probe: Add struct rcar_canfd_hw_info to driver data Marc Kleine-Budde
                   ` (36 subsequent siblings)
  38 siblings, 0 replies; 43+ messages in thread
From: Marc Kleine-Budde @ 2022-12-12 11:30 UTC (permalink / raw)
  To: netdev
  Cc: davem, kuba, linux-can, kernel, Marc Kleine-Budde,
	Jimmy Assarsson, Anssi Hannula

Fix coding style by removing empty lines in variable declaration.

Fixes: 39d3df6b0ea8 ("can: kvaser_usb: Compare requested bittiming parameters with actual parameters in do_set_{,data}_bittiming")
Cc: Jimmy Assarsson <extja@kvaser.com>
Cc: Anssi Hannula <anssi.hannula@bitwise.fi>
Link: https://lore.kernel.org/all/20221031114513.81214-2-mkl@pengutronix.de
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 drivers/net/can/usb/kvaser_usb/kvaser_usb_core.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/net/can/usb/kvaser_usb/kvaser_usb_core.c b/drivers/net/can/usb/kvaser_usb/kvaser_usb_core.c
index b17c4d8c6cf9..d4c5356d5884 100644
--- a/drivers/net/can/usb/kvaser_usb/kvaser_usb_core.c
+++ b/drivers/net/can/usb/kvaser_usb/kvaser_usb_core.c
@@ -536,7 +536,6 @@ static int kvaser_usb_set_bittiming(struct net_device *netdev)
 	struct kvaser_usb *dev = priv->dev;
 	const struct kvaser_usb_dev_ops *ops = dev->driver_info->ops;
 	struct can_bittiming *bt = &priv->can.bittiming;
-
 	struct kvaser_usb_busparams busparams;
 	int tseg1 = bt->prop_seg + bt->phase_seg1;
 	int tseg2 = bt->phase_seg2;
@@ -581,7 +580,6 @@ static int kvaser_usb_set_data_bittiming(struct net_device *netdev)
 	struct kvaser_usb *dev = priv->dev;
 	const struct kvaser_usb_dev_ops *ops = dev->driver_info->ops;
 	struct can_bittiming *dbt = &priv->can.data_bittiming;
-
 	struct kvaser_usb_busparams busparams;
 	int tseg1 = dbt->prop_seg + dbt->phase_seg1;
 	int tseg2 = dbt->phase_seg2;
-- 
2.35.1



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

* [PATCH net-next 03/39] can: rcar_canfd: rcar_canfd_probe: Add struct rcar_canfd_hw_info to driver data
  2022-12-12 11:30 [PATCH net-next 0/39] pull-request: can-next 2022-12-12 Marc Kleine-Budde
  2022-12-12 11:30 ` [PATCH net-next 01/39] can: kvaser_usb: kvaser_usb_set_bittiming(): fix redundant initialization warning for err Marc Kleine-Budde
  2022-12-12 11:30 ` [PATCH net-next 02/39] can: kvaser_usb: kvaser_usb_set_{,data}bittiming(): remove empty lines in variable declaration Marc Kleine-Budde
@ 2022-12-12 11:30 ` Marc Kleine-Budde
  2022-12-12 11:30 ` [PATCH net-next 04/39] can: m_can: sort header inclusion alphabetically Marc Kleine-Budde
                   ` (35 subsequent siblings)
  38 siblings, 0 replies; 43+ messages in thread
From: Marc Kleine-Budde @ 2022-12-12 11:30 UTC (permalink / raw)
  To: netdev
  Cc: davem, kuba, linux-can, kernel, Biju Das, Geert Uytterhoeven,
	Marc Kleine-Budde

From: Biju Das <biju.das.jz@bp.renesas.com>

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>
---
 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 0a59eab35da7..1a5a013ac5bc 100644
--- a/drivers/net/can/rcar/rcar_canfd.c
+++ b/drivers/net/can/rcar/rcar_canfd.c
@@ -522,6 +522,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 */
@@ -547,7 +551,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;
 };
 
@@ -590,10 +594,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,
@@ -1696,6 +1712,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;
@@ -1718,7 +1735,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;
@@ -1818,6 +1835,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;
@@ -1826,13 +1844,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 */
@@ -1845,7 +1862,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 */
@@ -1879,7 +1896,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,
@@ -1917,7 +1934,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;
 
@@ -1929,7 +1946,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);
@@ -2082,9 +2099,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.35.1



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

* [PATCH net-next 04/39] can: m_can: sort header inclusion alphabetically
  2022-12-12 11:30 [PATCH net-next 0/39] pull-request: can-next 2022-12-12 Marc Kleine-Budde
                   ` (2 preceding siblings ...)
  2022-12-12 11:30 ` [PATCH net-next 03/39] can: rcar_canfd: rcar_canfd_probe: Add struct rcar_canfd_hw_info to driver data Marc Kleine-Budde
@ 2022-12-12 11:30 ` Marc Kleine-Budde
  2022-12-12 11:30 ` [PATCH net-next 05/39] can: rcar_canfd: Add max_channels to struct rcar_canfd_hw_info Marc Kleine-Budde
                   ` (34 subsequent siblings)
  38 siblings, 0 replies; 43+ messages in thread
From: Marc Kleine-Budde @ 2022-12-12 11:30 UTC (permalink / raw)
  To: netdev; +Cc: davem, kuba, linux-can, kernel, Vivek Yadav, Marc Kleine-Budde

From: Vivek Yadav <vivek.2311@samsung.com>

Sort header inclusion alphabetically.

Suggested-by: Marc Kleine-Budde <mkl@pengutronix.de>
Signed-off-by: Vivek Yadav <vivek.2311@samsung.com>
Link: https://lore.kernel.org/all/20221104051617.21173-1-vivek.2311@samsung.com
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 drivers/net/can/m_can/m_can.c          |  8 ++++----
 drivers/net/can/m_can/m_can.h          | 16 ++++++++--------
 drivers/net/can/m_can/m_can_platform.c |  2 +-
 3 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/drivers/net/can/m_can/m_can.c b/drivers/net/can/m_can/m_can.c
index 0bdec28e7c85..b1893bb27d59 100644
--- a/drivers/net/can/m_can/m_can.c
+++ b/drivers/net/can/m_can/m_can.c
@@ -9,20 +9,20 @@
  */
 
 #include <linux/bitfield.h>
+#include <linux/can/dev.h>
 #include <linux/ethtool.h>
 #include <linux/interrupt.h>
 #include <linux/io.h>
+#include <linux/iopoll.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/netdevice.h>
 #include <linux/of.h>
 #include <linux/of_device.h>
+#include <linux/phy/phy.h>
+#include <linux/pinctrl/consumer.h>
 #include <linux/platform_device.h>
 #include <linux/pm_runtime.h>
-#include <linux/iopoll.h>
-#include <linux/can/dev.h>
-#include <linux/pinctrl/consumer.h>
-#include <linux/phy/phy.h>
 
 #include "m_can.h"
 
diff --git a/drivers/net/can/m_can/m_can.h b/drivers/net/can/m_can/m_can.h
index 52563c048732..a839dc71dc9b 100644
--- a/drivers/net/can/m_can/m_can.h
+++ b/drivers/net/can/m_can/m_can.h
@@ -7,27 +7,27 @@
 #define _CAN_M_CAN_H_
 
 #include <linux/can/core.h>
+#include <linux/can/dev.h>
 #include <linux/can/rx-offload.h>
+#include <linux/clk.h>
 #include <linux/completion.h>
+#include <linux/delay.h>
 #include <linux/device.h>
 #include <linux/dma-mapping.h>
 #include <linux/freezer.h>
-#include <linux/slab.h>
-#include <linux/uaccess.h>
-#include <linux/clk.h>
-#include <linux/delay.h>
 #include <linux/interrupt.h>
 #include <linux/io.h>
+#include <linux/iopoll.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/netdevice.h>
 #include <linux/of.h>
 #include <linux/of_device.h>
-#include <linux/pm_runtime.h>
-#include <linux/iopoll.h>
-#include <linux/can/dev.h>
-#include <linux/pinctrl/consumer.h>
 #include <linux/phy/phy.h>
+#include <linux/pinctrl/consumer.h>
+#include <linux/pm_runtime.h>
+#include <linux/slab.h>
+#include <linux/uaccess.h>
 
 /* m_can lec values */
 enum m_can_lec_type {
diff --git a/drivers/net/can/m_can/m_can_platform.c b/drivers/net/can/m_can/m_can_platform.c
index eee47bad0592..b5a5bedb3116 100644
--- a/drivers/net/can/m_can/m_can_platform.c
+++ b/drivers/net/can/m_can/m_can_platform.c
@@ -5,8 +5,8 @@
 //
 // Copyright (C) 2018-19 Texas Instruments Incorporated - http://www.ti.com/
 
-#include <linux/platform_device.h>
 #include <linux/phy/phy.h>
+#include <linux/platform_device.h>
 
 #include "m_can.h"
 
-- 
2.35.1



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

* [PATCH net-next 05/39] can: rcar_canfd: Add max_channels to struct rcar_canfd_hw_info
  2022-12-12 11:30 [PATCH net-next 0/39] pull-request: can-next 2022-12-12 Marc Kleine-Budde
                   ` (3 preceding siblings ...)
  2022-12-12 11:30 ` [PATCH net-next 04/39] can: m_can: sort header inclusion alphabetically Marc Kleine-Budde
@ 2022-12-12 11:30 ` Marc Kleine-Budde
  2022-12-12 11:30 ` [PATCH net-next 06/39] can: rcar_canfd: Add shared_global_irqs " Marc Kleine-Budde
                   ` (33 subsequent siblings)
  38 siblings, 0 replies; 43+ messages in thread
From: Marc Kleine-Budde @ 2022-12-12 11:30 UTC (permalink / raw)
  To: netdev
  Cc: davem, kuba, linux-can, kernel, Biju Das, Geert Uytterhoeven,
	Marc Kleine-Budde

From: Biju Das <biju.das.jz@bp.renesas.com>

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>
Link: https://lore.kernel.org/all/20221027082158.95895-3-biju.das.jz@bp.renesas.com
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 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 1a5a013ac5bc..6a9f750ac9c1 100644
--- a/drivers/net/can/rcar/rcar_canfd.c
+++ b/drivers/net/can/rcar/rcar_canfd.c
@@ -524,6 +524,7 @@ struct rcar_canfd_global;
 
 struct rcar_canfd_hw_info {
 	enum rcanfd_chip_id chip_id;
+	u8 max_channels;
 };
 
 /* Channel priv data */
@@ -552,7 +553,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 */
@@ -596,14 +596,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 */
@@ -737,7 +740,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);
 
@@ -778,7 +781,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),
@@ -1158,7 +1161,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;
@@ -1190,7 +1193,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;
@@ -1204,7 +1207,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);
 	}
@@ -1300,7 +1303,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);
 	}
@@ -1844,17 +1847,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))
@@ -1897,7 +1898,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");
@@ -2012,7 +2012,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);
 
@@ -2038,7 +2038,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;
@@ -2050,7 +2050,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);
@@ -2071,7 +2071,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.35.1



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

* [PATCH net-next 06/39] can: rcar_canfd: Add shared_global_irqs to struct rcar_canfd_hw_info
  2022-12-12 11:30 [PATCH net-next 0/39] pull-request: can-next 2022-12-12 Marc Kleine-Budde
                   ` (4 preceding siblings ...)
  2022-12-12 11:30 ` [PATCH net-next 05/39] can: rcar_canfd: Add max_channels to struct rcar_canfd_hw_info Marc Kleine-Budde
@ 2022-12-12 11:30 ` Marc Kleine-Budde
  2022-12-12 11:30 ` [PATCH net-next 07/39] can: rcar_canfd: Add postdiv " Marc Kleine-Budde
                   ` (32 subsequent siblings)
  38 siblings, 0 replies; 43+ messages in thread
From: Marc Kleine-Budde @ 2022-12-12 11:30 UTC (permalink / raw)
  To: netdev
  Cc: davem, kuba, linux-can, kernel, Biju Das, Geert Uytterhoeven,
	Marc Kleine-Budde

From: Biju Das <biju.das.jz@bp.renesas.com>

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>
---
 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 6a9f750ac9c1..8a0d2c64dd3e 100644
--- a/drivers/net/can/rcar/rcar_canfd.c
+++ b/drivers/net/can/rcar/rcar_canfd.c
@@ -525,6 +525,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 */
@@ -597,6 +599,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 = {
@@ -607,6 +610,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 */
@@ -1863,7 +1867,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 */
@@ -1946,7 +1950,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.35.1



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

* [PATCH net-next 07/39] can: rcar_canfd: Add postdiv to struct rcar_canfd_hw_info
  2022-12-12 11:30 [PATCH net-next 0/39] pull-request: can-next 2022-12-12 Marc Kleine-Budde
                   ` (5 preceding siblings ...)
  2022-12-12 11:30 ` [PATCH net-next 06/39] can: rcar_canfd: Add shared_global_irqs " Marc Kleine-Budde
@ 2022-12-12 11:30 ` Marc Kleine-Budde
  2022-12-12 11:30 ` [PATCH net-next 08/39] can: rcar_canfd: Add multi_channel_irqs " Marc Kleine-Budde
                   ` (31 subsequent siblings)
  38 siblings, 0 replies; 43+ messages in thread
From: Marc Kleine-Budde @ 2022-12-12 11:30 UTC (permalink / raw)
  To: netdev
  Cc: davem, kuba, linux-can, kernel, Biju Das, Geert Uytterhoeven,
	Marc Kleine-Budde

From: Biju Das <biju.das.jz@bp.renesas.com>

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>
---
 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 8a0d2c64dd3e..16294a78320e 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;
+	u8 postdiv;
 	/* hardware features */
 	unsigned shared_global_irqs:1;	/* Has shared global irqs */
 };
@@ -599,17 +600,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,
 };
 
@@ -1938,9 +1942,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.35.1



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

* [PATCH net-next 08/39] can: rcar_canfd: Add multi_channel_irqs to struct rcar_canfd_hw_info
  2022-12-12 11:30 [PATCH net-next 0/39] pull-request: can-next 2022-12-12 Marc Kleine-Budde
                   ` (6 preceding siblings ...)
  2022-12-12 11:30 ` [PATCH net-next 07/39] can: rcar_canfd: Add postdiv " Marc Kleine-Budde
@ 2022-12-12 11:30 ` Marc Kleine-Budde
  2022-12-12 11:30 ` [PATCH net-next 09/39] can: ctucanfd: Drop obsolete dependency on COMPILE_TEST Marc Kleine-Budde
                   ` (30 subsequent siblings)
  38 siblings, 0 replies; 43+ messages in thread
From: Marc Kleine-Budde @ 2022-12-12 11:30 UTC (permalink / raw)
  To: netdev
  Cc: davem, kuba, linux-can, kernel, Biju Das, Geert Uytterhoeven,
	Marc Kleine-Budde

From: Biju Das <biju.das.jz@bp.renesas.com>

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>
---
 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 16294a78320e..f6fa7157b99b 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 */
@@ -523,11 +517,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 */
@@ -598,20 +592,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,
@@ -1746,7 +1738,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.35.1



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

* [PATCH net-next 09/39] can: ctucanfd: Drop obsolete dependency on COMPILE_TEST
  2022-12-12 11:30 [PATCH net-next 0/39] pull-request: can-next 2022-12-12 Marc Kleine-Budde
                   ` (7 preceding siblings ...)
  2022-12-12 11:30 ` [PATCH net-next 08/39] can: rcar_canfd: Add multi_channel_irqs " Marc Kleine-Budde
@ 2022-12-12 11:30 ` Marc Kleine-Budde
  2022-12-12 11:30 ` [PATCH net-next 10/39] can: etas_es58x: sort the includes by alphabetic order Marc Kleine-Budde
                   ` (29 subsequent siblings)
  38 siblings, 0 replies; 43+ messages in thread
From: Marc Kleine-Budde @ 2022-12-12 11:30 UTC (permalink / raw)
  To: netdev
  Cc: davem, kuba, linux-can, kernel, Jean Delvare, Pavel Pisa,
	Ondrej Ille, Marc Kleine-Budde

From: Jean Delvare <jdelvare@suse.de>

Since commit 0166dc11be91 ("of: make CONFIG_OF user selectable"), it
is possible to test-build any driver which depends on OF on any
architecture by explicitly selecting OF. Therefore depending on
COMPILE_TEST as an alternative is no longer needed.

It is actually better to always build such drivers with OF enabled,
so that the test builds are closer to how each driver will actually be
built on its intended target. Building them without OF may not test
much as the compiler will optimize out potentially large parts of the
code. In the worst case, this could even pop false positive warnings.
Dropping COMPILE_TEST here improves the quality of our testing and
avoids wasting time on non-existent issues.

Signed-off-by: Jean Delvare <jdelvare@suse.de>
Cc: Pavel Pisa <pisa@cmp.felk.cvut.cz>
Cc: Ondrej Ille <ondrej.ille@gmail.com>
Acked-by: Pavel Pisa <pisa@cmp.felk.cvut.cz>
Link: https://lore.kernel.org/all/20221124141604.4265225f@endymion.delvare
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 drivers/net/can/ctucanfd/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/can/ctucanfd/Kconfig b/drivers/net/can/ctucanfd/Kconfig
index 6e2073351a8f..f52407f5c5d8 100644
--- a/drivers/net/can/ctucanfd/Kconfig
+++ b/drivers/net/can/ctucanfd/Kconfig
@@ -23,7 +23,7 @@ config CAN_CTUCANFD_PCI
 
 config CAN_CTUCANFD_PLATFORM
 	tristate "CTU CAN-FD IP core platform (FPGA, SoC) driver"
-	depends on HAS_IOMEM && (OF || COMPILE_TEST)
+	depends on HAS_IOMEM && OF
 	select CAN_CTUCANFD
 	help
 	  The core has been tested together with OpenCores SJA1000
-- 
2.35.1



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

* [PATCH net-next 10/39] can: etas_es58x: sort the includes by alphabetic order
  2022-12-12 11:30 [PATCH net-next 0/39] pull-request: can-next 2022-12-12 Marc Kleine-Budde
                   ` (8 preceding siblings ...)
  2022-12-12 11:30 ` [PATCH net-next 09/39] can: ctucanfd: Drop obsolete dependency on COMPILE_TEST Marc Kleine-Budde
@ 2022-12-12 11:30 ` Marc Kleine-Budde
  2022-12-12 11:30 ` [PATCH net-next 11/39] can: flexcan: add auto stop mode for IMX93 to support wakeup Marc Kleine-Budde
                   ` (28 subsequent siblings)
  38 siblings, 0 replies; 43+ messages in thread
From: Marc Kleine-Budde @ 2022-12-12 11:30 UTC (permalink / raw)
  To: netdev; +Cc: davem, kuba, linux-can, kernel, Vincent Mailhol, Marc Kleine-Budde

From: Vincent Mailhol <mailhol.vincent@wanadoo.fr>

Follow the best practices, reorder the includes.

While doing so, bump up copyright year of each modified files.

Signed-off-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr>
Link: https://lore.kernel.org/all/20221126160525.87036-1-mailhol.vincent@wanadoo.fr
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 drivers/net/can/usb/etas_es58x/es581_4.c    | 4 ++--
 drivers/net/can/usb/etas_es58x/es58x_core.c | 6 +++---
 drivers/net/can/usb/etas_es58x/es58x_core.h | 8 ++++----
 drivers/net/can/usb/etas_es58x/es58x_fd.c   | 4 ++--
 4 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/drivers/net/can/usb/etas_es58x/es581_4.c b/drivers/net/can/usb/etas_es58x/es581_4.c
index 1bcdcece5ec7..4151b18fd045 100644
--- a/drivers/net/can/usb/etas_es58x/es581_4.c
+++ b/drivers/net/can/usb/etas_es58x/es581_4.c
@@ -6,12 +6,12 @@
  *
  * Copyright (c) 2019 Robert Bosch Engineering and Business Solutions. All rights reserved.
  * Copyright (c) 2020 ETAS K.K.. All rights reserved.
- * Copyright (c) 2020, 2021 Vincent Mailhol <mailhol.vincent@wanadoo.fr>
+ * Copyright (c) 2020-2022 Vincent Mailhol <mailhol.vincent@wanadoo.fr>
  */
 
+#include <asm/unaligned.h>
 #include <linux/kernel.h>
 #include <linux/units.h>
-#include <asm/unaligned.h>
 
 #include "es58x_core.h"
 #include "es581_4.h"
diff --git a/drivers/net/can/usb/etas_es58x/es58x_core.c b/drivers/net/can/usb/etas_es58x/es58x_core.c
index ddb7c5735c9a..5aba16849603 100644
--- a/drivers/net/can/usb/etas_es58x/es58x_core.c
+++ b/drivers/net/can/usb/etas_es58x/es58x_core.c
@@ -7,15 +7,15 @@
  *
  * Copyright (c) 2019 Robert Bosch Engineering and Business Solutions. All rights reserved.
  * Copyright (c) 2020 ETAS K.K.. All rights reserved.
- * Copyright (c) 2020, 2021 Vincent Mailhol <mailhol.vincent@wanadoo.fr>
+ * Copyright (c) 2020-2022 Vincent Mailhol <mailhol.vincent@wanadoo.fr>
  */
 
+#include <asm/unaligned.h>
+#include <linux/crc16.h>
 #include <linux/ethtool.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/usb.h>
-#include <linux/crc16.h>
-#include <asm/unaligned.h>
 
 #include "es58x_core.h"
 
diff --git a/drivers/net/can/usb/etas_es58x/es58x_core.h b/drivers/net/can/usb/etas_es58x/es58x_core.h
index 640fe0a1df63..4a082fd69e6f 100644
--- a/drivers/net/can/usb/etas_es58x/es58x_core.h
+++ b/drivers/net/can/usb/etas_es58x/es58x_core.h
@@ -6,17 +6,17 @@
  *
  * Copyright (c) 2019 Robert Bosch Engineering and Business Solutions. All rights reserved.
  * Copyright (c) 2020 ETAS K.K.. All rights reserved.
- * Copyright (c) 2020, 2021 Vincent Mailhol <mailhol.vincent@wanadoo.fr>
+ * Copyright (c) 2020-2022 Vincent Mailhol <mailhol.vincent@wanadoo.fr>
  */
 
 #ifndef __ES58X_COMMON_H__
 #define __ES58X_COMMON_H__
 
-#include <linux/types.h>
-#include <linux/usb.h>
-#include <linux/netdevice.h>
 #include <linux/can.h>
 #include <linux/can/dev.h>
+#include <linux/netdevice.h>
+#include <linux/types.h>
+#include <linux/usb.h>
 
 #include "es581_4.h"
 #include "es58x_fd.h"
diff --git a/drivers/net/can/usb/etas_es58x/es58x_fd.c b/drivers/net/can/usb/etas_es58x/es58x_fd.c
index c97ffa71fd75..fa87b0b78e3e 100644
--- a/drivers/net/can/usb/etas_es58x/es58x_fd.c
+++ b/drivers/net/can/usb/etas_es58x/es58x_fd.c
@@ -8,12 +8,12 @@
  *
  * Copyright (c) 2019 Robert Bosch Engineering and Business Solutions. All rights reserved.
  * Copyright (c) 2020 ETAS K.K.. All rights reserved.
- * Copyright (c) 2020, 2021 Vincent Mailhol <mailhol.vincent@wanadoo.fr>
+ * Copyright (c) 2020-2022 Vincent Mailhol <mailhol.vincent@wanadoo.fr>
  */
 
+#include <asm/unaligned.h>
 #include <linux/kernel.h>
 #include <linux/units.h>
-#include <asm/unaligned.h>
 
 #include "es58x_core.h"
 #include "es58x_fd.h"
-- 
2.35.1



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

* [PATCH net-next 11/39] can: flexcan: add auto stop mode for IMX93 to support wakeup
  2022-12-12 11:30 [PATCH net-next 0/39] pull-request: can-next 2022-12-12 Marc Kleine-Budde
                   ` (9 preceding siblings ...)
  2022-12-12 11:30 ` [PATCH net-next 10/39] can: etas_es58x: sort the includes by alphabetic order Marc Kleine-Budde
@ 2022-12-12 11:30 ` Marc Kleine-Budde
  2022-12-13  2:22   ` Bough Chen
  2022-12-12 11:30 ` [PATCH net-next 12/39] can: etas_es58x: add devlink support Marc Kleine-Budde
                   ` (27 subsequent siblings)
  38 siblings, 1 reply; 43+ messages in thread
From: Marc Kleine-Budde @ 2022-12-12 11:30 UTC (permalink / raw)
  To: netdev; +Cc: davem, kuba, linux-can, kernel, Haibo Chen, Marc Kleine-Budde

From: Haibo Chen <haibo.chen@nxp.com>

IMX93 do not contain a GPR to config the stop mode, it will set
the flexcan into stop mode automatically once the ARM core go
into low power mode (WFI instruct) and gate off the flexcan
related clock automatically. But to let these logic work as
expect, before ARM core go into low power mode, need to make
sure the flexcan related clock keep on.

To support stop mode and wakeup feature on imx93, this patch
add a new fsl_imx93_devtype_data to separate from imx8mp.

Signed-off-by: Haibo Chen <haibo.chen@nxp.com>
Link: https://lore.kernel.org/all/1669116752-4260-1-git-send-email-haibo.chen@nxp.com
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 drivers/net/can/flexcan/flexcan-core.c | 37 +++++++++++++++++++++++---
 drivers/net/can/flexcan/flexcan.h      |  2 ++
 2 files changed, 36 insertions(+), 3 deletions(-)

diff --git a/drivers/net/can/flexcan/flexcan-core.c b/drivers/net/can/flexcan/flexcan-core.c
index 9bdadd716f4e..0aeff34e5ae1 100644
--- a/drivers/net/can/flexcan/flexcan-core.c
+++ b/drivers/net/can/flexcan/flexcan-core.c
@@ -345,6 +345,15 @@ static struct flexcan_devtype_data fsl_imx8mp_devtype_data = {
 		FLEXCAN_QUIRK_SUPPORT_RX_MAILBOX_RTR,
 };
 
+static struct flexcan_devtype_data fsl_imx93_devtype_data = {
+	.quirks = FLEXCAN_QUIRK_DISABLE_RXFG | FLEXCAN_QUIRK_ENABLE_EACEN_RRS |
+		FLEXCAN_QUIRK_DISABLE_MECR | FLEXCAN_QUIRK_USE_RX_MAILBOX |
+		FLEXCAN_QUIRK_BROKEN_PERR_STATE | FLEXCAN_QUIRK_AUTO_STOP_MODE |
+		FLEXCAN_QUIRK_SUPPORT_FD | FLEXCAN_QUIRK_SUPPORT_ECC |
+		FLEXCAN_QUIRK_SUPPORT_RX_MAILBOX |
+		FLEXCAN_QUIRK_SUPPORT_RX_MAILBOX_RTR,
+};
+
 static const struct flexcan_devtype_data fsl_vf610_devtype_data = {
 	.quirks = FLEXCAN_QUIRK_DISABLE_RXFG | FLEXCAN_QUIRK_ENABLE_EACEN_RRS |
 		FLEXCAN_QUIRK_DISABLE_MECR | FLEXCAN_QUIRK_USE_RX_MAILBOX |
@@ -532,9 +541,14 @@ static inline int flexcan_enter_stop_mode(struct flexcan_priv *priv)
 		ret = flexcan_stop_mode_enable_scfw(priv, true);
 		if (ret < 0)
 			return ret;
-	} else {
+	} else if (priv->devtype_data.quirks & FLEXCAN_QUIRK_SETUP_STOP_MODE_GPR) {
 		regmap_update_bits(priv->stm.gpr, priv->stm.req_gpr,
 				   1 << priv->stm.req_bit, 1 << priv->stm.req_bit);
+	} else if (priv->devtype_data.quirks & FLEXCAN_QUIRK_AUTO_STOP_MODE) {
+		/* For the auto stop mode, software do nothing, hardware will cover
+		 * all the operation automatically after system go into low power mode.
+		 */
+		return 0;
 	}
 
 	return flexcan_low_power_enter_ack(priv);
@@ -551,7 +565,7 @@ static inline int flexcan_exit_stop_mode(struct flexcan_priv *priv)
 		ret = flexcan_stop_mode_enable_scfw(priv, false);
 		if (ret < 0)
 			return ret;
-	} else {
+	} else if (priv->devtype_data.quirks & FLEXCAN_QUIRK_SETUP_STOP_MODE_GPR) {
 		regmap_update_bits(priv->stm.gpr, priv->stm.req_gpr,
 				   1 << priv->stm.req_bit, 0);
 	}
@@ -560,6 +574,12 @@ static inline int flexcan_exit_stop_mode(struct flexcan_priv *priv)
 	reg_mcr &= ~FLEXCAN_MCR_SLF_WAK;
 	priv->write(reg_mcr, &regs->mcr);
 
+	/* For the auto stop mode, hardware will exist stop mode
+	 * automatically after system go out of low power mode.
+	 */
+	if (priv->devtype_data.quirks & FLEXCAN_QUIRK_AUTO_STOP_MODE)
+		return 0;
+
 	return flexcan_low_power_exit_ack(priv);
 }
 
@@ -1974,6 +1994,8 @@ static int flexcan_setup_stop_mode(struct platform_device *pdev)
 		ret = flexcan_setup_stop_mode_scfw(pdev);
 	else if (priv->devtype_data.quirks & FLEXCAN_QUIRK_SETUP_STOP_MODE_GPR)
 		ret = flexcan_setup_stop_mode_gpr(pdev);
+	else if (priv->devtype_data.quirks & FLEXCAN_QUIRK_AUTO_STOP_MODE)
+		ret = 0;
 	else
 		/* return 0 directly if doesn't support stop mode feature */
 		return 0;
@@ -1992,6 +2014,7 @@ static int flexcan_setup_stop_mode(struct platform_device *pdev)
 static const struct of_device_id flexcan_of_match[] = {
 	{ .compatible = "fsl,imx8qm-flexcan", .data = &fsl_imx8qm_devtype_data, },
 	{ .compatible = "fsl,imx8mp-flexcan", .data = &fsl_imx8mp_devtype_data, },
+	{ .compatible = "fsl,imx93-flexcan", .data = &fsl_imx93_devtype_data, },
 	{ .compatible = "fsl,imx6q-flexcan", .data = &fsl_imx6q_devtype_data, },
 	{ .compatible = "fsl,imx28-flexcan", .data = &fsl_imx28_devtype_data, },
 	{ .compatible = "fsl,imx53-flexcan", .data = &fsl_imx25_devtype_data, },
@@ -2299,8 +2322,16 @@ static int __maybe_unused flexcan_noirq_suspend(struct device *device)
 	if (netif_running(dev)) {
 		int err;
 
-		if (device_may_wakeup(device))
+		if (device_may_wakeup(device)) {
 			flexcan_enable_wakeup_irq(priv, true);
+			/* For auto stop mode, need to keep the clock on before
+			 * system go into low power mode. After system go into
+			 * low power mode, hardware will config the flexcan into
+			 * stop mode, and gate off the clock automatically.
+			 */
+			if (priv->devtype_data.quirks & FLEXCAN_QUIRK_AUTO_STOP_MODE)
+				return 0;
+		}
 
 		err = pm_runtime_force_suspend(device);
 		if (err)
diff --git a/drivers/net/can/flexcan/flexcan.h b/drivers/net/can/flexcan/flexcan.h
index 025c3417031f..91402977780b 100644
--- a/drivers/net/can/flexcan/flexcan.h
+++ b/drivers/net/can/flexcan/flexcan.h
@@ -68,6 +68,8 @@
 #define FLEXCAN_QUIRK_SUPPORT_RX_MAILBOX_RTR BIT(15)
 /* Device supports RX via FIFO */
 #define FLEXCAN_QUIRK_SUPPORT_RX_FIFO BIT(16)
+/* auto enter stop mode to support wakeup */
+#define FLEXCAN_QUIRK_AUTO_STOP_MODE BIT(17)
 
 struct flexcan_devtype_data {
 	u32 quirks;		/* quirks needed for different IP cores */
-- 
2.35.1



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

* [PATCH net-next 12/39] can: etas_es58x: add devlink support
  2022-12-12 11:30 [PATCH net-next 0/39] pull-request: can-next 2022-12-12 Marc Kleine-Budde
                   ` (10 preceding siblings ...)
  2022-12-12 11:30 ` [PATCH net-next 11/39] can: flexcan: add auto stop mode for IMX93 to support wakeup Marc Kleine-Budde
@ 2022-12-12 11:30 ` Marc Kleine-Budde
  2022-12-12 11:30 ` [PATCH net-next 13/39] dt-bindings: can: fsl,flexcan: add imx93 compatible Marc Kleine-Budde
                   ` (26 subsequent siblings)
  38 siblings, 0 replies; 43+ messages in thread
From: Marc Kleine-Budde @ 2022-12-12 11:30 UTC (permalink / raw)
  To: netdev; +Cc: davem, kuba, linux-can, kernel, Vincent Mailhol, Marc Kleine-Budde

From: Vincent Mailhol <mailhol.vincent@wanadoo.fr>

Add basic support for devlink at the device level. The callbacks of
struct devlink_ops will be implemented next.

Signed-off-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr>
Link: https://lore.kernel.org/all/20221130174658.29282-2-mailhol.vincent@wanadoo.fr
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 drivers/net/can/usb/Kconfig                    |  1 +
 drivers/net/can/usb/etas_es58x/Makefile        |  2 +-
 drivers/net/can/usb/etas_es58x/es58x_core.c    | 13 ++++++++++---
 drivers/net/can/usb/etas_es58x/es58x_core.h    |  6 ++++++
 drivers/net/can/usb/etas_es58x/es58x_devlink.c | 13 +++++++++++++
 5 files changed, 31 insertions(+), 4 deletions(-)
 create mode 100644 drivers/net/can/usb/etas_es58x/es58x_devlink.c

diff --git a/drivers/net/can/usb/Kconfig b/drivers/net/can/usb/Kconfig
index 8c6fea661530..445504ababce 100644
--- a/drivers/net/can/usb/Kconfig
+++ b/drivers/net/can/usb/Kconfig
@@ -30,6 +30,7 @@ config CAN_ESD_USB
 config CAN_ETAS_ES58X
 	tristate "ETAS ES58X CAN/USB interfaces"
 	select CRC16
+	select NET_DEVLINK
 	help
 	  This driver supports the ES581.4, ES582.1 and ES584.1 interfaces
 	  from ETAS GmbH (https://www.etas.com/en/products/es58x.php).
diff --git a/drivers/net/can/usb/etas_es58x/Makefile b/drivers/net/can/usb/etas_es58x/Makefile
index a129b4aa0215..d6667ebe259f 100644
--- a/drivers/net/can/usb/etas_es58x/Makefile
+++ b/drivers/net/can/usb/etas_es58x/Makefile
@@ -1,3 +1,3 @@
 # SPDX-License-Identifier: GPL-2.0
 obj-$(CONFIG_CAN_ETAS_ES58X) += etas_es58x.o
-etas_es58x-y = es58x_core.o es581_4.o es58x_fd.o
+etas_es58x-y = es58x_core.o es58x_devlink.o es581_4.o es58x_fd.o
diff --git a/drivers/net/can/usb/etas_es58x/es58x_core.c b/drivers/net/can/usb/etas_es58x/es58x_core.c
index 5aba16849603..aeffe61faed8 100644
--- a/drivers/net/can/usb/etas_es58x/es58x_core.c
+++ b/drivers/net/can/usb/etas_es58x/es58x_core.c
@@ -16,6 +16,7 @@
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/usb.h>
+#include <net/devlink.h>
 
 #include "es58x_core.h"
 
@@ -2177,6 +2178,7 @@ static struct es58x_device *es58x_init_es58x_dev(struct usb_interface *intf,
 {
 	struct device *dev = &intf->dev;
 	struct es58x_device *es58x_dev;
+	struct devlink *devlink;
 	const struct es58x_parameters *param;
 	const struct es58x_operators *ops;
 	struct usb_device *udev = interface_to_usbdev(intf);
@@ -2199,11 +2201,12 @@ static struct es58x_device *es58x_init_es58x_dev(struct usb_interface *intf,
 		ops = &es581_4_ops;
 	}
 
-	es58x_dev = devm_kzalloc(dev, es58x_sizeof_es58x_device(param),
-				 GFP_KERNEL);
-	if (!es58x_dev)
+	devlink = devlink_alloc(&es58x_dl_ops, es58x_sizeof_es58x_device(param),
+				dev);
+	if (!devlink)
 		return ERR_PTR(-ENOMEM);
 
+	es58x_dev = devlink_priv(devlink);
 	es58x_dev->param = param;
 	es58x_dev->ops = ops;
 	es58x_dev->dev = dev;
@@ -2250,6 +2253,8 @@ static int es58x_probe(struct usb_interface *intf,
 	if (ret)
 		return ret;
 
+	devlink_register(priv_to_devlink(es58x_dev));
+
 	for (ch_idx = 0; ch_idx < es58x_dev->num_can_ch; ch_idx++) {
 		ret = es58x_init_netdev(es58x_dev, ch_idx);
 		if (ret) {
@@ -2275,8 +2280,10 @@ static void es58x_disconnect(struct usb_interface *intf)
 	dev_info(&intf->dev, "Disconnecting %s %s\n",
 		 es58x_dev->udev->manufacturer, es58x_dev->udev->product);
 
+	devlink_unregister(priv_to_devlink(es58x_dev));
 	es58x_free_netdevs(es58x_dev);
 	es58x_free_urbs(es58x_dev);
+	devlink_free(priv_to_devlink(es58x_dev));
 	usb_set_intfdata(intf, NULL);
 }
 
diff --git a/drivers/net/can/usb/etas_es58x/es58x_core.h b/drivers/net/can/usb/etas_es58x/es58x_core.h
index 4a082fd69e6f..bf24375580e5 100644
--- a/drivers/net/can/usb/etas_es58x/es58x_core.h
+++ b/drivers/net/can/usb/etas_es58x/es58x_core.h
@@ -674,6 +674,7 @@ static inline enum es58x_flag es58x_get_flags(const struct sk_buff *skb)
 	return es58x_flags;
 }
 
+/* es58x_core.c. */
 int es58x_can_get_echo_skb(struct net_device *netdev, u32 packet_idx,
 			   u64 *tstamps, unsigned int pkts);
 int es58x_tx_ack_msg(struct net_device *netdev, u16 tx_free_entries,
@@ -691,9 +692,14 @@ int es58x_rx_cmd_ret_u32(struct net_device *netdev,
 int es58x_send_msg(struct es58x_device *es58x_dev, u8 cmd_type, u8 cmd_id,
 		   const void *msg, u16 cmd_len, int channel_idx);
 
+/* es58x_devlink.c. */
+extern const struct devlink_ops es58x_dl_ops;
+
+/* es581_4.c. */
 extern const struct es58x_parameters es581_4_param;
 extern const struct es58x_operators es581_4_ops;
 
+/* es58x_fd.c. */
 extern const struct es58x_parameters es58x_fd_param;
 extern const struct es58x_operators es58x_fd_ops;
 
diff --git a/drivers/net/can/usb/etas_es58x/es58x_devlink.c b/drivers/net/can/usb/etas_es58x/es58x_devlink.c
new file mode 100644
index 000000000000..af6ca7ada23f
--- /dev/null
+++ b/drivers/net/can/usb/etas_es58x/es58x_devlink.c
@@ -0,0 +1,13 @@
+// SPDX-License-Identifier: GPL-2.0
+
+/* Driver for ETAS GmbH ES58X USB CAN(-FD) Bus Interfaces.
+ *
+ * File es58x_devlink.c: report the product information using devlink.
+ *
+ * Copyright (c) 2022 Vincent Mailhol <mailhol.vincent@wanadoo.fr>
+ */
+
+#include <net/devlink.h>
+
+const struct devlink_ops es58x_dl_ops = {
+};
-- 
2.35.1



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

* [PATCH net-next 13/39] dt-bindings: can: fsl,flexcan: add imx93 compatible
  2022-12-12 11:30 [PATCH net-next 0/39] pull-request: can-next 2022-12-12 Marc Kleine-Budde
                   ` (11 preceding siblings ...)
  2022-12-12 11:30 ` [PATCH net-next 12/39] can: etas_es58x: add devlink support Marc Kleine-Budde
@ 2022-12-12 11:30 ` Marc Kleine-Budde
  2022-12-12 11:30 ` [PATCH net-next 14/39] can: etas_es58x: add devlink port support Marc Kleine-Budde
                   ` (25 subsequent siblings)
  38 siblings, 0 replies; 43+ messages in thread
From: Marc Kleine-Budde @ 2022-12-12 11:30 UTC (permalink / raw)
  To: netdev
  Cc: davem, kuba, linux-can, kernel, Haibo Chen, Krzysztof Kozlowski,
	Marc Kleine-Budde

From: Haibo Chen <haibo.chen@nxp.com>

Add a new compatible string for imx93.

Signed-off-by: Haibo Chen <haibo.chen@nxp.com>
Acked-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Link: https://lore.kernel.org/all/1669116752-4260-2-git-send-email-haibo.chen@nxp.com
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 Documentation/devicetree/bindings/net/can/fsl,flexcan.yaml | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Documentation/devicetree/bindings/net/can/fsl,flexcan.yaml b/Documentation/devicetree/bindings/net/can/fsl,flexcan.yaml
index e52db841bb8c..6e59bd2a6094 100644
--- a/Documentation/devicetree/bindings/net/can/fsl,flexcan.yaml
+++ b/Documentation/devicetree/bindings/net/can/fsl,flexcan.yaml
@@ -17,6 +17,7 @@ properties:
   compatible:
     oneOf:
       - enum:
+          - fsl,imx93-flexcan
           - fsl,imx8qm-flexcan
           - fsl,imx8mp-flexcan
           - fsl,imx6q-flexcan
-- 
2.35.1



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

* [PATCH net-next 14/39] can: etas_es58x: add devlink port support
  2022-12-12 11:30 [PATCH net-next 0/39] pull-request: can-next 2022-12-12 Marc Kleine-Budde
                   ` (12 preceding siblings ...)
  2022-12-12 11:30 ` [PATCH net-next 13/39] dt-bindings: can: fsl,flexcan: add imx93 compatible Marc Kleine-Budde
@ 2022-12-12 11:30 ` Marc Kleine-Budde
  2022-12-12 11:30 ` [PATCH net-next 15/39] dt-bindings: can: renesas,rcar-canfd: Document RZ/Five SoC Marc Kleine-Budde
                   ` (24 subsequent siblings)
  38 siblings, 0 replies; 43+ messages in thread
From: Marc Kleine-Budde @ 2022-12-12 11:30 UTC (permalink / raw)
  To: netdev; +Cc: davem, kuba, linux-can, kernel, Vincent Mailhol, Marc Kleine-Budde

From: Vincent Mailhol <mailhol.vincent@wanadoo.fr>

Add support for devlink port which extends the devlink support to the
network interface level. For now, the etas_es58x driver will only rely
on the default features that devlink port has to offer and not
implement additional feature ones.

Signed-off-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr>
Link: https://lore.kernel.org/all/20221130174658.29282-3-mailhol.vincent@wanadoo.fr
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 drivers/net/can/usb/etas_es58x/es58x_core.c | 34 ++++++++++++++++-----
 drivers/net/can/usb/etas_es58x/es58x_core.h |  3 ++
 2 files changed, 29 insertions(+), 8 deletions(-)

diff --git a/drivers/net/can/usb/etas_es58x/es58x_core.c b/drivers/net/can/usb/etas_es58x/es58x_core.c
index aeffe61faed8..de884de9fe57 100644
--- a/drivers/net/can/usb/etas_es58x/es58x_core.c
+++ b/drivers/net/can/usb/etas_es58x/es58x_core.c
@@ -2039,10 +2039,16 @@ static int es58x_set_mode(struct net_device *netdev, enum can_mode mode)
  * @es58x_dev: ES58X device.
  * @priv: ES58X private parameters related to the network device.
  * @channel_idx: Index of the network device.
+ *
+ * Return: zero on success, errno if devlink port could not be
+ *	properly registered.
  */
-static void es58x_init_priv(struct es58x_device *es58x_dev,
-			    struct es58x_priv *priv, int channel_idx)
+static int es58x_init_priv(struct es58x_device *es58x_dev,
+			   struct es58x_priv *priv, int channel_idx)
 {
+	struct devlink_port_attrs attrs = {
+		.flavour = DEVLINK_PORT_FLAVOUR_PHYSICAL,
+	};
 	const struct es58x_parameters *param = es58x_dev->param;
 	struct can_priv *can = &priv->can;
 
@@ -2061,6 +2067,10 @@ static void es58x_init_priv(struct es58x_device *es58x_dev,
 	can->state = CAN_STATE_STOPPED;
 	can->ctrlmode_supported = param->ctrlmode_supported;
 	can->do_set_mode = es58x_set_mode;
+
+	devlink_port_attrs_set(&priv->devlink_port, &attrs);
+	return devlink_port_register(priv_to_devlink(es58x_dev),
+				     &priv->devlink_port, channel_idx);
 }
 
 /**
@@ -2084,7 +2094,10 @@ static int es58x_init_netdev(struct es58x_device *es58x_dev, int channel_idx)
 	}
 	SET_NETDEV_DEV(netdev, dev);
 	es58x_dev->netdev[channel_idx] = netdev;
-	es58x_init_priv(es58x_dev, es58x_priv(netdev), channel_idx);
+	ret = es58x_init_priv(es58x_dev, es58x_priv(netdev), channel_idx);
+	if (ret)
+		goto free_candev;
+	SET_NETDEV_DEVLINK_PORT(netdev, &es58x_priv(netdev)->devlink_port);
 
 	netdev->netdev_ops = &es58x_netdev_ops;
 	netdev->ethtool_ops = &es58x_ethtool_ops;
@@ -2092,16 +2105,20 @@ static int es58x_init_netdev(struct es58x_device *es58x_dev, int channel_idx)
 	netdev->dev_port = channel_idx;
 
 	ret = register_candev(netdev);
-	if (ret) {
-		es58x_dev->netdev[channel_idx] = NULL;
-		free_candev(netdev);
-		return ret;
-	}
+	if (ret)
+		goto devlink_port_unregister;
 
 	netdev_queue_set_dql_min_limit(netdev_get_tx_queue(netdev, 0),
 				       es58x_dev->param->dql_min_limit);
 
 	return ret;
+
+ devlink_port_unregister:
+	devlink_port_unregister(&es58x_priv(netdev)->devlink_port);
+ free_candev:
+	es58x_dev->netdev[channel_idx] = NULL;
+	free_candev(netdev);
+	return ret;
 }
 
 /**
@@ -2118,6 +2135,7 @@ static void es58x_free_netdevs(struct es58x_device *es58x_dev)
 		if (!netdev)
 			continue;
 		unregister_candev(netdev);
+		devlink_port_unregister(&es58x_priv(netdev)->devlink_port);
 		es58x_dev->netdev[i] = NULL;
 		free_candev(netdev);
 	}
diff --git a/drivers/net/can/usb/etas_es58x/es58x_core.h b/drivers/net/can/usb/etas_es58x/es58x_core.h
index bf24375580e5..a76789119229 100644
--- a/drivers/net/can/usb/etas_es58x/es58x_core.h
+++ b/drivers/net/can/usb/etas_es58x/es58x_core.h
@@ -17,6 +17,7 @@
 #include <linux/netdevice.h>
 #include <linux/types.h>
 #include <linux/usb.h>
+#include <net/devlink.h>
 
 #include "es581_4.h"
 #include "es58x_fd.h"
@@ -230,6 +231,7 @@ union es58x_urb_cmd {
  * @can: struct can_priv must be the first member (Socket CAN relies
  *	on the fact that function netdev_priv() returns a pointer to
  *	a struct can_priv).
+ * @devlink_port: devlink instance for the network interface.
  * @es58x_dev: pointer to the corresponding ES58X device.
  * @tx_urb: Used as a buffer to concatenate the TX messages and to do
  *	a bulk send. Please refer to es58x_start_xmit() for more
@@ -255,6 +257,7 @@ union es58x_urb_cmd {
  */
 struct es58x_priv {
 	struct can_priv can;
+	struct devlink_port devlink_port;
 	struct es58x_device *es58x_dev;
 	struct urb *tx_urb;
 
-- 
2.35.1



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

* [PATCH net-next 15/39] dt-bindings: can: renesas,rcar-canfd: Document RZ/Five SoC
  2022-12-12 11:30 [PATCH net-next 0/39] pull-request: can-next 2022-12-12 Marc Kleine-Budde
                   ` (13 preceding siblings ...)
  2022-12-12 11:30 ` [PATCH net-next 14/39] can: etas_es58x: add devlink port support Marc Kleine-Budde
@ 2022-12-12 11:30 ` Marc Kleine-Budde
  2022-12-12 11:30 ` [PATCH net-next 16/39] USB: core: export usb_cache_string() Marc Kleine-Budde
                   ` (23 subsequent siblings)
  38 siblings, 0 replies; 43+ messages in thread
From: Marc Kleine-Budde @ 2022-12-12 11:30 UTC (permalink / raw)
  To: netdev
  Cc: davem, kuba, linux-can, kernel, Lad Prabhakar, Rob Herring,
	Geert Uytterhoeven, Marc Kleine-Budde

From: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>

The CANFD block on the RZ/Five SoC is identical to one found on the
RZ/G2UL SoC. "renesas,r9a07g043-canfd" compatible string will be used
on the RZ/Five SoC so to make this clear, update the comment to include
RZ/Five SoC.

No driver changes are required as generic compatible string
"renesas,rzg2l-canfd" will be used as a fallback on RZ/Five SoC.

Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Acked-by: Rob Herring <robh@kernel.org>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Link: https://lore.kernel.org/all/20221115123811.1182922-1-prabhakar.mahadev-lad.rj@bp.renesas.com
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 .../devicetree/bindings/net/can/renesas,rcar-canfd.yaml         | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/net/can/renesas,rcar-canfd.yaml b/Documentation/devicetree/bindings/net/can/renesas,rcar-canfd.yaml
index 6f71fc96bc4e..8347053a96dc 100644
--- a/Documentation/devicetree/bindings/net/can/renesas,rcar-canfd.yaml
+++ b/Documentation/devicetree/bindings/net/can/renesas,rcar-canfd.yaml
@@ -33,7 +33,7 @@ properties:
 
       - items:
           - enum:
-              - renesas,r9a07g043-canfd    # RZ/G2UL
+              - renesas,r9a07g043-canfd    # RZ/G2UL and RZ/Five
               - renesas,r9a07g044-canfd    # RZ/G2{L,LC}
               - renesas,r9a07g054-canfd    # RZ/V2L
           - const: renesas,rzg2l-canfd     # RZ/G2L family
-- 
2.35.1



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

* [PATCH net-next 16/39] USB: core: export usb_cache_string()
  2022-12-12 11:30 [PATCH net-next 0/39] pull-request: can-next 2022-12-12 Marc Kleine-Budde
                   ` (14 preceding siblings ...)
  2022-12-12 11:30 ` [PATCH net-next 15/39] dt-bindings: can: renesas,rcar-canfd: Document RZ/Five SoC Marc Kleine-Budde
@ 2022-12-12 11:30 ` Marc Kleine-Budde
  2022-12-12 11:30 ` [PATCH net-next 17/39] can: c_can: use devm_platform_get_and_ioremap_resource() Marc Kleine-Budde
                   ` (22 subsequent siblings)
  38 siblings, 0 replies; 43+ messages in thread
From: Marc Kleine-Budde @ 2022-12-12 11:30 UTC (permalink / raw)
  To: netdev
  Cc: davem, kuba, linux-can, kernel, Vincent Mailhol,
	Greg Kroah-Hartman, Marc Kleine-Budde

From: Vincent Mailhol <mailhol.vincent@wanadoo.fr>

usb_cache_string() can also be useful for the drivers so export it.

Signed-off-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr>
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Link: https://lore.kernel.org/all/20221130174658.29282-4-mailhol.vincent@wanadoo.fr
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 drivers/usb/core/message.c | 1 +
 drivers/usb/core/usb.h     | 1 -
 include/linux/usb.h        | 1 +
 3 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
index 4d59d927ae3e..127fac1af676 100644
--- a/drivers/usb/core/message.c
+++ b/drivers/usb/core/message.c
@@ -1037,6 +1037,7 @@ char *usb_cache_string(struct usb_device *udev, int index)
 	}
 	return smallbuf;
 }
+EXPORT_SYMBOL_GPL(usb_cache_string);
 
 /*
  * usb_get_device_descriptor - (re)reads the device descriptor (usbcore)
diff --git a/drivers/usb/core/usb.h b/drivers/usb/core/usb.h
index 82538daac8b8..0eac7d4285d1 100644
--- a/drivers/usb/core/usb.h
+++ b/drivers/usb/core/usb.h
@@ -47,7 +47,6 @@ extern int usb_get_device_descriptor(struct usb_device *dev,
 extern int usb_set_isoch_delay(struct usb_device *dev);
 extern int usb_get_bos_descriptor(struct usb_device *dev);
 extern void usb_release_bos_descriptor(struct usb_device *dev);
-extern char *usb_cache_string(struct usb_device *udev, int index);
 extern int usb_set_configuration(struct usb_device *dev, int configuration);
 extern int usb_choose_configuration(struct usb_device *udev);
 extern int usb_generic_driver_probe(struct usb_device *udev);
diff --git a/include/linux/usb.h b/include/linux/usb.h
index 9ff1ad4dfad1..d2d2f41052c0 100644
--- a/include/linux/usb.h
+++ b/include/linux/usb.h
@@ -1829,6 +1829,7 @@ static inline int usb_get_ptm_status(struct usb_device *dev, void *data)
 
 extern int usb_string(struct usb_device *dev, int index,
 	char *buf, size_t size);
+extern char *usb_cache_string(struct usb_device *udev, int index);
 
 /* wrappers that also update important state inside usbcore */
 extern int usb_clear_halt(struct usb_device *dev, int pipe);
-- 
2.35.1



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

* [PATCH net-next 17/39] can: c_can: use devm_platform_get_and_ioremap_resource()
  2022-12-12 11:30 [PATCH net-next 0/39] pull-request: can-next 2022-12-12 Marc Kleine-Budde
                   ` (15 preceding siblings ...)
  2022-12-12 11:30 ` [PATCH net-next 16/39] USB: core: export usb_cache_string() Marc Kleine-Budde
@ 2022-12-12 11:30 ` Marc Kleine-Budde
  2022-12-12 11:30 ` [PATCH net-next 18/39] net: devlink: add DEVLINK_INFO_VERSION_GENERIC_FW_BOOTLOADER Marc Kleine-Budde
                   ` (21 subsequent siblings)
  38 siblings, 0 replies; 43+ messages in thread
From: Marc Kleine-Budde @ 2022-12-12 11:30 UTC (permalink / raw)
  To: netdev
  Cc: davem, kuba, linux-can, kernel, Minghao Chi, Zeal Robot,
	Marc Kleine-Budde

From: Minghao Chi <chi.minghao@zte.com.cn>

Convert platform_get_resource(), devm_ioremap_resource() to a single
call to devm_platform_get_and_ioremap_resource(), as this is exactly
what this function does.

Reported-by: Zeal Robot <zealci@zte.com.cn>
Signed-off-by: Minghao Chi <chi.minghao@zte.com.cn>
Link: https://lore.kernel.org/all/202211111443005202576@zte.com.cn
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 drivers/net/can/c_can/c_can_platform.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/can/c_can/c_can_platform.c b/drivers/net/can/c_can/c_can_platform.c
index 86e95e9d6533..03ccb7cfacaf 100644
--- a/drivers/net/can/c_can/c_can_platform.c
+++ b/drivers/net/can/c_can/c_can_platform.c
@@ -290,8 +290,7 @@ static int c_can_plat_probe(struct platform_device *pdev)
 		goto exit;
 	}
 
-	mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	addr = devm_ioremap_resource(&pdev->dev, mem);
+	addr = devm_platform_get_and_ioremap_resource(pdev, 0, &mem);
 	if (IS_ERR(addr)) {
 		ret =  PTR_ERR(addr);
 		goto exit;
-- 
2.35.1



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

* [PATCH net-next 18/39] net: devlink: add DEVLINK_INFO_VERSION_GENERIC_FW_BOOTLOADER
  2022-12-12 11:30 [PATCH net-next 0/39] pull-request: can-next 2022-12-12 Marc Kleine-Budde
                   ` (16 preceding siblings ...)
  2022-12-12 11:30 ` [PATCH net-next 17/39] can: c_can: use devm_platform_get_and_ioremap_resource() Marc Kleine-Budde
@ 2022-12-12 11:30 ` Marc Kleine-Budde
  2022-12-12 11:30 ` [PATCH net-next 19/39] can: etas_es58x: export product information through devlink_ops::info_get() Marc Kleine-Budde
                   ` (20 subsequent siblings)
  38 siblings, 0 replies; 43+ messages in thread
From: Marc Kleine-Budde @ 2022-12-12 11:30 UTC (permalink / raw)
  To: netdev; +Cc: davem, kuba, linux-can, kernel, Vincent Mailhol, Marc Kleine-Budde

From: Vincent Mailhol <mailhol.vincent@wanadoo.fr>

As discussed in [1], abbreviating the bootloader to "bl" might not be
well understood. Instead, a bootloader technically being a firmware,
name it "fw.bootloader".

Add a new macro to devlink.h to formalize this new info attribute name
and update the documentation.

[1] https://lore.kernel.org/netdev/20221128142723.2f826d20@kernel.org/

Suggested-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr>
Link: https://lore.kernel.org/all/20221130174658.29282-5-mailhol.vincent@wanadoo.fr
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 Documentation/networking/devlink/devlink-info.rst | 5 +++++
 include/net/devlink.h                             | 2 ++
 2 files changed, 7 insertions(+)

diff --git a/Documentation/networking/devlink/devlink-info.rst b/Documentation/networking/devlink/devlink-info.rst
index 7572bf6de5c1..1242b0e6826b 100644
--- a/Documentation/networking/devlink/devlink-info.rst
+++ b/Documentation/networking/devlink/devlink-info.rst
@@ -198,6 +198,11 @@ fw.bundle_id
 
 Unique identifier of the entire firmware bundle.
 
+fw.bootloader
+-------------
+
+Version of the bootloader.
+
 Future work
 ===========
 
diff --git a/include/net/devlink.h b/include/net/devlink.h
index 0f376a28b9c4..6a2e4f21779f 100644
--- a/include/net/devlink.h
+++ b/include/net/devlink.h
@@ -621,6 +621,8 @@ enum devlink_param_generic_id {
 #define DEVLINK_INFO_VERSION_GENERIC_FW_ROCE	"fw.roce"
 /* Firmware bundle identifier */
 #define DEVLINK_INFO_VERSION_GENERIC_FW_BUNDLE_ID	"fw.bundle_id"
+/* Bootloader */
+#define DEVLINK_INFO_VERSION_GENERIC_FW_BOOTLOADER	"fw.bootloader"
 
 /**
  * struct devlink_flash_update_params - Flash Update parameters
-- 
2.35.1



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

* [PATCH net-next 19/39] can: etas_es58x: export product information through devlink_ops::info_get()
  2022-12-12 11:30 [PATCH net-next 0/39] pull-request: can-next 2022-12-12 Marc Kleine-Budde
                   ` (17 preceding siblings ...)
  2022-12-12 11:30 ` [PATCH net-next 18/39] net: devlink: add DEVLINK_INFO_VERSION_GENERIC_FW_BOOTLOADER Marc Kleine-Budde
@ 2022-12-12 11:30 ` Marc Kleine-Budde
  2022-12-12 11:30 ` [PATCH net-next 20/39] can: etas_es58x: remove es58x_get_product_info() Marc Kleine-Budde
                   ` (19 subsequent siblings)
  38 siblings, 0 replies; 43+ messages in thread
From: Marc Kleine-Budde @ 2022-12-12 11:30 UTC (permalink / raw)
  To: netdev
  Cc: davem, kuba, linux-can, kernel, Vincent Mailhol, Andrew Lunn,
	Marc Kleine-Budde

From: Vincent Mailhol <mailhol.vincent@wanadoo.fr>

ES58x devices report below product information through a custom usb
string:

  * the firmware version
  * the bootloader version
  * the hardware revision

Parse this string, store the results in struct es58x_dev, export:

  * the firmware version through devlink's "fw" name
  * the bootloader version through devlink's "fw.bootloader" name
  * the hardware revisionthrough devlink's "board.rev" name

Those devlink entries are not critical to use the device, if parsing
fails, print an informative log message and continue to probe the
device.

In addition to that, use usb_device::serial to report the device
serial number.

Signed-off-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Link: https://lore.kernel.org/all/20221130174658.29282-6-mailhol.vincent@wanadoo.fr
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 drivers/net/can/usb/etas_es58x/es58x_core.c   |   1 +
 drivers/net/can/usb/etas_es58x/es58x_core.h   |  41 ++++
 .../net/can/usb/etas_es58x/es58x_devlink.c    | 222 ++++++++++++++++++
 3 files changed, 264 insertions(+)

diff --git a/drivers/net/can/usb/etas_es58x/es58x_core.c b/drivers/net/can/usb/etas_es58x/es58x_core.c
index de884de9fe57..4d6d5a4ac06e 100644
--- a/drivers/net/can/usb/etas_es58x/es58x_core.c
+++ b/drivers/net/can/usb/etas_es58x/es58x_core.c
@@ -2271,6 +2271,7 @@ static int es58x_probe(struct usb_interface *intf,
 	if (ret)
 		return ret;
 
+	es58x_parse_product_info(es58x_dev);
 	devlink_register(priv_to_devlink(es58x_dev));
 
 	for (ch_idx = 0; ch_idx < es58x_dev->num_can_ch; ch_idx++) {
diff --git a/drivers/net/can/usb/etas_es58x/es58x_core.h b/drivers/net/can/usb/etas_es58x/es58x_core.h
index a76789119229..c1ba1a4e8857 100644
--- a/drivers/net/can/usb/etas_es58x/es58x_core.h
+++ b/drivers/net/can/usb/etas_es58x/es58x_core.h
@@ -359,6 +359,39 @@ struct es58x_operators {
 	int (*get_timestamp)(struct es58x_device *es58x_dev);
 };
 
+/**
+ * struct es58x_sw_version - Version number of the firmware or the
+ *	bootloader.
+ * @major: Version major number, represented on two digits.
+ * @minor: Version minor number, represented on two digits.
+ * @revision: Version revision number, represented on two digits.
+ *
+ * The firmware and the bootloader share the same format: "xx.xx.xx"
+ * where 'x' is a digit. Both can be retrieved from the product
+ * information string.
+ */
+struct es58x_sw_version {
+	u8 major;
+	u8 minor;
+	u8 revision;
+};
+
+/**
+ * struct es58x_hw_revision - Hardware revision number.
+ * @letter: Revision letter.
+ * @major: Version major number, represented on three digits.
+ * @minor: Version minor number, represented on three digits.
+ *
+ * The hardware revision uses its own format: "axxx/xxx" where 'a' is
+ * a letter and 'x' a digit. It can be retrieved from the product
+ * information string.
+ */
+struct es58x_hw_revision {
+	char letter;
+	u16 major;
+	u16 minor;
+};
+
 /**
  * struct es58x_device - All information specific to an ES58X device.
  * @dev: Device information.
@@ -376,6 +409,9 @@ struct es58x_operators {
  *	queue wake/stop logic should prevent this URB from getting
  *	empty. Please refer to es58x_get_tx_urb() for more details.
  * @tx_urbs_idle_cnt: number of urbs in @tx_urbs_idle.
+ * @firmware_version: The firmware version number.
+ * @bootloader_version: The bootloader version number.
+ * @hardware_revision: The hardware revision number.
  * @ktime_req_ns: kernel timestamp when es58x_set_realtime_diff_ns()
  *	was called.
  * @realtime_diff_ns: difference in nanoseconds between the clocks of
@@ -411,6 +447,10 @@ struct es58x_device {
 	struct usb_anchor tx_urbs_idle;
 	atomic_t tx_urbs_idle_cnt;
 
+	struct es58x_sw_version firmware_version;
+	struct es58x_sw_version bootloader_version;
+	struct es58x_hw_revision hardware_revision;
+
 	u64 ktime_req_ns;
 	s64 realtime_diff_ns;
 
@@ -696,6 +736,7 @@ int es58x_send_msg(struct es58x_device *es58x_dev, u8 cmd_type, u8 cmd_id,
 		   const void *msg, u16 cmd_len, int channel_idx);
 
 /* es58x_devlink.c. */
+void es58x_parse_product_info(struct es58x_device *es58x_dev);
 extern const struct devlink_ops es58x_dl_ops;
 
 /* es581_4.c. */
diff --git a/drivers/net/can/usb/etas_es58x/es58x_devlink.c b/drivers/net/can/usb/etas_es58x/es58x_devlink.c
index af6ca7ada23f..9fba29e2f57c 100644
--- a/drivers/net/can/usb/etas_es58x/es58x_devlink.c
+++ b/drivers/net/can/usb/etas_es58x/es58x_devlink.c
@@ -7,7 +7,229 @@
  * Copyright (c) 2022 Vincent Mailhol <mailhol.vincent@wanadoo.fr>
  */
 
+#include <linux/ctype.h>
+#include <linux/device.h>
+#include <linux/usb.h>
 #include <net/devlink.h>
 
+#include "es58x_core.h"
+
+/* USB descriptor index containing the product information string. */
+#define ES58X_PROD_INFO_IDX 6
+
+/**
+ * es58x_parse_sw_version() - Extract boot loader or firmware version.
+ * @es58x_dev: ES58X device.
+ * @prod_info: USB custom string returned by the device.
+ * @prefix: Select which information should be parsed. Set it to "FW"
+ *	to parse the firmware version or to "BL" to parse the
+ *	bootloader version.
+ *
+ * The @prod_info string contains the firmware and the bootloader
+ * version number all prefixed by a magic string and concatenated with
+ * other numbers. Depending on the device, the firmware (bootloader)
+ * format is either "FW_Vxx.xx.xx" ("BL_Vxx.xx.xx") or "FW:xx.xx.xx"
+ * ("BL:xx.xx.xx") where 'x' represents a digit. @prod_info must
+ * contains the common part of those prefixes: "FW" or "BL".
+ *
+ * Parse @prod_info and store the version number in
+ * &es58x_dev.firmware_version or &es58x_dev.bootloader_version
+ * according to @prefix value.
+ *
+ * Return: zero on success, -EINVAL if @prefix contains an invalid
+ *	value and -EBADMSG if @prod_info could not be parsed.
+ */
+static int es58x_parse_sw_version(struct es58x_device *es58x_dev,
+				  const char *prod_info, const char *prefix)
+{
+	struct es58x_sw_version *version;
+	int major, minor, revision;
+
+	if (!strcmp(prefix, "FW"))
+		version = &es58x_dev->firmware_version;
+	else if (!strcmp(prefix, "BL"))
+		version = &es58x_dev->bootloader_version;
+	else
+		return -EINVAL;
+
+	/* Go to prefix */
+	prod_info = strstr(prod_info, prefix);
+	if (!prod_info)
+		return -EBADMSG;
+	/* Go to beginning of the version number */
+	while (!isdigit(*prod_info)) {
+		prod_info++;
+		if (!*prod_info)
+			return -EBADMSG;
+	}
+
+	if (sscanf(prod_info, "%2u.%2u.%2u", &major, &minor, &revision) != 3)
+		return -EBADMSG;
+
+	version->major = major;
+	version->minor = minor;
+	version->revision = revision;
+
+	return 0;
+}
+
+/**
+ * es58x_parse_hw_rev() - Extract hardware revision number.
+ * @es58x_dev: ES58X device.
+ * @prod_info: USB custom string returned by the device.
+ *
+ * @prod_info contains the hardware revision prefixed by a magic
+ * string and conquenated together with other numbers. Depending on
+ * the device, the hardware revision format is either
+ * "HW_VER:axxx/xxx" or "HR:axxx/xxx" where 'a' represents a letter
+ * and 'x' a digit.
+ *
+ * Parse @prod_info and store the hardware revision number in
+ * &es58x_dev.hardware_revision.
+ *
+ * Return: zero on success, -EBADMSG if @prod_info could not be
+ *	parsed.
+ */
+static int es58x_parse_hw_rev(struct es58x_device *es58x_dev,
+			      const char *prod_info)
+{
+	char letter;
+	int major, minor;
+
+	/* The only occurrence of 'H' is in the hardware revision prefix. */
+	prod_info = strchr(prod_info, 'H');
+	if (!prod_info)
+		return -EBADMSG;
+	/* Go to beginning of the hardware revision */
+	prod_info = strchr(prod_info, ':');
+	if (!prod_info)
+		return -EBADMSG;
+	prod_info++;
+
+	if (sscanf(prod_info, "%c%3u/%3u", &letter, &major, &minor) != 3)
+		return -EBADMSG;
+
+	es58x_dev->hardware_revision.letter = letter;
+	es58x_dev->hardware_revision.major = major;
+	es58x_dev->hardware_revision.minor = minor;
+
+	return 0;
+}
+
+/**
+ * es58x_parse_product_info() - Parse the ES58x product information
+ *	string.
+ * @es58x_dev: ES58X device.
+ *
+ * Retrieve the product information string and parse it to extract the
+ * firmware version, the bootloader version and the hardware
+ * revision.
+ *
+ * If the function fails, simply emit a log message and continue
+ * because product information is not critical for the driver to
+ * operate.
+ */
+void es58x_parse_product_info(struct es58x_device *es58x_dev)
+{
+	char *prod_info;
+
+	prod_info = usb_cache_string(es58x_dev->udev, ES58X_PROD_INFO_IDX);
+	if (!prod_info) {
+		dev_warn(es58x_dev->dev,
+			 "could not retrieve the product info string\n");
+		return;
+	}
+
+	if (es58x_parse_sw_version(es58x_dev, prod_info, "FW") ||
+	    es58x_parse_sw_version(es58x_dev, prod_info, "BL") ||
+	    es58x_parse_hw_rev(es58x_dev, prod_info))
+		dev_info(es58x_dev->dev,
+			 "could not parse product info: '%s'\n", prod_info);
+
+	kfree(prod_info);
+}
+
+/**
+ * es58x_sw_version_is_set() - Check if the version is a valid number.
+ * @sw_ver: Version number of either the firmware or the bootloader.
+ *
+ * If &es58x_sw_version.major, &es58x_sw_version.minor and
+ * &es58x_sw_version.revision are all zero, the product string could
+ * not be parsed and the version number is invalid.
+ */
+static inline bool es58x_sw_version_is_set(struct es58x_sw_version *sw_ver)
+{
+	return sw_ver->major || sw_ver->minor || sw_ver->revision;
+}
+
+/**
+ * es58x_hw_revision_is_set() - Check if the revision is a valid number.
+ * @hw_rev: Revision number of the hardware.
+ *
+ * If &es58x_hw_revision.letter is the null character, the product
+ * string could not be parsed and the hardware revision number is
+ * invalid.
+ */
+static inline bool es58x_hw_revision_is_set(struct es58x_hw_revision *hw_rev)
+{
+	return hw_rev->letter != '\0';
+}
+
+/**
+ * es58x_devlink_info_get() - Report the product information.
+ * @devlink: Devlink.
+ * @req: skb wrapper where to put requested information.
+ * @extack: Unused.
+ *
+ * Report the firmware version, the bootloader version, the hardware
+ * revision and the serial number through netlink.
+ *
+ * Return: zero on success, errno when any error occurs.
+ */
+static int es58x_devlink_info_get(struct devlink *devlink,
+				  struct devlink_info_req *req,
+				  struct netlink_ext_ack *extack)
+{
+	struct es58x_device *es58x_dev = devlink_priv(devlink);
+	struct es58x_sw_version *fw_ver = &es58x_dev->firmware_version;
+	struct es58x_sw_version *bl_ver = &es58x_dev->bootloader_version;
+	struct es58x_hw_revision *hw_rev = &es58x_dev->hardware_revision;
+	char buf[max(sizeof("xx.xx.xx"), sizeof("axxx/xxx"))];
+	int ret = 0;
+
+	if (es58x_sw_version_is_set(fw_ver)) {
+		snprintf(buf, sizeof(buf), "%02u.%02u.%02u",
+			 fw_ver->major, fw_ver->minor, fw_ver->revision);
+		ret = devlink_info_version_running_put(req,
+						       DEVLINK_INFO_VERSION_GENERIC_FW,
+						       buf);
+		if (ret)
+			return ret;
+	}
+
+	if (es58x_sw_version_is_set(bl_ver)) {
+		snprintf(buf, sizeof(buf), "%02u.%02u.%02u",
+			 bl_ver->major, bl_ver->minor, bl_ver->revision);
+		ret = devlink_info_version_running_put(req,
+						       DEVLINK_INFO_VERSION_GENERIC_FW_BOOTLOADER,
+						       buf);
+		if (ret)
+			return ret;
+	}
+
+	if (es58x_hw_revision_is_set(hw_rev)) {
+		snprintf(buf, sizeof(buf), "%c%03u/%03u",
+			 hw_rev->letter, hw_rev->major, hw_rev->minor);
+		ret = devlink_info_version_fixed_put(req,
+						     DEVLINK_INFO_VERSION_GENERIC_BOARD_REV,
+						     buf);
+		if (ret)
+			return ret;
+	}
+
+	return devlink_info_serial_number_put(req, es58x_dev->udev->serial);
+}
+
 const struct devlink_ops es58x_dl_ops = {
+	.info_get = es58x_devlink_info_get,
 };
-- 
2.35.1



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

* [PATCH net-next 20/39] can: etas_es58x: remove es58x_get_product_info()
  2022-12-12 11:30 [PATCH net-next 0/39] pull-request: can-next 2022-12-12 Marc Kleine-Budde
                   ` (18 preceding siblings ...)
  2022-12-12 11:30 ` [PATCH net-next 19/39] can: etas_es58x: export product information through devlink_ops::info_get() Marc Kleine-Budde
@ 2022-12-12 11:30 ` Marc Kleine-Budde
  2022-12-12 11:30 ` [PATCH net-next 21/39] Documentation: devlink: add devlink documentation for the etas_es58x driver Marc Kleine-Budde
                   ` (18 subsequent siblings)
  38 siblings, 0 replies; 43+ messages in thread
From: Marc Kleine-Budde @ 2022-12-12 11:30 UTC (permalink / raw)
  To: netdev
  Cc: davem, kuba, linux-can, kernel, Vincent Mailhol, Andrew Lunn,
	Marc Kleine-Budde

From: Vincent Mailhol <mailhol.vincent@wanadoo.fr>

Now that the product information are available under devlink, no more
need to print them in the kernel log. Remove es58x_get_product_info().

Signed-off-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Link: https://lore.kernel.org/all/20221130174658.29282-7-mailhol.vincent@wanadoo.fr
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 drivers/net/can/usb/etas_es58x/es58x_core.c | 52 ++-------------------
 1 file changed, 3 insertions(+), 49 deletions(-)

diff --git a/drivers/net/can/usb/etas_es58x/es58x_core.c b/drivers/net/can/usb/etas_es58x/es58x_core.c
index 4d6d5a4ac06e..0c7f7505632c 100644
--- a/drivers/net/can/usb/etas_es58x/es58x_core.c
+++ b/drivers/net/can/usb/etas_es58x/es58x_core.c
@@ -2141,48 +2141,6 @@ static void es58x_free_netdevs(struct es58x_device *es58x_dev)
 	}
 }
 
-/**
- * es58x_get_product_info() - Get the product information and print them.
- * @es58x_dev: ES58X device.
- *
- * Do a synchronous call to get the product information.
- *
- * Return: zero on success, errno when any error occurs.
- */
-static int es58x_get_product_info(struct es58x_device *es58x_dev)
-{
-	struct usb_device *udev = es58x_dev->udev;
-	const int es58x_prod_info_idx = 6;
-	/* Empirical tests show a prod_info length of maximum 83,
-	 * below should be more than enough.
-	 */
-	const size_t prod_info_len = 127;
-	char *prod_info;
-	int ret;
-
-	prod_info = kmalloc(prod_info_len, GFP_KERNEL);
-	if (!prod_info)
-		return -ENOMEM;
-
-	ret = usb_string(udev, es58x_prod_info_idx, prod_info, prod_info_len);
-	if (ret < 0) {
-		dev_err(es58x_dev->dev,
-			"%s: Could not read the product info: %pe\n",
-			__func__, ERR_PTR(ret));
-		goto out_free;
-	}
-	if (ret >= prod_info_len - 1) {
-		dev_warn(es58x_dev->dev,
-			 "%s: Buffer is too small, result might be truncated\n",
-			 __func__);
-	}
-	dev_info(es58x_dev->dev, "Product info: %s\n", prod_info);
-
- out_free:
-	kfree(prod_info);
-	return ret < 0 ? ret : 0;
-}
-
 /**
  * es58x_init_es58x_dev() - Initialize the ES58X device.
  * @intf: USB interface.
@@ -2261,28 +2219,24 @@ static int es58x_probe(struct usb_interface *intf,
 		       const struct usb_device_id *id)
 {
 	struct es58x_device *es58x_dev;
-	int ch_idx, ret;
+	int ch_idx;
 
 	es58x_dev = es58x_init_es58x_dev(intf, id->driver_info);
 	if (IS_ERR(es58x_dev))
 		return PTR_ERR(es58x_dev);
 
-	ret = es58x_get_product_info(es58x_dev);
-	if (ret)
-		return ret;
-
 	es58x_parse_product_info(es58x_dev);
 	devlink_register(priv_to_devlink(es58x_dev));
 
 	for (ch_idx = 0; ch_idx < es58x_dev->num_can_ch; ch_idx++) {
-		ret = es58x_init_netdev(es58x_dev, ch_idx);
+		int ret = es58x_init_netdev(es58x_dev, ch_idx);
 		if (ret) {
 			es58x_free_netdevs(es58x_dev);
 			return ret;
 		}
 	}
 
-	return ret;
+	return 0;
 }
 
 /**
-- 
2.35.1



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

* [PATCH net-next 21/39] Documentation: devlink: add devlink documentation for the etas_es58x driver
  2022-12-12 11:30 [PATCH net-next 0/39] pull-request: can-next 2022-12-12 Marc Kleine-Budde
                   ` (19 preceding siblings ...)
  2022-12-12 11:30 ` [PATCH net-next 20/39] can: etas_es58x: remove es58x_get_product_info() Marc Kleine-Budde
@ 2022-12-12 11:30 ` Marc Kleine-Budde
  2022-12-12 11:30 ` [PATCH net-next 22/39] can: ucan: use strscpy() to instead of strncpy() Marc Kleine-Budde
                   ` (17 subsequent siblings)
  38 siblings, 0 replies; 43+ messages in thread
From: Marc Kleine-Budde @ 2022-12-12 11:30 UTC (permalink / raw)
  To: netdev; +Cc: davem, kuba, linux-can, kernel, Vincent Mailhol, Marc Kleine-Budde

From: Vincent Mailhol <mailhol.vincent@wanadoo.fr>

List all the version information reported by the etas_es58x driver
through devlink. Also, update MAINTAINERS with the newly created file.

Signed-off-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr>
Link: https://lore.kernel.org/all/20221130174658.29282-8-mailhol.vincent@wanadoo.fr
[mkl: fixed version information table: "bl" -> "fw.bootloader"
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 .../networking/devlink/etas_es58x.rst         | 36 +++++++++++++++++++
 MAINTAINERS                                   |  1 +
 2 files changed, 37 insertions(+)
 create mode 100644 Documentation/networking/devlink/etas_es58x.rst

diff --git a/Documentation/networking/devlink/etas_es58x.rst b/Documentation/networking/devlink/etas_es58x.rst
new file mode 100644
index 000000000000..3b857d82a44c
--- /dev/null
+++ b/Documentation/networking/devlink/etas_es58x.rst
@@ -0,0 +1,36 @@
+.. SPDX-License-Identifier: GPL-2.0
+
+==========================
+etas_es58x devlink support
+==========================
+
+This document describes the devlink features implemented by the
+``etas_es58x`` device driver.
+
+Info versions
+=============
+
+The ``etas_es58x`` driver reports the following versions
+
+.. list-table:: devlink info versions implemented
+   :widths: 5 5 90
+
+   * - Name
+     - Type
+     - Description
+   * - ``fw``
+     - running
+     - Version of the firmware running on the device. Also available
+       through ``ethtool -i`` as the first member of the
+       ``firmware-version``.
+   * - ``fw.bootloader``
+     - running
+     - Version of the bootloader running on the device. Also available
+       through ``ethtool -i`` as the second member of the
+       ``firmware-version``.
+   * - ``board.rev``
+     - fixed
+     - The hardware revision of the device.
+   * - ``serial_number``
+     - fixed
+     - The USB serial number. Also available through ``lsusb -v``.
diff --git a/MAINTAINERS b/MAINTAINERS
index 955c1be1efb2..71f4f8776779 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -7682,6 +7682,7 @@ ETAS ES58X CAN/USB DRIVER
 M:	Vincent Mailhol <mailhol.vincent@wanadoo.fr>
 L:	linux-can@vger.kernel.org
 S:	Maintained
+F:	Documentation/networking/devlink/etas_es58x.rst
 F:	drivers/net/can/usb/etas_es58x/
 
 ETHERNET BRIDGE
-- 
2.35.1



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

* [PATCH net-next 22/39] can: ucan: use strscpy() to instead of strncpy()
  2022-12-12 11:30 [PATCH net-next 0/39] pull-request: can-next 2022-12-12 Marc Kleine-Budde
                   ` (20 preceding siblings ...)
  2022-12-12 11:30 ` [PATCH net-next 21/39] Documentation: devlink: add devlink documentation for the etas_es58x driver Marc Kleine-Budde
@ 2022-12-12 11:30 ` Marc Kleine-Budde
  2022-12-12 11:30 ` [PATCH net-next 23/39] net: af_can: remove useless parameter 'err' in 'can_rx_register()' Marc Kleine-Budde
                   ` (16 subsequent siblings)
  38 siblings, 0 replies; 43+ messages in thread
From: Marc Kleine-Budde @ 2022-12-12 11:30 UTC (permalink / raw)
  To: netdev
  Cc: davem, kuba, linux-can, kernel, Xu Panda, Yang Yang, Marc Kleine-Budde

From: Xu Panda <xu.panda@zte.com.cn>

The implementation of strscpy() is more robust and safer.
That's now the recommended way to copy NUL terminated strings.

Signed-off-by: Xu Panda <xu.panda@zte.com.cn>
Signed-off-by: Yang Yang <yang.yang29@zte.com>
Link: https://lore.kernel.org/all/202212070909095189693@zte.com.cn
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 drivers/net/can/usb/ucan.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/net/can/usb/ucan.c b/drivers/net/can/usb/ucan.c
index ffa38f533c35..159e25ffa337 100644
--- a/drivers/net/can/usb/ucan.c
+++ b/drivers/net/can/usb/ucan.c
@@ -1534,9 +1534,8 @@ static int ucan_probe(struct usb_interface *intf,
 				     sizeof(union ucan_ctl_payload));
 	if (ret > 0) {
 		/* copy string while ensuring zero termination */
-		strncpy(firmware_str, up->ctl_msg_buffer->raw,
-			sizeof(union ucan_ctl_payload));
-		firmware_str[sizeof(union ucan_ctl_payload)] = '\0';
+		strscpy(firmware_str, up->ctl_msg_buffer->raw,
+			sizeof(union ucan_ctl_payload) + 1);
 	} else {
 		strcpy(firmware_str, "unknown");
 	}
-- 
2.35.1



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

* [PATCH net-next 23/39] net: af_can: remove useless parameter 'err' in 'can_rx_register()'
  2022-12-12 11:30 [PATCH net-next 0/39] pull-request: can-next 2022-12-12 Marc Kleine-Budde
                   ` (21 preceding siblings ...)
  2022-12-12 11:30 ` [PATCH net-next 22/39] can: ucan: use strscpy() to instead of strncpy() Marc Kleine-Budde
@ 2022-12-12 11:30 ` Marc Kleine-Budde
  2022-12-12 11:30 ` [PATCH net-next 24/39] can: ucan: remove unused ucan_priv::intf Marc Kleine-Budde
                   ` (15 subsequent siblings)
  38 siblings, 0 replies; 43+ messages in thread
From: Marc Kleine-Budde @ 2022-12-12 11:30 UTC (permalink / raw)
  To: netdev; +Cc: davem, kuba, linux-can, kernel, Ye Bin, Marc Kleine-Budde

From: Ye Bin <yebin10@huawei.com>

Since commit bdfb5765e45b remove NULL-ptr checks from users of
can_dev_rcv_lists_find(). 'err' parameter is useless, so remove it.

Signed-off-by: Ye Bin <yebin10@huawei.com>
Link: https://lore.kernel.org/all/20221208090940.3695670-1-yebin@huaweicloud.com
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 net/can/af_can.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/net/can/af_can.c b/net/can/af_can.c
index c69168f11e44..7343fd487dbe 100644
--- a/net/can/af_can.c
+++ b/net/can/af_can.c
@@ -446,7 +446,6 @@ int can_rx_register(struct net *net, struct net_device *dev, canid_t can_id,
 	struct hlist_head *rcv_list;
 	struct can_dev_rcv_lists *dev_rcv_lists;
 	struct can_rcv_lists_stats *rcv_lists_stats = net->can.rcv_lists_stats;
-	int err = 0;
 
 	/* insert new receiver  (dev,canid,mask) -> (func,data) */
 
@@ -481,7 +480,7 @@ int can_rx_register(struct net *net, struct net_device *dev, canid_t can_id,
 					       rcv_lists_stats->rcv_entries);
 	spin_unlock_bh(&net->can.rcvlists_lock);
 
-	return err;
+	return 0;
 }
 EXPORT_SYMBOL(can_rx_register);
 
-- 
2.35.1



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

* [PATCH net-next 24/39] can: ucan: remove unused ucan_priv::intf
  2022-12-12 11:30 [PATCH net-next 0/39] pull-request: can-next 2022-12-12 Marc Kleine-Budde
                   ` (22 preceding siblings ...)
  2022-12-12 11:30 ` [PATCH net-next 23/39] net: af_can: remove useless parameter 'err' in 'can_rx_register()' Marc Kleine-Budde
@ 2022-12-12 11:30 ` Marc Kleine-Budde
  2022-12-12 11:30 ` [PATCH net-next 25/39] can: gs_usb: remove gs_can::iface Marc Kleine-Budde
                   ` (14 subsequent siblings)
  38 siblings, 0 replies; 43+ messages in thread
From: Marc Kleine-Budde @ 2022-12-12 11:30 UTC (permalink / raw)
  To: netdev; +Cc: davem, kuba, linux-can, kernel, Vincent Mailhol, Marc Kleine-Budde

From: Vincent Mailhol <mailhol.vincent@wanadoo.fr>

Field intf of struct ucan_priv is set but never used. Remove it.

Signed-off-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr>
Link: https://lore.kernel.org/all/20221208081142.16936-2-mailhol.vincent@wanadoo.fr
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 drivers/net/can/usb/ucan.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/net/can/usb/ucan.c b/drivers/net/can/usb/ucan.c
index 159e25ffa337..a0f7bcec719c 100644
--- a/drivers/net/can/usb/ucan.c
+++ b/drivers/net/can/usb/ucan.c
@@ -277,7 +277,6 @@ struct ucan_priv {
 
 	/* linux USB device structures */
 	struct usb_device *udev;
-	struct usb_interface *intf;
 	struct net_device *netdev;
 
 	/* lock for can->echo_skb (used around
@@ -1501,7 +1500,6 @@ static int ucan_probe(struct usb_interface *intf,
 
 	/* initialize data */
 	up->udev = udev;
-	up->intf = intf;
 	up->netdev = netdev;
 	up->intf_index = iface_desc->desc.bInterfaceNumber;
 	up->in_ep_addr = in_ep_addr;
-- 
2.35.1



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

* [PATCH net-next 25/39] can: gs_usb: remove gs_can::iface
  2022-12-12 11:30 [PATCH net-next 0/39] pull-request: can-next 2022-12-12 Marc Kleine-Budde
                   ` (23 preceding siblings ...)
  2022-12-12 11:30 ` [PATCH net-next 24/39] can: ucan: remove unused ucan_priv::intf Marc Kleine-Budde
@ 2022-12-12 11:30 ` Marc Kleine-Budde
  2022-12-12 11:30 ` [PATCH net-next 26/39] can: m_can: Call the RAM init directly from m_can_chip_config Marc Kleine-Budde
                   ` (13 subsequent siblings)
  38 siblings, 0 replies; 43+ messages in thread
From: Marc Kleine-Budde @ 2022-12-12 11:30 UTC (permalink / raw)
  To: netdev; +Cc: davem, kuba, linux-can, kernel, Vincent Mailhol, Marc Kleine-Budde

From: Vincent Mailhol <mailhol.vincent@wanadoo.fr>

The iface field of struct gs_can is only used to retrieve the
usb_device which is already available in gs_can::udev.

Replace each occurrence of interface_to_usbdev(dev->iface) with
dev->udev. This done, remove gs_can::iface.

Signed-off-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr>
Link: https://lore.kernel.org/all/20221208081142.16936-3-mailhol.vincent@wanadoo.fr
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 drivers/net/can/usb/gs_usb.c | 29 +++++++++--------------------
 1 file changed, 9 insertions(+), 20 deletions(-)

diff --git a/drivers/net/can/usb/gs_usb.c b/drivers/net/can/usb/gs_usb.c
index 838744d2ce34..d476c2884008 100644
--- a/drivers/net/can/usb/gs_usb.c
+++ b/drivers/net/can/usb/gs_usb.c
@@ -299,7 +299,6 @@ struct gs_can {
 
 	struct net_device *netdev;
 	struct usb_device *udev;
-	struct usb_interface *iface;
 
 	struct can_bittiming_const bt_const, data_bt_const;
 	unsigned int channel;	/* channel number */
@@ -383,8 +382,7 @@ static int gs_cmd_reset(struct gs_can *dev)
 		.mode = GS_CAN_MODE_RESET,
 	};
 
-	return usb_control_msg_send(interface_to_usbdev(dev->iface), 0,
-				    GS_USB_BREQ_MODE,
+	return usb_control_msg_send(dev->udev, 0, GS_USB_BREQ_MODE,
 				    USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
 				    dev->channel, 0, &dm, sizeof(dm), 1000,
 				    GFP_KERNEL);
@@ -396,8 +394,7 @@ static inline int gs_usb_get_timestamp(const struct gs_can *dev,
 	__le32 timestamp;
 	int rc;
 
-	rc = usb_control_msg_recv(interface_to_usbdev(dev->iface), 0,
-				  GS_USB_BREQ_TIMESTAMP,
+	rc = usb_control_msg_recv(dev->udev, 0, GS_USB_BREQ_TIMESTAMP,
 				  USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
 				  dev->channel, 0,
 				  &timestamp, sizeof(timestamp),
@@ -674,8 +671,7 @@ static int gs_usb_set_bittiming(struct net_device *netdev)
 	};
 
 	/* request bit timings */
-	return usb_control_msg_send(interface_to_usbdev(dev->iface), 0,
-				    GS_USB_BREQ_BITTIMING,
+	return usb_control_msg_send(dev->udev, 0, GS_USB_BREQ_BITTIMING,
 				    USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
 				    dev->channel, 0, &dbt, sizeof(dbt), 1000,
 				    GFP_KERNEL);
@@ -698,8 +694,7 @@ static int gs_usb_set_data_bittiming(struct net_device *netdev)
 		request = GS_USB_BREQ_QUIRK_CANTACT_PRO_DATA_BITTIMING;
 
 	/* request data bit timings */
-	return usb_control_msg_send(interface_to_usbdev(dev->iface), 0,
-				    request,
+	return usb_control_msg_send(dev->udev, 0, request,
 				    USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
 				    dev->channel, 0, &dbt, sizeof(dbt), 1000,
 				    GFP_KERNEL);
@@ -941,8 +936,7 @@ static int gs_can_open(struct net_device *netdev)
 	/* finally start device */
 	dev->can.state = CAN_STATE_ERROR_ACTIVE;
 	dm.flags = cpu_to_le32(flags);
-	rc = usb_control_msg_send(interface_to_usbdev(dev->iface), 0,
-				  GS_USB_BREQ_MODE,
+	rc = usb_control_msg_send(dev->udev, 0, GS_USB_BREQ_MODE,
 				  USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
 				  dev->channel, 0, &dm, sizeof(dm), 1000,
 				  GFP_KERNEL);
@@ -969,8 +963,7 @@ static int gs_usb_get_state(const struct net_device *netdev,
 	struct gs_device_state ds;
 	int rc;
 
-	rc = usb_control_msg_recv(interface_to_usbdev(dev->iface), 0,
-				  GS_USB_BREQ_GET_STATE,
+	rc = usb_control_msg_recv(dev->udev, 0, GS_USB_BREQ_GET_STATE,
 				  USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
 				  dev->channel, 0,
 				  &ds, sizeof(ds),
@@ -1064,8 +1057,7 @@ static int gs_usb_set_identify(struct net_device *netdev, bool do_identify)
 	else
 		imode.mode = cpu_to_le32(GS_CAN_IDENTIFY_OFF);
 
-	return usb_control_msg_send(interface_to_usbdev(dev->iface), 0,
-				    GS_USB_BREQ_IDENTIFY,
+	return usb_control_msg_send(dev->udev, 0, GS_USB_BREQ_IDENTIFY,
 				    USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
 				    dev->channel, 0, &imode, sizeof(imode), 100,
 				    GFP_KERNEL);
@@ -1118,8 +1110,7 @@ static int gs_usb_get_termination(struct net_device *netdev, u16 *term)
 	struct gs_device_termination_state term_state;
 	int rc;
 
-	rc = usb_control_msg_recv(interface_to_usbdev(dev->iface), 0,
-				  GS_USB_BREQ_GET_TERMINATION,
+	rc = usb_control_msg_recv(dev->udev, 0, GS_USB_BREQ_GET_TERMINATION,
 				  USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
 				  dev->channel, 0,
 				  &term_state, sizeof(term_state), 1000,
@@ -1145,8 +1136,7 @@ static int gs_usb_set_termination(struct net_device *netdev, u16 term)
 	else
 		term_state.state = cpu_to_le32(GS_CAN_TERMINATION_STATE_OFF);
 
-	return usb_control_msg_send(interface_to_usbdev(dev->iface), 0,
-				    GS_USB_BREQ_SET_TERMINATION,
+	return usb_control_msg_send(dev->udev, 0, GS_USB_BREQ_SET_TERMINATION,
 				    USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
 				    dev->channel, 0,
 				    &term_state, sizeof(term_state), 1000,
@@ -1210,7 +1200,6 @@ static struct gs_can *gs_make_candev(unsigned int channel,
 	dev->bt_const.brp_inc = le32_to_cpu(bt_const.brp_inc);
 
 	dev->udev = interface_to_usbdev(intf);
-	dev->iface = intf;
 	dev->netdev = netdev;
 	dev->channel = channel;
 
-- 
2.35.1



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

* [PATCH net-next 26/39] can: m_can: Call the RAM init directly from m_can_chip_config
  2022-12-12 11:30 [PATCH net-next 0/39] pull-request: can-next 2022-12-12 Marc Kleine-Budde
                   ` (24 preceding siblings ...)
  2022-12-12 11:30 ` [PATCH net-next 25/39] can: gs_usb: remove gs_can::iface Marc Kleine-Budde
@ 2022-12-12 11:30 ` Marc Kleine-Budde
  2022-12-12 11:30 ` [PATCH net-next 27/39] can: raw: add support for SO_MARK Marc Kleine-Budde
                   ` (12 subsequent siblings)
  38 siblings, 0 replies; 43+ messages in thread
From: Marc Kleine-Budde @ 2022-12-12 11:30 UTC (permalink / raw)
  To: netdev; +Cc: davem, kuba, linux-can, kernel, Vivek Yadav, Marc Kleine-Budde

From: Vivek Yadav <vivek.2311@samsung.com>

When we try to access the mcan message ram addresses during the probe,
hclk is gated by any other drivers or disabled, because of that probe
gets failed.

Move the mram init functionality to mcan chip config called by
m_can_start from mcan open function, by that time clocks are
enabled.

Suggested-by: Marc Kleine-Budde <mkl@pengutronix.de>
Signed-off-by: Vivek Yadav <vivek.2311@samsung.com>
Link: https://lore.kernel.org/all/20221207100632.96200-2-vivek.2311@samsung.com
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 drivers/net/can/m_can/m_can.c          | 32 +++++++++++++++++++++-----
 drivers/net/can/m_can/m_can_platform.c |  4 ----
 drivers/net/can/m_can/tcan4x5x-core.c  |  5 ----
 3 files changed, 26 insertions(+), 15 deletions(-)

diff --git a/drivers/net/can/m_can/m_can.c b/drivers/net/can/m_can/m_can.c
index b1893bb27d59..be8f4b662f95 100644
--- a/drivers/net/can/m_can/m_can.c
+++ b/drivers/net/can/m_can/m_can.c
@@ -1243,10 +1243,17 @@ static int m_can_set_bittiming(struct net_device *dev)
  * - setup bittiming
  * - configure timestamp generation
  */
-static void m_can_chip_config(struct net_device *dev)
+static int m_can_chip_config(struct net_device *dev)
 {
 	struct m_can_classdev *cdev = netdev_priv(dev);
 	u32 cccr, test;
+	int err;
+
+	err = m_can_init_ram(cdev);
+	if (err) {
+		dev_err(cdev->dev, "Message RAM configuration failed\n");
+		return err;
+	}
 
 	m_can_config_endisable(cdev, true);
 
@@ -1370,18 +1377,25 @@ static void m_can_chip_config(struct net_device *dev)
 
 	if (cdev->ops->init)
 		cdev->ops->init(cdev);
+
+	return 0;
 }
 
-static void m_can_start(struct net_device *dev)
+static int m_can_start(struct net_device *dev)
 {
 	struct m_can_classdev *cdev = netdev_priv(dev);
+	int ret;
 
 	/* basic m_can configuration */
-	m_can_chip_config(dev);
+	ret = m_can_chip_config(dev);
+	if (ret)
+		return ret;
 
 	cdev->can.state = CAN_STATE_ERROR_ACTIVE;
 
 	m_can_enable_all_interrupts(cdev);
+
+	return 0;
 }
 
 static int m_can_set_mode(struct net_device *dev, enum can_mode mode)
@@ -1809,7 +1823,9 @@ static int m_can_open(struct net_device *dev)
 	}
 
 	/* start the m_can controller */
-	m_can_start(dev);
+	err = m_can_start(dev);
+	if (err)
+		goto exit_irq_fail;
 
 	if (!cdev->is_peripheral)
 		napi_enable(&cdev->napi);
@@ -2068,9 +2084,13 @@ int m_can_class_resume(struct device *dev)
 		ret = m_can_clk_start(cdev);
 		if (ret)
 			return ret;
+		ret  = m_can_start(ndev);
+		if (ret) {
+			m_can_clk_stop(cdev);
+
+			return ret;
+		}
 
-		m_can_init_ram(cdev);
-		m_can_start(ndev);
 		netif_device_attach(ndev);
 		netif_start_queue(ndev);
 	}
diff --git a/drivers/net/can/m_can/m_can_platform.c b/drivers/net/can/m_can/m_can_platform.c
index b5a5bedb3116..9c1dcf838006 100644
--- a/drivers/net/can/m_can/m_can_platform.c
+++ b/drivers/net/can/m_can/m_can_platform.c
@@ -140,10 +140,6 @@ static int m_can_plat_probe(struct platform_device *pdev)
 
 	platform_set_drvdata(pdev, mcan_class);
 
-	ret = m_can_init_ram(mcan_class);
-	if (ret)
-		goto probe_fail;
-
 	pm_runtime_enable(mcan_class->dev);
 	ret = m_can_class_register(mcan_class);
 	if (ret)
diff --git a/drivers/net/can/m_can/tcan4x5x-core.c b/drivers/net/can/m_can/tcan4x5x-core.c
index 41645a24384c..a3aeb83de152 100644
--- a/drivers/net/can/m_can/tcan4x5x-core.c
+++ b/drivers/net/can/m_can/tcan4x5x-core.c
@@ -234,11 +234,6 @@ static int tcan4x5x_init(struct m_can_classdev *cdev)
 	if (ret)
 		return ret;
 
-	/* Zero out the MCAN buffers */
-	ret = m_can_init_ram(cdev);
-	if (ret)
-		return ret;
-
 	ret = regmap_update_bits(tcan4x5x->regmap, TCAN4X5X_CONFIG,
 				 TCAN4X5X_MODE_SEL_MASK, TCAN4X5X_MODE_NORMAL);
 	if (ret)
-- 
2.35.1



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

* [PATCH net-next 27/39] can: raw: add support for SO_MARK
  2022-12-12 11:30 [PATCH net-next 0/39] pull-request: can-next 2022-12-12 Marc Kleine-Budde
                   ` (25 preceding siblings ...)
  2022-12-12 11:30 ` [PATCH net-next 26/39] can: m_can: Call the RAM init directly from m_can_chip_config Marc Kleine-Budde
@ 2022-12-12 11:30 ` Marc Kleine-Budde
  2022-12-12 11:30 ` [PATCH net-next 28/39] dt-bindings: can: renesas,rcar-canfd: Fix number of channels for R-Car V3U Marc Kleine-Budde
                   ` (11 subsequent siblings)
  38 siblings, 0 replies; 43+ messages in thread
From: Marc Kleine-Budde @ 2022-12-12 11:30 UTC (permalink / raw)
  To: netdev; +Cc: davem, kuba, linux-can, kernel, Marc Kleine-Budde, Oliver Hartkopp

Add support for SO_MARK to the CAN_RAW protocol. This makes it
possible to add traffic control filters based on the fwmark.

Link: https://lore.kernel.org/all/20221210113653.170346-1-mkl@pengutronix.de
Acked-by: Oliver Hartkopp <socketcan@hartkopp.net>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 net/can/raw.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/net/can/raw.c b/net/can/raw.c
index 3eb7d3e2b541..81071cdb0301 100644
--- a/net/can/raw.c
+++ b/net/can/raw.c
@@ -857,6 +857,7 @@ static int raw_sendmsg(struct socket *sock, struct msghdr *msg, size_t size)
 
 	skb->dev = dev;
 	skb->priority = sk->sk_priority;
+	skb->mark = sk->sk_mark;
 	skb->tstamp = sockc.transmit_time;
 
 	skb_setup_tx_timestamp(skb, sockc.tsflags);
-- 
2.35.1



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

* [PATCH net-next 28/39] dt-bindings: can: renesas,rcar-canfd: Fix number of channels for R-Car V3U
  2022-12-12 11:30 [PATCH net-next 0/39] pull-request: can-next 2022-12-12 Marc Kleine-Budde
                   ` (26 preceding siblings ...)
  2022-12-12 11:30 ` [PATCH net-next 27/39] can: raw: add support for SO_MARK Marc Kleine-Budde
@ 2022-12-12 11:30 ` Marc Kleine-Budde
  2022-12-12 11:30 ` [PATCH net-next 29/39] can: m_can: Eliminate double read of TXFQS in tx_handler Marc Kleine-Budde
                   ` (10 subsequent siblings)
  38 siblings, 0 replies; 43+ messages in thread
From: Marc Kleine-Budde @ 2022-12-12 11:30 UTC (permalink / raw)
  To: netdev
  Cc: davem, kuba, linux-can, kernel, Geert Uytterhoeven,
	Krzysztof Kozlowski, Marc Kleine-Budde

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

According to the bindings, only two channels are supported.
However, R-Car V3U supports eight, leading to "make dtbs" failures:

        arch/arm64/boot/dts/renesas/r8a779a0-falcon.dtb: can@e6660000: Unevaluated properties are not allowed ('channel2', 'channel3', 'channel4', 'channel5', 'channel6', 'channel7' were unexpected)

Update the number of channels to 8 on R-Car V3U.
While at it, prevent adding more properties to the channel nodes, as
they must contain no other properties than a status property.

Fixes: d6254d52d70de530 ("dt-bindings: can: renesas,rcar-canfd: Document r8a779a0 support")
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Link: https://lore.kernel.org/all/7d41d72cd7db2e90bae069ce57dbb672f17500ae.1670431681.git.geert+renesas@glider.be
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 .../bindings/net/can/renesas,rcar-canfd.yaml  | 133 ++++++++++--------
 1 file changed, 72 insertions(+), 61 deletions(-)

diff --git a/Documentation/devicetree/bindings/net/can/renesas,rcar-canfd.yaml b/Documentation/devicetree/bindings/net/can/renesas,rcar-canfd.yaml
index 8347053a96dc..1eb98c9a1a26 100644
--- a/Documentation/devicetree/bindings/net/can/renesas,rcar-canfd.yaml
+++ b/Documentation/devicetree/bindings/net/can/renesas,rcar-canfd.yaml
@@ -9,9 +9,6 @@ title: Renesas R-Car CAN FD Controller
 maintainers:
   - Fabrizio Castro <fabrizio.castro.jz@renesas.com>
 
-allOf:
-  - $ref: can-controller.yaml#
-
 properties:
   compatible:
     oneOf:
@@ -77,12 +74,13 @@ properties:
     description: Maximum frequency of the CANFD clock.
 
 patternProperties:
-  "^channel[01]$":
+  "^channel[0-7]$":
     type: object
     description:
-      The controller supports two channels and each is represented as a child
-      node.  Each child node supports the "status" property only, which
-      is used to enable/disable the respective channel.
+      The controller supports multiple channels and each is represented as a
+      child node.  Each channel can be enabled/disabled individually.
+
+    additionalProperties: false
 
 required:
   - compatible
@@ -98,60 +96,73 @@ required:
   - channel0
   - channel1
 
-if:
-  properties:
-    compatible:
-      contains:
-        enum:
-          - renesas,rzg2l-canfd
-then:
-  properties:
-    interrupts:
-      items:
-        - description: CAN global error interrupt
-        - description: CAN receive FIFO interrupt
-        - description: CAN0 error interrupt
-        - description: CAN0 transmit interrupt
-        - description: CAN0 transmit/receive FIFO receive completion interrupt
-        - description: CAN1 error interrupt
-        - description: CAN1 transmit interrupt
-        - description: CAN1 transmit/receive FIFO receive completion interrupt
-
-    interrupt-names:
-      items:
-        - const: g_err
-        - const: g_recc
-        - const: ch0_err
-        - const: ch0_rec
-        - const: ch0_trx
-        - const: ch1_err
-        - const: ch1_rec
-        - const: ch1_trx
-
-    resets:
-      maxItems: 2
-
-    reset-names:
-      items:
-        - const: rstp_n
-        - const: rstc_n
-
-  required:
-    - reset-names
-else:
-  properties:
-    interrupts:
-      items:
-        - description: Channel interrupt
-        - description: Global interrupt
-
-    interrupt-names:
-      items:
-        - const: ch_int
-        - const: g_int
-
-    resets:
-      maxItems: 1
+allOf:
+  - $ref: can-controller.yaml#
+
+  - if:
+      properties:
+        compatible:
+          contains:
+            enum:
+              - renesas,rzg2l-canfd
+    then:
+      properties:
+        interrupts:
+          items:
+            - description: CAN global error interrupt
+            - description: CAN receive FIFO interrupt
+            - description: CAN0 error interrupt
+            - description: CAN0 transmit interrupt
+            - description: CAN0 transmit/receive FIFO receive completion interrupt
+            - description: CAN1 error interrupt
+            - description: CAN1 transmit interrupt
+            - description: CAN1 transmit/receive FIFO receive completion interrupt
+
+        interrupt-names:
+          items:
+            - const: g_err
+            - const: g_recc
+            - const: ch0_err
+            - const: ch0_rec
+            - const: ch0_trx
+            - const: ch1_err
+            - const: ch1_rec
+            - const: ch1_trx
+
+        resets:
+          maxItems: 2
+
+        reset-names:
+          items:
+            - const: rstp_n
+            - const: rstc_n
+
+      required:
+        - reset-names
+    else:
+      properties:
+        interrupts:
+          items:
+            - description: Channel interrupt
+            - description: Global interrupt
+
+        interrupt-names:
+          items:
+            - const: ch_int
+            - const: g_int
+
+        resets:
+          maxItems: 1
+
+  - if:
+      not:
+        properties:
+          compatible:
+            contains:
+              const: renesas,r8a779a0-canfd
+    then:
+      patternProperties:
+        "^channel[2-7]$": false
 
 unevaluatedProperties: false
 
-- 
2.35.1



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

* [PATCH net-next 29/39] can: m_can: Eliminate double read of TXFQS in tx_handler
  2022-12-12 11:30 [PATCH net-next 0/39] pull-request: can-next 2022-12-12 Marc Kleine-Budde
                   ` (27 preceding siblings ...)
  2022-12-12 11:30 ` [PATCH net-next 28/39] dt-bindings: can: renesas,rcar-canfd: Fix number of channels for R-Car V3U Marc Kleine-Budde
@ 2022-12-12 11:30 ` Marc Kleine-Budde
  2022-12-12 11:30 ` [PATCH net-next 30/39] can: m_can: Avoid reading irqstatus twice Marc Kleine-Budde
                   ` (9 subsequent siblings)
  38 siblings, 0 replies; 43+ messages in thread
From: Marc Kleine-Budde @ 2022-12-12 11:30 UTC (permalink / raw)
  To: netdev
  Cc: davem, kuba, linux-can, kernel, Markus Schneider-Pargmann,
	Marc Kleine-Budde

From: Markus Schneider-Pargmann <msp@baylibre.com>

The TXFQS register is read first to check if the fifo is full and then
immediately again to get the putidx. This is unnecessary and adds
significant overhead if read requests are done over a slow bus, for
example SPI with tcan4x5x.

Add a variable to store the value of the register. Split the
m_can_tx_fifo_full function into two to avoid the hidden m_can_read call
if not needed.

Signed-off-by: Markus Schneider-Pargmann <msp@baylibre.com>
Link: https://lore.kernel.org/all/20221206115728.1056014-2-msp@baylibre.com
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 drivers/net/can/m_can/m_can.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/drivers/net/can/m_can/m_can.c b/drivers/net/can/m_can/m_can.c
index be8f4b662f95..61531daf66b8 100644
--- a/drivers/net/can/m_can/m_can.c
+++ b/drivers/net/can/m_can/m_can.c
@@ -369,9 +369,14 @@ m_can_txe_fifo_read(struct m_can_classdev *cdev, u32 fgi, u32 offset, u32 *val)
 	return cdev->ops->read_fifo(cdev, addr_offset, val, 1);
 }
 
+static inline bool _m_can_tx_fifo_full(u32 txfqs)
+{
+	return !!(txfqs & TXFQS_TFQF);
+}
+
 static inline bool m_can_tx_fifo_full(struct m_can_classdev *cdev)
 {
-	return !!(m_can_read(cdev, M_CAN_TXFQS) & TXFQS_TFQF);
+	return _m_can_tx_fifo_full(m_can_read(cdev, M_CAN_TXFQS));
 }
 
 static void m_can_config_endisable(struct m_can_classdev *cdev, bool enable)
@@ -1609,6 +1614,7 @@ static netdev_tx_t m_can_tx_handler(struct m_can_classdev *cdev)
 	struct sk_buff *skb = cdev->tx_skb;
 	struct id_and_dlc fifo_header;
 	u32 cccr, fdflags;
+	u32 txfqs;
 	int err;
 	int putidx;
 
@@ -1665,8 +1671,10 @@ static netdev_tx_t m_can_tx_handler(struct m_can_classdev *cdev)
 	} else {
 		/* Transmit routine for version >= v3.1.x */
 
+		txfqs = m_can_read(cdev, M_CAN_TXFQS);
+
 		/* Check if FIFO full */
-		if (m_can_tx_fifo_full(cdev)) {
+		if (_m_can_tx_fifo_full(txfqs)) {
 			/* This shouldn't happen */
 			netif_stop_queue(dev);
 			netdev_warn(dev,
@@ -1682,8 +1690,7 @@ static netdev_tx_t m_can_tx_handler(struct m_can_classdev *cdev)
 		}
 
 		/* get put index for frame */
-		putidx = FIELD_GET(TXFQS_TFQPI_MASK,
-				   m_can_read(cdev, M_CAN_TXFQS));
+		putidx = FIELD_GET(TXFQS_TFQPI_MASK, txfqs);
 
 		/* Construct DLC Field, with CAN-FD configuration.
 		 * Use the put index of the fifo as the message marker,
-- 
2.35.1



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

* [PATCH net-next 30/39] can: m_can: Avoid reading irqstatus twice
  2022-12-12 11:30 [PATCH net-next 0/39] pull-request: can-next 2022-12-12 Marc Kleine-Budde
                   ` (28 preceding siblings ...)
  2022-12-12 11:30 ` [PATCH net-next 29/39] can: m_can: Eliminate double read of TXFQS in tx_handler Marc Kleine-Budde
@ 2022-12-12 11:30 ` Marc Kleine-Budde
  2022-12-12 11:30 ` [PATCH net-next 31/39] can: m_can: Read register PSR only on error Marc Kleine-Budde
                   ` (8 subsequent siblings)
  38 siblings, 0 replies; 43+ messages in thread
From: Marc Kleine-Budde @ 2022-12-12 11:30 UTC (permalink / raw)
  To: netdev
  Cc: davem, kuba, linux-can, kernel, Markus Schneider-Pargmann,
	Marc Kleine-Budde

From: Markus Schneider-Pargmann <msp@baylibre.com>

For peripheral devices the m_can_rx_handler is called directly after
setting cdev->irqstatus. This means we don't have to read the irqstatus
again in m_can_rx_handler. Avoid this by adding a parameter that is
false for direct calls.

Signed-off-by: Markus Schneider-Pargmann <msp@baylibre.com>
Link: https://lore.kernel.org/all/20221206115728.1056014-3-msp@baylibre.com
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 drivers/net/can/m_can/m_can.c | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/drivers/net/can/m_can/m_can.c b/drivers/net/can/m_can/m_can.c
index 61531daf66b8..8399e55a4ea6 100644
--- a/drivers/net/can/m_can/m_can.c
+++ b/drivers/net/can/m_can/m_can.c
@@ -905,14 +905,13 @@ static int m_can_handle_bus_errors(struct net_device *dev, u32 irqstatus,
 	return work_done;
 }
 
-static int m_can_rx_handler(struct net_device *dev, int quota)
+static int m_can_rx_handler(struct net_device *dev, int quota, u32 irqstatus)
 {
 	struct m_can_classdev *cdev = netdev_priv(dev);
 	int rx_work_or_err;
 	int work_done = 0;
-	u32 irqstatus, psr;
+	u32 psr;
 
-	irqstatus = cdev->irqstatus | m_can_read(cdev, M_CAN_IR);
 	if (!irqstatus)
 		goto end;
 
@@ -956,12 +955,12 @@ static int m_can_rx_handler(struct net_device *dev, int quota)
 	return work_done;
 }
 
-static int m_can_rx_peripheral(struct net_device *dev)
+static int m_can_rx_peripheral(struct net_device *dev, u32 irqstatus)
 {
 	struct m_can_classdev *cdev = netdev_priv(dev);
 	int work_done;
 
-	work_done = m_can_rx_handler(dev, NAPI_POLL_WEIGHT);
+	work_done = m_can_rx_handler(dev, NAPI_POLL_WEIGHT, irqstatus);
 
 	/* Don't re-enable interrupts if the driver had a fatal error
 	 * (e.g., FIFO read failure).
@@ -977,8 +976,11 @@ static int m_can_poll(struct napi_struct *napi, int quota)
 	struct net_device *dev = napi->dev;
 	struct m_can_classdev *cdev = netdev_priv(dev);
 	int work_done;
+	u32 irqstatus;
+
+	irqstatus = cdev->irqstatus | m_can_read(cdev, M_CAN_IR);
 
-	work_done = m_can_rx_handler(dev, quota);
+	work_done = m_can_rx_handler(dev, quota, irqstatus);
 
 	/* Don't re-enable interrupts if the driver had a fatal error
 	 * (e.g., FIFO read failure).
@@ -1088,7 +1090,7 @@ static irqreturn_t m_can_isr(int irq, void *dev_id)
 		m_can_disable_all_interrupts(cdev);
 		if (!cdev->is_peripheral)
 			napi_schedule(&cdev->napi);
-		else if (m_can_rx_peripheral(dev) < 0)
+		else if (m_can_rx_peripheral(dev, ir) < 0)
 			goto out_fail;
 	}
 
-- 
2.35.1



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

* [PATCH net-next 31/39] can: m_can: Read register PSR only on error
  2022-12-12 11:30 [PATCH net-next 0/39] pull-request: can-next 2022-12-12 Marc Kleine-Budde
                   ` (29 preceding siblings ...)
  2022-12-12 11:30 ` [PATCH net-next 30/39] can: m_can: Avoid reading irqstatus twice Marc Kleine-Budde
@ 2022-12-12 11:30 ` Marc Kleine-Budde
  2022-12-12 11:30 ` [PATCH net-next 32/39] can: m_can: Count TXE FIFO getidx in the driver Marc Kleine-Budde
                   ` (7 subsequent siblings)
  38 siblings, 0 replies; 43+ messages in thread
From: Marc Kleine-Budde @ 2022-12-12 11:30 UTC (permalink / raw)
  To: netdev
  Cc: davem, kuba, linux-can, kernel, Markus Schneider-Pargmann,
	Marc Kleine-Budde

From: Markus Schneider-Pargmann <msp@baylibre.com>

Only read register PSR if there is an error indicated in irqstatus.

Signed-off-by: Markus Schneider-Pargmann <msp@baylibre.com>
Link: https://lore.kernel.org/all/20221206115728.1056014-4-msp@baylibre.com
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 drivers/net/can/m_can/m_can.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/net/can/m_can/m_can.c b/drivers/net/can/m_can/m_can.c
index 8399e55a4ea6..045679af76a0 100644
--- a/drivers/net/can/m_can/m_can.c
+++ b/drivers/net/can/m_can/m_can.c
@@ -910,7 +910,6 @@ static int m_can_rx_handler(struct net_device *dev, int quota, u32 irqstatus)
 	struct m_can_classdev *cdev = netdev_priv(dev);
 	int rx_work_or_err;
 	int work_done = 0;
-	u32 psr;
 
 	if (!irqstatus)
 		goto end;
@@ -936,13 +935,13 @@ static int m_can_rx_handler(struct net_device *dev, int quota, u32 irqstatus)
 		}
 	}
 
-	psr = m_can_read(cdev, M_CAN_PSR);
-
 	if (irqstatus & IR_ERR_STATE)
-		work_done += m_can_handle_state_errors(dev, psr);
+		work_done += m_can_handle_state_errors(dev,
+						       m_can_read(cdev, M_CAN_PSR));
 
 	if (irqstatus & IR_ERR_BUS_30X)
-		work_done += m_can_handle_bus_errors(dev, irqstatus, psr);
+		work_done += m_can_handle_bus_errors(dev, irqstatus,
+						     m_can_read(cdev, M_CAN_PSR));
 
 	if (irqstatus & IR_RF0N) {
 		rx_work_or_err = m_can_do_rx_poll(dev, (quota - work_done));
-- 
2.35.1



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

* [PATCH net-next 32/39] can: m_can: Count TXE FIFO getidx in the driver
  2022-12-12 11:30 [PATCH net-next 0/39] pull-request: can-next 2022-12-12 Marc Kleine-Budde
                   ` (30 preceding siblings ...)
  2022-12-12 11:30 ` [PATCH net-next 31/39] can: m_can: Read register PSR only on error Marc Kleine-Budde
@ 2022-12-12 11:30 ` Marc Kleine-Budde
  2022-12-12 11:30 ` [PATCH net-next 33/39] can: m_can: Count read getindex " Marc Kleine-Budde
                   ` (6 subsequent siblings)
  38 siblings, 0 replies; 43+ messages in thread
From: Marc Kleine-Budde @ 2022-12-12 11:30 UTC (permalink / raw)
  To: netdev
  Cc: davem, kuba, linux-can, kernel, Markus Schneider-Pargmann,
	Marc Kleine-Budde

From: Markus Schneider-Pargmann <msp@baylibre.com>

The getindex simply increases by one for every iteration. There is no
need to get the current getidx every time from a register. Instead we
can just count and wrap if necessary.

Signed-off-by: Markus Schneider-Pargmann <msp@baylibre.com>
Link: https://lore.kernel.org/all/20221206115728.1056014-5-msp@baylibre.com
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 drivers/net/can/m_can/m_can.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/net/can/m_can/m_can.c b/drivers/net/can/m_can/m_can.c
index 045679af76a0..83d3a7f191bf 100644
--- a/drivers/net/can/m_can/m_can.c
+++ b/drivers/net/can/m_can/m_can.c
@@ -1030,15 +1030,13 @@ static int m_can_echo_tx_event(struct net_device *dev)
 
 	/* Get Tx Event fifo element count */
 	txe_count = FIELD_GET(TXEFS_EFFL_MASK, m_can_txefs);
+	fgi = FIELD_GET(TXEFS_EFGI_MASK, m_can_txefs);
 
 	/* Get and process all sent elements */
 	for (i = 0; i < txe_count; i++) {
 		u32 txe, timestamp = 0;
 		int err;
 
-		/* retrieve get index */
-		fgi = FIELD_GET(TXEFS_EFGI_MASK, m_can_read(cdev, M_CAN_TXEFS));
-
 		/* get message marker, timestamp */
 		err = m_can_txe_fifo_read(cdev, fgi, 4, &txe);
 		if (err) {
@@ -1052,6 +1050,7 @@ static int m_can_echo_tx_event(struct net_device *dev)
 		/* ack txe element */
 		m_can_write(cdev, M_CAN_TXEFA, FIELD_PREP(TXEFA_EFAI_MASK,
 							  fgi));
+		fgi = (++fgi >= cdev->mcfg[MRAM_TXE].num ? 0 : fgi);
 
 		/* update stats */
 		m_can_tx_update_stats(cdev, msg_mark, timestamp);
-- 
2.35.1



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

* [PATCH net-next 33/39] can: m_can: Count read getindex in the driver
  2022-12-12 11:30 [PATCH net-next 0/39] pull-request: can-next 2022-12-12 Marc Kleine-Budde
                   ` (31 preceding siblings ...)
  2022-12-12 11:30 ` [PATCH net-next 32/39] can: m_can: Count TXE FIFO getidx in the driver Marc Kleine-Budde
@ 2022-12-12 11:30 ` Marc Kleine-Budde
  2022-12-12 11:30 ` [PATCH net-next 34/39] can: m_can: Batch acknowledge transmit events Marc Kleine-Budde
                   ` (5 subsequent siblings)
  38 siblings, 0 replies; 43+ messages in thread
From: Marc Kleine-Budde @ 2022-12-12 11:30 UTC (permalink / raw)
  To: netdev
  Cc: davem, kuba, linux-can, kernel, Markus Schneider-Pargmann,
	Marc Kleine-Budde

From: Markus Schneider-Pargmann <msp@baylibre.com>

The getindex gets increased by one every time. We can calculate the
correct getindex in the driver and avoid the additional reads of rxfs.

Signed-off-by: Markus Schneider-Pargmann <msp@baylibre.com>
Link: https://lore.kernel.org/all/20221206115728.1056014-6-msp@baylibre.com
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 drivers/net/can/m_can/m_can.c | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/drivers/net/can/m_can/m_can.c b/drivers/net/can/m_can/m_can.c
index 83d3a7f191bf..9476d96013fa 100644
--- a/drivers/net/can/m_can/m_can.c
+++ b/drivers/net/can/m_can/m_can.c
@@ -477,19 +477,16 @@ static void m_can_receive_skb(struct m_can_classdev *cdev,
 	}
 }
 
-static int m_can_read_fifo(struct net_device *dev, u32 rxfs)
+static int m_can_read_fifo(struct net_device *dev, u32 fgi)
 {
 	struct net_device_stats *stats = &dev->stats;
 	struct m_can_classdev *cdev = netdev_priv(dev);
 	struct canfd_frame *cf;
 	struct sk_buff *skb;
 	struct id_and_dlc fifo_header;
-	u32 fgi;
 	u32 timestamp = 0;
 	int err;
 
-	/* calculate the fifo get index for where to read data */
-	fgi = FIELD_GET(RXFS_FGI_MASK, rxfs);
 	err = m_can_fifo_read(cdev, fgi, M_CAN_FIFO_ID, &fifo_header, 2);
 	if (err)
 		goto out_fail;
@@ -554,6 +551,9 @@ static int m_can_do_rx_poll(struct net_device *dev, int quota)
 	struct m_can_classdev *cdev = netdev_priv(dev);
 	u32 pkts = 0;
 	u32 rxfs;
+	u32 rx_count;
+	u32 fgi;
+	int i;
 	int err;
 
 	rxfs = m_can_read(cdev, M_CAN_RXF0S);
@@ -562,14 +562,17 @@ static int m_can_do_rx_poll(struct net_device *dev, int quota)
 		return 0;
 	}
 
-	while ((rxfs & RXFS_FFL_MASK) && (quota > 0)) {
-		err = m_can_read_fifo(dev, rxfs);
+	rx_count = FIELD_GET(RXFS_FFL_MASK, rxfs);
+	fgi = FIELD_GET(RXFS_FGI_MASK, rxfs);
+
+	for (i = 0; i < rx_count && quota > 0; ++i) {
+		err = m_can_read_fifo(dev, fgi);
 		if (err)
 			return err;
 
 		quota--;
 		pkts++;
-		rxfs = m_can_read(cdev, M_CAN_RXF0S);
+		fgi = (++fgi >= cdev->mcfg[MRAM_RXF0].num ? 0 : fgi);
 	}
 
 	return pkts;
-- 
2.35.1



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

* [PATCH net-next 34/39] can: m_can: Batch acknowledge transmit events
  2022-12-12 11:30 [PATCH net-next 0/39] pull-request: can-next 2022-12-12 Marc Kleine-Budde
                   ` (32 preceding siblings ...)
  2022-12-12 11:30 ` [PATCH net-next 33/39] can: m_can: Count read getindex " Marc Kleine-Budde
@ 2022-12-12 11:30 ` Marc Kleine-Budde
  2022-12-12 11:30 ` [PATCH net-next 35/39] can: m_can: Batch acknowledge rx fifo Marc Kleine-Budde
                   ` (4 subsequent siblings)
  38 siblings, 0 replies; 43+ messages in thread
From: Marc Kleine-Budde @ 2022-12-12 11:30 UTC (permalink / raw)
  To: netdev
  Cc: davem, kuba, linux-can, kernel, Markus Schneider-Pargmann,
	Marc Kleine-Budde

From: Markus Schneider-Pargmann <msp@baylibre.com>

Transmit events from the txe fifo can be batch acknowledged by
acknowledging the last read txe fifo item. This will save txe_count
writes which is important for peripheral chips.

Signed-off-by: Markus Schneider-Pargmann <msp@baylibre.com>
Link: https://lore.kernel.org/all/20221206115728.1056014-7-msp@baylibre.com
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 drivers/net/can/m_can/m_can.c | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/drivers/net/can/m_can/m_can.c b/drivers/net/can/m_can/m_can.c
index 9476d96013fa..656d2daafad1 100644
--- a/drivers/net/can/m_can/m_can.c
+++ b/drivers/net/can/m_can/m_can.c
@@ -1023,7 +1023,9 @@ static int m_can_echo_tx_event(struct net_device *dev)
 	u32 txe_count = 0;
 	u32 m_can_txefs;
 	u32 fgi = 0;
+	int ack_fgi = -1;
 	int i = 0;
+	int err = 0;
 	unsigned int msg_mark;
 
 	struct m_can_classdev *cdev = netdev_priv(dev);
@@ -1038,28 +1040,29 @@ static int m_can_echo_tx_event(struct net_device *dev)
 	/* Get and process all sent elements */
 	for (i = 0; i < txe_count; i++) {
 		u32 txe, timestamp = 0;
-		int err;
 
 		/* get message marker, timestamp */
 		err = m_can_txe_fifo_read(cdev, fgi, 4, &txe);
 		if (err) {
 			netdev_err(dev, "TXE FIFO read returned %d\n", err);
-			return err;
+			break;
 		}
 
 		msg_mark = FIELD_GET(TX_EVENT_MM_MASK, txe);
 		timestamp = FIELD_GET(TX_EVENT_TXTS_MASK, txe) << 16;
 
-		/* ack txe element */
-		m_can_write(cdev, M_CAN_TXEFA, FIELD_PREP(TXEFA_EFAI_MASK,
-							  fgi));
+		ack_fgi = fgi;
 		fgi = (++fgi >= cdev->mcfg[MRAM_TXE].num ? 0 : fgi);
 
 		/* update stats */
 		m_can_tx_update_stats(cdev, msg_mark, timestamp);
 	}
 
-	return 0;
+	if (ack_fgi != -1)
+		m_can_write(cdev, M_CAN_TXEFA, FIELD_PREP(TXEFA_EFAI_MASK,
+							  ack_fgi));
+
+	return err;
 }
 
 static irqreturn_t m_can_isr(int irq, void *dev_id)
-- 
2.35.1



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

* [PATCH net-next 35/39] can: m_can: Batch acknowledge rx fifo
  2022-12-12 11:30 [PATCH net-next 0/39] pull-request: can-next 2022-12-12 Marc Kleine-Budde
                   ` (33 preceding siblings ...)
  2022-12-12 11:30 ` [PATCH net-next 34/39] can: m_can: Batch acknowledge transmit events Marc Kleine-Budde
@ 2022-12-12 11:30 ` Marc Kleine-Budde
  2022-12-12 11:30 ` [PATCH net-next 36/39] can: tcan4x5x: Remove invalid write in clear_interrupts Marc Kleine-Budde
                   ` (3 subsequent siblings)
  38 siblings, 0 replies; 43+ messages in thread
From: Marc Kleine-Budde @ 2022-12-12 11:30 UTC (permalink / raw)
  To: netdev
  Cc: davem, kuba, linux-can, kernel, Markus Schneider-Pargmann,
	Marc Kleine-Budde

From: Markus Schneider-Pargmann <msp@baylibre.com>

Instead of acknowledging every item of the fifo, only acknowledge the
last item read. This behavior is documented in the datasheet. The new
getindex will be the acknowledged item + 1.

Signed-off-by: Markus Schneider-Pargmann <msp@baylibre.com>
Link: https://lore.kernel.org/all/20221206115728.1056014-8-msp@baylibre.com
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 drivers/net/can/m_can/m_can.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/drivers/net/can/m_can/m_can.c b/drivers/net/can/m_can/m_can.c
index 656d2daafad1..8e83d6963d85 100644
--- a/drivers/net/can/m_can/m_can.c
+++ b/drivers/net/can/m_can/m_can.c
@@ -530,9 +530,6 @@ static int m_can_read_fifo(struct net_device *dev, u32 fgi)
 	}
 	stats->rx_packets++;
 
-	/* acknowledge rx fifo 0 */
-	m_can_write(cdev, M_CAN_RXF0A, fgi);
-
 	timestamp = FIELD_GET(RX_BUF_RXTS_MASK, fifo_header.dlc) << 16;
 
 	m_can_receive_skb(cdev, skb, timestamp);
@@ -553,8 +550,9 @@ static int m_can_do_rx_poll(struct net_device *dev, int quota)
 	u32 rxfs;
 	u32 rx_count;
 	u32 fgi;
+	int ack_fgi = -1;
 	int i;
-	int err;
+	int err = 0;
 
 	rxfs = m_can_read(cdev, M_CAN_RXF0S);
 	if (!(rxfs & RXFS_FFL_MASK)) {
@@ -568,13 +566,20 @@ static int m_can_do_rx_poll(struct net_device *dev, int quota)
 	for (i = 0; i < rx_count && quota > 0; ++i) {
 		err = m_can_read_fifo(dev, fgi);
 		if (err)
-			return err;
+			break;
 
 		quota--;
 		pkts++;
+		ack_fgi = fgi;
 		fgi = (++fgi >= cdev->mcfg[MRAM_RXF0].num ? 0 : fgi);
 	}
 
+	if (ack_fgi != -1)
+		m_can_write(cdev, M_CAN_RXF0A, ack_fgi);
+
+	if (err)
+		return err;
+
 	return pkts;
 }
 
-- 
2.35.1



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

* [PATCH net-next 36/39] can: tcan4x5x: Remove invalid write in clear_interrupts
  2022-12-12 11:30 [PATCH net-next 0/39] pull-request: can-next 2022-12-12 Marc Kleine-Budde
                   ` (34 preceding siblings ...)
  2022-12-12 11:30 ` [PATCH net-next 35/39] can: m_can: Batch acknowledge rx fifo Marc Kleine-Budde
@ 2022-12-12 11:30 ` Marc Kleine-Budde
  2022-12-12 11:30 ` [PATCH net-next 37/39] can: tcan4x5x: Fix use of register error status mask Marc Kleine-Budde
                   ` (2 subsequent siblings)
  38 siblings, 0 replies; 43+ messages in thread
From: Marc Kleine-Budde @ 2022-12-12 11:30 UTC (permalink / raw)
  To: netdev
  Cc: davem, kuba, linux-can, kernel, Markus Schneider-Pargmann,
	Marc Kleine-Budde

From: Markus Schneider-Pargmann <msp@baylibre.com>

Register 0x824 TCAN4X5X_MCAN_INT_REG is a read-only register. Any writes
to this register do not have any effect.

Remove this write. The m_can driver aldready clears the interrupts in
m_can_isr() by writing to M_CAN_IR which is translated to register
0x1050 which is a writable version of this register.

Fixes: 5443c226ba91 ("can: tcan4x5x: Add tcan4x5x driver to the kernel")
Signed-off-by: Markus Schneider-Pargmann <msp@baylibre.com>
Link: https://lore.kernel.org/all/20221206115728.1056014-9-msp@baylibre.com
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 drivers/net/can/m_can/tcan4x5x-core.c | 5 -----
 1 file changed, 5 deletions(-)

diff --git a/drivers/net/can/m_can/tcan4x5x-core.c b/drivers/net/can/m_can/tcan4x5x-core.c
index a3aeb83de152..a77f4d4f6299 100644
--- a/drivers/net/can/m_can/tcan4x5x-core.c
+++ b/drivers/net/can/m_can/tcan4x5x-core.c
@@ -204,11 +204,6 @@ static int tcan4x5x_clear_interrupts(struct m_can_classdev *cdev)
 	if (ret)
 		return ret;
 
-	ret = tcan4x5x_write_tcan_reg(cdev, TCAN4X5X_MCAN_INT_REG,
-				      TCAN4X5X_ENABLE_MCAN_INT);
-	if (ret)
-		return ret;
-
 	ret = tcan4x5x_write_tcan_reg(cdev, TCAN4X5X_INT_FLAGS,
 				      TCAN4X5X_CLEAR_ALL_INT);
 	if (ret)
-- 
2.35.1



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

* [PATCH net-next 37/39] can: tcan4x5x: Fix use of register error status mask
  2022-12-12 11:30 [PATCH net-next 0/39] pull-request: can-next 2022-12-12 Marc Kleine-Budde
                   ` (35 preceding siblings ...)
  2022-12-12 11:30 ` [PATCH net-next 36/39] can: tcan4x5x: Remove invalid write in clear_interrupts Marc Kleine-Budde
@ 2022-12-12 11:30 ` Marc Kleine-Budde
  2022-12-12 11:30 ` [PATCH net-next 38/39] can: tcan4x5x: Fix register range of first two blocks Marc Kleine-Budde
  2022-12-12 11:30 ` [PATCH net-next 39/39] can: tcan4x5x: Specify separate read/write ranges Marc Kleine-Budde
  38 siblings, 0 replies; 43+ messages in thread
From: Marc Kleine-Budde @ 2022-12-12 11:30 UTC (permalink / raw)
  To: netdev
  Cc: davem, kuba, linux-can, kernel, Markus Schneider-Pargmann,
	Marc Kleine-Budde

From: Markus Schneider-Pargmann <msp@baylibre.com>

TCAN4X5X_ERROR_STATUS is not a status register that needs clearing
during interrupt handling. Instead this is a masking register that masks
error interrupts. Writing TCAN4X5X_CLEAR_ALL_INT to this register
effectively masks everything.

Rename the register and mask all error interrupts only once by writing
to the register in tcan4x5x_init.

Fixes: 5443c226ba91 ("can: tcan4x5x: Add tcan4x5x driver to the kernel")
Signed-off-by: Markus Schneider-Pargmann <msp@baylibre.com>
Link: https://lore.kernel.org/all/20221206115728.1056014-10-msp@baylibre.com
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 drivers/net/can/m_can/tcan4x5x-core.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/net/can/m_can/tcan4x5x-core.c b/drivers/net/can/m_can/tcan4x5x-core.c
index a77f4d4f6299..2342aa011647 100644
--- a/drivers/net/can/m_can/tcan4x5x-core.c
+++ b/drivers/net/can/m_can/tcan4x5x-core.c
@@ -10,7 +10,7 @@
 #define TCAN4X5X_DEV_ID1 0x04
 #define TCAN4X5X_REV 0x08
 #define TCAN4X5X_STATUS 0x0C
-#define TCAN4X5X_ERROR_STATUS 0x10
+#define TCAN4X5X_ERROR_STATUS_MASK 0x10
 #define TCAN4X5X_CONTROL 0x14
 
 #define TCAN4X5X_CONFIG 0x800
@@ -204,12 +204,7 @@ static int tcan4x5x_clear_interrupts(struct m_can_classdev *cdev)
 	if (ret)
 		return ret;
 
-	ret = tcan4x5x_write_tcan_reg(cdev, TCAN4X5X_INT_FLAGS,
-				      TCAN4X5X_CLEAR_ALL_INT);
-	if (ret)
-		return ret;
-
-	return tcan4x5x_write_tcan_reg(cdev, TCAN4X5X_ERROR_STATUS,
+	return tcan4x5x_write_tcan_reg(cdev, TCAN4X5X_INT_FLAGS,
 				       TCAN4X5X_CLEAR_ALL_INT);
 }
 
@@ -229,6 +224,11 @@ static int tcan4x5x_init(struct m_can_classdev *cdev)
 	if (ret)
 		return ret;
 
+	ret = tcan4x5x_write_tcan_reg(cdev, TCAN4X5X_ERROR_STATUS_MASK,
+				      TCAN4X5X_CLEAR_ALL_INT);
+	if (ret)
+		return ret;
+
 	ret = regmap_update_bits(tcan4x5x->regmap, TCAN4X5X_CONFIG,
 				 TCAN4X5X_MODE_SEL_MASK, TCAN4X5X_MODE_NORMAL);
 	if (ret)
-- 
2.35.1



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

* [PATCH net-next 38/39] can: tcan4x5x: Fix register range of first two blocks
  2022-12-12 11:30 [PATCH net-next 0/39] pull-request: can-next 2022-12-12 Marc Kleine-Budde
                   ` (36 preceding siblings ...)
  2022-12-12 11:30 ` [PATCH net-next 37/39] can: tcan4x5x: Fix use of register error status mask Marc Kleine-Budde
@ 2022-12-12 11:30 ` Marc Kleine-Budde
  2022-12-12 11:30 ` [PATCH net-next 39/39] can: tcan4x5x: Specify separate read/write ranges Marc Kleine-Budde
  38 siblings, 0 replies; 43+ messages in thread
From: Marc Kleine-Budde @ 2022-12-12 11:30 UTC (permalink / raw)
  To: netdev
  Cc: davem, kuba, linux-can, kernel, Markus Schneider-Pargmann,
	Marc Kleine-Budde

From: Markus Schneider-Pargmann <msp@baylibre.com>

According to the datasheet 0x10 is the last register in the first block,
not register 0x2c.

The datasheet lists the last register of the second block as 0x830, not
0x83c.

Signed-off-by: Markus Schneider-Pargmann <msp@baylibre.com>
Link: https://lore.kernel.org/all/20221206115728.1056014-11-msp@baylibre.com
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 drivers/net/can/m_can/tcan4x5x-regmap.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/can/m_can/tcan4x5x-regmap.c b/drivers/net/can/m_can/tcan4x5x-regmap.c
index 26e212b8ca7a..33aed989e42a 100644
--- a/drivers/net/can/m_can/tcan4x5x-regmap.c
+++ b/drivers/net/can/m_can/tcan4x5x-regmap.c
@@ -91,8 +91,8 @@ static int tcan4x5x_regmap_read(void *context,
 }
 
 static const struct regmap_range tcan4x5x_reg_table_yes_range[] = {
-	regmap_reg_range(0x0000, 0x002c),	/* Device ID and SPI Registers */
-	regmap_reg_range(0x0800, 0x083c),	/* Device configuration registers and Interrupt Flags*/
+	regmap_reg_range(0x0000, 0x0010),	/* Device ID and SPI Registers */
+	regmap_reg_range(0x0800, 0x0830),	/* Device configuration registers and Interrupt Flags*/
 	regmap_reg_range(0x1000, 0x10fc),	/* M_CAN */
 	regmap_reg_range(0x8000, 0x87fc),	/* MRAM */
 };
-- 
2.35.1



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

* [PATCH net-next 39/39] can: tcan4x5x: Specify separate read/write ranges
  2022-12-12 11:30 [PATCH net-next 0/39] pull-request: can-next 2022-12-12 Marc Kleine-Budde
                   ` (37 preceding siblings ...)
  2022-12-12 11:30 ` [PATCH net-next 38/39] can: tcan4x5x: Fix register range of first two blocks Marc Kleine-Budde
@ 2022-12-12 11:30 ` Marc Kleine-Budde
  38 siblings, 0 replies; 43+ messages in thread
From: Marc Kleine-Budde @ 2022-12-12 11:30 UTC (permalink / raw)
  To: netdev
  Cc: davem, kuba, linux-can, kernel, Markus Schneider-Pargmann,
	Marc Kleine-Budde

From: Markus Schneider-Pargmann <msp@baylibre.com>

Specify exactly which registers are read/writeable in the chip. This
is supposed to help detect any violations in the future.

Signed-off-by: Markus Schneider-Pargmann <msp@baylibre.com>
Link: https://lore.kernel.org/all/20221206115728.1056014-12-msp@baylibre.com
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 drivers/net/can/m_can/tcan4x5x-regmap.c | 43 +++++++++++++++++++++----
 1 file changed, 37 insertions(+), 6 deletions(-)

diff --git a/drivers/net/can/m_can/tcan4x5x-regmap.c b/drivers/net/can/m_can/tcan4x5x-regmap.c
index 33aed989e42a..2b218ce04e9f 100644
--- a/drivers/net/can/m_can/tcan4x5x-regmap.c
+++ b/drivers/net/can/m_can/tcan4x5x-regmap.c
@@ -90,16 +90,47 @@ static int tcan4x5x_regmap_read(void *context,
 	return 0;
 }
 
-static const struct regmap_range tcan4x5x_reg_table_yes_range[] = {
+static const struct regmap_range tcan4x5x_reg_table_wr_range[] = {
+	/* Device ID and SPI Registers */
+	regmap_reg_range(0x000c, 0x0010),
+	/* Device configuration registers and Interrupt Flags*/
+	regmap_reg_range(0x0800, 0x080c),
+	regmap_reg_range(0x0814, 0x0814),
+	regmap_reg_range(0x0820, 0x0820),
+	regmap_reg_range(0x0830, 0x0830),
+	/* M_CAN */
+	regmap_reg_range(0x100c, 0x102c),
+	regmap_reg_range(0x1048, 0x1048),
+	regmap_reg_range(0x1050, 0x105c),
+	regmap_reg_range(0x1080, 0x1088),
+	regmap_reg_range(0x1090, 0x1090),
+	regmap_reg_range(0x1098, 0x10a0),
+	regmap_reg_range(0x10a8, 0x10b0),
+	regmap_reg_range(0x10b8, 0x10c0),
+	regmap_reg_range(0x10c8, 0x10c8),
+	regmap_reg_range(0x10d0, 0x10d4),
+	regmap_reg_range(0x10e0, 0x10e4),
+	regmap_reg_range(0x10f0, 0x10f0),
+	regmap_reg_range(0x10f8, 0x10f8),
+	/* MRAM */
+	regmap_reg_range(0x8000, 0x87fc),
+};
+
+static const struct regmap_range tcan4x5x_reg_table_rd_range[] = {
 	regmap_reg_range(0x0000, 0x0010),	/* Device ID and SPI Registers */
 	regmap_reg_range(0x0800, 0x0830),	/* Device configuration registers and Interrupt Flags*/
 	regmap_reg_range(0x1000, 0x10fc),	/* M_CAN */
 	regmap_reg_range(0x8000, 0x87fc),	/* MRAM */
 };
 
-static const struct regmap_access_table tcan4x5x_reg_table = {
-	.yes_ranges = tcan4x5x_reg_table_yes_range,
-	.n_yes_ranges = ARRAY_SIZE(tcan4x5x_reg_table_yes_range),
+static const struct regmap_access_table tcan4x5x_reg_table_wr = {
+	.yes_ranges = tcan4x5x_reg_table_wr_range,
+	.n_yes_ranges = ARRAY_SIZE(tcan4x5x_reg_table_wr_range),
+};
+
+static const struct regmap_access_table tcan4x5x_reg_table_rd = {
+	.yes_ranges = tcan4x5x_reg_table_rd_range,
+	.n_yes_ranges = ARRAY_SIZE(tcan4x5x_reg_table_rd_range),
 };
 
 static const struct regmap_config tcan4x5x_regmap = {
@@ -107,8 +138,8 @@ static const struct regmap_config tcan4x5x_regmap = {
 	.reg_stride = 4,
 	.pad_bits = 8,
 	.val_bits = 32,
-	.wr_table = &tcan4x5x_reg_table,
-	.rd_table = &tcan4x5x_reg_table,
+	.wr_table = &tcan4x5x_reg_table_wr,
+	.rd_table = &tcan4x5x_reg_table_rd,
 	.max_register = TCAN4X5X_MAX_REGISTER,
 	.cache_type = REGCACHE_NONE,
 	.read_flag_mask = (__force unsigned long)
-- 
2.35.1



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

* Re: [PATCH net-next 01/39] can: kvaser_usb: kvaser_usb_set_bittiming(): fix redundant initialization warning for err
  2022-12-12 11:30 ` [PATCH net-next 01/39] can: kvaser_usb: kvaser_usb_set_bittiming(): fix redundant initialization warning for err Marc Kleine-Budde
@ 2022-12-12 12:20   ` patchwork-bot+netdevbpf
  0 siblings, 0 replies; 43+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-12-12 12:20 UTC (permalink / raw)
  To: Marc Kleine-Budde
  Cc: netdev, davem, kuba, linux-can, kernel, extja, anssi.hannula

Hello:

This series was applied to netdev/net-next.git (master)
by Marc Kleine-Budde <mkl@pengutronix.de>:

On Mon, 12 Dec 2022 12:30:07 +0100 you wrote:
> The variable err is initialized, but the initialized value is
> Overwritten before it is read. Fix the warning by not initializing the
> variable err at all.
> 
> Fixes: 39d3df6b0ea8 ("can: kvaser_usb: Compare requested bittiming parameters with actual parameters in do_set_{,data}_bittiming")
> Cc: Jimmy Assarsson <extja@kvaser.com>
> Cc: Anssi Hannula <anssi.hannula@bitwise.fi>
> Link: https://lore.kernel.org/all/20221031114513.81214-1-mkl@pengutronix.de
> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
> 
> [...]

Here is the summary with links:
  - [net-next,01/39] can: kvaser_usb: kvaser_usb_set_bittiming(): fix redundant initialization warning for err
    https://git.kernel.org/netdev/net-next/c/cce2d7d2abcc
  - [net-next,02/39] can: kvaser_usb: kvaser_usb_set_{,data}bittiming(): remove empty lines in variable declaration
    https://git.kernel.org/netdev/net-next/c/0bf582fc5168
  - [net-next,03/39] can: rcar_canfd: rcar_canfd_probe: Add struct rcar_canfd_hw_info to driver data
    https://git.kernel.org/netdev/net-next/c/ce7c5382758b
  - [net-next,04/39] can: m_can: sort header inclusion alphabetically
    https://git.kernel.org/netdev/net-next/c/09451f244eab
  - [net-next,05/39] can: rcar_canfd: Add max_channels to struct rcar_canfd_hw_info
    https://git.kernel.org/netdev/net-next/c/34f9e9852b90
  - [net-next,06/39] can: rcar_canfd: Add shared_global_irqs to struct rcar_canfd_hw_info
    https://git.kernel.org/netdev/net-next/c/841645cfc773
  - [net-next,07/39] can: rcar_canfd: Add postdiv to struct rcar_canfd_hw_info
    https://git.kernel.org/netdev/net-next/c/a1dcfbdfd1d0
  - [net-next,08/39] can: rcar_canfd: Add multi_channel_irqs to struct rcar_canfd_hw_info
    https://git.kernel.org/netdev/net-next/c/ea6ff7792203
  - [net-next,09/39] can: ctucanfd: Drop obsolete dependency on COMPILE_TEST
    https://git.kernel.org/netdev/net-next/c/005c54278b3d
  - [net-next,10/39] can: etas_es58x: sort the includes by alphabetic order
    https://git.kernel.org/netdev/net-next/c/8fd9323ef721
  - [net-next,11/39] can: flexcan: add auto stop mode for IMX93 to support wakeup
    https://git.kernel.org/netdev/net-next/c/8cb53b485f18
  - [net-next,12/39] can: etas_es58x: add devlink support
    https://git.kernel.org/netdev/net-next/c/2c4a1efcf6ab
  - [net-next,13/39] dt-bindings: can: fsl,flexcan: add imx93 compatible
    https://git.kernel.org/netdev/net-next/c/a21cee59b416
  - [net-next,14/39] can: etas_es58x: add devlink port support
    https://git.kernel.org/netdev/net-next/c/594a25e1ffc5
  - [net-next,15/39] dt-bindings: can: renesas,rcar-canfd: Document RZ/Five SoC
    https://git.kernel.org/netdev/net-next/c/5237ff4e7d3d
  - [net-next,16/39] USB: core: export usb_cache_string()
    https://git.kernel.org/netdev/net-next/c/983055bf8397
  - [net-next,17/39] can: c_can: use devm_platform_get_and_ioremap_resource()
    https://git.kernel.org/netdev/net-next/c/74d95352bdfc
  - [net-next,18/39] net: devlink: add DEVLINK_INFO_VERSION_GENERIC_FW_BOOTLOADER
    https://git.kernel.org/netdev/net-next/c/01d80532295c
  - [net-next,19/39] can: etas_es58x: export product information through devlink_ops::info_get()
    https://git.kernel.org/netdev/net-next/c/9f06631c3f1f
  - [net-next,20/39] can: etas_es58x: remove es58x_get_product_info()
    https://git.kernel.org/netdev/net-next/c/d8f26fd689dd
  - [net-next,21/39] Documentation: devlink: add devlink documentation for the etas_es58x driver
    https://git.kernel.org/netdev/net-next/c/9f63f96aac92
  - [net-next,22/39] can: ucan: use strscpy() to instead of strncpy()
    https://git.kernel.org/netdev/net-next/c/7fdaf8966aae
  - [net-next,23/39] net: af_can: remove useless parameter 'err' in 'can_rx_register()'
    https://git.kernel.org/netdev/net-next/c/f793458bba54
  - [net-next,24/39] can: ucan: remove unused ucan_priv::intf
    https://git.kernel.org/netdev/net-next/c/f54b101ddeae
  - [net-next,25/39] can: gs_usb: remove gs_can::iface
    https://git.kernel.org/netdev/net-next/c/56c56a309e79
  - [net-next,26/39] can: m_can: Call the RAM init directly from m_can_chip_config
    https://git.kernel.org/netdev/net-next/c/eaacfeaca7ad
  - [net-next,27/39] can: raw: add support for SO_MARK
    https://git.kernel.org/netdev/net-next/c/0826e82b8a32
  - [net-next,28/39] dt-bindings: can: renesas,rcar-canfd: Fix number of channels for R-Car V3U
    https://git.kernel.org/netdev/net-next/c/3abcc01c38bc
  - [net-next,29/39] can: m_can: Eliminate double read of TXFQS in tx_handler
    https://git.kernel.org/netdev/net-next/c/c1eaf8b9bd31
  - [net-next,30/39] can: m_can: Avoid reading irqstatus twice
    https://git.kernel.org/netdev/net-next/c/577579379749
  - [net-next,31/39] can: m_can: Read register PSR only on error
    https://git.kernel.org/netdev/net-next/c/fac52bf786e5
  - [net-next,32/39] can: m_can: Count TXE FIFO getidx in the driver
    https://git.kernel.org/netdev/net-next/c/d4535b90a76a
  - [net-next,33/39] can: m_can: Count read getindex in the driver
    https://git.kernel.org/netdev/net-next/c/6355a3c983e6
  - [net-next,34/39] can: m_can: Batch acknowledge transmit events
    https://git.kernel.org/netdev/net-next/c/e3bff5256a0f
  - [net-next,35/39] can: m_can: Batch acknowledge rx fifo
    https://git.kernel.org/netdev/net-next/c/e2f1c8cb0202
  - [net-next,36/39] can: tcan4x5x: Remove invalid write in clear_interrupts
    https://git.kernel.org/netdev/net-next/c/40c9e4f676ab
  - [net-next,37/39] can: tcan4x5x: Fix use of register error status mask
    https://git.kernel.org/netdev/net-next/c/67727a17a6b3
  - [net-next,38/39] can: tcan4x5x: Fix register range of first two blocks
    https://git.kernel.org/netdev/net-next/c/ef5778f70841
  - [net-next,39/39] can: tcan4x5x: Specify separate read/write ranges
    https://git.kernel.org/netdev/net-next/c/39dbb21b6a29

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



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

* RE: [PATCH net-next 11/39] can: flexcan: add auto stop mode for IMX93 to support wakeup
  2022-12-12 11:30 ` [PATCH net-next 11/39] can: flexcan: add auto stop mode for IMX93 to support wakeup Marc Kleine-Budde
@ 2022-12-13  2:22   ` Bough Chen
  2022-12-13  8:11     ` Marc Kleine-Budde
  0 siblings, 1 reply; 43+ messages in thread
From: Bough Chen @ 2022-12-13  2:22 UTC (permalink / raw)
  To: Marc Kleine-Budde, netdev; +Cc: davem, kuba, linux-can, kernel

> -----Original Message-----
> From: Marc Kleine-Budde <mkl@pengutronix.de>
> Sent: 2022年12月12日 19:30
> To: netdev@vger.kernel.org
> Cc: davem@davemloft.net; kuba@kernel.org; linux-can@vger.kernel.org;
> kernel@pengutronix.de; Bough Chen <haibo.chen@nxp.com>; Marc
> Kleine-Budde <mkl@pengutronix.de>
> Subject: [PATCH net-next 11/39] can: flexcan: add auto stop mode for IMX93 to
> support wakeup
> 
> From: Haibo Chen <haibo.chen@nxp.com>
> 
> IMX93 do not contain a GPR to config the stop mode, it will set the flexcan into
> stop mode automatically once the ARM core go into low power mode (WFI
> instruct) and gate off the flexcan related clock automatically. But to let these
> logic work as expect, before ARM core go into low power mode, need to make
> sure the flexcan related clock keep on.
> 
> To support stop mode and wakeup feature on imx93, this patch add a new
> fsl_imx93_devtype_data to separate from imx8mp.
> 
> Signed-off-by: Haibo Chen <haibo.chen@nxp.com>
> Link:
> https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Flore.kern
> el.org%2Fall%2F1669116752-4260-1-git-send-email-haibo.chen%40nxp.com&a
> mp;data=05%7C01%7Chaibo.chen%40nxp.com%7C57db640faf1a4fe6ac9e08da
> dc34556c%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C0%7C638064414
> 581423735%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV
> 2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&amp;sdata=
> yc1AspfoVq%2BHKokRFxf06vcaqqP%2FtZUnpMnTaXL97y8%3D&amp;reserved=
> 0
> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>

Hi Marc,

Thanks for sending this patch.
But this patch has one runtime PM unbalance issue, I will fix this issue and send again these days.

Best Regards
Haibo Chen
> ---
>  drivers/net/can/flexcan/flexcan-core.c | 37 +++++++++++++++++++++++---
>  drivers/net/can/flexcan/flexcan.h      |  2 ++
>  2 files changed, 36 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/net/can/flexcan/flexcan-core.c
> b/drivers/net/can/flexcan/flexcan-core.c
> index 9bdadd716f4e..0aeff34e5ae1 100644
> --- a/drivers/net/can/flexcan/flexcan-core.c
> +++ b/drivers/net/can/flexcan/flexcan-core.c
> @@ -345,6 +345,15 @@ static struct flexcan_devtype_data
> fsl_imx8mp_devtype_data = {
>  		FLEXCAN_QUIRK_SUPPORT_RX_MAILBOX_RTR,
>  };
> 
> +static struct flexcan_devtype_data fsl_imx93_devtype_data = {
> +	.quirks = FLEXCAN_QUIRK_DISABLE_RXFG |
> FLEXCAN_QUIRK_ENABLE_EACEN_RRS |
> +		FLEXCAN_QUIRK_DISABLE_MECR |
> FLEXCAN_QUIRK_USE_RX_MAILBOX |
> +		FLEXCAN_QUIRK_BROKEN_PERR_STATE |
> FLEXCAN_QUIRK_AUTO_STOP_MODE |
> +		FLEXCAN_QUIRK_SUPPORT_FD | FLEXCAN_QUIRK_SUPPORT_ECC |
> +		FLEXCAN_QUIRK_SUPPORT_RX_MAILBOX |
> +		FLEXCAN_QUIRK_SUPPORT_RX_MAILBOX_RTR,
> +};
> +
>  static const struct flexcan_devtype_data fsl_vf610_devtype_data = {
>  	.quirks = FLEXCAN_QUIRK_DISABLE_RXFG |
> FLEXCAN_QUIRK_ENABLE_EACEN_RRS |
>  		FLEXCAN_QUIRK_DISABLE_MECR |
> FLEXCAN_QUIRK_USE_RX_MAILBOX | @@ -532,9 +541,14 @@ static inline int
> flexcan_enter_stop_mode(struct flexcan_priv *priv)
>  		ret = flexcan_stop_mode_enable_scfw(priv, true);
>  		if (ret < 0)
>  			return ret;
> -	} else {
> +	} else if (priv->devtype_data.quirks &
> +FLEXCAN_QUIRK_SETUP_STOP_MODE_GPR) {
>  		regmap_update_bits(priv->stm.gpr, priv->stm.req_gpr,
>  				   1 << priv->stm.req_bit, 1 << priv->stm.req_bit);
> +	} else if (priv->devtype_data.quirks & FLEXCAN_QUIRK_AUTO_STOP_MODE)
> {
> +		/* For the auto stop mode, software do nothing, hardware will cover
> +		 * all the operation automatically after system go into low power
> mode.
> +		 */
> +		return 0;
>  	}
> 
>  	return flexcan_low_power_enter_ack(priv);
> @@ -551,7 +565,7 @@ static inline int flexcan_exit_stop_mode(struct
> flexcan_priv *priv)
>  		ret = flexcan_stop_mode_enable_scfw(priv, false);
>  		if (ret < 0)
>  			return ret;
> -	} else {
> +	} else if (priv->devtype_data.quirks &
> +FLEXCAN_QUIRK_SETUP_STOP_MODE_GPR) {
>  		regmap_update_bits(priv->stm.gpr, priv->stm.req_gpr,
>  				   1 << priv->stm.req_bit, 0);
>  	}
> @@ -560,6 +574,12 @@ static inline int flexcan_exit_stop_mode(struct
> flexcan_priv *priv)
>  	reg_mcr &= ~FLEXCAN_MCR_SLF_WAK;
>  	priv->write(reg_mcr, &regs->mcr);
> 
> +	/* For the auto stop mode, hardware will exist stop mode
> +	 * automatically after system go out of low power mode.
> +	 */
> +	if (priv->devtype_data.quirks & FLEXCAN_QUIRK_AUTO_STOP_MODE)
> +		return 0;
> +
>  	return flexcan_low_power_exit_ack(priv);  }
> 
> @@ -1974,6 +1994,8 @@ static int flexcan_setup_stop_mode(struct
> platform_device *pdev)
>  		ret = flexcan_setup_stop_mode_scfw(pdev);
>  	else if (priv->devtype_data.quirks &
> FLEXCAN_QUIRK_SETUP_STOP_MODE_GPR)
>  		ret = flexcan_setup_stop_mode_gpr(pdev);
> +	else if (priv->devtype_data.quirks & FLEXCAN_QUIRK_AUTO_STOP_MODE)
> +		ret = 0;
>  	else
>  		/* return 0 directly if doesn't support stop mode feature */
>  		return 0;
> @@ -1992,6 +2014,7 @@ static int flexcan_setup_stop_mode(struct
> platform_device *pdev)  static const struct of_device_id flexcan_of_match[] =
> {
>  	{ .compatible = "fsl,imx8qm-flexcan", .data =
> &fsl_imx8qm_devtype_data, },
>  	{ .compatible = "fsl,imx8mp-flexcan", .data =
> &fsl_imx8mp_devtype_data, },
> +	{ .compatible = "fsl,imx93-flexcan", .data = &fsl_imx93_devtype_data,
> +},
>  	{ .compatible = "fsl,imx6q-flexcan", .data = &fsl_imx6q_devtype_data, },
>  	{ .compatible = "fsl,imx28-flexcan", .data = &fsl_imx28_devtype_data, },
>  	{ .compatible = "fsl,imx53-flexcan", .data = &fsl_imx25_devtype_data, },
> @@ -2299,8 +2322,16 @@ static int __maybe_unused
> flexcan_noirq_suspend(struct device *device)
>  	if (netif_running(dev)) {
>  		int err;
> 
> -		if (device_may_wakeup(device))
> +		if (device_may_wakeup(device)) {
>  			flexcan_enable_wakeup_irq(priv, true);
> +			/* For auto stop mode, need to keep the clock on before
> +			 * system go into low power mode. After system go into
> +			 * low power mode, hardware will config the flexcan into
> +			 * stop mode, and gate off the clock automatically.
> +			 */
> +			if (priv->devtype_data.quirks &
> FLEXCAN_QUIRK_AUTO_STOP_MODE)
> +				return 0;
> +		}
> 
>  		err = pm_runtime_force_suspend(device);
>  		if (err)
> diff --git a/drivers/net/can/flexcan/flexcan.h
> b/drivers/net/can/flexcan/flexcan.h
> index 025c3417031f..91402977780b 100644
> --- a/drivers/net/can/flexcan/flexcan.h
> +++ b/drivers/net/can/flexcan/flexcan.h
> @@ -68,6 +68,8 @@
>  #define FLEXCAN_QUIRK_SUPPORT_RX_MAILBOX_RTR BIT(15)
>  /* Device supports RX via FIFO */
>  #define FLEXCAN_QUIRK_SUPPORT_RX_FIFO BIT(16)
> +/* auto enter stop mode to support wakeup */ #define
> +FLEXCAN_QUIRK_AUTO_STOP_MODE BIT(17)
> 
>  struct flexcan_devtype_data {
>  	u32 quirks;		/* quirks needed for different IP cores */
> --
> 2.35.1
> 


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

* Re: RE: [PATCH net-next 11/39] can: flexcan: add auto stop mode for IMX93 to support wakeup
  2022-12-13  2:22   ` Bough Chen
@ 2022-12-13  8:11     ` Marc Kleine-Budde
  0 siblings, 0 replies; 43+ messages in thread
From: Marc Kleine-Budde @ 2022-12-13  8:11 UTC (permalink / raw)
  To: Bough Chen; +Cc: netdev, davem, kuba, linux-can, kernel

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

On 13.12.2022 02:22:02, Bough Chen wrote:
> > -----Original Message-----
> > From: Marc Kleine-Budde <mkl@pengutronix.de>
> > Sent: 2022年12月12日 19:30
> > To: netdev@vger.kernel.org
> > Cc: davem@davemloft.net; kuba@kernel.org; linux-can@vger.kernel.org;
> > kernel@pengutronix.de; Bough Chen <haibo.chen@nxp.com>; Marc
> > Kleine-Budde <mkl@pengutronix.de>
> > Subject: [PATCH net-next 11/39] can: flexcan: add auto stop mode for IMX93 to
> > support wakeup
> > 
> > From: Haibo Chen <haibo.chen@nxp.com>
> > 
> > IMX93 do not contain a GPR to config the stop mode, it will set the flexcan into
> > stop mode automatically once the ARM core go into low power mode (WFI
> > instruct) and gate off the flexcan related clock automatically. But to let these
> > logic work as expect, before ARM core go into low power mode, need to make
> > sure the flexcan related clock keep on.
> > 
> > To support stop mode and wakeup feature on imx93, this patch add a new
> > fsl_imx93_devtype_data to separate from imx8mp.
> > 
> > Signed-off-by: Haibo Chen <haibo.chen@nxp.com>
> > Link:
> > https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Flore.kern
> > el.org%2Fall%2F1669116752-4260-1-git-send-email-haibo.chen%40nxp.com&a
> > mp;data=05%7C01%7Chaibo.chen%40nxp.com%7C57db640faf1a4fe6ac9e08da
> > dc34556c%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C0%7C638064414
> > 581423735%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV
> > 2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&amp;sdata=
> > yc1AspfoVq%2BHKokRFxf06vcaqqP%2FtZUnpMnTaXL97y8%3D&amp;reserved=
> > 0
> > Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
> 
> Hi Marc,
> 
> Thanks for sending this patch.
> But this patch has one runtime PM unbalance issue, I will fix this issue and send again these days.

It's in net-next now, please send an incremental patch.

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] 43+ messages in thread

end of thread, other threads:[~2022-12-13  8:12 UTC | newest]

Thread overview: 43+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-12 11:30 [PATCH net-next 0/39] pull-request: can-next 2022-12-12 Marc Kleine-Budde
2022-12-12 11:30 ` [PATCH net-next 01/39] can: kvaser_usb: kvaser_usb_set_bittiming(): fix redundant initialization warning for err Marc Kleine-Budde
2022-12-12 12:20   ` patchwork-bot+netdevbpf
2022-12-12 11:30 ` [PATCH net-next 02/39] can: kvaser_usb: kvaser_usb_set_{,data}bittiming(): remove empty lines in variable declaration Marc Kleine-Budde
2022-12-12 11:30 ` [PATCH net-next 03/39] can: rcar_canfd: rcar_canfd_probe: Add struct rcar_canfd_hw_info to driver data Marc Kleine-Budde
2022-12-12 11:30 ` [PATCH net-next 04/39] can: m_can: sort header inclusion alphabetically Marc Kleine-Budde
2022-12-12 11:30 ` [PATCH net-next 05/39] can: rcar_canfd: Add max_channels to struct rcar_canfd_hw_info Marc Kleine-Budde
2022-12-12 11:30 ` [PATCH net-next 06/39] can: rcar_canfd: Add shared_global_irqs " Marc Kleine-Budde
2022-12-12 11:30 ` [PATCH net-next 07/39] can: rcar_canfd: Add postdiv " Marc Kleine-Budde
2022-12-12 11:30 ` [PATCH net-next 08/39] can: rcar_canfd: Add multi_channel_irqs " Marc Kleine-Budde
2022-12-12 11:30 ` [PATCH net-next 09/39] can: ctucanfd: Drop obsolete dependency on COMPILE_TEST Marc Kleine-Budde
2022-12-12 11:30 ` [PATCH net-next 10/39] can: etas_es58x: sort the includes by alphabetic order Marc Kleine-Budde
2022-12-12 11:30 ` [PATCH net-next 11/39] can: flexcan: add auto stop mode for IMX93 to support wakeup Marc Kleine-Budde
2022-12-13  2:22   ` Bough Chen
2022-12-13  8:11     ` Marc Kleine-Budde
2022-12-12 11:30 ` [PATCH net-next 12/39] can: etas_es58x: add devlink support Marc Kleine-Budde
2022-12-12 11:30 ` [PATCH net-next 13/39] dt-bindings: can: fsl,flexcan: add imx93 compatible Marc Kleine-Budde
2022-12-12 11:30 ` [PATCH net-next 14/39] can: etas_es58x: add devlink port support Marc Kleine-Budde
2022-12-12 11:30 ` [PATCH net-next 15/39] dt-bindings: can: renesas,rcar-canfd: Document RZ/Five SoC Marc Kleine-Budde
2022-12-12 11:30 ` [PATCH net-next 16/39] USB: core: export usb_cache_string() Marc Kleine-Budde
2022-12-12 11:30 ` [PATCH net-next 17/39] can: c_can: use devm_platform_get_and_ioremap_resource() Marc Kleine-Budde
2022-12-12 11:30 ` [PATCH net-next 18/39] net: devlink: add DEVLINK_INFO_VERSION_GENERIC_FW_BOOTLOADER Marc Kleine-Budde
2022-12-12 11:30 ` [PATCH net-next 19/39] can: etas_es58x: export product information through devlink_ops::info_get() Marc Kleine-Budde
2022-12-12 11:30 ` [PATCH net-next 20/39] can: etas_es58x: remove es58x_get_product_info() Marc Kleine-Budde
2022-12-12 11:30 ` [PATCH net-next 21/39] Documentation: devlink: add devlink documentation for the etas_es58x driver Marc Kleine-Budde
2022-12-12 11:30 ` [PATCH net-next 22/39] can: ucan: use strscpy() to instead of strncpy() Marc Kleine-Budde
2022-12-12 11:30 ` [PATCH net-next 23/39] net: af_can: remove useless parameter 'err' in 'can_rx_register()' Marc Kleine-Budde
2022-12-12 11:30 ` [PATCH net-next 24/39] can: ucan: remove unused ucan_priv::intf Marc Kleine-Budde
2022-12-12 11:30 ` [PATCH net-next 25/39] can: gs_usb: remove gs_can::iface Marc Kleine-Budde
2022-12-12 11:30 ` [PATCH net-next 26/39] can: m_can: Call the RAM init directly from m_can_chip_config Marc Kleine-Budde
2022-12-12 11:30 ` [PATCH net-next 27/39] can: raw: add support for SO_MARK Marc Kleine-Budde
2022-12-12 11:30 ` [PATCH net-next 28/39] dt-bindings: can: renesas,rcar-canfd: Fix number of channels for R-Car V3U Marc Kleine-Budde
2022-12-12 11:30 ` [PATCH net-next 29/39] can: m_can: Eliminate double read of TXFQS in tx_handler Marc Kleine-Budde
2022-12-12 11:30 ` [PATCH net-next 30/39] can: m_can: Avoid reading irqstatus twice Marc Kleine-Budde
2022-12-12 11:30 ` [PATCH net-next 31/39] can: m_can: Read register PSR only on error Marc Kleine-Budde
2022-12-12 11:30 ` [PATCH net-next 32/39] can: m_can: Count TXE FIFO getidx in the driver Marc Kleine-Budde
2022-12-12 11:30 ` [PATCH net-next 33/39] can: m_can: Count read getindex " Marc Kleine-Budde
2022-12-12 11:30 ` [PATCH net-next 34/39] can: m_can: Batch acknowledge transmit events Marc Kleine-Budde
2022-12-12 11:30 ` [PATCH net-next 35/39] can: m_can: Batch acknowledge rx fifo Marc Kleine-Budde
2022-12-12 11:30 ` [PATCH net-next 36/39] can: tcan4x5x: Remove invalid write in clear_interrupts Marc Kleine-Budde
2022-12-12 11:30 ` [PATCH net-next 37/39] can: tcan4x5x: Fix use of register error status mask Marc Kleine-Budde
2022-12-12 11:30 ` [PATCH net-next 38/39] can: tcan4x5x: Fix register range of first two blocks Marc Kleine-Budde
2022-12-12 11:30 ` [PATCH net-next 39/39] can: tcan4x5x: Specify separate read/write ranges Marc Kleine-Budde

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).