From: Christoph Hellwig <hch@lst.de>
To: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Cc: Tom Lendacky <thomas.lendacky@amd.com>,
Thomas Bogendoerfer <tsbogend@alpha.franken.de>,
Michael Ellerman <mpe@ellerman.id.au>,
Boris Ostrovsky <boris.ostrovsky@oracle.com>,
Juergen Gross <jgross@suse.com>,
Stefano Stabellini <sstabellini@kernel.org>,
linux-mips@vger.kernel.org, linuxppc-dev@lists.ozlabs.org,
xen-devel@lists.xenproject.org, iommu@lists.linux-foundation.org
Subject: [PATCH 5/7] MIPS/octeon: simplify swiotlb initialization
Date: Thu, 22 Apr 2021 09:19:19 +0200 [thread overview]
Message-ID: <20210422071921.1428607-6-hch@lst.de> (raw)
In-Reply-To: <20210422071921.1428607-1-hch@lst.de>
Just use swiotlb_adjust_size and swiotlb_init to initialize
swiotlb instead of doing a lot of manual work.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
arch/mips/cavium-octeon/dma-octeon.c | 16 ++--------------
arch/mips/include/asm/octeon/pci-octeon.h | 1 -
arch/mips/pci/pci-octeon.c | 2 +-
3 files changed, 3 insertions(+), 16 deletions(-)
diff --git a/arch/mips/cavium-octeon/dma-octeon.c b/arch/mips/cavium-octeon/dma-octeon.c
index 020b8ce5b8ff7c..6bc9ef5e3790ec 100644
--- a/arch/mips/cavium-octeon/dma-octeon.c
+++ b/arch/mips/cavium-octeon/dma-octeon.c
@@ -186,15 +186,12 @@ phys_addr_t dma_to_phys(struct device *dev, dma_addr_t daddr)
return daddr;
}
-char *octeon_swiotlb;
-
void __init plat_swiotlb_setup(void)
{
phys_addr_t start, end;
phys_addr_t max_addr;
phys_addr_t addr_size;
size_t swiotlbsize;
- unsigned long swiotlb_nslabs;
u64 i;
max_addr = 0;
@@ -236,15 +233,6 @@ void __init plat_swiotlb_setup(void)
if (OCTEON_IS_OCTEON2() && max_addr >= 0x100000000ul)
swiotlbsize = 64 * (1<<20);
#endif
- swiotlb_nslabs = swiotlbsize >> IO_TLB_SHIFT;
- swiotlb_nslabs = ALIGN(swiotlb_nslabs, IO_TLB_SEGSIZE);
- swiotlbsize = swiotlb_nslabs << IO_TLB_SHIFT;
-
- octeon_swiotlb = memblock_alloc_low(swiotlbsize, PAGE_SIZE);
- if (!octeon_swiotlb)
- panic("%s: Failed to allocate %zu bytes align=%lx\n",
- __func__, swiotlbsize, PAGE_SIZE);
-
- if (swiotlb_init_with_tbl(octeon_swiotlb, swiotlbsize, 1) == -ENOMEM)
- panic("Cannot allocate SWIOTLB buffer");
+ swiotlb_adjust_size(swiotlbsize);
+ swiotlb_init(false);
}
diff --git a/arch/mips/include/asm/octeon/pci-octeon.h b/arch/mips/include/asm/octeon/pci-octeon.h
index b12d9a3fbfb6c0..a2f20a44fb6143 100644
--- a/arch/mips/include/asm/octeon/pci-octeon.h
+++ b/arch/mips/include/asm/octeon/pci-octeon.h
@@ -64,6 +64,5 @@ enum octeon_dma_bar_type {
extern enum octeon_dma_bar_type octeon_dma_bar_type;
void octeon_pci_dma_init(void);
-extern char *octeon_swiotlb;
#endif
diff --git a/arch/mips/pci/pci-octeon.c b/arch/mips/pci/pci-octeon.c
index fc29b85cfa926d..ff26cd9dc083f6 100644
--- a/arch/mips/pci/pci-octeon.c
+++ b/arch/mips/pci/pci-octeon.c
@@ -664,7 +664,7 @@ static int __init octeon_pci_setup(void)
/* BAR1 movable regions contiguous to cover the swiotlb */
octeon_bar1_pci_phys =
- virt_to_phys(octeon_swiotlb) & ~((1ull << 22) - 1);
+ io_tlb_default_mem->start & ~((1ull << 22) - 1);
for (index = 0; index < 32; index++) {
union cvmx_pci_bar1_indexx bar1_index;
--
2.30.1
next prev parent reply other threads:[~2021-04-22 7:20 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-22 7:19 cleanup and fix swiotlb sizing Christoph Hellwig
2021-04-22 7:19 ` [PATCH 1/7] swiotlb: pass bytes instead of nslabs to swiotlb_init_with_tbl Christoph Hellwig
2021-04-22 7:19 ` [PATCH 2/7] swiotlb: use swiotlb_size_or_default in swiotlb_init Christoph Hellwig
2021-04-22 7:19 ` [PATCH 3/7] swiotlb: use swiotlb_adjust_size in setup_io_tlb_npages Christoph Hellwig
2021-04-22 7:19 ` [PATCH 4/7] powerpc/pseries: simplify svm_swiotlb_init Christoph Hellwig
2021-04-22 7:19 ` Christoph Hellwig [this message]
2021-04-22 7:19 ` [PATCH 6/7] swiotlb: replace default_nslabs with a byte value Christoph Hellwig
2021-04-22 7:19 ` [PATCH 7/7] swiotlb: don't override the command line in swiotlb_adjust_size Christoph Hellwig
2021-04-23 5:23 ` Tom Lendacky
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=20210422071921.1428607-6-hch@lst.de \
--to=hch@lst.de \
--cc=boris.ostrovsky@oracle.com \
--cc=iommu@lists.linux-foundation.org \
--cc=jgross@suse.com \
--cc=konrad.wilk@oracle.com \
--cc=linux-mips@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=mpe@ellerman.id.au \
--cc=sstabellini@kernel.org \
--cc=thomas.lendacky@amd.com \
--cc=tsbogend@alpha.franken.de \
--cc=xen-devel@lists.xenproject.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).