kernel: update bgmac by adding Florian's upstream changes

Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
lede-17.01
Rafał Miłecki 2016-08-16 17:40:32 +02:00
parent 99a1888287
commit 13e20e6956
5 changed files with 202 additions and 4 deletions

View File

@ -0,0 +1,105 @@
From b21fcb259313bcf7d4f73ecd5e44948995c8957c Mon Sep 17 00:00:00 2001
From: Philippe Reynes <tremyfr@gmail.com>
Date: Sun, 19 Jun 2016 22:37:05 +0200
Subject: [PATCH 1/2] net: ethernet: bgmac: use phydev from struct net_device
The private structure contain a pointer to phydev, but the structure
net_device already contain such pointer. So we can remove the pointer
phydev in the private structure, and update the driver to use the
one contained in struct net_device.
Signed-off-by: Philippe Reynes <tremyfr@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
---
drivers/net/ethernet/broadcom/bgmac.c | 17 ++++++-----------
drivers/net/ethernet/broadcom/bgmac.h | 1 -
2 files changed, 6 insertions(+), 12 deletions(-)
--- a/drivers/net/ethernet/broadcom/bgmac.c
+++ b/drivers/net/ethernet/broadcom/bgmac.c
@@ -1320,7 +1320,7 @@ static int bgmac_open(struct net_device
}
napi_enable(&bgmac->napi);
- phy_start(bgmac->phy_dev);
+ phy_start(net_dev->phydev);
netif_carrier_on(net_dev);
return 0;
@@ -1332,7 +1332,7 @@ static int bgmac_stop(struct net_device
netif_carrier_off(net_dev);
- phy_stop(bgmac->phy_dev);
+ phy_stop(net_dev->phydev);
napi_disable(&bgmac->napi);
bgmac_chip_intrs_off(bgmac);
@@ -1370,12 +1370,10 @@ static int bgmac_set_mac_address(struct
static int bgmac_ioctl(struct net_device *net_dev, struct ifreq *ifr, int cmd)
{
- struct bgmac *bgmac = netdev_priv(net_dev);
-
if (!netif_running(net_dev))
return -EINVAL;
- return phy_mii_ioctl(bgmac->phy_dev, ifr, cmd);
+ return phy_mii_ioctl(net_dev->phydev, ifr, cmd);
}
static const struct net_device_ops bgmac_netdev_ops = {
@@ -1518,7 +1516,7 @@ static int bgmac_get_settings(struct net
{
struct bgmac *bgmac = netdev_priv(net_dev);
- return phy_ethtool_gset(bgmac->phy_dev, cmd);
+ return phy_ethtool_gset(net_dev->phydev, cmd);
}
static int bgmac_set_settings(struct net_device *net_dev,
@@ -1526,7 +1524,7 @@ static int bgmac_set_settings(struct net
{
struct bgmac *bgmac = netdev_priv(net_dev);
- return phy_ethtool_sset(bgmac->phy_dev, cmd);
+ return phy_ethtool_sset(net_dev->phydev, cmd);
}
static void bgmac_get_drvinfo(struct net_device *net_dev,
@@ -1563,7 +1561,7 @@ static int bgmac_mii_write(struct mii_bu
static void bgmac_adjust_link(struct net_device *net_dev)
{
struct bgmac *bgmac = netdev_priv(net_dev);
- struct phy_device *phy_dev = bgmac->phy_dev;
+ struct phy_device *phy_dev = net_dev->phydev;
bool update = false;
if (phy_dev->link) {
@@ -1607,8 +1605,6 @@ static int bgmac_fixed_phy_register(stru
return err;
}
- bgmac->phy_dev = phy_dev;
-
return err;
}
@@ -1661,7 +1657,6 @@ static int bgmac_mii_register(struct bgm
err = PTR_ERR(phy_dev);
goto err_unregister_bus;
}
- bgmac->phy_dev = phy_dev;
return err;
--- a/drivers/net/ethernet/broadcom/bgmac.h
+++ b/drivers/net/ethernet/broadcom/bgmac.h
@@ -441,7 +441,6 @@ struct bgmac {
struct net_device *net_dev;
struct napi_struct napi;
struct mii_bus *mii_bus;
- struct phy_device *phy_dev;
/* DMA */
struct bgmac_dma_ring tx_ring[BGMAC_MAX_TX_RINGS];

View File

@ -0,0 +1,37 @@
From d2b13233879ca1268a1c027d4573109e5a777811 Mon Sep 17 00:00:00 2001
From: Florian Fainelli <f.fainelli@gmail.com>
Date: Thu, 23 Jun 2016 14:23:12 -0700
Subject: [PATCH 1/3] net: bgmac: Fix SOF bit checking
We are checking for the Start of Frame bit in the ctl1 word, while this
bit is set in the ctl0 word instead. Read the ctl0 word and update the
check to verify that.
Fixes: 9cde94506eac ("bgmac: implement scatter/gather support")
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
---
drivers/net/ethernet/broadcom/bgmac.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
--- a/drivers/net/ethernet/broadcom/bgmac.c
+++ b/drivers/net/ethernet/broadcom/bgmac.c
@@ -269,15 +269,16 @@ static void bgmac_dma_tx_free(struct bgm
while (ring->start != ring->end) {
int slot_idx = ring->start % BGMAC_TX_RING_SLOTS;
struct bgmac_slot_info *slot = &ring->slots[slot_idx];
- u32 ctl1;
+ u32 ctl0, ctl1;
int len;
if (slot_idx == empty_slot)
break;
+ ctl0 = le32_to_cpu(ring->cpu_base[slot_idx].ctl0);
ctl1 = le32_to_cpu(ring->cpu_base[slot_idx].ctl1);
len = ctl1 & BGMAC_DESC_CTL1_LEN;
- if (ctl1 & BGMAC_DESC_CTL0_SOF)
+ if (ctl0 & BGMAC_DESC_CTL0_SOF)
/* Unmap no longer used buffer */
dma_unmap_single(dma_dev, slot->dma_addr, len,
DMA_TO_DEVICE);

View File

@ -0,0 +1,28 @@
From c3897f2a69e54dd113fc9abd2daf872e5b495798 Mon Sep 17 00:00:00 2001
From: Florian Fainelli <f.fainelli@gmail.com>
Date: Thu, 23 Jun 2016 14:25:32 -0700
Subject: [PATCH 2/3] net: bgmac: Start transmit queue in bgmac_open
The driver does not start the transmit queue in bgmac_open(). If the
queue was stopped prior to closing then re-opening the interface, we
would never be able to wake-up again.
Fixes: dd4544f05469 ("bgmac: driver for GBit MAC core on BCMA bus")
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
---
drivers/net/ethernet/broadcom/bgmac.c | 3 +++
1 file changed, 3 insertions(+)
--- a/drivers/net/ethernet/broadcom/bgmac.c
+++ b/drivers/net/ethernet/broadcom/bgmac.c
@@ -1324,6 +1324,9 @@ static int bgmac_open(struct net_device
phy_start(net_dev->phydev);
netif_carrier_on(net_dev);
+
+ netif_start_queue(net_dev);
+
return 0;
}

View File

@ -0,0 +1,28 @@
From 3894396e64994f31c3ef5c7e6f63dded0593e567 Mon Sep 17 00:00:00 2001
From: Florian Fainelli <f.fainelli@gmail.com>
Date: Thu, 23 Jun 2016 14:25:33 -0700
Subject: [PATCH 3/3] net: bgmac: Remove superflous netif_carrier_on()
bgmac_open() calls phy_start() to initialize the PHY state machine,
which will set the interface's carrier state accordingly, no need to
force that as this could be conflicting with the PHY state determined by
PHYLIB.
Fixes: dd4544f05469 ("bgmac: driver for GBit MAC core on BCMA bus")
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
---
drivers/net/ethernet/broadcom/bgmac.c | 2 --
1 file changed, 2 deletions(-)
--- a/drivers/net/ethernet/broadcom/bgmac.c
+++ b/drivers/net/ethernet/broadcom/bgmac.c
@@ -1323,8 +1323,6 @@ static int bgmac_open(struct net_device
phy_start(net_dev->phydev);
- netif_carrier_on(net_dev);
-
netif_start_queue(net_dev);
return 0;

View File

@ -12,7 +12,7 @@ Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
#include <linux/bcm47xx_nvram.h>
static const struct bcma_device_id bgmac_bcma_tbl[] = {
@@ -1683,6 +1684,17 @@ static void bgmac_mii_unregister(struct
@@ -1680,6 +1681,17 @@ static void bgmac_mii_unregister(struct
mdiobus_free(mii_bus);
}
@ -30,7 +30,7 @@ Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
/**************************************************
* BCMA bus ops
**************************************************/
@@ -1828,6 +1840,14 @@ static int bgmac_probe(struct bcma_devic
@@ -1825,6 +1837,14 @@ static int bgmac_probe(struct bcma_devic
net_dev->hw_features = net_dev->features;
net_dev->vlan_features = net_dev->features;
@ -45,7 +45,7 @@ Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
err = register_netdev(bgmac->net_dev);
if (err) {
bgmac_err(bgmac, "Cannot register net device\n");
@@ -1854,6 +1874,10 @@ static void bgmac_remove(struct bcma_dev
@@ -1851,6 +1871,10 @@ static void bgmac_remove(struct bcma_dev
{
struct bgmac *bgmac = bcma_get_drvdata(core);
@ -58,7 +58,7 @@ Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
netif_napi_del(&bgmac->napi);
--- a/drivers/net/ethernet/broadcom/bgmac.h
+++ b/drivers/net/ethernet/broadcom/bgmac.h
@@ -463,6 +463,9 @@ struct bgmac {
@@ -462,6 +462,9 @@ struct bgmac {
bool has_robosw;
bool loopback;