CC: [email protected]
In-Reply-To: <[email protected]>
References: <[email protected]>
TO: Dongli Zhang <[email protected]>

Hi Dongli,

[FYI, it's a private test report for your RFC patch.]
[auto build test WARNING on powerpc/next]
[also build test WARNING on linus/master v5.11-rc6 next-20210125]
[cannot apply to swiotlb/linux-next xen-tip/linux-next]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    
https://github.com/0day-ci/linux/commits/Dongli-Zhang/swiotlb-64-bit-DMA-buffer/20210204-074426
base:   https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git next
:::::: branch date: 2 hours ago
:::::: commit date: 2 hours ago
config: i386-randconfig-m021-20210202 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-15) 9.3.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <[email protected]>
Reported-by: Dan Carpenter <[email protected]>

smatch warnings:
kernel/dma/swiotlb.c:524 swiotlb_tbl_map_single() warn: impossible condition 
'(dma_mask == ((((64) == 64)) ?~0:((1 << (64)) - 1))) => (0-u32max == u64max)'

vim +524 kernel/dma/swiotlb.c

1b548f667c1487 lib/swiotlb.c           Jeremy Fitzhardinge   2008-12-16  506  
fc0021aa340af6 kernel/dma/swiotlb.c    Christoph Hellwig     2020-10-23  507  
phys_addr_t swiotlb_tbl_map_single(struct device *hwdev, phys_addr_t orig_addr,
fc0021aa340af6 kernel/dma/swiotlb.c    Christoph Hellwig     2020-10-23  508    
        size_t mapping_size, size_t alloc_size,
fc0021aa340af6 kernel/dma/swiotlb.c    Christoph Hellwig     2020-10-23  509    
        enum dma_data_direction dir, unsigned long attrs)
