diff mbox series

PCI: ixp4xx: Use PCI_CONF1_ADDRESS() macro

Message ID 20220928122539.15116-1-pali@kernel.org
State New
Headers show
Series PCI: ixp4xx: Use PCI_CONF1_ADDRESS() macro | expand

Commit Message

Pali Rohár Sept. 28, 2022, 12:25 p.m. UTC
Simplify pci-ixp4xx.c driver code and use new PCI_CONF1_ADDRESS() macro for
accessing PCI config space.

Signed-off-by: Pali Rohár <pali@kernel.org>
---
 drivers/pci/controller/pci-ixp4xx.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

Comments

Linus Walleij Oct. 4, 2022, 7:56 a.m. UTC | #1
On Wed, Sep 28, 2022 at 2:25 PM Pali Rohár <pali@kernel.org> wrote:

> Simplify pci-ixp4xx.c driver code and use new PCI_CONF1_ADDRESS() macro for
> accessing PCI config space.
>
> Signed-off-by: Pali Rohár <pali@kernel.org>

I have no way to evaluate this change in my head, once the kernel test robot is
happy I can test the patch on IXP4xx.

Yours,
Linus Walleij
Pali Rohár Oct. 4, 2022, 8:41 a.m. UTC | #2
On Tuesday 04 October 2022 09:56:18 Linus Walleij wrote:
> On Wed, Sep 28, 2022 at 2:25 PM Pali Rohár <pali@kernel.org> wrote:
> 
> > Simplify pci-ixp4xx.c driver code and use new PCI_CONF1_ADDRESS() macro for
> > accessing PCI config space.
> >
> > Signed-off-by: Pali Rohár <pali@kernel.org>
> 
> I have no way to evaluate this change in my head, once the kernel test robot is
> happy I can test the patch on IXP4xx.
> 
> Yours,
> Linus Walleij

You just need to apply this change on Lorenzo's pci tree. Or wait until
Lorenzo's changes are propagated into master tree and then robot should
be happy.
Lorenzo Pieralisi March 10, 2023, 1:57 p.m. UTC | #3
On Tue, Oct 04, 2022 at 09:56:18AM +0200, Linus Walleij wrote:
> On Wed, Sep 28, 2022 at 2:25 PM Pali Rohár <pali@kernel.org> wrote:
> 
> > Simplify pci-ixp4xx.c driver code and use new PCI_CONF1_ADDRESS() macro for
> > accessing PCI config space.
> >
> > Signed-off-by: Pali Rohár <pali@kernel.org>
> 
> I have no way to evaluate this change in my head, once the kernel test robot is
> happy I can test the patch on IXP4xx.

If you can manage to test it I can go ahead and merge it.

Thanks,
Lorenzo

> Yours,
> Linus Walleij
Linus Walleij March 10, 2023, 10:38 p.m. UTC | #4
On Wed, Sep 28, 2022 at 2:25 PM Pali Rohár <pali@kernel.org> wrote:

> Simplify pci-ixp4xx.c driver code and use new PCI_CONF1_ADDRESS() macro for
> accessing PCI config space.
>
> Signed-off-by: Pali Rohár <pali@kernel.org>

This does not compile right off (on kernel v6.3-rc1), I had to add this:

diff --git a/drivers/pci/controller/pci-ixp4xx.c
b/drivers/pci/controller/pci-ixp4xx.c
index c83b5ae0b017..e44252db6085 100644
--- a/drivers/pci/controller/pci-ixp4xx.c
+++ b/drivers/pci/controller/pci-ixp4xx.c
@@ -26,6 +26,7 @@
 #include <linux/platform_device.h>
 #include <linux/slab.h>
 #include <linux/bits.h>
+#include "../pci.h"

 /* Register offsets */
 #define IXP4XX_PCI_NP_AD               0x00

After this it compiles, boots and mounts root on a PCI-USB-connected
rootfs, so it seems to work fine!
Tested-by: Linus Walleij <linus.walleij@linaro.org>

Yours,
Linus Walleij
Linus Walleij March 10, 2023, 10:38 p.m. UTC | #5
On Fri, Mar 10, 2023 at 2:57 PM Lorenzo Pieralisi <lpieralisi@kernel.org> wrote:
> On Tue, Oct 04, 2022 at 09:56:18AM +0200, Linus Walleij wrote:
> > On Wed, Sep 28, 2022 at 2:25 PM Pali Rohár <pali@kernel.org> wrote:
> >
> > > Simplify pci-ixp4xx.c driver code and use new PCI_CONF1_ADDRESS() macro for
> > > accessing PCI config space.
> > >
> > > Signed-off-by: Pali Rohár <pali@kernel.org>
> >
> > I have no way to evaluate this change in my head, once the kernel test robot is
> > happy I can test the patch on IXP4xx.
>
> If you can manage to test it I can go ahead and merge it.

I managed to test it with a oneliner to add the right include on top
of v6.3-rc1.

Yours,
Linus Walleij
Lorenzo Pieralisi March 24, 2023, 3:51 p.m. UTC | #6
On Wed, 28 Sep 2022 14:25:39 +0200, Pali Rohár wrote:
> Simplify pci-ixp4xx.c driver code and use new PCI_CONF1_ADDRESS() macro for
> accessing PCI config space.
> 
> 

Applied to controller/ixp4xx, thanks!

[1/1] PCI: ixp4xx: Use PCI_CONF1_ADDRESS() macro
      https://git.kernel.org/pci/pci/c/6c6fa1f3f771

Thanks,
Lorenzo
diff mbox series

Patch

diff --git a/drivers/pci/controller/pci-ixp4xx.c b/drivers/pci/controller/pci-ixp4xx.c
index 654ac4a82beb..c83b5ae0b017 100644
--- a/drivers/pci/controller/pci-ixp4xx.c
+++ b/drivers/pci/controller/pci-ixp4xx.c
@@ -188,12 +188,13 @@  static u32 ixp4xx_config_addr(u8 bus_num, u16 devfn, int where)
 	/* Root bus is always 0 in this hardware */
 	if (bus_num == 0) {
 		/* type 0 */
-		return BIT(32-PCI_SLOT(devfn)) | ((PCI_FUNC(devfn)) << 8) |
-			(where & ~3);
+		return (PCI_CONF1_ADDRESS(0, 0, PCI_FUNC(devfn), where) &
+			~PCI_CONF1_ENABLE) | BIT(32-PCI_SLOT(devfn));
 	} else {
 		/* type 1 */
-		return (bus_num << 16) | ((PCI_SLOT(devfn)) << 11) |
-			((PCI_FUNC(devfn)) << 8) | (where & ~3) | 1;
+		return (PCI_CONF1_ADDRESS(bus_num, PCI_SLOT(devfn),
+					  PCI_FUNC(devfn), where) &
+			~PCI_CONF1_ENABLE) | 1;
 	}
 }