* [PATCH] i2c: i801: Use PCI bus rescan mutex to protect P2SB access
@ 2021-09-05 15:59 Heiner Kallweit
2021-09-06 8:30 ` Andy Shevchenko
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Heiner Kallweit @ 2021-09-05 15:59 UTC (permalink / raw)
To: Jean Delvare; +Cc: linux-i2c@vger.kernel.org, Andy Shevchenko
As pointed out by Andy in [0] using a local mutex here isn't strictly
wrong but not sufficient. We should hold the PCI rescan lock for P2SB
operations.
[0] https://www.spinics.net/lists/linux-i2c/msg52717.html
Fixes: 1a987c69ce2c ("i2c: i801: make p2sb_spinlock a mutex")
Reported-by: Andy Shevchenko <andriy.shevchenko@intel.com>
Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
drivers/i2c/busses/i2c-i801.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/drivers/i2c/busses/i2c-i801.c b/drivers/i2c/busses/i2c-i801.c
index 89ae78ef1..1f929e6c3 100644
--- a/drivers/i2c/busses/i2c-i801.c
+++ b/drivers/i2c/busses/i2c-i801.c
@@ -1493,7 +1493,6 @@ static struct platform_device *
i801_add_tco_spt(struct i801_priv *priv, struct pci_dev *pci_dev,
struct resource *tco_res)
{
- static DEFINE_MUTEX(p2sb_mutex);
struct resource *res;
unsigned int devfn;
u64 base64_addr;
@@ -1506,7 +1505,7 @@ i801_add_tco_spt(struct i801_priv *priv, struct pci_dev *pci_dev,
* enumerated by the PCI subsystem, so we need to unhide/hide it
* to lookup the P2SB BAR.
*/
- mutex_lock(&p2sb_mutex);
+ pci_lock_rescan_remove();
devfn = PCI_DEVFN(PCI_SLOT(pci_dev->devfn), 1);
@@ -1524,7 +1523,7 @@ i801_add_tco_spt(struct i801_priv *priv, struct pci_dev *pci_dev,
/* Hide the P2SB device, if it was hidden before */
if (hidden)
pci_bus_write_config_byte(pci_dev->bus, devfn, 0xe1, hidden);
- mutex_unlock(&p2sb_mutex);
+ pci_unlock_rescan_remove();
res = &tco_res[1];
if (pci_dev->device == PCI_DEVICE_ID_INTEL_DNV_SMBUS)
--
2.33.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] i2c: i801: Use PCI bus rescan mutex to protect P2SB access
2021-09-05 15:59 [PATCH] i2c: i801: Use PCI bus rescan mutex to protect P2SB access Heiner Kallweit
@ 2021-09-06 8:30 ` Andy Shevchenko
2021-09-06 9:21 ` Jean Delvare
2021-09-29 20:13 ` Wolfram Sang
2 siblings, 0 replies; 4+ messages in thread
From: Andy Shevchenko @ 2021-09-06 8:30 UTC (permalink / raw)
To: Heiner Kallweit; +Cc: Jean Delvare, linux-i2c@vger.kernel.org
On Sun, Sep 05, 2021 at 05:59:42PM +0200, Heiner Kallweit wrote:
> As pointed out by Andy in [0] using a local mutex here isn't strictly
> wrong but not sufficient. We should hold the PCI rescan lock for P2SB
> operations.
Thanks!
Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>
> [0] https://www.spinics.net/lists/linux-i2c/msg52717.html
>
> Fixes: 1a987c69ce2c ("i2c: i801: make p2sb_spinlock a mutex")
> Reported-by: Andy Shevchenko <andriy.shevchenko@intel.com>
> Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
> ---
> drivers/i2c/busses/i2c-i801.c | 5 ++---
> 1 file changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/i2c/busses/i2c-i801.c b/drivers/i2c/busses/i2c-i801.c
> index 89ae78ef1..1f929e6c3 100644
> --- a/drivers/i2c/busses/i2c-i801.c
> +++ b/drivers/i2c/busses/i2c-i801.c
> @@ -1493,7 +1493,6 @@ static struct platform_device *
> i801_add_tco_spt(struct i801_priv *priv, struct pci_dev *pci_dev,
> struct resource *tco_res)
> {
> - static DEFINE_MUTEX(p2sb_mutex);
> struct resource *res;
> unsigned int devfn;
> u64 base64_addr;
> @@ -1506,7 +1505,7 @@ i801_add_tco_spt(struct i801_priv *priv, struct pci_dev *pci_dev,
> * enumerated by the PCI subsystem, so we need to unhide/hide it
> * to lookup the P2SB BAR.
> */
> - mutex_lock(&p2sb_mutex);
> + pci_lock_rescan_remove();
>
> devfn = PCI_DEVFN(PCI_SLOT(pci_dev->devfn), 1);
>
> @@ -1524,7 +1523,7 @@ i801_add_tco_spt(struct i801_priv *priv, struct pci_dev *pci_dev,
> /* Hide the P2SB device, if it was hidden before */
> if (hidden)
> pci_bus_write_config_byte(pci_dev->bus, devfn, 0xe1, hidden);
> - mutex_unlock(&p2sb_mutex);
> + pci_unlock_rescan_remove();
>
> res = &tco_res[1];
> if (pci_dev->device == PCI_DEVICE_ID_INTEL_DNV_SMBUS)
> --
> 2.33.0
>
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] i2c: i801: Use PCI bus rescan mutex to protect P2SB access
2021-09-05 15:59 [PATCH] i2c: i801: Use PCI bus rescan mutex to protect P2SB access Heiner Kallweit
2021-09-06 8:30 ` Andy Shevchenko
@ 2021-09-06 9:21 ` Jean Delvare
2021-09-29 20:13 ` Wolfram Sang
2 siblings, 0 replies; 4+ messages in thread
From: Jean Delvare @ 2021-09-06 9:21 UTC (permalink / raw)
To: Heiner Kallweit; +Cc: linux-i2c, Andy Shevchenko
Hi Heiner,
On Sun, 05 Sep 2021 17:59:42 +0200, Heiner Kallweit wrote:
> As pointed out by Andy in [0] using a local mutex here isn't strictly
> wrong but not sufficient. We should hold the PCI rescan lock for P2SB
> operations.
>
> [0] https://www.spinics.net/lists/linux-i2c/msg52717.html
>
> Fixes: 1a987c69ce2c ("i2c: i801: make p2sb_spinlock a mutex")
> Reported-by: Andy Shevchenko <andriy.shevchenko@intel.com>
> Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
> ---
> drivers/i2c/busses/i2c-i801.c | 5 ++---
> 1 file changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/i2c/busses/i2c-i801.c b/drivers/i2c/busses/i2c-i801.c
> index 89ae78ef1..1f929e6c3 100644
> --- a/drivers/i2c/busses/i2c-i801.c
> +++ b/drivers/i2c/busses/i2c-i801.c
> @@ -1493,7 +1493,6 @@ static struct platform_device *
> i801_add_tco_spt(struct i801_priv *priv, struct pci_dev *pci_dev,
> struct resource *tco_res)
> {
> - static DEFINE_MUTEX(p2sb_mutex);
> struct resource *res;
> unsigned int devfn;
> u64 base64_addr;
> @@ -1506,7 +1505,7 @@ i801_add_tco_spt(struct i801_priv *priv, struct pci_dev *pci_dev,
> * enumerated by the PCI subsystem, so we need to unhide/hide it
> * to lookup the P2SB BAR.
> */
> - mutex_lock(&p2sb_mutex);
> + pci_lock_rescan_remove();
>
> devfn = PCI_DEVFN(PCI_SLOT(pci_dev->devfn), 1);
>
> @@ -1524,7 +1523,7 @@ i801_add_tco_spt(struct i801_priv *priv, struct pci_dev *pci_dev,
> /* Hide the P2SB device, if it was hidden before */
> if (hidden)
> pci_bus_write_config_byte(pci_dev->bus, devfn, 0xe1, hidden);
> - mutex_unlock(&p2sb_mutex);
> + pci_unlock_rescan_remove();
>
> res = &tco_res[1];
> if (pci_dev->device == PCI_DEVICE_ID_INTEL_DNV_SMBUS)
Looks good to me.
Reviewed-by: Jean Delvare <jdelvare@suse.de>
--
Jean Delvare
SUSE L3 Support
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] i2c: i801: Use PCI bus rescan mutex to protect P2SB access
2021-09-05 15:59 [PATCH] i2c: i801: Use PCI bus rescan mutex to protect P2SB access Heiner Kallweit
2021-09-06 8:30 ` Andy Shevchenko
2021-09-06 9:21 ` Jean Delvare
@ 2021-09-29 20:13 ` Wolfram Sang
2 siblings, 0 replies; 4+ messages in thread
From: Wolfram Sang @ 2021-09-29 20:13 UTC (permalink / raw)
To: Heiner Kallweit; +Cc: Jean Delvare, linux-i2c@vger.kernel.org, Andy Shevchenko
[-- Attachment #1: Type: text/plain, Size: 514 bytes --]
On Sun, Sep 05, 2021 at 05:59:42PM +0200, Heiner Kallweit wrote:
> As pointed out by Andy in [0] using a local mutex here isn't strictly
> wrong but not sufficient. We should hold the PCI rescan lock for P2SB
> operations.
>
> [0] https://www.spinics.net/lists/linux-i2c/msg52717.html
>
> Fixes: 1a987c69ce2c ("i2c: i801: make p2sb_spinlock a mutex")
> Reported-by: Andy Shevchenko <andriy.shevchenko@intel.com>
> Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Applied to for-next, thanks!
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-09-29 20:13 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-09-05 15:59 [PATCH] i2c: i801: Use PCI bus rescan mutex to protect P2SB access Heiner Kallweit
2021-09-06 8:30 ` Andy Shevchenko
2021-09-06 9:21 ` Jean Delvare
2021-09-29 20:13 ` Wolfram Sang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox