* [Question] Failed to access the BAR MMIO space of PCI device
@ 2013-04-07 19:19 zhengfei
2013-04-08 14:23 ` Alex Williamson
0 siblings, 1 reply; 5+ messages in thread
From: zhengfei @ 2013-04-07 19:19 UTC (permalink / raw)
To: linux-pci
Hi,
I'm writing a driver for a SR-IOV device on the PCI bus. My architecture is
a 64-bit X86 of intel Sandy bridge.
In my device driver, I want to configure the device to transfer data to/from
X86.I get the the device BAR MMIO base address with the command "lspci -s
04:00.03 -xxx" in the guest os(kvm).
But after I ioremap() that MMIO base address,I failed to access the BAR MMIO
space in the guest os(kvm).
Is there a function which show mapping between the real PCI address stored in
the BAR and the emulated address stored in the BAR?
Thanks.
zhengfei
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Question] Failed to access the BAR MMIO space of PCI device
2013-04-07 19:19 [Question] Failed to access the BAR MMIO space of PCI device zhengfei
@ 2013-04-08 14:23 ` Alex Williamson
2013-04-11 17:15 ` zhengfei
0 siblings, 1 reply; 5+ messages in thread
From: Alex Williamson @ 2013-04-08 14:23 UTC (permalink / raw)
To: zhengfei; +Cc: linux-pci
On Sun, 2013-04-07 at 19:19 +0000, zhengfei wrote:
> Hi,
>
> I'm writing a driver for a SR-IOV device on the PCI bus. My architecture is
> a 64-bit X86 of intel Sandy bridge.
>
> In my device driver, I want to configure the device to transfer data to/from
> X86.I get the the device BAR MMIO base address with the command "lspci -s
> 04:00.03 -xxx" in the guest os(kvm).
> But after I ioremap() that MMIO base address,I failed to access the BAR MMIO
> space in the guest os(kvm).
>
> Is there a function which show mapping between the real PCI address stored in
> the BAR and the emulated address stored in the BAR?
Is this a userspace driver or a kernel driver? I can't figure out why
you would use lspci to get a static BAR address, then use ioremap() to
map it. If it's a kernel driver, the sequence you want is something
like:
pci_enable_device
pci_request_selected_regions
pci_iomap
Thanks,
Alex
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Question] Failed to access the BAR MMIO space of PCI device
2013-04-08 14:23 ` Alex Williamson
@ 2013-04-11 17:15 ` zhengfei
2013-04-11 17:57 ` Alex Williamson
0 siblings, 1 reply; 5+ messages in thread
From: zhengfei @ 2013-04-11 17:15 UTC (permalink / raw)
To: linux-pci
Alex Williamson <alex.williamson <at> redhat.com> writes:
>
> On Sun, 2013-04-07 at 19:19 +0000, zhengfei wrote:
> > Hi,
> >
> > I'm writing a driver for a SR-IOV device on the PCI bus. My architecture
is
> > a 64-bit X86 of intel Sandy bridge.
> >
> > In my device driver, I want to configure the device to transfer data
to/from
> > X86.I get the the device BAR MMIO base address with the command "lspci -
s
> > 04:00.03 -xxx" in the guest os(kvm).
> > But after I ioremap() that MMIO base address,I failed to access the BAR
MMIO
> > space in the guest os(kvm).
> >
> > Is there a function which show mapping between the real PCI address
stored in
> > the BAR and the emulated address stored in the BAR?
>
> Is this a userspace driver or a kernel driver? I can't figure out why
> you would use lspci to get a static BAR address, then use ioremap() to
> map it. If it's a kernel driver, the sequence you want is something
> like:
>
> pci_enable_device
> pci_request_selected_regions
> pci_iomap
>
> Thanks,
> Alex
>
>
It is a userspace driver on guest os.To be simply,I got the BAR0
address(gpa) on guest os,but I failed to access real BAR0 MMIO address space
of the device with the gpa.So what can I do next? and in which source code
file,could I find the procedure of mapping the real BAR address space(hpa)
to gpa?
Thanks
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Question] Failed to access the BAR MMIO space of PCI device
2013-04-11 17:15 ` zhengfei
@ 2013-04-11 17:57 ` Alex Williamson
2013-04-12 15:28 ` zhengfei
0 siblings, 1 reply; 5+ messages in thread
From: Alex Williamson @ 2013-04-11 17:57 UTC (permalink / raw)
To: zhengfei; +Cc: linux-pci
On Thu, 2013-04-11 at 17:15 +0000, zhengfei wrote:
> Alex Williamson <alex.williamson <at> redhat.com> writes:
>
> >
> > On Sun, 2013-04-07 at 19:19 +0000, zhengfei wrote:
> > > Hi,
> > >
> > > I'm writing a driver for a SR-IOV device on the PCI bus. My architecture
> is
> > > a 64-bit X86 of intel Sandy bridge.
> > >
> > > In my device driver, I want to configure the device to transfer data
> to/from
> > > X86.I get the the device BAR MMIO base address with the command "lspci -
> s
> > > 04:00.03 -xxx" in the guest os(kvm).
> > > But after I ioremap() that MMIO base address,I failed to access the BAR
> MMIO
> > > space in the guest os(kvm).
> > >
> > > Is there a function which show mapping between the real PCI address
> stored in
> > > the BAR and the emulated address stored in the BAR?
> >
> > Is this a userspace driver or a kernel driver? I can't figure out why
> > you would use lspci to get a static BAR address, then use ioremap() to
> > map it. If it's a kernel driver, the sequence you want is something
> > like:
> >
> > pci_enable_device
> > pci_request_selected_regions
> > pci_iomap
> >
> > Thanks,
> > Alex
> >
> >
>
> It is a userspace driver on guest os.To be simply,I got the BAR0
> address(gpa) on guest os,but I failed to access real BAR0 MMIO address space
> of the device with the gpa.So what can I do next? and in which source code
> file,could I find the procedure of mapping the real BAR address space(hpa)
> to gpa?
The guest doesn't have access to the hpa, nor should it need it. To map
BAR0 from guest userspace
mmap /sys/bus/pci/devices/xxxx:xx:xx.x/resource0. Thanks,
Alex
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Question] Failed to access the BAR MMIO space of PCI device
2013-04-11 17:57 ` Alex Williamson
@ 2013-04-12 15:28 ` zhengfei
0 siblings, 0 replies; 5+ messages in thread
From: zhengfei @ 2013-04-12 15:28 UTC (permalink / raw)
To: linux-pci
Alex Williamson <alex.williamson <at> redhat.com> writes:
>
> On Thu, 2013-04-11 at 17:15 +0000, zhengfei wrote:
> > Alex Williamson <alex.williamson <at> redhat.com> writes:
> >
> > >
> > > On Sun, 2013-04-07 at 19:19 +0000, zhengfei wrote:
> > > > Hi,
> > > >
> > > > I'm writing a driver for a SR-IOV device on the PCI bus. My
architecture
> > is
> > > > a 64-bit X86 of intel Sandy bridge.
> > > >
> > > > In my device driver, I want to configure the device to transfer data
> > to/from
> > > > X86.I get the the device BAR MMIO base address with the command
"lspci -
> > s
> > > > 04:00.03 -xxx" in the guest os(kvm).
> > > > But after I ioremap() that MMIO base address,I failed to access the
BAR
> > MMIO
> > > > space in the guest os(kvm).
> > > >
> > > > Is there a function which show mapping between the real PCI address
> > stored in
> > > > the BAR and the emulated address stored in the BAR?
> > >
> >
> > It is a userspace driver on guest os.To be simply,I got the BAR0
> > address(gpa) on guest os,but I failed to access real BAR0 MMIO address
space
> > of the device with the gpa.So what can I do next? and in which source
code
> > file,could I find the procedure of mapping the real BAR address
space(hpa)
> > to gpa?
>
> The guest doesn't have access to the hpa, nor should it need it. To map
> BAR0 from guest userspace
> mmap /sys/bus/pci/devices/xxxx:xx:xx.x/resource0. Thanks,
>
> Alex
>
>
Yes,I have followed your advice above,but the problem still exists.I doubt
the address may not be correct gotten by "mmap
/sys/bus/pci/devices/xxxx:xx:xx.x/resource0",what can I do next to debug? so
I want to learn ,how do the guest userspace mapping to host BAR0 address
space.
zhengfei,
Thanks
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2013-04-12 15:28 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-04-07 19:19 [Question] Failed to access the BAR MMIO space of PCI device zhengfei
2013-04-08 14:23 ` Alex Williamson
2013-04-11 17:15 ` zhengfei
2013-04-11 17:57 ` Alex Williamson
2013-04-12 15:28 ` zhengfei
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).