1. 10 May, 2020 29 commits
  2. 06 May, 2020 11 commits
    • Greg Kroah-Hartman's avatar
      Linux 4.19.121 · 84920cc7
      Greg Kroah-Hartman authored
      84920cc7
    • Martin Blumenstingl's avatar
      mmc: meson-mx-sdio: remove the broken ->card_busy() op · 144857ac
      Martin Blumenstingl authored
      commit ddca1092 upstream.
      
      The recent commit 0d84c3e6 ("mmc: core: Convert to
      mmc_poll_for_busy() for erase/trim/discard") makes use of the
      ->card_busy() op for SD cards. This uncovered that the ->card_busy() op
      in the Meson SDIO driver was never working right:
      while polling the busy status with ->card_busy()
      meson_mx_mmc_card_busy() reads only one of the two MESON_MX_SDIO_IRQC
      register values 0x1f001f10 or 0x1f003f10. This translates to "three out
      of four DAT lines are HIGH" and "all four DAT lines are HIGH", which
      is interpreted as "the card is busy".
      
      It turns out that no situation can be observed where all four DAT lines
      are LOW, meaning the card is not busy anymore. Upon further research the
      3.10 vendor driver for this controller does not implement the
      ->card_busy() op.
      
      Remove the ->card_busy() op from the meson-mx-sdio driver since it is
      not working. At the time of writing this patch it is not clear what's
      needed to make the ->card_busy() implementation work with this specific
      controller hardware. For all use-cases which have previously worked the
      MMC_CAP_WAIT_WHILE_BUSY flag is now taking over, even if we don't have
      a ->card_busy() op anymore.
      
      Fixes: ed80a13b ("mmc: meson-mx-sdio: Add a driver for the Amlogic Meson8 and Meson8b SoCs")
      Signed-off-by: default avatarMartin Blumenstingl <martin.blumenstingl@googlemail.com>
      Cc: stable@vger.kernel.org
      Link: https://lore.kernel.org/r/20200416183513.993763-3-martin.blumenstingl@googlemail.comSigned-off-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      144857ac
    • Martin Blumenstingl's avatar
      mmc: meson-mx-sdio: Set MMC_CAP_WAIT_WHILE_BUSY · 920d9c11
      Martin Blumenstingl authored
      commit e53b868b upstream.
      
      The Meson SDIO controller uses the DAT0 lane for hardware busy
      detection. Set MMC_CAP_WAIT_WHILE_BUSY accordingly. This fixes
      the following error observed with Linux 5.7 (pre-rc-1):
        mmc1: Card stuck being busy! __mmc_poll_for_busy
        blk_update_request: I/O error, dev mmcblk1, sector 17111080 op
         0x3:(DISCARD) flags 0x0 phys_seg 1 prio class 0
      
      Fixes: ed80a13b ("mmc: meson-mx-sdio: Add a driver for the Amlogic Meson8 and Meson8b SoCs")
      Signed-off-by: default avatarMartin Blumenstingl <martin.blumenstingl@googlemail.com>
      Cc: stable@vger.kernel.org
      Link: https://lore.kernel.org/r/20200416183513.993763-2-martin.blumenstingl@googlemail.comSigned-off-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      920d9c11
    • Veerabhadrarao Badiganti's avatar
      mmc: sdhci-msm: Enable host capabilities pertains to R1b response · 2c1b0513
      Veerabhadrarao Badiganti authored
      commit 9d8cb586 upstream.
      
      MSM sd host controller is capable of HW busy detection of device busy
      signaling over DAT0 line. And it requires the R1B response for commands
      that have this response associated with them.
      
      So set the below two host capabilities for qcom SDHC.
       - MMC_CAP_WAIT_WHILE_BUSY
       - MMC_CAP_NEED_RSP_BUSY
      
      Recent development of the mmc core in regards to this, revealed this as
      being a potential bug, hence the stable tag.
      
      Cc: <stable@vger.kernel.org> # v4.19+
      Signed-off-by: default avatarVeerabhadrarao Badiganti <vbadigan@codeaurora.org>
      Acked-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Link: https://lore.kernel.org/r/1587363626-20413-2-git-send-email-vbadigan@codeaurora.orgSigned-off-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      2c1b0513
    • Adrian Hunter's avatar
      mmc: sdhci-pci: Fix eMMC driver strength for BYT-based controllers · a1acd57f
      Adrian Hunter authored
      commit 1a8eb6b3 upstream.
      
      BIOS writers have begun the practice of setting 40 ohm eMMC driver strength
      even though the eMMC may not support it, on the assumption that the kernel
      will validate the value against the eMMC (Extended CSD DRIVER_STRENGTH
      [offset 197]) and revert to the default 50 ohm value if 40 ohm is invalid.
      
      This is done to avoid changing the value for different boards.
      
      Putting aside the merits of this approach, it is clear the eMMC's mask
      of supported driver strengths is more reliable than the value provided
      by BIOS. Add validation accordingly.
      Signed-off-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Fixes: 51ced59c ("mmc: sdhci-pci: Use ACPI DSM to get driver strength for some Intel devices")
      Cc: stable@vger.kernel.org
      Link: https://lore.kernel.org/r/20200422111629.4899-1-adrian.hunter@intel.comSigned-off-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      a1acd57f
    • Marek Behún's avatar
      mmc: sdhci-xenon: fix annoying 1.8V regulator warning · 82e242c1
      Marek Behún authored
      commit bb32e198 upstream.
      
      For some reason the Host Control2 register of the Xenon SDHCI controller
      sometimes reports the bit representing 1.8V signaling as 0 when read
      after it was written as 1. Subsequent read reports 1.
      
      This causes the sdhci_start_signal_voltage_switch function to report
        1.8V regulator output did not become stable
      
      When CONFIG_PM is enabled, the host is suspended and resumend many
      times, and in each resume the switch to 1.8V is called, and so the
      kernel log reports this message annoyingly often.
      
      Do an empty read of the Host Control2 register in Xenon's
      .voltage_switch method to circumvent this.
      
      This patch fixes this particular problem on Turris MOX.
      Signed-off-by: default avatarMarek Behún <marek.behun@nic.cz>
      Fixes: 8d876bf4 ("mmc: sdhci-xenon: wait 5ms after set 1.8V...")
      Cc: stable@vger.kernel.org # v4.16+
      Link: https://lore.kernel.org/r/20200420080444.25242-1-marek.behun@nic.czSigned-off-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      82e242c1
    • Douglas Anderson's avatar
      mmc: cqhci: Avoid false "cqhci: CQE stuck on" by not open-coding timeout loop · dbbee5a1
      Douglas Anderson authored
      commit b1ac62a7 upstream.
      
      Open-coding a timeout loop invariably leads to errors with handling
      the timeout properly in one corner case or another.  In the case of
      cqhci we might report "CQE stuck on" even if it wasn't stuck on.
      You'd just need this sequence of events to happen in cqhci_off():
      
      1. Call ktime_get().
      2. Something happens to interrupt the CPU for > 100 us (context switch
         or interrupt).
      3. Check time and; set "timed_out" to true since > 100 us.
      4. Read CQHCI_CTL.
      5. Both "reg & CQHCI_HALT" and "timed_out" are true, so break.
      6. Since "timed_out" is true, falsely print the error message.
      
      Rather than fixing the polling loop, use readx_poll_timeout() like
      many people do.  This has been time tested to handle the corner cases.
      
      Fixes: a4080225 ("mmc: cqhci: support for command queue enabled host")
      Signed-off-by: default avatarDouglas Anderson <dianders@chromium.org>
      Acked-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Cc: stable@vger.kernel.org
      Link: https://lore.kernel.org/r/20200413162717.1.Idece266f5c8793193b57a1ddb1066d030c6af8e0@changeidSigned-off-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      dbbee5a1
    • Qu Wenruo's avatar
      btrfs: transaction: Avoid deadlock due to bad initialization timing of fs_info::journal_info · 57be052c
      Qu Wenruo authored
      commit fcc99734 upstream.
      
      [BUG]
      One run of btrfs/063 triggered the following lockdep warning:
        ============================================
        WARNING: possible recursive locking detected
        5.6.0-rc7-custom+ #48 Not tainted
        --------------------------------------------
        kworker/u24:0/7 is trying to acquire lock:
        ffff88817d3a46e0 (sb_internal#2){.+.+}, at: start_transaction+0x66c/0x890 [btrfs]
      
        but task is already holding lock:
        ffff88817d3a46e0 (sb_internal#2){.+.+}, at: start_transaction+0x66c/0x890 [btrfs]
      
        other info that might help us debug this:
         Possible unsafe locking scenario:
      
               CPU0
               ----
          lock(sb_internal#2);
          lock(sb_internal#2);
      
         *** DEADLOCK ***
      
         May be due to missing lock nesting notation
      
        4 locks held by kworker/u24:0/7:
         #0: ffff88817b495948 ((wq_completion)btrfs-endio-write){+.+.}, at: process_one_work+0x557/0xb80
         #1: ffff888189ea7db8 ((work_completion)(&work->normal_work)){+.+.}, at: process_one_work+0x557/0xb80
         #2: ffff88817d3a46e0 (sb_internal#2){.+.+}, at: start_transaction+0x66c/0x890 [btrfs]
         #3: ffff888174ca4da8 (&fs_info->reloc_mutex){+.+.}, at: btrfs_record_root_in_trans+0x83/0xd0 [btrfs]
      
        stack backtrace:
        CPU: 0 PID: 7 Comm: kworker/u24:0 Not tainted 5.6.0-rc7-custom+ #48
        Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 0.0.0 02/06/2015
        Workqueue: btrfs-endio-write btrfs_work_helper [btrfs]
        Call Trace:
         dump_stack+0xc2/0x11a
         __lock_acquire.cold+0xce/0x214
         lock_acquire+0xe6/0x210
         __sb_start_write+0x14e/0x290
         start_transaction+0x66c/0x890 [btrfs]
         btrfs_join_transaction+0x1d/0x20 [btrfs]
         find_free_extent+0x1504/0x1a50 [btrfs]
         btrfs_reserve_extent+0xd5/0x1f0 [btrfs]
         btrfs_alloc_tree_block+0x1ac/0x570 [btrfs]
         btrfs_copy_root+0x213/0x580 [btrfs]
         create_reloc_root+0x3bd/0x470 [btrfs]
         btrfs_init_reloc_root+0x2d2/0x310 [btrfs]
         record_root_in_trans+0x191/0x1d0 [btrfs]
         btrfs_record_root_in_trans+0x90/0xd0 [btrfs]
         start_transaction+0x16e/0x890 [btrfs]
         btrfs_join_transaction+0x1d/0x20 [btrfs]
         btrfs_finish_ordered_io+0x55d/0xcd0 [btrfs]
         finish_ordered_fn+0x15/0x20 [btrfs]
         btrfs_work_helper+0x116/0x9a0 [btrfs]
         process_one_work+0x632/0xb80
         worker_thread+0x80/0x690
         kthread+0x1a3/0x1f0
         ret_from_fork+0x27/0x50
      
      It's pretty hard to reproduce, only one hit so far.
      
      [CAUSE]
      This is because we're calling btrfs_join_transaction() without re-using
      the current running one:
      
      btrfs_finish_ordered_io()
      |- btrfs_join_transaction()		<<< Call #1
         |- btrfs_record_root_in_trans()
            |- btrfs_reserve_extent()
      	 |- btrfs_join_transaction()	<<< Call #2
      
      Normally such btrfs_join_transaction() call should re-use the existing
      one, without trying to re-start a transaction.
      
      But the problem is, in btrfs_join_transaction() call #1, we call
      btrfs_record_root_in_trans() before initializing current::journal_info.
      
      And in btrfs_join_transaction() call #2, we're relying on
      current::journal_info to avoid such deadlock.
      
      [FIX]
      Call btrfs_record_root_in_trans() after we have initialized
      current::journal_info.
      
      CC: stable@vger.kernel.org # 4.4+
      Signed-off-by: default avatarQu Wenruo <wqu@suse.com>
      Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
      Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      57be052c
    • Filipe Manana's avatar
      btrfs: fix partial loss of prealloc extent past i_size after fsync · 00043456
      Filipe Manana authored
      commit f135cea3 upstream.
      
      When we have an inode with a prealloc extent that starts at an offset
      lower than the i_size and there is another prealloc extent that starts at
      an offset beyond i_size, we can end up losing part of the first prealloc
      extent (the part that starts at i_size) and have an implicit hole if we
      fsync the file and then have a power failure.
      
      Consider the following example with comments explaining how and why it
      happens.
      
        $ mkfs.btrfs -f /dev/sdb
        $ mount /dev/sdb /mnt
      
        # Create our test file with 2 consecutive prealloc extents, each with a
        # size of 128Kb, and covering the range from 0 to 256Kb, with a file
        # size of 0.
        $ xfs_io -f -c "falloc -k 0 128K" /mnt/foo
        $ xfs_io -c "falloc -k 128K 128K" /mnt/foo
      
        # Fsync the file to record both extents in the log tree.
        $ xfs_io -c "fsync" /mnt/foo
      
        # Now do a redudant extent allocation for the range from 0 to 64Kb.
        # This will merely increase the file size from 0 to 64Kb. Instead we
        # could also do a truncate to set the file size to 64Kb.
        $ xfs_io -c "falloc 0 64K" /mnt/foo
      
        # Fsync the file, so we update the inode item in the log tree with the
        # new file size (64Kb). This also ends up setting the number of bytes
        # for the first prealloc extent to 64Kb. This is done by the truncation
        # at btrfs_log_prealloc_extents().
        # This means that if a power failure happens after this, a write into
        # the file range 64Kb to 128Kb will not use the prealloc extent and
        # will result in allocation of a new extent.
        $ xfs_io -c "fsync" /mnt/foo
      
        # Now set the file size to 256K with a truncate and then fsync the file.
        # Since no changes happened to the extents, the fsync only updates the
        # i_size in the inode item at the log tree. This results in an implicit
        # hole for the file range from 64Kb to 128Kb, something which fsck will
        # complain when not using the NO_HOLES feature if we replay the log
        # after a power failure.
        $ xfs_io -c "truncate 256K" -c "fsync" /mnt/foo
      
      So instead of always truncating the log to the inode's current i_size at
      btrfs_log_prealloc_extents(), check first if there's a prealloc extent
      that starts at an offset lower than the i_size and with a length that
      crosses the i_size - if there is one, just make sure we truncate to a
      size that corresponds to the end offset of that prealloc extent, so
      that we don't lose the part of that extent that starts at i_size if a
      power failure happens.
      
      A test case for fstests follows soon.
      
      Fixes: 31d11b83 ("Btrfs: fix duplicate extents after fsync of file with prealloc extents")
      CC: stable@vger.kernel.org # 4.14+
      Signed-off-by: default avatarFilipe Manana <fdmanana@suse.com>
      Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      00043456
    • Paul Moore's avatar
      selinux: properly handle multiple messages in selinux_netlink_send() · 23075857
      Paul Moore authored
      commit fb739741 upstream.
      
      Fix the SELinux netlink_send hook to properly handle multiple netlink
      messages in a single sk_buff; each message is parsed and subject to
      SELinux access control.  Prior to this patch, SELinux only inspected
      the first message in the sk_buff.
      
      Cc: stable@vger.kernel.org
      Reported-by: default avatarDmitry Vyukov <dvyukov@google.com>
      Reviewed-by: default avatarStephen Smalley <stephen.smalley.work@gmail.com>
      Signed-off-by: default avatarPaul Moore <paul@paul-moore.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      23075857
    • Andy Shevchenko's avatar
      dmaengine: dmatest: Fix iteration non-stop logic · 87cb81e6
      Andy Shevchenko authored
      commit b9f96020 upstream.
      
      Under some circumstances, i.e. when test is still running and about to
      time out and user runs, for example,
      
      	grep -H . /sys/module/dmatest/parameters/*
      
      the iterations parameter is not respected and test is going on and on until
      user gives
      
      	echo 0 > /sys/module/dmatest/parameters/run
      
      This is not what expected.
      
      The history of this bug is interesting. I though that the commit
        2d88ce76 ("dmatest: add a 'wait' parameter")
      is a culprit, but looking closer to the code I think it simple revealed the
      broken logic from the day one, i.e. in the commit
        0a2ff57d ("dmaengine: dmatest: add a maximum number of test iterations")
      which adds iterations parameter.
      
      So, to the point, the conditional of checking the thread to be stopped being
      first part of conjunction logic prevents to check iterations. Thus, we have to
      always check both conditions to be able to stop after given iterations.
      
      Since it wasn't visible before second commit appeared, I add a respective
      Fixes tag.
      
      Fixes: 2d88ce76 ("dmatest: add a 'wait' parameter")
      Cc: Dan Williams <dan.j.williams@intel.com>
      Cc: Nicolas Ferre <nicolas.ferre@microchip.com>
      Signed-off-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
      Acked-by: default avatarNicolas Ferre <nicolas.ferre@microchip.com>
      Link: https://lore.kernel.org/r/20200424161147.16895-1-andriy.shevchenko@linux.intel.comSigned-off-by: default avatarVinod Koul <vkoul@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      87cb81e6