Commit 8445a87f authored by Guilherme G. Piccoli's avatar Guilherme G. Piccoli Committed by Michael Ellerman

powerpc/iommu: Remove the dependency on EEH struct in DDW mechanism

Commit 39baadbf ("powerpc/eeh: Remove eeh information from pci_dn")
changed the pci_dn struct by removing its EEH-related members.
As part of this clean-up, DDW mechanism was modified to read the device
configuration address from eeh_dev struct.

As a consequence, now if we disable EEH mechanism on kernel command-line
for example, the DDW mechanism will fail, generating a kernel oops by
dereferencing a NULL pointer (which turns to be the eeh_dev pointer).

This patch just changes the configuration address calculation on DDW
functions to a manual calculation based on pci_dn members instead of
using eeh_dev-based address.

No functional changes were made. This was tested on pSeries, both
in PHyp and qemu guest.

Fixes: 39baadbf ("powerpc/eeh: Remove eeh information from pci_dn")
Cc: stable@vger.kernel.org # v3.4+
Reviewed-by: default avatarGavin Shan <gwshan@linux.vnet.ibm.com>
Signed-off-by: default avatarGuilherme G. Piccoli <gpiccoli@linux.vnet.ibm.com>
Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
parent c2078d9e
...@@ -912,7 +912,8 @@ machine_arch_initcall(pseries, find_existing_ddw_windows); ...@@ -912,7 +912,8 @@ machine_arch_initcall(pseries, find_existing_ddw_windows);
static int query_ddw(struct pci_dev *dev, const u32 *ddw_avail, static int query_ddw(struct pci_dev *dev, const u32 *ddw_avail,
struct ddw_query_response *query) struct ddw_query_response *query)
{ {
struct eeh_dev *edev; struct device_node *dn;
struct pci_dn *pdn;
u32 cfg_addr; u32 cfg_addr;
u64 buid; u64 buid;
int ret; int ret;
...@@ -923,11 +924,10 @@ static int query_ddw(struct pci_dev *dev, const u32 *ddw_avail, ...@@ -923,11 +924,10 @@ static int query_ddw(struct pci_dev *dev, const u32 *ddw_avail,
* Retrieve them from the pci device, not the node with the * Retrieve them from the pci device, not the node with the
* dma-window property * dma-window property
*/ */
edev = pci_dev_to_eeh_dev(dev); dn = pci_device_to_OF_node(dev);
cfg_addr = edev->config_addr; pdn = PCI_DN(dn);
if (edev->pe_config_addr) buid = pdn->phb->buid;
cfg_addr = edev->pe_config_addr; cfg_addr = (pdn->busno << 8) | pdn->devfn;
buid = edev->phb->buid;
ret = rtas_call(ddw_avail[0], 3, 5, (u32 *)query, ret = rtas_call(ddw_avail[0], 3, 5, (u32 *)query,
cfg_addr, BUID_HI(buid), BUID_LO(buid)); cfg_addr, BUID_HI(buid), BUID_LO(buid));
...@@ -941,7 +941,8 @@ static int create_ddw(struct pci_dev *dev, const u32 *ddw_avail, ...@@ -941,7 +941,8 @@ static int create_ddw(struct pci_dev *dev, const u32 *ddw_avail,
struct ddw_create_response *create, int page_shift, struct ddw_create_response *create, int page_shift,
int window_shift) int window_shift)
{ {
struct eeh_dev *edev; struct device_node *dn;
struct pci_dn *pdn;
u32 cfg_addr; u32 cfg_addr;
u64 buid; u64 buid;
int ret; int ret;
...@@ -952,11 +953,10 @@ static int create_ddw(struct pci_dev *dev, const u32 *ddw_avail, ...@@ -952,11 +953,10 @@ static int create_ddw(struct pci_dev *dev, const u32 *ddw_avail,
* Retrieve them from the pci device, not the node with the * Retrieve them from the pci device, not the node with the
* dma-window property * dma-window property
*/ */
edev = pci_dev_to_eeh_dev(dev); dn = pci_device_to_OF_node(dev);
cfg_addr = edev->config_addr; pdn = PCI_DN(dn);
if (edev->pe_config_addr) buid = pdn->phb->buid;
cfg_addr = edev->pe_config_addr; cfg_addr = (pdn->busno << 8) | pdn->devfn;
buid = edev->phb->buid;
do { do {
/* extra outputs are LIOBN and dma-addr (hi, lo) */ /* extra outputs are LIOBN and dma-addr (hi, lo) */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment