linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* get rid of dma_max_pfn
@ 2019-06-25  9:20 Christoph Hellwig
  2019-06-25  9:20 ` [PATCH 1/2] mmc: let the dma map ops handle bouncing Christoph Hellwig
  2019-06-25  9:20 ` [PATCH 2/2] dma-mapping: remove dma_max_pfn Christoph Hellwig
  0 siblings, 2 replies; 8+ messages in thread
From: Christoph Hellwig @ 2019-06-25  9:20 UTC (permalink / raw)
  To: Ulf Hansson
  Cc: Russell King, linux-mmc, linux-arm-kernel, iommu, linux-kernel

Hi everyone,

I though I got rid of all non-highmem, non-ISA block layer bounce
buffering a while ago, but I missed the MMC case.  While I still plan to
also kill off the highmem bouncing there I won't get to it this merge
window, so for now I'd like to make some progress and move MMC to the
DMA layer (swiotlb or arm dmabounce) bouncing for addressing limitations
and kill off the dma_max_pfn helper.

I'm fine with merging this through the mmc tree if it suits everyone.

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

* [PATCH 1/2] mmc: let the dma map ops handle bouncing
  2019-06-25  9:20 get rid of dma_max_pfn Christoph Hellwig
@ 2019-06-25  9:20 ` Christoph Hellwig
  2019-07-08 11:55   ` Ulf Hansson
  2019-06-25  9:20 ` [PATCH 2/2] dma-mapping: remove dma_max_pfn Christoph Hellwig
  1 sibling, 1 reply; 8+ messages in thread
From: Christoph Hellwig @ 2019-06-25  9:20 UTC (permalink / raw)
  To: Ulf Hansson
  Cc: Russell King, linux-mmc, linux-arm-kernel, iommu, linux-kernel

Just like we do for all other block drivers.  Especially as the limit
imposed at the moment might be way to pessimistic for iommus.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 drivers/mmc/core/queue.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/mmc/core/queue.c b/drivers/mmc/core/queue.c
index 3557d5c51141..e327f80ebe70 100644
--- a/drivers/mmc/core/queue.c
+++ b/drivers/mmc/core/queue.c
@@ -350,18 +350,15 @@ static const struct blk_mq_ops mmc_mq_ops = {
 static void mmc_setup_queue(struct mmc_queue *mq, struct mmc_card *card)
 {
 	struct mmc_host *host = card->host;
-	u64 limit = BLK_BOUNCE_HIGH;
 	unsigned block_size = 512;
 
-	if (mmc_dev(host)->dma_mask && *mmc_dev(host)->dma_mask)
-		limit = (u64)dma_max_pfn(mmc_dev(host)) << PAGE_SHIFT;
-
 	blk_queue_flag_set(QUEUE_FLAG_NONROT, mq->queue);
 	blk_queue_flag_clear(QUEUE_FLAG_ADD_RANDOM, mq->queue);
 	if (mmc_can_erase(card))
 		mmc_queue_setup_discard(mq->queue, card);
 
-	blk_queue_bounce_limit(mq->queue, limit);
+	if (!mmc_dev(host)->dma_mask || !*mmc_dev(host)->dma_mask)
+		blk_queue_bounce_limit(mq->queue, BLK_BOUNCE_HIGH);
 	blk_queue_max_hw_sectors(mq->queue,
 		min(host->max_blk_count, host->max_req_size / 512));
 	blk_queue_max_segments(mq->queue, host->max_segs);
-- 
2.20.1


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

* [PATCH 2/2] dma-mapping: remove dma_max_pfn
  2019-06-25  9:20 get rid of dma_max_pfn Christoph Hellwig
  2019-06-25  9:20 ` [PATCH 1/2] mmc: let the dma map ops handle bouncing Christoph Hellwig
