* [PATCH v2 0/2] Fix the arc emac driver
@ 2024-11-04 13:01 Andy Yan
2024-11-04 13:01 ` [PATCH v2 1/2] net: arc: fix the device for dma_map_single/dma_unmap_single Andy Yan
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Andy Yan @ 2024-11-04 13:01 UTC (permalink / raw)
To: andrew+netdev; +Cc: netdev, linux-kernel, david.wu, Andy Yan
From: Andy Yan <andy.yan@rock-chips.com>
The arc emac driver was broken for a long time,
The first broken happens when a dma releated fix introduced in Linux 5.10.
The second broken happens when a emac device tree node restyle introduced
in Linux 6.1.
These two patches are try to make the arc emac work again.
Changes in v2:
- Add cover letter.
- Add fix tag.
- Add more detail explaination.
Johan Jonker (2):
net: arc: fix the device for dma_map_single/dma_unmap_single
net: arc: rockchip: fix emac mdio node support
drivers/net/ethernet/arc/emac_main.c | 27 ++++++++++++++++-----------
drivers/net/ethernet/arc/emac_mdio.c | 9 ++++++++-
2 files changed, 24 insertions(+), 12 deletions(-)
--
2.34.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v2 1/2] net: arc: fix the device for dma_map_single/dma_unmap_single
2024-11-04 13:01 [PATCH v2 0/2] Fix the arc emac driver Andy Yan
@ 2024-11-04 13:01 ` Andy Yan
2024-11-04 13:01 ` [PATCH v2 2/2] net: arc: rockchip: fix emac mdio node support Andy Yan
2024-11-07 13:00 ` [PATCH v2 0/2] Fix the arc emac driver patchwork-bot+netdevbpf
2 siblings, 0 replies; 6+ messages in thread
From: Andy Yan @ 2024-11-04 13:01 UTC (permalink / raw)
To: andrew+netdev; +Cc: netdev, linux-kernel, david.wu, Johan Jonker, Andy Yan
From: Johan Jonker <jbx6244@gmail.com>
The ndev->dev and pdev->dev aren't the same device, use ndev->dev.parent
which has dma_mask, ndev->dev.parent is just pdev->dev.
Or it would cause the following issue:
[ 39.933526] ------------[ cut here ]------------
[ 39.938414] WARNING: CPU: 1 PID: 501 at kernel/dma/mapping.c:149 dma_map_page_attrs+0x90/0x1f8
Fixes: f959dcd6ddfd ("dma-direct: Fix potential NULL pointer dereference")
Signed-off-by: David Wu <david.wu@rock-chips.com>
Signed-off-by: Johan Jonker <jbx6244@gmail.com>
Signed-off-by: Andy Yan <andy.yan@rock-chips.com>
---
Changes in v2:
- Add fix tag.
- Add cover letter.
drivers/net/ethernet/arc/emac_main.c | 27 ++++++++++++++++-----------
1 file changed, 16 insertions(+), 11 deletions(-)
diff --git a/drivers/net/ethernet/arc/emac_main.c b/drivers/net/ethernet/arc/emac_main.c
index 31ee477dd131e..8283aeee35fb6 100644
--- a/drivers/net/ethernet/arc/emac_main.c
+++ b/drivers/net/ethernet/arc/emac_main.c
@@ -111,6 +111,7 @@ static void arc_emac_tx_clean(struct net_device *ndev)
{
struct arc_emac_priv *priv = netdev_priv(ndev);
struct net_device_stats *stats = &ndev->stats;
+ struct device *dev = ndev->dev.parent;
unsigned int i;
for (i = 0; i < TX_BD_NUM; i++) {
@@ -140,7 +141,7 @@ static void arc_emac_tx_clean(struct net_device *ndev)
stats->tx_bytes += skb->len;
}
- dma_unmap_single(&ndev->dev, dma_unmap_addr(tx_buff, addr),
+ dma_unmap_single(dev, dma_unmap_addr(tx_buff, addr),
dma_unmap_len(tx_buff, len), DMA_TO_DEVICE);
/* return the sk_buff to system */
@@ -174,6 +175,7 @@ static void arc_emac_tx_clean(struct net_device *ndev)
static int arc_emac_rx(struct net_device *ndev, int budget)
{
struct arc_emac_priv *priv = netdev_priv(ndev);
+ struct device *dev = ndev->dev.parent;
unsigned int work_done;
for (work_done = 0; work_done < budget; work_done++) {
@@ -223,9 +225,9 @@ static int arc_emac_rx(struct net_device *ndev, int budget)
continue;
}
- addr = dma_map_single(&ndev->dev, (void *)skb->data,
+ addr = dma_map_single(dev, (void *)skb->data,
EMAC_BUFFER_SIZE, DMA_FROM_DEVICE);
- if (dma_mapping_error(&ndev->dev, addr)) {
+ if (dma_mapping_error(dev, addr)) {
if (net_ratelimit())
netdev_err(ndev, "cannot map dma buffer\n");
dev_kfree_skb(skb);
@@ -237,7 +239,7 @@ static int arc_emac_rx(struct net_device *ndev, int budget)
}
/* unmap previosly mapped skb */
- dma_unmap_single(&ndev->dev, dma_unmap_addr(rx_buff, addr),
+ dma_unmap_single(dev, dma_unmap_addr(rx_buff, addr),
dma_unmap_len(rx_buff, len), DMA_FROM_DEVICE);
pktlen = info & LEN_MASK;
@@ -423,6 +425,7 @@ static int arc_emac_open(struct net_device *ndev)
{
struct arc_emac_priv *priv = netdev_priv(ndev);
struct phy_device *phy_dev = ndev->phydev;
+ struct device *dev = ndev->dev.parent;
int i;
phy_dev->autoneg = AUTONEG_ENABLE;
@@ -445,9 +448,9 @@ static int arc_emac_open(struct net_device *ndev)
if (unlikely(!rx_buff->skb))
return -ENOMEM;
- addr = dma_map_single(&ndev->dev, (void *)rx_buff->skb->data,
+ addr = dma_map_single(dev, (void *)rx_buff->skb->data,
EMAC_BUFFER_SIZE, DMA_FROM_DEVICE);
- if (dma_mapping_error(&ndev->dev, addr)) {
+ if (dma_mapping_error(dev, addr)) {
netdev_err(ndev, "cannot dma map\n");
dev_kfree_skb(rx_buff->skb);
return -ENOMEM;
@@ -548,6 +551,7 @@ static void arc_emac_set_rx_mode(struct net_device *ndev)
static void arc_free_tx_queue(struct net_device *ndev)
{
struct arc_emac_priv *priv = netdev_priv(ndev);
+ struct device *dev = ndev->dev.parent;
unsigned int i;
for (i = 0; i < TX_BD_NUM; i++) {
@@ -555,7 +559,7 @@ static void arc_free_tx_queue(struct net_device *ndev)
struct buffer_state *tx_buff = &priv->tx_buff[i];
if (tx_buff->skb) {
- dma_unmap_single(&ndev->dev,
+ dma_unmap_single(dev,
dma_unmap_addr(tx_buff, addr),
dma_unmap_len(tx_buff, len),
DMA_TO_DEVICE);
@@ -579,6 +583,7 @@ static void arc_free_tx_queue(struct net_device *ndev)
static void arc_free_rx_queue(struct net_device *ndev)
{
struct arc_emac_priv *priv = netdev_priv(ndev);
+ struct device *dev = ndev->dev.parent;
unsigned int i;
for (i = 0; i < RX_BD_NUM; i++) {
@@ -586,7 +591,7 @@ static void arc_free_rx_queue(struct net_device *ndev)
struct buffer_state *rx_buff = &priv->rx_buff[i];
if (rx_buff->skb) {
- dma_unmap_single(&ndev->dev,
+ dma_unmap_single(dev,
dma_unmap_addr(rx_buff, addr),
dma_unmap_len(rx_buff, len),
DMA_FROM_DEVICE);
@@ -679,6 +684,7 @@ static netdev_tx_t arc_emac_tx(struct sk_buff *skb, struct net_device *ndev)
unsigned int len, *txbd_curr = &priv->txbd_curr;
struct net_device_stats *stats = &ndev->stats;
__le32 *info = &priv->txbd[*txbd_curr].info;
+ struct device *dev = ndev->dev.parent;
dma_addr_t addr;
if (skb_padto(skb, ETH_ZLEN))
@@ -692,10 +698,9 @@ static netdev_tx_t arc_emac_tx(struct sk_buff *skb, struct net_device *ndev)
return NETDEV_TX_BUSY;
}
- addr = dma_map_single(&ndev->dev, (void *)skb->data, len,
- DMA_TO_DEVICE);
+ addr = dma_map_single(dev, (void *)skb->data, len, DMA_TO_DEVICE);
- if (unlikely(dma_mapping_error(&ndev->dev, addr))) {
+ if (unlikely(dma_mapping_error(dev, addr))) {
stats->tx_dropped++;
stats->tx_errors++;
dev_kfree_skb_any(skb);
--
2.34.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH v2 2/2] net: arc: rockchip: fix emac mdio node support
2024-11-04 13:01 [PATCH v2 0/2] Fix the arc emac driver Andy Yan
2024-11-04 13:01 ` [PATCH v2 1/2] net: arc: fix the device for dma_map_single/dma_unmap_single Andy Yan
@ 2024-11-04 13:01 ` Andy Yan
2024-11-07 1:50 ` Jakub Kicinski
2024-11-07 13:00 ` [PATCH v2 0/2] Fix the arc emac driver patchwork-bot+netdevbpf
2 siblings, 1 reply; 6+ messages in thread
From: Andy Yan @ 2024-11-04 13:01 UTC (permalink / raw)
To: andrew+netdev
Cc: netdev, linux-kernel, david.wu, Johan Jonker, Andy Yan, Andy Yan
From: Johan Jonker <jbx6244@gmail.com>
The binding emac_rockchip.txt is converted to YAML.
Changed against the original binding is an added MDIO subnode.
This make the driver failed to find the PHY, and given the 'mdio
has invalid PHY address' it is probably looking in the wrong node.
Fix emac_mdio.c so that it can handle both old and new
device trees.
Fixes: 1dabb74971b3 ("ARM: dts: rockchip: restyle emac nodes")
Signed-off-by: Johan Jonker <jbx6244@gmail.com>
Tested-by: Andy Yan <andyshrk@163.com>
Link: https://lore.kernel.org/r/20220603163539.537-3-jbx6244@gmail.com
Signed-off-by: Andy Yan <andy.yan@rock-chips.com>
---
Changes in v2:
- Add fix tag.
- Add more detail explaination.
drivers/net/ethernet/arc/emac_mdio.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/arc/emac_mdio.c b/drivers/net/ethernet/arc/emac_mdio.c
index 87f40c2ba9040..078b1a72c1613 100644
--- a/drivers/net/ethernet/arc/emac_mdio.c
+++ b/drivers/net/ethernet/arc/emac_mdio.c
@@ -133,6 +133,7 @@ int arc_mdio_probe(struct arc_emac_priv *priv)
struct arc_emac_mdio_bus_data *data = &priv->bus_data;
struct device_node *np = priv->dev->of_node;
const char *name = "Synopsys MII Bus";
+ struct device_node *mdio_node;
struct mii_bus *bus;
int error;
@@ -164,7 +165,13 @@ int arc_mdio_probe(struct arc_emac_priv *priv)
snprintf(bus->id, MII_BUS_ID_SIZE, "%s", bus->name);
- error = of_mdiobus_register(bus, priv->dev->of_node);
+ /* Backwards compatibility for EMAC nodes without MDIO subnode. */
+ mdio_node = of_get_child_by_name(np, "mdio");
+ if (!mdio_node)
+ mdio_node = of_node_get(np);
+
+ error = of_mdiobus_register(bus, mdio_node);
+ of_node_put(mdio_node);
if (error) {
mdiobus_free(bus);
return dev_err_probe(priv->dev, error,
--
2.34.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v2 2/2] net: arc: rockchip: fix emac mdio node support
2024-11-04 13:01 ` [PATCH v2 2/2] net: arc: rockchip: fix emac mdio node support Andy Yan
@ 2024-11-07 1:50 ` Jakub Kicinski
2024-11-07 3:05 ` Andrew Lunn
0 siblings, 1 reply; 6+ messages in thread
From: Jakub Kicinski @ 2024-11-07 1:50 UTC (permalink / raw)
To: andrew; +Cc: Andy Yan, netdev, linux-kernel, david.wu, Johan Jonker, Andy Yan
On Mon, 4 Nov 2024 21:01:39 +0800 Andy Yan wrote:
> From: Johan Jonker <jbx6244@gmail.com>
>
> The binding emac_rockchip.txt is converted to YAML.
> Changed against the original binding is an added MDIO subnode.
> This make the driver failed to find the PHY, and given the 'mdio
> has invalid PHY address' it is probably looking in the wrong node.
> Fix emac_mdio.c so that it can handle both old and new
> device trees.
Andrew, looks good?
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2 2/2] net: arc: rockchip: fix emac mdio node support
2024-11-07 1:50 ` Jakub Kicinski
@ 2024-11-07 3:05 ` Andrew Lunn
0 siblings, 0 replies; 6+ messages in thread
From: Andrew Lunn @ 2024-11-07 3:05 UTC (permalink / raw)
To: Jakub Kicinski
Cc: Andy Yan, netdev, linux-kernel, david.wu, Johan Jonker, Andy Yan
On Wed, Nov 06, 2024 at 05:50:02PM -0800, Jakub Kicinski wrote:
> On Mon, 4 Nov 2024 21:01:39 +0800 Andy Yan wrote:
> > From: Johan Jonker <jbx6244@gmail.com>
> >
> > The binding emac_rockchip.txt is converted to YAML.
> > Changed against the original binding is an added MDIO subnode.
> > This make the driver failed to find the PHY, and given the 'mdio
> > has invalid PHY address' it is probably looking in the wrong node.
> > Fix emac_mdio.c so that it can handle both old and new
> > device trees.
>
> Andrew, looks good?
The MDIO patch looks correct. I cannot say anything about the DMA
mapping.
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Andrew
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2 0/2] Fix the arc emac driver
2024-11-04 13:01 [PATCH v2 0/2] Fix the arc emac driver Andy Yan
2024-11-04 13:01 ` [PATCH v2 1/2] net: arc: fix the device for dma_map_single/dma_unmap_single Andy Yan
2024-11-04 13:01 ` [PATCH v2 2/2] net: arc: rockchip: fix emac mdio node support Andy Yan
@ 2024-11-07 13:00 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 6+ messages in thread
From: patchwork-bot+netdevbpf @ 2024-11-07 13:00 UTC (permalink / raw)
To: Andy Yan; +Cc: andrew+netdev, netdev, linux-kernel, david.wu, andy.yan
Hello:
This series was applied to netdev/net.git (main)
by Paolo Abeni <pabeni@redhat.com>:
On Mon, 4 Nov 2024 21:01:37 +0800 you wrote:
> From: Andy Yan <andy.yan@rock-chips.com>
>
>
> The arc emac driver was broken for a long time,
> The first broken happens when a dma releated fix introduced in Linux 5.10.
> The second broken happens when a emac device tree node restyle introduced
> in Linux 6.1.
>
> [...]
Here is the summary with links:
- [v2,1/2] net: arc: fix the device for dma_map_single/dma_unmap_single
https://git.kernel.org/netdev/net/c/71803c1dfa29
- [v2,2/2] net: arc: rockchip: fix emac mdio node support
https://git.kernel.org/netdev/net/c/0a1c7a7b0adb
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2024-11-07 13:00 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-04 13:01 [PATCH v2 0/2] Fix the arc emac driver Andy Yan
2024-11-04 13:01 ` [PATCH v2 1/2] net: arc: fix the device for dma_map_single/dma_unmap_single Andy Yan
2024-11-04 13:01 ` [PATCH v2 2/2] net: arc: rockchip: fix emac mdio node support Andy Yan
2024-11-07 1:50 ` Jakub Kicinski
2024-11-07 3:05 ` Andrew Lunn
2024-11-07 13:00 ` [PATCH v2 0/2] Fix the arc emac driver patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).