Commit 49344462 authored by Paolo Abeni's avatar Paolo Abeni

Merge tag 'linux-can-next-for-6.9-20240220' of...

Merge tag 'linux-can-next-for-6.9-20240220' of git://git.kernel.org/pub/scm/linux/kernel/git/mkl/linux-can-next

Marc Kleine-Budde says:

====================
pull-request: can-next 2024-02-20

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

The first patch is by Francesco Dolcini and removes a redundant check
for pm_clock_support from the m_can driver.

Martin Hundebøll contributes 3 patches to the m_can/tcan4x5x driver to
allow resume upon RX of a CAN frame.

3 patches by Srinivas Goud add support for ECC statistics to the
xilinx_can driver.

The last 2 patches are by Oliver Hartkopp and me, target the CAN RAW
protocol and fix an error in the getsockopt() for CAN-XL introduced in
the previous pull request to net-next (linux-can-next-for-6.9-20240213).

linux-can-next-for-6.9-20240220

* tag 'linux-can-next-for-6.9-20240220' of git://git.kernel.org/pub/scm/linux/kernel/git/mkl/linux-can-next:
  can: raw: raw_getsockopt(): reduce scope of err
  can: raw: fix getsockopt() for new CAN_RAW_XL_VCID_OPTS
  can: xilinx_can: Add ethtool stats interface for ECC errors
  can: xilinx_can: Add ECC support
  dt-bindings: can: xilinx_can: Add 'xlnx,has-ecc' optional property
  can: tcan4x5x: support resuming from rx interrupt signal
  can: m_can: allow keeping the transceiver running in suspend
  dt-bindings: can: tcan4x5x: Document the wakeup-source flag
  can: m_can: remove redundant check for pm_clock_support
====================

