mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH net] net: phy: nxp-c45-tja11xx: add remove callback
@ 2023-04-06  9:59 Radu Pirea (OSS)
  2023-04-07 14:20 ` Andrew Lunn
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Radu Pirea (OSS) @ 2023-04-06  9:59 UTC (permalink / raw)
  To: andrew, hkallweit1, linux, davem, edumazet, kuba, pabeni
  Cc: netdev, linux-kernel, Radu Pirea (OSS), stable

Unregister PTP clock when the driver is removed.
Purge the RX and TX skb queues.

Fixes: 514def5dd339 ("phy: nxp-c45-tja11xx: add timestamping support")
CC: stable@vger.kernel.org # 5.15+
Signed-off-by: Radu Pirea (OSS) <radu-nicolae.pirea@oss.nxp.com>
---
 drivers/net/phy/nxp-c45-tja11xx.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/drivers/net/phy/nxp-c45-tja11xx.c b/drivers/net/phy/nxp-c45-tja11xx.c
index 5813b07242ce..27738d1ae9ea 100644
--- a/drivers/net/phy/nxp-c45-tja11xx.c
+++ b/drivers/net/phy/nxp-c45-tja11xx.c
@@ -1337,6 +1337,17 @@ static int nxp_c45_probe(struct phy_device *phydev)
 	return ret;
 }
 
+static void nxp_c45_remove(struct phy_device *phydev)
+{
+	struct nxp_c45_phy *priv = phydev->priv;
+
+	if (priv->ptp_clock)
+		ptp_clock_unregister(priv->ptp_clock);
+
+	skb_queue_purge(&priv->tx_queue);
+	skb_queue_purge(&priv->rx_queue);
+}
+
 static struct phy_driver nxp_c45_driver[] = {
 	{
 		PHY_ID_MATCH_MODEL(PHY_ID_TJA_1103),
@@ -1359,6 +1370,7 @@ static struct phy_driver nxp_c45_driver[] = {
 		.set_loopback		= genphy_c45_loopback,
 		.get_sqi		= nxp_c45_get_sqi,
 		.get_sqi_max		= nxp_c45_get_sqi_max,
+		.remove			= nxp_c45_remove,
 	},
 };
 
-- 
2.34.1


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH net] net: phy: nxp-c45-tja11xx: add remove callback
  2023-04-06  9:59 [PATCH net] net: phy: nxp-c45-tja11xx: add remove callback Radu Pirea (OSS)
@ 2023-04-07 14:20 ` Andrew Lunn
  2023-04-07 17:42   ` Radu Pirea (OSS)
  2023-04-11 10:05 ` Paolo Abeni
  2023-04-11 13:40 ` patchwork-bot+netdevbpf
  2 siblings, 1 reply; 7+ messages in thread
From: Andrew Lunn @ 2023-04-07 14:20 UTC (permalink / raw)
  To: Radu Pirea (OSS)
  Cc: hkallweit1, linux, davem, edumazet, kuba, pabeni, netdev,
	linux-kernel, stable

On Thu, Apr 06, 2023 at 12:59:04PM +0300, Radu Pirea (OSS) wrote:
> Unregister PTP clock when the driver is removed.
> Purge the RX and TX skb queues.
> 
> Fixes: 514def5dd339 ("phy: nxp-c45-tja11xx: add timestamping support")
> CC: stable@vger.kernel.org # 5.15+
> Signed-off-by: Radu Pirea (OSS) <radu-nicolae.pirea@oss.nxp.com>
> ---
>  drivers/net/phy/nxp-c45-tja11xx.c | 12 ++++++++++++
>  1 file changed, 12 insertions(+)
> 
> diff --git a/drivers/net/phy/nxp-c45-tja11xx.c b/drivers/net/phy/nxp-c45-tja11xx.c
> index 5813b07242ce..27738d1ae9ea 100644
> --- a/drivers/net/phy/nxp-c45-tja11xx.c
> +++ b/drivers/net/phy/nxp-c45-tja11xx.c
> @@ -1337,6 +1337,17 @@ static int nxp_c45_probe(struct phy_device *phydev)
>  	return ret;
>  }
>  
> +static void nxp_c45_remove(struct phy_device *phydev)
> +{
> +	struct nxp_c45_phy *priv = phydev->priv;
> +
> +	if (priv->ptp_clock)
> +		ptp_clock_unregister(priv->ptp_clock);
> +
> +	skb_queue_purge(&priv->tx_queue);
> +	skb_queue_purge(&priv->rx_queue);

Do you need to disable interrupts? I suppose the real question is, is
it guaranteed phy_disconnect() is called before the driver is removed?

   Andrew

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH net] net: phy: nxp-c45-tja11xx: add remove callback
  2023-04-07 14:20 ` Andrew Lunn
