linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Myron Stowe <myron.stowe@gmail.com>
To: Borislav Petkov <bp@suse.de>
Cc: Myron Stowe <myron.stowe@redhat.com>,
	Bjorn Helgaas <bhelgaas@google.com>,
	linux-pci <linux-pci@vger.kernel.org>,
	Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>,
	Aravind Gopalakrishnan <aravind.gopalakrishnan@amd.com>,
	kim.naru@amd.com, daniel@numascale.com,
	Thomas Gleixner <tglx@linutronix.de>,
	mingo@redhat.com, hpa@zytor.com, x86 <x86@kernel.org>,
	sp@numascale.com,
	"linux-acpi@vger.kernel.org" <linux-acpi@vger.kernel.org>,
	LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2 1/5] x86/PCI: Add support for generic AMD hostbridges
Date: Mon, 28 Apr 2014 15:10:55 -0600	[thread overview]
Message-ID: <CAL-B5D0j8JXPTC87wsaArHVGPJxKphW8i0LCMYHR_2ck2S7AXA@mail.gmail.com> (raw)
In-Reply-To: <20140419113111.GA8109@pd.tnic>

On Sat, Apr 19, 2014 at 5:31 AM, Borislav Petkov <bp@suse.de> wrote:
> On Fri, Apr 18, 2014 at 08:53:16PM -0600, Myron Stowe wrote:
>> From: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>
>>
>> AMD hostbridges gnenerally show up as PCI device 0:18.0.  This patch adds
>> logic to automatically probe the device at this location and check PCI
>> device class code.
>>
>> This patch supports platforms with the following AMD hostbridge types:
>> (K8, family10h, 11h, 12h, 14h 15h  and 16h processors).
>>
>> Reference(s):
>>   https://bugzilla.kernel.org/show_bug.cgi?id=72051
>>   Advanced Micro Devices (AMD), "BIOS and Kernel Developer's
>>   Guide (BKDG) for AMD Family 15h Models 00h-0fh Processors."  Section
>>   3.4 Device [1F:18]h Function 1 Configuration Registers; D18F1x[EC:E0]
>>   Configuration Map, 42301 Rev 3.12 - October 11, 2012.
>>
>> Signed-off-by: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>
>> Signed-off-by: Myron Stowe <myron.stowe@redhat.com>
>> Tested-by: Aravind Gopalakrishnan <Aravind.Gopalakrishnan@amd.com>
>> ---
>>
>>  arch/x86/pci/amd_bus.c |   71 ++++++++++++++++++++++++++++++++----------------
>>  1 files changed, 47 insertions(+), 24 deletions(-)
>>
>> diff --git a/arch/x86/pci/amd_bus.c b/arch/x86/pci/amd_bus.c
>> index e88f4c5..c8cd75c 100644
>> --- a/arch/x86/pci/amd_bus.c
>> +++ b/arch/x86/pci/amd_bus.c
>> @@ -11,27 +11,34 @@
>>
>>  #include "bus_numa.h"
>>
>> +#define AMD_NB_F0_NODE_ID                    0x60
>> +#define AMD_NB_F0_UNIT_ID                    0x64
>> +#define AMD_NB_F1_CONFIG_MAP_REG             0xe0
>> +
>> +#define RANGE_NUM                            16
>> +#define AMD_NB_F1_CONFIG_MAP_RANGES          4
>> +
>>  /*
>> - * This discovers the pcibus <-> node mapping on AMD K8.
>> - * also get peer root bus resource for io,mmio
>> + * This discovers the pcibus <-> node mapping on AMD K8, Family 10h, 12h,
>> + * 14h, 15h, and 16h processor based systems.  This also gets peer root bus
>> + * resources corresponding to I/O and MMIO addresses.
>>   */
>>
>> -struct pci_hostbridge_probe {
>> +struct amd_hostbridge {
>>       u32 bus;
>>       u32 slot;
>> -     u32 vendor;
>>       u32 device;
>>  };
>>
>> -static struct pci_hostbridge_probe pci_probes[] __initdata = {
>> -     { 0, 0x18, PCI_VENDOR_ID_AMD, 0x1100 },
>> -     { 0, 0x18, PCI_VENDOR_ID_AMD, 0x1200 },
>> -     { 0xff, 0, PCI_VENDOR_ID_AMD, 0x1200 },
>> -     { 0, 0x18, PCI_VENDOR_ID_AMD, 0x1300 },
>> +static struct amd_hostbridge hb_probes[] __initdata = {
>> +     /* Standard AMD Hostbriges are at bus 0x0 slot 0x18.
>> +      * In case of PCI_ANY_ID, the logic will try matching
>> +      * PCI_CLASS_BRIDGE_HOST instead.
>> +      */
>
> Standard kernel comment style:
>
> /*
>  * Something interesting for the code below.
>  * This is the second comment line.
>  */
>

I went ahead and made this change in patch 1/5 (even though most
non-functional changes are in patch 3/5) as it seems to belong here.

>> +     { 0x0 , 0x18, PCI_ANY_ID },
>> +     { 0xff, 0   , PCI_DEVICE_ID_AMD_10H_NB_HT },
>>  };
>>
>> -#define RANGE_NUM 16
>> -
>>  static struct pci_root_info __init *find_pci_root_info(int node, int link)
>>  {
>>       struct pci_root_info *info;
>> @@ -75,31 +82,47 @@ static int __init early_fill_mp_bus_info(void)
>
> Btw, this function is huuuge. It could use a splitup some day.
>

Yes, Suravee did split this up in patch 3/5

>>               return -1;
>>
>>       found = false;
>> -     for (i = 0; i < ARRAY_SIZE(pci_probes); i++) {
>> +     for (i = 0; i < ARRAY_SIZE(hb_probes); i++) {
>>               u32 id;
>>               u16 device;
>>               u16 vendor;
>> +             u32 class;
>>
>> -             bus = pci_probes[i].bus;
>> -             slot = pci_probes[i].slot;
>> +             bus = hb_probes[i].bus;
>> +             slot = hb_probes[i].slot;
>>               id = read_pci_config(bus, slot, 0, PCI_VENDOR_ID);
>> -
>>               vendor = id & 0xffff;
>>               device = (id>>16) & 0xffff;
>> -             if (pci_probes[i].vendor == vendor &&
>> -                 pci_probes[i].device == device) {
>> -                     found = true;
>> -                     break;
>> +             class = read_pci_config(bus, slot, 0,
>> +                     PCI_CLASS_REVISION) >> 16;
>> +
>> +             if (PCI_VENDOR_ID_AMD == vendor) {
>
> Flip comparison:
>
>                 if (vendor == PCI_VENDOR_ID_AMD)
>
> and then save yourself another indentation level:
>
>                 if (vendor != PCI_VENDOR_ID_AMD)
>                         continue;
>

Yes, much better

>> +                     if (hb_probes[i].device == device) {
>> +                             found = true;
>> +                             break;
>> +                     }
>> +
>> +                     if ((hb_probes[i].device == PCI_ANY_ID) &&
>> +                         (class == PCI_CLASS_BRIDGE_HOST)) {
>> +                             hb_probes[i].device = device;
>> +                             found = true;
>> +                             break;
>> +                     }
>>               }
>>       }
>>
>> -     if (!found)
>> +     if (!found) {
>> +             pr_warn("AMD hostbridge not found\n");
>>               return 0;
>> +     }
>
> I guess this should return a negative value... Not that it matters much
> from looking at the call site in the amd_postcore_init initcall.
>

Patch 3/5 cleans this up.

>>
>> -     for (i = 0; i < 4; i++) {
>> +     pr_debug("Found AMD hostbridge at %x:%x.0\n", bus, slot);
>
> Why not pr_info? I think this is useful info we want to print out at
> default level.

Sure, ok  ;)
>
> --
> Regards/Gruss,
>     Boris.
>
> Sent from a fat crate under my desk. Formatting is fine.
> --
> --
> To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

  reply	other threads:[~2014-04-28 21:10 UTC|newest]

Thread overview: 58+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-05 21:06 [PATCH 0/3] amd/pci: Add AMD hostbridge supports for newer AMD systems suravee.suthikulpanit
2014-03-05 21:06 ` [PATCH 1/3] amd/pci: Add supports for generic AMD hostbridges suravee.suthikulpanit
2014-03-05 21:06 ` [PATCH 2/3] amd/pci: Support additional MMIO ranges capabilities suravee.suthikulpanit
2014-03-20 17:33   ` Bjorn Helgaas
2014-03-05 21:06 ` [PATCH 3/3] amd/pci: Miscellaneous code clean up for early_fillup_mp_bus_info suravee.suthikulpanit
2014-03-05 21:24 ` [PATCH 0/3] amd/pci: Add AMD hostbridge supports for newer AMD systems Bjorn Helgaas
2014-03-06  2:13   ` Suravee Suthikulanit
2014-03-06  6:30     ` Suravee Suthikulpanit
2014-03-06 17:40       ` Bjorn Helgaas
2014-03-06 20:03         ` Suravee Suthikulpanit
2014-03-11 18:12           ` Bjorn Helgaas
2014-03-12 21:13             ` Bjorn Helgaas
2014-03-13  1:30               ` Myron Stowe
2014-03-14  2:06               ` Suravee Suthikulpanit
2014-03-17 17:18                 ` Bjorn Helgaas
2014-03-20 17:42                   ` Bjorn Helgaas
2014-04-19  2:53 ` [PATCH v2 0/5] x86/PCI: Add AMD hostbridge support " Myron Stowe
2014-04-19  2:53   ` [PATCH v2 1/5] x86/PCI: Add support for generic AMD hostbridges Myron Stowe
2014-04-19 11:31     ` Borislav Petkov
2014-04-28 21:10       ` Myron Stowe [this message]
2014-04-19  2:53   ` [PATCH v2 2/5] x86/PCI: Support additional MMIO range capabilities Myron Stowe
2014-04-19 13:52     ` Borislav Petkov
2014-04-20  7:59       ` Borislav Petkov
2014-04-25 22:24         ` Myron Stowe
2014-04-26  9:10           ` Borislav Petkov
2014-04-28 20:50             ` Bjorn Helgaas
2014-04-28 21:40               ` Borislav Petkov
2014-04-29  7:33                 ` Andreas Herrmann
2014-04-29 10:20                   ` Borislav Petkov
2014-04-29 13:07                     ` Steffen Persvold
2014-04-29 15:16                     ` Suravee Suthikulanit
2014-04-29 19:14                       ` Borislav Petkov
2014-04-29 21:40                         ` Myron Stowe
2014-04-30  7:00                           ` Robert Richter
2014-04-30  7:50                             ` Suravee Suthikulpanit
2014-04-30  9:51                               ` Robert Richter
2014-04-30 23:03                             ` Myron Stowe
2014-04-29 11:19                   ` Robert Richter
2014-04-29  7:06               ` Jan Beulich
2014-04-29  3:04           ` Suravee Suthikulanit
2014-04-28 21:19       ` Myron Stowe
2014-04-29  2:47         ` Suravee Suthikulanit
2014-04-29 17:17     ` Robert Richter
2014-04-30  6:41     ` Robert Richter
2014-04-19  2:53   ` [PATCH v2 3/5] x86/PCI: Miscellaneous code clean up for early_fillup_mp_bus_info Myron Stowe
2014-04-20  8:02     ` Borislav Petkov
2014-04-28 21:21       ` Myron Stowe
2014-04-19  2:53   ` [PATCH v2 4/5] ACPI/PCI: Warn if we have to "guess" host bridge node information Myron Stowe
2014-04-20 10:21     ` Borislav Petkov
2014-04-28 21:24       ` Myron Stowe
2014-04-29 19:16         ` Borislav Petkov
2014-04-19  2:53   ` [PATCH v2 5/5] PCI: Remove redundant 'quirk_amd_nb_node' Myron Stowe
2014-04-20 10:54     ` Borislav Petkov
2014-04-20 13:44       ` Myron Stowe
2014-04-21 16:53         ` Daniel J Blueman
2014-04-29  2:02           ` Suravee Suthikulanit
2014-04-29 19:29             ` Bjorn Helgaas
2014-04-28 21:28       ` Myron Stowe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAL-B5D0j8JXPTC87wsaArHVGPJxKphW8i0LCMYHR_2ck2S7AXA@mail.gmail.com \
    --to=myron.stowe@gmail.com \
    --cc=aravind.gopalakrishnan@amd.com \
    --cc=bhelgaas@google.com \
    --cc=bp@suse.de \
    --cc=daniel@numascale.com \
    --cc=hpa@zytor.com \
    --cc=kim.naru@amd.com \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=myron.stowe@redhat.com \
    --cc=sp@numascale.com \
    --cc=suravee.suthikulpanit@amd.com \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).