1. 03 Jun, 2019 6 commits
    • 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/497Signed-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. 27 May, 2019 23 commits
  3. 26 May, 2019 6 commits
    • Linus Torvalds's avatar
      Linux 5.2-rc2 · cd6c84d8
      Linus Torvalds authored
      cd6c84d8
    • Linus Torvalds's avatar
      Merge tag 'trace-v5.2-rc1-2' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace · c5b44095
      Linus Torvalds authored
      Pull tracing warning fix from Steven Rostedt:
       "Make the GCC 9 warning for sub struct memset go away.
      
        GCC 9 now warns about calling memset() on partial structures when it
        goes across multiple fields. This adds a helper for the place in
        tracing that does this type of clearing of a structure"
      
      * tag 'trace-v5.2-rc1-2' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace:
        tracing: Silence GCC 9 array bounds warning
      c5b44095
    • Linus Torvalds's avatar
      Merge tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm · 862f0a32
      Linus Torvalds authored
      Pull KVM fixes from Paolo Bonzini:
       "The usual smattering of fixes and tunings that came in too late for
        the merge window, but should not wait four months before they appear
        in a release.
      
        I also travelled a bit more than usual in the first part of May, which
        didn't help with picking up patches and reports promptly"
      
      * tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm: (33 commits)
        KVM: x86: fix return value for reserved EFER
        tools/kvm_stat: fix fields filter for child events
        KVM: selftests: Wrap vcpu_nested_state_get/set functions with x86 guard
        kvm: selftests: aarch64: compile with warnings on
        kvm: selftests: aarch64: fix default vm mode
        kvm: selftests: aarch64: dirty_log_test: fix unaligned memslot size
        KVM: s390: fix memory slot handling for KVM_SET_USER_MEMORY_REGION
        KVM: x86/pmu: do not mask the value that is written to fixed PMUs
        KVM: x86/pmu: mask the result of rdpmc according to the width of the counters
        x86/kvm/pmu: Set AMD's virt PMU version to 1
        KVM: x86: do not spam dmesg with VMCS/VMCB dumps
        kvm: Check irqchip mode before assign irqfd
        kvm: svm/avic: fix off-by-one in checking host APIC ID
        KVM: selftests: do not blindly clobber registers in guest asm
        KVM: selftests: Remove duplicated TEST_ASSERT in hyperv_cpuid.c
        KVM: LAPIC: Expose per-vCPU timer_advance_ns to userspace
        KVM: LAPIC: Fix lapic_timer_advance_ns parameter overflow
        kvm: vmx: Fix -Wmissing-prototypes warnings
        KVM: nVMX: Fix using __this_cpu_read() in preemptible context
        kvm: fix compilation on s390
        ...
      862f0a32
    • Linus Torvalds's avatar
      Merge tag 'random_for_linus_stable' of git://git.kernel.org/pub/scm/linux/kernel/git/tytso/random · 128f2bfa
      Linus Torvalds authored
      Pull /dev/random fix from Ted Ts'o:
       "Fix a soft lockup regression when reading from /dev/random in early
        boot"
      
      * tag 'random_for_linus_stable' of git://git.kernel.org/pub/scm/linux/kernel/git/tytso/random:
        random: fix soft lockup when trying to read from an uninitialized blocking pool
      128f2bfa
    • Theodore Ts'o's avatar
      random: fix soft lockup when trying to read from an uninitialized blocking pool · 58be0106
      Theodore Ts'o authored
      Fixes: eb9d1bf0: "random: only read from /dev/random after its pool has received 128 bits"
      Reported-by: default avatarkernel test robot <lkp@intel.com>
      Signed-off-by: default avatarTheodore Ts'o <tytso@mit.edu>
      58be0106
    • Miguel Ojeda's avatar
      tracing: Silence GCC 9 array bounds warning · 0c97bf86
      Miguel Ojeda authored
      Starting with GCC 9, -Warray-bounds detects cases when memset is called
      starting on a member of a struct but the size to be cleared ends up
      writing over further members.
      
      Such a call happens in the trace code to clear, at once, all members
      after and including `seq` on struct trace_iterator:
      
          In function 'memset',
              inlined from 'ftrace_dump' at kernel/trace/trace.c:8914:3:
          ./include/linux/string.h:344:9: warning: '__builtin_memset' offset
          [8505, 8560] from the object at 'iter' is out of the bounds of
          referenced subobject 'seq' with type 'struct trace_seq' at offset
          4368 [-Warray-bounds]
            344 |  return __builtin_memset(p, c, size);
                |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
      
      In order to avoid GCC complaining about it, we compute the address
      ourselves by adding the offsetof distance instead of referring
      directly to the member.
      
      Since there are two places doing this clear (trace.c and trace_kdb.c),
      take the chance to move the workaround into a single place in
      the internal header.
      
      Link: http://lkml.kernel.org/r/20190523124535.GA12931@gmail.comSigned-off-by: default avatarMiguel Ojeda <miguel.ojeda.sandonis@gmail.com>
      [ Removed unnecessary parenthesis around "iter" ]
      Signed-off-by: default avatarSteven Rostedt (VMware) <rostedt@goodmis.org>
      0c97bf86
  4. 25 May, 2019 5 commits