* [PATCH] pci: Fix e100 interrupt quirk
@ 2007-09-18 11:17 Valentine Barshak
2007-09-19 10:43 ` Jarek Poplawski
2007-09-20 6:37 ` Andrew Morton
0 siblings, 2 replies; 6+ messages in thread
From: Valentine Barshak @ 2007-09-18 11:17 UTC (permalink / raw)
To: linux-kernel
PCI memory space may have a 64-bit offset on some architectures
(for example, PowerPC 440) and the actual PCI memory address
has to fixed up (an offset to PCI mem space shuld be added)
before remapping. So, pci_iomap should be used instead of
reading and remapping PCI BAR directly. This has been tested
on Sequoia PowerPC 440EPx board.
Signed-off-by: Valentine Barshak <vbarshak@ru.mvista.com>
---
--- linux-2.6.orig/drivers/pci/quirks.c 2007-09-04 21:15:43.000000000 +0400
+++ linux-2.6.bld/drivers/pci/quirks.c 2007-09-05 20:46:14.000000000 +0400
@@ -1444,9 +1444,9 @@
static void __devinit quirk_e100_interrupt(struct pci_dev *dev)
{
u16 command;
- u32 bar;
u8 __iomem *csr;
u8 cmd_hi;
+ int rc;
switch (dev->device) {
/* PCI IDs taken from drivers/net/e100.c */
@@ -1476,16 +1476,17 @@
* re-enable them when it's ready.
*/
pci_read_config_word(dev, PCI_COMMAND, &command);
- pci_read_config_dword(dev, PCI_BASE_ADDRESS_0, &bar);
- if (!(command & PCI_COMMAND_MEMORY) || !bar)
+ rc = pci_request_region(dev, 0, "e100_quirk");
+
+ if (!(command & PCI_COMMAND_MEMORY) || (rc < 0))
return;
- csr = ioremap(bar, 8);
+ csr = pci_iomap(dev, 0, 8);
if (!csr) {
printk(KERN_WARNING "PCI: Can't map %s e100 registers\n",
pci_name(dev));
- return;
+ goto e100_quirk_exit;
}
cmd_hi = readb(csr + 3);
@@ -1495,7 +1496,9 @@
writeb(1, csr + 3);
}
- iounmap(csr);
+ pci_iounmap(dev, csr);
+e100_quirk_exit:
+ pci_release_region(dev, 0);
}
DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, PCI_ANY_ID, quirk_e100_interrupt);
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] pci: Fix e100 interrupt quirk
2007-09-18 11:17 [PATCH] pci: Fix e100 interrupt quirk Valentine Barshak
@ 2007-09-19 10:43 ` Jarek Poplawski
2007-09-19 10:59 ` Valentine Barshak
2007-09-19 12:36 ` Valentine Barshak
2007-09-20 6:37 ` Andrew Morton
1 sibling, 2 replies; 6+ messages in thread
From: Jarek Poplawski @ 2007-09-19 10:43 UTC (permalink / raw)
To: Valentine Barshak; +Cc: linux-kernel
On 18-09-2007 13:17, Valentine Barshak wrote:
> PCI memory space may have a 64-bit offset on some architectures
> (for example, PowerPC 440) and the actual PCI memory address
> has to fixed up (an offset to PCI mem space shuld be added)
> before remapping. So, pci_iomap should be used instead of
> reading and remapping PCI BAR directly. This has been tested
> on Sequoia PowerPC 440EPx board.
>
> Signed-off-by: Valentine Barshak <vbarshak@ru.mvista.com>
> ---
>
> --- linux-2.6.orig/drivers/pci/quirks.c 2007-09-04 21:15:43.000000000 +0400
> +++ linux-2.6.bld/drivers/pci/quirks.c 2007-09-05 20:46:14.000000000 +0400
> @@ -1444,9 +1444,9 @@
> static void __devinit quirk_e100_interrupt(struct pci_dev *dev)
> {
> u16 command;
> - u32 bar;
> u8 __iomem *csr;
> u8 cmd_hi;
> + int rc;
>
> switch (dev->device) {
> /* PCI IDs taken from drivers/net/e100.c */
> @@ -1476,16 +1476,17 @@
> * re-enable them when it's ready.
> */
> pci_read_config_word(dev, PCI_COMMAND, &command);
> - pci_read_config_dword(dev, PCI_BASE_ADDRESS_0, &bar);
>
> - if (!(command & PCI_COMMAND_MEMORY) || !bar)
> + rc = pci_request_region(dev, 0, "e100_quirk");
> +
> + if (!(command & PCI_COMMAND_MEMORY) || (rc < 0))
> return;
I didn't look at this too much, but isn't something like:
if (rc >= 0)
goto e100_quirk_exit;
needed before this return?
Regards,
Jarek P.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] pci: Fix e100 interrupt quirk
2007-09-19 10:43 ` Jarek Poplawski
@ 2007-09-19 10:59 ` Valentine Barshak
2007-09-19 12:36 ` Valentine Barshak
1 sibling, 0 replies; 6+ messages in thread
From: Valentine Barshak @ 2007-09-19 10:59 UTC (permalink / raw)
To: Jarek Poplawski; +Cc: linux-kernel
Jarek Poplawski wrote:
> On 18-09-2007 13:17, Valentine Barshak wrote:
>> PCI memory space may have a 64-bit offset on some architectures
>> (for example, PowerPC 440) and the actual PCI memory address
>> has to fixed up (an offset to PCI mem space shuld be added)
>> before remapping. So, pci_iomap should be used instead of
>> reading and remapping PCI BAR directly. This has been tested
>> on Sequoia PowerPC 440EPx board.
>>
>> Signed-off-by: Valentine Barshak <vbarshak@ru.mvista.com>
>> ---
>>
>> --- linux-2.6.orig/drivers/pci/quirks.c 2007-09-04 21:15:43.000000000 +0400
>> +++ linux-2.6.bld/drivers/pci/quirks.c 2007-09-05 20:46:14.000000000 +0400
>> @@ -1444,9 +1444,9 @@
>> static void __devinit quirk_e100_interrupt(struct pci_dev *dev)
>> {
>> u16 command;
>> - u32 bar;
>> u8 __iomem *csr;
>> u8 cmd_hi;
>> + int rc;
>>
>> switch (dev->device) {
>> /* PCI IDs taken from drivers/net/e100.c */
>> @@ -1476,16 +1476,17 @@
>> * re-enable them when it's ready.
>> */
>> pci_read_config_word(dev, PCI_COMMAND, &command);
>> - pci_read_config_dword(dev, PCI_BASE_ADDRESS_0, &bar);
>>
>> - if (!(command & PCI_COMMAND_MEMORY) || !bar)
>> + rc = pci_request_region(dev, 0, "e100_quirk");
>> +
>> + if (!(command & PCI_COMMAND_MEMORY) || (rc < 0))
>> return;
>
> I didn't look at this too much, but isn't something like:
> if (rc >= 0)
> goto e100_quirk_exit;
> needed before this return?
I'll split these 2 checks and submit new patch in a minute.
Thanks.
>
> Regards,
> Jarek P.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH] pci: Fix e100 interrupt quirk
2007-09-19 10:43 ` Jarek Poplawski
2007-09-19 10:59 ` Valentine Barshak
@ 2007-09-19 12:36 ` Valentine Barshak
1 sibling, 0 replies; 6+ messages in thread
From: Valentine Barshak @ 2007-09-19 12:36 UTC (permalink / raw)
To: linux-kernel; +Cc: jarkao2
PCI memory space may have a 64-bit offset on some architectures
(for example, PowerPC 440) and the actual PCI memory address
has to fixed up (an offset to PCI mem space shuld be added)
before remapping. So, pci_iomap should be used instead of
reading and remapping PCI BAR directly. This has been tested
on Sequoia PowerPC 440EPx board.
Signed-off-by: Valentine Barshak <vbarshak@ru.mvista.com>
---
diff -ruN linux-2.6.orig/drivers/pci/quirks.c linux-2.6/drivers/pci/quirks.c
--- linux-2.6.orig/drivers/pci/quirks.c 2007-09-18 15:32:48.000000000 +0400
+++ linux-2.6/drivers/pci/quirks.c 2007-09-19 15:57:26.000000000 +0400
@@ -1444,7 +1444,6 @@
static void __devinit quirk_e100_interrupt(struct pci_dev *dev)
{
u16 command;
- u32 bar;
u8 __iomem *csr;
u8 cmd_hi;
@@ -1476,16 +1475,18 @@
* re-enable them when it's ready.
*/
pci_read_config_word(dev, PCI_COMMAND, &command);
- pci_read_config_dword(dev, PCI_BASE_ADDRESS_0, &bar);
- if (!(command & PCI_COMMAND_MEMORY) || !bar)
+ if (!(command & PCI_COMMAND_MEMORY))
return;
- csr = ioremap(bar, 8);
+ if (pci_request_region(dev, 0, "e100_quirk"))
+ return;
+
+ csr = pci_iomap(dev, 0, 8);
if (!csr) {
printk(KERN_WARNING "PCI: Can't map %s e100 registers\n",
pci_name(dev));
- return;
+ goto e100_quirk_exit;
}
cmd_hi = readb(csr + 3);
@@ -1495,7 +1496,9 @@
writeb(1, csr + 3);
}
- iounmap(csr);
+ pci_iounmap(dev, csr);
+e100_quirk_exit:
+ pci_release_region(dev, 0);
}
DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, PCI_ANY_ID, quirk_e100_interrupt);
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] pci: Fix e100 interrupt quirk
2007-09-18 11:17 [PATCH] pci: Fix e100 interrupt quirk Valentine Barshak
2007-09-19 10:43 ` Jarek Poplawski
@ 2007-09-20 6:37 ` Andrew Morton
2007-09-20 11:33 ` Valentine Barshak
1 sibling, 1 reply; 6+ messages in thread
From: Andrew Morton @ 2007-09-20 6:37 UTC (permalink / raw)
To: Valentine Barshak; +Cc: linux-kernel, Auke Kok, netdev
On Tue, 18 Sep 2007 15:17:37 +0400 Valentine Barshak <vbarshak@ru.mvista.com> wrote:
> PCI memory space may have a 64-bit offset on some architectures
> (for example, PowerPC 440) and the actual PCI memory address
> has to fixed up (an offset to PCI mem space shuld be added)
> before remapping. So, pci_iomap should be used instead of
> reading and remapping PCI BAR directly. This has been tested
> on Sequoia PowerPC 440EPx board.
>
> Signed-off-by: Valentine Barshak <vbarshak@ru.mvista.com>
> ---
>
> --- linux-2.6.orig/drivers/pci/quirks.c 2007-09-04 21:15:43.000000000 +0400
> +++ linux-2.6.bld/drivers/pci/quirks.c 2007-09-05 20:46:14.000000000 +0400
> @@ -1444,9 +1444,9 @@
> static void __devinit quirk_e100_interrupt(struct pci_dev *dev)
> {
> u16 command;
> - u32 bar;
> u8 __iomem *csr;
> u8 cmd_hi;
> + int rc;
>
> switch (dev->device) {
> /* PCI IDs taken from drivers/net/e100.c */
> @@ -1476,16 +1476,17 @@
> * re-enable them when it's ready.
> */
> pci_read_config_word(dev, PCI_COMMAND, &command);
> - pci_read_config_dword(dev, PCI_BASE_ADDRESS_0, &bar);
>
> - if (!(command & PCI_COMMAND_MEMORY) || !bar)
> + rc = pci_request_region(dev, 0, "e100_quirk");
> +
> + if (!(command & PCI_COMMAND_MEMORY) || (rc < 0))
> return;
Really? So if pci_request_region() failed and !(command & PCI_COMMAND_MEMORY),
we leak the region? So the next call to this function will fail?
> - csr = ioremap(bar, 8);
> + csr = pci_iomap(dev, 0, 8);
> if (!csr) {
> printk(KERN_WARNING "PCI: Can't map %s e100 registers\n",
> pci_name(dev));
> - return;
> + goto e100_quirk_exit;
> }
>
> cmd_hi = readb(csr + 3);
> @@ -1495,7 +1496,9 @@
> writeb(1, csr + 3);
> }
>
> - iounmap(csr);
> + pci_iounmap(dev, csr);
> +e100_quirk_exit:
> + pci_release_region(dev, 0);
> }
> DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, PCI_ANY_ID, quirk_e100_interrupt);
>
> -
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] pci: Fix e100 interrupt quirk
2007-09-20 6:37 ` Andrew Morton
@ 2007-09-20 11:33 ` Valentine Barshak
0 siblings, 0 replies; 6+ messages in thread
From: Valentine Barshak @ 2007-09-20 11:33 UTC (permalink / raw)
To: Andrew Morton; +Cc: linux-kernel, Auke Kok, netdev
Andrew Morton wrote:
> On Tue, 18 Sep 2007 15:17:37 +0400 Valentine Barshak <vbarshak@ru.mvista.com> wrote:
>
>> PCI memory space may have a 64-bit offset on some architectures
>> (for example, PowerPC 440) and the actual PCI memory address
>> has to fixed up (an offset to PCI mem space shuld be added)
>> before remapping. So, pci_iomap should be used instead of
>> reading and remapping PCI BAR directly. This has been tested
>> on Sequoia PowerPC 440EPx board.
>>
>> Signed-off-by: Valentine Barshak <vbarshak@ru.mvista.com>
>> ---
>>
>> --- linux-2.6.orig/drivers/pci/quirks.c 2007-09-04 21:15:43.000000000 +0400
>> +++ linux-2.6.bld/drivers/pci/quirks.c 2007-09-05 20:46:14.000000000 +0400
>> @@ -1444,9 +1444,9 @@
>> static void __devinit quirk_e100_interrupt(struct pci_dev *dev)
>> {
>> u16 command;
>> - u32 bar;
>> u8 __iomem *csr;
>> u8 cmd_hi;
>> + int rc;
>>
>> switch (dev->device) {
>> /* PCI IDs taken from drivers/net/e100.c */
>> @@ -1476,16 +1476,17 @@
>> * re-enable them when it's ready.
>> */
>> pci_read_config_word(dev, PCI_COMMAND, &command);
>> - pci_read_config_dword(dev, PCI_BASE_ADDRESS_0, &bar);
>>
>> - if (!(command & PCI_COMMAND_MEMORY) || !bar)
>> + rc = pci_request_region(dev, 0, "e100_quirk");
>> +
>> + if (!(command & PCI_COMMAND_MEMORY) || (rc < 0))
>> return;
>
> Really? So if pci_request_region() failed and !(command & PCI_COMMAND_MEMORY),
> we leak the region? So the next call to this function will fail?
>
I've split command and request region checks and submitted new patch:
http://lkml.org/lkml/2007/9/19/106
Please, take a look,
Thanks,
Valentine.
>
>> - csr = ioremap(bar, 8);
>> + csr = pci_iomap(dev, 0, 8);
>> if (!csr) {
>> printk(KERN_WARNING "PCI: Can't map %s e100 registers\n",
>> pci_name(dev));
>> - return;
>> + goto e100_quirk_exit;
>> }
>>
>> cmd_hi = readb(csr + 3);
>> @@ -1495,7 +1496,9 @@
>> writeb(1, csr + 3);
>> }
>>
>> - iounmap(csr);
>> + pci_iounmap(dev, csr);
>> +e100_quirk_exit:
>> + pci_release_region(dev, 0);
>> }
>> DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, PCI_ANY_ID, quirk_e100_interrupt);
>>
>> -
>> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at http://vger.kernel.org/majordomo-info.html
>> Please read the FAQ at http://www.tux.org/lkml/
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2007-09-20 11:34 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-09-18 11:17 [PATCH] pci: Fix e100 interrupt quirk Valentine Barshak
2007-09-19 10:43 ` Jarek Poplawski
2007-09-19 10:59 ` Valentine Barshak
2007-09-19 12:36 ` Valentine Barshak
2007-09-20 6:37 ` Andrew Morton
2007-09-20 11:33 ` Valentine Barshak
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox