public inbox for linux-efi@vger.kernel.org
 help / color / mirror / Atom feed
From: Leif Lindholm <leif.lindholm-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
To: Matt Fleming <matt.fleming-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
Cc: tony.luck-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org,
	linux-efi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-ia64-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	hpa-YMNOUZJC4hwAvxtiuMwx3w@public.gmane.org,
	tglx-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org,
	patches-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org
Subject: Re: [PATCH 4/4] efi: x86: make efi_lookup_mapped_addr() a common function
Date: Thu, 1 Aug 2013 12:11:55 +0200	[thread overview]
Message-ID: <20130801101155.GK18151@rocoto.smurfnet.nu> (raw)
In-Reply-To: <51F8D1AC.4040501-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>

On Wed, Jul 31, 2013 at 09:58:20AM +0100, Matt Fleming wrote:
> On 07/30/2013 05:47 PM, Leif Lindholm wrote:
> > efi_lookup_mapped_addr() is a handy utility for other platforms
> > than x86. Move it from arch/x86 to drivers/firmware/efi.
> > 
> > This function will be used by future ARM patches.
> > 
> > Signed-off-by: Leif Lindholm <leif.lindholm-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
> > ---
> >  arch/x86/platform/efi/efi.c |   28 ----------------------------
> >  drivers/firmware/efi/efi.c  |   30 ++++++++++++++++++++++++++++++
> >  2 files changed, 30 insertions(+), 28 deletions(-)
> > 
> 
> [...]
> 
> > +#if defined(CONFIG_X86)
> > +/*
> > + * We can't ioremap data in EFI boot services RAM, because we've already mapped
> > + * it as RAM.  So, look it up in the existing EFI memory map instead.  Only
> > + * callable after efi_enter_virtual_mode and before efi_free_boot_services.
> > + */
> > +void __iomem *efi_lookup_mapped_addr(u64 phys_addr)
> > +{
> > +	void *p;
> > +	if (WARN_ON(!memmap.map))
> > +		return NULL;
> > +	for (p = memmap.map; p < memmap.map_end; p += memmap.desc_size) {
> > +		efi_memory_desc_t *md = p;
> > +		u64 size = md->num_pages << EFI_PAGE_SHIFT;
> > +		u64 end = md->phys_addr + size;
> > +		if (!(md->attribute & EFI_MEMORY_RUNTIME) &&
> > +		    md->type != EFI_BOOT_SERVICES_CODE &&
> > +		    md->type != EFI_BOOT_SERVICES_DATA)
> > +			continue;
> > +		if (!md->virt_addr)
> > +			continue;
> > +		if (phys_addr >= md->phys_addr && phys_addr < end) {
> > +			phys_addr += md->virt_addr - md->phys_addr;
> > +			return (__force void __iomem *)(unsigned long)phys_addr;
> > +		}
> > +	}
> > +	return NULL;
> > +}
> > +#endif
> > +
> 
> If we hang a 'struct efi_memory_map' off of 'struct efi', can we get rid
> of this #ifdef?

Sure.

It would just be a small bit of wasted memory for IA64 (struct +
code). On the flip side, having that on all platforms could lend
itself to making a little bit more code common.

Tony?

/
    Leif

  parent reply	other threads:[~2013-08-01 10:11 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-30 16:47 [PATCH 0/4] Make commonly useful UEFI functions common Leif Lindholm
2013-07-30 16:47 ` [PATCH 1/4] efi: provide a generic efi_config_init() Leif Lindholm
     [not found]   ` <1375202858-28470-2-git-send-email-leif.lindholm-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2013-07-30 17:53     ` Tony Luck
2013-07-30 18:02       ` Leif Lindholm
2013-07-30 18:14         ` Tony Luck
2013-07-30 16:47 ` [PATCH 2/4] efi: x86: use common code for (U)EFI configuration scanning Leif Lindholm
2013-07-30 16:47 ` [PATCH 3/4] efi: ia64: " Leif Lindholm
2013-07-30 16:47 ` [PATCH 4/4] efi: x86: make efi_lookup_mapped_addr() a common function Leif Lindholm
2013-07-31  8:58   ` Matt Fleming
     [not found]     ` <51F8D1AC.4040501-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2013-08-01 10:11       ` Leif Lindholm [this message]
     [not found] ` <1375202858-28470-1-git-send-email-leif.lindholm-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2013-07-30 19:57   ` [PATCH 0/4] Make commonly useful UEFI functions common Tony Luck
2013-08-01 20:26   ` H. Peter Anvin
2013-08-01 20:45     ` Fleming, Matt

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=20130801101155.GK18151@rocoto.smurfnet.nu \
    --to=leif.lindholm-qsej5fyqhm4dnm+yrofe0a@public.gmane.org \
    --cc=hpa-YMNOUZJC4hwAvxtiuMwx3w@public.gmane.org \
    --cc=linux-efi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-ia64-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=matt.fleming-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org \
    --cc=patches-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
    --cc=tglx-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org \
    --cc=tony.luck-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.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