Skip to contentSkip to conversation

s390: fix invalid kmalloc flags

PATCH In review [email protected] 4 participants 5 messages Aug 6, 2005

Subsystems (6)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 s390: fix invalid kmalloc flags

The following patch fixes the compilation (defconfig) of s390:

arch/s390/mm/built-in.o(.text+0x152c): In function `query_segment_type':
extmem.c: undefined reference to __your_kmalloc_flags_are_not_valid' arch/s390/mm/built-in.o(.text+0x19ec): In function segment_load':
: undefined reference to `__your_kmalloc_flags_are_not_valid'

arch/s390/mm/extmem.c +3 -3
@@ -172,8 +172,8 @@ dcss_diag_translate_rc (int vm_rc) {
 static int
 query_segment_type (struct dcss_segment *seg)
 {
-	struct qin64  *qin = kmalloc (sizeof(struct qin64), GFP_DMA);
-	struct qout64 *qout = kmalloc (sizeof(struct qout64), GFP_DMA);
+	struct qin64  *qin = kmalloc (sizeof(struct qin64), GFP_DMA|GFP_KERNEL);
+	struct qout64 *qout = kmalloc (sizeof(struct qout64), GFP_DMA|GFP_KERNEL);
 
 	int diag_cc, rc, i;
 	unsigned long dummy, vmrc;
@@ -332,7 +332,7 @@ static int
 __segment_load (char *name, int do_nonshared, unsigned long *addr, unsigned long *end)
 {
 	struct dcss_segment *seg = kmalloc(sizeof(struct dcss_segment),
-			GFP_DMA);
+			GFP_DMA|GFP_KERNEL);
 	int dcss_command, rc, diag_cc;
 
 	if (seg == NULL) {
#1 lore raw
Quoted 11 lines · [email protected] wrote:

The following patch fixes the compilation (defconfig) of s390:

arch/s390/mm/built-in.o(.text+0x152c): In function `query_segment_type':
extmem.c: undefined reference to __your_kmalloc_flags_are_not_valid' arch/s390/mm/built-in.o(.text+0x19ec): In function segment_load':
: undefined reference to `__your_kmalloc_flags_are_not_valid'

Quoted 10 lines

--- a/arch/s390/mm/extmem.c 2005-08-06 01:32:56.000000000 +0200
+++ b/arch/s390/mm/extmem.c 2005-07-31 17:46:36.000000000 +0200
@@ -172,8 +172,8 @@ dcss_diag_translate_rc (int vm_rc) {
static int
query_segment_type (struct dcss_segment *seg) {
- struct qin64 *qin = kmalloc (sizeof(struct qin64), GFP_DMA);
- struct qout64 *qout = kmalloc (sizeof(struct qout64), GFP_DMA);
+ struct qin64 *qin = kmalloc (sizeof(struct qin64), GFP_DMA|GFP_KERNEL);
+ struct qout64 *qout = kmalloc (sizeof(struct qout64), GFP_DMA|GFP_KERNEL);

No, GFP_DMA should work OK. Except GFP_DMA doesn't have __GFP_VALID set. It's strange that this didn't get noticed earlier.

Ben, was there a reason for not giving GFP_DMA the treatment?

#2 lore raw
Quoted 4 lines · Andrew Morton

No, GFP_DMA should work OK. Except GFP_DMA doesn't have __GFP_VALID set. It's strange that this didn't get noticed earlier.

Ben, was there a reason for not giving GFP_DMA the treatment?

Not really. Traditionally GFP_DMA was always mixed in with GFP_KERNEL or GFP_ATOMIC. It seems that GFP_DMA wasn't in the hunk of defines that all the other kernel flags were in, so if GFP_DMA is really valid all by itself, adding in the __GFP_VALID should be okay.

-ben

Signature · 1 line
"Time is what keeps everything from happening all at once." -- John Wheeler
#3 lore raw
Quoted 5 lines · Benjamin LaHaise
Quoted 3 lines · Andrew Morton

No, GFP_DMA should work OK. Except GFP_DMA doesn't have __GFP_VALID set. It's strange that this didn't get noticed earlier.

Quoted 7 lines
Quoted 1 line

Ben, was there a reason for not giving GFP_DMA the treatment?

Not really. Traditionally GFP_DMA was always mixed in with GFP_KERNEL or GFP_ATOMIC. It seems that GFP_DMA wasn't in the hunk of defines that all the other kernel flags were in, so if GFP_DMA is really valid all by itself, adding in the __GFP_VALID should be okay.

OK, it seems that pretty much all callers do remember to add GFP_KERNEL so I guess we can treat this as a bug-which-ben's-patch-found and merge Benoit's fix.

#4 lore raw

PATCH 1/1 fix invalid kmalloc flags (GFP_DMA alone)

Quoted 14 lines · Andrew Morton
Quoted 5 lines · Benjamin LaHaise
Quoted 3 lines · Andrew Morton

No, GFP_DMA should work OK. Except GFP_DMA doesn't have __GFP_VALID set. It's strange that this didn't get noticed earlier.

Quoted 7 lines
Quoted 1 line

Ben, was there a reason for not giving GFP_DMA the treatment?

Not really. Traditionally GFP_DMA was always mixed in with GFP_KERNEL or GFP_ATOMIC. It seems that GFP_DMA wasn't in the hunk of defines that all the other kernel flags were in, so if GFP_DMA is really valid all by itself, adding in the __GFP_VALID should be okay.

Quoted 3 lines

OK, it seems that pretty much all callers do remember to add GFP_KERNEL so I guess we can treat this as a bug-which-ben's-patch-found and merge Benoit's fix.

The following patch should catch all the other calls with GFP_DMA and without either GFP_KERNEL or GFP_ATOMIC.
I didn't included the previous patch (for arch/s390/mm/extmem.c).

arch/s390/appldata/appldata_os.c +1 -1
diff -urp -X other/Documentation/dontdiff truc/arch/s390/appldata/appldata_os.c other/arch/s390/appldata/appldata_os.c
@@ -194,7 +194,7 @@ static int __init appldata_os_init(void)
 	P_DEBUG("sizeof(os) = %i, sizeof(os_cpu) = %lu\n", size,
 		sizeof(struct appldata_os_per_cpu));
 
-	appldata_os_data = kmalloc(size, GFP_DMA);
+	appldata_os_data = kmalloc(size, GFP_DMA|GFP_KERNEL);
 	if (appldata_os_data == NULL) {
 		P_ERROR("No memory for %s!\n", ops.name);
 		rc = -ENOMEM;
drivers/net/b44.c +1 -1
diff -urp -X other/Documentation/dontdiff truc/drivers/net/b44.c other/drivers/net/b44.c
@@ -632,7 +632,7 @@ static int b44_alloc_rx_skb(struct b44 *
 		/* Sigh... */
 		pci_unmap_single(bp->pdev, mapping, RX_PKT_BUF_SZ,PCI_DMA_FROMDEVICE);
 		dev_kfree_skb_any(skb);
-		skb = __dev_alloc_skb(RX_PKT_BUF_SZ,GFP_DMA);
+		skb = __dev_alloc_skb(RX_PKT_BUF_SZ,GFP_ATOMIC|GFP_DMA);
 		if (skb == NULL)
 			return -ENOMEM;
 		mapping = pci_map_single(bp->pdev, skb->data,
drivers/net/wireless/hostap/hostap_hw.c +1 -1
diff -urp -X other/Documentation/dontdiff truc/drivers/net/wireless/hostap/hostap_hw.c other/drivers/net/wireless/hostap/hostap_hw.c
@@ -3308,7 +3308,7 @@ prism2_init_local_data(struct prism2_hel
 
 #if defined(PRISM2_PCI) && defined(PRISM2_BUS_MASTER)
 	local->bus_m0_buf = (u8 *) kmalloc(sizeof(struct hfa384x_tx_frame) +
-					   PRISM2_DATA_MAXLEN, GFP_DMA);
+					   PRISM2_DATA_MAXLEN, GFP_ATOMIC|GFP_DMA);
 	if (local->bus_m0_buf == NULL)
 		goto fail;
 #endif /* PRISM2_PCI and PRISM2_BUS_MASTER */
drivers/s390/net/claw.c +5 -5
diff -urp -X other/Documentation/dontdiff truc/drivers/s390/net/claw.c other/drivers/s390/net/claw.c
@@ -2198,7 +2198,7 @@ init_ccw_bk(struct net_device *dev)
         */
         if (privptr->p_buff_ccw==NULL) {
                 privptr->p_buff_ccw=
-			(void *)__get_free_pages(__GFP_DMA,
+			(void *)__get_free_pages(__GFP_DMA|GFP_KERNEL,
 		        (int)pages_to_order_of_mag(ccw_pages_required ));
                 if (privptr->p_buff_ccw==NULL) {
                         printk(KERN_INFO "%s: %s()  "
@@ -2354,7 +2354,7 @@ init_ccw_bk(struct net_device *dev)
         if (privptr->p_buff_write==NULL) {
             if (privptr->p_env->write_size < PAGE_SIZE) {
                 privptr->p_buff_write=
-			(void *)__get_free_pages(__GFP_DMA,
+			(void *)__get_free_pages(__GFP_DMA|GFP_KERNEL,
 			(int)pages_to_order_of_mag(claw_write_pages ));
                 if (privptr->p_buff_write==NULL) {
                         printk(KERN_INFO "%s: %s() __get_free_pages for write"
@@ -2413,7 +2413,7 @@ init_ccw_bk(struct net_device *dev)
            {
                privptr->p_write_free_chain=NULL;
                for (i = 0; i< privptr->p_env->write_buffers ; i++) {
-                   p_buff=(void *)__get_free_pages(__GFP_DMA,
+                   p_buff=(void *)__get_free_pages(__GFP_DMA|GFP_KERNEL,
 		        (int)pages_to_order_of_mag(
 			privptr->p_buff_pages_perwrite) );
 #ifdef IOTRACE
@@ -2489,7 +2489,7 @@ init_ccw_bk(struct net_device *dev)
         if (privptr->p_buff_read==NULL) {
             if (privptr->p_env->read_size < PAGE_SIZE)  {
                 privptr->p_buff_read=
-			(void *)__get_free_pages(__GFP_DMA,
+			(void *)__get_free_pages(__GFP_DMA|GFP_KERNEL,
 			(int)pages_to_order_of_mag(claw_read_pages) );
                 if (privptr->p_buff_read==NULL) {
                         printk(KERN_INFO "%s: %s() "
@@ -2603,7 +2603,7 @@ init_ccw_bk(struct net_device *dev)
 		dev->name,__FUNCTION__);
 #endif
                 for (i=0 ; i< privptr->p_env->read_buffers ; i++) {
-                        p_buff = (void *)__get_free_pages(__GFP_DMA,
+                        p_buff = (void *)__get_free_pages(__GFP_DMA|GFP_KERNEL,
 				(int)pages_to_order_of_mag(privptr->p_buff_pages_perread) );
                         if (p_buff==NULL) {
                                 printk(KERN_INFO "%s: %s() __get_free_pages for read "
drivers/scsi/pluto.c +1 -1
diff -urp -X other/Documentation/dontdiff truc/drivers/scsi/pluto.c other/drivers/scsi/pluto.c
@@ -116,7 +116,7 @@ int __init pluto_detect(Scsi_Host_Templa
 #endif
 			return 0;
 	}
-	fcs = (struct ctrl_inquiry *) kmalloc (sizeof (struct ctrl_inquiry) * fcscount, GFP_DMA);
+	fcs = (struct ctrl_inquiry *) kmalloc (sizeof (struct ctrl_inquiry) * fcscount, GFP_DMA|GFP_KERNEL);
 	if (!fcs) {
 		printk ("PLUTO: Not enough memory to probe\n");
 		return 0;