saa7134 ioremap() problem
I have been using the saa7134.ko and saa7134_dvb.ko drivers for years as part of my mythtv system, working very nicely.
Now I am trying to use xen to virtualise my mythtv-backend, with PCI passthrough of the tuner to the virtual machine, everything hasn't gone smoothly, but I believe I have found an issue within the driver which would have gone un-noticed on a bare-metal machine, yet which causes a problem under xen.
Here is what lspci -vvv shows for my card
08:01.0 Multimedia controller: Philips Semiconductors SAA7130 Video Broadcast Decoder (rev 01)
Subsystem: Compro Technology, Inc. Videomate DVB-T200
Control: I/O- Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop-
ParErr- Stepping- SERR- FastB2B- DisINTx-
Status: Cap+ 66MHz- UDF- FastB2B+ ParErr- DEVSEL=medium
Quoted 1 line
TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
Latency: 64 (21000ns min, 8000ns max)
Interrupt: pin A routed to IRQ 17
Region 0: Memory at febffc00 (32-bit, non-prefetchable) [size=1K]
Capabilities: [40] Power Management version 1
Flags: PMEClk- DSI- D1+ D2+ AuxCurrent=0mAPME(D0-,D1-,D2-,D3hot-,D3cold-)
Status: D0 PME-Enable- DSel=0 DScale=1 PME-
Kernel modules: saa7134
Notice the MMIO area is 1K in size, but within the driver, it requests mapping of a 4K area, rather than 1K.
Obviously the kernel will have to round the start/end addresses to the nearest 4K boundaries as this is the granularity of page mapping, but if the request is too large to begin with it attempts to map two pages, straddling the card's physical address range, this works on a physical machine, but fails under xen due to more rigourous checking/enforcement of permissions.
I have rebuilt the driver module using 0x400 instead of 0x1000 for the ioremap() size and the driver then loads, instead of failing (I still have an interrupt problem but will follow that up separately).
If you'd like to follow the discussion I've been having on the xen-devel list, Keir Fraser should be able to answer questions on why this fails under xen far better than I can.
http://lists.xensource.com/archives/html/xen-devel/2008-07/msg00004.html
Could you comment on whether you'd accept a patch for this?
_______________________________________________
linux-dvb mailing list
[email protected]
http://www.linuxtv.org/cgi-bin/mailman/listinfo/linux-dvb
PATCH 1/1 Shrink saa7134 mmio mapped size
The saa7134 driver attempts to map 4K starting from the base address of its mmio area, although lspci shows the size of the area is only 1K. The excessive mapping goes un-noticed on bare-metal, but is detected and denied when the card is used with pci passthrough to a xen domU. If shared IRQ is used the "pollirq" kernel option may be required in dom0.
--- drivers/media/video/saa7134/saa7134-core.c.orig 2008-07-01
16:46:49.000000000 +0100
+++ drivers/media/video/saa7134/saa7134-core.c 2008-07-01 16:47:10.000000000 +0100
@@ -908,7 +908,7 @@
dev->name,(unsigned long
long)pci_resource_start(pci_dev,0));
goto fail1;
}
- dev->lmmio = ioremap(pci_resource_start(pci_dev,0), 0x1000);
+ dev->lmmio = ioremap(pci_resource_start(pci_dev,0), 0x400);
dev->bmmio = (__u8 __iomem *)dev->lmmio;
if (NULL == dev->lmmio) {
err = -EIO;_______________________________________________
linux-dvb mailing list
[email protected]
http://www.linuxtv.org/cgi-bin/mailman/listinfo/linux-dvb
Re: [linux-dvb] [PATCH] Shrink saa7134 mmio mapped size
Quoted 6 lines · Andy Burns
The saa7134 driver attempts to map 4K starting from the base address of its mmio area, although lspci shows the size of the area is only 1K. The excessive mapping goes un-noticed on bare-metal, but is detected and denied when the card is used with pci passthrough to a xen domU. If shared IRQ is used the "pollirq" kernel option may be required in dom0.
I have no real insight into the saa7134 core, but at least my card does have a memory region of 2K.
lspci -vvnn:
00:0b.0 Multimedia controller [0480]: Philips Semiconductors SAA7133/SAA7135 Video Broadcast Decoder [1131:7133] (rev d1)
Subsystem: Avermedia Technologies Inc Device [1461:a7a1]
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: 32 (63750ns min, 63750ns max)
Interrupt: pin A routed to IRQ 19
Region 0: Memory at dfffb800 (32-bit, non-prefetchable) [size=2K]
Capabilities: [40] Power Management version 2
Flags: PMEClk- DSI- D1+ D2+ AuxCurrent=0mAPME(D0-,D1-,D2-,D3hot-,D3cold-)
Status: D0 PME-Enable- DSel=0 DScale=3 PME-
Kernel driver in use: saa7134
Kernel modules: saa7134
Regards
Matthias
_______________________________________________
linux-dvb mailing list
[email protected]
http://www.linuxtv.org/cgi-bin/mailman/listinfo/linux-dvb
Re: [linux-dvb] [PATCH] Shrink saa7134 mmio mapped size
Quoted 2 lines · Matthias Schwarzott
I have no real insight into the saa7134 core, but at least my card does have a memory region of 2K.
Thanks, I only have one type of card, I'll try to investigate the best way to programatically determine the size of the memory region and use that instead of a hard-coded value, then resubmit a new patch.
_______________________________________________
linux-dvb mailing list
[email protected]
http://www.linuxtv.org/cgi-bin/mailman/listinfo/linux-dvb
Re: [linux-dvb] [PATCH] Shrink saa7134 mmio mapped size
The saa7134 driver attempts to map a fixed 4K starting from the base address of its mmio area, regardless of the actual size of the area. Any excessive mapping may extend past the end of a page, which goes un-noticed on bare-metal, but is detected and denied when the card is used with pci passthrough to a xen domU. If shared IRQ is used the "pollirq" kernel option may be required in dom0.
---- drivers/media/video/saa7134/saa7134-core.c.orig 2008-07-01
16:46:49.000000000 +0100
+++ drivers/media/video/saa7134/saa7134-core.c 2008-07-02 16:41:37.000000000 +0100
@@ -908,7 +908,8 @@
dev->name,(unsigned long
long)pci_resource_start(pci_dev,0));
goto fail1;
}
- dev->lmmio = ioremap(pci_resource_start(pci_dev,0), 0x1000);
+ dev->lmmio = ioremap(pci_resource_start(pci_dev,0),
+ pci_resource_len(pci_dev,0));
dev->bmmio = (__u8 __iomem *)dev->lmmio;
if (NULL == dev->lmmio) {
err = -EIO;_______________________________________________
linux-dvb mailing list
[email protected]
http://www.linuxtv.org/cgi-bin/mailman/listinfo/linux-dvb
Re: [linux-dvb] [PATCH] Shrink saa7134 mmio mapped size
Hello,
Am Mittwoch, den 02.07.2008, 16:50 +0100 schrieb Andy Burns:
Quoted 6 lines
The saa7134 driver attempts to map a fixed 4K starting from the base address of its mmio area, regardless of the actual size of the area. Any excessive mapping may extend past the end of a page, which goes un-noticed on bare-metal, but is detected and denied when the card is used with pci passthrough to a xen domU. If shared IRQ is used the "pollirq" kernel option may be required in dom0.
just a note.
We have some recent remotes sampling from IRQs triggered by a gpio pin without any additional IR chip.
There are some reports that "pollirq" makes them unusable, since sensible timings are lost.
No such reports from xen stuff yet, but the same might happen with shared IRQs and "pollirq" there too.
Cheers,
Hermann
Quoted 15 lines
Signed-off-by Andy Burns <[email protected]>----
drivers/media/video/saa7134/saa7134-core.c.orig2008-07-01
16:46:49.000000000 +0100
+++drivers/media/video/saa7134/saa7134-core.c2008-07-02 16:41:37.000000000 +0100(quoted diff) +2
-1@@ -908,7 +908,8 @@ dev->name,(unsigned long long)pci_resource_start(pci_dev,0)); goto fail1; } - dev->lmmio = ioremap(pci_resource_start(pci_dev,0), 0x1000); + dev->lmmio = ioremap(pci_resource_start(pci_dev,0), + pci_resource_len(pci_dev,0)); dev->bmmio = (__u8 __iomem *)dev->lmmio; if (NULL == dev->lmmio) {
Quoted 3 lines
err = -EIO;
--
video4linux-list mailing list
Unsubscribe mailto:[email protected]?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/video4linux-list
Re: [linux-dvb] [PATCH] Shrink saa7134 mmio mapped size
Quoted 5 lines · hermann pitton
We have some recent remotes sampling from IRQs triggered by a gpio pin without any additional IR chip.
There are some reports that "pollirq" makes them unusable, since sensible timings are lost.
Thanks for the info, not relevant for me though, the whole point of virtualising my mythtv backend with xen is to stuff all the noisy bits is a cupboard and have a separate frontend which does have a LiRC device.
Quoted 2 lines
No such reports from xen stuff yet, but the same might happen with shared IRQs and "pollirq" there too.
After I'd sorted the mmio mapping issue, the driver loaded under xen, but crashed after 40 seconds or so due to shared interrupt routing, so I added the pollirq, I understand this might cause performance issues as IRQs have to be delivered to multiple drivers in different xen domains, particularly one of my PCI slots shares with a PCI-X slot which has my 8xSATA card in it, so I've avoided that slot for now, but would like to have dual tuner again.
The driver is now working fairly well under xen, with a single tuner mythbckend can record three concurrent streams from a mux, with under 10% CPU.
I have one remaining issue, which I will try to track down, every now and then I seem to get a DMA error causing a kernel panic, my feeling is it happens when retuning; perhaps some DMA transfer is in-flight when something changes on the card and causes a problem? Or like the ioremap() it might be something xen is more sensitive to than a bare-metal machine.
Do I need to send my patch direct to Harmut Hackmann, or will he pick it up from the list if he likes it?
_______________________________________________
linux-dvb mailing list
[email protected]
http://www.linuxtv.org/cgi-bin/mailman/listinfo/linux-dvb
Re: [linux-dvb] [PATCH] Shrink saa7134 mmio mapped size
Hi,
Am Mittwoch, den 02.07.2008, 22:00 +0100 schrieb Andy Burns:
Quoted 34 lines · hermann pitton
Quoted 6 lines
We have some recent remotes sampling from IRQs triggered by a gpio pin without any additional IR chip.
There are some reports that "pollirq" makes them unusable, since sensible timings are lost.
Thanks for the info, not relevant for me though, the whole point of virtualising my mythtv backend with xen is to stuff all the noisy bits is a cupboard and have a separate frontend which does have a LiRC device.
Quoted 2 lines
No such reports from xen stuff yet, but the same might happen with shared IRQs and "pollirq" there too.
After I'd sorted the mmio mapping issue, the driver loaded under xen, but crashed after 40 seconds or so due to shared interrupt routing, so I added the pollirq, I understand this might cause performance issues as IRQs have to be delivered to multiple drivers in different xen domains, particularly one of my PCI slots shares with a PCI-X slot which has my 8xSATA card in it, so I've avoided that slot for now, but would like to have dual tuner again.
The driver is now working fairly well under xen, with a single tuner mythbckend can record three concurrent streams from a mux, with under 10% CPU.
I have one remaining issue, which I will try to track down, every now and then I seem to get a DMA error causing a kernel panic, my feeling is it happens when retuning; perhaps some DMA transfer is in-flight when something changes on the card and causes a problem? Or like the
ioremap()it might be something xen is more sensitive to than a bare-metal machine.
Quoted 3 lines
Do I need to send my patch direct to Harmut Hackmann, or will he pick it up from the list if he likes it?
that depends on the time he has, but if you think you have something proper, always send a copy directly to Hartmut and Mauro too.
I'm not within any xen, but Gerd, the saa7134 author, is on it since then. If you think it is xen specific, you might try to reach him too. ([email protected])
Can't tell, if he has time for it currently.
Cheers,
Hermann
--
video4linux-list mailing list
Unsubscribe mailto:[email protected]?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/video4linux-list