Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8966159
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T16:58:02+00:00 2026-06-15T16:58:02+00:00

I am writing a PCI driver for a simple test device. Hardware is recognized

  • 0

I am writing a PCI driver for a simple test device.

Hardware is recognized correctly with lspci (as you can see my driver vabs has been registered):

04:02.0 Non-VGA unclassified device: Device bace:55aa
    Control: I/O+ Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx-
    Status: Cap- 66MHz- UDF- FastB2B- ParErr- DEVSEL=medium >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
    Latency: 0
    Region 0: Memory at f0000000 (32-bit, prefetchable) [size=16M]
    Kernel driver in use: vabs

Initialisation and deinitalisation of driver and PCI subystem works fine. I am getting a device number, and udev creates a device file.

When reading from the device file I get the following error message:

BUG: unable to handle kernel paging request at 00000000f0000000

I request PCI ressources in the initialisation successfully. This returns 00000000f0000000 for memstart0, which is my base address 0 for PCI.

memstart0 = pci_resource_start( pdev, 0 );
memlen = pci_resource_len( pdev, 0 );
if( request_mem_region(memstart0,memlen,pdev->dev.kobj.name)==NULL ) {
    dev_err(&pdev->dev,"Memory address conflict for device\n");
    goto cleanup_mem;
}

Trying to read from this memio address with the following code gives the mentioned error:

ssize_t driver_read(struct file *instance, char __user *buffer, size_t max_bytes_to_read, loff_t *offset) {
    u32 test;

    dev_dbg(vabs_dev,"copying from %p\n", (void *) memstart0);
    test = readl((void *) memstart0);

    return max_bytes_to_read;
}

I also tried other access functions like memcpy_fromio, ioread32, and direct pointer access with the same result.

The hardware works on a Windows machine. The only notable difference is that Windows reserves base address 0 as 00000000fd000000 while Linux reserves it as 00000000f0000000.

This is for non-profit educational purpose in a public school. Thanks for your help!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T16:58:03+00:00Added an answer on June 15, 2026 at 4:58 pm

    Read Documentation/IO-mapping.txt (search for “iomap”) and/or Chapter 15 of LDD3.

    request_mem_region just ensures no other driver has already grabbed that memory region. You still need to map it into the kernel’s VM space using iomap before you can read/write it.

    Note that the whole pci_resource_start etc. dance is somewhat deprecated. I believe the recommended approach these days is:

    pci_request_regions(pdev, "myname");  /* to request regions for all BARs */
    

    Then:

    void __iomem *base = pci_iomap(pdev, 0, pci_resources_len(pdev,0)); /* to map BAR 0 */
    

    Then:

    ioread32(base + offset);  /* Or readl(base + offset), but this is more generic */
    

    And finally, at the end:

    pci_iounmap(pdev, base);  /* Release kernel VM mapping (undoes pci_iomap) */
    pci_release_regions(pdev); /* Release all regions (undoes pci_request_regions) */
    

    You can do the first two manually by combining pci_resource_start, pci_resource_len, request_mem_region, and iomap. But the above is (a) shorter and (b) generic between memory-mapped devices and those that use the old x86 I/O space. (Not that there are a whole lot of those around anymore.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm writing a block device driver for a hot-pluggable PCI memory device on 2.6.43.2-6.fc15
Writing a test app to emulate PIO lines, I have a very simple Python/Tk
I have a PCI device, its Linux driver, and a user-space application. The application
I was asked this question in an interview. You are writing a PCI driver
I'm writing a device driver to access the memory in a FPGA on a
Writing Classic ASP code in JScript has a lot going for it: more humane
Writing htaccess that allows me to remove index.php from the URL can confuse search
Writing a recursive function, I want one fn that executes when the list has
Writing a small HTML web page with some very simple Javascript in it, I
Writing a sound control applet with GUI that communicates with a device via USB.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.