public inbox for linux-pci@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] PCI: Make PCI cfg_access_lock lockdep key a singleton
@ 2024-05-28 23:22 Dan Williams
  2024-05-28 23:25 ` Dave Jiang
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Dan Williams @ 2024-05-28 23:22 UTC (permalink / raw)
  To: bhelgaas; +Cc: Jani Saarinen, Dave Jiang, linux-cxl, linux-pci

The new lockdep annotation for cfg_access_lock naively registered a new
key per device. This is overkill and leads to warnings on hash
collisions at dynamic registration time:

 WARNING: CPU: 0 PID: 1 at kernel/locking/lockdep.c:1226 lockdep_register_key+0xb0/0x240
 RIP: 0010:lockdep_register_key+0xb0/0x240
 [..]
 Call Trace:
  <TASK>
  ? __warn+0x8c/0x190
  ? lockdep_register_key+0xb0/0x240
  ? report_bug+0x1f8/0x200
  ? handle_bug+0x3c/0x70
  ? exc_invalid_op+0x18/0x70
  ? asm_exc_invalid_op+0x1a/0x20
  ? lockdep_register_key+0xb0/0x240
  pci_device_add+0x14b/0x560
  ? pci_setup_device+0x42e/0x6a0
  pci_scan_single_device+0xa7/0xd0
  p2sb_scan_and_cache_devfn+0xc/0x90
  p2sb_fs_init+0x15f/0x170

Switch to a shared static key for all instances.

Fixes: 7e89efc6e9e4 ("PCI: Lock upstream bridge for pci_reset_function()")
Reported-by: Jani Saarinen <jani.saarinen@intel.com>
Closes: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_14834/bat-apl-1/boot0.txt
Cc: Dave Jiang <dave.jiang@intel.com>
Cc: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
Hi Bjorn,

One more fallout from the cfg_access_lock lockdep annotation. This one
still wants a Tested-by from Jani before merging, but wanted to make you
aware of it in case similar reports make their way to you in the
meantime.

 drivers/pci/probe.c |    7 ++++---
 include/linux/pci.h |    1 -
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 8e696e547565..15168881ec94 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -2533,6 +2533,8 @@ static void pci_set_msi_domain(struct pci_dev *dev)
 	dev_set_msi_domain(&dev->dev, d);
 }
 
+static struct lock_class_key cfg_access_key;
+
 void pci_device_add(struct pci_dev *dev, struct pci_bus *bus)
 {
 	int ret;
@@ -2546,9 +2548,8 @@ void pci_device_add(struct pci_dev *dev, struct pci_bus *bus)
 	dev->dev.dma_mask = &dev->dma_mask;
 	dev->dev.dma_parms = &dev->dma_parms;
 	dev->dev.coherent_dma_mask = 0xffffffffull;
-	lockdep_register_key(&dev->cfg_access_key);
-	lockdep_init_map(&dev->cfg_access_lock, dev_name(&dev->dev),
-			 &dev->cfg_access_key, 0);
+	lockdep_init_map(&dev->cfg_access_lock, "&dev->cfg_access_lock",
+			 &cfg_access_key, 0);
 
 	dma_set_max_seg_size(&dev->dev, 65536);
 	dma_set_seg_boundary(&dev->dev, 0xffffffff);
diff --git a/include/linux/pci.h b/include/linux/pci.h
index fb004fd4e889..5bece7fd11f8 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -413,7 +413,6 @@ struct pci_dev {
 	struct resource driver_exclusive_resource;	 /* driver exclusive resource ranges */
 
 	bool		match_driver;		/* Skip attaching driver */
-	struct lock_class_key cfg_access_key;
 	struct lockdep_map cfg_access_lock;
 
 	unsigned int	transparent:1;		/* Subtractive decode bridge */


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

* Re: [PATCH] PCI: Make PCI cfg_access_lock lockdep key a singleton
  2024-05-28 23:22 [PATCH] PCI: Make PCI cfg_access_lock lockdep key a singleton Dan Williams
@ 2024-05-28 23:25 ` Dave Jiang
  2024-05-29  0:00 ` Alison Schofield
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Dave Jiang @ 2024-05-28 23:25 UTC (permalink / raw)
  To: Dan Williams, bhelgaas; +Cc: Jani Saarinen, linux-cxl, linux-pci



On 5/28/24 4:22 PM, Dan Williams wrote:
> The new lockdep annotation for cfg_access_lock naively registered a new
> key per device. This is overkill and leads to warnings on hash
> collisions at dynamic registration time:
> 
>  WARNING: CPU: 0 PID: 1 at kernel/locking/lockdep.c:1226 lockdep_register_key+0xb0/0x240
>  RIP: 0010:lockdep_register_key+0xb0/0x240
>  [..]
>  Call Trace:
>   <TASK>
>   ? __warn+0x8c/0x190
>   ? lockdep_register_key+0xb0/0x240
>   ? report_bug+0x1f8/0x200
>   ? handle_bug+0x3c/0x70
>   ? exc_invalid_op+0x18/0x70
>   ? asm_exc_invalid_op+0x1a/0x20
>   ? lockdep_register_key+0xb0/0x240
>   pci_device_add+0x14b/0x560
>   ? pci_setup_device+0x42e/0x6a0
>   pci_scan_single_device+0xa7/0xd0
>   p2sb_scan_and_cache_devfn+0xc/0x90
>   p2sb_fs_init+0x15f/0x170
> 
> Switch to a shared static key for all instances.
> 
> Fixes: 7e89efc6e9e4 ("PCI: Lock upstream bridge for pci_reset_function()")
> Reported-by: Jani Saarinen <jani.saarinen@intel.com>
> Closes: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_14834/bat-apl-1/boot0.txt
> Cc: Dave Jiang <dave.jiang@intel.com>
> Cc: Bjorn Helgaas <bhelgaas@google.com>
> Signed-off-by: Dan Williams <dan.j.williams@intel.com>

Reviewed-by: Dave Jiang <dave.jiang@intel.com>

> ---
> Hi Bjorn,
> 
> One more fallout from the cfg_access_lock lockdep annotation. This one
> still wants a Tested-by from Jani before merging, but wanted to make you
> aware of it in case similar reports make their way to you in the
> meantime.
> 
>  drivers/pci/probe.c |    7 ++++---
>  include/linux/pci.h |    1 -
>  2 files changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
> index 8e696e547565..15168881ec94 100644
> --- a/drivers/pci/probe.c
> +++ b/drivers/pci/probe.c
> @@ -2533,6 +2533,8 @@ static void pci_set_msi_domain(struct pci_dev *dev)
>  	dev_set_msi_domain(&dev->dev, d);
>  }
>  
> +static struct lock_class_key cfg_access_key;
> +
>  void pci_device_add(struct pci_dev *dev, struct pci_bus *bus)
>  {
>  	int ret;
> @@ -2546,9 +2548,8 @@ void pci_device_add(struct pci_dev *dev, struct pci_bus *bus)
>  	dev->dev.dma_mask = &dev->dma_mask;
>  	dev->dev.dma_parms = &dev->dma_parms;
>  	dev->dev.coherent_dma_mask = 0xffffffffull;
> -	lockdep_register_key(&dev->cfg_access_key);
> -	lockdep_init_map(&dev->cfg_access_lock, dev_name(&dev->dev),
> -			 &dev->cfg_access_key, 0);
> +	lockdep_init_map(&dev->cfg_access_lock, "&dev->cfg_access_lock",
> +			 &cfg_access_key, 0);
>  
>  	dma_set_max_seg_size(&dev->dev, 65536);
>  	dma_set_seg_boundary(&dev->dev, 0xffffffff);
> diff --git a/include/linux/pci.h b/include/linux/pci.h
> index fb004fd4e889..5bece7fd11f8 100644
> --- a/include/linux/pci.h
> +++ b/include/linux/pci.h
> @@ -413,7 +413,6 @@ struct pci_dev {
>  	struct resource driver_exclusive_resource;	 /* driver exclusive resource ranges */
>  
>  	bool		match_driver;		/* Skip attaching driver */
> -	struct lock_class_key cfg_access_key;
>  	struct lockdep_map cfg_access_lock;
>  
>  	unsigned int	transparent:1;		/* Subtractive decode bridge */
> 

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

* Re: [PATCH] PCI: Make PCI cfg_access_lock lockdep key a singleton
  2024-05-28 23:22 [PATCH] PCI: Make PCI cfg_access_lock lockdep key a singleton Dan Williams
  2024-05-28 23:25 ` Dave Jiang
@ 2024-05-29  0:00 ` Alison Schofield
  2024-05-29 15:22 ` Saarinen, Jani
  2024-05-30 17:36 ` Bjorn Helgaas
  3 siblings, 0 replies; 5+ messages in thread
From: Alison Schofield @ 2024-05-29  0:00 UTC (permalink / raw)
  To: Dan Williams; +Cc: bhelgaas, Jani Saarinen, Dave Jiang, linux-cxl, linux-pci

On Tue, May 28, 2024 at 04:22:59PM -0700, Dan Williams wrote:
> The new lockdep annotation for cfg_access_lock naively registered a new
> key per device. This is overkill and leads to warnings on hash
> collisions at dynamic registration time:
> 
>  WARNING: CPU: 0 PID: 1 at kernel/locking/lockdep.c:1226 lockdep_register_key+0xb0/0x240
>  RIP: 0010:lockdep_register_key+0xb0/0x240
>  [..]
>  Call Trace:
>   <TASK>
>   ? __warn+0x8c/0x190
>   ? lockdep_register_key+0xb0/0x240
>   ? report_bug+0x1f8/0x200
>   ? handle_bug+0x3c/0x70
>   ? exc_invalid_op+0x18/0x70
>   ? asm_exc_invalid_op+0x1a/0x20
>   ? lockdep_register_key+0xb0/0x240
>   pci_device_add+0x14b/0x560
>   ? pci_setup_device+0x42e/0x6a0
>   pci_scan_single_device+0xa7/0xd0
>   p2sb_scan_and_cache_devfn+0xc/0x90
>   p2sb_fs_init+0x15f/0x170
> 
> Switch to a shared static key for all instances.
> 
> Fixes: 7e89efc6e9e4 ("PCI: Lock upstream bridge for pci_reset_function()")
> Reported-by: Jani Saarinen <jani.saarinen@intel.com>
> Closes: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_14834/bat-apl-1/boot0.txt
> Cc: Dave Jiang <dave.jiang@intel.com>
> Cc: Bjorn Helgaas <bhelgaas@google.com>
> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
> ---

Reviewed-by: Alison Schofield <alison.schofield@intel.com>

> 

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

* RE: [PATCH] PCI: Make PCI cfg_access_lock lockdep key a singleton
  2024-05-28 23:22 [PATCH] PCI: Make PCI cfg_access_lock lockdep key a singleton Dan Williams
  2024-05-28 23:25 ` Dave Jiang
  2024-05-29  0:00 ` Alison Schofield
@ 2024-05-29 15:22 ` Saarinen, Jani
  2024-05-30 17:36 ` Bjorn Helgaas
  3 siblings, 0 replies; 5+ messages in thread
From: Saarinen, Jani @ 2024-05-29 15:22 UTC (permalink / raw)
  To: Williams, Dan J, bhelgaas@google.com
  Cc: Jiang, Dave, linux-cxl@vger.kernel.org, linux-pci@vger.kernel.org,
	Deak, Imre

Hi,

> -----Original Message-----
> From: Williams, Dan J <dan.j.williams@intel.com>
> Sent: Wednesday, 29 May 2024 2.23
> To: bhelgaas@google.com
> Cc: Saarinen, Jani <jani.saarinen@intel.com>; Jiang, Dave
> <dave.jiang@intel.com>; linux-cxl@vger.kernel.org; linux-pci@vger.kernel.org
> Subject: [PATCH] PCI: Make PCI cfg_access_lock lockdep key a singleton
> 
> The new lockdep annotation for cfg_access_lock naively registered a new key
> per device. This is overkill and leads to warnings on hash collisions at
> dynamic registration time:
> 
>  WARNING: CPU: 0 PID: 1 at kernel/locking/lockdep.c:1226
> lockdep_register_key+0xb0/0x240
>  RIP: 0010:lockdep_register_key+0xb0/0x240
>  [..]
>  Call Trace:
>   <TASK>
>   ? __warn+0x8c/0x190
>   ? lockdep_register_key+0xb0/0x240
>   ? report_bug+0x1f8/0x200
>   ? handle_bug+0x3c/0x70
>   ? exc_invalid_op+0x18/0x70
>   ? asm_exc_invalid_op+0x1a/0x20
>   ? lockdep_register_key+0xb0/0x240
>   pci_device_add+0x14b/0x560
>   ? pci_setup_device+0x42e/0x6a0
>   pci_scan_single_device+0xa7/0xd0
>   p2sb_scan_and_cache_devfn+0xc/0x90
>   p2sb_fs_init+0x15f/0x170
> 
> Switch to a shared static key for all instances.
> 
> Fixes: 7e89efc6e9e4 ("PCI: Lock upstream bridge for pci_reset_function()")
> Reported-by: Jani Saarinen <jani.saarinen@intel.com>
> Closes: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_14834/bat-apl-
> 1/boot0.txt
> Cc: Dave Jiang <dave.jiang@intel.com>
> Cc: Bjorn Helgaas <bhelgaas@google.com>
> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
> ---
> Hi Bjorn,
> 
> One more fallout from the cfg_access_lock lockdep annotation. This one still
> wants a Tested-by from Jani before merging, but wanted to make you aware of
> it in case similar reports make their way to you in the meantime.

See patch sent to intel-gfx https://patchwork.freedesktop.org/series/134186/ 
=> https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_134186v1/index.html?hosts=apl
=> No taint in the boot and system does testing again: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_134186v1/bat-all.html?hosts=apl

With that:
Tested-By: Jani Saarinen <jani.saarinen@intel.com>

Br,
Jani

> 
>  drivers/pci/probe.c |    7 ++++---
>  include/linux/pci.h |    1 -
>  2 files changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index
> 8e696e547565..15168881ec94 100644
> --- a/drivers/pci/probe.c
> +++ b/drivers/pci/probe.c
> @@ -2533,6 +2533,8 @@ static void pci_set_msi_domain(struct pci_dev
> *dev)
>  	dev_set_msi_domain(&dev->dev, d);
>  }
> 
> +static struct lock_class_key cfg_access_key;
> +
>  void pci_device_add(struct pci_dev *dev, struct pci_bus *bus)  {
>  	int ret;
> @@ -2546,9 +2548,8 @@ void pci_device_add(struct pci_dev *dev, struct
> pci_bus *bus)
>  	dev->dev.dma_mask = &dev->dma_mask;
>  	dev->dev.dma_parms = &dev->dma_parms;
>  	dev->dev.coherent_dma_mask = 0xffffffffull;
> -	lockdep_register_key(&dev->cfg_access_key);
> -	lockdep_init_map(&dev->cfg_access_lock, dev_name(&dev->dev),
> -			 &dev->cfg_access_key, 0);
> +	lockdep_init_map(&dev->cfg_access_lock, "&dev->cfg_access_lock",
> +			 &cfg_access_key, 0);
> 
>  	dma_set_max_seg_size(&dev->dev, 65536);
>  	dma_set_seg_boundary(&dev->dev, 0xffffffff); diff --git
> a/include/linux/pci.h b/include/linux/pci.h index fb004fd4e889..5bece7fd11f8
> 100644
> --- a/include/linux/pci.h
> +++ b/include/linux/pci.h
> @@ -413,7 +413,6 @@ struct pci_dev {
>  	struct resource driver_exclusive_resource;	 /* driver exclusive
> resource ranges */
> 
>  	bool		match_driver;		/* Skip attaching driver */
> -	struct lock_class_key cfg_access_key;
>  	struct lockdep_map cfg_access_lock;
> 
>  	unsigned int	transparent:1;		/* Subtractive decode bridge
> */


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

* Re: [PATCH] PCI: Make PCI cfg_access_lock lockdep key a singleton
  2024-05-28 23:22 [PATCH] PCI: Make PCI cfg_access_lock lockdep key a singleton Dan Williams
                   ` (2 preceding siblings ...)
  2024-05-29 15:22 ` Saarinen, Jani
@ 2024-05-30 17:36 ` Bjorn Helgaas
  3 siblings, 0 replies; 5+ messages in thread
