linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] PCI/PTM: Build debugfs code only if CONFIG_DEBUG_FS is enabled
@ 2025-06-08  3:33 Manivannan Sadhasivam
  2025-06-09  0:08 ` Eric Biggers
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Manivannan Sadhasivam @ 2025-06-08  3:33 UTC (permalink / raw)
  To: bhelgaas; +Cc: linux-pci, linux-kernel, Manivannan Sadhasivam, Eric Biggers

Otherwise, the following build error will happen for CONFIG_DEBUG_FS=n &&
CONFIG_PCIE_PTM=y.

    drivers/pci/pcie/ptm.c:498:25: error: redefinition of 'pcie_ptm_create_debugfs'
      498 | struct pci_ptm_debugfs *pcie_ptm_create_debugfs(struct device *dev, void *pdata,
          |                         ^
    ./include/linux/pci.h:1915:2: note: previous definition is here
     1915 | *pcie_ptm_create_debugfs(struct device *dev, void *pdata,
          |  ^
    drivers/pci/pcie/ptm.c:546:6: error: redefinition of 'pcie_ptm_destroy_debugfs'
      546 | void pcie_ptm_destroy_debugfs(struct pci_ptm_debugfs *ptm_debugfs)
          |      ^
    ./include/linux/pci.h:1918:1: note: previous definition is here
     1918 | pcie_ptm_destroy_debugfs(struct pci_ptm_debugfs *ptm_debugfs) { }
          |

Fixes: 132833405e61 ("PCI: Add debugfs support for exposing PTM context")
Reported-by: Eric Biggers <ebiggers@kernel.org>
Closes: https://lore.kernel.org/linux-pci/20250607025506.GA16607@sol
Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
---
 drivers/pci/pcie/ptm.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/pci/pcie/ptm.c b/drivers/pci/pcie/ptm.c
index ee5f615a9023..4bd73f038ffb 100644
--- a/drivers/pci/pcie/ptm.c
+++ b/drivers/pci/pcie/ptm.c
@@ -254,6 +254,7 @@ bool pcie_ptm_enabled(struct pci_dev *dev)
 }
 EXPORT_SYMBOL(pcie_ptm_enabled);
 
+#if IS_ENABLED(CONFIG_DEBUG_FS)
 static ssize_t context_update_write(struct file *file, const char __user *ubuf,
 			     size_t count, loff_t *ppos)
 {
@@ -552,3 +553,4 @@ void pcie_ptm_destroy_debugfs(struct pci_ptm_debugfs *ptm_debugfs)
 	debugfs_remove_recursive(ptm_debugfs->debugfs);
 }
 EXPORT_SYMBOL_GPL(pcie_ptm_destroy_debugfs);
+#endif
-- 
2.43.0


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

* Re: [PATCH] PCI/PTM: Build debugfs code only if CONFIG_DEBUG_FS is enabled
  2025-06-08  3:33 [PATCH] PCI/PTM: Build debugfs code only if CONFIG_DEBUG_FS is enabled Manivannan Sadhasivam
@ 2025-06-09  0:08 ` Eric Biggers
  2025-06-09  3:13   ` Manivannan Sadhasivam
  2025-06-09 22:33 ` Sathyanarayanan Kuppuswamy
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 6+ messages in thread
From: Eric Biggers @ 2025-06-09  0:08 UTC (permalink / raw)
  To: Manivannan Sadhasivam; +Cc: bhelgaas, linux-pci, linux-kernel

On Sun, Jun 08, 2025 at 09:03:05AM +0530, Manivannan Sadhasivam wrote:
> Otherwise, the following build error will happen for CONFIG_DEBUG_FS=n &&
> CONFIG_PCIE_PTM=y.
> 
>     drivers/pci/pcie/ptm.c:498:25: error: redefinition of 'pcie_ptm_create_debugfs'
>       498 | struct pci_ptm_debugfs *pcie_ptm_create_debugfs(struct device *dev, void *pdata,
>           |                         ^
>     ./include/linux/pci.h:1915:2: note: previous definition is here
>      1915 | *pcie_ptm_create_debugfs(struct device *dev, void *pdata,
>           |  ^
>     drivers/pci/pcie/ptm.c:546:6: error: redefinition of 'pcie_ptm_destroy_debugfs'
>       546 | void pcie_ptm_destroy_debugfs(struct pci_ptm_debugfs *ptm_debugfs)
>           |      ^
>     ./include/linux/pci.h:1918:1: note: previous definition is here
>      1918 | pcie_ptm_destroy_debugfs(struct pci_ptm_debugfs *ptm_debugfs) { }
>           |
> 
> Fixes: 132833405e61 ("PCI: Add debugfs support for exposing PTM context")
> Reported-by: Eric Biggers <ebiggers@kernel.org>
> Closes: https://lore.kernel.org/linux-pci/20250607025506.GA16607@sol
> Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
> ---
>  drivers/pci/pcie/ptm.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/pci/pcie/ptm.c b/drivers/pci/pcie/ptm.c
> index ee5f615a9023..4bd73f038ffb 100644
> --- a/drivers/pci/pcie/ptm.c
> +++ b/drivers/pci/pcie/ptm.c
> @@ -254,6 +254,7 @@ bool pcie_ptm_enabled(struct pci_dev *dev)
>  }
>  EXPORT_SYMBOL(pcie_ptm_enabled);
>  
> +#if IS_ENABLED(CONFIG_DEBUG_FS)
>  static ssize_t context_update_write(struct file *file, const char __user *ubuf,
>  			     size_t count, loff_t *ppos)
>  {
> @@ -552,3 +553,4 @@ void pcie_ptm_destroy_debugfs(struct pci_ptm_debugfs *ptm_debugfs)
>  	debugfs_remove_recursive(ptm_debugfs->debugfs);
>  }
>  EXPORT_SYMBOL_GPL(pcie_ptm_destroy_debugfs);
> +#endif

Tested-by: Eric Biggers <ebiggers@kernel.org>

DEBUG_FS is a bool, not a tristate.  It would be more conventional to write
'#ifdef CONFIG_DEBUG_FS' instead of '#if IS_ENABLED(CONFIG_DEBUG_FS)'.

Also, the #if guards 300 lines of code.  Perhaps they belong in a separate .c
file?

- Eric

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

* Re: [PATCH] PCI/PTM: Build debugfs code only if CONFIG_DEBUG_FS is enabled
  2025-06-09  0:08 ` Eric Biggers
@ 2025-06-09  3:13   ` Manivannan Sadhasivam
  0 siblings, 0 replies; 6+ messages in thread
From: Manivannan Sadhasivam @ 2025-06-09  3:13 UTC (permalink / raw)
  To: Eric Biggers; +Cc: Manivannan Sadhasivam, bhelgaas, linux-pci, linux-kernel

On Sun, Jun 08, 2025 at 05:08:09PM -0700, Eric Biggers wrote:
> On Sun, Jun 08, 2025 at 09:03:05AM +0530, Manivannan Sadhasivam wrote:
> > Otherwise, the following build error will happen for CONFIG_DEBUG_FS=n &&
> > CONFIG_PCIE_PTM=y.
> > 
> >     drivers/pci/pcie/ptm.c:498:25: error: redefinition of 'pcie_ptm_create_debugfs'
> >       498 | struct pci_ptm_debugfs *pcie_ptm_create_debugfs(struct device *dev, void *pdata,
> >           |                         ^
> >     ./include/linux/pci.h:1915:2: note: previous definition is here
> >      1915 | *pcie_ptm_create_debugfs(struct device *dev, void *pdata,
> >           |  ^
> >     drivers/pci/pcie/ptm.c:546:6: error: redefinition of 'pcie_ptm_destroy_debugfs'
> >       546 | void pcie_ptm_destroy_debugfs(struct pci_ptm_debugfs *ptm_debugfs)
> >           |      ^
> >     ./include/linux/pci.h:1918:1: note: previous definition is here
> >      1918 | pcie_ptm_destroy_debugfs(struct pci_ptm_debugfs *ptm_debugfs) { }
> >           |
> > 
> > Fixes: 132833405e61 ("PCI: Add debugfs support for exposing PTM context")
> > Reported-by: Eric Biggers <ebiggers@kernel.org>
> > Closes: https://lore.kernel.org/linux-pci/20250607025506.GA16607@sol
> > Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
> > ---
> >  drivers/pci/pcie/ptm.c | 2 ++
> >  1 file changed, 2 insertions(+)
> > 
> > diff --git a/drivers/pci/pcie/ptm.c b/drivers/pci/pcie/ptm.c
> > index ee5f615a9023..4bd73f038ffb 100644
> > --- a/drivers/pci/pcie/ptm.c
> > +++ b/drivers/pci/pcie/ptm.c
> > @@ -254,6 +254,7 @@ bool pcie_ptm_enabled(struct pci_dev *dev)
> >  }
> >  EXPORT_SYMBOL(pcie_ptm_enabled);
> >  
> > +#if IS_ENABLED(CONFIG_DEBUG_FS)
> >  static ssize_t context_update_write(struct file *file, const char __user *ubuf,
> >  			     size_t count, loff_t *ppos)
> >  {
> > @@ -552,3 +553,4 @@ void pcie_ptm_destroy_debugfs(struct pci_ptm_debugfs *ptm_debugfs)
> >  	debugfs_remove_recursive(ptm_debugfs->debugfs);
> >  }
> >  EXPORT_SYMBOL_GPL(pcie_ptm_destroy_debugfs);
> > +#endif
> 
> Tested-by: Eric Biggers <ebiggers@kernel.org>
> 
> DEBUG_FS is a bool, not a tristate.  It would be more conventional to write
> '#ifdef CONFIG_DEBUG_FS' instead of '#if IS_ENABLED(CONFIG_DEBUG_FS)'.
> 

I intentionally wanted to avoid using '#ifdef' since mixing both '#ifdef' and
'#if IS_ENABLED' always create issues when one mistakenly uses the former for
tristate symbols. So I always prefer using '#if IS_ENABLED'.

> Also, the #if guards 300 lines of code.  Perhaps they belong in a separate .c
> file?
> 

Perhaps, but not for this fix patch.

- Mani

-- 
மணிவண்ணன் சதாசிவம்

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

* Re: [PATCH] PCI/PTM: Build debugfs code only if CONFIG_DEBUG_FS is enabled
  2025-06-08  3:33 [PATCH] PCI/PTM: Build debugfs code only if CONFIG_DEBUG_FS is enabled Manivannan Sadhasivam
  2025-06-09  0:08 ` Eric Biggers
@ 2025-06-09 22:33 ` Sathyanarayanan Kuppuswamy
  2025-06-17  3:43 ` Eric Biggers
  2025-06-23 18:07 ` Bjorn Helgaas
  3 siblings, 0 replies; 6+ messages in thread
From: Sathyanarayanan Kuppuswamy @ 2025-06-09 22:33 UTC (permalink / raw)
  To: Manivannan Sadhasivam, bhelgaas; +Cc: linux-pci, linux-kernel, Eric Biggers


On 6/7/25 8:33 PM, Manivannan Sadhasivam wrote:
> Otherwise, the following build error will happen for CONFIG_DEBUG_FS=n &&
> CONFIG_PCIE_PTM=y.
>
>      drivers/pci/pcie/ptm.c:498:25: error: redefinition of 'pcie_ptm_create_debugfs'
>        498 | struct pci_ptm_debugfs *pcie_ptm_create_debugfs(struct device *dev, void *pdata,
>            |                         ^
>      ./include/linux/pci.h:1915:2: note: previous definition is here
>       1915 | *pcie_ptm_create_debugfs(struct device *dev, void *pdata,
>            |  ^
>      drivers/pci/pcie/ptm.c:546:6: error: redefinition of 'pcie_ptm_destroy_debugfs'
>        546 | void pcie_ptm_destroy_debugfs(struct pci_ptm_debugfs *ptm_debugfs)
>            |      ^
>      ./include/linux/pci.h:1918:1: note: previous definition is here
>       1918 | pcie_ptm_destroy_debugfs(struct pci_ptm_debugfs *ptm_debugfs) { }
>            |
>
> Fixes: 132833405e61 ("PCI: Add debugfs support for exposing PTM context")
> Reported-by: Eric Biggers <ebiggers@kernel.org>
> Closes: https://lore.kernel.org/linux-pci/20250607025506.GA16607@sol
> Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
> ---

Looks good to me.

Reviewed-by: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com>
>   drivers/pci/pcie/ptm.c | 2 ++
>   1 file changed, 2 insertions(+)
>
> diff --git a/drivers/pci/pcie/ptm.c b/drivers/pci/pcie/ptm.c
> index ee5f615a9023..4bd73f038ffb 100644
> --- a/drivers/pci/pcie/ptm.c
> +++ b/drivers/pci/pcie/ptm.c
> @@ -254,6 +254,7 @@ bool pcie_ptm_enabled(struct pci_dev *dev)
>   }
>   EXPORT_SYMBOL(pcie_ptm_enabled);
>   
> +#if IS_ENABLED(CONFIG_DEBUG_FS)
>   static ssize_t context_update_write(struct file *file, const char __user *ubuf,
>   			     size_t count, loff_t *ppos)
>   {
> @@ -552,3 +553,4 @@ void pcie_ptm_destroy_debugfs(struct pci_ptm_debugfs *ptm_debugfs)
>   	debugfs_remove_recursive(ptm_debugfs->debugfs);
>   }
>   EXPORT_SYMBOL_GPL(pcie_ptm_destroy_debugfs);
> +#endif

-- 
Sathyanarayanan Kuppuswamy
Linux Kernel Developer


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

* Re: [PATCH] PCI/PTM: Build debugfs code only if CONFIG_DEBUG_FS is enabled
  2025-06-08  3:33 [PATCH] PCI/PTM: Build debugfs code only if CONFIG_DEBUG_FS is enabled Manivannan Sadhasivam
  2025-06-09  0:08 ` Eric Biggers
  2025-06-09 22:33 ` Sathyanarayanan Kuppuswamy
@ 2025-06-17  3:43 ` Eric Biggers
  2025-06-23 18:07 ` Bjorn Helgaas
  3 siblings, 0 replies; 6+ messages in thread
From: Eric Biggers @ 2025-06-17  3:43 UTC (permalink / raw)
  To: Bjorn Helgaas; +Cc: linux-pci, linux-kernel, Manivannan Sadhasivam

On Sun, Jun 08, 2025 at 09:03:05AM +0530, Manivannan Sadhasivam wrote:
> Otherwise, the following build error will happen for CONFIG_DEBUG_FS=n &&
> CONFIG_PCIE_PTM=y.
> 
>     drivers/pci/pcie/ptm.c:498:25: error: redefinition of 'pcie_ptm_create_debugfs'
>       498 | struct pci_ptm_debugfs *pcie_ptm_create_debugfs(struct device *dev, void *pdata,
>           |                         ^
>     ./include/linux/pci.h:1915:2: note: previous definition is here
>      1915 | *pcie_ptm_create_debugfs(struct device *dev, void *pdata,
>           |  ^
>     drivers/pci/pcie/ptm.c:546:6: error: redefinition of 'pcie_ptm_destroy_debugfs'
>       546 | void pcie_ptm_destroy_debugfs(struct pci_ptm_debugfs *ptm_debugfs)
>           |      ^
>     ./include/linux/pci.h:1918:1: note: previous definition is here
>      1918 | pcie_ptm_destroy_debugfs(struct pci_ptm_debugfs *ptm_debugfs) { }
>           |
> 
> Fixes: 132833405e61 ("PCI: Add debugfs support for exposing PTM context")
> Reported-by: Eric Biggers <ebiggers@kernel.org>
> Closes: https://lore.kernel.org/linux-pci/20250607025506.GA16607@sol
> Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
> ---
>  drivers/pci/pcie/ptm.c | 2 ++
>  1 file changed, 2 insertions(+)

This is still broken in mainline.  Bjorn, can you apply this?

- Eric

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

* Re: [PATCH] PCI/PTM: Build debugfs code only if CONFIG_DEBUG_FS is enabled
  2025-06-08  3:33 [PATCH] PCI/PTM: Build debugfs code only if CONFIG_DEBUG_FS is enabled Manivannan Sadhasivam
                   ` (2 preceding siblings ...)
  2025-06-17  3:43 ` Eric Biggers
@ 2025-06-23 18:07 ` Bjorn Helgaas
  3 siblings, 0 replies; 6+ messages in thread
From: Bjorn Helgaas @ 2025-06-23 18:07 UTC (permalink / raw)
  To: Manivannan Sadhasivam; +Cc: bhelgaas, linux-pci, linux-kernel, Eric Biggers

On Sun, Jun 08, 2025 at 09:03:05AM +0530, Manivannan Sadhasivam wrote:
> Otherwise, the following build error will happen for CONFIG_DEBUG_FS=n &&
> CONFIG_PCIE_PTM=y.
> 
>     drivers/pci/pcie/ptm.c:498:25: error: redefinition of 'pcie_ptm_create_debugfs'
>       498 | struct pci_ptm_debugfs *pcie_ptm_create_debugfs(struct device *dev, void *pdata,
>           |                         ^
>     ./include/linux/pci.h:1915:2: note: previous definition is here
>      1915 | *pcie_ptm_create_debugfs(struct device *dev, void *pdata,
>           |  ^
>     drivers/pci/pcie/ptm.c:546:6: error: redefinition of 'pcie_ptm_destroy_debugfs'
>       546 | void pcie_ptm_destroy_debugfs(struct pci_ptm_debugfs *ptm_debugfs)
>           |      ^
>     ./include/linux/pci.h:1918:1: note: previous definition is here
>      1918 | pcie_ptm_destroy_debugfs(struct pci_ptm_debugfs *ptm_debugfs) { }

Why are struct pci_ptm_debugfs, pcie_ptm_create_debugfs_file(), and
pcie_ptm_destroy_debugfs() in include/linux/pci.h?  They look like
things that should be in drivers/pci/pci.h.

> Fixes: 132833405e61 ("PCI: Add debugfs support for exposing PTM context")
> Reported-by: Eric Biggers <ebiggers@kernel.org>
> Closes: https://lore.kernel.org/linux-pci/20250607025506.GA16607@sol
> Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>

Applied to pci/for-linus for v6.16, thanks!

> ---
>  drivers/pci/pcie/ptm.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/pci/pcie/ptm.c b/drivers/pci/pcie/ptm.c
> index ee5f615a9023..4bd73f038ffb 100644
> --- a/drivers/pci/pcie/ptm.c
> +++ b/drivers/pci/pcie/ptm.c
> @@ -254,6 +254,7 @@ bool pcie_ptm_enabled(struct pci_dev *dev)
>  }
>  EXPORT_SYMBOL(pcie_ptm_enabled);
>  
> +#if IS_ENABLED(CONFIG_DEBUG_FS)
>  static ssize_t context_update_write(struct file *file, const char __user *ubuf,
>  			     size_t count, loff_t *ppos)
>  {
> @@ -552,3 +553,4 @@ void pcie_ptm_destroy_debugfs(struct pci_ptm_debugfs *ptm_debugfs)
>  	debugfs_remove_recursive(ptm_debugfs->debugfs);
>  }
>  EXPORT_SYMBOL_GPL(pcie_ptm_destroy_debugfs);
> +#endif
> -- 
> 2.43.0
> 

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

end of thread, other threads:[~2025-06-23 18:07 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-08  3:33 [PATCH] PCI/PTM: Build debugfs code only if CONFIG_DEBUG_FS is enabled Manivannan Sadhasivam
2025-06-09  0:08 ` Eric Biggers
2025-06-09  3:13   ` Manivannan Sadhasivam
2025-06-09 22:33 ` Sathyanarayanan Kuppuswamy
2025-06-17  3:43 ` Eric Biggers
2025-06-23 18:07 ` Bjorn Helgaas

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).