public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Ian Campbell <Ian.Campbell@citrix.com>
To: Jeremy Fitzhardinge <jeremy@goop.org>
Cc: <linux-kernel@vger.kernel.org>,
	Becky Bruce <beckyb@kernel.crashing.org>,
	Benjamin Herrenschmidt <benh@kernel.crashing.org>,
	Kumar Gala <galak@kernel.crashing.org>,
	FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>,
	Ingo Molnar <mingo@elte.hu>, <linuxppc-dev@ozlabs.org>
Subject: Re: [PATCH 8/9] swiotlb: support HIGHMEM in swiotlb_bus_to_virt
Date: Sat, 30 May 2009 14:02:27 +0100	[thread overview]
Message-ID: <1243688547.4399.65.camel@localhost.localdomain> (raw)
In-Reply-To: <4A20060C.2050701@goop.org>

On Fri, 2009-05-29 at 08:58 -0700, Jeremy Fitzhardinge wrote:
> Ian Campbell wrote:

> > -void * __weak swiotlb_bus_to_virt(struct device *hwdev, dma_addr_t address)
> > +#ifdef CONFIG_HIGHMEM
> > +static void * swiotlb_bus_to_virt(struct device *hwdev, dma_addr_t address)
> >   
> 
> I think it would be better to put the #ifdef within the function body so 
> that there's no chance of prototype-drift.

Yes, good idea.

> > +{
> > +	unsigned long pfn = PFN_DOWN(dma_to_phys(hwdev, addr));
> > +	void *pageaddr = page_address(pfn_to_page(pfn));
> > +
> > +	if (pageaddr != NULL)
> > +		return pageaddr + (addr % PAGE_SIZE);
> >   
> Is there an arch-independent test to see if a pfn is considered highmem 
> or not (which returns a constant on non-highmem configurations)?  If so, 
> then I think this could be common without having to go via a struct page.

I'm not aware of a way apart from PageHighMem -- which needs the struct
page. Highmem is a property of the zone, I think, so you have to go
through the struct page back to the zone to find out if it is high or
not.

At first glance it looks like many of the callers of bus_to_virt
eventually end up in swiotlb_bounce which converts to a struct page
anyway. I'll take a look next week whether it makes any sense to go to
struct page further up the call chain and pass that around instead.

Ian.



  reply	other threads:[~2009-05-30 13:02 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-05-29  8:43 Ian Campbell
2009-05-29  8:43 ` [PATCH 1/9] ia64: introduce arch-specific dma-mapping interfaces Ian Campbell
2009-05-29  8:43 ` [PATCH 2/9] x86: introduce arch-specific dma-mapping interface Ian Campbell
2009-05-29  8:43 ` [PATCH 3/9] x86: use dma_map_range when allocating PCI DMA memory Ian Campbell
2009-05-29  8:43 ` [PATCH 4/9] x86: use dma_map_range when allocating PCI DMA memory with no IOMMU Ian Campbell
2009-05-29  8:43 ` [PATCH 5/9] x86: use dma_map_range when allocating PCI GART memory Ian Campbell
2009-05-29  8:44 ` [PATCH 6/9] swiotlb: use dma_to_phys and phys_to_dma Ian Campbell
2009-05-29 21:09   ` Jeremy Fitzhardinge
2009-05-30 13:02     ` Ian Campbell
2009-05-29  8:44 ` [PATCH 7/9] swiotlb: use dma_map_range Ian Campbell
2009-05-29  8:44 ` [PATCH 8/9] swiotlb: support HIGHMEM in swiotlb_bus_to_virt Ian Campbell
2009-05-29 15:58   ` Jeremy Fitzhardinge
2009-05-30 13:02     ` Ian Campbell [this message]
2009-05-29  8:44 ` [PATCH 9/9] swiotlb: rename swiotlb_virt_to_bus as virt_to_dma Ian Campbell
2009-05-29  9:06 ` swiotlb: Introduce architecture-specific APIs to replace __weak functions Ian Campbell

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=1243688547.4399.65.camel@localhost.localdomain \
    --to=ian.campbell@citrix.com \
    --cc=beckyb@kernel.crashing.org \
    --cc=benh@kernel.crashing.org \
    --cc=fujita.tomonori@lab.ntt.co.jp \
    --cc=galak@kernel.crashing.org \
    --cc=jeremy@goop.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxppc-dev@ozlabs.org \
    --cc=mingo@elte.hu \
    /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