Link: https://lore.kernel.org/r/20240220085130.2936533-1-mkl@pengutronix.deSigned-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
parents 219eee9c 00bf80c4
...@@ -28,6 +28,8 @@ Optional properties: ...@@ -28,6 +28,8 @@ Optional properties:
available with tcan4552/4553. available with tcan4552/4553.
- device-wake-gpios: Wake up GPIO to wake up the TCAN device. Not - device-wake-gpios: Wake up GPIO to wake up the TCAN device. Not
available with tcan4552/4553. available with tcan4552/4553.
- wakeup-source: Leave the chip running when suspended, and configure
the RX interrupt to wake up the device.
Example: Example:
tcan4x5x: tcan4x5x@0 { tcan4x5x: tcan4x5x@0 {
...@@ -42,4 +44,5 @@ tcan4x5x: tcan4x5x@0 { ...@@ -42,4 +44,5 @@ tcan4x5x: tcan4x5x@0 {
device-state-gpios = <&gpio3 21 GPIO_ACTIVE_HIGH>; device-state-gpios = <&gpio3 21 GPIO_ACTIVE_HIGH>;
device-wake-gpios = <&gpio1 15 GPIO_ACTIVE_HIGH>; device-wake-gpios = <&gpio1 15 GPIO_ACTIVE_HIGH>;
reset-gpios = <&gpio1 27 GPIO_ACTIVE_HIGH>; reset-gpios = <&gpio1 27 GPIO_ACTIVE_HIGH>;
wakeup-source;
}; };
...@@ -49,6 +49,10 @@ properties: ...@@ -49,6 +49,10 @@ properties:
resets: resets:
maxItems: 1 maxItems: 1
xlnx,has-ecc:
$ref: /schemas/types.yaml#/definitions/flag
description: CAN TX_OL, TX_TL and RX FIFOs have ECC support(AXI CAN)
required: required:
- compatible - compatible
- reg - reg
...@@ -137,6 +141,7 @@ examples: ...@@ -137,6 +141,7 @@ examples:
interrupts = <GIC_SPI 59 IRQ_TYPE_EDGE_RISING>; interrupts = <GIC_SPI 59 IRQ_TYPE_EDGE_RISING>;
tx-fifo-depth = <0x40>; tx-fifo-depth = <0x40>;
rx-fifo-depth = <0x40>; rx-fifo-depth = <0x40>;
xlnx,has-ecc;
}; };
- | - |
......
...@@ -2312,11 +2312,9 @@ int m_can_class_register(struct m_can_classdev *cdev) ...@@ -2312,11 +2312,9 @@ int m_can_class_register(struct m_can_classdev *cdev)
} }
} }
if (cdev->pm_clock_support) {
ret = m_can_clk_start(cdev); ret = m_can_clk_start(cdev);
if (ret) if (ret)
return ret; return ret;
}
if (cdev->is_peripheral) { if (cdev->is_peripheral) {
ret = can_rx_offload_add_manual(cdev->net, &cdev->offload, ret = can_rx_offload_add_manual(cdev->net, &cdev->offload,
...@@ -2384,7 +2382,15 @@ int m_can_class_suspend(struct device *dev) ...@@ -2384,7 +2382,15 @@ int m_can_class_suspend(struct device *dev)
if (netif_running(ndev)) { if (netif_running(ndev)) {
netif_stop_queue(ndev); netif_stop_queue(ndev);
netif_device_detach(ndev); netif_device_detach(ndev);
/* leave the chip running with rx interrupt enabled if it is
* used as a wake-up source.
*/
if (cdev->pm_wake_source)
m_can_write(cdev, M_CAN_IE, IR_RF0N);
else
m_can_stop(ndev); m_can_stop(ndev);
m_can_clk_stop(cdev); m_can_clk_stop(cdev);
} }
...@@ -2411,12 +2417,16 @@ int m_can_class_resume(struct device *dev) ...@@ -2411,12 +2417,16 @@ int m_can_class_resume(struct device *dev)
ret = m_can_clk_start(cdev); ret = m_can_clk_start(cdev);
if (ret) if (ret)
return ret; return ret;
if (cdev->pm_wake_source) {
m_can_write(cdev, M_CAN_IE, cdev->active_interrupts);
} else {
ret = m_can_start(ndev); ret = m_can_start(ndev);
if (ret) { if (ret) {
m_can_clk_stop(cdev); m_can_clk_stop(cdev);
return ret; return ret;
} }
}
netif_device_attach(ndev); netif_device_attach(ndev);
netif_start_queue(ndev); netif_start_queue(ndev);
......
...@@ -97,6 +97,7 @@ struct m_can_classdev { ...@@ -97,6 +97,7 @@ struct m_can_classdev {
u32 irqstatus; u32 irqstatus;
int pm_clock_support; int pm_clock_support;
int pm_wake_source;
int is_peripheral; int is_peripheral;
// Cached M_CAN_IE register content // Cached M_CAN_IE register content
......
...@@ -125,6 +125,7 @@ static int m_can_pci_probe(struct pci_dev *pci, const struct pci_device_id *id) ...@@ -125,6 +125,7 @@ static int m_can_pci_probe(struct pci_dev *pci, const struct pci_device_id *id)
mcan_class->dev = &pci->dev; mcan_class->dev = &pci->dev;
mcan_class->net->irq = pci_irq_vector(pci, 0); mcan_class->net->irq = pci_irq_vector(pci, 0);
mcan_class->pm_clock_support = 1; mcan_class->pm_clock_support = 1;
mcan_class->pm_wake_source = 0;
mcan_class->can.clock.freq = id->driver_data; mcan_class->can.clock.freq = id->driver_data;
mcan_class->ops = &m_can_pci_ops; mcan_class->ops = &m_can_pci_ops;
......
...@@ -139,6 +139,7 @@ static int m_can_plat_probe(struct platform_device *pdev) ...@@ -139,6 +139,7 @@ static int m_can_plat_probe(struct platform_device *pdev)
mcan_class->net->irq = irq; mcan_class->net->irq = irq;
mcan_class->pm_clock_support = 1; mcan_class->pm_clock_support = 1;
mcan_class->pm_wake_source = 0;
mcan_class->can.clock.freq = clk_get_rate(mcan_class->cclk); mcan_class->can.clock.freq = clk_get_rate(mcan_class->cclk);
mcan_class->dev = &pdev->dev; mcan_class->dev = &pdev->dev;
mcan_class->transceiver = transceiver; mcan_class->transceiver = transceiver;
......
...@@ -411,6 +411,7 @@ static int tcan4x5x_can_probe(struct spi_device *spi) ...@@ -411,6 +411,7 @@ static int tcan4x5x_can_probe(struct spi_device *spi)
priv->spi = spi; priv->spi = spi;
mcan_class->pm_clock_support = 0; mcan_class->pm_clock_support = 0;
mcan_class->pm_wake_source = device_property_read_bool(&spi->dev, "wakeup-source");
mcan_class->can.clock.freq = freq; mcan_class->can.clock.freq = freq;
mcan_class->dev = &spi->dev; mcan_class->dev = &spi->dev;
mcan_class->ops = &tcan4x5x_ops; mcan_class->ops = &tcan4x5x_ops;
...@@ -459,6 +460,9 @@ static int tcan4x5x_can_probe(struct spi_device *spi) ...@@ -459,6 +460,9 @@ static int tcan4x5x_can_probe(struct spi_device *spi)
goto out_power; goto out_power;
} }
if (mcan_class->pm_wake_source)
device_init_wakeup(&spi->dev, true);
ret = m_can_class_register(mcan_class); ret = m_can_class_register(mcan_class);
if (ret) { if (ret) {
dev_err(&spi->dev, "Failed registering m_can device %pe\n", dev_err(&spi->dev, "Failed registering m_can device %pe\n",
...@@ -487,6 +491,29 @@ static void tcan4x5x_can_remove(struct spi_device *spi) ...@@ -487,6 +491,29 @@ static void tcan4x5x_can_remove(struct spi_device *spi)
m_can_class_free_dev(priv->cdev.net); m_can_class_free_dev(priv->cdev.net);
} }
static int __maybe_unused tcan4x5x_suspend(struct device *dev)
{
struct m_can_classdev *cdev = dev_get_drvdata(dev);
struct spi_device *spi = to_spi_device(dev);
if (cdev->pm_wake_source)
enable_irq_wake(spi->irq);
return m_can_class_suspend(dev);
}
static int __maybe_unused tcan4x5x_resume(struct device *dev)
{
struct m_can_classdev *cdev = dev_get_drvdata(dev);
struct spi_device *spi = to_spi_device(dev);
int ret = m_can_class_resume(dev);
if (cdev->pm_wake_source)
disable_irq_wake(spi->irq);
return ret;
}
static const struct of_device_id tcan4x5x_of_match[] = { static const struct of_device_id tcan4x5x_of_match[] = {
{ {
.compatible = "ti,tcan4x5x", .compatible = "ti,tcan4x5x",
...@@ -505,11 +532,15 @@ static const struct spi_device_id tcan4x5x_id_table[] = { ...@@ -505,11 +532,15 @@ static const struct spi_device_id tcan4x5x_id_table[] = {
}; };
MODULE_DEVICE_TABLE(spi, tcan4x5x_id_table); MODULE_DEVICE_TABLE(spi, tcan4x5x_id_table);
static const struct dev_pm_ops tcan4x5x_pm_ops = {
SET_SYSTEM_SLEEP_PM_OPS(tcan4x5x_suspend, tcan4x5x_resume)
};
static struct spi_driver tcan4x5x_can_driver = { static struct spi_driver tcan4x5x_can_driver = {
.driver = { .driver = {
.name = KBUILD_MODNAME, .name = KBUILD_MODNAME,
.of_match_table = tcan4x5x_of_match, .of_match_table = tcan4x5x_of_match,
.pm = NULL, .pm = &tcan4x5x_pm_ops,
}, },
.id_table = tcan4x5x_id_table, .id_table = tcan4x5x_id_table,
.probe = tcan4x5x_can_probe, .probe = tcan4x5x_can_probe,
......
This diff is collapsed.
...@@ -756,7 +756,6 @@ static int raw_getsockopt(struct socket *sock, int level, int optname, ...@@ -756,7 +756,6 @@ static int raw_getsockopt(struct socket *sock, int level, int optname,
struct raw_sock *ro = raw_sk(sk); struct raw_sock *ro = raw_sk(sk);
int len; int len;
void *val; void *val;
int err = 0;
if (level != SOL_CAN_RAW) if (level != SOL_CAN_RAW)
return -EINVAL; return -EINVAL;
...@@ -766,7 +765,9 @@ static int raw_getsockopt(struct socket *sock, int level, int optname, ...@@ -766,7 +765,9 @@ static int raw_getsockopt(struct socket *sock, int level, int optname,
return -EINVAL; return -EINVAL;
switch (optname) { switch (optname) {
case CAN_RAW_FILTER: case CAN_RAW_FILTER: {
int err = 0;
lock_sock(sk); lock_sock(sk);
if (ro->count > 0) { if (ro->count > 0) {
int fsize = ro->count * sizeof(struct can_filter); int fsize = ro->count * sizeof(struct can_filter);
...@@ -791,7 +792,7 @@ static int raw_getsockopt(struct socket *sock, int level, int optname, ...@@ -791,7 +792,7 @@ static int raw_getsockopt(struct socket *sock, int level, int optname,
if (!err) if (!err)
err = put_user(len, optlen); err = put_user(len, optlen);
return err; return err;
}
case CAN_RAW_ERR_FILTER: case CAN_RAW_ERR_FILTER:
if (len > sizeof(can_err_mask_t)) if (len > sizeof(can_err_mask_t))
len = sizeof(can_err_mask_t); len = sizeof(can_err_mask_t);
...@@ -822,7 +823,9 @@ static int raw_getsockopt(struct socket *sock, int level, int optname, ...@@ -822,7 +823,9 @@ static int raw_getsockopt(struct socket *sock, int level, int optname,
val = &ro->xl_frames; val = &ro->xl_frames;
break; break;
case CAN_RAW_XL_VCID_OPTS: case CAN_RAW_XL_VCID_OPTS: {
int err = 0;
/* user space buffer to small for VCID opts? */ /* user space buffer to small for VCID opts? */
if (len < sizeof(ro->raw_vcid_opts)) { if (len < sizeof(ro->raw_vcid_opts)) {
/* return -ERANGE and needed space in optlen */ /* return -ERANGE and needed space in optlen */
...@@ -835,8 +838,10 @@ static int raw_getsockopt(struct socket *sock, int level, int optname, ...@@ -835,8 +838,10 @@ static int raw_getsockopt(struct socket *sock, int level, int optname,
if (copy_to_user(optval, &ro->raw_vcid_opts, len)) if (copy_to_user(optval, &ro->raw_vcid_opts, len))
err = -EFAULT; err = -EFAULT;
} }
break; if (!err)
err = put_user(len, optlen);
return err;
}
case CAN_RAW_JOIN_FILTERS: case CAN_RAW_JOIN_FILTERS:
if (len > sizeof(int)) if (len > sizeof(int))
len = sizeof(int); len = sizeof(int);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment