public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: David Woodhouse <dwmw2@infradead.org>
To: Dave Airlie <airlied@gmail.com>
Cc: Zhenyu Wang <zhenyu.z.wang@intel.com>,
	linux-kernel@vger.kernel.org, iommu@lists.linux-foundation.org,
	Joerg Roedel <joerg.roedel@amd.com>
Subject: Re: [RFC] Make AGP work with IOMMU
Date: Wed, 29 Jul 2009 10:01:08 +0100	[thread overview]
Message-ID: <1248858068.19733.229.camel@macbook.infradead.org> (raw)
In-Reply-To: <21d7e9970907290143q6778511cvda1c6b915f61654a@mail.gmail.com>

On Wed, 2009-07-29 at 18:43 +1000, Dave Airlie wrote:
> On Wed, Jul 29, 2009 at 5:15 PM, David Woodhouse<dwmw2@infradead.org> wrote:
> > On Wed, 2009-07-29 at 16:28 +1000, Dave Airlie wrote:
> >> Yup pretty much we always got lucky, its not like AGP and IOMMU systems
> >> are a huge item, its really only Intel IGPs which use the AGP
> >> subsystem these days.
> >
> > Ah, really? One thing which was bothering me was what happens when I use
> > non-onboard graphics in one of these beasts -- are individual gfx
> > drivers going to need to be fixed too?
> 
> Yes, more than likely. I think radeon and radeon kms drivers dtrt, at
> least they call pci_map_single for the pages they use in their on-chip
> translation units, and the cards have been used in sparc64 and ppc64
> with iommu stuff happening.

It's going to perform a lot better if we use pci_map_sg() to map as many
pages as possible at once.

> nouveau might work when it gets upstream but it may not.
> 
> Other PCI and/or PCIE1x cards still around would be MGA and SiS based,
> and I suspect they would need work, but they might just work.
>
> nvidia/fglrx binary drivers, who knows.

... or cares.

> >
> >> >                cur_gatt = GET_GATT(addr);
> >> >                writel(agp_generic_mask_memory(agp_bridge,
> >> > -                       mem->pages[i], mem->type), cur_gatt+GET_GATT_OFF(addr));
> >> > +                                              phys_to_gart(page_to_phys(mem->pages[i])),
> >>
> >> don't suppose we want page_to_gart or is the double function nicer?
> >
> > I pondered that briefly. But then observed that phys_to_gart() and
> > gart_to_phys() _always_ describe an identity mapping, so perhaps they
> > could just be ditched completely?
> 
> Yeah that could work too, no idea why they were introduced, well before my time.
> 
> >
> >> > @@ -150,8 +150,17 @@ static int agp_backend_initialize(struct agp_bridge_data *bridge)
> >> >                }
> >> >
> >> >                bridge->scratch_page_real = phys_to_gart(page_to_phys(page));
> >> > -               bridge->scratch_page =
> >> > -                   bridge->driver->mask_memory(bridge, page, 0);
> >> > +               bridge->scratch_page = bridge->driver->mask_memory(bridge,
> >> > +                                          phys_to_gart(page_to_phys(page)), 0);
> >> > +
> >> > +               if (bridge->driver->agp_map_page &&
> >> > +                   bridge->driver->agp_map_page(phys_to_virt(page_to_phys(page)),
> >>
> >> and maybe page_to_virt.
> >
> > That's called page_address(), and it (as well as the above construct) is
> > broken with highmem pages. It's actually OK here, since this page is
> > allocated with GFP_DMA32 -- but for cleanliness' sake I should probably
> > switch agp_map_page() to take a 'struct page *' rather than a virtual
> > address.
> 
> Yes that might be best, having a function called map_page taking an
> address seems wrong.

http://git.infradead.org/users/dwmw2/iommu-agp.git?a=commitdiff;h=71fc2ae5

> >
> >> > +       if ((mem->page_count * sizeof(*mem->sg_list)) < 2*PAGE_SIZE)
> >> > +               mem->sg_list = kcalloc(mem->page_count, sizeof(*mem->sg_list),
> >> > +                                      GFP_KERNEL);
> >> > +
> >> > +       if (mem->sg_list == NULL) {
> >> > +               mem->sg_list = vmalloc(mem->page_count * sizeof(*mem->sg_list));
> >> > +               mem->sg_vmalloc_flag = 1;
> >>
> >> Can we drop vmalloc_flag and use is_vmalloc_addr on the free function?
> >
> > I suppose so -- we could eliminate the other vmalloc_flag field in
> > 'struct agp_memory' that way too? Doesn't shrink the structure any --
> > we'd just end up with padding where the flags were.
> 
> Yeah we should drop both of them maybe I can do that as a cleanup
> after this patch.
> 
> >
> >> (aside: yet another place that wants a kmalloc/vmalloc allocator. I suspect
> >> vmalloc here to be slow but I suppose there isn't much we can do.)
> >
> > http://lwn.net/Articles/342915/ ?
> >
> > In fact, can't scatterlists do something like that already?
> 
> no idea, I think I've seen vmalloc used in other places before.

This fixes it for scatterlists:
http://git.infradead.org/users/dwmw2/iommu-agp.git?a=commitdiff;h=89187864

-- 
David Woodhouse                            Open Source Technology Centre
David.Woodhouse@intel.com                              Intel Corporation


  reply	other threads:[~2009-07-29  9:01 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-07-27 15:04 [RFC] Make AGP work with IOMMU David Woodhouse
2009-07-29  6:28 ` Dave Airlie
2009-07-29  7:15   ` David Woodhouse
2009-07-29  8:43     ` Dave Airlie
2009-07-29  9:01       ` David Woodhouse [this message]
2009-07-29  9:36       ` David Woodhouse
2009-08-03  6:50         ` Zhenyu Wang
2009-08-03  8:39           ` David Woodhouse
2009-08-04 23:52         ` [Xen-devel] " Jeremy Fitzhardinge
2009-08-05  6:44           ` David Woodhouse
2009-08-05  6:57             ` Dave Airlie
2009-08-05  7:08               ` David Woodhouse
2009-08-05 18:26               ` Jeremy Fitzhardinge
2009-08-05 23:12                 ` Dave Airlie
2009-08-06 19:32                   ` Jeremy Fitzhardinge
2009-08-06 19:36                     ` David Woodhouse

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=1248858068.19733.229.camel@macbook.infradead.org \
    --to=dwmw2@infradead.org \
    --cc=airlied@gmail.com \
    --cc=iommu@lists.linux-foundation.org \
    --cc=joerg.roedel@amd.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=zhenyu.z.wang@intel.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