@ 2023-04-07 17:42   ` Radu Pirea (OSS)
  2023-04-07 18:15     ` Andrew Lunn
  0 siblings, 1 reply; 7+ messages in thread
From: Radu Pirea (OSS) @ 2023-04-07 17:42 UTC (permalink / raw)
  To: Andrew Lunn
  Cc: hkallweit1, linux, davem, edumazet, kuba, pabeni, netdev,
	linux-kernel, stable



On 07.04.2023 17:20, Andrew Lunn wrote:
> On Thu, Apr 06, 2023 at 12:59:04PM +0300, Radu Pirea (OSS) wrote:
>> Unregister PTP clock when the driver is removed.
>> Purge the RX and TX skb queues.
>>
>> Fixes: 514def5dd339 ("phy: nxp-c45-tja11xx: add timestamping support")
>> CC: stable@vger.kernel.org # 5.15+
>> Signed-off-by: Radu Pirea (OSS) <radu-nicolae.pirea@oss.nxp.com>
>> ---
>>   drivers/net/phy/nxp-c45-tja11xx.c | 12 ++++++++++++
>>   1 file changed, 12 insertions(+)
>>
>> diff --git a/drivers/net/phy/nxp-c45-tja11xx.c b/drivers/net/phy/nxp-c45-tja11xx.c
>> index 5813b07242ce..27738d1ae9ea 100644
>> --- a/drivers/net/phy/nxp-c45-tja11xx.c
>> +++ b/drivers/net/phy/nxp-c45-tja11xx.c
>> @@ -1337,6 +1337,17 @@ static int nxp_c45_probe(struct phy_device *phydev)
>>   	return ret;
>>   }
>>   
>> +static void nxp_c45_remove(struct phy_device *phydev)
>> +{
>> +	struct nxp_c45_phy *priv = phydev->priv;
>> +
>> +	if (priv->ptp_clock)
>> +		ptp_clock_unregister(priv->ptp_clock);
>> +
>> +	skb_queue_purge(&priv->tx_queue);
>> +	skb_queue_purge(&priv->rx_queue);
> 
> Do you need to disable interrupts? I suppose the real question is, is
> it guaranteed phy_disconnect() is called before the driver is removed?
The MAC driver should call phy_disconnect() when it is removed. Also, 
the user should not be able to remove the PHY driver if is in uses.

Radu P.
> 
>     Andrew

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH net] net: phy: nxp-c45-tja11xx: add remove callback
  2023-04-07 17:42   ` Radu Pirea (OSS)
@ 2023-04-07 18:15     ` Andrew Lunn
  0 siblings, 0 replies; 7+ messages in thread
From: Andrew Lunn @ 2023-04-07 18:15 UTC (permalink / raw)
  To: Radu Pirea (OSS)
  Cc: hkallweit1, linux, davem, edumazet, kuba, pabeni, netdev,
	linux-kernel, stable

> > Do you need to disable interrupts? I suppose the real question is, is
> > it guaranteed phy_disconnect() is called before the driver is removed?
> The MAC driver should call phy_disconnect() when it is removed. Also, the
> user should not be able to remove the PHY driver if is in uses.

That was what i was thinking. But i've never unloaded a PHY driver, so
i've no idea what actually happens.

     Andrew

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH net] net: phy: nxp-c45-tja11xx: add remove callback
  2023-04-06  9:59 [PATCH net] net: phy: nxp-c45-tja11xx: add remove callback Radu Pirea (OSS)
  2023-04-07 14:20 ` Andrew Lunn
@ 2023-04-11 10:05 ` Paolo Abeni
  2023-04-11 12:45   ` Andrew Lunn
  2023-04-11 13:40 ` patchwork-bot+netdevbpf
  2 siblings, 1 reply; 7+ messages in thread