^1da177e4c3f41 arch/ia64/lib/swiotlb.c Linus Torvalds        2005-04-16  510  {
bb094f75bbb66b kernel/dma/swiotlb.c    Dongli Zhang          2021-02-03  511    
dma_addr_t tbl_dma_addr;
^1da177e4c3f41 arch/ia64/lib/swiotlb.c Linus Torvalds        2005-04-16  512    
unsigned long flags;
e05ed4d1fad9e7 lib/swiotlb.c           Alexander Duyck       2012-10-15  513    
phys_addr_t tlb_addr;
^1da177e4c3f41 arch/ia64/lib/swiotlb.c Linus Torvalds        2005-04-16  514    
unsigned int nslots, stride, index, wrap;
^1da177e4c3f41 arch/ia64/lib/swiotlb.c Linus Torvalds        2005-04-16  515    
int i;
681cc5cd3efbea lib/swiotlb.c           FUJITA Tomonori       2008-02-04  516    
unsigned long mask;
681cc5cd3efbea lib/swiotlb.c           FUJITA Tomonori       2008-02-04  517    
unsigned long offset_slots;
681cc5cd3efbea lib/swiotlb.c           FUJITA Tomonori       2008-02-04  518    
unsigned long max_slots;
53b29c336830db kernel/dma/swiotlb.c    Dongli Zhang          2019-04-12  519    
unsigned long tmp_io_tlb_used;
bb094f75bbb66b kernel/dma/swiotlb.c    Dongli Zhang          2021-02-03  520    
unsigned long dma_mask = min_not_zero(*hwdev->dma_mask,
bb094f75bbb66b kernel/dma/swiotlb.c    Dongli Zhang          2021-02-03  521    
                                      hwdev->bus_dma_limit);
bb094f75bbb66b kernel/dma/swiotlb.c    Dongli Zhang          2021-02-03  522    
int type;
bb094f75bbb66b kernel/dma/swiotlb.c    Dongli Zhang          2021-02-03  523  
bb094f75bbb66b kernel/dma/swiotlb.c    Dongli Zhang          2021-02-03 @524    
if (swiotlb_nr > 1 && dma_mask == DMA_BIT_MASK(64))
bb094f75bbb66b kernel/dma/swiotlb.c    Dongli Zhang          2021-02-03  525    
        type = SWIOTLB_HI;
bb094f75bbb66b kernel/dma/swiotlb.c    Dongli Zhang          2021-02-03  526    
else
bb094f75bbb66b kernel/dma/swiotlb.c    Dongli Zhang          2021-02-03  527    
        type = SWIOTLB_LO;
681cc5cd3efbea lib/swiotlb.c           FUJITA Tomonori       2008-02-04  528  
bb094f75bbb66b kernel/dma/swiotlb.c    Dongli Zhang          2021-02-03  529    
if (no_iotlb_memory[type])
ac2cbab21f318e lib/swiotlb.c           Yinghai Lu            2013-01-24  530    
        panic("Can not allocate SWIOTLB buffer earlier and can't now provide 
you with the DMA bounce buffer");
ac2cbab21f318e lib/swiotlb.c           Yinghai Lu            2013-01-24  531  
d7b417fa08d118 lib/swiotlb.c           Tom Lendacky          2017-10-20  532    
if (mem_encrypt_active())
47e5d8f9ed34a5 kernel/dma/swiotlb.c    Thiago Jung Bauermann 2019-08-06  533    
        pr_warn_once("Memory encryption is active and system is using DMA 
bounce buffers\n");
648babb7078c63 lib/swiotlb.c           Tom Lendacky          2017-07-17  534  
3fc1ca00653db6 kernel/dma/swiotlb.c    Lu Baolu              2019-09-06  535    
if (mapping_size > alloc_size) {
3fc1ca00653db6 kernel/dma/swiotlb.c    Lu Baolu              2019-09-06  536    
        dev_warn_once(hwdev, "Invalid sizes (mapping: %zd bytes, alloc: %zd 
bytes)",
3fc1ca00653db6 kernel/dma/swiotlb.c    Lu Baolu              2019-09-06  537    
                      mapping_size, alloc_size);
3fc1ca00653db6 kernel/dma/swiotlb.c    Lu Baolu              2019-09-06  538    
        return (phys_addr_t)DMA_MAPPING_ERROR;
3fc1ca00653db6 kernel/dma/swiotlb.c    Lu Baolu              2019-09-06  539    
}
3fc1ca00653db6 kernel/dma/swiotlb.c    Lu Baolu              2019-09-06  540  
bb094f75bbb66b kernel/dma/swiotlb.c    Dongli Zhang          2021-02-03  541    
tbl_dma_addr = phys_to_dma_unencrypted(hwdev, io_tlb_start[type]);
bb094f75bbb66b kernel/dma/swiotlb.c    Dongli Zhang          2021-02-03  542  
681cc5cd3efbea lib/swiotlb.c           FUJITA Tomonori       2008-02-04  543    
mask = dma_get_seg_boundary(hwdev);
681cc5cd3efbea lib/swiotlb.c           FUJITA Tomonori       2008-02-04  544  
eb605a5754d050 lib/swiotlb.c           FUJITA Tomonori       2010-05-10  545    
tbl_dma_addr &= mask;
eb605a5754d050 lib/swiotlb.c           FUJITA Tomonori       2010-05-10  546  
eb605a5754d050 lib/swiotlb.c           FUJITA Tomonori       2010-05-10  547    
offset_slots = ALIGN(tbl_dma_addr, 1 << IO_TLB_SHIFT) >> IO_TLB_SHIFT;
a5ddde4a558b3b lib/swiotlb.c           Ian Campbell          2008-12-16  548  
a5ddde4a558b3b lib/swiotlb.c           Ian Campbell          2008-12-16  549    
/*
a5ddde4a558b3b lib/swiotlb.c           Ian Campbell          2008-12-16  550    
 * Carefully handle integer overflow which can occur when mask == ~0UL.
a5ddde4a558b3b lib/swiotlb.c           Ian Campbell          2008-12-16  551    
 */
b15a3891c916f3 lib/swiotlb.c           Jan Beulich           2008-03-13  552    
max_slots = mask + 1
b15a3891c916f3 lib/swiotlb.c           Jan Beulich           2008-03-13  553    
            ? ALIGN(mask + 1, 1 << IO_TLB_SHIFT) >> IO_TLB_SHIFT
b15a3891c916f3 lib/swiotlb.c           Jan Beulich           2008-03-13  554    
            : 1UL << (BITS_PER_LONG - IO_TLB_SHIFT);
^1da177e4c3f41 arch/ia64/lib/swiotlb.c Linus Torvalds        2005-04-16  555  
^1da177e4c3f41 arch/ia64/lib/swiotlb.c Linus Torvalds        2005-04-16  556    
/*
602d9858f07c72 lib/swiotlb.c           Nikita Yushchenko     2017-01-11  557    
 * For mappings greater than or equal to a page, we limit the stride
602d9858f07c72 lib/swiotlb.c           Nikita Yushchenko     2017-01-11  558    
 * (and hence alignment) to a page size.
^1da177e4c3f41 arch/ia64/lib/swiotlb.c Linus Torvalds        2005-04-16  559    
 */
3fc1ca00653db6 kernel/dma/swiotlb.c    Lu Baolu              2019-09-06  560    
nslots = ALIGN(alloc_size, 1 << IO_TLB_SHIFT) >> IO_TLB_SHIFT;
3fc1ca00653db6 kernel/dma/swiotlb.c    Lu Baolu              2019-09-06  561    
if (alloc_size >= PAGE_SIZE)
^1da177e4c3f41 arch/ia64/lib/swiotlb.c Linus Torvalds        2005-04-16  562    
        stride = (1 << (PAGE_SHIFT - IO_TLB_SHIFT));
^1da177e4c3f41 arch/ia64/lib/swiotlb.c Linus Torvalds        2005-04-16  563    
else
^1da177e4c3f41 arch/ia64/lib/swiotlb.c Linus Torvalds        2005-04-16  564    
        stride = 1;
^1da177e4c3f41 arch/ia64/lib/swiotlb.c Linus Torvalds        2005-04-16  565  
34814545890db6 lib/swiotlb.c           Eric Sesterhenn       2006-03-24  566    
BUG_ON(!nslots);
^1da177e4c3f41 arch/ia64/lib/swiotlb.c Linus Torvalds        2005-04-16  567  
^1da177e4c3f41 arch/ia64/lib/swiotlb.c Linus Torvalds        2005-04-16  568    
/*
^1da177e4c3f41 arch/ia64/lib/swiotlb.c Linus Torvalds        2005-04-16  569    
 * Find suitable number of IO TLB entries size that will fit this
^1da177e4c3f41 arch/ia64/lib/swiotlb.c Linus Torvalds        2005-04-16  570    
 * request and allocate a buffer from that IO TLB pool.
^1da177e4c3f41 arch/ia64/lib/swiotlb.c Linus Torvalds        2005-04-16  571    
 */
^1da177e4c3f41 arch/ia64/lib/swiotlb.c Linus Torvalds        2005-04-16  572    
spin_lock_irqsave(&io_tlb_lock, flags);
60513ed06a4104 kernel/dma/swiotlb.c    Dongli Zhang          2019-01-18  573  
bb094f75bbb66b kernel/dma/swiotlb.c    Dongli Zhang          2021-02-03  574    
if (unlikely(nslots > io_tlb_nslabs[type] - io_tlb_used[type]))
60513ed06a4104 kernel/dma/swiotlb.c    Dongli Zhang          2019-01-18  575    
        goto not_found;
60513ed06a4104 kernel/dma/swiotlb.c    Dongli Zhang          2019-01-18  576  
bb094f75bbb66b kernel/dma/swiotlb.c    Dongli Zhang          2021-02-03  577    
index = ALIGN(io_tlb_index[type], stride);
bb094f75bbb66b kernel/dma/swiotlb.c    Dongli Zhang          2021-02-03  578    
if (index >= io_tlb_nslabs[type])
681cc5cd3efbea lib/swiotlb.c           FUJITA Tomonori       2008-02-04  579    
        index = 0;
b15a3891c916f3 lib/swiotlb.c           Jan Beulich           2008-03-13  580    
wrap = index;
^1da177e4c3f41 arch/ia64/lib/swiotlb.c Linus Torvalds        2005-04-16  581  
b15a3891c916f3 lib/swiotlb.c           Jan Beulich           2008-03-13  582    
do {
a8522509200b46 lib/swiotlb.c           FUJITA Tomonori       2008-04-29  583    
        while (iommu_is_span_boundary(index, nslots, offset_slots,
681cc5cd3efbea lib/swiotlb.c           FUJITA Tomonori       2008-02-04  584    
                                      max_slots)) {
681cc5cd3efbea lib/swiotlb.c           FUJITA Tomonori       2008-02-04  585    
                index += stride;
bb094f75bbb66b kernel/dma/swiotlb.c    Dongli Zhang          2021-02-03  586    
                if (index >= io_tlb_nslabs[type])
681cc5cd3efbea lib/swiotlb.c           FUJITA Tomonori       2008-02-04  587    
                        index = 0;
b15a3891c916f3 lib/swiotlb.c           Jan Beulich           2008-03-13  588    
                if (index == wrap)
b15a3891c916f3 lib/swiotlb.c           Jan Beulich           2008-03-13  589    
                        goto not_found;
681cc5cd3efbea lib/swiotlb.c           FUJITA Tomonori       2008-02-04  590    
        }
^1da177e4c3f41 arch/ia64/lib/swiotlb.c Linus Torvalds        2005-04-16  591  
^1da177e4c3f41 arch/ia64/lib/swiotlb.c Linus Torvalds        2005-04-16  592    
        /*
a7133a15587b89 lib/swiotlb.c           Andrew Morton         2008-04-29  593    
         * If we find a slot that indicates we have 'nslots' number of
a7133a15587b89 lib/swiotlb.c           Andrew Morton         2008-04-29  594    
         * contiguous buffers, we allocate the buffers from that slot
a7133a15587b89 lib/swiotlb.c           Andrew Morton         2008-04-29  595    
         * and mark the entries as '0' indicating unavailable.
^1da177e4c3f41 arch/ia64/lib/swiotlb.c Linus Torvalds        2005-04-16  596    
         */
bb094f75bbb66b kernel/dma/swiotlb.c    Dongli Zhang          2021-02-03  597    
        if (io_tlb_list[type][index] >= nslots) {
^1da177e4c3f41 arch/ia64/lib/swiotlb.c Linus Torvalds        2005-04-16  598    
                int count = 0;
^1da177e4c3f41 arch/ia64/lib/swiotlb.c Linus Torvalds        2005-04-16  599  
^1da177e4c3f41 arch/ia64/lib/swiotlb.c Linus Torvalds        2005-04-16  600    
                for (i = index; i < (int) (index + nslots); i++)
bb094f75bbb66b kernel/dma/swiotlb.c    Dongli Zhang          2021-02-03  601    
                        io_tlb_list[type][i] = 0;
2e7a0d517bf27a kernel/dma/swiotlb.c    Dongli Zhang          2021-02-03  602    
                for (i = index - 1;
2e7a0d517bf27a kernel/dma/swiotlb.c    Dongli Zhang          2021-02-03  603    
                     (OFFSET(i, IO_TLB_SEGSIZE) != IO_TLB_SEGSIZE - 1) &&
bb094f75bbb66b kernel/dma/swiotlb.c    Dongli Zhang          2021-02-03  604    
                     io_tlb_list[type][i];
2e7a0d517bf27a kernel/dma/swiotlb.c    Dongli Zhang          2021-02-03  605    
                     i--)
bb094f75bbb66b kernel/dma/swiotlb.c    Dongli Zhang          2021-02-03  606    
                        io_tlb_list[type][i] = ++count;
bb094f75bbb66b kernel/dma/swiotlb.c    Dongli Zhang          2021-02-03  607    
                tlb_addr = io_tlb_start[type] + (index << IO_TLB_SHIFT);
^1da177e4c3f41 arch/ia64/lib/swiotlb.c Linus Torvalds        2005-04-16  608  
^1da177e4c3f41 arch/ia64/lib/swiotlb.c Linus Torvalds        2005-04-16  609    
                /*
a7133a15587b89 lib/swiotlb.c           Andrew Morton         2008-04-29  610    
                 * Update the indices to avoid searching in the next
a7133a15587b89 lib/swiotlb.c           Andrew Morton         2008-04-29  611    
                 * round.
^1da177e4c3f41 arch/ia64/lib/swiotlb.c Linus Torvalds        2005-04-16  612    
                 */
bb094f75bbb66b kernel/dma/swiotlb.c    Dongli Zhang          2021-02-03  613    
                io_tlb_index[type] = ((index + nslots) < io_tlb_nslabs[type]
^1da177e4c3f41 arch/ia64/lib/swiotlb.c Linus Torvalds        2005-04-16  614    
                                ? (index + nslots) : 0);
^1da177e4c3f41 arch/ia64/lib/swiotlb.c Linus Torvalds        2005-04-16  615  
^1da177e4c3f41 arch/ia64/lib/swiotlb.c Linus Torvalds        2005-04-16  616    
                goto found;
^1da177e4c3f41 arch/ia64/lib/swiotlb.c Linus Torvalds        2005-04-16  617    
        }
^1da177e4c3f41 arch/ia64/lib/swiotlb.c Linus Torvalds        2005-04-16  618    
        index += stride;
bb094f75bbb66b kernel/dma/swiotlb.c    Dongli Zhang          2021-02-03  619    
        if (index >= io_tlb_nslabs[type])
^1da177e4c3f41 arch/ia64/lib/swiotlb.c Linus Torvalds        2005-04-16  620    
                index = 0;
^1da177e4c3f41 arch/ia64/lib/swiotlb.c Linus Torvalds        2005-04-16  621    
} while (index != wrap);
^1da177e4c3f41 arch/ia64/lib/swiotlb.c Linus Torvalds        2005-04-16  622  
b15a3891c916f3 lib/swiotlb.c           Jan Beulich           2008-03-13  623  
not_found:
bb094f75bbb66b kernel/dma/swiotlb.c    Dongli Zhang          2021-02-03  624    
tmp_io_tlb_used = io_tlb_used[type];
53b29c336830db kernel/dma/swiotlb.c    Dongli Zhang          2019-04-12  625  
^1da177e4c3f41 arch/ia64/lib/swiotlb.c Linus Torvalds        2005-04-16  626    
spin_unlock_irqrestore(&io_tlb_lock, flags);
d0bc0c2a31c950 lib/swiotlb.c           Christian König       2018-01-04  627    
if (!(attrs & DMA_ATTR_NO_WARN) && printk_ratelimit())
bb094f75bbb66b kernel/dma/swiotlb.c    Dongli Zhang          2021-02-03  628    
        dev_warn(hwdev, "%s swiotlb buffer is full (sz: %zd bytes), total %lu 
(slots), used %lu (slots)\n",
bb094f75bbb66b kernel/dma/swiotlb.c    Dongli Zhang          2021-02-03  629    
                 swiotlb_name[type], alloc_size, io_tlb_nslabs[type], 
tmp_io_tlb_used);
9c106119f6538f kernel/dma/swiotlb.c    Arnd Bergmann         2019-06-17  630    
return (phys_addr_t)DMA_MAPPING_ERROR;
^1da177e4c3f41 arch/ia64/lib/swiotlb.c Linus Torvalds        2005-04-16  631  
found:
bb094f75bbb66b kernel/dma/swiotlb.c    Dongli Zhang          2021-02-03  632    
io_tlb_used[type] += nslots;
^1da177e4c3f41 arch/ia64/lib/swiotlb.c Linus Torvalds        2005-04-16  633    
spin_unlock_irqrestore(&io_tlb_lock, flags);
^1da177e4c3f41 arch/ia64/lib/swiotlb.c Linus Torvalds        2005-04-16  634  
^1da177e4c3f41 arch/ia64/lib/swiotlb.c Linus Torvalds        2005-04-16  635    
/*
^1da177e4c3f41 arch/ia64/lib/swiotlb.c Linus Torvalds        2005-04-16  636    
 * Save away the mapping from the original address to the DMA address.
^1da177e4c3f41 arch/ia64/lib/swiotlb.c Linus Torvalds        2005-04-16  637    
 * This is needed when we sync the memory.  Then we sync the buffer if
^1da177e4c3f41 arch/ia64/lib/swiotlb.c Linus Torvalds        2005-04-16  638    
 * needed.
^1da177e4c3f41 arch/ia64/lib/swiotlb.c Linus Torvalds        2005-04-16  639    
 */
bc40ac66988a77 lib/swiotlb.c           Becky Bruce           2008-12-22  640    
for (i = 0; i < nslots; i++)
bb094f75bbb66b kernel/dma/swiotlb.c    Dongli Zhang          2021-02-03  641    
        io_tlb_orig_addr[type][index+i] = orig_addr + (i << IO_TLB_SHIFT);
0443fa003fa199 lib/swiotlb.c           Alexander Duyck       2016-11-02  642    
if (!(attrs & DMA_ATTR_SKIP_CPU_SYNC) &&
0443fa003fa199 lib/swiotlb.c           Alexander Duyck       2016-11-02  643    
    (dir == DMA_TO_DEVICE || dir == DMA_BIDIRECTIONAL))
3fc1ca00653db6 kernel/dma/swiotlb.c    Lu Baolu              2019-09-06  644    
        swiotlb_bounce(orig_addr, tlb_addr, mapping_size, DMA_TO_DEVICE);
^1da177e4c3f41 arch/ia64/lib/swiotlb.c Linus Torvalds        2005-04-16  645  
e05ed4d1fad9e7 lib/swiotlb.c           Alexander Duyck       2012-10-15  646    
return tlb_addr;
^1da177e4c3f41 arch/ia64/lib/swiotlb.c Linus Torvalds        2005-04-16  647  }
^1da177e4c3f41 arch/ia64/lib/swiotlb.c Linus Torvalds        2005-04-16  648  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/[email protected]

Attachment: .config.gz
Description: application/gzip

_______________________________________________
kbuild mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to