All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alexey Kardashevskiy <aik@ozlabs.ru>
To: Christoph Hellwig <hch@lst.de>
Cc: iommu@lists.linux-foundation.org, linuxppc-dev@lists.ozlabs.org,
	Lu Baolu <baolu.lu@linux.intel.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Joerg Roedel <joro@8bytes.org>,
	Robin Murphy <robin.murphy@arm.com>,
	linux-kernel@vger.kernel.org,
	"Aneesh Kumar K.V" <aneesh.kumar@linux.ibm.com>
Subject: Re: [PATCH 1/2] dma-mapping: add a dma_ops_bypass flag to struct device
Date: Mon, 23 Mar 2020 19:58:01 +1100	[thread overview]
Message-ID: <37ce1b7e-264d-292d-32b1-093b24b3525c@ozlabs.ru> (raw)
In-Reply-To: <20200323083705.GA31245@lst.de>



On 23/03/2020 19:37, Christoph Hellwig wrote:
> On Mon, Mar 23, 2020 at 12:28:34PM +1100, Alexey Kardashevskiy wrote:
> 
> [full quote deleted, please follow proper quoting rules]
> 
>>> +static bool dma_alloc_direct(struct device *dev, const struct dma_map_ops *ops)
>>> +{
>>> +	if (!ops)
>>> +		return true;
>>> +
>>> +	/*
>>> +	 * Allows IOMMU drivers to bypass dynamic translations if the DMA mask
>>> +	 * is large enough.
>>> +	 */
>>> +	if (dev->dma_ops_bypass) {
>>> +		if (min_not_zero(dev->coherent_dma_mask, dev->bus_dma_limit) >=
>>> +				dma_direct_get_required_mask(dev))
>>> +			return true;
>>> +	}
>>
>>
>> Why not do this in dma_map_direct() as well?
> 
> Mostly beacuse it is a relatively expensive operation, including a
> fls64.

Ah, ok.

>> Or simply have just one dma_map_direct()?
> 
> What do you mean with that?

I mean use dma_alloc_direct() instead of dma_map_direct() everywhere,
you explained just above.

> 
>> And one more general question - we need a way to use non-direct IOMMU
>> for RAM above certain limit.
>>
>> Let's say we have a system with:
>> 0 .. 0x1.0000.0000
>> 0x100.0000.0000 .. 0x101.0000.0000
>>
>> 2x4G, each is 1TB aligned. And we can map directly only the first 4GB
>> (because of the maximum IOMMU table size) but not the other. And 1:1 on
>> that "pseries" is done with offset=0x0800.0000.0000.0000.
>>
>> So we want to check every bus address against dev->bus_dma_limit, not
>> dev->coherent_dma_mask. In the example above I'd set bus_dma_limit to
>> 0x0800.0001.0000.0000 and 1:1 mapping for the second 4GB would not be
>> tried. Does this sound reasonable? Thanks,
> 
> bus_dma_limit is just another limiting factor applied on top of
> coherent_dma_mask or dma_mask respectively.

This is not enough for the task: in my example, I'd set bus limit to
0x0800.0001.0000.0000 but this would disable bypass for all RAM
addresses - the first and the second 4GB blocks.


-- 
Alexey

WARNING: multiple messages have this Message-ID (diff)
From: Alexey Kardashevskiy <aik@ozlabs.ru>
To: Christoph Hellwig <hch@lst.de>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Joerg Roedel <joro@8bytes.org>,
	linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org,
	iommu@lists.linux-foundation.org,
	"Aneesh Kumar K.V" <aneesh.kumar@linux.ibm.com>,
	Robin Murphy <robin.murphy@arm.com>,
	Lu Baolu <baolu.lu@linux.intel.com>
Subject: Re: [PATCH 1/2] dma-mapping: add a dma_ops_bypass flag to struct device
Date: Mon, 23 Mar 2020 19:58:01 +1100	[thread overview]
Message-ID: <37ce1b7e-264d-292d-32b1-093b24b3525c@ozlabs.ru> (raw)
In-Reply-To: <20200323083705.GA31245@lst.de>



On 23/03/2020 19:37, Christoph Hellwig wrote:
> On Mon, Mar 23, 2020 at 12:28:34PM +1100, Alexey Kardashevskiy wrote:
> 
> [full quote deleted, please follow proper quoting rules]
> 
>>> +static bool dma_alloc_direct(struct device *dev, const struct dma_map_ops *ops)
>>> +{
>>> +	if (!ops)
>>> +		return true;
>>> +
>>> +	/*
>>> +	 * Allows IOMMU drivers to bypass dynamic translations if the DMA mask
>>> +	 * is large enough.
>>> +	 */
>>> +	if (dev->dma_ops_bypass) {
>>> +		if (min_not_zero(dev->coherent_dma_mask, dev->bus_dma_limit) >=
>>> +				dma_direct_get_required_mask(dev))
>>> +			return true;
>>> +	}
>>
>>
>> Why not do this in dma_map_direct() as well?
> 
> Mostly beacuse it is a relatively expensive operation, including a
> fls64.

Ah, ok.

>> Or simply have just one dma_map_direct()?
> 
> What do you mean with that?

I mean use dma_alloc_direct() instead of dma_map_direct() everywhere,
you explained just above.

> 
>> And one more general question - we need a way to use non-direct IOMMU
>> for RAM above certain limit.
>>
>> Let's say we have a system with:
>> 0 .. 0x1.0000.0000
>> 0x100.0000.0000 .. 0x101.0000.0000
>>
>> 2x4G, each is 1TB aligned. And we can map directly only the first 4GB
>> (because of the maximum IOMMU table size) but not the other. And 1:1 on
>> that "pseries" is done with offset=0x0800.0000.0000.0000.
>>
>> So we want to check every bus address against dev->bus_dma_limit, not
>> dev->coherent_dma_mask. In the example above I'd set bus_dma_limit to
>> 0x0800.0001.0000.0000 and 1:1 mapping for the second 4GB would not be
>> tried. Does this sound reasonable? Thanks,
> 
> bus_dma_limit is just another limiting factor applied on top of
> coherent_dma_mask or dma_mask respectively.

This is not enough for the task: in my example, I'd set bus limit to
0x0800.0001.0000.0000 but this would disable bypass for all RAM
addresses - the first and the second 4GB blocks.


-- 
Alexey

WARNING: multiple messages have this Message-ID (diff)
From: Alexey Kardashevskiy <aik@ozlabs.ru>
To: Christoph Hellwig <hch@lst.de>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org,
	iommu@lists.linux-foundation.org,
	"Aneesh Kumar K.V" <aneesh.kumar@linux.ibm.com>,
	Robin Murphy <robin.murphy@arm.com>
Subject: Re: [PATCH 1/2] dma-mapping: add a dma_ops_bypass flag to struct device
Date: Mon, 23 Mar 2020 19:58:01 +1100	[thread overview]
Message-ID: <37ce1b7e-264d-292d-32b1-093b24b3525c@ozlabs.ru> (raw)
In-Reply-To: <20200323083705.GA31245@lst.de>



On 23/03/2020 19:37, Christoph Hellwig wrote:
> On Mon, Mar 23, 2020 at 12:28:34PM +1100, Alexey Kardashevskiy wrote:
> 
> [full quote deleted, please follow proper quoting rules]
> 
>>> +static bool dma_alloc_direct(struct device *dev, const struct dma_map_ops *ops)
>>> +{
>>> +	if (!ops)
>>> +		return true;
>>> +
>>> +	/*
>>> +	 * Allows IOMMU drivers to bypass dynamic translations if the DMA mask
>>> +	 * is large enough.
>>> +	 */
>>> +	if (dev->dma_ops_bypass) {
>>> +		if (min_not_zero(dev->coherent_dma_mask, dev->bus_dma_limit) >=
>>> +				dma_direct_get_required_mask(dev))
>>> +			return true;
>>> +	}
>>
>>
>> Why not do this in dma_map_direct() as well?
> 
> Mostly beacuse it is a relatively expensive operation, including a
> fls64.

Ah, ok.

>> Or simply have just one dma_map_direct()?
> 
> What do you mean with that?

I mean use dma_alloc_direct() instead of dma_map_direct() everywhere,
you explained just above.

> 
>> And one more general question - we need a way to use non-direct IOMMU
>> for RAM above certain limit.
>>
>> Let's say we have a system with:
>> 0 .. 0x1.0000.0000
>> 0x100.0000.0000 .. 0x101.0000.0000
>>
>> 2x4G, each is 1TB aligned. And we can map directly only the first 4GB
>> (because of the maximum IOMMU table size) but not the other. And 1:1 on
>> that "pseries" is done with offset=0x0800.0000.0000.0000.
>>
>> So we want to check every bus address against dev->bus_dma_limit, not
>> dev->coherent_dma_mask. In the example above I'd set bus_dma_limit to
>> 0x0800.0001.0000.0000 and 1:1 mapping for the second 4GB would not be
>> tried. Does this sound reasonable? Thanks,
> 
> bus_dma_limit is just another limiting factor applied on top of
> coherent_dma_mask or dma_mask respectively.

This is not enough for the task: in my example, I'd set bus limit to
0x0800.0001.0000.0000 but this would disable bypass for all RAM
addresses - the first and the second 4GB blocks.


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

  parent reply	other threads:[~2020-03-23  8:58 UTC|newest]

Thread overview: 94+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-20 14:16 generic DMA bypass flag v2 Christoph Hellwig
2020-03-20 14:16 ` Christoph Hellwig
2020-03-20 14:16 ` Christoph Hellwig
2020-03-20 14:16 ` [PATCH 1/2] dma-mapping: add a dma_ops_bypass flag to struct device Christoph Hellwig
2020-03-20 14:16   ` Christoph Hellwig
2020-03-20 14:16   ` Christoph Hellwig
2020-03-20 15:02   ` Greg Kroah-Hartman
2020-03-20 15:02     ` Greg Kroah-Hartman
2020-03-20 15:02     ` Greg Kroah-Hartman
2020-03-23  1:28   ` Alexey Kardashevskiy
2020-03-23  1:28     ` Alexey Kardashevskiy
2020-03-23  1:28     ` Alexey Kardashevskiy
2020-03-23  8:37     ` Christoph Hellwig
2020-03-23  8:37       ` Christoph Hellwig
2020-03-23  8:37       ` Christoph Hellwig
2020-03-23  8:50       ` Christoph Hellwig
2020-03-23  8:50         ` Christoph Hellwig
2020-03-23  8:50         ` Christoph Hellwig
2020-03-23 15:37         ` Aneesh Kumar K.V
2020-03-23 15:37           ` Aneesh Kumar K.V
2020-03-23 15:37           ` Aneesh Kumar K.V
2020-03-23 17:22           ` Christoph Hellwig
2020-03-23 17:22             ` Christoph Hellwig
2020-03-23 17:22             ` Christoph Hellwig
2020-03-24  3:05             ` Alexey Kardashevskiy
2020-03-24  3:05               ` Alexey Kardashevskiy
2020-03-24  3:05               ` Alexey Kardashevskiy
2020-03-24  6:30               ` Aneesh Kumar K.V
2020-03-24  6:30                 ` Aneesh Kumar K.V
2020-03-24  6:30                 ` Aneesh Kumar K.V
2020-03-24  7:55                 ` Christoph Hellwig
2020-03-24  7:55                   ` Christoph Hellwig
2020-03-24  7:55                   ` Christoph Hellwig
2020-03-24  7:54               ` Christoph Hellwig
2020-03-24  7:54                 ` Christoph Hellwig
2020-03-24  7:54                 ` Christoph Hellwig
2020-03-25  4:51                 ` Alexey Kardashevskiy
2020-03-25  4:51                   ` Alexey Kardashevskiy
2020-03-25  4:51                   ` Alexey Kardashevskiy
2020-03-25  8:37                   ` Christoph Hellwig
2020-03-25  8:37                     ` Christoph Hellwig
2020-03-25  8:37                     ` Christoph Hellwig
2020-03-26  1:26                     ` Alexey Kardashevskiy
2020-03-26  1:26                       ` Alexey Kardashevskiy
2020-03-26  1:26                       ` Alexey Kardashevskiy
2020-04-03  8:38                       ` Alexey Kardashevskiy
2020-04-03  8:38                         ` Alexey Kardashevskiy
2020-04-03  8:38                         ` Alexey Kardashevskiy
2020-04-06 11:50                         ` Christoph Hellwig
2020-04-06 11:50                           ` Christoph Hellwig
2020-04-06 11:50                           ` Christoph Hellwig
2020-04-06 13:25                           ` Alexey Kardashevskiy
2020-04-06 13:25                             ` Alexey Kardashevskiy
2020-04-06 13:25                             ` Alexey Kardashevskiy
2020-04-06 17:17                             ` Christoph Hellwig
2020-04-06 17:17                               ` Christoph Hellwig
2020-04-06 17:17                               ` Christoph Hellwig
2020-04-07 10:12                               ` Alexey Kardashevskiy
2020-04-07 10:12                                 ` Alexey Kardashevskiy
2020-04-07 10:12                                 ` Alexey Kardashevskiy
2020-04-14  6:21                                 ` Alexey Kardashevskiy
2020-04-14  6:21                                   ` Alexey Kardashevskiy
2020-04-14  6:21                                   ` Alexey Kardashevskiy
2020-04-14  6:30                                   ` Christoph Hellwig
2020-04-14  6:30                                     ` Christoph Hellwig
2020-04-14  6:30                                     ` Christoph Hellwig
2020-03-23  8:58       ` Alexey Kardashevskiy [this message]
2020-03-23  8:58         ` Alexey Kardashevskiy
2020-03-23  8:58         ` Alexey Kardashevskiy
2020-03-23 17:20         ` Christoph Hellwig
2020-03-23 17:20           ` Christoph Hellwig
2020-03-23 17:20           ` Christoph Hellwig
2020-03-24  3:37           ` Alexey Kardashevskiy
2020-03-24  3:37             ` Alexey Kardashevskiy
2020-03-24  3:37             ` Alexey Kardashevskiy
2020-03-24  4:55             ` Alexey Kardashevskiy
2020-03-24  4:55               ` Alexey Kardashevskiy
2020-03-24  4:55               ` Alexey Kardashevskiy
2020-03-24  7:52             ` Christoph Hellwig
2020-03-24  7:52               ` Christoph Hellwig
2020-03-24  7:52               ` Christoph Hellwig
2020-03-23 12:14   ` Robin Murphy
2020-03-23 12:14     ` Robin Murphy
2020-03-23 12:14     ` Robin Murphy
2020-03-23 12:55     ` Christoph Hellwig
2020-03-23 12:55       ` Christoph Hellwig
2020-03-23 12:55       ` Christoph Hellwig
2020-03-20 14:16 ` [PATCH 2/2] powerpc: use the generic dma_ops_bypass mode Christoph Hellwig
2020-03-20 14:16   ` Christoph Hellwig
2020-03-20 14:16   ` Christoph Hellwig
  -- strict thread matches above, loose matches on Subject: below --
2020-03-24  9:39 [PATCH 1/2] dma-mapping: add a dma_ops_bypass flag to, struct device Christian Zigotzky
2019-11-13 13:37 generic DMA bypass flag Christoph Hellwig
2019-11-13 13:37 ` [PATCH 1/2] dma-mapping: add a dma_ops_bypass flag to struct device Christoph Hellwig
2019-11-13 13:37   ` Christoph Hellwig
2019-11-13 13:37   ` Christoph Hellwig

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=37ce1b7e-264d-292d-32b1-093b24b3525c@ozlabs.ru \
    --to=aik@ozlabs.ru \
    --cc=aneesh.kumar@linux.ibm.com \
    --cc=baolu.lu@linux.intel.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=hch@lst.de \
    --cc=iommu@lists.linux-foundation.org \
    --cc=joro@8bytes.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.