mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Takashi Iwai <tiwai@suse.de>
To: Christoph Hellwig <hch@lst.de>
Cc: iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org
Subject: [PATCH 2/2] swiotlb: Fix dma_supported() to consider direct allocation
Date: Sun, 15 Apr 2018 11:08:08 +0200	[thread overview]
Message-ID: <20180415090808.19121-3-tiwai@suse.de> (raw)
In-Reply-To: <20180415090808.19121-1-tiwai@suse.de>

Along with the recent change to use the common swiotlb dma_ops, x86
also takes over the swiotlb_dma_supported().  This caused a regression
when a low bit DMA mask is set; e.g. parport_pc driver now fails to
set the 24bit DMA mask:

  parport_pc parport_pc.956: Unable to set coherent dma mask: disabling DMA

It's because swiotlb_dma_supported() only checks the swiotlb range,
and the 24bit DMA mask is below io_tlb_end.  OTOH, in the past kernel
versions, x86's swiotlb dma_supported() was NULL, which was
effectively evaluated as the direct DMA, hence the lower DMA mask was
allowed.

This patch fixes the regression by extending swiotlb_dma_supported()
to check the direct DMA at first for covering the primary allocation
before swiotlb.

Fixes: 6e4bf5867783 ("x86/dma: Use generic swiotlb_ops")
Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
 lib/swiotlb.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/lib/swiotlb.c b/lib/swiotlb.c
index de7cc540450f..a81502ea79e7 100644
--- a/lib/swiotlb.c
+++ b/lib/swiotlb.c
@@ -1042,6 +1042,10 @@ swiotlb_dma_mapping_error(struct device *hwdev, dma_addr_t dma_addr)
 int
 swiotlb_dma_supported(struct device *hwdev, u64 mask)
 {
+#ifdef CONFIG_DMA_DIRECT_OPS
+	if (dma_direct_supported(hwdev, mask))
+		return 1;
+#endif
 	return __phys_to_dma(hwdev, io_tlb_end - 1) <= mask;
 }
 
-- 
2.16.3

      parent reply	other threads:[~2018-04-15  9:08 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-15  9:08 [PATCH 0/2] swiotlb: Some regression fixes Takashi Iwai
2018-04-15  9:08 ` [PATCH 1/2] dma-direct: Don't repeat allocation for no-op GFP_DMA Takashi Iwai
2018-04-23 12:54   ` Christoph Hellwig
2018-04-15  9:08 ` Takashi Iwai [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180415090808.19121-3-tiwai@suse.de \
    --to=tiwai@suse.de \
    --cc=hch@lst.de \
    --cc=iommu@lists.linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®