[flashrom] [PATCH 6/8] use getpagesize() to determine physmap's length in nicintel_spi.c
Stefan Tauner
stefan.tauner at student.tuwien.ac.at
Sun May 29 23:31:45 CEST 2011
On Sun, 29 May 2011 06:17:15 +0200
Stefan Tauner <stefan.tauner at student.tuwien.ac.at> wrote:
> On Thu, 31 Mar 2011 22:31:17 +0200
> Stefan Tauner <stefan.tauner at student.tuwien.ac.at> wrote:
>
> > On Thu, 31 Mar 2011 13:03:54 +0200
> > Stefan Tauner <stefan.tauner at student.tuwien.ac.at> wrote:
> >
> > > On Thu, 31 Mar 2011 08:45:39 +0200
> > > Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006 at gmx.net> wrote:
> > >
> > > > Could you patch physmap instead to round down the requested address
> > > > and round up the end of the range? Then we could just request the
> > > > amount we need without having to care in each programmer driver
> > > > about page size. I think somewhere in flashrom we even have
> > > > rounding code for physmap, it just needs to be moved from a driver
> > > > to the generic physmap.
> > >
> > > oh. steep learning curve there. :)
> > > not because the rounding is complicated, but because i am not sure i
> > > am aware of all side effects.
> > > i guess the existing rounding code you was referring to is that in
> > > sb600spi.c?
> > >
> > > what i can do/propose for now:
> > > change physmap_common as follows:
> > > instead of the two check including getpagesize():
> > > - round down the physical address requested later from phys_to_virt to
> > > the nearest getpagesize()-aligned address
> > > - round up the length requested later accordingly i.e. request a
> > > physical window that is aligned to pages and includes at least the
> > > memory described by phys_addr + len
> > > - return virt_addr after adding the offset from rounding down the
> > > physical address
> > > - change nicintel_spi.c accordingly
> >
> > we also need something similar for physunmap(...).
> > would the same rounding be sufficient?
> > how should we implement that? a function void getWindow(*addr, *len)
> > that sets the addr and len and will be called by physmap and physunmap?
> > or is that too complicated?
>
> carldani: ping!
> i have started to mimic what the mei kernel driver does and i think i
> cant continue due to unaligned memory mappings. so it would be a good
> moment to push for what you have suggested. even if that is not the
> problem i currently face, i would like to work on this sometimes so
> please comment my proposal above.
my current solution:
static void round_to_page_boundaries(uint32_t start_in, uint32_t len_in,
uint32_t *start_out, uint32_t *len_out)
{
uint32_t page_size = getpagesize();
uint32_t end = start_in + len_in;;
msg_pdbg("start_in= 0x%08x, len_in= 0x%08x, end_in= 0x%08x, page_size=0x%08x\n", start_in, len_in, start_in+len_in, page_size);
*start_out = start_in & ~(page_size-1);
end = (end & ~(page_size-1)) + page_size;
*len_out = end - *start_out;
msg_pdbg("start_out=0x%08x, len_out=0x%08x, end_out=0x%08x\n", *start_out, *len_out, *start_out+ *len_out);
}
seems to do what we want, but i am not sure about the interface (atm i
am using it in ichspi.c directly instead in physmap.c).
--
Kind regards/Mit freundlichen Grüßen, Stefan Tauner
More information about the flashrom
mailing list