* [PATCH 3/3] arm/dts: Add nodes for flexcan devices present on LS1021A-Rev2 SoC
From: Pankaj Bansal @ 2017-11-10 10:17 UTC (permalink / raw)
To: wg, mkl, linux-can, robh+dt, mark.rutland, devicetree
Cc: V.Sethi, poonam.aggrwal, Pankaj Bansal, Bhupesh Sharma,
Sakar Arora
In-Reply-To: <1510309043-16777-1-git-send-email-pankaj.bansal@nxp.com>
This patch adds the device nodes for flexcan controller(s) present
on LS1021A-Rev2 SoC.
Signed-off-by: Pankaj Bansal <pankaj.bansal@nxp.com>
Signed-off-by: Bhupesh Sharma <bhupesh.sharma@freescale.com>
Signed-off-by: Sakar Arora <Sakar.Arora@freescale.com>
Reviewed-by: Zhengxiong Jin <Jason.Jin@freescale.com>
Reviewed-by: Poonam Aggrwal <poonam.aggrwal@nxp.com>
---
arch/arm/boot/dts/ls1021a-qds.dts | 16 +++++++++++++
arch/arm/boot/dts/ls1021a-twr.dts | 16 +++++++++++++
arch/arm/boot/dts/ls1021a.dtsi | 36 +++++++++++++++++++++++++++++
3 files changed, 68 insertions(+)
diff --git a/arch/arm/boot/dts/ls1021a-qds.dts b/arch/arm/boot/dts/ls1021a-qds.dts
index 9408753..4f211e3 100644
--- a/arch/arm/boot/dts/ls1021a-qds.dts
+++ b/arch/arm/boot/dts/ls1021a-qds.dts
@@ -331,3 +331,19 @@
&uart1 {
status = "okay";
};
+
+&can0 {
+ status = "okay";
+};
+
+&can1 {
+ status = "okay";
+};
+
+&can2 {
+ status = "disabled";
+};
+
+&can3 {
+ status = "disabled";
+};
diff --git a/arch/arm/boot/dts/ls1021a-twr.dts b/arch/arm/boot/dts/ls1021a-twr.dts
index a8b148a..7202d9c 100644
--- a/arch/arm/boot/dts/ls1021a-twr.dts
+++ b/arch/arm/boot/dts/ls1021a-twr.dts
@@ -243,3 +243,19 @@
&uart1 {
status = "okay";
};
+
+&can0 {
+ status = "okay";
+};
+
+&can1 {
+ status = "okay";
+};
+
+&can2 {
+ status = "disabled";
+};
+
+&can3 {
+ status = "disabled";
+};
diff --git a/arch/arm/boot/dts/ls1021a.dtsi b/arch/arm/boot/dts/ls1021a.dtsi
index 9319e1f..7789031 100644
--- a/arch/arm/boot/dts/ls1021a.dtsi
+++ b/arch/arm/boot/dts/ls1021a.dtsi
@@ -730,5 +730,41 @@
<0000 0 0 3 &gic GIC_SPI 191 IRQ_TYPE_LEVEL_HIGH>,
<0000 0 0 4 &gic GIC_SPI 193 IRQ_TYPE_LEVEL_HIGH>;
};
+
+ can0: can@2a70000 {
+ compatible = "fsl,ls1021ar2-flexcan";
+ reg = <0x0 0x2a70000 0x0 0x1000>;
+ interrupts = <GIC_SPI 126 IRQ_TYPE_LEVEL_HIGH>;
+ clocks = <&clockgen 4 1>, <&clockgen 4 1>;
+ clock-names = "ipg", "per";
+ big-endian;
+ };
+
+ can1: can@2a80000 {
+ compatible = "fsl,ls1021ar2-flexcan";
+ reg = <0x0 0x2a80000 0x0 0x1000>;
+ interrupts = <GIC_SPI 127 IRQ_TYPE_LEVEL_HIGH>;
+ clocks = <&clockgen 4 1>, <&clockgen 4 1>;
+ clock-names = "ipg", "per";
+ big-endian;
+ };
+
+ can2: can@2a90000 {
+ compatible = "fsl,ls1021ar2-flexcan";
+ reg = <0x0 0x2a90000 0x0 0x1000>;
+ interrupts = <GIC_SPI 128 IRQ_TYPE_LEVEL_HIGH>;
+ clocks = <&clockgen 4 1>, <&clockgen 4 1>;
+ clock-names = "ipg", "per";
+ big-endian;
+ };
+
+ can3: can@2aa0000 {
+ compatible = "fsl,ls1021ar2-flexcan";
+ reg = <0x0 0x2aa0000 0x0 0x1000>;
+ interrupts = <GIC_SPI 129 IRQ_TYPE_LEVEL_HIGH>;
+ clocks = <&clockgen 4 1>, <&clockgen 4 1>;
+ clock-names = "ipg", "per";
+ big-endian;
+ };
};
};
--
2.7.4
^ permalink raw reply related
* [PATCH 2/3] powerpc: dts: P1010: Add endianness property to flexcan node
From: Pankaj Bansal @ 2017-11-10 10:17 UTC (permalink / raw)
To: wg, mkl, linux-can, robh+dt, mark.rutland, devicetree
Cc: V.Sethi, poonam.aggrwal, Pankaj Bansal
In-Reply-To: <1510309043-16777-1-git-send-email-pankaj.bansal@nxp.com>
The flexcan driver assumed that flexcan controller is big endian for
powerpc architecture and little endian for other architectures.
But this is not universally true. flexcan controller can be little or
big endian on any architecture.
Therefore the flexcan driver has been modified to check for "big-endian"
device tree property for controllers that are big endian.
consequently add the property to freescale P1010 SOC device tree.
Signed-off-by: Pankaj Bansal <pankaj.bansal@nxp.com>
Reviewed-by: Poonam Aggrwal <poonam.aggrwal@nxp.com>
---
arch/powerpc/boot/dts/fsl/p1010si-post.dtsi | 2 ++
1 file changed, 2 insertions(+)
diff --git a/arch/powerpc/boot/dts/fsl/p1010si-post.dtsi b/arch/powerpc/boot/dts/fsl/p1010si-post.dtsi
index af12ead..1b4aafc 100644
--- a/arch/powerpc/boot/dts/fsl/p1010si-post.dtsi
+++ b/arch/powerpc/boot/dts/fsl/p1010si-post.dtsi
@@ -137,12 +137,14 @@
compatible = "fsl,p1010-flexcan";
reg = <0x1c000 0x1000>;
interrupts = <48 0x2 0 0>;
+ big-endian;
};
can1: can@1d000 {
compatible = "fsl,p1010-flexcan";
reg = <0x1d000 0x1000>;
interrupts = <61 0x2 0 0>;
+ big-endian;
};
L2: l2-cache-controller@20000 {
--
2.7.4
^ permalink raw reply related
* [PATCH 1/3] Documentation : can : flexcan : Add big-endian property to device tree
From: Pankaj Bansal @ 2017-11-10 10:17 UTC (permalink / raw)
To: wg, mkl, linux-can, robh+dt, mark.rutland, devicetree
Cc: V.Sethi, poonam.aggrwal, Pankaj Bansal
The FlexCAN controller can be modelled as little or big endian
depending on SOC design. This device tree property identifies the
controller endianness and the driver reads/writes controller registers
based on that.
This is optional property. i.e. if this property is not present in
device tree node then controller is assumed to be little endian. if
this property is present then controller is assumed to be big endian.
Signed-off-by: Pankaj Bansal <pankaj.bansal@nxp.com>
Reviewed-by: Poonam Aggrwal <poonam.aggrwal@nxp.com>
---
Documentation/devicetree/bindings/net/can/fsl-flexcan.txt | 3 +++
1 file changed, 3 insertions(+)
diff --git a/Documentation/devicetree/bindings/net/can/fsl-flexcan.txt b/Documentation/devicetree/bindings/net/can/fsl-flexcan.txt
index 56d6cc3..b9693c7 100644
--- a/Documentation/devicetree/bindings/net/can/fsl-flexcan.txt
+++ b/Documentation/devicetree/bindings/net/can/fsl-flexcan.txt
@@ -18,6 +18,8 @@ Optional properties:
- xceiver-supply: Regulator that powers the CAN transceiver
+- big-endian: This means the registers of FlexCAN controller are big endian
+
Example:
can@1c000 {
@@ -26,4 +28,5 @@ Example:
interrupts = <48 0x2>;
interrupt-parent = <&mpic>;
clock-frequency = <200000000>; // filled in by bootloader
+ big-endian;
};
--
2.7.4
^ permalink raw reply related
* [PATCH 2/2] can: flexcan: adding platform specific details for LS1021A
From: Pankaj Bansal @ 2017-11-10 9:59 UTC (permalink / raw)
To: wg, mkl, linux-can; +Cc: V.Sethi, poonam.aggrwal, Pankaj Bansal, Bhupesh Sharma
In-Reply-To: <1510307990-15418-1-git-send-email-pankaj.bansal@nxp.com>
This patch adds platform specific details for NXP SOC LS1021A
to the flexcan driver code.
Signed-off-by: Pankaj Bansal <pankaj.bansal@nxp.com>
Signed-off-by: Bhupesh Sharma <bhupesh.sharma@freescale.com>
Reviewed-by: Zhengxiong Jin <Jason.Jin@freescale.com>
Reviewed-by: Poonam Aggrwal <poonam.aggrwal@nxp.com>
---
drivers/net/can/flexcan.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/drivers/net/can/flexcan.c b/drivers/net/can/flexcan.c
index d4ce2df..d8cac4c 100644
--- a/drivers/net/can/flexcan.c
+++ b/drivers/net/can/flexcan.c
@@ -304,6 +304,12 @@ static const struct flexcan_devtype_data fsl_vf610_devtype_data = {
FLEXCAN_QUIRK_DISABLE_MECR | FLEXCAN_QUIRK_USE_OFF_TIMESTAMP,
};
+/* LS1021A-Rev2 has functional RX-FIFO mode
+ */
+static struct flexcan_devtype_data fsl_ls1021a_r2_devtype_data = {
+ .quirks = FLEXCAN_QUIRK_DISABLE_RXFG | FLEXCAN_QUIRK_DISABLE_MECR,
+};
+
static const struct can_bittiming_const flexcan_bittiming_const = {
.name = DRV_NAME,
.tseg1_min = 4,
@@ -1245,6 +1251,8 @@ static const struct of_device_id flexcan_of_match[] = {
{ .compatible = "fsl,imx28-flexcan", .data = &fsl_imx28_devtype_data, },
{ .compatible = "fsl,p1010-flexcan", .data = &fsl_p1010_devtype_data, },
{ .compatible = "fsl,vf610-flexcan", .data = &fsl_vf610_devtype_data, },
+ { .compatible = "fsl,ls1021ar2-flexcan",
+ .data = &fsl_ls1021a_r2_devtype_data, },
{ /* sentinel */ },
};
MODULE_DEVICE_TABLE(of, flexcan_of_match);
--
2.7.4
^ permalink raw reply related
* [PATCH 1/2] can: flexcan: Remodel FlexCAN register r/w APIs for big endian FlexCAN controllers.
From: Pankaj Bansal @ 2017-11-10 9:59 UTC (permalink / raw)
To: wg, mkl, linux-can
Cc: V.Sethi, poonam.aggrwal, Pankaj Bansal, Bhupesh Sharma,
Sakar Arora
The FlexCAN driver assumed that FlexCAN controller is big endian for
powerpc architecture and little endian for other architectures.
But this may not be the case. FlexCAN controller can be little or
big endian on any architecture. For e.g. NXP LS1021A ARM based SOC
has big endian FlexCAN controller.
Therefore, the driver has been modified to add a provision for both
types of controllers using an additional device tree property. Big
Endian controllers should have "big-endian" set in the device tree.
Signed-off-by: Pankaj Bansal <pankaj.bansal@nxp.com>
Signed-off-by: Bhupesh Sharma <bhupesh.sharma@freescale.com>
Signed-off-by: Sakar Arora <Sakar.Arora@freescale.com>
Reviewed-by: Zhengxiong Jin <Jason.Jin@freescale.com>
Reviewed-by: Poonam Aggrwal <poonam.aggrwal@nxp.com>
---
Tested on Arm32 based NXP LS1021A-TWR board (linux-can-next/master branch)
Tested on PowerPC based NXP P1010RDB board (after back porting to Freescale SDK 1.4 linux)
drivers/net/can/flexcan.c | 212 ++++++++++++++++++++----------------
1 file changed, 116 insertions(+), 96 deletions(-)
diff --git a/drivers/net/can/flexcan.c b/drivers/net/can/flexcan.c
index a13a489..d4ce2df 100644
--- a/drivers/net/can/flexcan.c
+++ b/drivers/net/can/flexcan.c
@@ -279,6 +279,10 @@ struct flexcan_priv {
struct clk *clk_per;
const struct flexcan_devtype_data *devtype_data;
struct regulator *reg_xceiver;
+
+ /* Read and Write APIs */
+ u32 (*read)(void __iomem *addr);
+ void (*write)(u32 val, void __iomem *addr);
};
static const struct flexcan_devtype_data fsl_p1010_devtype_data = {
@@ -312,39 +316,45 @@ static const struct can_bittiming_const flexcan_bittiming_const = {
.brp_inc = 1,
};
-/* Abstract off the read/write for arm versus ppc. This
- * assumes that PPC uses big-endian registers and everything
- * else uses little-endian registers, independent of CPU
- * endianness.
+/* FlexCAN module is essentially modelled as a little-endian IP in most
+ * SoCs, i.e the registers as well as the message buffer areas are
+ * implemented in a little-endian fashion.
+ *
+ * However there are some SoCs (e.g. LS1021A) which implement the FlexCAN
+ * module in a big-endian fashion (i.e the registers as well as the
+ * message buffer areas are implemented in a big-endian way).
+ *
+ * In addition, the FlexCAN module can be found on SoCs having ARM or
+ * PPC cores. So, we need to abstract off the register read/write
+ * functions, ensuring that these cater to all the combinations of module
+ * endianness and underlying CPU endianness.
*/
-#if defined(CONFIG_PPC)
-static inline u32 flexcan_read(void __iomem *addr)
+static inline u32 flexcan_read_le(void __iomem *addr)
{
- return in_be32(addr);
+ return ioread32(addr);
}
-static inline void flexcan_write(u32 val, void __iomem *addr)
+static inline void flexcan_write_le(u32 val, void __iomem *addr)
{
- out_be32(addr, val);
+ iowrite32(val, addr);
}
-#else
-static inline u32 flexcan_read(void __iomem *addr)
+
+static inline u32 flexcan_read_be(void __iomem *addr)
{
- return readl(addr);
+ return ioread32be(addr);
}
-static inline void flexcan_write(u32 val, void __iomem *addr)
+static inline void flexcan_write_be(u32 val, void __iomem *addr)
{
- writel(val, addr);
+ iowrite32be(val, addr);
}
-#endif
static inline void flexcan_error_irq_enable(const struct flexcan_priv *priv)
{
struct flexcan_regs __iomem *regs = priv->regs;
u32 reg_ctrl = (priv->reg_ctrl_default | FLEXCAN_CTRL_ERR_MSK);
- flexcan_write(reg_ctrl, ®s->ctrl);
+ priv->write(reg_ctrl, ®s->ctrl);
}
static inline void flexcan_error_irq_disable(const struct flexcan_priv *priv)
@@ -352,7 +362,7 @@ static inline void flexcan_error_irq_disable(const struct flexcan_priv *priv)
struct flexcan_regs __iomem *regs = priv->regs;
u32 reg_ctrl = (priv->reg_ctrl_default & ~FLEXCAN_CTRL_ERR_MSK);
- flexcan_write(reg_ctrl, ®s->ctrl);
+ priv->write(reg_ctrl, ®s->ctrl);
}
static inline int flexcan_transceiver_enable(const struct flexcan_priv *priv)
@@ -377,14 +387,14 @@ static int flexcan_chip_enable(struct flexcan_priv *priv)
unsigned int timeout = FLEXCAN_TIMEOUT_US / 10;
u32 reg;
- reg = flexcan_read(®s->mcr);
+ reg = priv->read(®s->mcr);
reg &= ~FLEXCAN_MCR_MDIS;
- flexcan_write(reg, ®s->mcr);
+ priv->write(reg, ®s->mcr);
- while (timeout-- && (flexcan_read(®s->mcr) & FLEXCAN_MCR_LPM_ACK))
+ while (timeout-- && (priv->read(®s->mcr) & FLEXCAN_MCR_LPM_ACK))
udelay(10);
- if (flexcan_read(®s->mcr) & FLEXCAN_MCR_LPM_ACK)
+ if (priv->read(®s->mcr) & FLEXCAN_MCR_LPM_ACK)
return -ETIMEDOUT;
return 0;
@@ -396,14 +406,14 @@ static int flexcan_chip_disable(struct flexcan_priv *priv)
unsigned int timeout = FLEXCAN_TIMEOUT_US / 10;
u32 reg;
- reg = flexcan_read(®s->mcr);
+ reg = priv->read(®s->mcr);
reg |= FLEXCAN_MCR_MDIS;
- flexcan_write(reg, ®s->mcr);
+ priv->write(reg, ®s->mcr);
- while (timeout-- && !(flexcan_read(®s->mcr) & FLEXCAN_MCR_LPM_ACK))
+ while (timeout-- && !(priv->read(®s->mcr) & FLEXCAN_MCR_LPM_ACK))
udelay(10);
- if (!(flexcan_read(®s->mcr) & FLEXCAN_MCR_LPM_ACK))
+ if (!(priv->read(®s->mcr) & FLEXCAN_MCR_LPM_ACK))
return -ETIMEDOUT;
return 0;
@@ -415,14 +425,14 @@ static int flexcan_chip_freeze(struct flexcan_priv *priv)
unsigned int timeout = 1000 * 1000 * 10 / priv->can.bittiming.bitrate;
u32 reg;
- reg = flexcan_read(®s->mcr);
+ reg = priv->read(®s->mcr);
reg |= FLEXCAN_MCR_HALT;
- flexcan_write(reg, ®s->mcr);
+ priv->write(reg, ®s->mcr);
- while (timeout-- && !(flexcan_read(®s->mcr) & FLEXCAN_MCR_FRZ_ACK))
+ while (timeout-- && !(priv->read(®s->mcr) & FLEXCAN_MCR_FRZ_ACK))
udelay(100);
- if (!(flexcan_read(®s->mcr) & FLEXCAN_MCR_FRZ_ACK))
+ if (!(priv->read(®s->mcr) & FLEXCAN_MCR_FRZ_ACK))
return -ETIMEDOUT;
return 0;
@@ -434,14 +444,14 @@ static int flexcan_chip_unfreeze(struct flexcan_priv *priv)
unsigned int timeout = FLEXCAN_TIMEOUT_US / 10;
u32 reg;
- reg = flexcan_read(®s->mcr);
+ reg = priv->read(®s->mcr);
reg &= ~FLEXCAN_MCR_HALT;
- flexcan_write(reg, ®s->mcr);
+ priv->write(reg, ®s->mcr);
- while (timeout-- && (flexcan_read(®s->mcr) & FLEXCAN_MCR_FRZ_ACK))
+ while (timeout-- && (priv->read(®s->mcr) & FLEXCAN_MCR_FRZ_ACK))
udelay(10);
- if (flexcan_read(®s->mcr) & FLEXCAN_MCR_FRZ_ACK)
+ if (priv->read(®s->mcr) & FLEXCAN_MCR_FRZ_ACK)
return -ETIMEDOUT;
return 0;
@@ -452,11 +462,11 @@ static int flexcan_chip_softreset(struct flexcan_priv *priv)
struct flexcan_regs __iomem *regs = priv->regs;
unsigned int timeout = FLEXCAN_TIMEOUT_US / 10;
- flexcan_write(FLEXCAN_MCR_SOFTRST, ®s->mcr);
- while (timeout-- && (flexcan_read(®s->mcr) & FLEXCAN_MCR_SOFTRST))
+ priv->write(FLEXCAN_MCR_SOFTRST, ®s->mcr);
+ while (timeout-- && (priv->read(®s->mcr) & FLEXCAN_MCR_SOFTRST))
udelay(10);
- if (flexcan_read(®s->mcr) & FLEXCAN_MCR_SOFTRST)
+ if (priv->read(®s->mcr) & FLEXCAN_MCR_SOFTRST)
return -ETIMEDOUT;
return 0;
@@ -467,7 +477,7 @@ static int __flexcan_get_berr_counter(const struct net_device *dev,
{
const struct flexcan_priv *priv = netdev_priv(dev);
struct flexcan_regs __iomem *regs = priv->regs;
- u32 reg = flexcan_read(®s->ecr);
+ u32 reg = priv->read(®s->ecr);
bec->txerr = (reg >> 0) & 0xff;
bec->rxerr = (reg >> 8) & 0xff;
@@ -523,24 +533,24 @@ static int flexcan_start_xmit(struct sk_buff *skb, struct net_device *dev)
if (cf->can_dlc > 0) {
data = be32_to_cpup((__be32 *)&cf->data[0]);
- flexcan_write(data, &priv->tx_mb->data[0]);
+ priv->write(data, &priv->tx_mb->data[0]);
}
if (cf->can_dlc > 3) {
data = be32_to_cpup((__be32 *)&cf->data[4]);
- flexcan_write(data, &priv->tx_mb->data[1]);
+ priv->write(data, &priv->tx_mb->data[1]);
}
can_put_echo_skb(skb, dev, 0);
- flexcan_write(can_id, &priv->tx_mb->can_id);
- flexcan_write(ctrl, &priv->tx_mb->can_ctrl);
+ priv->write(can_id, &priv->tx_mb->can_id);
+ priv->write(ctrl, &priv->tx_mb->can_ctrl);
/* Errata ERR005829 step8:
* Write twice INACTIVE(0x8) code to first MB.
*/
- flexcan_write(FLEXCAN_MB_CODE_TX_INACTIVE,
+ priv->write(FLEXCAN_MB_CODE_TX_INACTIVE,
&priv->tx_mb_reserved->can_ctrl);
- flexcan_write(FLEXCAN_MB_CODE_TX_INACTIVE,
+ priv->write(FLEXCAN_MB_CODE_TX_INACTIVE,
&priv->tx_mb_reserved->can_ctrl);
return NETDEV_TX_OK;
@@ -659,7 +669,7 @@ static unsigned int flexcan_mailbox_read(struct can_rx_offload *offload,
u32 code;
do {
- reg_ctrl = flexcan_read(&mb->can_ctrl);
+ reg_ctrl = priv->read(&mb->can_ctrl);
} while (reg_ctrl & FLEXCAN_MB_CODE_RX_BUSY_BIT);
/* is this MB empty? */
@@ -674,17 +684,17 @@ static unsigned int flexcan_mailbox_read(struct can_rx_offload *offload,
offload->dev->stats.rx_errors++;
}
} else {
- reg_iflag1 = flexcan_read(®s->iflag1);
+ reg_iflag1 = priv->read(®s->iflag1);
if (!(reg_iflag1 & FLEXCAN_IFLAG_RX_FIFO_AVAILABLE))
return 0;
- reg_ctrl = flexcan_read(&mb->can_ctrl);
+ reg_ctrl = priv->read(&mb->can_ctrl);
}
/* increase timstamp to full 32 bit */
*timestamp = reg_ctrl << 16;
- reg_id = flexcan_read(&mb->can_id);
+ reg_id = priv->read(&mb->can_id);
if (reg_ctrl & FLEXCAN_MB_CNT_IDE)
cf->can_id = ((reg_id >> 0) & CAN_EFF_MASK) | CAN_EFF_FLAG;
else
@@ -694,19 +704,19 @@ static unsigned int flexcan_mailbox_read(struct can_rx_offload *offload,
cf->can_id |= CAN_RTR_FLAG;
cf->can_dlc = get_can_dlc((reg_ctrl >> 16) & 0xf);
- *(__be32 *)(cf->data + 0) = cpu_to_be32(flexcan_read(&mb->data[0]));
- *(__be32 *)(cf->data + 4) = cpu_to_be32(flexcan_read(&mb->data[1]));
+ *(__be32 *)(cf->data + 0) = cpu_to_be32(priv->read(&mb->data[0]));
+ *(__be32 *)(cf->data + 4) = cpu_to_be32(priv->read(&mb->data[1]));
/* mark as read */
if (priv->devtype_data->quirks & FLEXCAN_QUIRK_USE_OFF_TIMESTAMP) {
/* Clear IRQ */
if (n < 32)
- flexcan_write(BIT(n), ®s->iflag1);
+ priv->write(BIT(n), ®s->iflag1);
else
- flexcan_write(BIT(n - 32), ®s->iflag2);
+ priv->write(BIT(n - 32), ®s->iflag2);
} else {
- flexcan_write(FLEXCAN_IFLAG_RX_FIFO_AVAILABLE, ®s->iflag1);
- flexcan_read(®s->timer);
+ priv->write(FLEXCAN_IFLAG_RX_FIFO_AVAILABLE, ®s->iflag1);
+ priv->read(®s->timer);
}
return 1;
@@ -718,8 +728,8 @@ static inline u64 flexcan_read_reg_iflag_rx(struct flexcan_priv *priv)
struct flexcan_regs __iomem *regs = priv->regs;
u32 iflag1, iflag2;
- iflag2 = flexcan_read(®s->iflag2) & priv->reg_imask2_default;
- iflag1 = flexcan_read(®s->iflag1) & priv->reg_imask1_default &
+ iflag2 = priv->read(®s->iflag2) & priv->reg_imask2_default;
+ iflag1 = priv->read(®s->iflag1) & priv->reg_imask1_default &
~FLEXCAN_IFLAG_MB(priv->tx_mb_idx);
return (u64)iflag2 << 32 | iflag1;
@@ -735,7 +745,7 @@ static irqreturn_t flexcan_irq(int irq, void *dev_id)
u32 reg_iflag1, reg_esr;
enum can_state last_state = priv->can.state;
- reg_iflag1 = flexcan_read(®s->iflag1);
+ reg_iflag1 = priv->read(®s->iflag1);
/* reception interrupt */
if (priv->devtype_data->quirks & FLEXCAN_QUIRK_USE_OFF_TIMESTAMP) {
@@ -758,7 +768,8 @@ static irqreturn_t flexcan_irq(int irq, void *dev_id)
/* FIFO overflow interrupt */
if (reg_iflag1 & FLEXCAN_IFLAG_RX_FIFO_OVERFLOW) {
handled = IRQ_HANDLED;
- flexcan_write(FLEXCAN_IFLAG_RX_FIFO_OVERFLOW, ®s->iflag1);
+ priv->write(FLEXCAN_IFLAG_RX_FIFO_OVERFLOW,
+ ®s->iflag1);
dev->stats.rx_over_errors++;
dev->stats.rx_errors++;
}
@@ -772,18 +783,18 @@ static irqreturn_t flexcan_irq(int irq, void *dev_id)
can_led_event(dev, CAN_LED_EVENT_TX);
/* after sending a RTR frame MB is in RX mode */
- flexcan_write(FLEXCAN_MB_CODE_TX_INACTIVE,
+ priv->write(FLEXCAN_MB_CODE_TX_INACTIVE,
&priv->tx_mb->can_ctrl);
- flexcan_write(FLEXCAN_IFLAG_MB(priv->tx_mb_idx), ®s->iflag1);
+ priv->write(FLEXCAN_IFLAG_MB(priv->tx_mb_idx), ®s->iflag1);
netif_wake_queue(dev);
}
- reg_esr = flexcan_read(®s->esr);
+ reg_esr = priv->read(®s->esr);
/* ACK all bus error and state change IRQ sources */
if (reg_esr & FLEXCAN_ESR_ALL_INT) {
handled = IRQ_HANDLED;
- flexcan_write(reg_esr & FLEXCAN_ESR_ALL_INT, ®s->esr);
+ priv->write(reg_esr & FLEXCAN_ESR_ALL_INT, ®s->esr);
}
/* state change interrupt or broken error state quirk fix is enabled */
@@ -845,7 +856,7 @@ static void flexcan_set_bittiming(struct net_device *dev)
struct flexcan_regs __iomem *regs = priv->regs;
u32 reg;
- reg = flexcan_read(®s->ctrl);
+ reg = priv->read(®s->ctrl);
reg &= ~(FLEXCAN_CTRL_PRESDIV(0xff) |
FLEXCAN_CTRL_RJW(0x3) |
FLEXCAN_CTRL_PSEG1(0x7) |
@@ -869,11 +880,11 @@ static void flexcan_set_bittiming(struct net_device *dev)
reg |= FLEXCAN_CTRL_SMP;
netdev_dbg(dev, "writing ctrl=0x%08x\n", reg);
- flexcan_write(reg, ®s->ctrl);
+ priv->write(reg, ®s->ctrl);
/* print chip status */
netdev_dbg(dev, "%s: mcr=0x%08x ctrl=0x%08x\n", __func__,
- flexcan_read(®s->mcr), flexcan_read(®s->ctrl));
+ priv->read(®s->mcr), priv->read(®s->ctrl));
}
/* flexcan_chip_start
@@ -912,7 +923,7 @@ static int flexcan_chip_start(struct net_device *dev)
* choose format C
* set max mailbox number
*/
- reg_mcr = flexcan_read(®s->mcr);
+ reg_mcr = priv->read(®s->mcr);
reg_mcr &= ~FLEXCAN_MCR_MAXMB(0xff);
reg_mcr |= FLEXCAN_MCR_FRZ | FLEXCAN_MCR_HALT | FLEXCAN_MCR_SUPV |
FLEXCAN_MCR_WRN_EN | FLEXCAN_MCR_SRX_DIS | FLEXCAN_MCR_IRMQ |
@@ -926,7 +937,7 @@ static int flexcan_chip_start(struct net_device *dev)
FLEXCAN_MCR_MAXMB(priv->tx_mb_idx);
}
netdev_dbg(dev, "%s: writing mcr=0x%08x", __func__, reg_mcr);
- flexcan_write(reg_mcr, ®s->mcr);
+ priv->write(reg_mcr, ®s->mcr);
/* CTRL
*
@@ -939,7 +950,7 @@ static int flexcan_chip_start(struct net_device *dev)
* enable bus off interrupt
* (== FLEXCAN_CTRL_ERR_STATE)
*/
- reg_ctrl = flexcan_read(®s->ctrl);
+ reg_ctrl = priv->read(®s->ctrl);
reg_ctrl &= ~FLEXCAN_CTRL_TSYN;
reg_ctrl |= FLEXCAN_CTRL_BOFF_REC | FLEXCAN_CTRL_LBUF |
FLEXCAN_CTRL_ERR_STATE;
@@ -959,45 +970,45 @@ static int flexcan_chip_start(struct net_device *dev)
/* leave interrupts disabled for now */
reg_ctrl &= ~FLEXCAN_CTRL_ERR_ALL;
netdev_dbg(dev, "%s: writing ctrl=0x%08x", __func__, reg_ctrl);
- flexcan_write(reg_ctrl, ®s->ctrl);
+ priv->write(reg_ctrl, ®s->ctrl);
if ((priv->devtype_data->quirks & FLEXCAN_QUIRK_ENABLE_EACEN_RRS)) {
- reg_ctrl2 = flexcan_read(®s->ctrl2);
+ reg_ctrl2 = priv->read(®s->ctrl2);
reg_ctrl2 |= FLEXCAN_CTRL2_EACEN | FLEXCAN_CTRL2_RRS;
- flexcan_write(reg_ctrl2, ®s->ctrl2);
+ priv->write(reg_ctrl2, ®s->ctrl2);
}
/* clear and invalidate all mailboxes first */
for (i = priv->tx_mb_idx; i < ARRAY_SIZE(regs->mb); i++) {
- flexcan_write(FLEXCAN_MB_CODE_RX_INACTIVE,
+ priv->write(FLEXCAN_MB_CODE_RX_INACTIVE,
®s->mb[i].can_ctrl);
}
if (priv->devtype_data->quirks & FLEXCAN_QUIRK_USE_OFF_TIMESTAMP) {
for (i = priv->offload.mb_first; i <= priv->offload.mb_last; i++)
- flexcan_write(FLEXCAN_MB_CODE_RX_EMPTY,
+ priv->write(FLEXCAN_MB_CODE_RX_EMPTY,
®s->mb[i].can_ctrl);
}
/* Errata ERR005829: mark first TX mailbox as INACTIVE */
- flexcan_write(FLEXCAN_MB_CODE_TX_INACTIVE,
+ priv->write(FLEXCAN_MB_CODE_TX_INACTIVE,
&priv->tx_mb_reserved->can_ctrl);
/* mark TX mailbox as INACTIVE */
- flexcan_write(FLEXCAN_MB_CODE_TX_INACTIVE,
+ priv->write(FLEXCAN_MB_CODE_TX_INACTIVE,
&priv->tx_mb->can_ctrl);
/* acceptance mask/acceptance code (accept everything) */
- flexcan_write(0x0, ®s->rxgmask);
- flexcan_write(0x0, ®s->rx14mask);
- flexcan_write(0x0, ®s->rx15mask);
+ priv->write(0x0, ®s->rxgmask);
+ priv->write(0x0, ®s->rx14mask);
+ priv->write(0x0, ®s->rx15mask);
if (priv->devtype_data->quirks & FLEXCAN_QUIRK_DISABLE_RXFG)
- flexcan_write(0x0, ®s->rxfgmask);
+ priv->write(0x0, ®s->rxfgmask);
/* clear acceptance filters */
for (i = 0; i < ARRAY_SIZE(regs->mb); i++)
- flexcan_write(0, ®s->rximr[i]);
+ priv->write(0, ®s->rximr[i]);
/* On Vybrid, disable memory error detection interrupts
* and freeze mode.
@@ -1010,16 +1021,16 @@ static int flexcan_chip_start(struct net_device *dev)
* and Correction of Memory Errors" to write to
* MECR register
*/
- reg_ctrl2 = flexcan_read(®s->ctrl2);
+ reg_ctrl2 = priv->read(®s->ctrl2);
reg_ctrl2 |= FLEXCAN_CTRL2_ECRWRE;
- flexcan_write(reg_ctrl2, ®s->ctrl2);
+ priv->write(reg_ctrl2, ®s->ctrl2);
- reg_mecr = flexcan_read(®s->mecr);
+ reg_mecr = priv->read(®s->mecr);
reg_mecr &= ~FLEXCAN_MECR_ECRWRDIS;
- flexcan_write(reg_mecr, ®s->mecr);
+ priv->write(reg_mecr, ®s->mecr);
reg_mecr &= ~(FLEXCAN_MECR_NCEFAFRZ | FLEXCAN_MECR_HANCEI_MSK |
FLEXCAN_MECR_FANCEI_MSK);
- flexcan_write(reg_mecr, ®s->mecr);
+ priv->write(reg_mecr, ®s->mecr);
}
err = flexcan_transceiver_enable(priv);
@@ -1035,14 +1046,14 @@ static int flexcan_chip_start(struct net_device *dev)
/* enable interrupts atomically */
disable_irq(dev->irq);
- flexcan_write(priv->reg_ctrl_default, ®s->ctrl);
- flexcan_write(priv->reg_imask1_default, ®s->imask1);
- flexcan_write(priv->reg_imask2_default, ®s->imask2);
+ priv->write(priv->reg_ctrl_default, ®s->ctrl);
+ priv->write(priv->reg_imask1_default, ®s->imask1);
+ priv->write(priv->reg_imask2_default, ®s->imask2);
enable_irq(dev->irq);
/* print chip status */
netdev_dbg(dev, "%s: reading mcr=0x%08x ctrl=0x%08x\n", __func__,
- flexcan_read(®s->mcr), flexcan_read(®s->ctrl));
+ priv->read(®s->mcr), priv->read(®s->ctrl));
return 0;
@@ -1067,9 +1078,9 @@ static void flexcan_chip_stop(struct net_device *dev)
flexcan_chip_disable(priv);
/* Disable all interrupts */
- flexcan_write(0, ®s->imask2);
- flexcan_write(0, ®s->imask1);
- flexcan_write(priv->reg_ctrl_default & ~FLEXCAN_CTRL_ERR_ALL,
+ priv->write(0, ®s->imask2);
+ priv->write(0, ®s->imask1);
+ priv->write(priv->reg_ctrl_default & ~FLEXCAN_CTRL_ERR_ALL,
®s->ctrl);
flexcan_transceiver_disable(priv);
@@ -1185,26 +1196,26 @@ static int register_flexcandev(struct net_device *dev)
err = flexcan_chip_disable(priv);
if (err)
goto out_disable_per;
- reg = flexcan_read(®s->ctrl);
+ reg = priv->read(®s->ctrl);
reg |= FLEXCAN_CTRL_CLK_SRC;
- flexcan_write(reg, ®s->ctrl);
+ priv->write(reg, ®s->ctrl);
err = flexcan_chip_enable(priv);
if (err)
goto out_chip_disable;
/* set freeze, halt and activate FIFO, restrict register access */
- reg = flexcan_read(®s->mcr);
+ reg = priv->read(®s->mcr);
reg |= FLEXCAN_MCR_FRZ | FLEXCAN_MCR_HALT |
FLEXCAN_MCR_FEN | FLEXCAN_MCR_SUPV;
- flexcan_write(reg, ®s->mcr);
+ priv->write(reg, ®s->mcr);
/* Currently we only support newer versions of this core
* featuring a RX hardware FIFO (although this driver doesn't
* make use of it on some cores). Older cores, found on some
* Coldfire derivates are not tested.
*/
- reg = flexcan_read(®s->mcr);
+ reg = priv->read(®s->mcr);
if (!(reg & FLEXCAN_MCR_FEN)) {
netdev_err(dev, "Could not enable RX FIFO, unsupported core\n");
err = -ENODEV;
@@ -1313,6 +1324,15 @@ static int flexcan_probe(struct platform_device *pdev)
dev->flags |= IFF_ECHO;
priv = netdev_priv(dev);
+
+ if (of_property_read_bool(pdev->dev.of_node, "big-endian")) {
+ priv->read = flexcan_read_be;
+ priv->write = flexcan_write_be;
+ } else {
+ priv->read = flexcan_read_le;
+ priv->write = flexcan_write_le;
+ }
+
priv->can.clock.freq = clock_freq;
priv->can.bittiming_const = &flexcan_bittiming_const;
priv->can.do_set_mode = flexcan_set_mode;
--
2.7.4
^ permalink raw reply related
* [PATCH] can: peak: Add support for new PCIe/M2 CAN FD interfaces
From: Stephane Grosjean @ 2017-11-09 13:42 UTC (permalink / raw)
To: Oliver Hartkopp; +Cc: linux-can Mailing List, Stephane Grosjean
This adds support for the following PEAK-System CAN FD interfaces:
PCAN-cPCIe FD CAN FD Interface for cPCI Serial (2 or 4 channels)
PCAN-PCIe/104-Express CAN FD Interface for PCIe/104-Express (1, 2 or 4 ch.)
PCAN-miniPCIe FD CAN FD Interface for PCIe Mini (1, 2 or 4 channels)
PCAN-PCIe FD OEM CAN FD Interface for PCIe OEM version (1, 2 or 4 ch.)
PCAN-M.2 CAN FD Interface for M.2 (1 or 2 channels)
Like the PCAN-PCIe FD interface, all of these boards run the same IP Core
that is able to handle CAN FD (see also http://www.peak-system.com).
Signed-off-by: Stephane Grosjean <s.grosjean@peak-system.com>
---
drivers/net/can/peak_canfd/peak_pciefd_main.c | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/drivers/net/can/peak_canfd/peak_pciefd_main.c b/drivers/net/can/peak_canfd/peak_pciefd_main.c
index 51c2d182a33a..b4efd711f824 100644
--- a/drivers/net/can/peak_canfd/peak_pciefd_main.c
+++ b/drivers/net/can/peak_canfd/peak_pciefd_main.c
@@ -29,14 +29,19 @@
#include "peak_canfd_user.h"
MODULE_AUTHOR("Stephane Grosjean <s.grosjean@peak-system.com>");
-MODULE_DESCRIPTION("Socket-CAN driver for PEAK PCAN PCIe FD family cards");
-MODULE_SUPPORTED_DEVICE("PEAK PCAN PCIe FD CAN cards");
+MODULE_DESCRIPTION("Socket-CAN driver for PEAK PCAN PCIe/M.2 FD family cards");
+MODULE_SUPPORTED_DEVICE("PEAK PCAN PCIe/M.2 FD CAN cards");
MODULE_LICENSE("GPL v2");
#define PCIEFD_DRV_NAME "peak_pciefd"
#define PEAK_PCI_VENDOR_ID 0x001c /* The PCI device and vendor IDs */
#define PEAK_PCIEFD_ID 0x0013 /* for PCIe slot cards */
+#define PCAN_CPCIEFD_ID 0x0014 /* for Compact-PCI Serial slot cards */
+#define PCAN_PCIE104FD_ID 0x0017 /* for PCIe-104 Express slot cards */
+#define PCAN_MINIPCIEFD_ID 0x0018 /* for mini-PCIe slot cards */
+#define PCAN_PCIEFD_OEM_ID 0x0019 /* for PCIe slot OEM cards */
+#define PCAN_M2_ID 0x001a /* for M2 slot cards */
/* PEAK PCIe board access description */
#define PCIEFD_BAR0_SIZE (64 * 1024)
@@ -203,6 +208,11 @@ struct pciefd_board {
/* supported device ids. */
static const struct pci_device_id peak_pciefd_tbl[] = {
{PEAK_PCI_VENDOR_ID, PEAK_PCIEFD_ID, PCI_ANY_ID, PCI_ANY_ID,},
+ {PEAK_PCI_VENDOR_ID, PCAN_CPCIEFD_ID, PCI_ANY_ID, PCI_ANY_ID,},
+ {PEAK_PCI_VENDOR_ID, PCAN_PCIE104FD_ID, PCI_ANY_ID, PCI_ANY_ID,},
+ {PEAK_PCI_VENDOR_ID, PCAN_MINIPCIEFD_ID, PCI_ANY_ID, PCI_ANY_ID,},
+ {PEAK_PCI_VENDOR_ID, PCAN_PCIEFD_OEM_ID, PCI_ANY_ID, PCI_ANY_ID,},
+ {PEAK_PCI_VENDOR_ID, PCAN_M2_ID, PCI_ANY_ID, PCI_ANY_ID,},
{0,}
};
--
2.14.1
^ permalink raw reply related
* Re: [PATCH 1/8] dt-bindings: can: rcar_can: document r8a774[35] can support
From: Geert Uytterhoeven @ 2017-11-07 15:26 UTC (permalink / raw)
To: Fabrizio Castro
Cc: Wolfgang Grandegger, Marc Kleine-Budde, Rob Herring, Mark Rutland,
Simon Horman, Geert Uytterhoeven,
linux-can-u79uwXL29TY76Z2rM5mHXA,
netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, Linux-Renesas,
Chris Paterson, Biju Das
In-Reply-To: <1510067449-17017-2-git-send-email-fabrizio.castro-kTT6dE0pTRh9uiUsa/gSgQ@public.gmane.org>
On Tue, Nov 7, 2017 at 4:10 PM, Fabrizio Castro
<fabrizio.castro-kTT6dE0pTRh9uiUsa/gSgQ@public.gmane.org> wrote:
> Document "renesas,can-r8a7743" and "renesas,can-r8a7745" compatible
> strings. Since the fallback compatible string ("renesas,rcar-gen2-can")
> activates the right code in the driver, no driver change is needed.
>
> Signed-off-by: Fabrizio Castro <fabrizio.castro-kTT6dE0pTRh9uiUsa/gSgQ@public.gmane.org>
> Reviewed-by: Biju Das <biju.das-kTT6dE0pTRh9uiUsa/gSgQ@public.gmane.org>
Reviewed-by: Geert Uytterhoeven <geert+renesas-gXvu3+zWzMSzQB+pC5nmwQ@public.gmane.org>
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert-Td1EMuHUCqxL1ZNQvxDV9g@public.gmane.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply
* [PATCH 1/8] dt-bindings: can: rcar_can: document r8a774[35] can support
From: Fabrizio Castro @ 2017-11-07 15:10 UTC (permalink / raw)
To: Wolfgang Grandegger, Marc Kleine-Budde, Rob Herring, Mark Rutland
Cc: Fabrizio Castro, Simon Horman, Geert Uytterhoeven, linux-can,
netdev, devicetree, linux-renesas-soc, Chris Paterson, Biju Das
In-Reply-To: <1510067449-17017-1-git-send-email-fabrizio.castro@bp.renesas.com>
Document "renesas,can-r8a7743" and "renesas,can-r8a7745" compatible
strings. Since the fallback compatible string ("renesas,rcar-gen2-can")
activates the right code in the driver, no driver change is needed.
Signed-off-by: Fabrizio Castro <fabrizio.castro@bp.renesas.com>
Reviewed-by: Biju Das <biju.das@bp.renesas.com>
---
Documentation/devicetree/bindings/net/can/rcar_can.txt | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/Documentation/devicetree/bindings/net/can/rcar_can.txt b/Documentation/devicetree/bindings/net/can/rcar_can.txt
index 06bb7cc..94a7f33 100644
--- a/Documentation/devicetree/bindings/net/can/rcar_can.txt
+++ b/Documentation/devicetree/bindings/net/can/rcar_can.txt
@@ -2,7 +2,9 @@ Renesas R-Car CAN controller Device Tree Bindings
-------------------------------------------------
Required properties:
-- compatible: "renesas,can-r8a7778" if CAN controller is a part of R8A7778 SoC.
+- compatible: "renesas,can-r8a7743" if CAN controller is a part of R8A7743 SoC.
+ "renesas,can-r8a7745" if CAN controller is a part of R8A7745 SoC.
+ "renesas,can-r8a7778" if CAN controller is a part of R8A7778 SoC.
"renesas,can-r8a7779" if CAN controller is a part of R8A7779 SoC.
"renesas,can-r8a7790" if CAN controller is a part of R8A7790 SoC.
"renesas,can-r8a7791" if CAN controller is a part of R8A7791 SoC.
@@ -12,7 +14,8 @@ Required properties:
"renesas,can-r8a7795" if CAN controller is a part of R8A7795 SoC.
"renesas,can-r8a7796" if CAN controller is a part of R8A7796 SoC.
"renesas,rcar-gen1-can" for a generic R-Car Gen1 compatible device.
- "renesas,rcar-gen2-can" for a generic R-Car Gen2 compatible device.
+ "renesas,rcar-gen2-can" for a generic R-Car Gen2 or RZ/G1
+ compatible device.
"renesas,rcar-gen3-can" for a generic R-Car Gen3 compatible device.
When compatible with the generic version, nodes must list the
SoC-specific version corresponding to the platform first
--
2.7.4
^ permalink raw reply related
* [PATCH 0/8] Add CAN support to iwg2[02]d
From: Fabrizio Castro @ 2017-11-07 15:10 UTC (permalink / raw)
To: Wolfgang Grandegger, Marc Kleine-Budde, Rob Herring, Mark Rutland,
Russell King, Laurent Pinchart, Geert Uytterhoeven, Linus Walleij
Cc: Fabrizio Castro, Simon Horman, Magnus Damm, linux-can, netdev,
devicetree, linux-arm-kernel, linux-renesas-soc, linux-gpio,
Chris Paterson, Biju Das
Hello,
this series delivers all of the changes necessary to add CAN bus
support to the:
* iW-RainboW-G22D SODIMM, and
* iW-RainboW-G20M-Qseven-RZG1M
development platforms, including documentation, pinctrl driver, SoC
specific device trees, and board specific device trees.
This work has been based and tested on top of:
renesas-devel-20171106-v4.14-rc8
Best regards,
Fabrizio Castro (8):
dt-bindings: can: rcar_can: document r8a774[35] can support
pinctrl: sh-pfc: r8a7745: Add CAN[01] support
ARM: dts: r8a7745: Add CAN[01] SoC support
ARM: dts: iwg22d-sodimm: Add can0 support to carrier board
ARM: dts: iwg22d-sodimm-dbhd-ca: Add can1 support to HDMI DB
ARM: dts: r8a7743: Add CAN[01] SoC support
ARM: dts: iwg20d-q7-common: Add can0 support to carrier board
ARM: dts: iwg20d-q7-dbcm-ca: Add can1 support to camera DB
.../devicetree/bindings/net/can/rcar_can.txt | 7 +-
arch/arm/boot/dts/iwg20d-q7-common.dtsi | 12 ++
arch/arm/boot/dts/iwg20d-q7-dbcm-ca.dtsi | 12 ++
arch/arm/boot/dts/r8a7743.dtsi | 36 +++++
.../arm/boot/dts/r8a7745-iwg22d-sodimm-dbhd-ca.dts | 12 ++
arch/arm/boot/dts/r8a7745-iwg22d-sodimm.dts | 12 ++
arch/arm/boot/dts/r8a7745.dtsi | 36 +++++
drivers/pinctrl/sh-pfc/pfc-r8a7794.c | 146 +++++++++++++++++++++
8 files changed, 271 insertions(+), 2 deletions(-)
--
2.7.4
^ permalink raw reply
* [PATCH net] Fixed NULL ptr deref in enqueue_to_backlog().
From: Stefan Kratochwil @ 2017-11-07 11:17 UTC (permalink / raw)
To: netdev; +Cc: wg, mkl, linux-can
In-Reply-To: <484ddb3d-4bb6-46d7-1d5c-3319cdc52d6f@cetitec.com>
[-- Attachment #1: Type: text/plain, Size: 7400 bytes --]
Hey folks,
I replaced the free_skb() call wit a dev_free_skb_any() and performed a
few regression tests on the machines available to me. I was neither able
to reproduce the crash while upping/downing can interfaces during
operation, nor could I observe problems with ethernet connections on my
target hardware (Renesas R-CAR, arm64, kernel 4.9) and on my local
machine (x86_64, upstream kernel net-next).
The patch in the attachment was created against net-next.
Please review.
Thanks :)
On 11/06/2017 12:17 PM, Stefan Kratochwil wrote:
> Hey folks,
>
> I probably found a bug in the function mentioned above which leads to a
> WARN_ON() and in many cases to a kernel panic. The problem occurs when a
> CAN bus interface is put down using 'ip link' during a tx operation. In
> this situation, a code path exists from within a tx interrupt through
> core/net/dev.c#enqueue_to_backlog() to the non interrupt-safe function
> 'kfree_skb()'. This situation always triggers the 'WARN_ON(in_irq))' in
> net/core/skbuff.c#skb_release_head_state(), and with some luck it leads
> to a NULL pointer dereference.
>
> I first found this code path in the 'rcar_canfd' driver (kernel 4.9.58),
> but almost every other CAN driver does the same thing, even in the most
> up-to-date kernel.
>
> Now, net/core/dev.c is pretty hot code, and I have no idea what happens
> if we would substitute the 'kfree_skb()' in the 'drop' case of
> 'enqueue_to_backlog()' with a 'dev_kfree_skb_any()'.
>
> Some time ago, there was an almost identical issue reported via Bugzilla
> (https://bugzilla.kernel.org/show_bug.cgi?id=114791), but it was
> abandoned without further comments.
>
> Also, an actual fix was applied which addressed a similar bug
> (https://patchwork.kernel.org/patch/5479931/).
>
> Looking forward for your opinions!
>
>
> [12150.231280] ------------[ cut here ]------------
> [12150.232363] rcar_canfd e66c0000.can canif1: bitrate error 0.0%
> [12150.243474] WARNING: CPU: 0 PID: 0 at
> /home/skr/build_snapshot/build/tmp/work-shared/box-m3ulcb/kernel-source/net/core/skbuff.c:654
> skb_release_head_state+0xe0/0xe8
> [12150.261301] Modules linked in: can_raw can rcar_canfd mcp251x ravb
> mdio_bitbang can_dev ipv6 autofs4
> [12150.271475]
> [12150.273902] CPU: 0 PID: 0 Comm: swapper/0 Tainted: G W
> 4.9.58-box #1
> [12150.282703] Hardware name: BOX based on Renesas M3ULCB (r8a7796) (DT)
> [12150.290728] task: ffff00000899f480 task.stack: ffff000008990000
> [12150.297625] PC is at skb_release_head_state+0xe0/0xe8
> [12150.303654] LR is at skb_release_all+0x14/0x30
> [12150.309072] pc : [<ffff000008618090>] lr : [<ffff000008618374>]
> pstate: 000001c5
> [12150.317469] sp : ffff8005fff21ac0
> [12150.321779] x29: ffff8005fff21ac0 x28: 000000000000000c
> [12150.328097] x27: ffff8005fa23e880 x26: 0000000000000087
> [12150.334390] x25: ffff8005fff21bc8 x24: 00000000000001c0
> [12150.340666] x23: ffff8005f59d7800 x22: ffff00000897d000
> [12150.346934] x21: ffff000008629530 x20: ffff00000897d780
> [12150.353192] x19: ffff8005f59d7800 x18: 000000000000000a
> [12150.359441] x17: 0000ffffa4e36c40 x16: ffff00000820a060
> [12150.365680] x15: 00002fd2dc895abe x14: 000d59e4c4b21f40
> [12150.371915] x13: 0000000007ed6b48 x12: 071c71c71c71c71c
> [12150.378141] x11: 00000000000000b5 x10: 0000000000000040
> [12150.384363] x9 : ffff8005fd002da0 x8 : ffff8005fd000028
> [12150.390578] x7 : 0000000000000000 x6 : 000cd24f19d1cf10
> [12150.396778] x5 : 0000000000000018 x4 : 000000000059ecb6
> [12150.402967] x3 : 0000000000000000 x2 : 0000000000000000
> [12150.409153] x1 : ffff000008616808 x0 : 0000000000010102
> [12150.415332]
> [12150.417661] ---[ end trace b157fa53318961ad ]---
> [12150.423133] Call trace:
> [12150.426427] Exception stack(0xffff8005fff218f0 to 0xffff8005fff21a20)
> [12150.433738] 18e0: ffff8005f59d7800
> 0001000000000000
> [12150.442471] 1900: ffff8005fff21ac0 ffff000008618090 ffff8005fff21950
> ffff00000862987c
> [12150.451227] 1920: ffff8005fa23e000 ffff8005f505c600 0000000000000080
> 0000000000000001
> [12150.460002] 1940: 0000000000000080 000000000abffe46 ffff8005fff21970
> ffff0000007afc68
> [12150.468801] 1960: ffff8005fa23e000 0000000000000001 ffff8005fff21a00
> ffff0000080ebdf0
> [12150.477613] 1980: ffff8005fc3c4880 ffff8005fce38800 0000000000010102
> ffff000008616808
> [12150.486445] 19a0: 0000000000000000 0000000000000000 000000000059ecb6
> 0000000000000018
> [12150.495297] 19c0: 000cd24f19d1cf10 0000000000000000 ffff8005fd000028
> ffff8005fd002da0
> [12150.504168] 19e0: 0000000000000040 00000000000000b5 071c71c71c71c71c
> 0000000007ed6b48
> [12150.513060] 1a00: 000d59e4c4b21f40 00002fd2dc895abe ffff00000820a060
> 0000ffffa4e36c40
> [12150.521977] [<ffff000008618090>] skb_release_head_state+0xe0/0xe8
> [12150.529178] [<ffff000008618374>] skb_release_all+0x14/0x30
> [12150.535777] [<ffff000008618158>] kfree_skb+0x38/0x108
> [12150.541953] [<ffff000008629530>] enqueue_to_backlog+0xb0/0x238
> [12150.548928] [<ffff0000086296f8>] netif_rx_internal+0x40/0x1a8
> [12150.555828] [<ffff00000862987c>] netif_rx+0x1c/0xb0
> [12150.561853] [<ffff0000007791fc>] can_get_echo_skb+0x3c/0x78 [can_dev]
> [12150.569445] [<ffff0000007af754>]
> rcar_canfd_channel_interrupt+0x114/0x718 [rcar_canfd]
> [12150.578490] [<ffff0000080ebdf0>] __handle_irq_event_percpu+0x58/0x240
> [12150.586020] [<ffff0000080ebff4>] handle_irq_event_percpu+0x1c/0x58
> [12150.593263] [<ffff0000080ec078>] handle_irq_event+0x48/0x78
> [12150.599868] [<ffff0000080ef9c8>] handle_fasteoi_irq+0xb8/0x1a0
> [12150.606722] [<ffff0000080eaf44>] generic_handle_irq+0x24/0x38
> [12150.613465] [<ffff0000080eb5a4>] __handle_domain_irq+0x5c/0xb8
> [12150.620284] [<ffff000008080ca8>] gic_handle_irq+0x58/0xb0
>
>
>
> ---
> Diese E-Mail wurde von Avast Antivirus-Software auf Viren geprüft.
> https://www.avast.com/antivirus
>
-------------------------------------------------------------------------------
Stefan Kratochwil, Software Engineer
CETITEC GmbH
Mannheimer Straße 17
D-75179 Pforzheim, Germany
Phone: +49 (0)7231-95688-78
Fax: +49 (0)7231-95688-65
Sitz der Gesellschaft: Pforzheim
Amtsgericht Mannheim: HRB 715734
Geschäftsführer: Thomas Keicher
-------------------------------------------------------------------------------
Hinweis/Note:
-------------------------------------------------------------------------------
Diese E-Mail enthaelt vertrauliche und/oder rechtlich geschuetzte
Informationen. Wenn Sie nicht der richtige Adressat sind oder
diese E-Mail irrtuemlich erhalten haben, informieren Sie bitte sofort
den Absender und loeschen Sie diese Mail. Das unerlaubte Speichern,
Kopieren sowie die unbefugte Weitergabe dieser Mail ist nicht ge-
stattet!
Vielen Dank.
-------------------------------------------------------------------------------
This e-mail may contain confidential and/or privileged information.
If you are not the intended recipient (or have received this e-mail
in error) please notify the sender immediately and delete this e-mail.
Any unauthorised copying, disclosure or distribution of the contents
in this e-mail is strictly forbidden!
Thank you.
-------------------------------------------------------------------------------
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Fixed-NULL-ptr-deref-in-enqueue_to_backlog.patch --]
[-- Type: text/x-patch; name="0001-Fixed-NULL-ptr-deref-in-enqueue_to_backlog.patch", Size: 1101 bytes --]
From 04ed880706fc9fdd6ecd284de47a40c40a091b84 Mon Sep 17 00:00:00 2001
From: Stefan Kratochwil <stefan.kratochwil@cetitec.com>
Date: Tue, 7 Nov 2017 11:48:16 +0100
Subject: [PATCH] Fixed NULL ptr deref in enqueue_to_backlog().
This function may be called from within an interrupt context, e.g. when
putting a CAN interface down while transmitting data. While free_skb()
is not interrupt safe, dev_free_skb_any() is.
See https://marc.info/?l=linux-netdev&m=150996705622284&w=2 for more
details.
Signed-off-by: Stefan Kratochwil <stefan.kratochwil@cetitec.com>
---
net/core/dev.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/net/core/dev.c b/net/core/dev.c
index 30b5fe32c525..6c3a5f1f72a8 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -3886,7 +3886,9 @@ static int enqueue_to_backlog(struct sk_buff *skb, int cpu,
local_irq_restore(flags);
atomic_long_inc(&skb->dev->rx_dropped);
- kfree_skb(skb);
+
+ /* We may have been called from within an IRQ context. */
+ dev_kfree_skb_any(skb);
return NET_RX_DROP;
}
--
2.15.0
^ permalink raw reply related
* Re: [PATCH v5] can: sun4i: fix overrun
From: Marc Kleine-Budde @ 2017-11-07 8:22 UTC (permalink / raw)
To: GBert, linux-can
In-Reply-To: <1509988616-19479-1-git-send-email-info@gerhard-bertelsmann.de>
[-- Attachment #1.1: Type: text/plain, Size: 804 bytes --]
On 11/06/2017 06:16 PM, GBert wrote:
> From: cb2begq <info@gerhard-bertelsmann.de>
>
> SUN4Is CAN IP has a 64 byte deep FIFO buffer. If the buffer is not drained
> fast enough (overrun) it's getting mangled. Already received frames are
> dropped - the data can't be restored.
>
> V5: ignore timeout error and add a comment
> V4: add error handling
> V3: fix compilation
> V2: no duplicate error reporting
>
>
> Signed-off-by: Gerhard Bertelsmann <info@gerhard-bertelsmann.de>
Applied to can.
tnx,
Marc
--
Pengutronix e.K. | Marc Kleine-Budde |
Industrial Linux Solutions | Phone: +49-231-2826-924 |
Vertretung West/Dortmund | Fax: +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686 | http://www.pengutronix.de |
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply
* Re: [PATCH v2] can: Use common error handling code in vxcan_newlink()
From: Marc Kleine-Budde @ 2017-11-07 8:21 UTC (permalink / raw)
To: SF Markus Elfring, Oliver Hartkopp, Wolfgang Grandegger,
linux-can, netdev@vger.kernel.org
Cc: LKML, kernel-janitors
In-Reply-To: <23fbbdba-fb11-a6bc-7d6a-4af43ef79503@users.sourceforge.net>
[-- Attachment #1.1: Type: text/plain, Size: 709 bytes --]
On 11/01/2017 03:16 PM, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Wed, 1 Nov 2017 14:56:15 +0100
>
> Add a jump target so that a bit of exception handling can be better reused
> at the end of this function.
>
> This issue was detected by using the Coccinelle software.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
applied to can-next.
Tnx,
Marc
--
Pengutronix e.K. | Marc Kleine-Budde |
Industrial Linux Solutions | Phone: +49-231-2826-924 |
Vertretung West/Dortmund | Fax: +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686 | http://www.pengutronix.de |
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply
* Fwd: CAN interface handling: possible bug in net/core/dev.c#enqueue_to_backlog()
From: Oliver Hartkopp @ 2017-11-06 20:26 UTC (permalink / raw)
To: Wolfgang Grandegger, Marc Kleine-Budde
Cc: linux-can@vger.kernel.org, Stefan Kratochwil
In-Reply-To: <484ddb3d-4bb6-46d7-1d5c-3319cdc52d6f@cetitec.com>
Hi Wolfgang and Marc,
found this post which Stefan evaluated and posted on netdev mailing list.
Even if this seems to be an issue that is likely to be solved in
net/core/dev.c we might take a look on this whether we can support here.
Best,
Oliver
-------- Forwarded Message --------
Subject: CAN interface handling: possible bug in
net/core/dev.c#enqueue_to_backlog()
Date: Mon, 6 Nov 2017 12:17:30 +0100
From: Stefan Kratochwil <stefan.kratochwil@cetitec.com>
To: netdev@vger.kernel.org
Hey folks,
I probably found a bug in the function mentioned above which leads to a
WARN_ON() and in many cases to a kernel panic. The problem occurs when a
CAN bus interface is put down using 'ip link' during a tx operation. In
this situation, a code path exists from within a tx interrupt through
core/net/dev.c#enqueue_to_backlog() to the non interrupt-safe function
'kfree_skb()'. This situation always triggers the 'WARN_ON(in_irq))' in
net/core/skbuff.c#skb_release_head_state(), and with some luck it leads
to a NULL pointer dereference.
I first found this code path in the 'rcar_canfd' driver (kernel 4.9.58),
but almost every other CAN driver does the same thing, even in the most
up-to-date kernel.
Now, net/core/dev.c is pretty hot code, and I have no idea what happens
if we would substitute the 'kfree_skb()' in the 'drop' case of
'enqueue_to_backlog()' with a 'dev_kfree_skb_any()'.
Some time ago, there was an almost identical issue reported via Bugzilla
(https://bugzilla.kernel.org/show_bug.cgi?id=114791), but it was
abandoned without further comments.
Also, an actual fix was applied which addressed a similar bug
(https://patchwork.kernel.org/patch/5479931/).
Looking forward for your opinions!
[12150.231280] ------------[ cut here ]------------
[12150.232363] rcar_canfd e66c0000.can canif1: bitrate error 0.0%
[12150.243474] WARNING: CPU: 0 PID: 0 at
/home/skr/build_snapshot/build/tmp/work-shared/box-m3ulcb/kernel-source/net/core/skbuff.c:654
skb_release_head_state+0xe0/0xe8
[12150.261301] Modules linked in: can_raw can rcar_canfd mcp251x ravb
mdio_bitbang can_dev ipv6 autofs4
[12150.271475]
[12150.273902] CPU: 0 PID: 0 Comm: swapper/0 Tainted: G W
4.9.58-box #1
[12150.282703] Hardware name: BOX based on Renesas M3ULCB (r8a7796) (DT)
[12150.290728] task: ffff00000899f480 task.stack: ffff000008990000
[12150.297625] PC is at skb_release_head_state+0xe0/0xe8
[12150.303654] LR is at skb_release_all+0x14/0x30
[12150.309072] pc : [<ffff000008618090>] lr : [<ffff000008618374>]
pstate: 000001c5
[12150.317469] sp : ffff8005fff21ac0
[12150.321779] x29: ffff8005fff21ac0 x28: 000000000000000c
[12150.328097] x27: ffff8005fa23e880 x26: 0000000000000087
[12150.334390] x25: ffff8005fff21bc8 x24: 00000000000001c0
[12150.340666] x23: ffff8005f59d7800 x22: ffff00000897d000
[12150.346934] x21: ffff000008629530 x20: ffff00000897d780
[12150.353192] x19: ffff8005f59d7800 x18: 000000000000000a
[12150.359441] x17: 0000ffffa4e36c40 x16: ffff00000820a060
[12150.365680] x15: 00002fd2dc895abe x14: 000d59e4c4b21f40
[12150.371915] x13: 0000000007ed6b48 x12: 071c71c71c71c71c
[12150.378141] x11: 00000000000000b5 x10: 0000000000000040
[12150.384363] x9 : ffff8005fd002da0 x8 : ffff8005fd000028
[12150.390578] x7 : 0000000000000000 x6 : 000cd24f19d1cf10
[12150.396778] x5 : 0000000000000018 x4 : 000000000059ecb6
[12150.402967] x3 : 0000000000000000 x2 : 0000000000000000
[12150.409153] x1 : ffff000008616808 x0 : 0000000000010102
[12150.415332]
[12150.417661] ---[ end trace b157fa53318961ad ]---
[12150.423133] Call trace:
[12150.426427] Exception stack(0xffff8005fff218f0 to 0xffff8005fff21a20)
[12150.433738] 18e0: ffff8005f59d7800
0001000000000000
[12150.442471] 1900: ffff8005fff21ac0 ffff000008618090 ffff8005fff21950
ffff00000862987c
[12150.451227] 1920: ffff8005fa23e000 ffff8005f505c600 0000000000000080
0000000000000001
[12150.460002] 1940: 0000000000000080 000000000abffe46 ffff8005fff21970
ffff0000007afc68
[12150.468801] 1960: ffff8005fa23e000 0000000000000001 ffff8005fff21a00
ffff0000080ebdf0
[12150.477613] 1980: ffff8005fc3c4880 ffff8005fce38800 0000000000010102
ffff000008616808
[12150.486445] 19a0: 0000000000000000 0000000000000000 000000000059ecb6
0000000000000018
[12150.495297] 19c0: 000cd24f19d1cf10 0000000000000000 ffff8005fd000028
ffff8005fd002da0
[12150.504168] 19e0: 0000000000000040 00000000000000b5 071c71c71c71c71c
0000000007ed6b48
[12150.513060] 1a00: 000d59e4c4b21f40 00002fd2dc895abe ffff00000820a060
0000ffffa4e36c40
[12150.521977] [<ffff000008618090>] skb_release_head_state+0xe0/0xe8
[12150.529178] [<ffff000008618374>] skb_release_all+0x14/0x30
[12150.535777] [<ffff000008618158>] kfree_skb+0x38/0x108
[12150.541953] [<ffff000008629530>] enqueue_to_backlog+0xb0/0x238
[12150.548928] [<ffff0000086296f8>] netif_rx_internal+0x40/0x1a8
[12150.555828] [<ffff00000862987c>] netif_rx+0x1c/0xb0
[12150.561853] [<ffff0000007791fc>] can_get_echo_skb+0x3c/0x78 [can_dev]
[12150.569445] [<ffff0000007af754>]
rcar_canfd_channel_interrupt+0x114/0x718 [rcar_canfd]
[12150.578490] [<ffff0000080ebdf0>] __handle_irq_event_percpu+0x58/0x240
[12150.586020] [<ffff0000080ebff4>] handle_irq_event_percpu+0x1c/0x58
[12150.593263] [<ffff0000080ec078>] handle_irq_event+0x48/0x78
[12150.599868] [<ffff0000080ef9c8>] handle_fasteoi_irq+0xb8/0x1a0
[12150.606722] [<ffff0000080eaf44>] generic_handle_irq+0x24/0x38
[12150.613465] [<ffff0000080eb5a4>] __handle_domain_irq+0x5c/0xb8
[12150.620284] [<ffff000008080ca8>] gic_handle_irq+0x58/0xb0
---
Diese E-Mail wurde von Avast Antivirus-Software auf Viren geprüft.
https://www.avast.com/antivirus
^ permalink raw reply
* [PATCH v5] can: sun4i: fix overrun
From: GBert @ 2017-11-06 17:16 UTC (permalink / raw)
To: linux-can; +Cc: cb2begq
In-Reply-To: <1509983842-18821-1-git-send-email-info@gerhard-bertelsmann.de>
From: cb2begq <info@gerhard-bertelsmann.de>
SUN4Is CAN IP has a 64 byte deep FIFO buffer. If the buffer is not drained
fast enough (overrun) it's getting mangled. Already received frames are
dropped - the data can't be restored.
V5: ignore timeout error and add a comment
V4: add error handling
V3: fix compilation
V2: no duplicate error reporting
Signed-off-by: Gerhard Bertelsmann <info@gerhard-bertelsmann.de>
---
drivers/net/can/sun4i_can.c | 12 ++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)
diff --git a/drivers/net/can/sun4i_can.c b/drivers/net/can/sun4i_can.c
index b0c8085..1d2d12e 100644
--- a/drivers/net/can/sun4i_can.c
+++ b/drivers/net/can/sun4i_can.c
@@ -539,6 +539,13 @@ static int sun4i_can_err(struct net_device *dev, u8 isrc, u8 status)
}
stats->rx_over_errors++;
stats->rx_errors++;
+
+ /* reset the CAN IP by entering reset mode
+ * ignoring timeout error
+ */
+ set_reset_mode(dev);
+ set_normal_mode(dev);
+
/* clear bit */
sun4i_can_write_cmdreg(priv, SUN4I_CMD_CLEAR_OR_FLAG);
}
@@ -653,8 +663,9 @@ static irqreturn_t sun4i_can_interrupt(int irq, void *dev_id)
netif_wake_queue(dev);
can_led_event(dev, CAN_LED_EVENT_TX);
}
- if (isrc & SUN4I_INT_RBUF_VLD) {
- /* receive interrupt */
+ if ((isrc & SUN4I_INT_RBUF_VLD) &&
+ !(isrc & SUN4I_INT_DATA_OR)) {
+ /* receive interrupt - don't read if overrun occurred */
while (status & SUN4I_STA_RBUF_RDY) {
/* RX buffer is not empty */
sun4i_can_rx(dev);
--
1.7.9.5
^ permalink raw reply related
* Re: [PATCH v4] can: sun4i: fix overrun
From: Marc Kleine-Budde @ 2017-11-06 16:09 UTC (permalink / raw)
To: GBert, linux-can
In-Reply-To: <1509983842-18821-1-git-send-email-info@gerhard-bertelsmann.de>
[-- Attachment #1.1: Type: text/plain, Size: 2388 bytes --]
On 11/06/2017 04:57 PM, GBert wrote:
> From: cb2begq <info@gerhard-bertelsmann.de>
>
> SUN4Is CAN IP has a 64 byte deep FIFO buffer. If the buffer is not drained
> fast enough (overrun) it's getting mangled. Already received frames are
> dropped - the data can't be restored.
>
> V4: add error handling
> V3: fix compilation
> V2: no duplicate error reporting
>
>
> Signed-off-by: Gerhard Bertelsmann <info@gerhard-bertelsmann.de>
>
> ---
> drivers/net/can/sun4i_can.c | 15 +++++++++++++--
> 1 file changed, 13 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/can/sun4i_can.c b/drivers/net/can/sun4i_can.c
> index b0c8085..1d2d12e 100644
> --- a/drivers/net/can/sun4i_can.c
> +++ b/drivers/net/can/sun4i_can.c
> @@ -539,6 +539,15 @@ static int sun4i_can_err(struct net_device *dev, u8 isrc, u8 status)
> }
> stats->rx_over_errors++;
> stats->rx_errors++;
> +
> + /* reset the CAN IP by entering reset mode */
> + err = set_reset_mode(dev);
> + if (err < 0)
> + return err;
> + err = set_normal_mode(dev);
> + if (err < 0)
> + return err;
If an skb has been allocated it's lost here.
However, in which state is the controller if the set_reset or set_normal
doesn't work? Maybe ignore the error altogether and just carry on? If
so, add ad comment stating that the only error can be a timeout and we
ignore the errors in that case.
See the caller of sun4i_can_err() which assumes the only error will be a
ENOMEM due to no skb.
> +
> /* clear bit */
> sun4i_can_write_cmdreg(priv, SUN4I_CMD_CLEAR_OR_FLAG);
> }
> @@ -653,8 +663,9 @@ static irqreturn_t sun4i_can_interrupt(int irq, void *dev_id)
> netif_wake_queue(dev);
> can_led_event(dev, CAN_LED_EVENT_TX);
> }
> - if (isrc & SUN4I_INT_RBUF_VLD) {
> - /* receive interrupt */
> + if ((isrc & SUN4I_INT_RBUF_VLD) &&
> + !(isrc & SUN4I_INT_DATA_OR)) {
> + /* receive interrupt - don't read if overrun occurred */
> while (status & SUN4I_STA_RBUF_RDY) {
> /* RX buffer is not empty */
> sun4i_can_rx(dev);
>
Marc
--
Pengutronix e.K. | Marc Kleine-Budde |
Industrial Linux Solutions | Phone: +49-231-2826-924 |
Vertretung West/Dortmund | Fax: +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686 | http://www.pengutronix.de |
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply
* [PATCH v4] can: sun4i: fix overrun
From: GBert @ 2017-11-06 15:57 UTC (permalink / raw)
To: linux-can; +Cc: cb2begq
In-Reply-To: <d834a10b-414b-2555-a268-39304dd622f3@pengutronix.de>
From: cb2begq <info@gerhard-bertelsmann.de>
SUN4Is CAN IP has a 64 byte deep FIFO buffer. If the buffer is not drained
fast enough (overrun) it's getting mangled. Already received frames are
dropped - the data can't be restored.
V4: add error handling
V3: fix compilation
V2: no duplicate error reporting
Signed-off-by: Gerhard Bertelsmann <info@gerhard-bertelsmann.de>
---
drivers/net/can/sun4i_can.c | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)
diff --git a/drivers/net/can/sun4i_can.c b/drivers/net/can/sun4i_can.c
index b0c8085..1d2d12e 100644
--- a/drivers/net/can/sun4i_can.c
+++ b/drivers/net/can/sun4i_can.c
@@ -539,6 +539,15 @@ static int sun4i_can_err(struct net_device *dev, u8 isrc, u8 status)
}
stats->rx_over_errors++;
stats->rx_errors++;
+
+ /* reset the CAN IP by entering reset mode */
+ err = set_reset_mode(dev);
+ if (err < 0)
+ return err;
+ err = set_normal_mode(dev);
+ if (err < 0)
+ return err;
+
/* clear bit */
sun4i_can_write_cmdreg(priv, SUN4I_CMD_CLEAR_OR_FLAG);
}
@@ -653,8 +663,9 @@ static irqreturn_t sun4i_can_interrupt(int irq, void *dev_id)
netif_wake_queue(dev);
can_led_event(dev, CAN_LED_EVENT_TX);
}
- if (isrc & SUN4I_INT_RBUF_VLD) {
- /* receive interrupt */
+ if ((isrc & SUN4I_INT_RBUF_VLD) &&
+ !(isrc & SUN4I_INT_DATA_OR)) {
+ /* receive interrupt - don't read if overrun occurred */
while (status & SUN4I_STA_RBUF_RDY) {
/* RX buffer is not empty */
sun4i_can_rx(dev);
--
1.7.9.5
^ permalink raw reply related
* Re: [PATCH v2] can: sun4i: fix overrun
From: Marc Kleine-Budde @ 2017-11-06 15:03 UTC (permalink / raw)
To: GBert, linux-can
In-Reply-To: <1509108411-9614-1-git-send-email-info@gerhard-bertelsmann.de>
[-- Attachment #1.1: Type: text/plain, Size: 1280 bytes --]
On 10/27/2017 02:46 PM, GBert wrote:
> From: Gerhard Bertelsmann <info@gerhard-bertelsmann.de>
>
> SUN4Is CAN IP has a 64 byte deep FIFO buffer. If the buffer is not drained
> fast enough (overrun) it's getting mangled. Already received frames are
> dropped - the data can't be restored.
>
> V2: no duplicate error reporting
Please don't forget your S-o-b.
> ---
> drivers/net/can/sun4i_can.c | 10 ++++++++--
> 1 file changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/can/sun4i_can.c b/drivers/net/can/sun4i_can.c
> index 68ef0a4..bcec511 100644
> --- a/drivers/net/can/sun4i_can.c
> +++ b/drivers/net/can/sun4i_can.c
> @@ -539,6 +539,11 @@ static int sun4i_can_err(struct net_device *dev, u8 isrc, u8 status)
> }
> stats->rx_over_errors++;
> stats->rx_errors++;
> +
> + /* reset the CAN IP by entering reset mode */
> + err = set_reset_mode(dev);
> + err = set_normal_mode(dev);
Please add the missing error handling here.
Marc
--
Pengutronix e.K. | Marc Kleine-Budde |
Industrial Linux Solutions | Phone: +49-231-2826-924 |
Vertretung West/Dortmund | Fax: +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686 | http://www.pengutronix.de |
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply
* Re: [PATCH 1/2] can: peak_usb: remove some 'struct timeval' users
From: Marc Kleine-Budde @ 2017-11-06 15:01 UTC (permalink / raw)
To: Arnd Bergmann, Wolfgang Grandegger
Cc: David S. Miller, Kees Cook, Allen Pais, Stephane Grosjean,
Johan Hovold, 추지호, linux-can, netdev,
linux-kernel
In-Reply-To: <20171103163220.3799742-1-arnd@arndb.de>
[-- Attachment #1.1: Type: text/plain, Size: 699 bytes --]
On 11/03/2017 05:31 PM, Arnd Bergmann wrote:
> We want to remove 'struct timeval' and related interfaces since this is
> generally not safe for use beyond 2038.
>
> For peak_usb, we can simplify the internal interface by using ktime_t
> directly. This should not change any behavior, but it avoids a few
> conversions.
>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Both applied to can-next.
Tnx,
Marc
--
Pengutronix e.K. | Marc Kleine-Budde |
Industrial Linux Solutions | Phone: +49-231-2826-924 |
Vertretung West/Dortmund | Fax: +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686 | http://www.pengutronix.de |
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply
* Re: [PATCH] can: c_can: don't indicate triple sampling support for D_CAN
From: Marc Kleine-Budde @ 2017-11-06 13:39 UTC (permalink / raw)
To: Richard Schütz, Wolfgang Grandegger, linux-can
In-Reply-To: <20171029120322.22197-1-rschuetz@uni-koblenz.de>
[-- Attachment #1.1: Type: text/plain, Size: 607 bytes --]
On 10/29/2017 01:03 PM, Richard Schütz wrote:
> The D_CAN controller doesn't provide a triple sampling mode, so don't set
> the CAN_CTRLMODE_3_SAMPLES flag in ctrlmode_supported. Currently enabling
> triple sampling is a no-op.
>
> Signed-off-by: Richard Schütz <rschuetz@uni-koblenz.de>
Applied to can.
tnx,
Marc
--
Pengutronix e.K. | Marc Kleine-Budde |
Industrial Linux Solutions | Phone: +49-231-2826-924 |
Vertretung West/Dortmund | Fax: +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686 | http://www.pengutronix.de |
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply
* [PATCH 1/2] can: peak_usb: remove some 'struct timeval' users
From: Arnd Bergmann @ 2017-11-03 16:31 UTC (permalink / raw)
To: Wolfgang Grandegger, Marc Kleine-Budde
Cc: Arnd Bergmann, David S. Miller, Kees Cook, Allen Pais,
Stephane Grosjean, Johan Hovold, 추지호,
linux-can, netdev, linux-kernel
We want to remove 'struct timeval' and related interfaces since this is
generally not safe for use beyond 2038.
For peak_usb, we can simplify the internal interface by using ktime_t
directly. This should not change any behavior, but it avoids a few
conversions.
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
drivers/net/can/usb/peak_usb/pcan_usb.c | 9 +++------
drivers/net/can/usb/peak_usb/pcan_usb_core.c | 15 +++++++--------
drivers/net/can/usb/peak_usb/pcan_usb_core.h | 3 +--
drivers/net/can/usb/peak_usb/pcan_usb_pro.c | 9 +++------
4 files changed, 14 insertions(+), 22 deletions(-)
diff --git a/drivers/net/can/usb/peak_usb/pcan_usb.c b/drivers/net/can/usb/peak_usb/pcan_usb.c
index 25a9b79cc42d..f530a80f5051 100644
--- a/drivers/net/can/usb/peak_usb/pcan_usb.c
+++ b/drivers/net/can/usb/peak_usb/pcan_usb.c
@@ -408,7 +408,6 @@ static int pcan_usb_decode_error(struct pcan_usb_msg_context *mc, u8 n,
{
struct sk_buff *skb;
struct can_frame *cf;
- struct timeval tv;
enum can_state new_state;
/* ignore this error until 1st ts received */
@@ -525,8 +524,8 @@ static int pcan_usb_decode_error(struct pcan_usb_msg_context *mc, u8 n,
if (status_len & PCAN_USB_STATUSLEN_TIMESTAMP) {
struct skb_shared_hwtstamps *hwts = skb_hwtstamps(skb);
- peak_usb_get_ts_tv(&mc->pdev->time_ref, mc->ts16, &tv);
- hwts->hwtstamp = timeval_to_ktime(tv);
+ peak_usb_get_ts_time(&mc->pdev->time_ref, mc->ts16,
+ &hwts->hwtstamp);
}
mc->netdev->stats.rx_packets++;
@@ -610,7 +609,6 @@ static int pcan_usb_decode_data(struct pcan_usb_msg_context *mc, u8 status_len)
u8 rec_len = status_len & PCAN_USB_STATUSLEN_DLC;
struct sk_buff *skb;
struct can_frame *cf;
- struct timeval tv;
struct skb_shared_hwtstamps *hwts;
skb = alloc_can_skb(mc->netdev, &cf);
@@ -658,9 +656,8 @@ static int pcan_usb_decode_data(struct pcan_usb_msg_context *mc, u8 status_len)
}
/* convert timestamp into kernel time */
- peak_usb_get_ts_tv(&mc->pdev->time_ref, mc->ts16, &tv);
hwts = skb_hwtstamps(skb);
- hwts->hwtstamp = timeval_to_ktime(tv);
+ peak_usb_get_ts_time(&mc->pdev->time_ref, mc->ts16, &hwts->hwtstamp);
/* update statistics */
mc->netdev->stats.rx_packets++;
diff --git a/drivers/net/can/usb/peak_usb/pcan_usb_core.c b/drivers/net/can/usb/peak_usb/pcan_usb_core.c
index 1ca76e03e965..695a75a9b4bb 100644
--- a/drivers/net/can/usb/peak_usb/pcan_usb_core.c
+++ b/drivers/net/can/usb/peak_usb/pcan_usb_core.c
@@ -148,11 +148,11 @@ void peak_usb_set_ts_now(struct peak_time_ref *time_ref, u32 ts_now)
/*
* compute timeval according to current ts and time_ref data
*/
-void peak_usb_get_ts_tv(struct peak_time_ref *time_ref, u32 ts,
- struct timeval *tv)
+void peak_usb_get_ts_time(struct peak_time_ref *time_ref, u32 ts, ktime_t *time)
{
/* protect from getting timeval before setting now */
if (time_ref->tv_host.tv_sec > 0) {
+ struct timeval tv;
u64 delta_us;
delta_us = ts - time_ref->ts_dev_2;
@@ -164,10 +164,11 @@ void peak_usb_get_ts_tv(struct peak_time_ref *time_ref, u32 ts,
delta_us *= time_ref->adapter->us_per_ts_scale;
delta_us >>= time_ref->adapter->us_per_ts_shift;
- *tv = time_ref->tv_host_0;
- peak_usb_add_us(tv, (u32)delta_us);
+ tv = time_ref->tv_host_0;
+ peak_usb_add_us(&tv, (u32)delta_us);
+ *time = timeval_to_ktime(tv);
} else {
- *tv = ktime_to_timeval(ktime_get());
+ *time = ktime_get();
}
}
@@ -178,10 +179,8 @@ int peak_usb_netif_rx(struct sk_buff *skb,
struct peak_time_ref *time_ref, u32 ts_low, u32 ts_high)
{
struct skb_shared_hwtstamps *hwts = skb_hwtstamps(skb);
- struct timeval tv;
- peak_usb_get_ts_tv(time_ref, ts_low, &tv);
- hwts->hwtstamp = timeval_to_ktime(tv);
+ peak_usb_get_ts_time(time_ref, ts_low, &hwts->hwtstamp);
return netif_rx(skb);
}
diff --git a/drivers/net/can/usb/peak_usb/pcan_usb_core.h b/drivers/net/can/usb/peak_usb/pcan_usb_core.h
index c01316cac354..b9a221ea7e5c 100644
--- a/drivers/net/can/usb/peak_usb/pcan_usb_core.h
+++ b/drivers/net/can/usb/peak_usb/pcan_usb_core.h
@@ -151,8 +151,7 @@ void peak_usb_init_time_ref(struct peak_time_ref *time_ref,
const struct peak_usb_adapter *adapter);
void peak_usb_update_ts_now(struct peak_time_ref *time_ref, u32 ts_now);
void peak_usb_set_ts_now(struct peak_time_ref *time_ref, u32 ts_now);
-void peak_usb_get_ts_tv(struct peak_time_ref *time_ref, u32 ts,
- struct timeval *tv);
+void peak_usb_get_ts_time(struct peak_time_ref *time_ref, u32 ts, ktime_t *tv);
int peak_usb_netif_rx(struct sk_buff *skb,
struct peak_time_ref *time_ref, u32 ts_low, u32 ts_high);
void peak_usb_async_complete(struct urb *urb);
diff --git a/drivers/net/can/usb/peak_usb/pcan_usb_pro.c b/drivers/net/can/usb/peak_usb/pcan_usb_pro.c
index bbdd6058cd2f..0105fbfea273 100644
--- a/drivers/net/can/usb/peak_usb/pcan_usb_pro.c
+++ b/drivers/net/can/usb/peak_usb/pcan_usb_pro.c
@@ -531,7 +531,6 @@ static int pcan_usb_pro_handle_canmsg(struct pcan_usb_pro_interface *usb_if,
struct net_device *netdev = dev->netdev;
struct can_frame *can_frame;
struct sk_buff *skb;
- struct timeval tv;
struct skb_shared_hwtstamps *hwts;
skb = alloc_can_skb(netdev, &can_frame);
@@ -549,9 +548,9 @@ static int pcan_usb_pro_handle_canmsg(struct pcan_usb_pro_interface *usb_if,
else
memcpy(can_frame->data, rx->data, can_frame->can_dlc);
- peak_usb_get_ts_tv(&usb_if->time_ref, le32_to_cpu(rx->ts32), &tv);
hwts = skb_hwtstamps(skb);
- hwts->hwtstamp = timeval_to_ktime(tv);
+ peak_usb_get_ts_time(&usb_if->time_ref, le32_to_cpu(rx->ts32),
+ &hwts->hwtstamp);
netdev->stats.rx_packets++;
netdev->stats.rx_bytes += can_frame->can_dlc;
@@ -571,7 +570,6 @@ static int pcan_usb_pro_handle_error(struct pcan_usb_pro_interface *usb_if,
enum can_state new_state = CAN_STATE_ERROR_ACTIVE;
u8 err_mask = 0;
struct sk_buff *skb;
- struct timeval tv;
struct skb_shared_hwtstamps *hwts;
/* nothing should be sent while in BUS_OFF state */
@@ -667,9 +665,8 @@ static int pcan_usb_pro_handle_error(struct pcan_usb_pro_interface *usb_if,
dev->can.state = new_state;
- peak_usb_get_ts_tv(&usb_if->time_ref, le32_to_cpu(er->ts32), &tv);
hwts = skb_hwtstamps(skb);
- hwts->hwtstamp = timeval_to_ktime(tv);
+ peak_usb_get_ts_time(&usb_if->time_ref, le32_to_cpu(er->ts32), &hwts->hwtstamp);
netdev->stats.rx_packets++;
netdev->stats.rx_bytes += can_frame->can_dlc;
netif_rx(skb);
--
2.9.0
^ permalink raw reply related
* [PATCH 2/2] can: peak_usb: use ktime_t consistently
From: Arnd Bergmann @ 2017-11-03 16:31 UTC (permalink / raw)
To: Wolfgang Grandegger, Marc Kleine-Budde
Cc: Arnd Bergmann, Stephane Grosjean, 추지호,
Johan Hovold, linux-can, netdev, linux-kernel
In-Reply-To: <20171103163220.3799742-1-arnd@arndb.de>
This changes the calculation of the timestamps to use ktime_t
instead of struct timeval as the base. This gets rid of one
of the few remaining users of the deprecated ktime_to_timeval()
and timeval_to_ktime() helpers.
The code should also get more efficient, as we have now removed
all of the divisions.
I have left the cut-off for resetting the counters as 4.200
seconds, in order to leave the behavior unchanged otherwise.
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
drivers/net/can/usb/peak_usb/pcan_usb_core.c | 46 +++++++++-------------------
drivers/net/can/usb/peak_usb/pcan_usb_core.h | 2 +-
2 files changed, 15 insertions(+), 33 deletions(-)
diff --git a/drivers/net/can/usb/peak_usb/pcan_usb_core.c b/drivers/net/can/usb/peak_usb/pcan_usb_core.c
index 695a75a9b4bb..8f699ee6a528 100644
--- a/drivers/net/can/usb/peak_usb/pcan_usb_core.c
+++ b/drivers/net/can/usb/peak_usb/pcan_usb_core.c
@@ -80,21 +80,6 @@ void peak_usb_init_time_ref(struct peak_time_ref *time_ref,
}
}
-static void peak_usb_add_us(struct timeval *tv, u32 delta_us)
-{
- /* number of s. to add to final time */
- u32 delta_s = delta_us / 1000000;
-
- delta_us -= delta_s * 1000000;
-
- tv->tv_usec += delta_us;
- if (tv->tv_usec >= 1000000) {
- tv->tv_usec -= 1000000;
- delta_s++;
- }
- tv->tv_sec += delta_s;
-}
-
/*
* sometimes, another now may be more recent than current one...
*/
@@ -103,7 +88,7 @@ void peak_usb_update_ts_now(struct peak_time_ref *time_ref, u32 ts_now)
time_ref->ts_dev_2 = ts_now;
/* should wait at least two passes before computing */
- if (time_ref->tv_host.tv_sec > 0) {
+ if (ktime_to_ns(time_ref->tv_host) > 0) {
u32 delta_ts = time_ref->ts_dev_2 - time_ref->ts_dev_1;
if (time_ref->ts_dev_2 < time_ref->ts_dev_1)
@@ -118,26 +103,26 @@ void peak_usb_update_ts_now(struct peak_time_ref *time_ref, u32 ts_now)
*/
void peak_usb_set_ts_now(struct peak_time_ref *time_ref, u32 ts_now)
{
- if (time_ref->tv_host_0.tv_sec == 0) {
+ if (ktime_to_ns(time_ref->tv_host_0) == 0) {
/* use monotonic clock to correctly compute further deltas */
- time_ref->tv_host_0 = ktime_to_timeval(ktime_get());
- time_ref->tv_host.tv_sec = 0;
+ time_ref->tv_host_0 = ktime_get();
+ time_ref->tv_host = ktime_set(0, 0);
} else {
/*
- * delta_us should not be >= 2^32 => delta_s should be < 4294
+ * delta_us should not be >= 2^32 => delta should be < 4294s
* handle 32-bits wrapping here: if count of s. reaches 4200,
* reset counters and change time base
*/
- if (time_ref->tv_host.tv_sec != 0) {
- u32 delta_s = time_ref->tv_host.tv_sec
- - time_ref->tv_host_0.tv_sec;
- if (delta_s > 4200) {
+ if (ktime_to_ns(time_ref->tv_host)) {
+ ktime_t delta = ktime_sub(time_ref->tv_host,
+ time_ref->tv_host_0);
+ if (ktime_to_ns(delta) > (4200ull * NSEC_PER_SEC)) {
time_ref->tv_host_0 = time_ref->tv_host;
time_ref->ts_total = 0;
}
}
- time_ref->tv_host = ktime_to_timeval(ktime_get());
+ time_ref->tv_host = ktime_get();
time_ref->tick_count++;
}
@@ -146,13 +131,12 @@ void peak_usb_set_ts_now(struct peak_time_ref *time_ref, u32 ts_now)
}
/*
- * compute timeval according to current ts and time_ref data
+ * compute time according to current ts and time_ref data
*/
void peak_usb_get_ts_time(struct peak_time_ref *time_ref, u32 ts, ktime_t *time)
{
- /* protect from getting timeval before setting now */
- if (time_ref->tv_host.tv_sec > 0) {
- struct timeval tv;
+ /* protect from getting time before setting now */
+ if (ktime_to_ns(time_ref->tv_host)) {
u64 delta_us;
delta_us = ts - time_ref->ts_dev_2;
@@ -164,9 +148,7 @@ void peak_usb_get_ts_time(struct peak_time_ref *time_ref, u32 ts, ktime_t *time)
delta_us *= time_ref->adapter->us_per_ts_scale;
delta_us >>= time_ref->adapter->us_per_ts_shift;
- tv = time_ref->tv_host_0;
- peak_usb_add_us(&tv, (u32)delta_us);
- *time = timeval_to_ktime(tv);
+ *time = ktime_add_us(time_ref->tv_host_0, delta_us);
} else {
*time = ktime_get();
}
diff --git a/drivers/net/can/usb/peak_usb/pcan_usb_core.h b/drivers/net/can/usb/peak_usb/pcan_usb_core.h
index b9a221ea7e5c..29f03dccca10 100644
--- a/drivers/net/can/usb/peak_usb/pcan_usb_core.h
+++ b/drivers/net/can/usb/peak_usb/pcan_usb_core.h
@@ -96,7 +96,7 @@ extern const struct peak_usb_adapter pcan_usb_pro_fd;
extern const struct peak_usb_adapter pcan_usb_x6;
struct peak_time_ref {
- struct timeval tv_host_0, tv_host;
+ ktime_t tv_host_0, tv_host;
u32 ts_dev_1, ts_dev_2;
u64 ts_total;
u32 tick_count;
--
2.9.0
^ permalink raw reply related
* Re: [v2] can: Use common error handling code in vxcan_newlink()
From: Oliver Hartkopp @ 2017-11-02 8:22 UTC (permalink / raw)
To: SF Markus Elfring, Marc Kleine-Budde, Wolfgang Grandegger,
linux-can, netdev@vger.kernel.org
Cc: LKML, kernel-janitors
In-Reply-To: <2346609d-85f6-6eec-e492-d15ba1b6489a@users.sourceforge.net>
On 11/01/2017 08:37 PM, SF Markus Elfring wrote:
> These addresses were suggested (or recommended?) by the script “get_maintainer.pl”.
I know.
(..)
> How does this view fit to the information in the section “5) Select
> the recipients for your patch” from the document “submitting-patches.rst”?
We discussed and agreed about your patch. It is clear and simple and has
no side effects to any other driver nor other subsystems.
It was just about getting *this* patch into upstream where the Linux CAN
ML is the right place to post - that was my suggestion. So there was no
need to take the *standard* get_maintainer mail pump-gun again for this
patch in order to save bandwidth, energy and peoples lifetime :-)
Regards,
Oliver
^ permalink raw reply
* Re: [v2] can: Use common error handling code in vxcan_newlink()
From: SF Markus Elfring @ 2017-11-01 19:37 UTC (permalink / raw)
To: Oliver Hartkopp, Marc Kleine-Budde, Wolfgang Grandegger,
linux-can, netdev@vger.kernel.org
Cc: LKML, kernel-janitors
In-Reply-To: <08fd31d5-8677-81e7-65d6-40d501017db6@hartkopp.net>
> Acked-by: Oliver Hartkopp <socketcan@hartkopp.net>
Thanks for another positive feedback.
> Again: Posting such a patch on linux-can@vger.kernel.org is ENOUGH!
I was informed in an other way for Linux software patches.
> No need to cross post such a patch additionally on
>
> netdev@vger.kernel.org
> linux-kernel@vger.kernel.org
These addresses were suggested (or recommended?) by the script “get_maintainer.pl”.
> kernel-janitors@vger.kernel.org
I tend to add this address also for my update suggestions.
> and to each of the maintainers
…
> We all subscribed the mailing list and listen to it.
This is generally fine. - But I do not know how long such subscriptions
will be active.
> That's the intention of a mailing list ...
I know …
> Cross posting is not appreciated in the community.
How does this view fit to the information in the section “5) Select
the recipients for your patch” from the document “submitting-patches.rst”?
Regards,
Markus
^ permalink raw reply
* Re: [PATCH v2] can: Use common error handling code in vxcan_newlink()
From: Oliver Hartkopp @ 2017-11-01 19:09 UTC (permalink / raw)
To: SF Markus Elfring, Marc Kleine-Budde, Wolfgang Grandegger,
linux-can, netdev@vger.kernel.org
Cc: LKML, kernel-janitors
In-Reply-To: <23fbbdba-fb11-a6bc-7d6a-4af43ef79503@users.sourceforge.net>
On 11/01/2017 03:16 PM, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Wed, 1 Nov 2017 14:56:15 +0100
>
> Add a jump target so that a bit of exception handling can be better reused
> at the end of this function.
>
> This issue was detected by using the Coccinelle software.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
Acked-by: Oliver Hartkopp <socketcan@hartkopp.net>
Again: Posting such a patch on linux-can@vger.kernel.org is ENOUGH!
No need to cross post such a patch additionally on
netdev@vger.kernel.org
linux-kernel@vger.kernel.org
kernel-janitors@vger.kernel.org
and to each of the maintainers
mkl@pengutronix.de
wg@grandegger.com
socketcan@hartkopp.net
We all subscribed the mailing list and listen to it.
That's the intention of a mailing list ...
Cross posting is not appreciated in the community.
Thanks,
Oliver
> ---
>
> v2:
> An approach to make two checks for a failure predicate a bit safer
> was rejected on 2017-10-28.
> The possibility remains to reconsider such an adjustment later again.
> https://lkml.org/lkml/2017/10/28/125
> https://lkml.kernel.org/r/<264b3c2b-8354-5769-639c-ac8d2fcbe630@hartkopp.net>
>
> drivers/net/can/vxcan.c | 16 ++++++++--------
> 1 file changed, 8 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/net/can/vxcan.c b/drivers/net/can/vxcan.c
> index 8404e8852a0f..5d1753cfacea 100644
> --- a/drivers/net/can/vxcan.c
> +++ b/drivers/net/can/vxcan.c
> @@ -227,10 +227,8 @@ static int vxcan_newlink(struct net *net, struct net_device *dev,
> netif_carrier_off(peer);
>
> err = rtnl_configure_link(peer, ifmp);
> - if (err < 0) {
> - unregister_netdevice(peer);
> - return err;
> - }
> + if (err < 0)
> + goto unregister_network_device;
>
> /* register first device */
> if (tb[IFLA_IFNAME])
> @@ -239,10 +237,8 @@ static int vxcan_newlink(struct net *net, struct net_device *dev,
> snprintf(dev->name, IFNAMSIZ, DRV_NAME "%%d");
>
> err = register_netdevice(dev);
> - if (err < 0) {
> - unregister_netdevice(peer);
> - return err;
> - }
> + if (err < 0)
> + goto unregister_network_device;
>
> netif_carrier_off(dev);
>
> @@ -254,6 +250,10 @@ static int vxcan_newlink(struct net *net, struct net_device *dev,
> rcu_assign_pointer(priv->peer, dev);
>
> return 0;
> +
> +unregister_network_device:
> + unregister_netdevice(peer);
> + return err;
> }
>
> static void vxcan_dellink(struct net_device *dev, struct list_head *head)
>
^ permalink raw reply
* [PATCH v2] can: Use common error handling code in vxcan_newlink()
From: SF Markus Elfring @ 2017-11-01 14:16 UTC (permalink / raw)
To: Marc Kleine-Budde, Oliver Hartkopp, Wolfgang Grandegger,
linux-can, netdev@vger.kernel.org
Cc: LKML, kernel-janitors
In-Reply-To: <264b3c2b-8354-5769-639c-ac8d2fcbe630@hartkopp.net>
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 1 Nov 2017 14:56:15 +0100
Add a jump target so that a bit of exception handling can be better reused
at the end of this function.
This issue was detected by using the Coccinelle software.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
v2:
An approach to make two checks for a failure predicate a bit safer
was rejected on 2017-10-28.
The possibility remains to reconsider such an adjustment later again.
https://lkml.org/lkml/2017/10/28/125
https://lkml.kernel.org/r/<264b3c2b-8354-5769-639c-ac8d2fcbe630@hartkopp.net>
drivers/net/can/vxcan.c | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/drivers/net/can/vxcan.c b/drivers/net/can/vxcan.c
index 8404e8852a0f..5d1753cfacea 100644
--- a/drivers/net/can/vxcan.c
+++ b/drivers/net/can/vxcan.c
@@ -227,10 +227,8 @@ static int vxcan_newlink(struct net *net, struct net_device *dev,
netif_carrier_off(peer);
err = rtnl_configure_link(peer, ifmp);
- if (err < 0) {
- unregister_netdevice(peer);
- return err;
- }
+ if (err < 0)
+ goto unregister_network_device;
/* register first device */
if (tb[IFLA_IFNAME])
@@ -239,10 +237,8 @@ static int vxcan_newlink(struct net *net, struct net_device *dev,
snprintf(dev->name, IFNAMSIZ, DRV_NAME "%%d");
err = register_netdevice(dev);
- if (err < 0) {
- unregister_netdevice(peer);
- return err;
- }
+ if (err < 0)
+ goto unregister_network_device;
netif_carrier_off(dev);
@@ -254,6 +250,10 @@ static int vxcan_newlink(struct net *net, struct net_device *dev,
rcu_assign_pointer(priv->peer, dev);
return 0;
+
+unregister_network_device:
+ unregister_netdevice(peer);
+ return err;
}
static void vxcan_dellink(struct net_device *dev, struct list_head *head)
--
2.14.3
^ permalink raw reply related
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox