LinuxPPC-Dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Alexey Kardashevskiy <aik@ozlabs.ru>
To: Alistair Popple <alistair@popple.id.au>
Cc: Oliver O'Halloran <oohall@gmail.com>,
	linuxppc-dev@lists.ozlabs.org,
	David Gibson <david@gibson.dropbear.id.au>
Subject: Re: [PATCH kernel v2 0/2] powerpc/ioda2: Another attempt to allow DMA masks between 32 and 59
Date: Wed, 1 May 2019 17:28:49 +1000	[thread overview]
Message-ID: <ffc44b1c-ca9d-84c9-e72b-4de51d36900f@ozlabs.ru> (raw)
In-Reply-To: <2637621.o3tU8Khc0e@townsend>



On 01/05/2019 16:09, Alistair Popple wrote:
> Hi Alexey,
> 
> Do we need a seperate patch to allow this to be used? Last time I tried 
> calling dma_set_mask(52) on powernv it returned an error and there doesn't 
> seem to be anything obvious to me in this series to change that behaviour, but 
> perhaps I missed something.


Right now (this could have changed with the Hellwig's patches) when
called with MASK(52), dma_iommu_dma_supported() will select the default
ops and allow any mask. The kernel won't be able to use the entire mask
(since the default window won't be that big) and eventually
dma_map_ops::alloc() will fail when the entire DMA window is used but
this may happen anyway. This patchset does not change this behaviour,
just moves the upper limit for DMA window further up.



https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/powerpc/kernel/dma-iommu.c?h=v5.1-rc7#n117

int dma_iommu_dma_supported(struct device *dev, u64 mask)
{
	struct iommu_table *tbl = get_iommu_table_base(dev);

	if (!tbl) {
		dev_info(dev, "Warning: IOMMU dma not supported: mask 0x%08llx"
			", table unavailable\n", mask);
		return 0;
	}

	if (dev_is_pci(dev) && dma_iommu_bypass_supported(dev, mask)) {
		dev->archdata.iommu_bypass = true;
		dev_dbg(dev, "iommu: 64-bit OK, using fixed ops\n");
		return 1;
	}

	if (tbl->it_offset > (mask >> tbl->it_page_shift)) {
		dev_info(dev, "Warning: IOMMU offset too big for device mask\n");
		dev_info(dev, "mask: 0x%08llx, table offset: 0x%08lx\n",
				mask, tbl->it_offset << tbl->it_page_shift);
		return 0;
	}

	dev_dbg(dev, "iommu: not 64-bit, using default ops\n");
	dev->archdata.iommu_bypass = false;
	return 1;
}


> 
> - Alistair
> 
> On Wednesday, 1 May 2019 3:28:20 PM AEST Alexey Kardashevskiy wrote:
>> This is an attempt to allow DMA masks between 32..59 which are not large
>> enough to use either a PHB3 bypass mode or a sketchy bypass. Depending
>> on the max order, up to 40 is usually available.
>>
>>
>> This is based on sha1
>> 37624b58542f Linus Torvalds "Linux 5.1-rc7".
>>
>> Please comment. Thanks.
>>
>>
>>
>> Alexey Kardashevskiy (2):
>>   powerpc/powernv/ioda2: Allocate TCE table levels on demand for default
>>     DMA window
>>   powerpc/powernv/ioda2: Create bigger default window with 64k IOMMU
>>     pages
>>
>>  arch/powerpc/include/asm/iommu.h              |  8 ++-
>>  arch/powerpc/platforms/powernv/pci.h          |  2 +-
>>  arch/powerpc/kernel/iommu.c                   | 58 +++++++++++++------
>>  arch/powerpc/platforms/powernv/pci-ioda-tce.c | 20 +++----
>>  arch/powerpc/platforms/powernv/pci-ioda.c     | 40 +++++++++++--
>>  5 files changed, 90 insertions(+), 38 deletions(-)
> 
> 

-- 
Alexey

      reply	other threads:[~2019-05-01  7:30 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-01  5:28 [PATCH kernel v2 0/2] powerpc/ioda2: Another attempt to allow DMA masks between 32 and 59 Alexey Kardashevskiy
2019-05-01  5:28 ` [PATCH kernel v2 1/2] powerpc/powernv/ioda2: Allocate TCE table levels on demand for default DMA window Alexey Kardashevskiy
2019-05-01  5:28 ` [PATCH kernel v2 2/2] powerpc/powernv/ioda2: Create bigger default window with 64k IOMMU pages Alexey Kardashevskiy
2019-05-01  6:09 ` [PATCH kernel v2 0/2] powerpc/ioda2: Another attempt to allow DMA masks between 32 and 59 Alistair Popple
2019-05-01  7:28   ` Alexey Kardashevskiy [this message]

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=ffc44b1c-ca9d-84c9-e72b-4de51d36900f@ozlabs.ru \
    --to=aik@ozlabs.ru \
    --cc=alistair@popple.id.au \
    --cc=david@gibson.dropbear.id.au \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=oohall@gmail.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