netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* pull-request: can 2020-11-18
@ 2020-11-18 16:04 Marc Kleine-Budde
  2020-11-18 16:04 ` [net 1/4] can: kvaser_pciefd: Fix KCAN bittiming limits Marc Kleine-Budde
                   ` (4 more replies)
  0 siblings, 5 replies; 7+ messages in thread
From: Marc Kleine-Budde @ 2020-11-18 16:04 UTC (permalink / raw)
  To: netdev; +Cc: davem, kuba, linux-can, kernel

Hello Jakub, hello David,

here's a pull request for net/master consisting of 4 patches for net/master,

Jimmy Assarsson provides two patches for the kvaser_pciefd and kvaser_usb
drivers, where the can_bittiming_const are fixed.

The next patch is by me and fixes an erroneous flexcan_transceiver_enable()
during bus-off recovery in the flexcan driver.

Jarkko Nikula's patch for the m_can driver fixes the IRQ handler to only
process the interrupts if the device is not suspended.

regards,
Marc

P.S.: Can you merge net/master into net-next/master after merging this pull
request?

---

The following changes since commit c09c8a27b9baa417864b9adc3228b10ae5eeec93:

  ipv4: use IS_ENABLED instead of ifdef (2020-11-17 17:02:03 -0800)

are available in the Git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/mkl/linux-can.git tags/linux-can-fixes-for-5.10-20201118

for you to fetch changes up to a1f634463aaf2c94dfa13001dbdea011303124cc:

  can: m_can: process interrupt only when not runtime suspended (2020-11-18 16:37:32 +0100)

----------------------------------------------------------------
linux-can-fixes-for-5.10-20201118

----------------------------------------------------------------
Jarkko Nikula (1):
      can: m_can: process interrupt only when not runtime suspended

Jimmy Assarsson (2):
      can: kvaser_pciefd: Fix KCAN bittiming limits
      can: kvaser_usb: kvaser_usb_hydra: Fix KCAN bittiming limits

Marc Kleine-Budde (1):
      can: flexcan: flexcan_chip_start(): fix erroneous flexcan_transceiver_enable() during bus-off recovery

 drivers/net/can/flexcan.c                         | 18 +++++++++---------
 drivers/net/can/kvaser_pciefd.c                   |  4 ++--
 drivers/net/can/m_can/m_can.c                     |  2 ++
 drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c |  2 +-
 4 files changed, 14 insertions(+), 12 deletions(-)



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

* [net 1/4] can: kvaser_pciefd: Fix KCAN bittiming limits
  2020-11-18 16:04 pull-request: can 2020-11-18 Marc Kleine-Budde
@ 2020-11-18 16:04 ` Marc Kleine-Budde
  2020-11-18 16:04 ` [net 2/4] can: kvaser_usb: kvaser_usb_hydra: " Marc Kleine-Budde
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Marc Kleine-Budde @ 2020-11-18 16:04 UTC (permalink / raw)
  To: netdev; +Cc: davem, kuba, linux-can, kernel, Jimmy Assarsson, Marc Kleine-Budde

From: Jimmy Assarsson <extja@kvaser.com>

Use correct bittiming limits for the KCAN CAN controller.

Fixes: 26ad340e582d ("can: kvaser_pciefd: Add driver for Kvaser PCIEcan devices")
Signed-off-by: Jimmy Assarsson <extja@kvaser.com>
Link: https://lore.kernel.org/r/20201115163027.16851-1-jimmyassarsson@gmail.com
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 drivers/net/can/kvaser_pciefd.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/can/kvaser_pciefd.c b/drivers/net/can/kvaser_pciefd.c
index 6f766918211a..72acd1ba162d 100644
--- a/drivers/net/can/kvaser_pciefd.c
+++ b/drivers/net/can/kvaser_pciefd.c
@@ -287,12 +287,12 @@ struct kvaser_pciefd_tx_packet {
 static const struct can_bittiming_const kvaser_pciefd_bittiming_const = {
 	.name = KVASER_PCIEFD_DRV_NAME,
 	.tseg1_min = 1,
-	.tseg1_max = 255,
+	.tseg1_max = 512,
 	.tseg2_min = 1,
 	.tseg2_max = 32,
 	.sjw_max = 16,
 	.brp_min = 1,
-	.brp_max = 4096,
+	.brp_max = 8192,
 	.brp_inc = 1,
 };
 

base-commit: c09c8a27b9baa417864b9adc3228b10ae5eeec93
-- 
2.29.2


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

* [net 2/4] can: kvaser_usb: kvaser_usb_hydra: Fix KCAN bittiming limits
  2020-11-18 16:04 pull-request: can 2020-11-18 Marc Kleine-Budde
  2020-11-18 16:04 ` [net 1/4] can: kvaser_pciefd: Fix KCAN bittiming limits Marc Kleine-Budde
@ 2020-11-18 16:04 ` Marc Kleine-Budde
  2020-11-18 16:04 ` [net 3/4] can: flexcan: flexcan_chip_start(): fix erroneous flexcan_transceiver_enable() during bus-off recovery Marc Kleine-Budde
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Marc Kleine-Budde @ 2020-11-18 16:04 UTC (permalink / raw)
  To: netdev; +Cc: davem, kuba, linux-can, kernel, Jimmy Assarsson, Marc Kleine-Budde

From: Jimmy Assarsson <extja@kvaser.com>

Use correct bittiming limits for the KCAN CAN controller.

Fixes: aec5fb2268b7 ("can: kvaser_usb: Add support for Kvaser USB hydra family")
Signed-off-by: Jimmy Assarsson <extja@kvaser.com>
Link: https://lore.kernel.org/r/20201115163027.16851-2-jimmyassarsson@gmail.com
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c b/drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c
index 7ab87a758754..218fadc91155 100644
--- a/drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c
+++ b/drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c
@@ -367,7 +367,7 @@ static const struct can_bittiming_const kvaser_usb_hydra_kcan_bittiming_c = {
 	.tseg2_max = 32,
 	.sjw_max = 16,
 	.brp_min = 1,
-	.brp_max = 4096,
+	.brp_max = 8192,
 	.brp_inc = 1,
 };
 
-- 
2.29.2


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

* [net 3/4] can: flexcan: flexcan_chip_start(): fix erroneous flexcan_transceiver_enable() during bus-off recovery
  2020-11-18 16:04 pull-request: can 2020-11-18 Marc Kleine-Budde
  2020-11-18 16:04 ` [net 1/4] can: kvaser_pciefd: Fix KCAN bittiming limits Marc Kleine-Budde
  2020-11-18 16:04 ` [net 2/4] can: kvaser_usb: kvaser_usb_hydra: " Marc Kleine-Budde
@ 2020-11-18 16:04 ` Marc Kleine-Budde
  2020-11-18 16:04 ` [net 4/4] can: m_can: process interrupt only when not runtime suspended Marc Kleine-Budde
  2020-11-19  1:52 ` pull-request: can 2020-11-18 Jakub Kicinski
  4 siblings, 0 replies; 7+ messages in thread
From: Marc Kleine-Budde @ 2020-11-18 16:04 UTC (permalink / raw)
  To: netdev; +Cc: davem, kuba, linux-can, kernel, Marc Kleine-Budde

If the CAN controller goes into bus off, the do_set_mode() callback with
CAN_MODE_START can be used to recover the controller, which then calls
flexcan_chip_start(). If configured, this is done automatically by the
framework or manually by the user.

In flexcan_chip_start() there is an explicit call to
flexcan_transceiver_enable(), which does a regulator_enable() on the
transceiver regulator. This results in a net usage counter increase, as there
is no corresponding flexcan_transceiver_disable() in the bus off code path.
This further leads to the transceiver stuck enabled, even if the CAN interface
is shut down.

To fix this problem the
flexcan_transceiver_enable()/flexcan_transceiver_disable() are moved out of
flexcan_chip_start()/flexcan_chip_stop() into flexcan_open()/flexcan_close().

Fixes: e955cead0311 ("CAN: Add Flexcan CAN controller driver")
Link: https://lore.kernel.org/r/20201118150148.2664024-1-mkl@pengutronix.de
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 drivers/net/can/flexcan.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/net/can/flexcan.c b/drivers/net/can/flexcan.c
index d6a9cf0e9b60..99e5f272205d 100644
--- a/drivers/net/can/flexcan.c
+++ b/drivers/net/can/flexcan.c
@@ -1567,14 +1567,10 @@ static int flexcan_chip_start(struct net_device *dev)
 		priv->write(reg_ctrl2, &regs->ctrl2);
 	}
 
-	err = flexcan_transceiver_enable(priv);
-	if (err)
-		goto out_chip_disable;
-
 	/* synchronize with the can bus */
 	err = flexcan_chip_unfreeze(priv);
 	if (err)
-		goto out_transceiver_disable;
+		goto out_chip_disable;
 
 	priv->can.state = CAN_STATE_ERROR_ACTIVE;
 
@@ -1592,8 +1588,6 @@ static int flexcan_chip_start(struct net_device *dev)
 
 	return 0;
 
- out_transceiver_disable:
-	flexcan_transceiver_disable(priv);
  out_chip_disable:
 	flexcan_chip_disable(priv);
 	return err;
@@ -1623,7 +1617,6 @@ static int __flexcan_chip_stop(struct net_device *dev, bool disable_on_error)
 	priv->write(priv->reg_ctrl_default & ~FLEXCAN_CTRL_ERR_ALL,
 		    &regs->ctrl);
 
-	flexcan_transceiver_disable(priv);
 	priv->can.state = CAN_STATE_STOPPED;
 
 	return 0;
@@ -1665,10 +1658,14 @@ static int flexcan_open(struct net_device *dev)
 	if (err)
 		goto out_runtime_put;
 
-	err = request_irq(dev->irq, flexcan_irq, IRQF_SHARED, dev->name, dev);
+	err = flexcan_transceiver_enable(priv);
 	if (err)
 		goto out_close;
 
+	err = request_irq(dev->irq, flexcan_irq, IRQF_SHARED, dev->name, dev);
+	if (err)
+		goto out_transceiver_disable;
+
 	if (priv->can.ctrlmode & CAN_CTRLMODE_FD)
 		priv->mb_size = sizeof(struct flexcan_mb) + CANFD_MAX_DLEN;
 	else
@@ -1720,6 +1717,8 @@ static int flexcan_open(struct net_device *dev)
 	can_rx_offload_del(&priv->offload);
  out_free_irq:
 	free_irq(dev->irq, dev);
+ out_transceiver_disable:
+	flexcan_transceiver_disable(priv);
  out_close:
 	close_candev(dev);
  out_runtime_put:
@@ -1738,6 +1737,7 @@ static int flexcan_close(struct net_device *dev)
 
 	can_rx_offload_del(&priv->offload);
 	free_irq(dev->irq, dev);
+	flexcan_transceiver_disable(priv);
 
 	close_candev(dev);
 	pm_runtime_put(priv->dev);
-- 
2.29.2


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

* [net 4/4] can: m_can: process interrupt only when not runtime suspended
  2020-11-18 16:04 pull-request: can 2020-11-18 Marc Kleine-Budde
                   ` (2 preceding siblings ...)
  2020-11-18 16:04 ` [net 3/4] can: flexcan: flexcan_chip_start(): fix erroneous flexcan_transceiver_enable() during bus-off recovery Marc Kleine-Budde
@ 2020-11-18 16:04 ` Marc Kleine-Budde
  2020-11-19  1:52 ` pull-request: can 2020-11-18 Jakub Kicinski
  4 siblings, 0 replies; 7+ messages in thread
From: Marc Kleine-Budde @ 2020-11-18 16:04 UTC (permalink / raw)
  To: netdev; +Cc: davem, kuba, linux-can, kernel, Jarkko Nikula, Marc Kleine-Budde

From: Jarkko Nikula <jarkko.nikula@linux.intel.com>

Avoid processing bogus interrupt statuses when the HW is runtime suspended and
the M_CAN_IR register read may get all bits 1's. Handler can be called if the
interrupt request is shared with other peripherals or at the end of free_irq().

Therefore check the runtime suspended status before processing.

Fixes: cdf8259d6573 ("can: m_can: Add PM Support")
Signed-off-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
Link: https://lore.kernel.org/r/20200915134715.696303-1-jarkko.nikula@linux.intel.com
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 drivers/net/can/m_can/m_can.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/can/m_can/m_can.c b/drivers/net/can/m_can/m_can.c
index e7264043f79a..f3fc37e96b08 100644
--- a/drivers/net/can/m_can/m_can.c
+++ b/drivers/net/can/m_can/m_can.c
@@ -956,6 +956,8 @@ static irqreturn_t m_can_isr(int irq, void *dev_id)
 	struct net_device_stats *stats = &dev->stats;
 	u32 ir;
 
+	if (pm_runtime_suspended(cdev->dev))
+		return IRQ_NONE;
 	ir = m_can_read(cdev, M_CAN_IR);
 	if (!ir)
 		return IRQ_NONE;
-- 
2.29.2


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

* Re: pull-request: can 2020-11-18
  2020-11-18 16:04 pull-request: can 2020-11-18 Marc Kleine-Budde
                   ` (3 preceding siblings ...)
  2020-11-18 16:04 ` [net 4/4] can: m_can: process interrupt only when not runtime suspended Marc Kleine-Budde
@ 2020-11-19  1:52 ` Jakub Kicinski
  2020-11-19  7:10   ` Marc Kleine-Budde
  4 siblings, 1 reply; 7+ messages in thread
From: Jakub Kicinski @ 2020-11-19  1:52 UTC (permalink / raw)
  To: Marc Kleine-Budde; +Cc: netdev, davem, linux-can, kernel

On Wed, 18 Nov 2020 17:04:10 +0100 Marc Kleine-Budde wrote:
> Hello Jakub, hello David,
> 
> here's a pull request for net/master consisting of 4 patches for net/master,
> 
> Jimmy Assarsson provides two patches for the kvaser_pciefd and kvaser_usb
> drivers, where the can_bittiming_const are fixed.
> 
> The next patch is by me and fixes an erroneous flexcan_transceiver_enable()
> during bus-off recovery in the flexcan driver.
> 
> Jarkko Nikula's patch for the m_can driver fixes the IRQ handler to only
> process the interrupts if the device is not suspended.

Pulled, thanks!

> P.S.: Can you merge net/master into net-next/master after merging this pull
> request?

That usually happens after Linus pulls from net, I will send a PR to him
tomorrow, and then merge net -> net-next. Hope that works for you!

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

* Re: pull-request: can 2020-11-18
  2020-11-19  1:52 ` pull-request: can 2020-11-18 Jakub Kicinski
@ 2020-11-19  7:10   ` Marc Kleine-Budde
  0 siblings, 0 replies; 7+ messages in thread
From: Marc Kleine-Budde @ 2020-11-19  7:10 UTC (permalink / raw)
  To: Jakub Kicinski; +Cc: netdev, davem, kernel, linux-can


[-- Attachment #1.1: Type: text/plain, Size: 636 bytes --]

On 11/19/20 2:52 AM, Jakub Kicinski wrote:
>> P.S.: Can you merge net/master into net-next/master after merging this pull
>> request?
> 
> That usually happens after Linus pulls from net, I will send a PR to him
> tomorrow, and then merge net -> net-next. Hope that works for you!

Yes, fine with me. I wasn't aware of the exact details.

Thanks,
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: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

end of thread, other threads:[~2020-11-19  7:11 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-18 16:04 pull-request: can 2020-11-18 Marc Kleine-Budde
2020-11-18 16:04 ` [net 1/4] can: kvaser_pciefd: Fix KCAN bittiming limits Marc Kleine-Budde
2020-11-18 16:04 ` [net 2/4] can: kvaser_usb: kvaser_usb_hydra: " Marc Kleine-Budde
2020-11-18 16:04 ` [net 3/4] can: flexcan: flexcan_chip_start(): fix erroneous flexcan_transceiver_enable() during bus-off recovery Marc Kleine-Budde
2020-11-18 16:04 ` [net 4/4] can: m_can: process interrupt only when not runtime suspended Marc Kleine-Budde
2020-11-19  1:52 ` pull-request: can 2020-11-18 Jakub Kicinski
2020-11-19  7:10   ` 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).