mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
To: David Vrabel <david.vrabel@citrix.com>
Cc: Chen Baozi <cbz@baozis.org>, <stefano.stabellini@eu.citrix.com>,
	<linux-kernel@vger.kernel.org>,
	<linux-arm-kernel@lists.infradead.org>, <xen-devel@lists.xen.org>
Subject: Re: [Xen-devel] [PATCH] xen: Add __GFP_DMA flag when xen_swiotlb_init gets free pages.
Date: Mon, 20 Apr 2015 18:54:22 +0100	[thread overview]
Message-ID: <alpine.DEB.2.02.1504201828380.30125@kaball.uk.xensource.com> (raw)
In-Reply-To: <5534EAE3.8060403@citrix.com>

On Mon, 20 Apr 2015, David Vrabel wrote:
> On 20/04/15 12:07, Chen Baozi wrote:
> > On Mon, Apr 20, 2015 at 11:53:47AM +0100, David Vrabel wrote:
> >> On 20/04/15 11:48, Chen Baozi wrote:
> >>> Make sure that xen_swiotlb_init allocates buffers that is DMA capable.
> >>>
> >>> Signed-off-by: Chen Baozi <baozich@gmail.com>
> >>> ---
> >>>  drivers/xen/swiotlb-xen.c | 3 ++-
> >>>  1 file changed, 2 insertions(+), 1 deletion(-)
> >>>
> >>> diff --git a/drivers/xen/swiotlb-xen.c b/drivers/xen/swiotlb-xen.c
> >>> index 810ad41..7345afd 100644
> >>> --- a/drivers/xen/swiotlb-xen.c
> >>> +++ b/drivers/xen/swiotlb-xen.c
> >>> @@ -235,7 +235,8 @@ retry:
> >>>  #define SLABS_PER_PAGE (1 << (PAGE_SHIFT - IO_TLB_SHIFT))
> >>>  #define IO_TLB_MIN_SLABS ((1<<20) >> IO_TLB_SHIFT)
> >>>  		while ((SLABS_PER_PAGE << order) > IO_TLB_MIN_SLABS) {
> >>> -			xen_io_tlb_start = (void *)__get_free_pages(__GFP_NOWARN, order);
> >>> +			xen_io_tlb_start = (void *)__get_free_pages(
> >>> +						__GFP_NOWARN|__GFP_DMA, order);
> >>
> >> I think this breaks x86 where __GFP_DMA means below 16 MB.  Perhaps you
> >> mean __GFP_DMA32?
> > 
> > __GFP_DMA32 doesn't help on arm64...
> > 
> > I guess there might be conflicts about the meaning of __GFP_DMA between x86 and
> > arm?
> 
> Yes.

This should definitely be done only on ARM and ARM64, as on x86 PVH
assumes the presence of an IOMMU. We need an ifdef.

Also we need to figure out a way to try without GFP_DMA in case no ram
under 4g is available at all, as some arm64 platforms don't have any. Of
course in those cases we don't need to worry about devices and their dma
masks.  Maybe we could use memblock for that? Something like:

    struct memblock_region *reg;
    gfp_t flags = __GFP_NOWARN;

#if defined(CONFIG_ARM) || defined(CONFIG_ARM64)
	for_each_memblock(memory, reg) {
		unsigned long start = memblock_region_memory_base_pfn(reg);

        if (start < 4G) {
            flags |= __GFP_DMA;
            break;
        }
    }
#endif

    [...]

    xen_io_tlb_start = (void *)__get_free_pages(flags, order);
    




> This is also conceptually wrong since it doesn't matter where the pages
> are in PFN space,  but where they are in bus address (MFN) space (which
> is what the subsequent hypercall is required to sort out).

Actually on ARM dom0 is mapped 1:1, so it is the same thing.

  reply	other threads:[~2015-04-20 17:56 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1429526904-27176-1-git-send-email-cbz@baozis.org>
     [not found] ` <5534DABB.5060305@citrix.com>
2015-04-20 11:07   ` Chen Baozi
2015-04-20 12:02     ` David Vrabel
2015-04-20 17:54       ` Stefano Stabellini [this message]
2015-04-21  7:57         ` Ian Campbell
2015-04-21 10:36           ` Stefano Stabellini
2015-04-21 11:05             ` Ian Campbell
2015-04-21 11:11             ` Stefano Stabellini
2015-04-23  2:33               ` Chen Baozi
2015-04-21 12:01             ` Roger Pau Monné

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=alpine.DEB.2.02.1504201828380.30125@kaball.uk.xensource.com \
    --to=stefano.stabellini@eu.citrix.com \
    --cc=cbz@baozis.org \
    --cc=david.vrabel@citrix.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=xen-devel@lists.xen.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

all inboxes | Powered by JetHome®