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 'dma-mapping-6.0-2022-09-10' of git://git.infradead.org/users/hch/dma-mapping

Pull dma-mapping fixes from Christoph Hellwig:

- revert a panic on swiotlb initialization failure (Yu Zhao)

- fix the lookup for partial syncs in dma-debug (Robin Murphy)

- fix a shift overflow in swiotlb (Chao Gao)

- fix a comment typo in swiotlb (Chao Gao)

- mark a function static now that all abusers are gone (Christoph
Hellwig)

* tag 'dma-mapping-6.0-2022-09-10' of git://git.infradead.org/users/hch/dma-mapping:
dma-mapping: mark dma_supported static
swiotlb: fix a typo
swiotlb: avoid potential left shift overflow
dma-debug: improve search for partial syncs
Revert "swiotlb: panic if nslabs is too small"

+9 -18
-5
include/linux/dma-mapping.h
··· 139 139 void *cpu_addr, dma_addr_t dma_addr, size_t size, 140 140 unsigned long attrs); 141 141 bool dma_can_mmap(struct device *dev); 142 - int dma_supported(struct device *dev, u64 mask); 143 142 bool dma_pci_p2pdma_supported(struct device *dev); 144 143 int dma_set_mask(struct device *dev, u64 mask); 145 144 int dma_set_coherent_mask(struct device *dev, u64 mask); ··· 246 247 static inline bool dma_can_mmap(struct device *dev) 247 248 { 248 249 return false; 249 - } 250 - static inline int dma_supported(struct device *dev, u64 mask) 251 - { 252 - return 0; 253 250 } 254 251 static inline bool dma_pci_p2pdma_supported(struct device *dev) 255 252 {
+2 -4
kernel/dma/debug.c
··· 350 350 unsigned long *flags) 351 351 { 352 352 353 - unsigned int max_range = dma_get_max_seg_size(ref->dev); 354 353 struct dma_debug_entry *entry, index = *ref; 355 - unsigned int range = 0; 354 + int limit = min(HASH_SIZE, (index.dev_addr >> HASH_FN_SHIFT) + 1); 356 355 357 - while (range <= max_range) { 356 + for (int i = 0; i < limit; i++) { 358 357 entry = __hash_bucket_find(*bucket, ref, containing_match); 359 358 360 359 if (entry) ··· 363 364 * Nothing found, go back a hash bucket 364 365 */ 365 366 put_hash_bucket(*bucket, *flags); 366 - range += (1 << HASH_FN_SHIFT); 367 367 index.dev_addr -= (1 << HASH_FN_SHIFT); 368 368 *bucket = get_hash_bucket(&index, flags); 369 369 }
+1 -2
kernel/dma/mapping.c
··· 707 707 } 708 708 EXPORT_SYMBOL_GPL(dma_mmap_noncontiguous); 709 709 710 - int dma_supported(struct device *dev, u64 mask) 710 + static int dma_supported(struct device *dev, u64 mask) 711 711 { 712 712 const struct dma_map_ops *ops = get_dma_ops(dev); 713 713 ··· 721 721 return 1; 722 722 return ops->dma_supported(dev, mask); 723 723 } 724 - EXPORT_SYMBOL(dma_supported); 725 724 726 725 bool dma_pci_p2pdma_supported(struct device *dev) 727 726 {
+6 -7
kernel/dma/swiotlb.c
··· 326 326 swiotlb_adjust_nareas(num_possible_cpus()); 327 327 328 328 nslabs = default_nslabs; 329 - if (nslabs < IO_TLB_MIN_SLABS) 330 - panic("%s: nslabs = %lu too small\n", __func__, nslabs); 331 - 332 329 /* 333 330 * By default allocate the bounce buffer memory from low memory, but 334 331 * allow to pick a location everywhere for hypervisors with guest ··· 338 341 else 339 342 tlb = memblock_alloc_low(bytes, PAGE_SIZE); 340 343 if (!tlb) { 341 - pr_warn("%s: Failed to allocate %zu bytes tlb structure\n", 342 - __func__, bytes); 344 + pr_warn("%s: failed to allocate tlb structure\n", __func__); 343 345 return; 344 346 } 345 347 ··· 575 579 } 576 580 } 577 581 578 - #define slot_addr(start, idx) ((start) + ((idx) << IO_TLB_SHIFT)) 582 + static inline phys_addr_t slot_addr(phys_addr_t start, phys_addr_t idx) 583 + { 584 + return start + (idx << IO_TLB_SHIFT); 585 + } 579 586 580 587 /* 581 588 * Carefully handle integer overflow which can occur when boundary_mask == ~0UL. ··· 764 765 /* 765 766 * When dir == DMA_FROM_DEVICE we could omit the copy from the orig 766 767 * to the tlb buffer, if we knew for sure the device will 767 - * overwirte the entire current content. But we don't. Thus 768 + * overwrite the entire current content. But we don't. Thus 768 769 * unconditional bounce may prevent leaking swiotlb content (i.e. 769 770 * kernel memory) to user-space. 770 771 */