From: Paolo Abeni @ 2023-04-11 10:05 UTC (permalink / raw)
  To: Radu Pirea (OSS), andrew, hkallweit1, linux, davem, edumazet, kuba
  Cc: netdev, linux-kernel, stable

On Thu, 2023-04-06 at 12:59 +0300, Radu Pirea (OSS) wrote:
> Unregister PTP clock when the driver is removed.
> Purge the RX and TX skb queues.
> 
> Fixes: 514def5dd339 ("phy: nxp-c45-tja11xx: add timestamping support")
> CC: stable@vger.kernel.org # 5.15+
> Signed-off-by: Radu Pirea (OSS) <radu-nicolae.pirea@oss.nxp.com>

Andrew: my understanding is that a connected phy, maintains a reference
to the relevant driver via phydev->mdio.dev.driver->owner, and such
reference is dropped by phy_disconnect() via phy_detach().

So remove can invoked only after phy_disconnect

Does the above sounds reasonable/answer your question?

Thanks

Paolo


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH net] net: phy: nxp-c45-tja11xx: add remove callback
  2023-04-11 10:05 ` Paolo Abeni
@ 2023-04-11 12:45   ` Andrew Lunn
  0 siblings, 0 replies; 7+ messages in thread
From: Andrew Lunn @ 2023-04-11 12:45 UTC (permalink / raw)
  To: Paolo Abeni
  Cc: Radu Pirea (OSS),
	hkallweit1, linux, davem, edumazet, kuba, netdev, linux-kernel,
	stable

> Andrew: my understanding is that a connected phy, maintains a reference
> to the relevant driver via phydev->mdio.dev.driver->owner, and such
> reference is dropped by phy_disconnect() via phy_detach().
> 
> So remove can invoked only after phy_disconnect
> 
> Does the above sounds reasonable/answer your question?

Yes, that does seem logical.

Reviewed-by: Andrew Lunn <andrew@lunn.ch>

    Andrew

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH net] net: phy: nxp-c45-tja11xx: add remove callback
  2023-04-06  9:59 [PATCH net] net: phy: nxp-c45-tja11xx: add remove callback Radu Pirea (OSS)
  2023-04-07 14:20 ` Andrew Lunn
  2023-04-11 10:05 ` Paolo Abeni
@ 2023-04-11 13:40 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 7+ messages in thread
From: patchwork-bot+netdevbpf @ 2023-04-11 13:40 UTC (permalink / raw)
  To: Radu Pirea
  Cc: andrew, hkallweit1, linux, davem, edumazet, kuba, pabeni, netdev,
	linux-kernel, stable

Hello:

This patch was applied to netdev/net.git (main)
by Paolo Abeni <pabeni@redhat.com>:

On Thu,  6 Apr 2023 12:59:04 +0300 you wrote:
> Unregister PTP clock when the driver is removed.
> Purge the RX and TX skb queues.
> 
> Fixes: 514def5dd339 ("phy: nxp-c45-tja11xx: add timestamping support")
> CC: stable@vger.kernel.org # 5.15+
> Signed-off-by: Radu Pirea (OSS) <radu-nicolae.pirea@oss.nxp.com>
> 
> [...]

Here is the summary with links:
  - [net] net: phy: nxp-c45-tja11xx: add remove callback
    https://git.kernel.org/netdev/net/c/a4506722dc39

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2023-04-11 13:40 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-06  9:59 [PATCH net] net: phy: nxp-c45-tja11xx: add remove callback Radu Pirea (OSS)
2023-04-07 14:20 ` Andrew Lunn
2023-04-07 17:42   ` Radu Pirea (OSS)
2023-04-07 18:15     ` Andrew Lunn
2023-04-11 10:05 ` Paolo Abeni
2023-04-11 12:45   ` Andrew Lunn
2023-04-11 13:40 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®