Search Linux Wireless

Re: [v2 05/11] rsi: Remove unnecessary buffer allocation

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 5/11/2017 8:28 PM, Kalle Valo wrote:
Amitkumar Karwar <amitkarwar@xxxxxxxxx> writes:

From: Prameela Rani Garnepudi <prameela.j04cs@xxxxxxxxx>

In functions usb read register and usb write register, dynamic allocation
of 4 bytes is used. This is removed as it is unncessary for local variable
and for such small data.

Signed-off-by: Prameela Rani Garnepudi <prameela.j04cs@xxxxxxxxx>
Signed-off-by: Amitkumar Karwar <amit.karwar@xxxxxxxxxxxxxxxxxx>
---
  drivers/net/wireless/rsi/rsi_91x_usb.c | 18 ++++--------------
  1 file changed, 4 insertions(+), 14 deletions(-)

diff --git a/drivers/net/wireless/rsi/rsi_91x_usb.c b/drivers/net/wireless/rsi/rsi_91x_usb.c
index 73b01a8..8eb7407 100644
--- a/drivers/net/wireless/rsi/rsi_91x_usb.c
+++ b/drivers/net/wireless/rsi/rsi_91x_usb.c
@@ -157,12 +157,8 @@ static int rsi_usb_reg_read(struct usb_device *usbdev,
  			    u16 *value,
  			    u16 len)
  {
-	u8 *buf;
-	int status = -ENOMEM;
-
-	buf  = kmalloc(0x04, GFP_KERNEL);
-	if (!buf)
-		return status;
+	u8 buf[4];
+	int status;
status = usb_control_msg(usbdev,
  				 usb_rcvctrlpipe(usbdev, 0),

Recently I got a patch to orinoco_usb which did exactly the opposite
(unless I'm missing something):

https://git.kernel.org/pub/scm/linux/kernel/git/kvalo/wireless-drivers-next.git/commit/?id=2f6ae79cb04bb7f9b4be3f1c32b6fda35bf976bc

The documentation for usb_control_msg() does not mention anything if
it's possible to use stack memory, but AFAIU it's not possible to use
stack memory with DMA. Can anyone clarify?

After private message I sent to Kalle here my public response :-p
According to Greg this has been a USB core requirement for a long, long time (see below).

Regards,
Arend

[1] http://marc.info/?l=linux-kernel&m=149391173014176&w=2

-------- Forwarded Message --------
Subject: Re: [PATCH] i2c: i2c-tiny-usb: fix buffer not being DMA capable
Date: Thu, 4 May 2017 08:27:09 -0700
From: Greg KH <gregkh@xxxxxxxxxxxxxxxxxxx>
To: Sebastian Reichel <sebastian.reichel@xxxxxxxxxxxxxxx>
CC: Sebastian Reichel <sre@xxxxxxxxxx>, Till Harbaum <till@xxxxxxxxxxx>, Wolfram Sang <wsa@xxxxxxxxxxxxx>, linux-i2c@xxxxxxxxxxxxxxx, linux-kernel@xxxxxxxxxxxxxxx, # Kernel 4 . 9+ <stable@xxxxxxxxxxxxxxx>

On Thu, May 04, 2017 at 02:56:32PM +0200, Sebastian Reichel wrote:
> The i2c-tiny-usb driver generates the following trace and fails to
> read or write data on a v4.9 or newer kernels. This patch avoids the
> problem by allocating a DMA capable buffer for data transfer.

[snip]

This has been a USB core requirement since the 2.2 days, it's only since
4.9 that most people have started to notice this.  So backporting it to
anything that it can go to is best to have happen :)

> Signed-off-by: Sebastian Reichel <sebastian.reichel@xxxxxxxxxxxxxxx>
> ---
>  drivers/i2c/busses/i2c-tiny-usb.c | 19 +++++++++++++++----
>  1 file changed, 15 insertions(+), 4 deletions(-)



[Index of Archives]     [Linux Host AP]     [ATH6KL]     [Linux Wireless Personal Area Network]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Linux Kernel]     [IDE]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite Hiking]     [MIPS Linux]     [ARM Linux]     [Linux RAID]

  Powered by Linux