linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] mmc: Fix scatter/gather on SDHCI
@ 2019-09-09 12:56 Thierry Reding
  2019-09-09 12:56 ` [PATCH 1/3] block: Respect the device's maximum segment size Thierry Reding
                   ` (2 more replies)
  0 siblings, 3 replies; 15+ messages in thread
From: Thierry Reding @ 2019-09-09 12:56 UTC (permalink / raw)
  To: Jens Axboe, Ulf Hansson, Adrian Hunter
  Cc: Yoshihiro Shimoda, Christoph Hellwig, Simon Horman, Jon Hunter,
	linux-block, linux-mmc, linux-tegra

From: Thierry Reding <treding@nvidia.com>

Commit 158a6d3ce3bc ("iommu/dma: add a new dma_map_ops of
get_merge_boundary()") causes scatter/gather to break for SDHCI and
potentially other MMC hosts.

The reason is that the commit ends up tricking the block layer into
believing that there's effectively no limit on the segment size. While
this may be true for some device, it's certainly not true for all. The
DMA descriptors used by SDHCI, for example, have a 16-bit field that
contains the number of bytes to transmit for that particular transfer.
As a result of the segment size exceeding the capabilities of the
hardware, the scatterlist ends up containing entries that are too large
to fit into a single descriptor.

This small series fixes this by making the block layer respect the
segment size restrictions set for the device. It also prevents the MMC
queue code to attempt to overwrite the maximum segment size of a device
that may already have been set up. Finally it configures the maximum
segment size for SDHCI. The last step is technically not required
because the maximum segment size for SDHCI coincides with the default,
but I think it's better to be explicit here.

As a result, all entries in the scatterlist are now small enough to fit
into SDHCI DMA descriptors. Some improvements could be made to how the
scatterlist is packed. For example, the dma-iommu code compacts the SG
entries so that they result in segments less than the maximum segment,
but doesn't split up individual entries. This often results in holes in
the individual segments. In order to create full 64 KiB segments with
only the last segment being partial, the code would have to split up
individual entries. This should be possible but is not done as part of
this series.

Thierry

Thierry Reding (3):
  block: Respect the device's maximum segment size
  mmc: core: Respect MMC host's maximum segment size
  mmc: sdhci: Set DMA maximum segment size to 64 KiB

 block/blk-settings.c     | 24 +++++++++++++++---------
 drivers/mmc/core/queue.c |  2 --
 drivers/mmc/host/sdhci.c |  5 +++++
 drivers/mmc/host/sdhci.h |  1 +
 4 files changed, 21 insertions(+), 11 deletions(-)

-- 
2.23.0


^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2019-09-12  8:19 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-09 12:56 [PATCH 0/3] mmc: Fix scatter/gather on SDHCI Thierry Reding
2019-09-09 12:56 ` [PATCH 1/3] block: Respect the device's maximum segment size Thierry Reding
2019-09-09 16:13   ` Christoph Hellwig
2019-09-09 19:19     ` Thierry Reding
2019-09-10  2:03       ` Yoshihiro Shimoda
2019-09-10  6:13         ` Christoph Hellwig
2019-09-10  7:37           ` Thierry Reding
2019-09-11 10:36             ` Christoph Hellwig
2019-09-10  7:30         ` Thierry Reding
2019-09-11  7:23           ` Yoshihiro Shimoda
2019-09-11 10:37         ` Christoph Hellwig
2019-09-12  0:57     ` Ming Lei
2019-09-12  8:19       ` Christoph Hellwig
2019-09-09 12:56 ` [PATCH 2/3] mmc: core: Respect MMC host's " Thierry Reding
2019-09-09 12:56 ` [PATCH 3/3] mmc: sdhci: Set DMA maximum segment size to 64 KiB Thierry Reding

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).