diff mbox

[v10,06/59] PCI: Kill wrong quirk about M7101

Message ID CAE9FiQVAPfb-PYGQoRJzXdn3NAOK-X25M9pWvR2m7_9qT5qQ+w@mail.gmail.com (mailing list archive)
State New, archived
Delegated to: Bjorn Helgaas
Headers show

Commit Message

Yinghai Lu March 11, 2016, 10:08 p.m. UTC
On Thu, Mar 10, 2016 at 9:40 AM, Bjorn Helgaas <helgaas@kernel.org> wrote:
> On Wed, Feb 24, 2016 at 06:11:57PM -0800, Yinghai Lu wrote:
>> Meelis reported that qla2000 driver does not get loaded on one sparc system.
>>
>> schizo f00732d0: PCI host bridge to bus 0001:00
>> pci_bus 0001:00: root bus resource [io  0x7fe01000000-0x7fe01ffffff] (bus address [0x0000-0xffffff])
>> pci 0001:00:06.0: quirk: [io  0x7fe01000800-0x7fe0100083f] claimed by ali7101 ACPI
>> pci 0001:00:06.0: quirk: [io  0x7fe01000600-0x7fe0100061f] claimed by ali7101 SMB
>> pci 0001:00:07.0: can't claim BAR 0 [io  0x7fe01000000-0x7fe0100ffff]: address conflict with 0001:00:06.0 [io  0x7fe01000600-0x7fe0100061f]
>>
>> So the quirk for M7101 claim the io range early.
>>
>> According to spec with M7101 in M1543 page 103/104,
>>       http://www.versalogic.com/Support/Downloads/pdf/ali1543.pdf
>> 0xe0, and 0xe2 do not include address info for acpi/smb.
>>
>> Kill wrong quirk about them.
>
> This needs an explanation for why the quirk was added in the first
> place, and why it is now safe to remove it.

The related commit does not tell much about why it is there exactly.
But it is added the same time with intel piix4.

Maybe Linus could have some hint about that quirk?

commit 34f550135e349102bd065488eabbbb217ab27f0d
Author: Linus Torvalds <torvalds@linuxfoundation.org>
Date:   Fri Nov 23 15:32:20 2007 -0500

    Import 2.3.49pre2

  *  The main table of quirks.
@@ -143,6 +192,8 @@ static struct pci_fixup pci_fixups[] __initdata = {
        { PCI_FIXUP_FINAL,      PCI_VENDOR_ID_INTEL,
PCI_DEVICE_ID_INTEL_82443BX_2,  quirk_natoma },
        { PCI_FIXUP_FINAL,      PCI_VENDOR_ID_SI,
PCI_DEVICE_ID_SI_5597,          quirk_nopcipci },
        { PCI_FIXUP_FINAL,      PCI_VENDOR_ID_SI,
PCI_DEVICE_ID_SI_496,           quirk_nopcipci },
+       { PCI_FIXUP_FINAL,      PCI_VENDOR_ID_INTEL,
PCI_DEVICE_ID_INTEL_82371AB_3,  quirk_piix4acpi },
+       { PCI_FIXUP_FINAL,      PCI_VENDOR_ID_AL,
PCI_DEVICE_ID_AL_M7101,         quirk_ali7101 },
        { 0 }
 };
--
To unsubscribe from this list: send the line "unsubscribe linux-pci" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Linus Torvalds March 12, 2016, 1:06 a.m. UTC | #1
On Fri, Mar 11, 2016 at 2:08 PM, Yinghai Lu <yinghai@kernel.org> wrote:
>
> Maybe Linus could have some hint about that quirk?
>
> commit 34f550135e349102bd065488eabbbb217ab27f0d
> Author: Linus Torvalds <torvalds@linuxfoundation.org>
> Date:   Fri Nov 23 15:32:20 2007 -0500
>
>     Import 2.3.49pre2

Gah. That's marked as 2007, but that's an import of a much older
change, and 2.3.49 is way back in the last century.

But I looked at the datasheet for the M1543 PMU, and can confirm that
there's nothing at e0/e2 according to that datasheet. The PMU IO bases
show up at 0x10, and the SMB IO base at 0x14 in that doc..

Those kinds of things sometimes change between revisions, and it's
possible that there were versions that had them at that e0/e2 area,
and it got moved to the standard PCI BAR locations later.

I was definitely involved in these things, but my memory just doesn't
go back far enough to haev a clue what is going on. The only one I
remember working on myself was the PIIX4 one.

Removing it based on current datasheets and a failure of a known sparc
setup sounds reasonable.

                Linus
--
To unsubscribe from this list: send the line "unsubscribe linux-pci" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Meelis Roos March 12, 2016, 7:52 a.m. UTC | #2
> On Thu, Mar 10, 2016 at 9:40 AM, Bjorn Helgaas <helgaas@kernel.org> wrote:
> > On Wed, Feb 24, 2016 at 06:11:57PM -0800, Yinghai Lu wrote:
> >> Meelis reported that qla2000 driver does not get loaded on one sparc system.
> >>
> >> schizo f00732d0: PCI host bridge to bus 0001:00
> >> pci_bus 0001:00: root bus resource [io  0x7fe01000000-0x7fe01ffffff] (bus address [0x0000-0xffffff])
> >> pci 0001:00:06.0: quirk: [io  0x7fe01000800-0x7fe0100083f] claimed by ali7101 ACPI
> >> pci 0001:00:06.0: quirk: [io  0x7fe01000600-0x7fe0100061f] claimed by ali7101 SMB
> >> pci 0001:00:07.0: can't claim BAR 0 [io  0x7fe01000000-0x7fe0100ffff]: address conflict with 0001:00:06.0 [io  0x7fe01000600-0x7fe0100061f]
> >>
> >> So the quirk for M7101 claim the io range early.

But why did it work until 4.2 and only with 4.3 the allocations broke?


> >>
> >> According to spec with M7101 in M1543 page 103/104,
> >>       http://www.versalogic.com/Support/Downloads/pdf/ali1543.pdf
> >> 0xe0, and 0xe2 do not include address info for acpi/smb.
> >>
> >> Kill wrong quirk about them.
> >
> > This needs an explanation for why the quirk was added in the first
> > place, and why it is now safe to remove it.
> 
> The related commit does not tell much about why it is there exactly.
> But it is added the same time with intel piix4.
> 
> Maybe Linus could have some hint about that quirk?
> 
> commit 34f550135e349102bd065488eabbbb217ab27f0d
> Author: Linus Torvalds <torvalds@linuxfoundation.org>
> Date:   Fri Nov 23 15:32:20 2007 -0500
> 
>     Import 2.3.49pre2
> 
> diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
> index cda39a5..8029b19 100644
> --- a/drivers/pci/quirks.c
> +++ b/drivers/pci/quirks.c
> @@ -113,6 +113,55 @@ static void __init quirk_s3_64M(struct pci_dev *dev)
>         }
>  }
> 
> +static void __init quirk_io_region(struct pci_dev *dev, unsigned region, unsign
> ed size, int nr)
> +{
> +       region &= ~(size-1);
> +       if (region) {
> +               struct resource *res = dev->resource + nr;
> +
> +               res->name = dev->name;
> +               res->start = region;
> +               res->end = region + size - 1;
> +               res->flags = IORESOURCE_IO;
> +               pci_claim_resource(dev, nr);
> +       }
> +}
> +
> +/*
> + * Let's make the southbridge information explicit instead
> + * of having to worry about people probing the ACPI areas,
> + * for example.. (Yes, it happens, and if you read the wrong
> + * ACPI register it will put the machine to sleep with no
> + * way of waking it up again. Bummer).
> + *
> + * ALI M7101: Two IO regions pointed to by words at
> + *     0xE0 (64 bytes of ACPI registers)
> + *     0xE2 (32 bytes of SMB registers)
> + */
> +static void __init quirk_ali7101(struct pci_dev *dev)
> +{
> +       u16 region;
> +
> +       pci_read_config_word(dev, 0xE0, &region);
> +       quirk_io_region(dev, region, 64, PCI_BRIDGE_RESOURCES);
> +       pci_read_config_word(dev, 0xE2, &region);
> +       quirk_io_region(dev, region, 32, PCI_BRIDGE_RESOURCES+1);
> +}
> +
> +/*
> + * PIIX4 ACPI: Two IO regions pointed to by longwords at
> + *     0x40 (64 bytes of ACPI registers)
> + *     0x90 (32 bytes of SMB registers)
> + */
> +static void __init quirk_piix4acpi(struct pci_dev *dev)
> +{
> +       u32 region;
> +
> +       pci_read_config_dword(dev, 0x40, &region);
> +       quirk_io_region(dev, region, 64, PCI_BRIDGE_RESOURCES);
> +       pci_read_config_dword(dev, 0x90, &region);
> +       quirk_io_region(dev, region, 32, PCI_BRIDGE_RESOURCES+1);
> +}
> 
>  /*
>   *  The main table of quirks.
> @@ -143,6 +192,8 @@ static struct pci_fixup pci_fixups[] __initdata = {
>         { PCI_FIXUP_FINAL,      PCI_VENDOR_ID_INTEL,
> PCI_DEVICE_ID_INTEL_82443BX_2,  quirk_natoma },
>         { PCI_FIXUP_FINAL,      PCI_VENDOR_ID_SI,
> PCI_DEVICE_ID_SI_5597,          quirk_nopcipci },
>         { PCI_FIXUP_FINAL,      PCI_VENDOR_ID_SI,
> PCI_DEVICE_ID_SI_496,           quirk_nopcipci },
> +       { PCI_FIXUP_FINAL,      PCI_VENDOR_ID_INTEL,
> PCI_DEVICE_ID_INTEL_82371AB_3,  quirk_piix4acpi },
> +       { PCI_FIXUP_FINAL,      PCI_VENDOR_ID_AL,
> PCI_DEVICE_ID_AL_M7101,         quirk_ali7101 },
>         { 0 }
>  };
>
Yinghai Lu March 12, 2016, 8:26 a.m. UTC | #3
On Fri, Mar 11, 2016 at 11:52 PM, Meelis Roos <mroos@linux.ee> wrote:
>> On Thu, Mar 10, 2016 at 9:40 AM, Bjorn Helgaas <helgaas@kernel.org> wrote:
>> > On Wed, Feb 24, 2016 at 06:11:57PM -0800, Yinghai Lu wrote:
>> >> Meelis reported that qla2000 driver does not get loaded on one sparc system.
>> >>
>> >> schizo f00732d0: PCI host bridge to bus 0001:00
>> >> pci_bus 0001:00: root bus resource [io  0x7fe01000000-0x7fe01ffffff] (bus address [0x0000-0xffffff])
>> >> pci 0001:00:06.0: quirk: [io  0x7fe01000800-0x7fe0100083f] claimed by ali7101 ACPI
>> >> pci 0001:00:06.0: quirk: [io  0x7fe01000600-0x7fe0100061f] claimed by ali7101 SMB
>> >> pci 0001:00:07.0: can't claim BAR 0 [io  0x7fe01000000-0x7fe0100ffff]: address conflict with 0001:00:06.0 [io  0x7fe01000600-0x7fe0100061f]
>> >>
>> >> So the quirk for M7101 claim the io range early.
>
> But why did it work until 4.2 and only with 4.3 the allocations broke?
>

My understanding is we really install the root bus resource and try to
do the sanitary checking
for device resource.

Or did you find exact commit between 4.2 and 4.3 cause the problem ?

Thanks

Yinghai
--
To unsubscribe from this list: send the line "unsubscribe linux-pci" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Meelis Roos March 12, 2016, 8:39 a.m. UTC | #4
> On Fri, Mar 11, 2016 at 11:52 PM, Meelis Roos <mroos@linux.ee> wrote:
> >> On Thu, Mar 10, 2016 at 9:40 AM, Bjorn Helgaas <helgaas@kernel.org> wrote:
> >> > On Wed, Feb 24, 2016 at 06:11:57PM -0800, Yinghai Lu wrote:
> >> >> Meelis reported that qla2000 driver does not get loaded on one sparc system.
> >> >>
> >> >> schizo f00732d0: PCI host bridge to bus 0001:00
> >> >> pci_bus 0001:00: root bus resource [io  0x7fe01000000-0x7fe01ffffff] (bus address [0x0000-0xffffff])
> >> >> pci 0001:00:06.0: quirk: [io  0x7fe01000800-0x7fe0100083f] claimed by ali7101 ACPI
> >> >> pci 0001:00:06.0: quirk: [io  0x7fe01000600-0x7fe0100061f] claimed by ali7101 SMB
> >> >> pci 0001:00:07.0: can't claim BAR 0 [io  0x7fe01000000-0x7fe0100ffff]: address conflict with 0001:00:06.0 [io  0x7fe01000600-0x7fe0100061f]
> >> >>
> >> >> So the quirk for M7101 claim the io range early.
> >
> > But why did it work until 4.2 and only with 4.3 the allocations broke?
> >
> 
> My understanding is we really install the root bus resource and try to
> do the sanitary checking
> for device resource.
> 
> Or did you find exact commit between 4.2 and 4.3 cause the problem ?

No, I have not bisected that.
Bjorn Helgaas April 25, 2016, 8:57 p.m. UTC | #5
Hi Yinghai & Meelis,

On Sat, Mar 12, 2016 at 10:39:15AM +0200, Meelis Roos wrote:
> > On Fri, Mar 11, 2016 at 11:52 PM, Meelis Roos <mroos@linux.ee> wrote:
> > >> On Thu, Mar 10, 2016 at 9:40 AM, Bjorn Helgaas <helgaas@kernel.org> wrote:
> > >> > On Wed, Feb 24, 2016 at 06:11:57PM -0800, Yinghai Lu wrote:
> > >> >> Meelis reported that qla2000 driver does not get loaded on one sparc system.
> > >> >>
> > >> >> schizo f00732d0: PCI host bridge to bus 0001:00
> > >> >> pci_bus 0001:00: root bus resource [io  0x7fe01000000-0x7fe01ffffff] (bus address [0x0000-0xffffff])
> > >> >> pci 0001:00:06.0: quirk: [io  0x7fe01000800-0x7fe0100083f] claimed by ali7101 ACPI
> > >> >> pci 0001:00:06.0: quirk: [io  0x7fe01000600-0x7fe0100061f] claimed by ali7101 SMB
> > >> >> pci 0001:00:07.0: can't claim BAR 0 [io  0x7fe01000000-0x7fe0100ffff]: address conflict with 0001:00:06.0 [io  0x7fe01000600-0x7fe0100061f]
> > >> >>
> > >> >> So the quirk for M7101 claim the io range early.
> > >
> > > But why did it work until 4.2 and only with 4.3 the allocations broke?
> > >
> > 
> > My understanding is we really install the root bus resource and try to
> > do the sanitary checking
> > for device resource.
> > 
> > Or did you find exact commit between 4.2 and 4.3 cause the problem ?
> 
> No, I have not bisected that.

I'm confused again.

I opened https://bugzilla.kernel.org/show_bug.cgi?id=117191 and
attached dmesg logs and lspci output from Meelis' original bug report,
since you included URLs in the changelog (thank you for that), and I
don't want Meelis to have to worry about keeping the URLs alive.

I extracted the following from the v210 dmesg and lspci attached there
(I used these because they're the only matching pair of dmesg & lspci
I saw):

  PCI: Scanning PBM /pci@1e,600000
  schizo f00732d0: PCI host bridge to bus 0001:00
  pci_bus 0001:00: root bus resource [io  0x7fe01000000-0x7fe01ffffff] (bus address [0x0000-0xffffff])
  pci_bus 0001:00: root bus resource [mem 0x7ff00000000-0x7ffffffffff] (bus address [0x00000000-0xffffffff])
  pci_bus 0001:00: root bus resource [bus 00]
  pci 0001:00:06.0: quirk: [io  0x7fe01000800-0x7fe0100083f] claimed by ali7101 ACPI
  pci 0001:00:06.0: quirk: [io  0x7fe01000600-0x7fe0100061f] claimed by ali7101 SMB
  pci 0001:00:07.0: can't claim BAR 0 [io  0x7fe01000000-0x7fe0100ffff]: address conflict with 0001:00:06.0 [io  0x7fe01000600-0x7fe0100061f]
  pci 0001:00:07.0: can't claim BAR 1 [mem 0x7ff00000000-0x7ff000fffff]: address conflict with Video RAM area [??? 0x7ff000a0000-0x7ff000bffff flags 0x80000000]
  pci 0001:00:07.0: can't claim BAR 2 [mem 0x7ff00000000-0x7ff000fffff]: address conflict with Video RAM area [??? 0x7ff000a0000-0x7ff000bffff flags 0x80000000]

  0001:00:06.0 Non-VGA unclassified device: ULi Electronics Inc. M7101 Power Management Controller [PMU]
	  Control: I/O- Mem- BusMaster- SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx-
	  Status: Cap- 66MHz- UDF- FastB2B- ParErr- DEVSEL=medium >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
	  Region 0: [virtual] I/O ports at <unassigned> [size=16]
  00: b9 10 01 71 00 00 00 02 00 00 00 00 00 00 00 00
  10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

  0001:00:07.0 ISA bridge: ULi Electronics Inc. M1533/M1535/M1543 PCI to ISA Bridge [Aladdin IV/V/V+]
	  Control: I/O+ Mem+ BusMaster+ SpecCycle+ MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx-
	  Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=medium >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
	  Latency: 0
	  Region 0: [virtual] I/O ports at 0000 [size=64K]
  00: b9 10 33 15 0f 00 10 02 00 00 01 06 00 00 00 00
  10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

The PCI core thinks 0001:00:07.0 BAR 0 is 64K of I/O space.  That
looks wrong (it's way too big), and it doesn't match the actual config
space, which says 0x10 is 0x00000000, which would be an unimplemented
BAR.

I suspect this is because PCI enumeration on sparc gets some
information from OBP instead of from config space.  I think we should
fix this enumeration problem instead of throwing away the quirk.

Bjorn
--
To unsubscribe from this list: send the line "unsubscribe linux-pci" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
index cda39a5..8029b19 100644
--- a/drivers/pci/quirks.c
+++ b/drivers/pci/quirks.c
@@ -113,6 +113,55 @@  static void __init quirk_s3_64M(struct pci_dev *dev)
        }
 }

+static void __init quirk_io_region(struct pci_dev *dev, unsigned region, unsign
ed size, int nr)
+{
+       region &= ~(size-1);
+       if (region) {
+               struct resource *res = dev->resource + nr;
+
+               res->name = dev->name;
+               res->start = region;
+               res->end = region + size - 1;
+               res->flags = IORESOURCE_IO;
+               pci_claim_resource(dev, nr);
+       }
+}
+
+/*
+ * Let's make the southbridge information explicit instead
+ * of having to worry about people probing the ACPI areas,
+ * for example.. (Yes, it happens, and if you read the wrong
+ * ACPI register it will put the machine to sleep with no
+ * way of waking it up again. Bummer).
+ *
+ * ALI M7101: Two IO regions pointed to by words at
+ *     0xE0 (64 bytes of ACPI registers)
+ *     0xE2 (32 bytes of SMB registers)
+ */
+static void __init quirk_ali7101(struct pci_dev *dev)
+{
+       u16 region;
+
+       pci_read_config_word(dev, 0xE0, &region);
+       quirk_io_region(dev, region, 64, PCI_BRIDGE_RESOURCES);
+       pci_read_config_word(dev, 0xE2, &region);
+       quirk_io_region(dev, region, 32, PCI_BRIDGE_RESOURCES+1);
+}
+
+/*
+ * PIIX4 ACPI: Two IO regions pointed to by longwords at
+ *     0x40 (64 bytes of ACPI registers)
+ *     0x90 (32 bytes of SMB registers)
+ */
+static void __init quirk_piix4acpi(struct pci_dev *dev)
+{
+       u32 region;
+
+       pci_read_config_dword(dev, 0x40, &region);
+       quirk_io_region(dev, region, 64, PCI_BRIDGE_RESOURCES);
+       pci_read_config_dword(dev, 0x90, &region);
+       quirk_io_region(dev, region, 32, PCI_BRIDGE_RESOURCES+1);
+}

 /*