From: Bjorn Helgaas @ 2024-05-30 17:36 UTC (permalink / raw)
  To: Dan Williams
  Cc: bhelgaas, Jani Saarinen, Dave Jiang, linux-cxl, linux-pci,
	Alison Schofield, Imre Deak, Xinghui Li, Nirmal Patel,
	Jonathan Derrick, intel-gfx

[+cc Alison, Imre, et al.  IIUC this patch didn't help the similar
issue reported by Imre at
https://lore.kernel.org/r/ZlXP5oTnSApiDbD1@ideak-desk.fi.intel.com,
but just FYI]

On Tue, May 28, 2024 at 04:22:59PM -0700, Dan Williams wrote:
> The new lockdep annotation for cfg_access_lock naively registered a new
> key per device. This is overkill and leads to warnings on hash
> collisions at dynamic registration time:
> 
>  WARNING: CPU: 0 PID: 1 at kernel/locking/lockdep.c:1226 lockdep_register_key+0xb0/0x240
>  RIP: 0010:lockdep_register_key+0xb0/0x240
>  [..]
>  Call Trace:
>   <TASK>
>   ? __warn+0x8c/0x190
>   ? lockdep_register_key+0xb0/0x240
>   ? report_bug+0x1f8/0x200
>   ? handle_bug+0x3c/0x70
>   ? exc_invalid_op+0x18/0x70
>   ? asm_exc_invalid_op+0x1a/0x20
>   ? lockdep_register_key+0xb0/0x240
>   pci_device_add+0x14b/0x560
>   ? pci_setup_device+0x42e/0x6a0
>   pci_scan_single_device+0xa7/0xd0
>   p2sb_scan_and_cache_devfn+0xc/0x90
>   p2sb_fs_init+0x15f/0x170
> 
> Switch to a shared static key for all instances.
> 
> Fixes: 7e89efc6e9e4 ("PCI: Lock upstream bridge for pci_reset_function()")
> Reported-by: Jani Saarinen <jani.saarinen@intel.com>
> Closes: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_14834/bat-apl-1/boot0.txt
> Cc: Dave Jiang <dave.jiang@intel.com>
> Cc: Bjorn Helgaas <bhelgaas@google.com>
> Signed-off-by: Dan Williams <dan.j.williams@intel.com>

