DPDK patches and discussions
 help / color / mirror / Atom feed
From: Gopakumar Choorakkot Edakkunni <gopakumar.c.e@gmail.com>
To: dev@dpdk.org, Olivier Matz <olivier.matz@6wind.com>
Subject: Re: [dpdk-dev] dpdk16.07 and virtio "Cannot mmap IO port resource"
Date: Sun, 11 Dec 2016 00:29:56 -0800	[thread overview]
Message-ID: <CABK1yFAXs6HC9hOy4RF0FLwvOhgeh4EQwp5NRTevwmJOys-qmQ@mail.gmail.com> (raw)
In-Reply-To: <CABK1yFDSHOh3CRrNMoEZniTrk8JLW3XSpe2dvcuUsOynH2RXRQ@mail.gmail.com>

Somewhere I read that the "offset" parameter for sysfs mmap() needs to be
the start address of the resource, so I tried the below diff, and mmap
still fails .. Still scratching my head

diff --git a/lib/librte_eal/linuxapp/eal/eal_pci_uio.c
b/lib/librte_eal/linuxapp/eal/eal_pci_uio.c
index 1786b75..e882940 100644
--- a/lib/librte_eal/linuxapp/eal/eal_pci_uio.c
+++ b/lib/librte_eal/linuxapp/eal/eal_pci_uio.c
@@ -462,8 +462,8 @@ pci_uio_ioport_map(struct rte_pci_device *dev, int bar,
                        strerror(errno));
                goto error;
        }
-       addr = mmap(NULL, end_addr + 1, PROT_READ | PROT_WRITE,
-               MAP_SHARED, fd, 0);
+       addr = mmap(NULL, (end_addr-phys_addr) + 1, PROT_READ | PROT_WRITE,
+               MAP_SHARED, fd, phys_addr);
        close(fd);
        if (addr == MAP_FAILED) {
                RTE_LOG(ERR, EAL, "Cannot mmap IO port resource: %s\n",
@@ -473,7 +473,7 @@ pci_uio_ioport_map(struct rte_pci_device *dev, int bar,

        /* strangely, the base address is mmap addr + phys_addr */
        p->base = (uintptr_t)addr + phys_addr;
-       p->len = end_addr + 1;
+       p->len = (end_addr-phys_addr) + 1;
        RTE_LOG(DEBUG, EAL, "PCI Port IO found start=0x%"PRIx64"\n",
p->base);
        fclose(f);

On Sat, Dec 10, 2016 at 3:21 PM, Gopakumar Choorakkot Edakkunni <
gopakumar.c.e@gmail.com> wrote:

> Hi Oliver,
>
> Looking at the kernel code pci_mmap_resource()--->pci_mmap_fits(), it
> looks like pci_mmap_fits() expects that the "number of pages" requested to
> map is no larger than the actual size of the pci resource. But in
> pci_uio_ioport_map() what is passed as the requested size is the end_addr
> of the resource, which in my case is 0xc09f, but the size of the resource
> itself is 0x20 and hence kernel expects one page - but 0xc09f+1
> (end_addr+1) gets translated to 13 pages ! And I guess that leads to the
> mmap to fail .. Thoughts on this ?
>
> Rgds,
> Gopa.
>
>
> On Fri, Dec 9, 2016 at 8:30 PM, Gopakumar Choorakkot Edakkunni <
> gopakumar.c.e@gmail.com> wrote:
>
>> I tried to load up dpdk (bound to uio_pci_generic, tried igb_uio also!)
>> on a virtio interface. Dpdk exits with the "Cannot mmap IO port resource"
>> complaint - the call chain is legacy_virtio_resource_init()-->pci_uio_ioport_map().
>>
>>
>> If anyone can give any clues/pointers as to what might be wrong, that can
>> greatly help in getting me on the right track fast !
>>
>> ---
>> EAL:   probe driver: 1af4:1000 rte_virtio_pmd
>> EAL: PCI device 0000:00:05.0 on NUMA socket 0
>> EAL:   probe driver: 1af4:1000 r[  330.753458] ------------[ cut here
>> ]------------
>> rte_virtio_pmd
>> [  330.754430] WARNING: CPU: 0 PID: 8063 at drivers/pci/pci-sysfs.c:984
>> pci_mmap_resource.isra.14+0x113/0x1b0()
>> [  330.756083] process "dpdk_master" tried to map 0x0000d000 bytes at
>> page 0x00000000 on 0000:00:05.0 BAR 0 (start 0x            c080, size
>> 0x              20)
>> [  330.758272] Modules linked in: rte_kni igb_uio pppoe ppp_async
>> iptable_nat cdc_mbim sierra_net rndis_host qmi_wwan qcserial pppox
>> ppp_generic option nf_nat_pptp nf_nat_ipv4 nf_nat_amanda nf_conntrack_pptp
>> nf_conntrack_ipv4 nf_conntrack_amanda ipt_MASQUERADE huawei_cdc_ncm
>> cdc_subset cdc_ncm cdc_ether cdc_eem ax88179_178a asix xt_u32 xt_time
>> xt_tcpmss xt_string xt_statistic xt_state xt_socket xt_recent xt_quota
>> xt_pkttype xt_physdev xt_owner xt_nat xt_multiport xt_mark xt_mac xt_limit
>> xt_length xt_iprange xt_id xt_hl xt_helper xt_hashlimit xt_esp xt_ecn
>> xt_dscp xt_conntrack xt_connmark xt_connlimit xt_connbytes xt_comment
>> xt_addrtype xt_TPROXY xt_TEE xt_TCPMSS xt_REDIRECT xt_NETMAP xt_LOG xt_LED
>> xt_HL xt_DSCP xt_CT xt_CLASSIFY usbnet usb_wwan ts_kmp ts_fsm ts_bm slhc
>> sierra pl2303 nfnetlink_queue nfnetlink_log nf_nat_tftp nf_nat_snmp_basic
>> nf_nat_sip nf_nat_proto_gre nf_nat_irc nf_nat_h323 nf_nat_ftp nf_nat
>> nf_defrag_ipv4 nf_conntrack_tftp nf_conntrack_snmp nf_conntrack_sip
>> nf_conntrack_proto_gre nf_conntrack_netlink nf_conntrack_irc
>> nf_conntrack_h323 nf_conntrack_ftp nf_conntrack_broadcast
>> lib80211_crypt_wep lib80211_crypt_tkip lib80211_crypt_ccmp lib80211
>> iptable_raw iptable_mangle iptable_filter ipt_ah ipt_ULOG ipt_REJECT
>> ipt_ECN hso ftdi_sio crc8 crc7 crc_itu_t crc_ccitt cp210x cordic
>> compat_xtables cdc_wdm cdc_acm arptable_filter arpt_mangle arp_tables
>> sch_teql sch_tbf sch_sfq sch_red sch_prio sch_netem sch_htb sch_gred
>> sch_dsmark sch_codel em_text em_nbyte em_meta em_cmp cls_basic act_police
>> act_ipt act_connmark act_skbedit act_mirred em_u32 cls_u32 cls_tcindex
>> cls_flow cls_route cls_fw sch_hfsc sch_ingress evdev xt_NFQUEUE xt_set
>> ip_set_list_set ip_set_hash_netport ip_set_hash_netiface ip_set_hash_net
>> ip_set_hash_ipportnet ip_set_hash_ipportip ip_set_hash_ipport
>> ip_set_hash_ip ip_set_bitmap_port ip_set_bitmap_ipmac ip_set_bitmap_ip
>> ip_set nfnetlink sr_mod cdrom ip6t_REJECT ip6table_raw ip6table_mangle
>> ip6table_filter ip6_tables nf_conntrack_ipv6 nf_conntrack nf_defrag_ipv6
>> ifb ipip ip6_tunnel tunnel6 tunnel4 ip_tunnel tun mdio loop vfat fat isofs
>> nls_utf8 nls_iso8859_15 nls_iso8859_1 nls_cp850 nls_cp437 rfkill virtio_rng
>> sha512_generic sha256_generic sha1_generic md5 arc4 ath10k_pci ath10k_core
>> ath9k ath9k_common ath9k_hw ath mac80211 cfg80211 compat pcnet32 e1000
>> virtio_net ohci_hcd ixgbevf ixgbe hwmon igbvf igb dsa_core mii [last
>> unloaded: igb_uio]
>> [  330.805110] CPU: 0 PID: 8063 Comm: dpdk_master Tainted: G        W
>> 3.14.67 #1
>> [  330.806104] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996),
>> BIOS Bochs 01/01/2011
>> [  330.806104]  0000000000000286 0000000000000000 ffffffff814e167c
>> 0000000000000006
>> [  330.806104]  ffff88008b573cd8 ffffffff81259d73 ffffffff81061b72
>> ffff88013b24fae0
>> [  330.806104]  ffff88013b24f800 0000000000000000 ffff88013a498000
>> ffff88013b24f8a8
>> [  330.806104] Call Trace:
>> [  330.806104]  [<ffffffff814e167c>] ? dump_stack+0x5e/0x7a
>> [  330.806104]  [<ffffffff81259d73>] ? pci_mmap_resource.isra.14+0x11
>> 3/0x1b0
>> [  330.806104]  [<ffffffff81061b72>] ? warn_slowpath_common+0x82/0xb0
>> [  330.806104]  [<ffffffff81061c55>] ? warn_slowpath_fmt+0x45/0x50
>> [  330.806104]  [<ffffffff81120321>] ? do_last.isra.58+0xac1/0xc00
>> [  330.806104]  [<ffffffff81259d73>] ? pci_mmap_resource.isra.14+0x11
>> 3/0x1b0
>> [  330.806104]  [<ffffffff8116da79>] ? kernfs_fop_mmap+0x69/0x100
>> [  330.806104]  [<ffffffff810f4018>] ? mmap_region+0x2e8/0x560
>> [  330.806104]  [<ffffffff810f45a8>] ? do_mmap_pgoff+0x318/0x3b0
>> [  330.806104]  [<ffffffff810e1724>] ? vm_mmap_pgoff+0x74/0xc0
>> [  330.806104]  [<ffffffff810f2d1a>] ? SyS_mmap_pgoff+0x18a/0x1e0
>> [  330.806104]  [<ffffffff814e7759>] ? system_call_fastpath+0x16/0x1b
>> [  330.823897] ---[ end trace c6106b67c768d501 ]---
>> EAL: Cannot mmap IO port resource: Invalid argument
>> EAL: Error - exiting with code: 1
>>   Cause: Requested device 0000:00:05.0 cannot be used
>>
>
>

  reply	other threads:[~2016-12-11  8:29 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-10  4:30 Gopakumar Choorakkot Edakkunni
2016-12-10 23:21 ` Gopakumar Choorakkot Edakkunni
2016-12-11  8:29   ` Gopakumar Choorakkot Edakkunni [this message]
2016-12-11 18:52     ` Gopakumar Choorakkot Edakkunni

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=CABK1yFAXs6HC9hOy4RF0FLwvOhgeh4EQwp5NRTevwmJOys-qmQ@mail.gmail.com \
    --to=gopakumar.c.e@gmail.com \
    --cc=dev@dpdk.org \
    --cc=olivier.matz@6wind.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).