All of lore.kernel.org
 help / color / mirror / Atom feed
* Wrong looking statement in cpm_common.c
@ 2009-05-25  4:00 Benjamin Herrenschmidt
  2009-05-26 17:56 ` Scott Wood
  0 siblings, 1 reply; 6+ messages in thread
From: Benjamin Herrenschmidt @ 2009-05-25  4:00 UTC (permalink / raw)
  To: Scott Wood; +Cc: linuxppc-dev list

Hi Scott !

There's this pearl in cpm_common.c :

void __init udbg_init_cpm(void)
{
	if (cpm_udbg_txdesc) {
#ifdef CONFIG_CPM2
		setbat(1, 0xf0000000, 0xf0000000, 1024*1024, PAGE_KERNEL_NCG);
#endif
		udbg_putc = udbg_putc_cpm;
	}
}

Now, last I looked, 0xf0000000 (virtual) lands about right in the middle
of the vmalloc space... so unless there's code somewhere that I missed
that reserves that region of virtual space for use by that crap above,
I think somebody is in trouble :-)

Additionally, that's the last user of setbat that I can find outside
of the linear mapping setup proper, so scott, once you've fixed that
I'll happily make setbat static once for all. We -can- still provide
a facility for using BATs for early ioremap's but that should be done
properly, not by whacking setbat with random hard wired virtual
addresses.

Cheers,
Ben.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Wrong looking statement in cpm_common.c
  2009-05-25  4:00 Wrong looking statement in cpm_common.c Benjamin Herrenschmidt
@ 2009-05-26 17:56 ` Scott Wood
  2009-05-26 22:07   ` Benjamin Herrenschmidt
  0 siblings, 1 reply; 6+ messages in thread
From: Scott Wood @ 2009-05-26 17:56 UTC (permalink / raw)
  To: Benjamin Herrenschmidt; +Cc: linuxppc-dev list

On Mon, May 25, 2009 at 02:00:33PM +1000, Benjamin Herrenschmidt wrote:
> Hi Scott !
> 
> There's this pearl in cpm_common.c :
> 
> void __init udbg_init_cpm(void)
> {
> 	if (cpm_udbg_txdesc) {
> #ifdef CONFIG_CPM2
> 		setbat(1, 0xf0000000, 0xf0000000, 1024*1024, PAGE_KERNEL_NCG);
> #endif
> 		udbg_putc = udbg_putc_cpm;
> 	}
> }
> 
> Now, last I looked, 0xf0000000 (virtual) lands about right in the middle
> of the vmalloc space... so unless there's code somewhere that I missed
> that reserves that region of virtual space for use by that crap above,
> I think somebody is in trouble :-)

:-(

> Additionally, that's the last user of setbat that I can find outside
> of the linear mapping setup proper, so scott, once you've fixed that
> I'll happily make setbat static once for all. We -can- still provide
> a facility for using BATs for early ioremap's but that should be done
> properly, not by whacking setbat with random hard wired virtual
> addresses.

Any suggestions for how to do it properly?

-Scott

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Wrong looking statement in cpm_common.c
  2009-05-26 17:56 ` Scott Wood
@ 2009-05-26 22:07   ` Benjamin Herrenschmidt
  2009-05-26 22:15     ` Scott Wood
  0 siblings, 1 reply; 6+ messages in thread
From: Benjamin Herrenschmidt @ 2009-05-26 22:07 UTC (permalink / raw)
  To: Scott Wood; +Cc: linuxppc-dev list

On Tue, 2009-05-26 at 12:56 -0500, Scott Wood wrote:
> 
> Any suggestions for how to do it properly?

ioremap ? :-)

Ben.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Wrong looking statement in cpm_common.c
  2009-05-26 22:07   ` Benjamin Herrenschmidt
@ 2009-05-26 22:15     ` Scott Wood
  2009-05-26 22:22       ` Benjamin Herrenschmidt
  0 siblings, 1 reply; 6+ messages in thread
From: Scott Wood @ 2009-05-26 22:15 UTC (permalink / raw)
  To: Benjamin Herrenschmidt; +Cc: linuxppc-dev list

Benjamin Herrenschmidt wrote:
> On Tue, 2009-05-26 at 12:56 -0500, Scott Wood wrote:
>> Any suggestions for how to do it properly?
> 
> ioremap ? :-)

Does ioremap work that early?

-Scott

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Wrong looking statement in cpm_common.c
  2009-05-26 22:15     ` Scott Wood
@ 2009-05-26 22:22       ` Benjamin Herrenschmidt
  2009-05-26 22:38         ` Scott Wood
  0 siblings, 1 reply; 6+ messages in thread
From: Benjamin Herrenschmidt @ 2009-05-26 22:22 UTC (permalink / raw)
  To: Scott Wood; +Cc: linuxppc-dev list

On Tue, 2009-05-26 at 17:15 -0500, Scott Wood wrote:
> Benjamin Herrenschmidt wrote:
> > On Tue, 2009-05-26 at 12:56 -0500, Scott Wood wrote:
> >> Any suggestions for how to do it properly?
> > 
> > ioremap ? :-)
> 
> Does ioremap work that early?

It works very early on ppc32 but maybe not -that- early... It works from
start_kernel on. You might be able to do the ioremaps in machine_init
(provided LMBs are up) but they won't be "effective" until MMU_init
returns, but then, neither will setbat anyway.

However, since that's the only user of setbat I can still find and we
want to replace that with something saner, I'd rather kill it.

Ben.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Wrong looking statement in cpm_common.c
  2009-05-26 22:22       ` Benjamin Herrenschmidt
@ 2009-05-26 22:38         ` Scott Wood
  0 siblings, 0 replies; 6+ messages in thread
From: Scott Wood @ 2009-05-26 22:38 UTC (permalink / raw)
  To: Benjamin Herrenschmidt; +Cc: linuxppc-dev list

Benjamin Herrenschmidt wrote:
> On Tue, 2009-05-26 at 17:15 -0500, Scott Wood wrote:
>> Benjamin Herrenschmidt wrote:
>>> On Tue, 2009-05-26 at 12:56 -0500, Scott Wood wrote:
>>>> Any suggestions for how to do it properly?
>>> ioremap ? :-)
>> Does ioremap work that early?
> 
> It works very early on ppc32 but maybe not -that- early... It works from
> start_kernel on. You might be able to do the ioremaps in machine_init
> (provided LMBs are up) but they won't be "effective" until MMU_init
> returns, but then, neither will setbat anyway.

Before the setbat takes effect, there is a BAT established by 
setup_cpm_bat in head_32.S.

How about something similar to btext_unmap to tell cpm2 udbg that the 
mapping is gone, and to do ioremap at that point (or perhaps it would be 
better to wait until the next print after unmap is called, which should 
be after load_up_mmu assuming nothing crashes in the assembly code)?

-Scott

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2009-05-26 22:38 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-05-25  4:00 Wrong looking statement in cpm_common.c Benjamin Herrenschmidt
2009-05-26 17:56 ` Scott Wood
2009-05-26 22:07   ` Benjamin Herrenschmidt
2009-05-26 22:15     ` Scott Wood
2009-05-26 22:22       ` Benjamin Herrenschmidt
2009-05-26 22:38         ` Scott Wood

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.