linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] PCI: Use pcie_reset_state_t type in function arguments
@ 2021-07-13  0:25 Krzysztof Wilczyński
  2021-07-13  0:25 ` [PATCH 2/2] powerpc/eeh: " Krzysztof Wilczyński
  0 siblings, 1 reply; 4+ messages in thread
From: Krzysztof Wilczyński @ 2021-07-13  0:25 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Benjamin Herrenschmidt, Michael Ellerman, Oliver O'Halloran,
	Paul Mackerras, Russell Currey, linuxppc-dev, linux-pci

The pcie_reset_state_t type has been introduced in the commit
f7bdd12d234d ("pci: New PCI-E reset API") along with the enum
pcie_reset_state, but it has never been used for anything else
other than to define the members of the enumeration set in the
enum pcie_reset_state.

Thus, replace the direct use of enum pcie_reset_state in function
arguments and replace it with pcie_reset_state_t type so that the
argument type matches the type used in enum pcie_reset_state.

Signed-off-by: Krzysztof Wilczyński <kw@linux.com>
---
 drivers/pci/pci.c   | 4 ++--
 include/linux/pci.h | 5 ++---
 2 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index aacf575c15cf..5c3386a73eb1 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -2194,7 +2194,7 @@ EXPORT_SYMBOL(pci_disable_device);
  * implementation. Architecture implementations can override this.
  */
 int __weak pcibios_set_pcie_reset_state(struct pci_dev *dev,
-					enum pcie_reset_state state)
+					pcie_reset_state_t state)
 {
 	return -EINVAL;
 }
@@ -2206,7 +2206,7 @@ int __weak pcibios_set_pcie_reset_state(struct pci_dev *dev,
  *
  * Sets the PCI reset state for the device.
  */
-int pci_set_pcie_reset_state(struct pci_dev *dev, enum pcie_reset_state state)
+int pci_set_pcie_reset_state(struct pci_dev *dev, pcie_reset_state_t state)
 {
 	return pcibios_set_pcie_reset_state(dev, state);
 }
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 540b377ca8f6..15f93de69e6a 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -191,7 +191,6 @@ enum {
 };
 
 typedef unsigned int __bitwise pcie_reset_state_t;
-
 enum pcie_reset_state {
 	/* Reset is NOT asserted (Use to deassert reset) */
 	pcie_deassert_reset = (__force pcie_reset_state_t) 1,
@@ -1205,7 +1204,7 @@ extern unsigned int pcibios_max_latency;
 void pci_set_master(struct pci_dev *dev);
 void pci_clear_master(struct pci_dev *dev);
 
-int pci_set_pcie_reset_state(struct pci_dev *dev, enum pcie_reset_state state);
+int pci_set_pcie_reset_state(struct pci_dev *dev, pcie_reset_state_t state);
 int pci_set_cacheline_size(struct pci_dev *dev);
 int __must_check pci_set_mwi(struct pci_dev *dev);
 int __must_check pcim_set_mwi(struct pci_dev *dev);
@@ -2079,7 +2078,7 @@ extern u8 pci_cache_line_size;
 void pcibios_disable_device(struct pci_dev *dev);
 void pcibios_set_master(struct pci_dev *dev);
 int pcibios_set_pcie_reset_state(struct pci_dev *dev,
-				 enum pcie_reset_state state);
+				 pcie_reset_state_t state);
 int pcibios_add_device(struct pci_dev *dev);
 void pcibios_release_device(struct pci_dev *dev);
 #ifdef CONFIG_PCI
-- 
2.32.0


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

* [PATCH 2/2] powerpc/eeh: Use pcie_reset_state_t type in function arguments
  2021-07-13  0:25 [PATCH 1/2] PCI: Use pcie_reset_state_t type in function arguments Krzysztof Wilczyński
@ 2021-07-13  0:25 ` Krzysztof Wilczyński
  2022-03-10  8:51   ` Christophe Leroy
  0 siblings, 1 reply; 4+ messages in thread
From: Krzysztof Wilczyński @ 2021-07-13  0:25 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Benjamin Herrenschmidt, Michael Ellerman, Oliver O'Halloran,
	Paul Mackerras, Russell Currey, linuxppc-dev, linux-pci

The pcie_reset_state_t type has been introduced in the commit
f7bdd12d234d ("pci: New PCI-E reset API") along with the enum
pcie_reset_state, but it has never been used for anything else
other than to define the members of the enumeration set in the
enum pcie_reset_state.

Thus, replace the direct use of enum pcie_reset_state in function
arguments and replace it with pcie_reset_state_t type so that the
argument type matches the type used in enum pcie_reset_state.

Signed-off-by: Krzysztof Wilczyński <kw@linux.com>
---
 arch/powerpc/kernel/eeh.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/powerpc/kernel/eeh.c b/arch/powerpc/kernel/eeh.c
index 3bbdcc86d01b..15485abb89ff 100644
--- a/arch/powerpc/kernel/eeh.c
+++ b/arch/powerpc/kernel/eeh.c
@@ -714,7 +714,7 @@ static void eeh_restore_dev_state(struct eeh_dev *edev, void *userdata)
  * Return value:
  * 	0 if success
  */
-int pcibios_set_pcie_reset_state(struct pci_dev *dev, enum pcie_reset_state state)
+int pcibios_set_pcie_reset_state(struct pci_dev *dev, pcie_reset_state_t state)
 {
 	struct eeh_dev *edev = pci_dev_to_eeh_dev(dev);
 	struct eeh_pe *pe = eeh_dev_to_pe(edev);
-- 
2.32.0


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

* Re: [PATCH 2/2] powerpc/eeh: Use pcie_reset_state_t type in function arguments
  2021-07-13  0:25 ` [PATCH 2/2] powerpc/eeh: " Krzysztof Wilczyński
@ 2022-03-10  8:51   ` Christophe Leroy
  2022-03-24 22:09     ` Bjorn Helgaas
  0 siblings, 1 reply; 4+ messages in thread
From: Christophe Leroy @ 2022-03-10  8:51 UTC (permalink / raw)
  To: Krzysztof Wilczyński, Bjorn Helgaas
  Cc: linux-pci, Oliver O'Halloran, Paul Mackerras, linuxppc-dev



Le 13/07/2021 à 02:25, Krzysztof Wilczyński a écrit :
> The pcie_reset_state_t type has been introduced in the commit
> f7bdd12d234d ("pci: New PCI-E reset API") along with the enum
> pcie_reset_state, but it has never been used for anything else
> other than to define the members of the enumeration set in the
> enum pcie_reset_state.
> 
> Thus, replace the direct use of enum pcie_reset_state in function
> arguments and replace it with pcie_reset_state_t type so that the
> argument type matches the type used in enum pcie_reset_state.
> 
> Signed-off-by: Krzysztof Wilczyński <kw@linux.com>

I don't understand the purpose of this change. Does any tool like sparse 
of so reports an error here ?

My feeling is that by doing this you loose the added value of using an 
enumerate.

state is used in a switch/case, that's exactly what we expect from an enum.

By the way, I think you can't change the prototype of a weak function in 
a patch and not change it at the same time for the overloading function.

So should you still think this change is necessary, I think patch 1 and 
2 should be squashed together in one.

Christophe


