Skip to content

Commit 3d35d95

Browse files
committed
Merge branch 'qca8k-fixes'
Marek Behún says: ==================== net: dsa: qca8k: fix qca8k driver for Turris 1.x this is v2 of https://lore.kernel.org/netdev/20231002104612.21898-1-kabel@kernel.org/ Changes since v1: - fixed a typo in commit message noticed by Simon Horman ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
2 parents 109c2de + 526c8ee commit 3d35d95

1 file changed

Lines changed: 13 additions & 2 deletions

File tree

drivers/net/dsa/qca/qca8k-8xxx.c

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -505,8 +505,8 @@ qca8k_bulk_read(void *ctx, const void *reg_buf, size_t reg_len,
505505
void *val_buf, size_t val_len)
506506
{
507507
int i, count = val_len / sizeof(u32), ret;
508-
u32 reg = *(u32 *)reg_buf & U16_MAX;
509508
struct qca8k_priv *priv = ctx;
509+
u32 reg = *(u16 *)reg_buf;
510510

511511
if (priv->mgmt_master &&
512512
!qca8k_read_eth(priv, reg, val_buf, val_len))
@@ -527,8 +527,8 @@ qca8k_bulk_gather_write(void *ctx, const void *reg_buf, size_t reg_len,
527527
const void *val_buf, size_t val_len)
528528
{
529529
int i, count = val_len / sizeof(u32), ret;
530-
u32 reg = *(u32 *)reg_buf & U16_MAX;
531530
struct qca8k_priv *priv = ctx;
531+
u32 reg = *(u16 *)reg_buf;
532532
u32 *val = (u32 *)val_buf;
533533

534534
if (priv->mgmt_master &&
@@ -666,6 +666,15 @@ qca8k_phy_eth_command(struct qca8k_priv *priv, bool read, int phy,
666666
goto err_read_skb;
667667
}
668668

669+
/* It seems that accessing the switch's internal PHYs via management
670+
* packets still uses the MDIO bus within the switch internally, and
671+
* these accesses can conflict with external MDIO accesses to other
672+
* devices on the MDIO bus.
673+
* We therefore need to lock the MDIO bus onto which the switch is
674+
* connected.
675+
*/
676+
mutex_lock(&priv->bus->mdio_lock);
677+
669678
/* Actually start the request:
670679
* 1. Send mdio master packet
671680
* 2. Busy Wait for mdio master command
@@ -678,6 +687,7 @@ qca8k_phy_eth_command(struct qca8k_priv *priv, bool read, int phy,
678687
mgmt_master = priv->mgmt_master;
679688
if (!mgmt_master) {
680689
mutex_unlock(&mgmt_eth_data->mutex);
690+
mutex_unlock(&priv->bus->mdio_lock);
681691
ret = -EINVAL;
682692
goto err_mgmt_master;
683693
}
@@ -765,6 +775,7 @@ qca8k_phy_eth_command(struct qca8k_priv *priv, bool read, int phy,
765775
QCA8K_ETHERNET_TIMEOUT);
766776

767777
mutex_unlock(&mgmt_eth_data->mutex);
778+
mutex_unlock(&priv->bus->mdio_lock);
768779

769780
return ret;
770781

0 commit comments

Comments
 (0)