From: Fredrik Noring <noring@nocrew.org>
To: Christoph Hellwig <hch@lst.de>
Cc: linux-usb@vger.kernel.org,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Subject: Re: [PATCH] USB: Fix incorrect DMA allocations for local memory pool drivers
Date: Tue, 3 Dec 2019 17:54:07 +0100 [thread overview]
Message-ID: <20191203165407.GA4230@sx9> (raw)
In-Reply-To: <20191203073920.GB23881@lst.de>
Hi Christoph,
> > One can also consider unsetting HCD_DMA for local memory pool drivers.
>
> That seems like a good idea to me, as the "local DMA pool" really isn't
> DMA in the traditional sense. The host has to copy data into it by MMIO,
> and it then is accessed by the device.
Perhaps we can combine several enhancements, given that the local memory
pool drivers frequently break with peculiar errors? For example:
1. Arrange localmem_pool and hcd_uses_dma() statements consistently.
Inconsistent ordering was a source of this bug.
2. Make localmem_pool and hcd_uses_dma() mutually exclusive. Allocating
DMA memory was a source of this bug.
3. Introduce hcd_uses_localmem_pool(), as show below, to have it on the
same abstraction level as hcd_uses_dma(). The current localmem_pool
pointer tests throughout the code are not quite as readable.
A minor note: The commit sequence
7b81cb6bddd2 ("usb: add a HCD_DMA flag instead of guestimating DMA capabilities")
5d6ff300f011 ("usb/max3421: remove the dummy {un,}map_urb_for_dma methods")
bd5defaee872 ("dma-mapping: remove is_device_dma_capable")
cdfee5623290 ("driver core: initialize a default DMA mask for platform device")
broke bisection because the first commit 7b81cb6bddd2 crashes with "DMA map
on device without dma_mask", that is fixed in the fourth commit cdfee5623290.
Too late to do anything about that now, though.
Fredrik
diff --git a/include/linux/usb/hcd.h b/include/linux/usb/hcd.h
--- a/include/linux/usb/hcd.h
+++ b/include/linux/usb/hcd.h
@@ -423,6 +423,11 @@ static inline bool hcd_periodic_completion_in_progress(struct usb_hcd *hcd,
return hcd->high_prio_bh.completing_ep == ep;
}
+static inline bool hcd_uses_localmem_pool(struct usb_hcd *hcd)
+{
+ return hcd->localmem_pool != NULL;
+}
+
static inline bool hcd_uses_dma(struct usb_hcd *hcd)
{
return IS_ENABLED(CONFIG_HAS_DMA) && (hcd->driver->flags & HCD_DMA);
next prev parent reply other threads:[~2019-12-03 17:01 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-30 16:50 [PATCH] USB: Fix incorrect DMA allocations for local memory pool drivers Fredrik Noring
2019-12-03 7:39 ` Christoph Hellwig
2019-12-03 16:54 ` Fredrik Noring [this message]
2019-12-03 8:12 ` Johan Hovold
2019-12-03 16:55 ` Fredrik Noring
2019-12-10 11:22 ` Greg Kroah-Hartman
2019-12-10 17:29 ` [PATCH v2] " Fredrik Noring
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=20191203165407.GA4230@sx9 \
--to=noring@nocrew.org \
--cc=gregkh@linuxfoundation.org \
--cc=hch@lst.de \
--cc=linux-usb@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