From: David Gibson <david@gibson.dropbear.id.au>
To: Alexey Kardashevskiy <aik@ozlabs.ru>
Cc: linuxppc-dev@lists.ozlabs.org, kvm-ppc@vger.kernel.org,
kvm@vger.kernel.org, Alex Williamson <alex.williamson@redhat.com>,
Benjamin Herrenschmidt <benh@kernel.crashing.org>
Subject: Re: [PATCH kernel 5/6] powerpc/powernv: Rework TCE level allocation
Date: Tue, 12 Jun 2018 12:40:32 +1000 [thread overview]
Message-ID: <20180612024032.GX2737@umbus.fritz.box> (raw)
In-Reply-To: <20180608054633.18659-6-aik@ozlabs.ru>
[-- Attachment #1: Type: text/plain, Size: 2605 bytes --]
On Fri, Jun 08, 2018 at 03:46:32PM +1000, Alexey Kardashevskiy wrote:
> This moves actual pages allocation to a separate function which is going
> to be reused later in on-demand TCE allocation.
>
> While we are at it, remove unnecessary level size round up as the caller
> does this already.
>
> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
> ---
> arch/powerpc/platforms/powernv/pci-ioda-tce.c | 30 +++++++++++++++++----------
> 1 file changed, 19 insertions(+), 11 deletions(-)
>
> diff --git a/arch/powerpc/platforms/powernv/pci-ioda-tce.c b/arch/powerpc/platforms/powernv/pci-ioda-tce.c
> index f14b282..36c2eb0 100644
> --- a/arch/powerpc/platforms/powernv/pci-ioda-tce.c
> +++ b/arch/powerpc/platforms/powernv/pci-ioda-tce.c
> @@ -31,6 +31,23 @@ void pnv_pci_setup_iommu_table(struct iommu_table *tbl,
> tbl->it_type = TCE_PCI;
> }
>
> +static __be64 *pnv_alloc_tce_level(int nid, unsigned int shift)
> +{
> + struct page *tce_mem = NULL;
> + __be64 *addr;
> +
> + tce_mem = alloc_pages_node(nid, GFP_KERNEL, shift - PAGE_SHIFT);
> + if (!tce_mem) {
> + pr_err("Failed to allocate a TCE memory, level shift=%d\n",
> + shift);
> + return NULL;
> + }
> + addr = page_address(tce_mem);
> + memset(addr, 0, 1UL << shift);
> +
> + return addr;
> +}
> +
> static __be64 *pnv_tce(struct iommu_table *tbl, bool user, long idx)
> {
> __be64 *tmp = user ? tbl->it_userspace : (__be64 *) tbl->it_base;
> @@ -165,21 +182,12 @@ static __be64 *pnv_pci_ioda2_table_do_alloc_pages(int nid, unsigned int shift,
> unsigned int levels, unsigned long limit,
> unsigned long *current_offset, unsigned long *total_allocated)
> {
> - struct page *tce_mem = NULL;
> __be64 *addr, *tmp;
> - unsigned int order = max_t(unsigned int, shift, PAGE_SHIFT) -
> - PAGE_SHIFT;
> - unsigned long allocated = 1UL << (order + PAGE_SHIFT);
> + unsigned long allocated = 1UL << shift;
> unsigned int entries = 1UL << (shift - 3);
> long i;
>
> - tce_mem = alloc_pages_node(nid, GFP_KERNEL, order);
> - if (!tce_mem) {
> - pr_err("Failed to allocate a TCE memory, order=%d\n", order);
> - return NULL;
> - }
> - addr = page_address(tce_mem);
> - memset(addr, 0, allocated);
> + addr = pnv_alloc_tce_level(nid, shift);
> *total_allocated += allocated;
>
> --levels;
--
David Gibson | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2018-06-12 2:40 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-08 5:46 [PATCH kernel 0/6] powerpc/powernv/iommu: Optimize memory use Alexey Kardashevskiy
2018-06-08 5:46 ` [PATCH kernel 1/6] powerpc/powernv: Remove useless wrapper Alexey Kardashevskiy
2018-06-09 2:04 ` David Gibson
2018-06-08 5:46 ` [PATCH kernel 2/6] powerpc/powernv: Move TCE manupulation code to its own file Alexey Kardashevskiy
2018-06-09 2:21 ` David Gibson
2018-06-08 5:46 ` [PATCH kernel 3/6] KVM: PPC: Make iommu_table::it_userspace big endian Alexey Kardashevskiy
2018-06-09 8:53 ` David Gibson
2018-06-08 5:46 ` [PATCH kernel 4/6] powerpc/powernv: Add indirect levels to it_userspace Alexey Kardashevskiy
2018-06-12 2:26 ` David Gibson
2018-06-08 5:46 ` [PATCH kernel 5/6] powerpc/powernv: Rework TCE level allocation Alexey Kardashevskiy
2018-06-12 2:40 ` David Gibson [this message]
2018-06-08 5:46 ` [PATCH kernel 6/6] powerpc/powernv/ioda: Allocate indirect TCE levels on demand Alexey Kardashevskiy
2018-06-12 4:17 ` David Gibson
2018-06-14 6:35 ` Alexey Kardashevskiy
2018-06-14 12:35 ` David Gibson
2018-06-15 7:15 ` Alexey Kardashevskiy
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=20180612024032.GX2737@umbus.fritz.box \
--to=david@gibson.dropbear.id.au \
--cc=aik@ozlabs.ru \
--cc=alex.williamson@redhat.com \
--cc=benh@kernel.crashing.org \
--cc=kvm-ppc@vger.kernel.org \
--cc=kvm@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.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).