iommu.lists.linux-foundation.org archive mirror
 help / color / mirror / Atom feed
From: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
To: Christoph Hellwig <hch@lst.de>, Amit Pundir <amit.pundir@linaro.org>
Cc: iommu@lists.linux-foundation.org,
	Robin Murphy <robin.murphy@arm.com>,
	linux-rpi-kernel@lists.infradead.org, jeremy.linton@arm.com,
	David Rientjes <rientjes@google.com>
Subject: Re: [PATCH 1/2] dma-pool: fix coherent pool allocations for IOMMU mappings
Date: Tue, 28 Jul 2020 16:56:29 +0200	[thread overview]
Message-ID: <0c602a1d887d0fe38857e21aa963d51f5c772661.camel@suse.de> (raw)
In-Reply-To: <20200728104742.422960-2-hch@lst.de>


[-- Attachment #1.1: Type: text/plain, Size: 1475 bytes --]

On Tue, 2020-07-28 at 12:47 +0200, Christoph Hellwig wrote:
> When allocating coherent pool memory for an IOMMU mapping we don't care
> about the DMA mask.  Move the guess for the initial GFP mask into the
> dma_direct_alloc_pages and pass dma_coherent_ok as a function pointer
> argument so that it doesn't get applied to the IOMMU case.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
>  drivers/iommu/dma-iommu.c   |   4 +-
>  include/linux/dma-direct.h  |   3 -
>  include/linux/dma-mapping.h |   5 +-
>  kernel/dma/direct.c         |  13 ++--
>  kernel/dma/pool.c           | 114 +++++++++++++++---------------------
>  5 files changed, 62 insertions(+), 77 deletions(-)
> 

[...]

> -static inline struct gen_pool *dma_get_safer_pool(struct gen_pool *bad_pool)
> +static struct page *__dma_alloc_from_pool(struct device *dev, size_t size,
> +		struct gen_pool *pool, void **cpu_addr,
> +		bool (*phys_addr_ok)(struct device *, phys_addr_t, size_t))
>  {
> -	if (bad_pool == atomic_pool_kernel)
> -		return atomic_pool_dma32 ? : atomic_pool_dma;
> +	unsigned long addr;
> +	phys_addr_t phys;
>  
> -	if (bad_pool == atomic_pool_dma32)
> -		return atomic_pool_dma;
> +	addr = gen_pool_alloc(pool, size);
> +	if (!addr)
> +		return NULL;
>  
> -	return NULL;
> -}
> +	phys = gen_pool_virt_to_phys(pool, addr);
> +	if (!phys_addr_ok(dev, phys, size)) {

Shoudn't we check if phys_addr_ok() != NULL?

Regards,
Nicolas



[-- Attachment #1.2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

[-- Attachment #2: Type: text/plain, Size: 156 bytes --]

_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

  reply	other threads:[~2020-07-28 14:56 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-28 10:47 dma-pool fixes Christoph Hellwig
2020-07-28 10:47 ` [PATCH 1/2] dma-pool: fix coherent pool allocations for IOMMU mappings Christoph Hellwig
2020-07-28 14:56   ` Nicolas Saenz Julienne [this message]
2020-07-28 15:28     ` Christoph Hellwig
2020-07-28 10:47 ` [PATCH 2/2] dma-pool: Only allocate from CMA when in same memory zone Christoph Hellwig
2020-07-28 12:02 ` dma-pool fixes Amit Pundir
2020-07-28 12:07   ` Christoph Hellwig
2020-07-28 12:25     ` Amit Pundir
2020-07-28 12:41       ` Christoph Hellwig
2020-07-28 12:48         ` Amit Pundir
2020-07-28 15:30           ` Christoph Hellwig
2020-07-29 10:45             ` Nicolas Saenz Julienne
2020-07-29 12:22               ` Amit Pundir
2020-07-31  7:46                 ` Amit Pundir
2020-07-31 13:09                   ` Christoph Hellwig
2020-07-31 14:15                     ` Amit Pundir
2020-07-31 19:04                     ` David Rientjes via iommu
2020-08-01  8:20                       ` David Rientjes via iommu
2020-08-01  8:57                         ` revert scope for 5.8, was " Christoph Hellwig
2020-08-01 11:57                           ` Amit Pundir
2020-08-01 16:59                             ` Nicolas Saenz Julienne
2020-08-01 17:39                             ` Christoph Hellwig
2020-08-02  4:46                               ` Amit Pundir
2020-08-02 15:04                                 ` Amit Pundir
2020-08-03  4:14                                   ` David Rientjes via iommu
2020-08-03  6:44                                     ` Christoph Hellwig
2020-08-03 18:30                                       ` David Rientjes via iommu
2020-08-01 18:28                             ` Linus Torvalds
2020-08-02  4:35                               ` Amit Pundir
2020-08-01  8:29                       ` Christoph Hellwig
2020-07-31 10:47                 ` Nicolas Saenz Julienne
2020-07-31 11:17                   ` Amit Pundir
2020-07-31 14:15                     ` Nicolas Saenz Julienne
2020-07-31 14:20                       ` Amit Pundir
2020-08-01  7:34                         ` Amit Pundir

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=0c602a1d887d0fe38857e21aa963d51f5c772661.camel@suse.de \
    --to=nsaenzjulienne@suse.de \
    --cc=amit.pundir@linaro.org \
    --cc=hch@lst.de \
    --cc=iommu@lists.linux-foundation.org \
    --cc=jeremy.linton@arm.com \
    --cc=linux-rpi-kernel@lists.infradead.org \
    --cc=rientjes@google.com \
    --cc=robin.murphy@arm.com \
    /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;
as well as URLs for NNTP newsgroup(s).