linux-hotplug.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Chitturi, Divakar" <divakar.chitturi@hpe.com>
To: linux-hotplug@vger.kernel.org
Subject: Assign BAR address for pci device after hotplug
Date: Tue, 02 Aug 2016 21:11:09 +0000	[thread overview]
Message-ID: <AT5PR84MB0177723391A9CA3EAEE43C0088050@AT5PR84MB0177.NAMPRD84.PROD.OUTLOOK.COM> (raw)

Hi

Below are two scenarios for which i would like to understand the right way to assign the BAR address for my PCI device

Device details:
pci switch upstrem port connected to root complex
pci switch downstream port 1 connected to my_pci_device
my_pci_device is FPGA
FPGA has bunch of controllers and other logic

Driver details:
Have a dedicated pci kernel driver for my_device
Enabled pcihp kernel driver
 
At power on, BIOS assigns/reserves specific region of memory for my pci device.
during the linux boot process, pci core will assign the bar and other initialization and call my
probe function in the driver. probe function will perform some initialization which includes reading
the BAR and setting some registers in IO space of the device. 

Scn1:
At some point the device is removed and reinserted

Scn2:
At some point similar device is inserted in a new pci slot

In both the scenarios explained about, BIOS is not involved as system was never turned off completely. So
1. how do we obtain the BAR address for the device. 
2. Should i assign it explicitly? 
3. if yes, should it be done in my driver ( in both the case i am assuming driver's probe function will be called )
4. can i use pci_assign_resource() in drivers probe function
5. is something like below the right way to do it ?

static int my_probe(struct pci_dev *pdev, const struct pci_device_id *id)
{
         if( pci_resource_start (pdev,BAR0) <= 0) {
                pr_debug(" Assign BAR0 \n");
	ret = pci_assign_resource(pdev,BAR0);
                if( 0 > ret) {
                    dev_err(&pdev->dev, " Failed to assign resource \n");
                    return ret;
                }
        }
		
       ret = pci_enable_device(pdev);
       ret = pci_request_regions(pdev, dev_driver_string(&pdev->dev));
       base_addr = pci_iomap(pdev, BAR0, 0);
}

Thanks
Divakar

             reply	other threads:[~2016-08-02 21:11 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-02 21:11 Chitturi, Divakar [this message]
2016-08-03  5:12 ` Assign BAR address for pci device after hotplug Greg KH
2016-08-04 17:09 ` Chitturi, Divakar
2016-08-05 10:53 ` Greg KH
2016-08-09  0:32 ` divakar
2016-08-09  0:49 ` Greg KH
2016-08-09 17:00 ` divakar
2016-08-09 17:18 ` Greg KH
2016-08-09 18:48 ` divakar
2016-08-09 18:59 ` Greg KH
2016-08-10  0:26 ` divakar
2016-08-10  8:47 ` Greg KH

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=AT5PR84MB0177723391A9CA3EAEE43C0088050@AT5PR84MB0177.NAMPRD84.PROD.OUTLOOK.COM \
    --to=divakar.chitturi@hpe.com \
    --cc=linux-hotplug@vger.kernel.org \
    /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 read-only IMAP folder(s) and NNTP newsgroup(s).