Skip to contentSkip to conversation

8xx: add cpm_get_cpmp()

PATCH In review Aristeu Sergio Rozanski Filho 4 participants 12 messages Aug 6, 2005 – Aug 7, 2005

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 8xx: add cpm_get_cpmp()

8xx: add cpm_get_cpmp() to make cpmp visible to modules

arch/ppc/8xx_io/commproc.c +7 -0
Index: 2.6-8xx/arch/ppc/8xx_io/commproc.c
===================================================================
@@ -462,3 +462,10 @@
 	return ((immap_t *)IMAP_ADDR)->im_cpm.cp_dpmem + offset;
 }
 EXPORT_SYMBOL(cpm_dpram_addr);
+
+cpm8xx_t *cpm_get_cpmp(void)
+{
+	return cpmp;
+}
+EXPORT_SYMBOL(cpm_get_cpmp);
+
include/asm/commproc.h +1 -0
Index: 2.6-8xx/include/asm/commproc.h
===================================================================
@@ -78,6 +78,7 @@
 extern void cpm_dpdump(void);
 extern void *cpm_dpram_addr(uint offset);
 extern void cpm_setbrg(uint brg, uint rate);
+extern cpm8xx_t *cpm_get_cpmp(void);
 
 extern uint m8xx_cpm_hostalloc(uint size);
 extern int  m8xx_cpm_hostfree(uint start);
#1 lore raw

Aris,

It already is exported, declared as

commproc.h:extern cpm8xx_t *cpmp; /* Pointer to comm processor */

and many drivers use the pointer directly.

arch/ppc/8260_io/ drivers also use the same convention.

Not sure I see much advantage in changing it?

Quoted 31 lines · Aristeu Sergio Rozanski Filho

8xx: add cpm_get_cpmp() to make cpmp visible to modules

Index: 2.6-8xx/arch/ppc/8xx_io/commproc.c
===================================================================

arch/ppc/8xx_io/commproc.c +7 -0
@@ -462,3 +462,10 @@
 	return ((immap_t *)IMAP_ADDR)->im_cpm.cp_dpmem + offset;
 }
 EXPORT_SYMBOL(cpm_dpram_addr);
+
+cpm8xx_t *cpm_get_cpmp(void)
+{
+	return cpmp;
+}
+EXPORT_SYMBOL(cpm_get_cpmp);
+

Index: 2.6-8xx/include/asm/commproc.h
===================================================================

include/asm/commproc.h +1 -0
@@ -78,6 +78,7 @@
 extern void cpm_dpdump(void);
 extern void *cpm_dpram_addr(uint offset);
 extern void cpm_setbrg(uint brg, uint rate);
+extern cpm8xx_t *cpm_get_cpmp(void);
 
 extern uint m8xx_cpm_hostalloc(uint size);
 extern int  m8xx_cpm_hostfree(uint start);
#2 lore raw
Quoted 10 lines

It already is exported, declared as

commproc.h:extern cpm8xx_t *cpmp; /* Pointer to comm processor */

and many drivers use the pointer directly.

arch/ppc/8260_io/ drivers also use the same convention.

Not sure I see much advantage in changing it?

but not with EXPORT_SYMBOL(). I noticed this while compiling i2c stuff as module. also, I think it's better add a function to do this instead doing EXPORT_SYMBOL() in a variable.
what you think?

Signature · 1 line
Aristeu
#3 lore raw
Quoted 5 lines · Aristeu Sergio Rozanski Filho
Quoted 5 lines

It already is exported, declared as

commproc.h:extern cpm8xx_t *cpmp; /* Pointer to comm processor */

Quoted 7 lines
Quoted 5 lines

and many drivers use the pointer directly.

arch/ppc/8260_io/ drivers also use the same convention.

Not sure I see much advantage in changing it?

but not with EXPORT_SYMBOL(). I noticed this while compiling i2c stuff as module.

Then other modules suffer from the same problem - what if you EXPORT_SYMBOL(cpmp)?

Quoted 3 lines

also, I think it's better add a function to do this instead doing EXPORT_SYMBOL() in a variable.
what you think?

Well it is better in theory because it hides details, but in practice I'm not sure its worth it - the CPM pointer (along with the whole immap) never changes during runtime.

#4 lore raw
In reply to Aristeu Sergio Rozanski Filho
Quoted 3 lines · Aristeu Sergio Rozanski Filho

but not with EXPORT_SYMBOL(). I noticed this while compiling i2c stuff as module. also, I think it's better add a function to do this instead doing EXPORT_SYMBOL() in a variable.

Right. We should just ioremap() :-)

Thanks.

	-- Dan