@ 2019-06-25  9:20 ` Christoph Hellwig
  2019-06-25 11:45   ` Marc Gonzalez
  2019-07-08 11:55   ` Ulf Hansson
  1 sibling, 2 replies; 8+ messages in thread
From: Christoph Hellwig @ 2019-06-25  9:20 UTC (permalink / raw)
  To: Ulf Hansson
  Cc: Russell King, linux-mmc, linux-arm-kernel, iommu, linux-kernel

These days the DMA mapping code must bounce buffer for any not supported
address, and if they driver needs to optimize for natively supported
ranged it should use dma_get_required_mask.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 arch/arm/include/asm/dma-mapping.h | 7 -------
 include/linux/dma-mapping.h        | 7 -------
 2 files changed, 14 deletions(-)

diff --git a/arch/arm/include/asm/dma-mapping.h b/arch/arm/include/asm/dma-mapping.h
index 03ba90ffc0f8..7e0486ad1318 100644
--- a/arch/arm/include/asm/dma-mapping.h
+++ b/arch/arm/include/asm/dma-mapping.h
@@ -89,13 +89,6 @@ static inline dma_addr_t virt_to_dma(struct device *dev, void *addr)
 }
 #endif
 
-/* The ARM override for dma_max_pfn() */
-static inline unsigned long dma_max_pfn(struct device *dev)
-{
-	return dma_to_pfn(dev, *dev->dma_mask);
-}
-#define dma_max_pfn(dev) dma_max_pfn(dev)
-
 /* do not use this function in a driver */
 static inline bool is_device_dma_coherent(struct device *dev)
 {
diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h
index 6309a721394b..8d13e28a8e07 100644
--- a/include/linux/dma-mapping.h
+++ b/include/linux/dma-mapping.h
@@ -729,13 +729,6 @@ static inline int dma_set_seg_boundary(struct device *dev, unsigned long mask)
 	return -EIO;
 }
 
-#ifndef dma_max_pfn
-static inline unsigned long dma_max_pfn(struct device *dev)
-{
-	return (*dev->dma_mask >> PAGE_SHIFT) + dev->dma_pfn_offset;
-}
-#endif
-
 static inline int dma_get_cache_alignment(void)
 {
 #ifdef ARCH_DMA_MINALIGN
-- 
2.20.1


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

* Re: [PATCH 2/2] dma-mapping: remove dma_max_pfn
  2019-06-25  9:20 ` [PATCH 2/2] dma-mapping: remove dma_max_pfn Christoph Hellwig
@ 2019-06-25 11:45   ` Marc Gonzalez
  2019-06-28  6:00     ` Christoph Hellwig
  2019-07-08 11:55   ` Ulf Hansson
  1 sibling, 1 reply; 8+ messages in thread
From: Marc Gonzalez @ 2019-06-25 11:45 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: LKML, Ulf Hansson

Hello Christoph,

There are some typos in the commit message that make it harder
(for me) to parse.

On 25/06/2019 11:20, Christoph Hellwig wrote:

> These days the DMA mapping code must bounce buffer for any not supported

Add comma after "These days" ?
s/must bounce buffer/must bounce buffers/ ?
s/not supported/unsupported/ ?

> address, and if they driver needs to optimize for natively supported

s/if they driver/if the driver/ ?

> ranged it should use dma_get_required_mask.

s/ranged it should/ranges, then it should/ ?

Regards.

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

* Re: [PATCH 2/2] dma-mapping: remove dma_max_pfn
  2019-06-25 11:45   ` Marc Gonzalez
@ 2019-06-28  6:00     ` Christoph Hellwig
  0 siblings, 0 replies; 8+ messages in thread
From: Christoph Hellwig @ 2019-06-28  6:00 UTC (permalink / raw)
  To: Marc Gonzalez; +Cc: Christoph Hellwig, LKML, Ulf Hansson

On Tue, Jun 25, 2019 at 01:45:38PM +0200, Marc Gonzalez wrote:
> Hello Christoph,
> 
> There are some typos in the commit message that make it harder
> (for me) to parse.

The fixes looks good to me.  Ulf, do you want me to resend?

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

* Re: [PATCH 1/2] mmc: let the dma map ops handle bouncing
  2019-06-25  9:20 ` [PATCH 1/2] mmc: let the dma map ops handle bouncing Christoph Hellwig
@ 2019-07-08 11:55   ` Ulf Hansson
  0 siblings, 0 replies; 8+ messages in thread
From: Ulf Hansson @ 2019-07-08 11:55 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Russell King, linux-mmc, Linux ARM,
	list@263.net:IOMMU DRIVERS
	<iommu@lists.linux-foundation.org>,
	Joerg Roedel <joro@8bytes.org>,,
	Linux Kernel Mailing List

On Tue, 25 Jun 2019 at 11:21, Christoph Hellwig <hch@lst.de> wrote:
>
> Just like we do for all other block drivers.  Especially as the limit
> imposed at the moment might be way to pessimistic for iommus.
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>

From your earlier reply, I decided to fold in the following
information to the changelog, as to clarify things a bit:

"This also means we are not going to set a bounce limit for the queue, in
case we have a dma mask. On most architectures it was never needed, the
major hold out was x86-32 with PAE, but that has been fixed by now."

Please tell, if you want me to change something.

Applied for next, thanks!

Kind regards
Uffe


> ---
>  drivers/mmc/core/queue.c | 7 ++-----
>  1 file changed, 2 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/mmc/core/queue.c b/drivers/mmc/core/queue.c
> index 3557d5c51141..e327f80ebe70 100644
> --- a/drivers/mmc/core/queue.c
> +++ b/drivers/mmc/core/queue.c
> @@ -350,18 +350,15 @@ static const struct blk_mq_ops mmc_mq_ops = {
>  static void mmc_setup_queue(struct mmc_queue *mq, struct mmc_card *card)
>  {
>         struct mmc_host *host = card->host;
> -       u64 limit = BLK_BOUNCE_HIGH;
>         unsigned block_size = 512;
>
> -       if (mmc_dev(host)->dma_mask && *mmc_dev(host)->dma_mask)
> -               limit = (u64)dma_max_pfn(mmc_dev(host)) << PAGE_SHIFT;
> -
>         blk_queue_flag_set(QUEUE_FLAG_NONROT, mq->queue);
>         blk_queue_flag_clear(QUEUE_FLAG_ADD_RANDOM, mq->queue);
>         if (mmc_can_erase(card))
>                 mmc_queue_setup_discard(mq->queue, card);
>
> -       blk_queue_bounce_limit(mq->queue, limit);
> +       if (!mmc_dev(host)->dma_mask || !*mmc_dev(host)->dma_mask)
> +               blk_queue_bounce_limit(mq->queue, BLK_BOUNCE_HIGH);
>         blk_queue_max_hw_sectors(mq->queue,
>                 min(host->max_blk_count, host->max_req_size / 512));
>         blk_queue_max_segments(mq->queue, host->max_segs);
> --
> 2.20.1
>

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

* Re: [PATCH 2/2] dma-mapping: remove dma_max_pfn
  2019-06-25  9:20 ` [PATCH 2/2] dma-mapping: remove dma_max_pfn Christoph Hellwig
  2019-06-25 11:45   ` Marc Gonzalez
@ 2019-07-08 11:55   ` Ulf Hansson
  1 sibling, 0 replies; 8+ messages in thread
From: Ulf Hansson @ 2019-07-08 11:55 UTC (permalink / raw)
  To: Christoph Hellwig, Marc Gonzalez
  Cc: Russell King, linux-mmc, Linux ARM,
	list@263.net:IOMMU DRIVERS
	<iommu@lists.linux-foundation.org>,
	Joerg Roedel <joro@8bytes.org>,,
	Linux Kernel Mailing List

On Tue, 25 Jun 2019 at 11:21, Christoph Hellwig <hch@lst.de> wrote:
>
> These days the DMA mapping code must bounce buffer for any not supported
> address, and if they driver needs to optimize for natively supported
> ranged it should use dma_get_required_mask.
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>

Applied for next, by amending the changelog according to suggestions
from Marc, thanks!

I also decided to consider to the reply from Marc (with the changes
made) as an ack, so added a tag for that.

If there are any objections, from anyone, please tell now.

Kind regards
Uffe


> ---
>  arch/arm/include/asm/dma-mapping.h | 7 -------
>  include/linux/dma-mapping.h        | 7 -------
>  2 files changed, 14 deletions(-)
>
> diff --git a/arch/arm/include/asm/dma-mapping.h b/arch/arm/include/asm/dma-mapping.h
> index 03ba90ffc0f8..7e0486ad1318 100644
> --- a/arch/arm/include/asm/dma-mapping.h
> +++ b/arch/arm/include/asm/dma-mapping.h
> @@ -89,13 +89,6 @@ static inline dma_addr_t virt_to_dma(struct device *dev, void *addr)
>  }
>  #endif
>
> -/* The ARM override for dma_max_pfn() */
> -static inline unsigned long dma_max_pfn(struct device *dev)
> -{
> -       return dma_to_pfn(dev, *dev->dma_mask);
> -}
> -#define dma_max_pfn(dev) dma_max_pfn(dev)
> -
>  /* do not use this function in a driver */
>  static inline bool is_device_dma_coherent(struct device *dev)
>  {
> diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h
> index 6309a721394b..8d13e28a8e07 100644
> --- a/include/linux/dma-mapping.h
> +++ b/include/linux/dma-mapping.h
> @@ -729,13 +729,6 @@ static inline int dma_set_seg_boundary(struct device *dev, unsigned long mask)
>         return -EIO;
>  }
>
> -#ifndef dma_max_pfn
> -static inline unsigned long dma_max_pfn(struct device *dev)
> -{
> -       return (*dev->dma_mask >> PAGE_SHIFT) + dev->dma_pfn_offset;
> -}
> -#endif
> -
>  static inline int dma_get_cache_alignment(void)
>  {
>  #ifdef ARCH_DMA_MINALIGN
> --
> 2.20.1
>

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

* [PATCH 2/2] dma-mapping: remove dma_max_pfn
  2019-04-11  7:09 get rid of dma_max_pfn Christoph Hellwig
@ 2019-04-11  7:09 ` Christoph Hellwig
  0 siblings, 0 replies; 8+ messages in thread
From: Christoph Hellwig @ 2019-04-11  7:09 UTC (permalink / raw)
  To: Ulf Hansson
  Cc: Russell King, linux-mmc, linux-arm-kernel, iommu, linux-kernel

These days the DMA mapping code must bounce buffer for any not supported
address, and if they driver needs to optimize for natively supported
ranged it should use dma_get_required_mask.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 arch/arm/include/asm/dma-mapping.h | 7 -------
 include/linux/dma-mapping.h        | 7 -------
 2 files changed, 14 deletions(-)

diff --git a/arch/arm/include/asm/dma-mapping.h b/arch/arm/include/asm/dma-mapping.h
index 03ba90ffc0f8..7e0486ad1318 100644
--- a/arch/arm/include/asm/dma-mapping.h
+++ b/arch/arm/include/asm/dma-mapping.h
@@ -89,13 +89,6 @@ static inline dma_addr_t virt_to_dma(struct device *dev, void *addr)
 }
 #endif
 
-/* The ARM override for dma_max_pfn() */
-static inline unsigned long dma_max_pfn(struct device *dev)
-{
-	return dma_to_pfn(dev, *dev->dma_mask);
-}
-#define dma_max_pfn(dev) dma_max_pfn(dev)
-
 /* do not use this function in a driver */
 static inline bool is_device_dma_coherent(struct device *dev)
 {
diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h
index 75e60be91e5f..6976d36c05de 100644
--- a/include/linux/dma-mapping.h
+++ b/include/linux/dma-mapping.h
@@ -729,13 +729,6 @@ static inline int dma_set_seg_boundary(struct device *dev, unsigned long mask)
 	return -EIO;
 }
 
-#ifndef dma_max_pfn
-static inline unsigned long dma_max_pfn(struct device *dev)
-{
-	return (*dev->dma_mask >> PAGE_SHIFT) + dev->dma_pfn_offset;
-}
-#endif
-
 static inline int dma_get_cache_alignment(void)
 {
 #ifdef ARCH_DMA_MINALIGN
-- 
2.20.1


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

end of thread, other threads:[~2019-07-08 11:56 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-25  9:20 get rid of dma_max_pfn Christoph Hellwig
2019-06-25  9:20 ` [PATCH 1/2] mmc: let the dma map ops handle bouncing Christoph Hellwig
2019-07-08 11:55   ` Ulf Hansson
2019-06-25  9:20 ` [PATCH 2/2] dma-mapping: remove dma_max_pfn Christoph Hellwig
2019-06-25 11:45   ` Marc Gonzalez
2019-06-28  6:00     ` Christoph Hellwig
2019-07-08 11:55   ` Ulf Hansson
  -- strict thread matches above, loose matches on Subject: below --
2019-04-11  7:09 get rid of dma_max_pfn Christoph Hellwig
2019-04-11  7:09 ` [PATCH 2/2] dma-mapping: remove dma_max_pfn Christoph Hellwig

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).