spi: Don't have controller clean up spi device before driver unbind
PATCH v2 1/1 spi: Don't have controller clean up spi device before driver unbind
When a spi device is unregistered and triggers a driver unbind, the driver might need to access the spi device. So, don't have the controller clean up the spi device before the driver is unbound. Clean up the spi device after the driver is unbound.
---
v1->v2:
- Made the clean up more symmetric.
Lukas,
Can you test this one your end to make sure you don't have issues anymore?
Thanks,
Saravana
drivers/spi/spi.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/spi/spi.c +3 -3
@@ -714,8 +714,6 @@ void spi_unregister_device(struct spi_device *spi)if (!spi)return ; -spi_cleanup (spi); -if (spi->dev.of_node) {of_node_clear_flag (spi->dev.of_node,OF_POPULATED );of_node_put (spi->dev.of_node);
@@ -723,7 +721,9 @@ void spi_unregister_device(struct spi_device *spi)if (ACPI_COMPANION (&spi->dev))acpi_device_clear_enumerated (ACPI_COMPANION (&spi->dev));device_remove_software_node (&spi->dev); -device_unregister (&spi->dev); +device_del (&spi->dev); +spi_cleanup (spi); +put_device (&spi->dev); }EXPORT_SYMBOL_GPL (spi_unregister_device);
Signature · 1 line
2.31.1.527.g47e6f16901-goog
Quoted 8 lines · Saravana Kannan
When a spi device is unregistered and triggers a driver unbind, the driver might need to access the spi device. So, don't have the controller clean up the spi device before the driver is unbound. Clean up the spi device after the driver is unbound.
Fixes c7299fea6769 ("spi: Fix spi device unregister flow")Reported-by Lukas Wunner <[email protected]>
And
Suggested-by: Lukas ...
Quoted 1 line
Signed-off-by Saravana Kannan <[email protected]>
...
Quoted 2 lines
Can you test this one your end to make sure you don't have issues anymore?
Do you need a test on my setup?
...
drivers/spi/spi.c void spi_unregister_device(struct spi_device *spi) · line 726
Quoted 3 lines
drivers/spi/spi.c +3
-0+device_del (&spi->dev); +spi_cleanup (spi); +put_device (&spi->dev);
This block deserves a comment in the code.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Mark Brown
maintainerQuoted 6 lines · Andy Shevchenko
Quoted 2 lines · Saravana Kannan
Can you test this one your end to make sure you don't have issues anymore?
Do you need a test on my setup?
It wouldn't hurt.
Andy Shevchenko
Tested-byQuoted 10 lines · Mark Brown
Quoted 6 lines · Andy Shevchenko
Quoted 2 lines · Saravana Kannan
Can you test this one your end to make sure you don't have issues anymore?
Do you need a test on my setup?
It wouldn't hurt.
Okay, I have reverted first the "spi: Fix spi device unregister flow" to be sure I can reproduce the lockdep warning, indeed, it's there.
After applying the above mentioned patch it's gone.
On top I applied this ("spi: Don't have controller clean up spi device before driver unbind") patch to see if there is any changes, nope, seems everything is fine.
FWIW,
Signature · 2 lines
With Best Regards, Andy Shevchenko
Mark Brown
maintainerQuoted 4 lines · Saravana Kannan
When a spi device is unregistered and triggers a driver unbind, the driver might need to access the spi device. So, don't have the controller clean up the spi device before the driver is unbound. Clean up the spi device after the driver is unbound.
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git for-next
Thanks!
[1/1] spi: Don't have controller clean up spi device before driver unbind
commit: 27e7db56cf3dffd302bd7ddfacb1d405cf671a2a
All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark
Quoted 10 lines · Saravana Kannan
When a spi device is unregistered and triggers a driver unbind, the driver might need to access the spi device. So, don't have the controller clean up the spi device before the driver is unbound. Clean up the spi device after the driver is unbound.
Fixes c7299fea6769 ("spi: Fix spi device unregister flow")Reported-by Lukas Wunner <[email protected]>Signed-off-by Saravana Kannan <[email protected]>---
Quoted 7 lines
v1->v2:
- Made the clean up more symmetric.Lukas,
Can you test this one your end to make sure you don't have issues anymore?
My apologies for the delay, yesterday I was finally able to set up a RasPi in my home office and test the patch. I'm not seeing any issues when unloading/reloading the SPI controller module, so this LGTM.
Thanks,
Lukas