#5 lore raw
In reply to Marcelo Tosatti
Quoted 6 lines · Marcelo Tosatti

It already is exported, declared as

commproc.h:extern cpm8xx_t *cpmp; /* Pointer to comm processor */

and many drivers use the pointer directly.

We shouldn't be doing this. All drivers should ioremap() any peripheral spaces they use and not make any assumptions someone else has done that already. We've been making such changes in the 82xx/83xx/85xx CPM2 drivers. If it isn't convenient to find the #defines for the ioremap(), we should change that. When I originally wrote all of this code, it was long ago when we didn't have some of the abstractions and it seemed any shortcuts for performance were desired :-)

Quoted 1 line

arch/ppc/8260_io/ drivers also use the same convention.

If there are any drivers in here, they either aren't used or on their way out. The only things that should remain are common support functions.

Thanks.

	-- Dan
#6 lore raw
Quoted 11 lines · Dan Malek
Quoted 7 lines · Marcelo Tosatti

It already is exported, declared as

commproc.h:extern cpm8xx_t *cpmp; /* Pointer to
comm processor */

and many drivers use the pointer directly.

Quoted 9 lines

We shouldn't be doing this. All drivers should ioremap() any peripheral spaces they use and not make any assumptions someone else has done that already. We've been making such changes in the 82xx/83xx/85xx CPM2 drivers. If it isn't convenient to find the #defines for the ioremap(), we should change that. When I originally wrote all of this code, it was long ago when we didn't have some of the abstractions and it seemed any shortcuts for performance were desired :-)

OK makes sense (yep it was even discussed already).

Aris, sounds like you should proceed with cpm_get_cpmp() and change all other drivers using it also.

Quoted 7 lines
Quoted 3 lines

arch/ppc/8260_io/ drivers also use the same convention.

If there are any drivers in here, they either aren't used or on their way out. The only things that should remain are common support functions.

OK!

#7 lore raw
Quoted 2 lines · Marcelo Tosatti

Aris, sounds like you should proceed with cpm_get_cpmp() and change all other drivers using it also.

It depends how you define the semantics of this function call. Can you call it any (and all of the) time you need it, or does it actually perform an ioremap() and you only want to call it once?

I guess implemented properly it doesn't matter. On the first call it should do the ioremap() and on subsequent calls it just returns the mapping. This is one of those common functions that should be in commproc.c.

Thanks.

	-- Dan
#8 lore raw
Quoted 4 lines

It depends how you define the semantics of this function call. Can you call it any (and all of the) time you need it, or does it actually perform an ioremap() and you only want to call it once?

what about don't cache it and call ioremap() from driver? (I guess ioremap() already check if an area is already mapped, no?)

--
Aristeu

#9 lore raw
Quoted 6 lines · Aristeu Sergio Rozanski Filho
Quoted 4 lines

It depends how you define the semantics of this function call. Can you call it any (and all of the) time you need it, or does it actually perform an ioremap() and you only want to call it once?

what about don't cache it and call ioremap() from driver? (I guess ioremap() already check if an area is already mapped, no?)

Yep, ioremap() should be doing virtual address caching already, no?

#10 lore raw
Quoted 9 lines · Marcelo Tosatti
Quoted 6 lines · Aristeu Sergio Rozanski Filho
Quoted 4 lines

It depends how you define the semantics of this function call. Can you call it any (and all of the) time you need it, or does it actually perform an ioremap() and you only want to call it once?

what about don't cache it and call ioremap() from driver? (I guess ioremap() already check if an area is already mapped, no?)

Yep, ioremap() should be doing virtual address caching already, no?

In general, ioremap() doesn't do any caching currently. Some subarchs do some limited caching, e.g. if BATs (classic PPC) or CAMs (e500) are available and were used previously for ioremap() mappings.

Some time ago I made a trivial ioremap cache patch (useful on 4xx, which doesn't have BATs nor CAMs), although it wass really a hack and it was never merged :).

Signature · 1 line
Eugene
#11 lore raw
In reply to Aristeu Sergio Rozanski Filho
Quoted 2 lines · Aristeu Sergio Rozanski Filho

what about don't cache it and call ioremap() from driver? (I guess ioremap() already check if an area is already mapped, no?)

Either way. I'm actually leaning toward these "pointer helper" functions. :-) Something like get_cpmp(), or get_immr(), that will hide the details of the mapping, so you don't have to include and know which #defines to use as part of an ioremap() call.

It seems to be more clear to me, and I'm thinking about making the same changes to the CPM2 drivers. It also allows a performance versus compact code trade off, declaring these as inline functions or as real functions.

Thanks.

	-- Dan