Applied with Alison's reviewed-by and Jani's tested-by to for-linus
for v6.10, thanks!



> ---
> Hi Bjorn,
> 
> One more fallout from the cfg_access_lock lockdep annotation. This one
> still wants a Tested-by from Jani before merging, but wanted to make you
> aware of it in case similar reports make their way to you in the
> meantime.
> 
>  drivers/pci/probe.c |    7 ++++---
>  include/linux/pci.h |    1 -
>  2 files changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
> index 8e696e547565..15168881ec94 100644
> --- a/drivers/pci/probe.c
> +++ b/drivers/pci/probe.c
> @@ -2533,6 +2533,8 @@ static void pci_set_msi_domain(struct pci_dev *dev)
>  	dev_set_msi_domain(&dev->dev, d);
>  }
>  
> +static struct lock_class_key cfg_access_key;
> +
>  void pci_device_add(struct pci_dev *dev, struct pci_bus *bus)
>  {
>  	int ret;
> @@ -2546,9 +2548,8 @@ void pci_device_add(struct pci_dev *dev, struct pci_bus *bus)
>  	dev->dev.dma_mask = &dev->dma_mask;
>  	dev->dev.dma_parms = &dev->dma_parms;
>  	dev->dev.coherent_dma_mask = 0xffffffffull;
> -	lockdep_register_key(&dev->cfg_access_key);
> -	lockdep_init_map(&dev->cfg_access_lock, dev_name(&dev->dev),
> -			 &dev->cfg_access_key, 0);
> +	lockdep_init_map(&dev->cfg_access_lock, "&dev->cfg_access_lock",
> +			 &cfg_access_key, 0);
>  
>  	dma_set_max_seg_size(&dev->dev, 65536);
>  	dma_set_seg_boundary(&dev->dev, 0xffffffff);
> diff --git a/include/linux/pci.h b/include/linux/pci.h
> index fb004fd4e889..5bece7fd11f8 100644
> --- a/include/linux/pci.h
> +++ b/include/linux/pci.h
> @@ -413,7 +413,6 @@ struct pci_dev {
>  	struct resource driver_exclusive_resource;	 /* driver exclusive resource ranges */
>  
>  	bool		match_driver;		/* Skip attaching driver */
> -	struct lock_class_key cfg_access_key;
>  	struct lockdep_map cfg_access_lock;
>  
>  	unsigned int	transparent:1;		/* Subtractive decode bridge */
> 

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

end of thread, other threads:[~2024-05-30 17:37 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-28 23:22 [PATCH] PCI: Make PCI cfg_access_lock lockdep key a singleton Dan Williams
2024-05-28 23:25 ` Dave Jiang
2024-05-29  0:00 ` Alison Schofield
2024-05-29 15:22 ` Saarinen, Jani
2024-05-30 17:36 ` Bjorn Helgaas

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