2023-05-24 12:47:07

by Oleksij Rempel

[permalink] [raw]
Subject: [PATCH net-next v1 0/5] Microchip DSA Driver Improvements

I'd like to share a set of patches for the Microchip DSA driver. These
patches were chosen from a bigger set because they are simpler and
should be easier to review. The goal is to make the code easier to read,
get rid of unused code, and handle errors better.

Oleksij Rempel (4):
net: dsa: microchip: improving error handling for 8-bit register RMW
operations
net: dsa: microchip: remove ksz_port:on variable
net: dsa: microchip: ksz8: Prepare ksz8863_smi for regmap register
access validation
net: dsa: microchip: Add register access control for KSZ8873 chip

Vladimir Oltean (1):
net: dsa: microchip: add an enum for regmap widths

drivers/net/dsa/microchip/ksz8795.c | 28 ++-------
drivers/net/dsa/microchip/ksz8863_smi.c | 13 +++-
drivers/net/dsa/microchip/ksz9477.c | 24 ++++----
drivers/net/dsa/microchip/ksz9477_i2c.c | 2 +-
drivers/net/dsa/microchip/ksz_common.c | 47 ++++++++++++++-
drivers/net/dsa/microchip/ksz_common.h | 77 +++++++++++++++++-------
drivers/net/dsa/microchip/ksz_spi.c | 2 +-
drivers/net/dsa/microchip/lan937x_main.c | 8 +--
8 files changed, 135 insertions(+), 66 deletions(-)

--
2.39.2



2023-05-24 12:47:39

by Oleksij Rempel

[permalink] [raw]
Subject: [PATCH net-next v1 1/5] net: dsa: microchip: improving error handling for 8-bit register RMW operations

This patch refines the error handling mechanism for 8-bit register
read-modify-write operations. In case of a failure, it now logs an error
message detailing the problematic offset. This enhancement aids in
debugging by providing more precise information when these operations
encounter issues.

Furthermore, the ksz_prmw8() function has been updated to return error
values rather than void, enabling calling functions to appropriately
respond to errors.

Signed-off-by: Oleksij Rempel <[email protected]>
---
drivers/net/dsa/microchip/ksz_common.h | 28 ++++++++++++++++++++------
1 file changed, 22 insertions(+), 6 deletions(-)

diff --git a/drivers/net/dsa/microchip/ksz_common.h b/drivers/net/dsa/microchip/ksz_common.h
index 8abecaf6089e..b86f1e27a0c3 100644
--- a/drivers/net/dsa/microchip/ksz_common.h
+++ b/drivers/net/dsa/microchip/ksz_common.h
@@ -508,7 +508,14 @@ static inline int ksz_write64(struct ksz_device *dev, u32 reg, u64 value)

static inline int ksz_rmw8(struct ksz_device *dev, int offset, u8 mask, u8 val)
{
- return regmap_update_bits(dev->regmap[0], offset, mask, val);
+ int ret;
+
+ ret = regmap_update_bits(dev->regmap[0], offset, mask, val);
+ if (ret)
+ dev_err(dev->dev, "can't rmw 8bit reg 0x%x: %pe\n", offset,
+ ERR_PTR(ret));
+
+ return ret;
}

static inline int ksz_pread8(struct ksz_device *dev, int port, int offset,
@@ -549,12 +556,21 @@ static inline int ksz_pwrite32(struct ksz_device *dev, int port, int offset,
data);
}

-static inline void ksz_prmw8(struct ksz_device *dev, int port, int offset,
- u8 mask, u8 val)
+static inline int ksz_prmw8(struct ksz_device *dev, int port, int offset,
+ u8 mask, u8 val)
{
- regmap_update_bits(dev->regmap[0],
- dev->dev_ops->get_port_addr(port, offset),
- mask, val);
+ int ret;
+
+ ret = regmap_update_bits(dev->regmap[0],
+ dev->dev_ops->get_port_addr(port, offset),
+ mask, val);
+ if (ret)
+ dev_err(dev->dev, "can't rmw 8bit reg 0x%x: %pe\n",
+ dev->dev_ops->get_port_addr(port, offset),
+ ERR_PTR(ret));
+
+ return ret;
+
}

static inline void ksz_regmap_lock(void *__mtx)
--
2.39.2


2023-05-24 12:52:22

by Russell King (Oracle)

[permalink] [raw]
Subject: Re: [PATCH net-next v1 1/5] net: dsa: microchip: improving error handling for 8-bit register RMW operations

On Wed, May 24, 2023 at 02:32:16PM +0200, Oleksij Rempel wrote:
> This patch refines the error handling mechanism for 8-bit register
> read-modify-write operations. In case of a failure, it now logs an error
> message detailing the problematic offset. This enhancement aids in
> debugging by providing more precise information when these operations
> encounter issues.
>
> Furthermore, the ksz_prmw8() function has been updated to return error
> values rather than void, enabling calling functions to appropriately
> respond to errors.

What happens when there is an error that affects the current and future
accesses? Does this PHY driver then begin to flood the kernel log?

--
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!

2023-05-24 17:56:27

by Oleksij Rempel

[permalink] [raw]
Subject: Re: [PATCH net-next v1 1/5] net: dsa: microchip: improving error handling for 8-bit register RMW operations

On Wed, May 24, 2023 at 01:39:53PM +0100, Russell King (Oracle) wrote:
> On Wed, May 24, 2023 at 02:32:16PM +0200, Oleksij Rempel wrote:
> > This patch refines the error handling mechanism for 8-bit register
> > read-modify-write operations. In case of a failure, it now logs an error
> > message detailing the problematic offset. This enhancement aids in
> > debugging by providing more precise information when these operations
> > encounter issues.
> >
> > Furthermore, the ksz_prmw8() function has been updated to return error
> > values rather than void, enabling calling functions to appropriately
> > respond to errors.
>
> What happens when there is an error that affects the current and future
> accesses? Does this PHY driver then begin to flood the kernel log?

Yes. In the same way as it is done in all ksz_read*/ksz_write* helpers.

--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |