All of lore.kernel.org
 help / color / mirror / Atom feed
From: Simon Horman <horms@kernel.org>
To: Kory Maincent <kory.maincent@bootlin.com>
Cc: Andrew Lunn <andrew@lunn.ch>,
	Oleksij Rempel <o.rempel@pengutronix.de>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Jonathan Corbet <corbet@lwn.net>,
	Donald Hunter <donald.hunter@gmail.com>,
	Rob Herring <robh@kernel.org>,
	Andrew Lunn <andrew+netdev@lunn.ch>,
	Heiner Kallweit <hkallweit1@gmail.com>,
	Russell King <linux@armlinux.org.uk>,
	Liam Girdwood <lgirdwood@gmail.com>,
	Mark Brown <broonie@kernel.org>,
	Thomas Petazzoni <thomas.petazzoni@bootlin.com>,
	linux-kernel@vger.kernel.org, netdev@vger.kernel.org,
	linux-doc@vger.kernel.org, Kyle Swenson <kyle.swenson@est.tech>,
	Dent Project <dentproject@linuxfoundation.org>,
	kernel@pengutronix.de,
	Maxime Chevallier <maxime.chevallier@bootlin.com>
Subject: Re: [PATCH RFC net-next v3 26/27] net: pse-pd: tps23881: Add support for static port priority feature
Date: Tue, 3 Dec 2024 10:29:13 +0000	[thread overview]
Message-ID: <20241203102913.GD9361@kernel.org> (raw)
In-Reply-To: <20241121-feature_poe_port_prio-v3-26-83299fa6967c@bootlin.com>

On Thu, Nov 21, 2024 at 03:42:52PM +0100, Kory Maincent wrote:
> From: Kory Maincent (Dent Project) <kory.maincent@bootlin.com>
> 
> 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@bootlin.com>
> ---
> 
> 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;
> +}

...

  reply	other threads:[~2024-12-03 10:29 UTC|newest]

Thread overview: 60+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-21 14:42 [PATCH RFC net-next v3 00/27] Add support for PSE port priority Kory Maincent
2024-11-21 14:42 ` [PATCH RFC net-next v3 01/27] net: pse-pd: Remove unused pse_ethtool_get_pw_limit function declaration Kory Maincent
2024-11-21 14:42 ` [PATCH RFC net-next v3 02/27] regulator: core: Ignore unset max_uA constraints in current limit check Kory Maincent
2024-11-21 14:42 ` [PATCH RFC net-next v3 03/27] net: pse-pd: Avoid setting max_uA in regulator constraints Kory Maincent
2024-11-23  6:29   ` Oleksij Rempel
2024-11-24 11:47     ` Kory Maincent
2024-11-21 14:42 ` [PATCH RFC net-next v3 04/27] net: pse-pd: Add power limit check Kory Maincent
2024-11-23  6:31   ` Oleksij Rempel
2024-11-21 14:42 ` [PATCH RFC net-next v3 05/27] net: pse-pd: tps23881: Simplify function returns by removing redundant checks Kory Maincent
2024-11-21 14:42 ` [PATCH RFC net-next v3 06/27] net: pse-pd: tps23881: Use helpers to calculate bit offset for a channel Kory Maincent (Dent Project)
2024-11-21 14:42 ` [PATCH RFC net-next v3 07/27] net: pse-pd: tps23881: Add missing configuration register after disable Kory Maincent
2024-11-23  6:35   ` Oleksij Rempel
2024-11-21 14:42 ` [PATCH RFC net-next v3 08/27] net: pse-pd: tps23881: Add support for power limit and measurement features Kory Maincent
2024-11-23  7:31   ` Oleksij Rempel
2024-11-21 14:42 ` [PATCH RFC net-next v3 09/27] net: pse-pd: Add support for PSE device index Kory Maincent
2024-11-23  7:34   ` Oleksij Rempel
2024-11-21 14:42 ` [PATCH RFC net-next v3 10/27] net: ethtool: Add support for new PSE device index description Kory Maincent
2024-11-21 14:42 ` [PATCH RFC net-next v3 11/27] net: ethtool: Add support for ethnl_info_init_ntf helper function Kory Maincent
2024-11-21 14:42 ` [PATCH RFC net-next v3 12/27] net: pse-pd: Add support for reporting events Kory Maincent
2024-11-24  9:26   ` Oleksij Rempel
2024-11-25 10:42     ` Kory Maincent
2024-11-21 14:42 ` [PATCH RFC net-next v3 13/27] netlink: specs: Add support for PSE netlink notifications Kory Maincent
2024-11-21 14:42 ` [PATCH RFC net-next v3 14/27] net: pse-pd: tps23881: Add support for PSE events and interrupts Kory Maincent
2024-11-24  9:34   ` Oleksij Rempel
2024-11-25 11:39     ` Kory Maincent
2024-11-21 14:42 ` [PATCH RFC net-next v3 15/27] regulator: core: Resolve supply using of_node from regulator_config Kory Maincent
2024-11-24  9:39   ` Oleksij Rempel
2024-11-24  9:44     ` Oleksij Rempel
2024-11-21 14:42 ` [PATCH RFC net-next v3 16/27] regulator: Add support for power budget description Kory Maincent
2024-11-24  9:46   ` Oleksij Rempel
2024-11-21 14:42 ` [PATCH RFC net-next v3 17/27] regulator: dt-bindings: Add regulator-power-budget property Kory Maincent
2024-11-21 14:58   ` Mark Brown
2024-11-21 15:27     ` Kory Maincent
2024-11-22  6:57   ` Krzysztof Kozlowski
2024-11-21 14:42 ` [PATCH RFC net-next v3 18/27] net: pse-pd: Fix missing PI of_node description Kory Maincent
2024-11-24  9:49   ` Oleksij Rempel
2024-11-21 14:42 ` [PATCH RFC net-next v3 19/27] net: pse-pd: Add support for PSE power domains Kory Maincent
2024-11-24 10:24   ` Oleksij Rempel
2024-11-21 14:42 ` [PATCH RFC net-next v3 20/27] net: ethtool: Add support for new power domains index description Kory Maincent
2024-11-26  5:53   ` Oleksij Rempel
2024-11-21 14:42 ` [PATCH RFC net-next v3 21/27] net: pse-pd: Add support for getting and setting port priority Kory Maincent
2024-11-26  8:38   ` Oleksij Rempel
2024-11-26 15:31     ` Kory Maincent
2024-11-26 15:52       ` Kory Maincent
2024-11-27  9:30         ` Oleksij Rempel
2024-11-27 10:11           ` Kory Maincent
2024-11-27 10:31             ` Oleksij Rempel
2024-11-27 11:00               ` Kory Maincent
2024-11-21 14:42 ` [PATCH RFC net-next v3 22/27] net: ethtool: Add PSE new port priority support feature Kory Maincent
2024-11-21 14:42 ` [PATCH RFC net-next v3 23/27] netlink: specs: Expand the PSE netlink command with newly supported features Kory Maincent
2024-11-21 14:42 ` [PATCH RFC net-next v3 24/27] net: pse-pd: pd692x0: Add support for PSE PI priority feature Kory Maincent
2024-11-21 14:42 ` [PATCH RFC net-next v3 25/27] dt-bindings: net: pse-pd: microchip,pd692x0: Add manager regulator supply Kory Maincent
2024-11-22  6:58   ` Krzysztof Kozlowski
2024-11-22  8:42     ` Kory Maincent
2024-11-22  9:20       ` Krzysztof Kozlowski
2024-11-21 14:42 ` [PATCH RFC net-next v3 26/27] net: pse-pd: tps23881: Add support for static port priority feature Kory Maincent
2024-12-03 10:29   ` Simon Horman [this message]
2024-12-03 10:44     ` Kory Maincent
2024-11-21 14:42 ` [PATCH RFC net-next v3 27/27] dt-bindings: net: pse-pd: ti,tps23881: Add interrupt description Kory Maincent
2024-11-21 16:22 ` (subset) [PATCH RFC net-next v3 00/27] Add support for PSE port priority Mark Brown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20241203102913.GD9361@kernel.org \
    --to=horms@kernel.org \
    --cc=andrew+netdev@lunn.ch \
    --cc=andrew@lunn.ch \
    --cc=broonie@kernel.org \
    --cc=corbet@lwn.net \
    --cc=davem@davemloft.net \
    --cc=dentproject@linuxfoundation.org \
    --cc=donald.hunter@gmail.com \
    --cc=edumazet@google.com \
    --cc=hkallweit1@gmail.com \
    --cc=kernel@pengutronix.de \
    --cc=kory.maincent@bootlin.com \
    --cc=kuba@kernel.org \
    --cc=kyle.swenson@est.tech \
    --cc=lgirdwood@gmail.com \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=maxime.chevallier@bootlin.com \
    --cc=netdev@vger.kernel.org \
    --cc=o.rempel@pengutronix.de \
    --cc=pabeni@redhat.com \
    --cc=robh@kernel.org \
    --cc=thomas.petazzoni@bootlin.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.