Commit cac3e629 authored by Leonardo Bras's avatar Leonardo Bras Committed by Michael Ellerman

powerpc/pseries/iommu: Create defines for operations in ibm, ddw-applicable

Create defines to help handling ibm,ddw-applicable values, avoiding
confusion about the index of given operations.
Signed-off-by: default avatarLeonardo Bras <leobras.c@gmail.com>
Tested-by: default avatarDavid Dai <zdai@linux.vnet.ibm.com>
Reviewed-by: default avatarAlexey Kardashevskiy <aik@ozlabs.ru>
Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20200805030455.123024-2-leobras.c@gmail.com
parent 51a15881
...@@ -39,6 +39,14 @@ ...@@ -39,6 +39,14 @@
#include "pseries.h" #include "pseries.h"
enum {
DDW_QUERY_PE_DMA_WIN = 0,
DDW_CREATE_PE_DMA_WIN = 1,
DDW_REMOVE_PE_DMA_WIN = 2,
DDW_APPLICABLE_SIZE
};
static struct iommu_table_group *iommu_pseries_alloc_group(int node) static struct iommu_table_group *iommu_pseries_alloc_group(int node)
{ {
struct iommu_table_group *table_group; struct iommu_table_group *table_group;
...@@ -771,12 +779,12 @@ static void remove_ddw(struct device_node *np, bool remove_prop) ...@@ -771,12 +779,12 @@ static void remove_ddw(struct device_node *np, bool remove_prop)
{ {
struct dynamic_dma_window_prop *dwp; struct dynamic_dma_window_prop *dwp;
struct property *win64; struct property *win64;
u32 ddw_avail[3]; u32 ddw_avail[DDW_APPLICABLE_SIZE];
u64 liobn; u64 liobn;
int ret = 0; int ret = 0;
ret = of_property_read_u32_array(np, "ibm,ddw-applicable", ret = of_property_read_u32_array(np, "ibm,ddw-applicable",
&ddw_avail[0], 3); &ddw_avail[0], DDW_APPLICABLE_SIZE);
win64 = of_find_property(np, DIRECT64_PROPNAME, NULL); win64 = of_find_property(np, DIRECT64_PROPNAME, NULL);
if (!win64) if (!win64)
...@@ -798,15 +806,15 @@ static void remove_ddw(struct device_node *np, bool remove_prop) ...@@ -798,15 +806,15 @@ static void remove_ddw(struct device_node *np, bool remove_prop)
pr_debug("%pOF successfully cleared tces in window.\n", pr_debug("%pOF successfully cleared tces in window.\n",
np); np);
ret = rtas_call(ddw_avail[2], 1, 1, NULL, liobn); ret = rtas_call(ddw_avail[DDW_REMOVE_PE_DMA_WIN], 1, 1, NULL, liobn);
if (ret) if (ret)
pr_warn("%pOF: failed to remove direct window: rtas returned " pr_warn("%pOF: failed to remove direct window: rtas returned "
"%d to ibm,remove-pe-dma-window(%x) %llx\n", "%d to ibm,remove-pe-dma-window(%x) %llx\n",
np, ret, ddw_avail[2], liobn); np, ret, ddw_avail[DDW_REMOVE_PE_DMA_WIN], liobn);
else else
pr_debug("%pOF: successfully removed direct window: rtas returned " pr_debug("%pOF: successfully removed direct window: rtas returned "
"%d to ibm,remove-pe-dma-window(%x) %llx\n", "%d to ibm,remove-pe-dma-window(%x) %llx\n",
np, ret, ddw_avail[2], liobn); np, ret, ddw_avail[DDW_REMOVE_PE_DMA_WIN], liobn);
delprop: delprop:
if (remove_prop) if (remove_prop)
...@@ -889,11 +897,11 @@ static int query_ddw(struct pci_dev *dev, const u32 *ddw_avail, ...@@ -889,11 +897,11 @@ static int query_ddw(struct pci_dev *dev, const u32 *ddw_avail,
buid = pdn->phb->buid; buid = pdn->phb->buid;
cfg_addr = ((pdn->busno << 16) | (pdn->devfn << 8)); cfg_addr = ((pdn->busno << 16) | (pdn->devfn << 8));
ret = rtas_call(ddw_avail[0], 3, 5, (u32 *)query, ret = rtas_call(ddw_avail[DDW_QUERY_PE_DMA_WIN], 3, 5, (u32 *)query,
cfg_addr, BUID_HI(buid), BUID_LO(buid)); cfg_addr, BUID_HI(buid), BUID_LO(buid));
dev_info(&dev->dev, "ibm,query-pe-dma-windows(%x) %x %x %x" dev_info(&dev->dev, "ibm,query-pe-dma-windows(%x) %x %x %x"
" returned %d\n", ddw_avail[0], cfg_addr, BUID_HI(buid), " returned %d\n", ddw_avail[DDW_QUERY_PE_DMA_WIN], cfg_addr,
BUID_LO(buid), ret); BUID_HI(buid), BUID_LO(buid), ret);
return ret; return ret;
} }
...@@ -920,15 +928,16 @@ static int create_ddw(struct pci_dev *dev, const u32 *ddw_avail, ...@@ -920,15 +928,16 @@ static int create_ddw(struct pci_dev *dev, const u32 *ddw_avail,
do { do {
/* extra outputs are LIOBN and dma-addr (hi, lo) */ /* extra outputs are LIOBN and dma-addr (hi, lo) */
ret = rtas_call(ddw_avail[1], 5, 4, (u32 *)create, ret = rtas_call(ddw_avail[DDW_CREATE_PE_DMA_WIN], 5, 4,
cfg_addr, BUID_HI(buid), BUID_LO(buid), (u32 *)create, cfg_addr, BUID_HI(buid),
page_shift, window_shift); BUID_LO(buid), page_shift, window_shift);
} while (rtas_busy_delay(ret)); } while (rtas_busy_delay(ret));
dev_info(&dev->dev, dev_info(&dev->dev,
"ibm,create-pe-dma-window(%x) %x %x %x %x %x returned %d " "ibm,create-pe-dma-window(%x) %x %x %x %x %x returned %d "
"(liobn = 0x%x starting addr = %x %x)\n", ddw_avail[1], "(liobn = 0x%x starting addr = %x %x)\n",
cfg_addr, BUID_HI(buid), BUID_LO(buid), page_shift, ddw_avail[DDW_CREATE_PE_DMA_WIN], cfg_addr, BUID_HI(buid),
window_shift, ret, create->liobn, create->addr_hi, create->addr_lo); BUID_LO(buid), page_shift, window_shift, ret, create->liobn,
create->addr_hi, create->addr_lo);
return ret; return ret;
} }
...@@ -996,7 +1005,7 @@ static u64 enable_ddw(struct pci_dev *dev, struct device_node *pdn) ...@@ -996,7 +1005,7 @@ static u64 enable_ddw(struct pci_dev *dev, struct device_node *pdn)
int page_shift; int page_shift;
u64 dma_addr, max_addr; u64 dma_addr, max_addr;
struct device_node *dn; struct device_node *dn;
u32 ddw_avail[3]; u32 ddw_avail[DDW_APPLICABLE_SIZE];
struct direct_window *window; struct direct_window *window;
struct property *win64; struct property *win64;
struct dynamic_dma_window_prop *ddwprop; struct dynamic_dma_window_prop *ddwprop;
...@@ -1029,7 +1038,7 @@ static u64 enable_ddw(struct pci_dev *dev, struct device_node *pdn) ...@@ -1029,7 +1038,7 @@ static u64 enable_ddw(struct pci_dev *dev, struct device_node *pdn)
* the property is actually in the parent, not the PE * the property is actually in the parent, not the PE
*/ */
ret = of_property_read_u32_array(pdn, "ibm,ddw-applicable", ret = of_property_read_u32_array(pdn, "ibm,ddw-applicable",
&ddw_avail[0], 3); &ddw_avail[0], DDW_APPLICABLE_SIZE);
if (ret) if (ret)
goto out_failed; goto out_failed;
......
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