From: Christoph Hellwig <hch@lst.de>
To: "David S. Miller" <davem@davemloft.net>
Cc: Guenter Roeck <linux@roeck-us.net>,
sparclinux@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 9/9] sparc/iommu: merge iommu_get_one and __sbus_iommu_map_page
Date: Tue, 16 Apr 2019 20:23:47 +0200 [thread overview]
Message-ID: <20190416182347.18441-10-hch@lst.de> (raw)
In-Reply-To: <20190416182347.18441-1-hch@lst.de>
There is only one caller of iommu_get_one left, so merge it into
that one to clean things up a bit.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
arch/sparc/mm/iommu.c | 56 +++++++++++++++++++------------------------
1 file changed, 24 insertions(+), 32 deletions(-)
diff --git a/arch/sparc/mm/iommu.c b/arch/sparc/mm/iommu.c
index 8fbc08d14836..71ac353032b6 100644
--- a/arch/sparc/mm/iommu.c
+++ b/arch/sparc/mm/iommu.c
@@ -175,43 +175,17 @@ static void iommu_flush_iotlb(iopte_t *iopte, unsigned int niopte)
}
}
-static u32 iommu_get_one(struct device *dev, phys_addr_t paddr, int npages)
-{
- struct iommu_struct *iommu = dev->archdata.iommu;
- int ioptex;
- iopte_t *iopte, *iopte0;
- unsigned int busa, busa0;
- unsigned long pfn = __phys_to_pfn(paddr);
- int i;
-
- /* page color = pfn of page */
- ioptex = bit_map_string_get(&iommu->usemap, npages, pfn);
- if (ioptex < 0)
- panic("iommu out");
- busa0 = iommu->start + (ioptex << PAGE_SHIFT);
- iopte0 = &iommu->page_table[ioptex];
-
- busa = busa0;
- iopte = iopte0;
- for (i = 0; i < npages; i++) {
- iopte_val(*iopte) = MKIOPTE(pfn, IOPERM);
- iommu_invalidate_page(iommu->regs, busa);
- busa += PAGE_SIZE;
- iopte++;
- pfn++;
- }
-
- iommu_flush_iotlb(iopte0, npages);
-
- return busa0;
-}
-
static dma_addr_t __sbus_iommu_map_page(struct device *dev, struct page *page,
unsigned long offset, size_t len, bool per_page_flush)
{
+ struct iommu_struct *iommu = dev->archdata.iommu;
phys_addr_t paddr = page_to_phys(page) + offset;
unsigned long off = paddr & ~PAGE_MASK;
unsigned long npages = (off + len + PAGE_SIZE - 1) >> PAGE_SHIFT;
+ unsigned long pfn = __phys_to_pfn(paddr);
+ unsigned int busa, busa0;
+ iopte_t *iopte, *iopte0;
+ int ioptex, i;
/* XXX So what is maxphys for us and how do drivers know it? */
if (!len || len > 256 * 1024)
@@ -230,7 +204,25 @@ static dma_addr_t __sbus_iommu_map_page(struct device *dev, struct page *page,
flush_page_for_dma(p);
}
- return iommu_get_one(dev, paddr, npages) + off;
+ /* page color = pfn of page */
+ ioptex = bit_map_string_get(&iommu->usemap, npages, pfn);
+ if (ioptex < 0)
+ panic("iommu out");
+ busa0 = iommu->start + (ioptex << PAGE_SHIFT);
+ iopte0 = &iommu->page_table[ioptex];
+
+ busa = busa0;
+ iopte = iopte0;
+ for (i = 0; i < npages; i++) {
+ iopte_val(*iopte) = MKIOPTE(pfn, IOPERM);
+ iommu_invalidate_page(iommu->regs, busa);
+ busa += PAGE_SIZE;
+ iopte++;
+ pfn++;
+ }
+
+ iommu_flush_iotlb(iopte0, npages);
+ return busa0 + off;
}
static dma_addr_t sbus_iommu_map_page_gflush(struct device *dev,
--
2.20.1
next prev parent reply other threads:[~2019-04-16 18:24 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-16 18:23 fix SG list handling in the sparc32 iommu driver Christoph Hellwig
2019-04-16 18:23 ` [PATCH 1/9] sparc/iommu: use !PageHighMem to check if a page has a kernel mapping Christoph Hellwig
2019-04-16 18:23 ` [PATCH 2/9] sparc/iommu: use sbus_iommu_unmap_page in sbus_iommu_unmap_sg Christoph Hellwig
2019-04-16 18:23 ` [PATCH 3/9] sparc/iommu: merge iommu_release_one and sbus_iommu_unmap_page Christoph Hellwig
2019-04-16 18:23 ` [PATCH 4/9] sparc/iommu: create a common helper for map_sg Christoph Hellwig
2019-04-16 18:23 ` [PATCH 5/9] sparc/iommu: pass a physical address to iommu_get_one Christoph Hellwig
2019-04-16 18:23 ` [PATCH 6/9] sparc/iommu: move per-page flushing into __sbus_iommu_map_page Christoph Hellwig
2019-04-16 18:23 ` [PATCH 7/9] sparc/iommu: fix __sbus_iommu_map_page for highmem pages Christoph Hellwig
2019-04-16 18:23 ` [PATCH 8/9] sparc/iommu: use __sbus_iommu_map_page to implement the map_sg path Christoph Hellwig
2019-04-16 18:23 ` Christoph Hellwig [this message]
2019-04-16 19:35 ` fix SG list handling in the sparc32 iommu driver Guenter Roeck
2019-04-30 13:17 ` Christoph Hellwig
2019-05-09 0:12 ` David Miller
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=20190416182347.18441-10-hch@lst.de \
--to=hch@lst.de \
--cc=davem@davemloft.net \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=sparclinux@vger.kernel.org \
/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).