On Thu, Nov 21, 2024 at 03:42:52PM +0100, Kory Maincent wrote: > From: Kory Maincent (Dent Project) <kory.maincent@xxxxxxxxxxx> > > This patch enhances PSE callbacks by introducing support for the static > port priority feature. It extends interrupt management to handle and report > detection, classification, and disconnection events. Additionally, it > introduces the pi_get_pw_req() callback, which provides information about > the power requested by the Powered Devices. > > Interrupt support is essential for the proper functioning of the TPS23881 > controller. Without it, after a power-on (PWON), the controller will > no longer perform detection and classification. This could lead to > potential hazards, such as connecting a non-PoE device after a PoE device, > which might result in magic smoke. > > Signed-off-by: Kory Maincent <kory.maincent@xxxxxxxxxxx> > --- > > We may need a fix for the interrupt support in old version of Linux. > > Change in v3: > - New patch > --- > drivers/net/pse-pd/tps23881.c | 197 ++++++++++++++++++++++++++++++++++++++++-- > 1 file changed, 188 insertions(+), 9 deletions(-) > > diff --git a/drivers/net/pse-pd/tps23881.c b/drivers/net/pse-pd/tps23881.c ... > +static int tps23881_irq_event_detection(struct tps23881_priv *priv, > + u16 reg_val, > + unsigned long *notifs, > + unsigned long *notifs_mask) > +{ > + enum ethtool_pse_events event; > + int reg, ret, i, val; > + u8 chans; > + > + chans = tps23881_it_export_chans_helper(reg_val, 0); > + for_each_set_bit(i, (unsigned long *)&chans, TPS23881_MAX_CHANS) { Hi Kory, The storage size of chans is only 1 byte, but here we are pretending that it has more space. Which seems to be a bit of a stretch. Perhaps it would be better to simply use unsigned long as the type of chans here and in tps23881_irq_event_classification(). W=1 build with gcc-14 on x86_64 complains about this line as follows: In function 'find_next_bit', inlined from 'tps23881_irq_event_detection' at drivers/net/pse-pd/tps23881.c:1281:2, inlined from 'tps23881_irq_event_handler' at drivers/net/pse-pd/tps23881.c:1363:9, inlined from 'tps23881_irq_handler' at drivers/net/pse-pd/tps23881.c:1400:9: ./include/linux/find.h:65:23: warning: array subscript 'long unsigned int[0]' is partly outside array bounds of 'u8[1]' {aka 'unsigned char[1]'} [-Warray-bounds=] 65 | val = *addr & GENMASK(size - 1, offset); | ^~~~~ drivers/net/pse-pd/tps23881.c: In function 'tps23881_irq_handler': drivers/net/pse-pd/tps23881.c:1278:12: note: object 'chans' of size 1 1278 | u8 chans; | ^~~~~ > + reg = TPS23881_REG_DISC + (i % 4); > + ret = i2c_smbus_read_word_data(priv->client, reg); > + if (ret < 0) > + return ret; > + > + val = tps23881_calc_val(ret, i, 0, 0xf); > + /* If detection valid */ > + if (val == 0x4) > + event = ETHTOOL_C33_PSE_EVENT_DETECTION; > + else > + event = ETHTOOL_C33_PSE_EVENT_DISCONNECTION; > + > + tps23881_set_notifs_helper(priv, BIT(i), notifs, > + notifs_mask, event); > + } > + > + return 0; > +} ...