* [PATCH] [POWERPC] Limit range of __init_ref_ok somewhat
@ 2007-10-02 3:37 Stephen Rothwell
2007-10-02 11:42 ` mem_init_done (was: Re: [PATCH] [POWERPC] Limit range of __init_ref_ok somewhat) Geert Uytterhoeven
2007-10-02 21:40 ` [PATCH] powerpc: another use of zalloc_maybe_bootmem() Linas Vepstas
0 siblings, 2 replies; 3+ messages in thread
From: Stephen Rothwell @ 2007-10-02 3:37 UTC (permalink / raw)
To: paulus; +Cc: ppc-dev
This patch introduces zalloc_maybe_bootmem and uses it so that we don;t
have to mark a whole (largish) routine as __init_ref_ok.
Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au>
---
arch/powerpc/kernel/irq.c | 10 ++--------
arch/powerpc/lib/alloc.c | 15 +++++++++++++++
include/asm-powerpc/system.h | 1 +
3 files changed, 18 insertions(+), 8 deletions(-)
--
Cheers,
Stephen Rothwell sfr@canb.auug.org.au
diff --git a/arch/powerpc/kernel/irq.c b/arch/powerpc/kernel/irq.c
index 0e47c8c..151b131 100644
--- a/arch/powerpc/kernel/irq.c
+++ b/arch/powerpc/kernel/irq.c
@@ -424,7 +424,7 @@ static int default_irq_host_match(struct irq_host *h, struct device_node *np)
return h->of_node != NULL && h->of_node == np;
}
-__init_refok struct irq_host *irq_alloc_host(struct device_node *of_node,
+struct irq_host *irq_alloc_host(struct device_node *of_node,
unsigned int revmap_type,
unsigned int revmap_arg,
struct irq_host_ops *ops,
@@ -439,13 +439,7 @@ __init_refok struct irq_host *irq_alloc_host(struct device_node *of_node,
/* Allocate structure and revmap table if using linear mapping */
if (revmap_type == IRQ_HOST_MAP_LINEAR)
size += revmap_arg * sizeof(unsigned int);
- if (mem_init_done)
- host = kzalloc(size, GFP_KERNEL);
- else {
- host = alloc_bootmem(size);
- if (host)
- memset(host, 0, size);
- }
+ host = zalloc_maybe_bootmem(size, GFP_KERNEL);
if (host == NULL)
return NULL;
diff --git a/arch/powerpc/lib/alloc.c b/arch/powerpc/lib/alloc.c
index e58c805..f53e09c 100644
--- a/arch/powerpc/lib/alloc.c
+++ b/arch/powerpc/lib/alloc.c
@@ -2,6 +2,7 @@
#include <linux/init.h>
#include <linux/slab.h>
#include <linux/bootmem.h>
+#include <linux/string.h>
#include <asm/system.h>
@@ -12,3 +13,17 @@ void * __init_refok alloc_maybe_bootmem(size_t size, gfp_t mask)
else
return alloc_bootmem(size);
}
+
+void * __init_refok zalloc_maybe_bootmem(size_t size, gfp_t mask)
+{
+ void *p;
+
+ if (mem_init_done)
+ p = kzalloc(size, mask);
+ else {
+ p = alloc_bootmem(size);
+ if (p)
+ memset(p, 0, size);
+ }
+ return p;
+}
diff --git a/include/asm-powerpc/system.h b/include/asm-powerpc/system.h
index f7879fc..d10e99b 100644
--- a/include/asm-powerpc/system.h
+++ b/include/asm-powerpc/system.h
@@ -190,6 +190,7 @@ extern unsigned long memory_limit;
extern unsigned long klimit;
extern void *alloc_maybe_bootmem(size_t size, gfp_t mask);
+extern void *zalloc_maybe_bootmem(size_t size, gfp_t mask);
extern int powersave_nap; /* set if nap mode can be used in idle loop */
--
1.5.3.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* mem_init_done (was: Re: [PATCH] [POWERPC] Limit range of __init_ref_ok somewhat)
2007-10-02 3:37 [PATCH] [POWERPC] Limit range of __init_ref_ok somewhat Stephen Rothwell
@ 2007-10-02 11:42 ` Geert Uytterhoeven
2007-10-02 21:40 ` [PATCH] powerpc: another use of zalloc_maybe_bootmem() Linas Vepstas
1 sibling, 0 replies; 3+ messages in thread
From: Geert Uytterhoeven @ 2007-10-02 11:42 UTC (permalink / raw)
To: Stephen Rothwell; +Cc: ppc-dev, paulus
[-- Attachment #1: Type: TEXT/PLAIN, Size: 1396 bytes --]
On Tue, 2 Oct 2007, Stephen Rothwell wrote:
> +void * __init_refok zalloc_maybe_bootmem(size_t size, gfp_t mask)
> +{
> + void *p;
> +
> + if (mem_init_done)
> + p = kzalloc(size, mask);
> + else {
> + p = alloc_bootmem(size);
> + if (p)
> + memset(p, 0, size);
> + }
> + return p;
> +}
BTW, is this `mem_init_done' flag the recommended(TM) way to handle this?
Or is it just something that always stayed under the radar of the reviewers, as
only PPC has it (and Atari)?
I remember we had something similar globally when __init was introduced,
which was used by the frame buffer code to determine whether to draw the
penguin logo (which is __initdata) or not. This code had to be ripped out (and
was replaced by the FBINFO_MODULE logic), because people didn't like
mem_init_done flags...
With kind regards,
Geert Uytterhoeven
Software Architect
Sony Network and Software Technology Center Europe
The Corporate Village · Da Vincilaan 7-D1 · B-1935 Zaventem · Belgium
Phone: +32 (0)2 700 8453
Fax: +32 (0)2 700 8622
E-mail: Geert.Uytterhoeven@sonycom.com
Internet: http://www.sony-europe.com/
Sony Network and Software Technology Center Europe
A division of Sony Service Centre (Europe) N.V.
Registered office: Technologielaan 7 · B-1840 Londerzeel · Belgium
VAT BE 0413.825.160 · RPR Brussels
Fortis Bank Zaventem · Swift GEBABEBB08A · IBAN BE39001382358619
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH] powerpc: another use of zalloc_maybe_bootmem()
2007-10-02 3:37 [PATCH] [POWERPC] Limit range of __init_ref_ok somewhat Stephen Rothwell
2007-10-02 11:42 ` mem_init_done (was: Re: [PATCH] [POWERPC] Limit range of __init_ref_ok somewhat) Geert Uytterhoeven
@ 2007-10-02 21:40 ` Linas Vepstas
1 sibling, 0 replies; 3+ messages in thread
From: Linas Vepstas @ 2007-10-02 21:40 UTC (permalink / raw)
To: Stephen Rothwell; +Cc: ppc-dev, paulus
Use alloc_maybe_bootmem() which wraps the if(mem_init_done)
malloc clause.
Signed-off-by: Linas Vepstas <linas@austin.ibm.com>
----
On Tue, Oct 02, 2007 at 01:37:53PM +1000, Stephen Rothwell wrote:
> This patch introduces zalloc_maybe_bootmem and uses it so that we don;t
> have to mark a whole (largish) routine as __init_ref_ok.
sfr missed a spot -- may as well get rid of this one too.
arch/powerpc/kernel/pci-common.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
Index: linux-2.6.23-rc8-mm1/arch/powerpc/kernel/pci-common.c
===================================================================
--- linux-2.6.23-rc8-mm1.orig/arch/powerpc/kernel/pci-common.c 2007-09-26 15:02:41.000000000 -0500
+++ linux-2.6.23-rc8-mm1/arch/powerpc/kernel/pci-common.c 2007-10-02 16:28:16.000000000 -0500
@@ -65,14 +65,11 @@ static void __devinit pci_setup_pci_cont
spin_unlock(&hose_spinlock);
}
-__init_refok struct pci_controller * pcibios_alloc_controller(struct device_node *dev)
+struct pci_controller * pcibios_alloc_controller(struct device_node *dev)
{
struct pci_controller *phb;
- if (mem_init_done)
- phb = kmalloc(sizeof(struct pci_controller), GFP_KERNEL);
- else
- phb = alloc_bootmem(sizeof (struct pci_controller));
+ phb = alloc_maybe_bootmem(sizeof(struct pci_controller), GFP_KERNEL);
if (phb == NULL)
return NULL;
pci_setup_pci_controller(phb);
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2007-10-02 21:40 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-10-02 3:37 [PATCH] [POWERPC] Limit range of __init_ref_ok somewhat Stephen Rothwell
2007-10-02 11:42 ` mem_init_done (was: Re: [PATCH] [POWERPC] Limit range of __init_ref_ok somewhat) Geert Uytterhoeven
2007-10-02 21:40 ` [PATCH] powerpc: another use of zalloc_maybe_bootmem() Linas Vepstas
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).