> ---
>   arch/powerpc/kernel/eeh.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/powerpc/kernel/eeh.c b/arch/powerpc/kernel/eeh.c
> index 3bbdcc86d01b..15485abb89ff 100644
> --- a/arch/powerpc/kernel/eeh.c
> +++ b/arch/powerpc/kernel/eeh.c
> @@ -714,7 +714,7 @@ static void eeh_restore_dev_state(struct eeh_dev *edev, void *userdata)
>    * Return value:
>    * 	0 if success
>    */
> -int pcibios_set_pcie_reset_state(struct pci_dev *dev, enum pcie_reset_state state)
> +int pcibios_set_pcie_reset_state(struct pci_dev *dev, pcie_reset_state_t state)
>   {
>   	struct eeh_dev *edev = pci_dev_to_eeh_dev(dev);
>   	struct eeh_pe *pe = eeh_dev_to_pe(edev);

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

* Re: [PATCH 2/2] powerpc/eeh: Use pcie_reset_state_t type in function arguments
  2022-03-10  8:51   ` Christophe Leroy
@ 2022-03-24 22:09     ` Bjorn Helgaas
  0 siblings, 0 replies; 4+ messages in thread
From: Bjorn Helgaas @ 2022-03-24 22:09 UTC (permalink / raw)
  To: Christophe Leroy
  Cc: Krzysztof Wilczyński, Bjorn Helgaas, linux-pci,
	Oliver O'Halloran, linuxppc-dev, Paul Mackerras

On Thu, Mar 10, 2022 at 09:51:13AM +0100, Christophe Leroy wrote:
> Le 13/07/2021 à 02:25, Krzysztof Wilczyński a écrit :
> > The pcie_reset_state_t type has been introduced in the commit
> > f7bdd12d234d ("pci: New PCI-E reset API") along with the enum
> > pcie_reset_state, but it has never been used for anything else
> > other than to define the members of the enumeration set in the
> > enum pcie_reset_state.
> > 
> > Thus, replace the direct use of enum pcie_reset_state in function
> > arguments and replace it with pcie_reset_state_t type so that the
> > argument type matches the type used in enum pcie_reset_state.
> > 
> > Signed-off-by: Krzysztof Wilczyński <kw@linux.com>
> 
> I don't understand the purpose of this change. Does any tool like
> sparse of so reports an error here ?
> 
> My feeling is that by doing this you loose the added value of using
> an enumerate.
> 
> state is used in a switch/case, that's exactly what we expect from
> an enum.

I think this is true: in the patch below, we remove use of "enum
pcie_reset_state", so the compiler no longer knows that "state" is an
enum, and it cannot verify that "state" has a legal value in the
switch statement.  And at least with "gcc -Wall", it looks like it
*does* complain in that case.

Whether that value is worthwhile, I don't know.  AFAICT this is the
only place that uses "state", so there's not *much* value.

If we did apply the patch below, I think we could probably make "enum
pcie_reset_state" an anonymous enum instead, like the enum for
pci_channel_state_t.

But let's back up for a minute.  This is only used in the
pci_set_pcie_reset_state() path, and that's only used by three
drivers: cxl, genwqe, and ipr, and obviously only on powerpc, since
that's the only arch that implements pcibios_set_pcie_reset_state().

What's special about them?  Why do they need this and no other drivers
do?  And why only on powerpc?

I wonder if that powerpc functionality could be implemented in some
way that's more integrated into the PCI core reset and error handling
framework.

> > ---
> >   arch/powerpc/kernel/eeh.c | 2 +-
> >   1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/arch/powerpc/kernel/eeh.c b/arch/powerpc/kernel/eeh.c
> > index 3bbdcc86d01b..15485abb89ff 100644
> > --- a/arch/powerpc/kernel/eeh.c
> > +++ b/arch/powerpc/kernel/eeh.c
> > @@ -714,7 +714,7 @@ static void eeh_restore_dev_state(struct eeh_dev *edev, void *userdata)
> >    * Return value:
> >    * 	0 if success
> >    */
> > -int pcibios_set_pcie_reset_state(struct pci_dev *dev, enum pcie_reset_state state)
> > +int pcibios_set_pcie_reset_state(struct pci_dev *dev, pcie_reset_state_t state)
> >   {
> >   	struct eeh_dev *edev = pci_dev_to_eeh_dev(dev);
> >   	struct eeh_pe *pe = eeh_dev_to_pe(edev);

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

end of thread, other threads:[~2022-03-24 22:09 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-13  0:25 [PATCH 1/2] PCI: Use pcie_reset_state_t type in function arguments Krzysztof Wilczyński
2021-07-13  0:25 ` [PATCH 2/2] powerpc/eeh: " Krzysztof Wilczyński
2022-03-10  8:51   ` Christophe Leroy
2022-03-24 22:09     ` 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).