Results 1 to 5 of 5

Thread: mmap to PCI bars fails in SLES15 OS.

  1. #1

    Default mmap to PCI bars fails in SLES15 OS.

    I am trying to do mmap to PCI CSR bar. mmap fails with error EINVAL. The value obtained for sb.st_size is 65536. But mmap failed with error string "Invalid argument". The same code snippet works fine in RHEL 7.2 but fails in SLES15 operating system. Below is my code snippet.

    Code:
    snprintf(csr_bar_path,256,"/sys/bus/pci/devices/0000:16:00.0/resource2");
    csr_fd = open(csr_bar_path,O_RDWR | O_SYNC);
    if(csr_fd < 0)
    {
        printf("Cannot open CSR bar file %s\n",csr_bar_path);
    }
    if(fstat(csr_fd,&sb) == -1)
    {
        printf("CSR file size = %d\n",sb.st_size);
        close(csr_fd);
    }
    printf("CSR file size OK = %d\n",sb.st_size);
    csr_bar = (unsigned char *)mmap(NULL,sb.st_size,PROT_READ | 
                                      PROT_WRITE,MAP_SHARED,csr_fd,0);
    if(csr_bar == (void *) -1)
    {
        printf("mmap failed for CSR bar %s %d\n",strerror(errno),errno);
        close(csr_fd);
    }

  2. #2
    Join Date
    Jun 2008
    Location
    Netherlands
    Posts
    29,793

    Default Re: mmap to PCI bars fails in SLES15 OS.

    While it is possible that your code is so generic that it also fits other operating systems, I think you should be aware that these here are the openSUSE forums and not the SLES/SLED forums.

    They are at https://forums.suse.com/forum.php , same username/password as here.
    Henk van Velden

  3. #3
    Join Date
    Jun 2008
    Location
    San Diego, Ca, USA
    Posts
    13,295
    Blog Entries
    2

    Default Re: mmap to PCI bars fails in SLES15 OS.

    There is likely some confusion here.

    AFAIK SUSE latest version is SUSE 12 SP3
    while
    openSUSE 15 is launching shortly.

    TSU
    Beginner Wiki Quickstart - https://en.opensuse.org/User:Tsu2/Quickstart_Wiki
    Solved a problem recently? Create a wiki page for future personal reference!
    Learn something new?
    Attended a computing event?
    Post and Share!

  4. #4
    Join Date
    Jun 2008
    Location
    San Diego, Ca, USA
    Posts
    13,295
    Blog Entries
    2

    Default Re: mmap to PCI bars fails in SLES15 OS.

    Regarding your code snippet,
    It's never enough to say simply that code "fails."
    The way and at what point the code fails is always telling.

    So,
    If you're coding in an IDE you can generally insert breakpoints.
    If you're not coding in an IDE, then you may have to insert temporary code that instruments what is happening at a more detailed level.
    So, for instance I see I see several statements that require a number of parameters to be true, you may have to check that each are not null.

    HTH,
    TSU
    Beginner Wiki Quickstart - https://en.opensuse.org/User:Tsu2/Quickstart_Wiki
    Solved a problem recently? Create a wiki page for future personal reference!
    Learn something new?
    Attended a computing event?
    Post and Share!

  5. #5
    Join Date
    Jun 2008
    Location
    Podunk
    Posts
    32,336
    Blog Entries
    15

    Default Re: mmap to PCI bars fails in SLES15 OS.

    On Tue 22 May 2018 01:46:02 PM CDT, tsu2 wrote:

    There is likely some confusion here.

    AFAIK SUSE latest version is SUSE 12 SP3
    while
    openSUSE 15 is launching shortly.

    TSU


    Hi
    SLES 15 is still in beta (see my signature) but due out soon..... OP
    should post in the Beta Mailing List...

    --
    Cheers Malcolm °¿° SUSE Knowledge Partner (Linux Counter #276890)
    SLES 15 RC4 | GNOME Shell 3.26.2 | 4.12.14-18-default
    If you find this post helpful and are logged into the web interface,
    please show your appreciation and click on the star below... Thanks!


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •