Skip to contentSkip to conversation

drivers: rtl818x: request DMA-able memory

PATCH In review Serafeim Zanikolas 5 participants 9 messages Oct 24, 2010 – Oct 25, 2010

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

PATCH 1/1 drivers: rtl818x: request DMA-able memory

Despite the indicated intention in comment, the kmalloc() call was not explicitly requesting memory from ZONE_DMA.

---
 drivers/net/wireless/rtl818x/rtl8187_dev.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
drivers/net/wireless/rtl818x/rtl8187_dev.c +2 -1
index 38fa824..771794d 100644
@@ -1343,7 +1343,8 @@ static int __devinit rtl8187_probe(struct usb_interface *intf,
 	priv->is_rtl8187b = (id->driver_info == DEVICE_RTL8187B);
 
 	/* allocate "DMA aware" buffer for register accesses */
-	priv->io_dmabuf = kmalloc(sizeof(*priv->io_dmabuf), GFP_KERNEL);
+	priv->io_dmabuf = kmalloc(sizeof(*priv->io_dmabuf),
+				  GFP_DMA | GFP_KERNEL);
 	if (!priv->io_dmabuf) {
 		err = -ENOMEM;
 		goto err_free_dev;
Signature · 1 line
1.7.1
#1 lore raw
Quoted 13 lines · Serafeim Zanikolas

Despite the indicated intention in comment, the kmalloc() call was not explicitly requesting memory from ZONE_DMA.

---
 drivers/net/wireless/rtl818x/rtl8187_dev.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
drivers/net/wireless/rtl818x/rtl8187_dev.c +0 -0
index 38fa824..771794d 100644

drivers/net/wireless/rtl818x/rtl8187_dev.c static int __devinit rtl8187_probe(struct usb_interface *intf, · line 1350

Quoted 9 lines
drivers/net/wireless/rtl818x/rtl8187_dev.c +2 -1
@@ -1343,7 +1343,8 @@ static int __devinit rtl8187_probe(struct usb_interface *intf,
 	priv->is_rtl8187b = (id->driver_info == DEVICE_RTL8187B);
 
 	/* allocate "DMA aware" buffer for register accesses */
-	priv->io_dmabuf = kmalloc(sizeof(*priv->io_dmabuf), GFP_KERNEL);
+	priv->io_dmabuf = kmalloc(sizeof(*priv->io_dmabuf),
+				  GFP_DMA | GFP_KERNEL);
 	if (!priv->io_dmabuf) {
 		err = -ENOMEM;
 		goto err_free_dev;

ACK.

Larry

Acked-by
#2 lore raw
Quoted 26 lines · Larry Finger
Quoted 13 lines · Serafeim Zanikolas

Despite the indicated intention in comment, the kmalloc() call was not explicitly requesting memory from ZONE_DMA.

---
 drivers/net/wireless/rtl818x/rtl8187_dev.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
drivers/net/wireless/rtl818x/rtl8187_dev.c +0 -0
index 38fa824..771794d 100644

drivers/net/wireless/rtl818x/rtl8187_dev.c static int __devinit rtl8187_probe(struct usb_interface *intf, · line 1350

Quoted 9 lines
drivers/net/wireless/rtl818x/rtl8187_dev.c +2 -1
@@ -1343,7 +1343,8 @@ static int __devinit rtl8187_probe(struct usb_interface *intf,
 	priv->is_rtl8187b = (id->driver_info == DEVICE_RTL8187B);
 
 	/* allocate "DMA aware" buffer for register accesses */
-	priv->io_dmabuf = kmalloc(sizeof(*priv->io_dmabuf), GFP_KERNEL);
+	priv->io_dmabuf = kmalloc(sizeof(*priv->io_dmabuf),
+				  GFP_DMA | GFP_KERNEL);
 	if (!priv->io_dmabuf) {
 		err = -ENOMEM;
 		goto err_free_dev;

ACK.

Quoted 1 line

Larry

I had a quick look for similiar constructs and AFAIK only the b43/b43legacy drivers uses DMA buffers. Seems to be a rare practice. Is that something we should or should not do?

Hin-Tak

maintainer
#3 lore raw
Quoted 6 lines · Hin-Tak Leung
Quoted 2 lines
Quoted 2 lines

Despite the indicated intention in comment, the kmalloc() call was not explicitly requesting memory from ZONE_DMA.

I had a quick look for similiar constructs and AFAIK only the b43/b43legacy drivers uses DMA buffers. Seems to be a rare practice. Is that something we should or should not do?

I think there's some confusion here about ZONE_DMA vs. DMA-able memory. All memory you get with kmalloc can be used for DMA, GFP_DMA means using ZONE_DMA which is a hack for ISA (and in b43 maybe PCMCIA/Cardbus) devices to put memory into something they can address. I don't think the latter is necessary for USB devices.

johannes

#4 lore raw
In reply to Hin-Tak Leung
Quoted 28 lines · Hin-Tak Leung
Quoted 25 lines · Larry Finger
Quoted 13 lines · Serafeim Zanikolas

Despite the indicated intention in comment, the kmalloc() call was not explicitly requesting memory from ZONE_DMA.

---
drivers/net/wireless/rtl818x/rtl8187_dev.c | 3 ++-

1 files changed, 2 insertions(+), 1 deletions(-)
drivers/net/wireless/rtl818x/rtl8187_dev.c +0 -0
index 38fa824..771794d 100644

drivers/net/wireless/rtl818x/rtl8187_dev.c static int __devinit rtl8187_probe(struct usb_interface *intf, · line 1349

Quoted 8 lines
drivers/net/wireless/rtl818x/rtl8187_dev.c +2 -1
@@ -1343,7 +1343,8 @@ static int __devinit rtl8187_probe(struct usb_interface *intf,
 	priv->is_rtl8187b = (id->driver_info == DEVICE_RTL8187B);
 	/* allocate "DMA aware" buffer for register accesses */
-	priv->io_dmabuf = kmalloc(sizeof(*priv->io_dmabuf), GFP_KERNEL);
+	priv->io_dmabuf = kmalloc(sizeof(*priv->io_dmabuf),
+				  GFP_DMA | GFP_KERNEL);
 	if (!priv->io_dmabuf) {
 		err = -ENOMEM;
 		goto err_free_dev;

ACK.

Quoted 7 lines
Quoted 1 line

Larry

I had a quick look for similiar constructs and AFAIK only the b43/b43legacy drivers uses DMA buffers. Seems to be a rare practice. Is that something we should or should not do?

It doesn't mean what you think it means. It is a relic of the past, used to indicate memory below 16MB so that ISA devices could do DMA.

John

Signature · 2 lines
John W. Linville		Someday the world will need a hero, and you
[email protected]			might be all we have.  Be ready.
#5 lore raw
Quoted 10 lines · John W. Linville
Quoted 1 line

I had a quick look for similiar constructs and AFAIK

only the

Quoted 1 line

b43/b43legacy drivers uses DMA buffers. Seems to be a

rare practice.

Quoted 1 line

Is that something we should or should not do?

It doesn't mean what you think it means.  It is a relic of the past,
used to indicate memory below 16MB so that ISA devices could do DMA.

okay - sorry about the confusion - I was grep'ing for GFP_DMA and only b43/b43lagacy have it and it is relatively rare. AFAIK none of the rtl8187 devices are non-USB... probably a NACK then, but I should ask Serafeim if there is a reason for him to submit this patch? (other than "it says dma"...)

Hin-tak

#6 lore raw
Quoted 2 lines · Hin-Tak Leung

okay - sorry about the confusion - I was grep'ing for GFP_DMA and only b43/b43lagacy have it and it is relatively rare. AFAIK none of the rtl8187 devices are non-USB... probably a NACK then, but I should ask Serafeim if there is a reason for him to submit this patch? (other than "it says dma"...)

There are some devices driven by b43/b43legacy that implement only 24-bit DMA. For that reason, they need to allocate DMA buffers in the low 16 MB of RAM. For rtl8187, that consideration does not apply.

Larry

#7 lore raw
In reply to John W. Linville
Quoted 31 lines · John W. Linville
Quoted 30 lines · Hin-Tak Leung
Quoted 26 lines · Larry Finger
Quoted 13 lines · Serafeim Zanikolas

Despite the indicated intention in comment, the kmalloc() call was not explicitly requesting memory from ZONE_DMA.

---
drivers/net/wireless/rtl818x/rtl8187_dev.c | 3 ++-

1 files changed, 2 insertions(+), 1 deletions(-)
drivers/net/wireless/rtl818x/rtl8187_dev.c +0 -0
index 38fa824..771794d 100644

drivers/net/wireless/rtl818x/rtl8187_dev.c static int __devinit rtl8187_probe(struct usb_interface *intf, · line 1349

Quoted 8 lines
drivers/net/wireless/rtl818x/rtl8187_dev.c +2 -1
@@ -1343,7 +1343,8 @@ static int __devinit rtl8187_probe(struct usb_interface *intf,
 	priv->is_rtl8187b = (id->driver_info == DEVICE_RTL8187B);
 	/* allocate "DMA aware" buffer for register accesses */
-	priv->io_dmabuf = kmalloc(sizeof(*priv->io_dmabuf), GFP_KERNEL);
+	priv->io_dmabuf = kmalloc(sizeof(*priv->io_dmabuf),
+				  GFP_DMA | GFP_KERNEL);
 	if (!priv->io_dmabuf) {
 		err = -ENOMEM;
 		goto err_free_dev;

ACK.

Larry

Quoted 8 lines
Quoted 5 lines

I had a quick look for similiar constructs and AFAIK only the b43/b43legacy drivers uses DMA buffers. Seems to be a rare practice. Is that something we should or should not do?

It doesn't mean what you think it means. It is a relic of the past, used to indicate memory below 16MB so that ISA devices could do DMA.

Right. Sorry for the noise.

-S

#8 lore raw
In reply to Serafeim Zanikolas
Quoted 13 lines · Serafeim Zanikolas

Despite the indicated intention in comment, the kmalloc() call was not explicitly requesting memory from ZONE_DMA.

---
 drivers/net/wireless/rtl818x/rtl8187_dev.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
drivers/net/wireless/rtl818x/rtl8187_dev.c +0 -0
index 38fa824..771794d 100644

drivers/net/wireless/rtl818x/rtl8187_dev.c static int __devinit rtl8187_probe(struct usb_interface *intf, · line 1350

Quoted 9 lines
drivers/net/wireless/rtl818x/rtl8187_dev.c +2 -1
@@ -1343,7 +1343,8 @@ static int __devinit rtl8187_probe(struct usb_interface *intf,
 	priv->is_rtl8187b = (id->driver_info == DEVICE_RTL8187B);
 
 	/* allocate "DMA aware" buffer for register accesses */
-	priv->io_dmabuf = kmalloc(sizeof(*priv->io_dmabuf), GFP_KERNEL);
+	priv->io_dmabuf = kmalloc(sizeof(*priv->io_dmabuf),
+				  GFP_DMA | GFP_KERNEL);
 	if (!priv->io_dmabuf) {
 		err = -ENOMEM;
 		goto err_free_dev;

Are you sure about this? Are there USB controllers out there with the ISA 16MB limitation for DMA?

John

Signature · 2 lines
John W. Linville		Someday the world will need a hero, and you
[email protected]			might be all we have.  Be ready.