linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Alan Stern <stern@rowland.harvard.edu>
To: Christoph Hellwig <hch@lst.de>
Cc: Jens Axboe <axboe@kernel.dk>,
	"Martin K. Petersen" <martin.petersen@oracle.com>,
	"Juergen E. Fischer" <fischer@norbit.de>,
	Andrew Morton <akpm@linux-foundation.org>,
	linux-block@vger.kernel.org, linux-scsi@vger.kernel.org,
	linux-usb@vger.kernel.org, usb-storage@lists.one-eyed-alien.net,
	linux-mm@kvack.org
Subject: Re: [usb-storage] [PATCH 4/7] usb-storage: reject probe of device one non-DMA HCDs when using highmem
Date: Fri, 2 May 2025 09:19:25 -0400	[thread overview]
Message-ID: <34cb4621-5275-4c46-b652-01a4a708b4de@rowland.harvard.edu> (raw)
In-Reply-To: <20250502064930.2981820-5-hch@lst.de>

On Fri, May 02, 2025 at 07:49:21AM +0100, Christoph Hellwig wrote:
> usb-storage is the last user of the block layer bounce buffering now,
> and only uses it for HCDs that do not support DMA on highmem configs.
> 
> Remove this support and fail the probe so that the block layer bounce
> buffering can go away.

I'm not certain this reasoning is correct.  The code being changed is 
pretty old; it may be that the relevant HCDs now implement bounce 
buffering on their own.

However, the combination of USB mass storage with these restricted host 
controllers is probably pretty rare.

> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
>  drivers/usb/storage/usb.c | 14 +++++++++-----
>  1 file changed, 9 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/usb/storage/usb.c b/drivers/usb/storage/usb.c
> index d36f3b6992bb..49bbfe4610d5 100644
> --- a/drivers/usb/storage/usb.c
> +++ b/drivers/usb/storage/usb.c
> @@ -1057,12 +1057,15 @@ int usb_stor_probe1(struct us_data **pus,
>  
>  	/*
>  	 * Some USB host controllers can't do DMA; they have to use PIO.

I'd like to see this part of the comment updated:

	 * Some USB host controllers can't do DMA: They have to use PIO,
	 * or they have to use a small dedicated local memory area, or 
	 * they have other restrictions on addressable memory.

That explains the reason for the check of hcd->localmem_pool.

> -	 * For such controllers we need to make sure the block layer sets
> -	 * up bounce buffers in addressable memory.
> +	 * We can't support these controllers on highmem systems as the
> +	 * usb-storage code lacks the code to kmap or bounce buffer.

This looks a little stange.  How about instead:

	... as we don't kmap or bounce buffers.

>  	 */
> -	if (!hcd_uses_dma(bus_to_hcd(us->pusb_dev->bus)) ||
> -	    bus_to_hcd(us->pusb_dev->bus)->localmem_pool)
> -		host->no_highmem = true;
> +	if (IS_ENABLED(CONFIG_HIGHMEM) &&
> +	    (!hcd_uses_dma(bus_to_hcd(us->pusb_dev->bus)) ||
> +	     bus_to_hcd(us->pusb_dev->bus)->localmem_pool)) {
> +		dev_warn(&intf->dev, "USB Mass Storage device not support on this HCD\n");

Please say "host controller" instead of "HCD", and delete "device"
(and say "supported" instead of "support").

More importantly, set result to a negative error value before returning 
so that it won't look like the probe succeeded.

> +		goto release;
> +	}
>  
>  	/* Get the unusual_devs entries and the descriptors */
>  	result = get_device_info(us, id, unusual_dev);
> @@ -1081,6 +1084,7 @@ int usb_stor_probe1(struct us_data **pus,
>  
>  BadDevice:
>  	usb_stor_dbg(us, "storage_probe() failed\n");
> +release:
>  	release_everything(us);
>  	return result;
>  }

Alan Stern


  parent reply	other threads:[~2025-05-02 13:19 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-02  6:49 remove block layer bounce buffering Christoph Hellwig
2025-05-02  6:49 ` [PATCH 1/7] scsi: make aha152x depend on !HIGHMEM Christoph Hellwig
2025-05-02  7:24   ` Hannes Reinecke
2025-05-02  6:49 ` [PATCH 2/7] scsi: make imm " Christoph Hellwig
2025-05-02  7:24   ` Hannes Reinecke
2025-05-02  6:49 ` [PATCH 3/7] scsi: make ppa " Christoph Hellwig
2025-05-02  7:25   ` Hannes Reinecke
2025-05-02  6:49 ` [PATCH 4/7] usb-storage: reject probe of device one non-DMA HCDs when using highmem Christoph Hellwig
2025-05-02  7:02   ` Greg KH
2025-05-02 13:21     ` Alan Stern
2025-05-02  7:25   ` Hannes Reinecke
2025-05-02  8:48   ` Sergey Shtylyov
2025-05-02 13:19   ` Alan Stern [this message]
2025-05-02  6:49 ` [PATCH 5/7] scsi: remove the no_highmem flag in the host Christoph Hellwig
2025-05-02  7:26   ` Hannes Reinecke
2025-05-02  6:49 ` [PATCH 6/7] block: remove bounce buffering support Christoph Hellwig
2025-05-02  7:27   ` Hannes Reinecke
2025-05-02  6:49 ` [PATCH 7/7] mm: remove NR_BOUNCE zone stat Christoph Hellwig
2025-05-02  7:27   ` Hannes Reinecke
2025-05-02  8:43 ` remove block layer bounce buffering Sergey Shtylyov
2025-05-05  8:36 ` Johannes Thumshirn

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=34cb4621-5275-4c46-b652-01a4a708b4de@rowland.harvard.edu \
    --to=stern@rowland.harvard.edu \
    --cc=akpm@linux-foundation.org \
    --cc=axboe@kernel.dk \
    --cc=fischer@norbit.de \
    --cc=hch@lst.de \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=usb-storage@lists.one-eyed-alien.net \
    /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