History

Merge tag 'iommu-fixes-v3.16-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/joro/iommu

Pull iommu fixes from Joerg Roedel: "A couple of fixes for the Freescale PAMU driver queued up: - fix PAMU window size check. - fix the device domain attach condition. - fix the error condition during iommu group" * tag 'iommu-fixes-v3.16-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/joro/iommu: iommu/fsl: Fix the error condition during iommu group iommu/fsl: Fix the device domain attach condition. iommu/fsl: Fix PAMU window size check.

Linus Torvalds committed 12 years ago

Commit 0bae49b2 parents 084c9ca 31704472 files · +12 −14Browse files

Unified · Split

2 files
  1. drivers/iommu/fsl_pamu.c +4 −4
  2. drivers/iommu/fsl_pamu_domain.c +8 −10
drivers/iommu/fsl_pamu.c+4−4
@@ -170,10 +170,10 @@ int pamu_disable_liodn(int liodn) · 169 unmodified lines
170static unsigned int map_addrspace_size_to_wse(phys_addr_t addrspace_size)170static unsigned int map_addrspace_size_to_wse(phys_addr_t addrspace_size)
171{171{
172 /* Bug if not a power of 2 */172 /* Bug if not a power of 2 */
173 BUG_ON(!is_power_of_2(addrspace_size));173 BUG_ON((addrspace_size & (addrspace_size - 1)));
174 174
175 /* window size is 2^(WSE+1) bytes */175 /* window size is 2^(WSE+1) bytes */
176 return __ffs(addrspace_size) - 1;176 return fls64(addrspace_size) - 2;
177}177}
178 178
179/* Derive the PAACE window count encoding for the subwindow count */179/* Derive the PAACE window count encoding for the subwindow count */
@@ -351,7 +351,7 @@ int pamu_config_ppaace(int liodn, phys_addr_t win_addr, phys_addr_t win_size, · 171 unmodified lines
351 struct paace *ppaace;351 struct paace *ppaace;
352 unsigned long fspi;352 unsigned long fspi;
353 353
354 if (!is_power_of_2(win_size) || win_size < PAMU_PAGE_SIZE) {354 if ((win_size & (win_size - 1)) || win_size < PAMU_PAGE_SIZE) {
355 pr_debug("window size too small or not a power of two %llx\n", win_size);355 pr_debug("window size too small or not a power of two %llx\n", win_size);
356 return -EINVAL;356 return -EINVAL;
357 }357 }
@@ -464,7 +464,7 @@ int pamu_config_spaace(int liodn, u32 subwin_cnt, u32 subwin, · 106 unmodified lines
464 return -ENOENT;464 return -ENOENT;
465 }465 }
466 466
467 if (!is_power_of_2(subwin_size) || subwin_size < PAMU_PAGE_SIZE) {467 if ((subwin_size & (subwin_size - 1)) || subwin_size < PAMU_PAGE_SIZE) {
468 pr_debug("subwindow size out of range, or not a power of 2\n");468 pr_debug("subwindow size out of range, or not a power of 2\n");
469 return -EINVAL;469 return -EINVAL;
470 }470 }
drivers/iommu/fsl_pamu_domain.c+8−10
@@ -301,7 +301,7 @@ static int check_size(u64 size, dma_addr_t iova) · 300 unmodified lines
301 * Size must be a power of two and at least be equal301 * Size must be a power of two and at least be equal
302 * to PAMU page size.302 * to PAMU page size.
303 */303 */
304 if (!is_power_of_2(size) || size < PAMU_PAGE_SIZE) {304 if ((size & (size - 1)) || size < PAMU_PAGE_SIZE) {
305 pr_debug("%s: size too small or not a power of two\n", __func__);305 pr_debug("%s: size too small or not a power of two\n", __func__);
306 return -EINVAL;306 return -EINVAL;
307 }307 }
@@ -335,11 +335,6 @@ static struct fsl_dma_domain *iommu_alloc_dma_domain(void) · 27 unmodified lines
335 return domain;335 return domain;
336}336}
337 337
338static inline struct device_domain_info *find_domain(struct device *dev)
339{
340 return dev->archdata.iommu_domain;
341}
342
343static void remove_device_ref(struct device_domain_info *info, u32 win_cnt)338static void remove_device_ref(struct device_domain_info *info, u32 win_cnt)
344{339{
345 unsigned long flags;340 unsigned long flags;
@@ -380,7 +375,7 @@ static void attach_device(struct fsl_dma_domain *dma_domain, int liodn, struct d · 34 unmodified lines
380 * Check here if the device is already attached to domain or not.375 * Check here if the device is already attached to domain or not.
381 * If the device is already attached to a domain detach it.376 * If the device is already attached to a domain detach it.
382 */377 */
383 old_domain_info = find_domain(dev);378 old_domain_info = dev->archdata.iommu_domain;
384 if (old_domain_info && old_domain_info->domain != dma_domain) {379 if (old_domain_info && old_domain_info->domain != dma_domain) {
385 spin_unlock_irqrestore(&device_domain_lock, flags);380 spin_unlock_irqrestore(&device_domain_lock, flags);
386 detach_device(dev, old_domain_info->domain);381 detach_device(dev, old_domain_info->domain);
@@ -399,7 +394,7 @@ static void attach_device(struct fsl_dma_domain *dma_domain, int liodn, struct d · 12 unmodified lines
399 * the info for the first LIODN as all394 * the info for the first LIODN as all
400 * LIODNs share the same domain395 * LIODNs share the same domain
401 */396 */
402 if (!old_domain_info)397 if (!dev->archdata.iommu_domain)
403 dev->archdata.iommu_domain = info;398 dev->archdata.iommu_domain = info;
404 spin_unlock_irqrestore(&device_domain_lock, flags);399 spin_unlock_irqrestore(&device_domain_lock, flags);
405 400
@@ -1042,12 +1037,15 @@ root_bus: · 636 unmodified lines
1042 group = get_shared_pci_device_group(pdev);1037 group = get_shared_pci_device_group(pdev);
1043 }1038 }
1044 1039
1040 if (!group)
1041 group = ERR_PTR(-ENODEV);
1042
1045 return group;1043 return group;
1046}1044}
1047 1045
1048static int fsl_pamu_add_device(struct device *dev)1046static int fsl_pamu_add_device(struct device *dev)
1049{1047{
1050 struct iommu_group *group = NULL;1048 struct iommu_group *group = ERR_PTR(-ENODEV);
1051 struct pci_dev *pdev;1049 struct pci_dev *pdev;
1052 const u32 *prop;1050 const u32 *prop;
1053 int ret, len;1051 int ret, len;
@@ -1070,7 +1068,7 @@ static int fsl_pamu_add_device(struct device *dev) · 16 unmodified lines
1070 group = get_device_iommu_group(dev);1068 group = get_device_iommu_group(dev);
1071 }1069 }
1072 1070
1073 if (!group || IS_ERR(group))1071 if (IS_ERR(group))
1074 return PTR_ERR(group);1072 return PTR_ERR(group);
1075 1073
1076 ret = iommu_group_add_device(group, dev);1074 ret = iommu_group_add_device(group, dev);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t