diff mbox series

[net-next] net: sfp: Stop SFP polling during shutdown

Message ID 1559330285-30246-2-git-send-email-hancock@sedsystems.ca
State Superseded
Delegated to: David Miller
Headers show
Series [net-next] net: sfp: Stop SFP polling during shutdown | expand

Commit Message

Robert Hancock May 31, 2019, 7:18 p.m. UTC
SFP device polling can cause problems during the shutdown process if the
parent devices of the network controller have been shut down already.
This problem was seen on the iMX6 platform with PCIe devices, where
accessing the device after the bus is shut down causes a hang.

Stop all delayed work in the SFP driver during the shutdown process to
avoid this problem.

Signed-off-by: Robert Hancock <hancock@sedsystems.ca>
---
 drivers/net/phy/sfp.c | 9 +++++++++
 1 file changed, 9 insertions(+)

Comments

Russell King (Oracle) May 31, 2019, 8:12 p.m. UTC | #1
On Fri, May 31, 2019 at 01:18:02PM -0600, Robert Hancock wrote:
> SFP device polling can cause problems during the shutdown process if the
> parent devices of the network controller have been shut down already.
> This problem was seen on the iMX6 platform with PCIe devices, where
> accessing the device after the bus is shut down causes a hang.
> 
> Stop all delayed work in the SFP driver during the shutdown process to
> avoid this problem.

What about interrupts?

> 
> Signed-off-by: Robert Hancock <hancock@sedsystems.ca>
> ---
>  drivers/net/phy/sfp.c | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/drivers/net/phy/sfp.c b/drivers/net/phy/sfp.c
> index 554acc8..6b6c83d 100644
> --- a/drivers/net/phy/sfp.c
> +++ b/drivers/net/phy/sfp.c
> @@ -1928,9 +1928,18 @@ static int sfp_remove(struct platform_device *pdev)
>  	return 0;
>  }
>  
> +static void sfp_shutdown(struct platform_device *pdev)
> +{
> +	struct sfp *sfp = platform_get_drvdata(pdev);
> +
> +	cancel_delayed_work_sync(&sfp->poll);
> +	cancel_delayed_work_sync(&sfp->timeout);
> +}
> +
>  static struct platform_driver sfp_driver = {
>  	.probe = sfp_probe,
>  	.remove = sfp_remove,
> +	.shutdown = sfp_shutdown,
>  	.driver = {
>  		.name = "sfp",
>  		.of_match_table = sfp_of_match,
> -- 
> 1.8.3.1
> 
>
Robert Hancock May 31, 2019, 10:40 p.m. UTC | #2
On 2019-05-31 2:12 p.m., Russell King - ARM Linux admin wrote:
> On Fri, May 31, 2019 at 01:18:02PM -0600, Robert Hancock wrote:
>> SFP device polling can cause problems during the shutdown process if the
>> parent devices of the network controller have been shut down already.
>> This problem was seen on the iMX6 platform with PCIe devices, where
>> accessing the device after the bus is shut down causes a hang.
>>
>> Stop all delayed work in the SFP driver during the shutdown process to
>> avoid this problem.
> 
> What about interrupts?

Indeed, missed that as the GPIO controller this was being used with
didn't support interrupts. Will update the patch.
diff mbox series

Patch

diff --git a/drivers/net/phy/sfp.c b/drivers/net/phy/sfp.c
index 554acc8..6b6c83d 100644
--- a/drivers/net/phy/sfp.c
+++ b/drivers/net/phy/sfp.c
@@ -1928,9 +1928,18 @@  static int sfp_remove(struct platform_device *pdev)
 	return 0;
 }
 
+static void sfp_shutdown(struct platform_device *pdev)
+{
+	struct sfp *sfp = platform_get_drvdata(pdev);
+
+	cancel_delayed_work_sync(&sfp->poll);
+	cancel_delayed_work_sync(&sfp->timeout);
+}
+
 static struct platform_driver sfp_driver = {
 	.probe = sfp_probe,
 	.remove = sfp_remove,
+	.shutdown = sfp_shutdown,
 	.driver = {
 		.name = "sfp",
 		.of_match_table = sfp_of_match,