提交 971b5e56 编写于 作者: I Ian Abbott 提交者: Greg Kroah-Hartman

staging: comedi: me_daq: remove broken workaround for PLX bug

The PLX PCI 9050 interface chip has a bug where its local configuration
registers accessible through PCI BAR 0 and/or PCI BAR 1 (depending on
settings loaded from a serial EEPROM or local bus processor) are
unreadable (always read 0 instead of the true register values) if the
base address starts on an odd multiple of 0x80 (i.e.  has bit 7 set to
1).

The "me_daq" driver attempts to work around this by writing to the PCI
config space to swap the addresses assigned to PCI BAR 0 and PCI BAR 5
(which has been initially configured by serial EEPROM load as a spare
region of the same length as the PCI BAR 0 region).  (If the PCI BAR 5
region is absent, it attempts to reduce the PCI BAR 0 address by 0x80,
which is likely to cause havoc for some other device, but that case
shouldn't be reachable in practice.)

The workaround in the driver is ineffective because it has already
ioremapped the memory from `pci_resource_start(pcidev, 0)` *before* it
does the workaround, so after swapping PCI BAR 0 and PCI BAR 5, this
memory will end up accessing whatever onboard registers PCI BAR 5 was
linked to instead of the local configuration registers.  It also leaves
the addresses in the physical PCI BAR registers set differently to the
resource start addresses recorded in the `struct pci_dev`.

The workaround could be fixed by ioremapping `pci_resource_start(pcidev,
5)` if the PCI BAR addresses were physically swapped (and the fallback
workaround of subtracting 0x80 from the base address should really be
removed altogether).  However, it's not really worth it.  This sort of
thing should be worked around in "drivers/pci/quirks.c" by ensuring that
PCI BAR 0 and/or PCI BAR 1 do not end up on an odd multiple of 0x80
bytes.
Signed-off-by: NIan Abbott <abbotti@mev.co.uk>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
上级 a4a557e3
...@@ -486,48 +486,6 @@ static int me_reset(struct comedi_device *dev) ...@@ -486,48 +486,6 @@ static int me_reset(struct comedi_device *dev)
return 0; return 0;
} }
static int me_plx_bug_check(struct comedi_device *dev,
struct pci_dev *pcidev)
{
resource_size_t plx_regbase_tmp = pci_resource_start(pcidev, 0);
resource_size_t swap_regbase_tmp = pci_resource_start(pcidev, 5);
resource_size_t regbase_tmp;
int ret;
if (!swap_regbase_tmp)
dev_err(dev->class_dev, "Swap not present\n");
if (plx_regbase_tmp & 0x0080) {
dev_err(dev->class_dev, "PLX-Bug detected\n");
if (swap_regbase_tmp) {
regbase_tmp = plx_regbase_tmp;
plx_regbase_tmp = swap_regbase_tmp;
swap_regbase_tmp = regbase_tmp;
ret = pci_write_config_dword(pcidev,
PCI_BASE_ADDRESS_0,
plx_regbase_tmp);
if (ret != PCIBIOS_SUCCESSFUL)
return -EIO;
ret = pci_write_config_dword(pcidev,
PCI_BASE_ADDRESS_5,
swap_regbase_tmp);
if (ret != PCIBIOS_SUCCESSFUL)
return -EIO;
} else {
plx_regbase_tmp -= 0x80;
ret = pci_write_config_dword(pcidev,
PCI_BASE_ADDRESS_0,
plx_regbase_tmp);
if (ret != PCIBIOS_SUCCESSFUL)
return -EIO;
}
}
return 0;
}
static const void *me_find_boardinfo(struct comedi_device *dev, static const void *me_find_boardinfo(struct comedi_device *dev,
struct pci_dev *pcidev) struct pci_dev *pcidev)
{ {
...@@ -572,10 +530,6 @@ static int __devinit me_auto_attach(struct comedi_device *dev, ...@@ -572,10 +530,6 @@ static int __devinit me_auto_attach(struct comedi_device *dev,
if (!dev_private->plx_regbase) if (!dev_private->plx_regbase)
return -ENOMEM; return -ENOMEM;
ret = me_plx_bug_check(dev, pcidev);
if (ret)
return ret;
dev_private->me_regbase = ioremap(pci_resource_start(pcidev, 2), dev_private->me_regbase = ioremap(pci_resource_start(pcidev, 2),
pci_resource_len(pcidev, 2)); pci_resource_len(pcidev, 2));
if (!dev_private->me_regbase) if (!dev_private->me_regbase)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册