提交 57dbbe59 编写于 作者: L Leonardo Bras 提交者: Michael Ellerman

powerpc/pseries/iommu: Rename "direct window" to "dma window"

A previous change introduced the usage of DDW as a bigger indirect DMA
mapping when the DDW available size does not map the whole partition.

As most of the code that manipulates direct mappings was reused for
indirect mappings, it's necessary to rename all names and debug/info
messages to reflect that it can be used for both kinds of mapping.

This should cause no behavioural change, just adjust naming.
Signed-off-by: NLeonardo Bras <leobras.c@gmail.com>
Reviewed-by: NFrederic Barrat <fbarrat@linux.ibm.com>
Signed-off-by: NMichael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20210817063929.38701-12-leobras.c@gmail.com
上级 381ceda8
...@@ -349,7 +349,7 @@ struct dynamic_dma_window_prop { ...@@ -349,7 +349,7 @@ struct dynamic_dma_window_prop {
__be32 window_shift; /* ilog2(tce_window_size) */ __be32 window_shift; /* ilog2(tce_window_size) */
}; };
struct direct_window { struct dma_win {
struct device_node *device; struct device_node *device;
const struct dynamic_dma_window_prop *prop; const struct dynamic_dma_window_prop *prop;
struct list_head list; struct list_head list;
...@@ -369,11 +369,11 @@ struct ddw_create_response { ...@@ -369,11 +369,11 @@ struct ddw_create_response {
u32 addr_lo; u32 addr_lo;
}; };
static LIST_HEAD(direct_window_list); static LIST_HEAD(dma_win_list);
/* prevents races between memory on/offline and window creation */ /* prevents races between memory on/offline and window creation */
static DEFINE_SPINLOCK(direct_window_list_lock); static DEFINE_SPINLOCK(dma_win_list_lock);
/* protects initializing window twice for same device */ /* protects initializing window twice for same device */
static DEFINE_MUTEX(direct_window_init_mutex); static DEFINE_MUTEX(dma_win_init_mutex);
#define DIRECT64_PROPNAME "linux,direct64-ddr-window-info" #define DIRECT64_PROPNAME "linux,direct64-ddr-window-info"
#define DMA64_PROPNAME "linux,dma64-ddr-window-info" #define DMA64_PROPNAME "linux,dma64-ddr-window-info"
...@@ -713,7 +713,10 @@ static void pci_dma_bus_setup_pSeriesLP(struct pci_bus *bus) ...@@ -713,7 +713,10 @@ static void pci_dma_bus_setup_pSeriesLP(struct pci_bus *bus)
pr_debug("pci_dma_bus_setup_pSeriesLP: setting up bus %pOF\n", pr_debug("pci_dma_bus_setup_pSeriesLP: setting up bus %pOF\n",
dn); dn);
/* Find nearest ibm,dma-window, walking up the device tree */ /*
* Find nearest ibm,dma-window (default DMA window), walking up the
* device tree
*/
for (pdn = dn; pdn != NULL; pdn = pdn->parent) { for (pdn = dn; pdn != NULL; pdn = pdn->parent) {
dma_window = of_get_property(pdn, "ibm,dma-window", NULL); dma_window = of_get_property(pdn, "ibm,dma-window", NULL);
if (dma_window != NULL) if (dma_window != NULL)
...@@ -869,37 +872,37 @@ static int remove_ddw(struct device_node *np, bool remove_prop, const char *win_ ...@@ -869,37 +872,37 @@ static int remove_ddw(struct device_node *np, bool remove_prop, const char *win_
ret = of_remove_property(np, win); ret = of_remove_property(np, win);
if (ret) if (ret)
pr_warn("%pOF: failed to remove direct window property: %d\n", pr_warn("%pOF: failed to remove DMA window property: %d\n",
np, ret); np, ret);
return 0; return 0;
} }
static bool find_existing_ddw(struct device_node *pdn, u64 *dma_addr, int *window_shift) static bool find_existing_ddw(struct device_node *pdn, u64 *dma_addr, int *window_shift)
{ {
struct direct_window *window; struct dma_win *window;
const struct dynamic_dma_window_prop *direct64; const struct dynamic_dma_window_prop *dma64;
bool found = false; bool found = false;
spin_lock(&direct_window_list_lock); spin_lock(&dma_win_list_lock);
/* check if we already created a window and dupe that config if so */ /* check if we already created a window and dupe that config if so */
list_for_each_entry(window, &direct_window_list, list) { list_for_each_entry(window, &dma_win_list, list) {
if (window->device == pdn) { if (window->device == pdn) {
direct64 = window->prop; dma64 = window->prop;
*dma_addr = be64_to_cpu(direct64->dma_base); *dma_addr = be64_to_cpu(dma64->dma_base);
*window_shift = be32_to_cpu(direct64->window_shift); *window_shift = be32_to_cpu(dma64->window_shift);
found = true; found = true;
break; break;
} }
} }
spin_unlock(&direct_window_list_lock); spin_unlock(&dma_win_list_lock);
return found; return found;
} }
static struct direct_window *ddw_list_new_entry(struct device_node *pdn, static struct dma_win *ddw_list_new_entry(struct device_node *pdn,
const struct dynamic_dma_window_prop *dma64) const struct dynamic_dma_window_prop *dma64)
{ {
struct direct_window *window; struct dma_win *window;
window = kzalloc(sizeof(*window), GFP_KERNEL); window = kzalloc(sizeof(*window), GFP_KERNEL);
if (!window) if (!window)
...@@ -915,7 +918,7 @@ static void find_existing_ddw_windows_named(const char *name) ...@@ -915,7 +918,7 @@ static void find_existing_ddw_windows_named(const char *name)
{ {
int len; int len;
struct device_node *pdn; struct device_node *pdn;
struct direct_window *window; struct dma_win *window;
const struct dynamic_dma_window_prop *dma64; const struct dynamic_dma_window_prop *dma64;
for_each_node_with_property(pdn, name) { for_each_node_with_property(pdn, name) {
...@@ -929,9 +932,9 @@ static void find_existing_ddw_windows_named(const char *name) ...@@ -929,9 +932,9 @@ static void find_existing_ddw_windows_named(const char *name)
if (!window) if (!window)
break; break;
spin_lock(&direct_window_list_lock); spin_lock(&dma_win_list_lock);
list_add(&window->list, &direct_window_list); list_add(&window->list, &dma_win_list);
spin_unlock(&direct_window_list_lock); spin_unlock(&dma_win_list_lock);
} }
} }
...@@ -1231,7 +1234,7 @@ static bool enable_ddw(struct pci_dev *dev, struct device_node *pdn) ...@@ -1231,7 +1234,7 @@ static bool enable_ddw(struct pci_dev *dev, struct device_node *pdn)
const char *win_name; const char *win_name;
struct device_node *dn; struct device_node *dn;
u32 ddw_avail[DDW_APPLICABLE_SIZE]; u32 ddw_avail[DDW_APPLICABLE_SIZE];
struct direct_window *window; struct dma_win *window;
struct property *win64; struct property *win64;
bool ddw_enabled = false; bool ddw_enabled = false;
struct failed_ddw_pdn *fpdn; struct failed_ddw_pdn *fpdn;
...@@ -1244,7 +1247,7 @@ static bool enable_ddw(struct pci_dev *dev, struct device_node *pdn) ...@@ -1244,7 +1247,7 @@ static bool enable_ddw(struct pci_dev *dev, struct device_node *pdn)
pmem_present = dn != NULL; pmem_present = dn != NULL;
of_node_put(dn); of_node_put(dn);
mutex_lock(&direct_window_init_mutex); mutex_lock(&dma_win_init_mutex);
if (find_existing_ddw(pdn, &dev->dev.archdata.dma_offset, &len)) { if (find_existing_ddw(pdn, &dev->dev.archdata.dma_offset, &len)) {
direct_mapping = (len >= max_ram_len); direct_mapping = (len >= max_ram_len);
...@@ -1324,7 +1327,7 @@ static bool enable_ddw(struct pci_dev *dev, struct device_node *pdn) ...@@ -1324,7 +1327,7 @@ static bool enable_ddw(struct pci_dev *dev, struct device_node *pdn)
page_shift = iommu_get_page_shift(query.page_size); page_shift = iommu_get_page_shift(query.page_size);
if (!page_shift) { if (!page_shift) {
dev_dbg(&dev->dev, "no supported direct page size in mask %x", dev_dbg(&dev->dev, "no supported page size in mask %x",
query.page_size); query.page_size);
goto out_failed; goto out_failed;
} }
...@@ -1384,7 +1387,7 @@ static bool enable_ddw(struct pci_dev *dev, struct device_node *pdn) ...@@ -1384,7 +1387,7 @@ static bool enable_ddw(struct pci_dev *dev, struct device_node *pdn)
ret = of_add_property(pdn, win64); ret = of_add_property(pdn, win64);
if (ret) { if (ret) {
dev_err(&dev->dev, "unable to add dma window property for %pOF: %d", dev_err(&dev->dev, "unable to add DMA window property for %pOF: %d",
pdn, ret); pdn, ret);
goto out_free_prop; goto out_free_prop;
} }
...@@ -1398,7 +1401,7 @@ static bool enable_ddw(struct pci_dev *dev, struct device_node *pdn) ...@@ -1398,7 +1401,7 @@ static bool enable_ddw(struct pci_dev *dev, struct device_node *pdn)
ret = walk_system_ram_range(0, memblock_end_of_DRAM() >> PAGE_SHIFT, ret = walk_system_ram_range(0, memblock_end_of_DRAM() >> PAGE_SHIFT,
win64->value, tce_setrange_multi_pSeriesLP_walk); win64->value, tce_setrange_multi_pSeriesLP_walk);
if (ret) { if (ret) {
dev_info(&dev->dev, "failed to map direct window for %pOF: %d\n", dev_info(&dev->dev, "failed to map DMA window for %pOF: %d\n",
dn, ret); dn, ret);
/* Make sure to clean DDW if any TCE was set*/ /* Make sure to clean DDW if any TCE was set*/
...@@ -1443,9 +1446,9 @@ static bool enable_ddw(struct pci_dev *dev, struct device_node *pdn) ...@@ -1443,9 +1446,9 @@ static bool enable_ddw(struct pci_dev *dev, struct device_node *pdn)
set_iommu_table_base(&dev->dev, newtbl); set_iommu_table_base(&dev->dev, newtbl);
} }
spin_lock(&direct_window_list_lock); spin_lock(&dma_win_list_lock);
list_add(&window->list, &direct_window_list); list_add(&window->list, &dma_win_list);
spin_unlock(&direct_window_list_lock); spin_unlock(&dma_win_list_lock);
dev->dev.archdata.dma_offset = win_addr; dev->dev.archdata.dma_offset = win_addr;
ddw_enabled = true; ddw_enabled = true;
...@@ -1477,7 +1480,7 @@ static bool enable_ddw(struct pci_dev *dev, struct device_node *pdn) ...@@ -1477,7 +1480,7 @@ static bool enable_ddw(struct pci_dev *dev, struct device_node *pdn)
list_add(&fpdn->list, &failed_ddw_pdn_list); list_add(&fpdn->list, &failed_ddw_pdn_list);
out_unlock: out_unlock:
mutex_unlock(&direct_window_init_mutex); mutex_unlock(&dma_win_init_mutex);
/* /*
* If we have persistent memory and the window size is only as big * If we have persistent memory and the window size is only as big
...@@ -1575,29 +1578,29 @@ static bool iommu_bypass_supported_pSeriesLP(struct pci_dev *pdev, u64 dma_mask) ...@@ -1575,29 +1578,29 @@ static bool iommu_bypass_supported_pSeriesLP(struct pci_dev *pdev, u64 dma_mask)
static int iommu_mem_notifier(struct notifier_block *nb, unsigned long action, static int iommu_mem_notifier(struct notifier_block *nb, unsigned long action,
void *data) void *data)
{ {
struct direct_window *window; struct dma_win *window;
struct memory_notify *arg = data; struct memory_notify *arg = data;
int ret = 0; int ret = 0;
switch (action) { switch (action) {
case MEM_GOING_ONLINE: case MEM_GOING_ONLINE:
spin_lock(&direct_window_list_lock); spin_lock(&dma_win_list_lock);
list_for_each_entry(window, &direct_window_list, list) { list_for_each_entry(window, &dma_win_list, list) {
ret |= tce_setrange_multi_pSeriesLP(arg->start_pfn, ret |= tce_setrange_multi_pSeriesLP(arg->start_pfn,
arg->nr_pages, window->prop); arg->nr_pages, window->prop);
/* XXX log error */ /* XXX log error */
} }
spin_unlock(&direct_window_list_lock); spin_unlock(&dma_win_list_lock);
break; break;
case MEM_CANCEL_ONLINE: case MEM_CANCEL_ONLINE:
case MEM_OFFLINE: case MEM_OFFLINE:
spin_lock(&direct_window_list_lock); spin_lock(&dma_win_list_lock);
list_for_each_entry(window, &direct_window_list, list) { list_for_each_entry(window, &dma_win_list, list) {
ret |= tce_clearrange_multi_pSeriesLP(arg->start_pfn, ret |= tce_clearrange_multi_pSeriesLP(arg->start_pfn,
arg->nr_pages, window->prop); arg->nr_pages, window->prop);
/* XXX log error */ /* XXX log error */
} }
spin_unlock(&direct_window_list_lock); spin_unlock(&dma_win_list_lock);
break; break;
default: default:
break; break;
...@@ -1618,7 +1621,7 @@ static int iommu_reconfig_notifier(struct notifier_block *nb, unsigned long acti ...@@ -1618,7 +1621,7 @@ static int iommu_reconfig_notifier(struct notifier_block *nb, unsigned long acti
struct of_reconfig_data *rd = data; struct of_reconfig_data *rd = data;
struct device_node *np = rd->dn; struct device_node *np = rd->dn;
struct pci_dn *pci = PCI_DN(np); struct pci_dn *pci = PCI_DN(np);
struct direct_window *window; struct dma_win *window;
switch (action) { switch (action) {
case OF_RECONFIG_DETACH_NODE: case OF_RECONFIG_DETACH_NODE:
...@@ -1636,15 +1639,15 @@ static int iommu_reconfig_notifier(struct notifier_block *nb, unsigned long acti ...@@ -1636,15 +1639,15 @@ static int iommu_reconfig_notifier(struct notifier_block *nb, unsigned long acti
iommu_pseries_free_group(pci->table_group, iommu_pseries_free_group(pci->table_group,
np->full_name); np->full_name);
spin_lock(&direct_window_list_lock); spin_lock(&dma_win_list_lock);
list_for_each_entry(window, &direct_window_list, list) { list_for_each_entry(window, &dma_win_list, list) {
if (window->device == np) { if (window->device == np) {
list_del(&window->list); list_del(&window->list);
kfree(window); kfree(window);
break; break;
} }
} }
spin_unlock(&direct_window_list_lock); spin_unlock(&dma_win_list_lock);
break; break;
default: default:
err = NOTIFY_DONE; err = NOTIFY_DONE;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册