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
170170 static unsigned int map_addrspace_size_to_wse(phys_addr_t addrspace_size)
171171 {
172172 /* Bug if not a power of 2 */
173− BUG_ON(!is_power_of_2(addrspace_size));
173+ BUG_ON((addrspace_size & (addrspace_size - 1)));
174174
175175 /* window size is 2^(WSE+1) bytes */
176− return __ffs(addrspace_size) - 1;
176+ return fls64(addrspace_size) - 2;
177177 }
178178
179179 /* 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
351351 struct paace *ppaace;
352352 unsigned long fspi;
353353
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) {
355355 pr_debug("window size too small or not a power of two %llx\n", win_size);
356356 return -EINVAL;
357357 }
@@ -464,7 +464,7 @@ int pamu_config_spaace(int liodn, u32 subwin_cnt, u32 subwin, · 106 unmodified lines
464464 return -ENOENT;
465465 }
466466
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) {
468468 pr_debug("subwindow size out of range, or not a power of 2\n");
469469 return -EINVAL;
470470 }
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
301301 * Size must be a power of two and at least be equal
302302 * to PAMU page size.
303303 */
304− if (!is_power_of_2(size) || size < PAMU_PAGE_SIZE) {
304+ if ((size & (size - 1)) || size < PAMU_PAGE_SIZE) {
305305 pr_debug("%s: size too small or not a power of two\n", __func__);
306306 return -EINVAL;
307307 }
@@ -335,11 +335,6 @@ static struct fsl_dma_domain *iommu_alloc_dma_domain(void) · 27 unmodified lines
335335 return domain;
336336 }
337337
338−static inline struct device_domain_info *find_domain(struct device *dev)
339−{
340− return dev->archdata.iommu_domain;
341−}
342−
343338 static void remove_device_ref(struct device_domain_info *info, u32 win_cnt)
344339 {
345340 unsigned long flags;
@@ -380,7 +375,7 @@ static void attach_device(struct fsl_dma_domain *dma_domain, int liodn, struct d · 34 unmodified lines
380375 * Check here if the device is already attached to domain or not.
381376 * If the device is already attached to a domain detach it.
382377 */
383− old_domain_info = find_domain(dev);
378+ old_domain_info = dev->archdata.iommu_domain;
384379 if (old_domain_info && old_domain_info->domain != dma_domain) {
385380 spin_unlock_irqrestore(&device_domain_lock, flags);
386381 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
399394 * the info for the first LIODN as all
400395 * LIODNs share the same domain
401396 */
402− if (!old_domain_info)
397+ if (!dev->archdata.iommu_domain)
403398 dev->archdata.iommu_domain = info;
404399 spin_unlock_irqrestore(&device_domain_lock, flags);
405400
@@ -1042,12 +1037,15 @@ root_bus: · 636 unmodified lines
10421037 group = get_shared_pci_device_group(pdev);
10431038 }
10441039
1040+ if (!group)
1041+ group = ERR_PTR(-ENODEV);
1042+
10451043 return group;
10461044 }
10471045
10481046 static int fsl_pamu_add_device(struct device *dev)
10491047 {
1050− struct iommu_group *group = NULL;
1048+ struct iommu_group *group = ERR_PTR(-ENODEV);
10511049 struct pci_dev *pdev;
10521050 const u32 *prop;
10531051 int ret, len;
@@ -1070,7 +1068,7 @@ static int fsl_pamu_add_device(struct device *dev) · 16 unmodified lines
10701068 group = get_device_iommu_group(dev);
10711069 }
10721070
1073− if (!group || IS_ERR(group))
1071+ if (IS_ERR(group))
10741072 return PTR_ERR(group);
10751073
10761074 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