public inbox for kexec@lists.infradead.org
 help / color / mirror / Atom feed
From: Takao Indoh <indou.takao@jp.fujitsu.com>
To: amurray@embedded-bits.co.uk
Cc: tokunaga.keiich@jp.fujitsu.com, linux-pci@vger.kernel.org,
	x86@kernel.org, kexec@lists.infradead.org,
	linux-kernel@vger.kernel.org, hbabu@us.ibm.com,
	andi@firstfloor.org, ddutile@redhat.com,
	ishii.hironobu@jp.fujitsu.com, hpa@zytor.com,
	bhelgaas@google.com, tglx@linutronix.de, yinghai@kernel.org,
	mingo@redhat.com, vgoyal@redhat.com, khalid@gonehiking.org
Subject: Re: [PATCH v6 1/5] x86, pci: add dummy pci device for early stage
Date: Tue, 13 Nov 2012 19:57:35 +0900	[thread overview]
Message-ID: <50A2279F.60003@jp.fujitsu.com> (raw)
In-Reply-To: <CAPcvp5FCDt5Sy9W7s4gsWuq7z9dATvk37hS_5XfrYepNiJN=nA@mail.gmail.com>

(2012/11/13 19:01), Andrew Murray wrote:
> Hello,
>
> Some comments inline...
>
> On 13 November 2012 09:07, Takao Indoh <indou.takao@jp.fujitsu.com> wrote:
>> From: Yinghai Lu <yinghai@kernel.org>
>>
>> So we can pass pci_dev *dev to reuse some generic pci functions.
>>
>> Signed-off-by: Yinghai Lu <yinghai@kernel.org>
>> Signed-off-by: Takao Indoh <indou.takao@jp.fujitsu.com>
>> ---
>>   arch/x86/include/asm/pci-direct.h |    2 +
>>   arch/x86/pci/early.c              |   75 +++++++++++++++++++++++++++++++++++++
>>   2 files changed, 77 insertions(+), 0 deletions(-)
>>
>> diff --git a/arch/x86/include/asm/pci-direct.h b/arch/x86/include/asm/pci-direct.h
>> index b1e7a45..b6360d3 100644
>> --- a/arch/x86/include/asm/pci-direct.h
>> +++ b/arch/x86/include/asm/pci-direct.h
>> @@ -18,4 +18,6 @@ extern int early_pci_allowed(void);
>>   extern unsigned int pci_early_dump_regs;
>>   extern void early_dump_pci_device(u8 bus, u8 slot, u8 func);
>>   extern void early_dump_pci_devices(void);
>> +
>> +struct pci_dev *get_early_pci_dev(int num, int slot, int func);
>>   #endif /* _ASM_X86_PCI_DIRECT_H */
>> diff --git a/arch/x86/pci/early.c b/arch/x86/pci/early.c
>> index d1067d5..aea6b2b 100644
>> --- a/arch/x86/pci/early.c
>> +++ b/arch/x86/pci/early.c
>> @@ -109,3 +109,78 @@ void early_dump_pci_devices(void)
>>                  }
>>          }
>>   }
>> +
>> +static __init int
>> +early_pci_read(struct pci_bus *bus, unsigned int devfn, int where,
>> +                       int size, u32 *value)
>> +{
>> +       int num, slot, func;
>> +
>> +       num = bus->number;
>> +       slot = devfn >> 3;
>> +       func = devfn & 7;
>
> You may want to use the PCI_SLOT and PCI_FUNC macros in
> include/linux/pci.h to determine values for slot and func.
>
>> +       switch (size) {
>> +       case 1:
>> +               *value = read_pci_config_byte(num, slot, func, where);
>> +               break;
>> +       case 2:
>> +               *value = read_pci_config_16(num, slot, func, where);
>> +               break;
>> +       case 4:
>> +               *value = read_pci_config(num, slot, func, where);
>> +               break;
>> +       }
>> +
>> +       return 0;
>> +}
>> +
>> +static __init int
>> +early_pci_write(struct pci_bus *bus, unsigned int devfn, int where,
>> +                       int size, u32 value)
>> +{
>> +       int num, slot, func;
>> +
>> +       num = bus->number;
>> +       slot = devfn >> 3;
>> +       func = devfn & 7;
>
> As above.
>
>> +       switch (size) {
>> +       case 1:
>> +               write_pci_config_byte(num, slot, func, where, (u8)value);
>> +               break;
>> +       case 2:
>> +               write_pci_config_16(num, slot, func, where, (u16)value);
>> +               break;
>> +       case 4:
>> +               write_pci_config(num, slot, func, where, (u32)value);
>> +               break;
>> +       }
>> +
>> +       return 0;
>> +}
>> +
>> +static __initdata struct pci_ops pci_early_ops = {
>> +       .read  = early_pci_read,
>> +       .write = early_pci_write,
>> +};
>> +static __initdata struct pci_bus pci_early_bus = {
>> +       .ops = &pci_early_ops,
>> +};
>> +static __initdata char pci_early_init_name[8];
>> +static __initdata struct pci_dev pci_early_dev = {
>> +       .bus = &pci_early_bus,
>> +       .dev = {
>> +               .init_name = pci_early_init_name,
>> +       },
>> +};
>> +
>> +__init struct pci_dev *get_early_pci_dev(int num, int slot, int func)
>> +{
>> +       struct pci_dev *pdev;
>> +
>> +       pdev = &pci_early_dev;
>> +       pdev->devfn = (slot<<3) | (func & 7);
>
> You can use PCI_DEVFN here.

Yeah, I forgot to use these macros. I'll fix them, thanks!

Thanks,
Takao Indoh

>
>> +       pdev->bus->number = num;
>> +       sprintf((char *)pdev->dev.init_name, "%02x:%02x.%01x", num, slot, func);
>> +
>> +       return pdev;
>> +}
>> --
>> 1.7.1
>>
>>
>> --
>> 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
>
> Andrew Murray
>
>


_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

  reply	other threads:[~2012-11-13 11:03 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-13  9:07 [PATCH v6 0/5] Reset PCIe devices to address DMA problem on kdump with iommu Takao Indoh
2012-11-13  9:07 ` [PATCH v6 1/5] x86, pci: add dummy pci device for early stage Takao Indoh
2012-11-13 10:01   ` Andrew Murray
2012-11-13 10:57     ` Takao Indoh [this message]
2012-11-13  9:07 ` [PATCH v6 2/5] PCI: Define the maximum number of PCI function Takao Indoh
2012-11-13  9:07 ` [PATCH v6 3/5] Make reset_devices available at early stage Takao Indoh
2012-11-13  9:08 ` [PATCH v6 4/5] x86, pci: Reset PCIe devices at boot time Takao Indoh
2012-11-13  9:08 ` [PATCH v6 5/5] x86, pci: Enable PCI INTx when MSI is disabled Takao Indoh

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=50A2279F.60003@jp.fujitsu.com \
    --to=indou.takao@jp.fujitsu.com \
    --cc=amurray@embedded-bits.co.uk \
    --cc=andi@firstfloor.org \
    --cc=bhelgaas@google.com \
    --cc=ddutile@redhat.com \
    --cc=hbabu@us.ibm.com \
    --cc=hpa@zytor.com \
    --cc=ishii.hironobu@jp.fujitsu.com \
    --cc=kexec@lists.infradead.org \
    --cc=khalid@gonehiking.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=tglx@linutronix.de \
    --cc=tokunaga.keiich@jp.fujitsu.com \
    --cc=vgoyal@redhat.com \
    --cc=x86@kernel.org \
    --cc=yinghai@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