DPDK patches and discussions
 help / color / mirror / Atom feed
From: Ferruh Yigit <ferruh.yigit@intel.com>
To: "谢华伟(此时此刻)" <huawei.xhw@alibaba-inc.com>, dev <dev@dpdk.org>
Cc: "Wang, Zhihong" <zhihong.wang@intel.com>,
	"Xia, Chenbo" <chenbo.xia@intel.com>,
	Maxime Coquelin <maxime.coquelin@redhat.com>,
	Anatoly Burakov <anatoly.burakov@intel.com>,
	David Marchand <david.marchand@redhat.com>,
	Gaetan Rivet <grive@u256.net>
Subject: Re: [dpdk-dev] [PATCH] pci: support both PIO and MMIO BAR for legacy virtio on x86
Date: Thu, 24 Sep 2020 19:02:15 +0100	[thread overview]
Message-ID: <6b99b215-df24-10d8-5b10-75848e89e572@intel.com> (raw)
In-Reply-To: <3f5bd3a2-8696-237d-2723-35be5a60bb65@alibaba-inc.com>

On 9/15/2020 4:21 PM, 谢华伟(此时此刻) wrote:
> Hi Ferruh:
> Legacy virtio only supports PIO BAR resource. As we need to create lots 
> of virtio devices and PIO resource on x86 is very limited, we expose 
> MMIO BAR.
> Kernel support both PIO and MMIO BAR for legacy virtio device. This 
> patch deals with two cases in the similar way.
> 

Thanks Huawei,

I was about to ask the actual motivation for the patch, better to put 
this explenation into the commit log.

If legacy virtio device only supports PIO BAR, how exposing MMIO BAR 
helps? Or if there is MMIO BAR available in the device, why not mapping 
them instead of using PIO?
Most probably I am missing something but can you please help to understand.

Also below code unifies vfio & uio cases for PIO into same function. Are 
you using igb_uio or both? I am not sure about unifiying the vfio case, 
what do you think not touching that case in this patch?

There are a few more comments inline, please check.

Btw, the patch doesn't apply cleanly, can you please send a new version 
on top of latest head of repo?



> On 2020/9/15 16:18, 谢华伟(此时此刻) wrote:
>>  From d0138f24037d8df14cac04c2c24831e4b5d27b8c Mon Sep 17 00:00:00 2001
>> From: "huawei.xhw" <huawei.xhw@alibaba-inc.com>
>> Date: Mon, 14 Sep 2020 23:44:56 +0800
>> Subject: [PATCH] pci:  support both PIO and MMIO BAR for legacy virtio 
>> on x86
>>
>> In previous implementation, with igb_uio we get PIO address from igb_uio
>> sysfs entry; with uio_pci_generic, we get PIO address from
>> /proc/ioports.
>> For PIO/MMIO RW, there is different path for different drivers and arch.
>> For VFIO, PIO/MMIO RW is through syscall, which has big performance
>> issue.
>> On X86, it assumes only PIO is supported.
>>
>> This is too much twisted.
>> This patch unifies the way to get both PIO and MMIO address for 
>> different driver
>> and arch, all from standard resource attr under pci sysfs.
>>
>> We distinguish PIO and MMIO by their address. It is ugly but works.
>>
>> Signed-off-by: huawei.xhw <huawei.xhw@alibaba-inc.com>

<...>

>> --- a/drivers/bus/pci/linux/pci_uio.c
>> +++ b/drivers/bus/pci/linux/pci_uio.c
>> @@ -372,52 +372,82 @@
>>   pci_uio_ioport_map(struct rte_pci_device *dev, int bar,
>>              struct rte_pci_ioport *p)
>>   {

There are two 'pci_uio_ioport_map()', one for x86 and other for rest. 
This one is for x86, since read/write functions for multiple arch 
combined together, should non-x86 version of this function updated or 
removed completely?

<...>

>> +    if (flags & IORESOURCE_IO) {
>> +        iobar = 1;
>> +        base = (unsigned long)phys_addr;
>> +        RTE_LOG(INFO, EAL, "%s(): PIO BAR %08lx detected\n", 
>> __func__, base);
>> +    } else if (flags & IORESOURCE_MEM) {
>> +        iobar = 0;
>> +        base = (unsigned long)dev->mem_resource[bar].addr;

Isn't the 'mem_resource[bar].addr' value set only when it is mapped? For 
this case I guess it will be 0x0. If not who maps it first?

>> +        RTE_LOG(INFO, EAL, "%s(): MMIO BAR %08lx detected\n", 
>> __func__, base);
>> +    } else {
>> +        RTE_LOG(ERR, EAL, "%s(): unknown BAR type\n", __func__);
>> +        goto error;
>> +    }
>> +
>> +    if (iobar && rte_eal_iopl_init() != 0) {
>> +        RTE_LOG(ERR, EAL, "%s(): insufficient ioport permissions for 
>> PCI device %s\n",
>> +            __func__, dev->name);
>> +        goto error;
>>       }
>> -    /* ensure we don't get anything funny here, read/write will cast to
>> -     * uin16_t */
>> -    if (start > UINT16_MAX)
>> -        return -1;
>>       /* FIXME only for primary process ? */
>>       if (dev->intr_handle.type == RTE_INTR_HANDLE_UNKNOWN) {
>> +        uio_num = pci_get_uio_dev(dev, dirname, sizeof(dirname), 0);
>> +        if (uio_num < 0)
>> +            goto error;

How this will work with vfio?

  reply	other threads:[~2020-09-24 18:02 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-15  8:18 谢华伟(此时此刻)
2020-09-15 15:21 ` 谢华伟(此时此刻)
2020-09-24 18:02   ` Ferruh Yigit [this message]
2020-09-27 12:03     ` 谢华伟(此时此刻)
  -- strict thread matches above, loose matches on Subject: below --
2020-09-14 13:09 [dpdk-dev] [PATCH] pci: support both PIO and MMIO bar " 谢华伟(此时此刻)
2020-09-14 12:43 谢华伟(此时此刻)

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=6b99b215-df24-10d8-5b10-75848e89e572@intel.com \
    --to=ferruh.yigit@intel.com \
    --cc=anatoly.burakov@intel.com \
    --cc=chenbo.xia@intel.com \
    --cc=david.marchand@redhat.com \
    --cc=dev@dpdk.org \
    --cc=grive@u256.net \
    --cc=huawei.xhw@alibaba-inc.com \
    --cc=maxime.coquelin@redhat.com \
    --cc=zhihong.wang@intel.com \
    /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).