Skip to content

Commit

Permalink
tgupdate: merge t/DO-NOT-MERGE-mptcp-enabled-by-default base into t/D…
Browse files Browse the repository at this point in the history
…O-NOT-MERGE-mptcp-enabled-by-default
  • Loading branch information
matttbe committed Oct 22, 2024
2 parents 56bb51f + f0e9719 commit f39face
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 21 deletions.
68 changes: 51 additions & 17 deletions drivers/net/ethernet/freescale/fman/mac.c
Original file line number Diff line number Diff line change
Expand Up @@ -155,55 +155,67 @@ static int mac_probe(struct platform_device *_of_dev)
err = -EINVAL;
goto _return_of_node_put;
}
mac_dev->fman_dev = &of_dev->dev;

/* Get the FMan cell-index */
err = of_property_read_u32(dev_node, "cell-index", &val);
if (err) {
dev_err(dev, "failed to read cell-index for %pOF\n", dev_node);
err = -EINVAL;
goto _return_of_node_put;
goto _return_dev_put;
}
/* cell-index 0 => FMan id 1 */
fman_id = (u8)(val + 1);

priv->fman = fman_bind(&of_dev->dev);
priv->fman = fman_bind(mac_dev->fman_dev);
if (!priv->fman) {
dev_err(dev, "fman_bind(%pOF) failed\n", dev_node);
err = -ENODEV;
goto _return_of_node_put;
goto _return_dev_put;
}

/* Two references have been taken in of_find_device_by_node()
* and fman_bind(). Release one of them here. The second one
* will be released in mac_remove().
*/
put_device(mac_dev->fman_dev);
of_node_put(dev_node);
dev_node = NULL;

/* Get the address of the memory mapped registers */
mac_dev->res = platform_get_mem_or_io(_of_dev, 0);
if (!mac_dev->res) {
dev_err(dev, "could not get registers\n");
return -EINVAL;
err = -EINVAL;
goto _return_dev_put;
}

err = devm_request_resource(dev, fman_get_mem_region(priv->fman),
mac_dev->res);
if (err) {
dev_err_probe(dev, err, "could not request resource\n");
return err;
goto _return_dev_put;
}

mac_dev->vaddr = devm_ioremap(dev, mac_dev->res->start,
resource_size(mac_dev->res));
if (!mac_dev->vaddr) {
dev_err(dev, "devm_ioremap() failed\n");
return -EIO;
err = -EIO;
goto _return_dev_put;
}

if (!of_device_is_available(mac_node))
return -ENODEV;
if (!of_device_is_available(mac_node)) {
err = -ENODEV;
goto _return_dev_put;
}

/* Get the cell-index */
err = of_property_read_u32(mac_node, "cell-index", &val);
if (err) {
dev_err(dev, "failed to read cell-index for %pOF\n", mac_node);
return -EINVAL;
err = -EINVAL;
goto _return_dev_put;
}
priv->cell_index = (u8)val;

Expand All @@ -217,40 +229,51 @@ static int mac_probe(struct platform_device *_of_dev)
if (unlikely(nph < 0)) {
dev_err(dev, "of_count_phandle_with_args(%pOF, fsl,fman-ports) failed\n",
mac_node);
return nph;
err = nph;
goto _return_dev_put;
}

if (nph != ARRAY_SIZE(mac_dev->port)) {
dev_err(dev, "Not supported number of fman-ports handles of mac node %pOF from device tree\n",
mac_node);
return -EINVAL;
err = -EINVAL;
goto _return_dev_put;
}

for (i = 0; i < ARRAY_SIZE(mac_dev->port); i++) {
/* PORT_NUM determines the size of the port array */
for (i = 0; i < PORT_NUM; i++) {
/* Find the port node */
dev_node = of_parse_phandle(mac_node, "fsl,fman-ports", i);
if (!dev_node) {
dev_err(dev, "of_parse_phandle(%pOF, fsl,fman-ports) failed\n",
mac_node);
return -EINVAL;
err = -EINVAL;
goto _return_dev_arr_put;
}

of_dev = of_find_device_by_node(dev_node);
if (!of_dev) {
dev_err(dev, "of_find_device_by_node(%pOF) failed\n",
dev_node);
err = -EINVAL;
goto _return_of_node_put;
goto _return_dev_arr_put;
}
mac_dev->fman_port_devs[i] = &of_dev->dev;

mac_dev->port[i] = fman_port_bind(&of_dev->dev);
mac_dev->port[i] = fman_port_bind(mac_dev->fman_port_devs[i]);
if (!mac_dev->port[i]) {
dev_err(dev, "dev_get_drvdata(%pOF) failed\n",
dev_node);
err = -EINVAL;
goto _return_of_node_put;
goto _return_dev_arr_put;
}
/* Two references have been taken in of_find_device_by_node()
* and fman_port_bind(). Release one of them here. The second
* one will be released in mac_remove().
*/
put_device(mac_dev->fman_port_devs[i]);
of_node_put(dev_node);
dev_node = NULL;
}

/* Get the PHY connection type */
Expand All @@ -270,7 +293,7 @@ static int mac_probe(struct platform_device *_of_dev)

err = init(mac_dev, mac_node, &params);
if (err < 0)
return err;
goto _return_dev_arr_put;

if (!is_zero_ether_addr(mac_dev->addr))
dev_info(dev, "FMan MAC address: %pM\n", mac_dev->addr);
Expand All @@ -285,6 +308,12 @@ static int mac_probe(struct platform_device *_of_dev)

return err;

_return_dev_arr_put:
/* mac_dev is kzalloc'ed */
for (i = 0; i < PORT_NUM; i++)
put_device(mac_dev->fman_port_devs[i]);
_return_dev_put:
put_device(mac_dev->fman_dev);
_return_of_node_put:
of_node_put(dev_node);
return err;
Expand All @@ -293,6 +322,11 @@ static int mac_probe(struct platform_device *_of_dev)
static void mac_remove(struct platform_device *pdev)
{
struct mac_device *mac_dev = platform_get_drvdata(pdev);
int i;

for (i = 0; i < PORT_NUM; i++)
put_device(mac_dev->fman_port_devs[i]);
put_device(mac_dev->fman_dev);

platform_device_unregister(mac_dev->priv->eth_dev);
}
Expand Down
6 changes: 5 additions & 1 deletion drivers/net/ethernet/freescale/fman/mac.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,13 @@
struct fman_mac;
struct mac_priv_s;

#define PORT_NUM 2
struct mac_device {
void __iomem *vaddr;
struct device *dev;
struct resource *res;
u8 addr[ETH_ALEN];
struct fman_port *port[2];
struct fman_port *port[PORT_NUM];
struct phylink *phylink;
struct phylink_config phylink_config;
phy_interface_t phy_if;
Expand All @@ -50,6 +51,9 @@ struct mac_device {

struct fman_mac *fman_mac;
struct mac_priv_s *priv;

struct device *fman_dev;
struct device *fman_port_devs[PORT_NUM];
};

static inline struct mac_device
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/virtio_net.c
Original file line number Diff line number Diff line change
Expand Up @@ -4155,7 +4155,7 @@ struct virtnet_stats_ctx {
u32 desc_num[3];

/* The actual supported stat types. */
u32 bitmap[3];
u64 bitmap[3];

/* Used to calculate the reply buffer size. */
u32 size[3];
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/wwan/wwan_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -1038,7 +1038,7 @@ static const struct nla_policy wwan_rtnl_policy[IFLA_WWAN_MAX + 1] = {

static struct rtnl_link_ops wwan_rtnl_link_ops __read_mostly = {
.kind = "wwan",
.maxtype = __IFLA_WWAN_MAX,
.maxtype = IFLA_WWAN_MAX,
.alloc = wwan_rtnl_alloc,
.validate = wwan_rtnl_validate,
.newlink = wwan_rtnl_newlink,
Expand Down
12 changes: 12 additions & 0 deletions include/linux/netdevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -3385,6 +3385,12 @@ static inline void netif_tx_wake_all_queues(struct net_device *dev)

static __always_inline void netif_tx_stop_queue(struct netdev_queue *dev_queue)
{
/* Paired with READ_ONCE() from dev_watchdog() */
WRITE_ONCE(dev_queue->trans_start, jiffies);

/* This barrier is paired with smp_mb() from dev_watchdog() */
smp_mb__before_atomic();

/* Must be an atomic op see netif_txq_try_stop() */
set_bit(__QUEUE_STATE_DRV_XOFF, &dev_queue->state);
}
Expand Down Expand Up @@ -3511,6 +3517,12 @@ static inline void netdev_tx_sent_queue(struct netdev_queue *dev_queue,
if (likely(dql_avail(&dev_queue->dql) >= 0))
return;

/* Paired with READ_ONCE() from dev_watchdog() */
WRITE_ONCE(dev_queue->trans_start, jiffies);

/* This barrier is paired with smp_mb() from dev_watchdog() */
smp_mb__before_atomic();

set_bit(__QUEUE_STATE_STACK_XOFF, &dev_queue->state);

/*
Expand Down
8 changes: 7 additions & 1 deletion net/sched/sch_generic.c
Original file line number Diff line number Diff line change
Expand Up @@ -512,9 +512,15 @@ static void dev_watchdog(struct timer_list *t)
struct netdev_queue *txq;

txq = netdev_get_tx_queue(dev, i);
trans_start = READ_ONCE(txq->trans_start);
if (!netif_xmit_stopped(txq))
continue;

/* Paired with WRITE_ONCE() + smp_mb...() in
* netdev_tx_sent_queue() and netif_tx_stop_queue().
*/
smp_mb();
trans_start = READ_ONCE(txq->trans_start);

if (time_after(jiffies, trans_start + dev->watchdog_timeo)) {
timedout_ms = jiffies_to_msecs(jiffies - trans_start);
atomic_long_inc(&txq->trans_timeout);
Expand Down

0 comments on commit f39face

Please sign in to comment.