Skip to content
  1. Jun 03, 2019
    • Laurentiu Tudor's avatar
      USB: use genalloc for USB HCs with local memory · b0310c2f
      Laurentiu Tudor authored
      
      
      For HCs that have local memory, replace the current DMA API usage with
      a genalloc generic allocator to manage the mappings for these devices.
      To help users, introduce a new HCD API, usb_hcd_setup_local_mem() that
      will setup up the genalloc backing up the device local memory. It will
      be used in subsequent patches.  This is in preparation for dropping
      the existing "coherent" dma mem declaration APIs.  The current
      implementation was relying on a short circuit in the DMA API that in
      the end, was acting as an allocator for these type of devices.
      
      Signed-off-by: default avatarLaurentiu Tudor <laurentiu.tudor@nxp.com>
      Tested-by: default avatarFredrik Noring <noring@nocrew.org>
      Reviewed-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
      b0310c2f
    • Fredrik Noring's avatar
      lib/genalloc: add gen_pool_dma_zalloc() for zeroed DMA allocations · da83a722
      Fredrik Noring authored
      
      
      gen_pool_dma_zalloc() is a zeroed memory variant of
      gen_pool_dma_alloc().  Also document the return values of both, and
      indicate NULL as a "%NULL" constant.
      
      Signed-off-by: default avatarFredrik Noring <noring@nocrew.org>
      Reviewed-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
      da83a722
    • Nicolin Chen's avatar
      dma-contiguous: fix !CONFIG_DMA_CMA version of dma_{alloc, free}_contiguous() · dd3dcede
      Nicolin Chen authored
      Commit fdaeec198ada ("dma-contiguous: add dma_{alloc,free}_contiguous()
      helpers") adds a pair of new helper functions so as to abstract code in
      the dma-direct (and other places in the future), however it breaks QEMU
      boot feature using x86_64 defconfig.
      
      That's because x86_64 defconfig has CONFIG_DMA_CMA=n so those two newly
      introduced helper functions are empty in their !CONFIG_DMA_CMA version,
      while previously the platform independent dma-direct code had fallback
      alloc_pages_node() and __free_pages().
      
      So this patch fixes it by adding alloc_pages_node() and __free_pages()
      in the !CONFIG_DMA_CMA version of the two helper functions.
      
      Tested with below QEMU command:
        qemu-system-x86_64 -m 512m \
            -drive file=images/x86_64/rootfs.ext4,format=raw,if=ide \
            -append 'console=ttyS0 root=/dev/sda' -nographic \
            -kernel arch/x86_64/boot/bzImage
      
      with the rootfs from the below link:
        https://github.com/ClangBuiltLinux/continuous-integration/raw/master/images/x86_64/rootfs.ext4
      
      
      
      Fixes: fdaeec198ada ("dma-contiguous: add dma_{alloc,free}_contiguous() helpers")
      Reported-by: default avatarNathan Chancellor <natechancellor@gmail.com>
      Signed-off-by: default avatarNicolin Chen <nicoleotsuka@gmail.com>
      Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
      dd3dcede
    • Nicolin Chen's avatar
      dma-contiguous: use fallback alloc_pages for single pages · bd2e7563
      Nicolin Chen authored
      
      
      The addresses within a single page are always contiguous, so it's
      not so necessary to always allocate one single page from CMA area.
      Since the CMA area has a limited predefined size of space, it may
      run out of space in heavy use cases, where there might be quite a
      lot CMA pages being allocated for single pages.
      
      However, there is also a concern that a device might care where a
      page comes from -- it might expect the page from CMA area and act
      differently if the page doesn't.
      
      This patch tries to use the fallback alloc_pages path, instead of
      one-page size allocations from the global CMA area in case that a
      device does not have its own CMA area. This'd save resources from
      the CMA global area for more CMA allocations, and also reduce CMA
      fragmentations resulted from trivial allocations.
      
      Signed-off-by: default avatarNicolin Chen <nicoleotsuka@gmail.com>
      Tested-by: default avatardann frazier <dann.frazier@canonical.com>
      Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
      bd2e7563
    • Nicolin Chen's avatar
      dma-contiguous: add dma_{alloc,free}_contiguous() helpers · b1d2dc00
      Nicolin Chen authored
      
      
      Both dma_alloc_from_contiguous() and dma_release_from_contiguous() are
      very simply implemented, but requiring callers to pass certain
      parameters like count and align, and taking a boolean parameter to check
      __GFP_NOWARN in the allocation flags. So every function call duplicates
      similar work:
      
      	unsigned long order = get_order(size);
      	size_t count = size >> PAGE_SHIFT;
      
      	page = dma_alloc_from_contiguous(dev, count, order,
      			gfp & __GFP_NOWARN);
      
      	[...]
      
      	dma_release_from_contiguous(dev, page, size >> PAGE_SHIFT);
      
      Additionally, as CMA can be used only in the context which permits
      sleeping, most of callers do a gfpflags_allow_blocking() check and a
      corresponding fallback allocation of normal pages upon any false result:
      
      	if (gfpflags_allow_blocking(flag))
      		page = dma_alloc_from_contiguous();
      	if (!page)
      		page = alloc_pages();
      
      	[...]
      
      	if (!dma_release_from_contiguous(dev, page, count))
      		__free_pages(page, get_order(size));
      
      So this patch simplifies those function calls by abstracting these
      operations into the two new functions: dma_{alloc,free}_contiguous.
      
      As some callers of dma_{alloc,release}_from_contiguous() might be
      complicated, this patch just implements these two new functions to
      kernel/dma/direct.c only as an initial step.
      
      Suggested-by: default avatarChristoph Hellwig <hch@lst.de>
      Signed-off-by: default avatarNicolin Chen <nicoleotsuka@gmail.com>
      Tested-by: default avatardann frazier <dann.frazier@canonical.com>
      Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
      b1d2dc00
    • Nathan Chancellor's avatar
      iommu/dma: Fix condition check in iommu_dma_unmap_sg · 1b961423
      Nathan Chancellor authored
      Clang warns:
      
      drivers/iommu/dma-iommu.c:897:6: warning: logical not is only applied to
      the left hand side of this comparison [-Wlogical-not-parentheses]
              if (!(attrs & DMA_ATTR_SKIP_CPU_SYNC) == 0)
                  ^                                 ~~
      drivers/iommu/dma-iommu.c:897:6: note: add parentheses after the '!' to
      evaluate the comparison first
              if (!(attrs & DMA_ATTR_SKIP_CPU_SYNC) == 0)
                  ^
                   (                                    )
      drivers/iommu/dma-iommu.c:897:6: note: add parentheses around left hand
      side expression to silence this warning
              if (!(attrs & DMA_ATTR_SKIP_CPU_SYNC) == 0)
                  ^
                  (                                )
      1 warning generated.
      
      Judging from the rest of the commit and the conditional in
      iommu_dma_map_sg, either
      
          if (!(attrs & DMA_ATTR_SKIP_CPU_SYNC))
      
      or
          if ((attrs & DMA_ATTR_SKIP_CPU_SYNC) == 0)
      
      was intended, not a combination of the two.
      
      I personally think that the former is easier to understand so use that.
      
      Fixes: 06d60728 ("iommu/dma: move the arm64 wrappers to common code")
      Link: https://github.com/ClangBuiltLinux/linux/issues/497
      
      
      Signed-off-by: default avatarNathan Chancellor <natechancellor@gmail.com>
      Reviewed-by: default avatarRobin Murphy <robin.murphy@arm.com>
      Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
      Signed-off-by: default avatarJoerg Roedel <jroedel@suse.de>
      1b961423
  2. May 27, 2019
  3. May 26, 2019
  4. May 25, 2019
    • Gabriel Krisman Bertazi's avatar
      ext4: fix dcache lookup of !casefolded directories · 66883da1
      Gabriel Krisman Bertazi authored
      Found by visual inspection, this wasn't caught by my xfstest, since it's
      effect is ignoring positive dentries in the cache the fallback just goes
      to the disk.  it was introduced in the last iteration of the
      case-insensitive patch.
      
      d_compare should return 0 when the entries match, so make sure we are
      correctly comparing the entire string if the encoding feature is set and
      we are on a case-INsensitive directory.
      
      Fixes: b886ee3e
      
       ("ext4: Support case-insensitive file name lookups")
      Signed-off-by: default avatarGabriel Krisman Bertazi <krisman@collabora.com>
      Signed-off-by: default avatarTheodore Ts'o <tytso@mit.edu>
      66883da1
    • Linus Torvalds's avatar
      Merge tag 'scsi-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi · 2409207a
      Linus Torvalds authored
      Pull SCSI fixes from James Bottomley:
       "This is the same set of patches sent in the merge window as the final
        pull except that Martin's read only rework is replaced with a simple
        revert of the original change that caused the regression.
      
        Everything else is an obvious fix or small cleanup"
      
      * tag 'scsi-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi:
        Revert "scsi: sd: Keep disk read-only when re-reading partition"
        scsi: bnx2fc: fix incorrect cast to u64 on shift operation
        scsi: smartpqi: Reporting unhandled SCSI errors
        scsi: myrs: Fix uninitialized variable
        scsi: lpfc: Update lpfc version to 12.2.0.2
        scsi: lpfc: add check for loss of ndlp when sending RRQ
        scsi: lpfc: correct rcu unlock issue in lpfc_nvme_info_show
        scsi: lpfc: resolve lockdep warnings
        scsi: qedi: remove set but not used variables 'cdev' and 'udev'
        scsi: qedi: remove memset/memcpy to nfunc and use func instead
        scsi: qla2xxx: Add cleanup for PCI EEH recovery
      2409207a