Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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.

+12 -14
+4 -4
drivers/iommu/fsl_pamu.c
··· 170 170 static unsigned int map_addrspace_size_to_wse(phys_addr_t addrspace_size) 171 171 { 172 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 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 179 /* Derive the PAACE window count encoding for the subwindow count */ ··· 351 351 struct paace *ppaace; 352 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 355 pr_debug("window size too small or not a power of two %llx\n", win_size); 356 356 return -EINVAL; 357 357 } ··· 464 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 468 pr_debug("subwindow size out of range, or not a power of 2\n"); 469 469 return -EINVAL; 470 470 }
+8 -10
drivers/iommu/fsl_pamu_domain.c
··· 301 301 * Size must be a power of two and at least be equal 302 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 305 pr_debug("%s: size too small or not a power of two\n", __func__); 306 306 return -EINVAL; 307 307 } ··· 333 333 spin_lock_init(&domain->domain_lock); 334 334 335 335 return domain; 336 - } 337 - 338 - static inline struct device_domain_info *find_domain(struct device *dev) 339 - { 340 - return dev->archdata.iommu_domain; 341 336 } 342 337 343 338 static void remove_device_ref(struct device_domain_info *info, u32 win_cnt) ··· 375 380 * Check here if the device is already attached to domain or not. 376 381 * If the device is already attached to a domain detach it. 377 382 */ 378 - old_domain_info = find_domain(dev); 383 + old_domain_info = dev->archdata.iommu_domain; 379 384 if (old_domain_info && old_domain_info->domain != dma_domain) { 380 385 spin_unlock_irqrestore(&device_domain_lock, flags); 381 386 detach_device(dev, old_domain_info->domain); ··· 394 399 * the info for the first LIODN as all 395 400 * LIODNs share the same domain 396 401 */ 397 - if (!old_domain_info) 402 + if (!dev->archdata.iommu_domain) 398 403 dev->archdata.iommu_domain = info; 399 404 spin_unlock_irqrestore(&device_domain_lock, flags); 400 405 ··· 1037 1042 group = get_shared_pci_device_group(pdev); 1038 1043 } 1039 1044 1045 + if (!group) 1046 + group = ERR_PTR(-ENODEV); 1047 + 1040 1048 return group; 1041 1049 } 1042 1050 1043 1051 static int fsl_pamu_add_device(struct device *dev) 1044 1052 { 1045 - struct iommu_group *group = NULL; 1053 + struct iommu_group *group = ERR_PTR(-ENODEV); 1046 1054 struct pci_dev *pdev; 1047 1055 const u32 *prop; 1048 1056 int ret, len; ··· 1068 1070 group = get_device_iommu_group(dev); 1069 1071 } 1070 1072 1071 - if (!group || IS_ERR(group)) 1073 + if (IS_ERR(group)) 1072 1074 return PTR_ERR(group); 1073 1075 1074 1076 ret = iommu_group_add_device(group, dev);