DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] About 'CONFIG_RTE_EAL_UNBIND_PORTS'
@ 2013-08-29  7:54 Tetsuya Mukawa
  2013-09-02 15:57 ` Thomas Monjalon
  0 siblings, 1 reply; 3+ messages in thread
From: Tetsuya Mukawa @ 2013-08-29  7:54 UTC (permalink / raw)
  To: dev

Hi folks,

Someone, could you please let me know what is a case that I need to
enable 'CONFIG_RTE_EAL_UNBIND_PORTS'?

Also, if 'CONFIG_RTE_EAL_UNBIND_PORTS' is enabled, it seems an
application dumps error when it exits
This error is displayed by following code.

--------------------------------------
pci_exit_process(struct rte_pci_device *dev)
{
..............
        if (close(dev->intr_handle.fd) == -1){
                RTE_LOG(ERR, EAL, "Error closing interrupt handle\n");
                return -1;
        }

--------------------------------------
I've confirmed when the issue occurs, always the fd is '0'.

I guess that the fd should be initialized as '-1', but actually it is
initialized as '0'.
So during finalization, pci_exit_process() may try to close STDIN.
(But I am not sure why closing STDIN returns error. STDIN might be
already closed by somewhere?)

Anyway, here is a patch I wrote to fix the issue.
Is this correct?
--------------------------------------
diff --git a/lib/librte_eal/linuxapp/eal/eal_pci.c
b/lib/librte_eal/linuxapp/eal/eal_pci.c
index c793148..7bb03e9 100644
--- a/lib/librte_eal/linuxapp/eal/eal_pci.c
+++ b/lib/librte_eal/linuxapp/eal/eal_pci.c
@@ -519,6 +519,8 @@ pci_scan_one(const char *dirname, uint16_t domain,
uint8_t bus,
        dev->addr.devid = devid;
        dev->addr.function = function;

+       dev->intr_handle.fd = -1;
+
        /* get vendor id */
        rte_snprintf(filename, sizeof(filename), "%s/vendor", dirname);
        if (eal_parse_sysfs_value(filename, &tmp) < 0) {
@@ -718,7 +720,8 @@ pci_exit_process(struct rte_pci_device *dev)
                RTE_LOG(ERR, EAL, "Error with munmap\n");
                return -1;
        }
-       if (close(dev->intr_handle.fd) == -1){
+       if ((dev->intr_handle.fd != -1) &&
+               (close(dev->intr_handle.fd) == -1)) {
                RTE_LOG(ERR, EAL, "Error closing interrupt handle\n");
                return -1;
        }
--------------------------------------

Also here is the procedure to reproduce the issue.

1. Prepare Fedora16(3.6.11-4.fc16.x86_64) as a guest OS.
2. Add 2 network interfaces(virtio-net) to the guest.
3. Compile dpdk-1.3.2r2 with CONFIG_RTE_EAL_UNBIND_PORTS' enabled on the guest.
4. Run testpmd using virtio-net-pmd on the guest.
5. Quit testpmd, and check error messages.

Best Regards,
Tetsuya Mukawa

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [dpdk-dev] About 'CONFIG_RTE_EAL_UNBIND_PORTS'
  2013-08-29  7:54 [dpdk-dev] About 'CONFIG_RTE_EAL_UNBIND_PORTS' Tetsuya Mukawa
@ 2013-09-02 15:57 ` Thomas Monjalon
  2013-09-03  1:39   ` Tetsuya Mukawa
  0 siblings, 1 reply; 3+ messages in thread
From: Thomas Monjalon @ 2013-09-02 15:57 UTC (permalink / raw)
  To: Tetsuya Mukawa; +Cc: dev

29/08/2013 09:54, Tetsuya Mukawa :
> Someone, could you please let me know what is a case that I need to
> enable 'CONFIG_RTE_EAL_UNBIND_PORTS'?

In DPDK 1.3, the UNBIND option is intended to restore the previous state
when exiting a DPDK application.
In case of devices bound to igb_uio, it will re-bind them to their original 
driver (e1000/igb/ixgbe).
It has no effect with virtio.

The bug that you have described does not appear with igb_uio drivers because 
fd is initialized in pci_map_resource().
But in case of virtio, pci_map_resource() is not called.

> I guess that the fd should be initialized as '-1', but actually it is
> initialized as '0'.
> So during finalization, pci_exit_process() may try to close STDIN.
> (But I am not sure why closing STDIN returns error. STDIN might be
> already closed by somewhere?)
> 
> Anyway, here is a patch I wrote to fix the issue.
> Is this correct?
> --------------------------------------
> diff --git a/lib/librte_eal/linuxapp/eal/eal_pci.c
> b/lib/librte_eal/linuxapp/eal/eal_pci.c
> index c793148..7bb03e9 100644
> --- a/lib/librte_eal/linuxapp/eal/eal_pci.c
> +++ b/lib/librte_eal/linuxapp/eal/eal_pci.c
> @@ -519,6 +519,8 @@ pci_scan_one(const char *dirname, uint16_t domain,
> uint8_t bus,
>         dev->addr.devid = devid;
>         dev->addr.function = function;
> 
> +       dev->intr_handle.fd = -1;
> +
>         /* get vendor id */
>         rte_snprintf(filename, sizeof(filename), "%s/vendor", dirname);
>         if (eal_parse_sysfs_value(filename, &tmp) < 0) {
> @@ -718,7 +720,8 @@ pci_exit_process(struct rte_pci_device *dev)
>                 RTE_LOG(ERR, EAL, "Error with munmap\n");
>                 return -1;
>         }
> -       if (close(dev->intr_handle.fd) == -1){
> +       if ((dev->intr_handle.fd != -1) &&
> +               (close(dev->intr_handle.fd) == -1)) {
>                 RTE_LOG(ERR, EAL, "Error closing interrupt handle\n");
>                 return -1;
>         }
> --------------------------------------

It looks good.
Could you send it as a real patch with a commit log ?

Thank you
-- 
Thomas

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [dpdk-dev] About 'CONFIG_RTE_EAL_UNBIND_PORTS'
  2013-09-02 15:57 ` Thomas Monjalon
@ 2013-09-03  1:39   ` Tetsuya Mukawa
  0 siblings, 0 replies; 3+ messages in thread
From: Tetsuya Mukawa @ 2013-09-03  1:39 UTC (permalink / raw)
  To: Thomas Monjalon; +Cc: dev

2013/9/3 Thomas Monjalon <thomas.monjalon@6wind.com>:
> 29/08/2013 09:54, Tetsuya Mukawa :
>> Someone, could you please let me know what is a case that I need to
>> enable 'CONFIG_RTE_EAL_UNBIND_PORTS'?
>
> In DPDK 1.3, the UNBIND option is intended to restore the previous state
> when exiting a DPDK application.
> In case of devices bound to igb_uio, it will re-bind them to their original
> driver (e1000/igb/ixgbe).
> It has no effect with virtio.
>
> The bug that you have described does not appear with igb_uio drivers because
> fd is initialized in pci_map_resource().
> But in case of virtio, pci_map_resource() is not called.

Thank you for your explanation.
I understand it clearly.

> It looks good.
> Could you send it as a real patch with a commit log ?

Sure, I will.

Thanks,
Tetsuya Mukawa

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2013-09-03  1:38 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-08-29  7:54 [dpdk-dev] About 'CONFIG_RTE_EAL_UNBIND_PORTS' Tetsuya Mukawa
2013-09-02 15:57 ` Thomas Monjalon
2013-09-03  1:39   ` Tetsuya Mukawa

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).