Re: [PATCH 2/2] staging: iio_simple_dummy: zero check param

2015-05-28 Thread Dan Carpenter
On Thu, May 28, 2015 at 01:12:40AM +0300, Vladimirs Ambrosovs wrote:
> On Wed, May 27, 2015 at 11:25:07AM +0300, Dan Carpenter wrote:
> > On Wed, May 27, 2015 at 01:19:58AM +0300, Vladimirs Ambrosovs wrote:
> > > Check for zero was added to the module parameter "instances" to
> > > avoid the allocation of array of zero values. Although it is a valid call,
> > > we don't want to allocate ZERO_SIZE_PTR, so need to disallow this case.
> > > The type of variables which are compared to "instances" were also changed
> > > to unsigned int so that no compiler complaints occur.
> > 
> > Which compiler is that?
> > 
> > You should get a different compiler if you compiler complains about
> > stupid stuff like that.  Making everything unsigned int is a common
> > cause of problems.  I fixed or reported several of those bugs yesterday.
> > 
> > "instances" should be unsigned int, though, you're correct about that.
> > 
> Mine is fine - not complaining ;). 
> 
> Got your point, although, in some cases, I think, these warnings not a
> stupid stuff, and could get some junior out of trouble.
> 
> But anyway, will keep in mind to stay away from unsigned ints. 

It's not a matter of staying away from unsigned ints, it's that some
people make everything unsigned by default.  That causes problems for
two reasons.  1) The kernel uses negative error codes.  2) int is the
default datatype when you want a "number" in C.  If you want a special
number then you make it unsigned int, u32, or unsigned long or whatever.
All those types mean something.  An unsigned int and a u32 are the same
to a computer but to a human they mean something different.  People who
use complicated datatypes all the time instead of just plain old int are
making the code complicated.


> > > 
> > > Signed-off-by: Vladimirs Ambrosovs 
> > > ---
> > >  drivers/staging/iio/iio_simple_dummy.c | 9 +
> > >  1 file changed, 5 insertions(+), 4 deletions(-)
> > > 
> > > diff --git a/drivers/staging/iio/iio_simple_dummy.c 
> > > b/drivers/staging/iio/iio_simple_dummy.c
> > > index 88fbb4f..2744a1b 100644
> > > --- a/drivers/staging/iio/iio_simple_dummy.c
> > > +++ b/drivers/staging/iio/iio_simple_dummy.c
> > > @@ -30,7 +30,7 @@
> > >   * dummy devices are registered.
> > >   */
> > >  static unsigned instances = 1;
> > > -module_param(instances, int, 0);
> > > +module_param(instances, uint, 0);
> > >  
> > >  /* Pointer array used to fake bus elements */
> > >  static struct iio_dev **iio_dummy_devs;
> > > @@ -706,9 +706,10 @@ static void iio_dummy_remove(int index)
> > >   */
> > >  static __init int iio_dummy_init(void)
> > >  {
> > > - int i, ret;
> > > + unsigned int i;
> > > + int ret;
> > 
> > No.
> > 
> > >  
> > > - if (instances > 10) {
> > > + if (instances == 0 || instances > 10) {
> > >   instances = 1;
> > >   return -EINVAL;
> > 
> > Allocating zero size arrays is a totally valid thing the kernel and it
> > doesn't cause a problem unless there are other existing serious bugs in
> > the code.  In this case instances == 0 is fine.
> > 
> Sorry, got a bit confused - is it fine to be in the code, or the 0
> value is valid, and shouldn't be checked for? The idea behind this
> change was not the allocation of zero size array, but the
> use of the module with 0 instances.

The changelog specifically mentioned a ZERO_SIZE_ARRAY.  If you had
said, "It doesn't make sense to load a module with 0 instances" then I
would have allowed the patch.  I don't care if you make this change or
not, but the changelog had wrong motivation.

regards,
dan carpenter
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH net-next 1/1] hv_netvsc: Properly size the vrss queues

2015-05-28 Thread Dan Carpenter
Since you're redoing this anyway.

On Tue, May 26, 2015 at 04:21:09PM -0700, K. Y. Srinivasan wrote:
> diff --git a/drivers/net/hyperv/hyperv_net.h b/drivers/net/hyperv/hyperv_net.h
> index ddcc7f8..dd45440 100644
> --- a/drivers/net/hyperv/hyperv_net.h
> +++ b/drivers/net/hyperv/hyperv_net.h
> @@ -161,6 +161,7 @@ struct netvsc_device_info {
>   unsigned char mac_adr[ETH_ALEN];
>   bool link_state;/* 0 - link up, 1 - link down */
>   int  ring_size;
> + u32  max_num_vrss_chns;

We (Joe and I) have commented before that long names don't mix well with
the 80 character limit.  You could just leave the "num_" out.  Almost
all variables are numbers in C so it doesn't add anything.

regards,
dan carpenter
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: gdm72xx: remove unneeded test

2015-05-28 Thread Dan Carpenter
On Wed, May 27, 2015 at 01:30:08PM -0700, Joe Perches wrote:
> On Wed, 2015-05-27 at 22:25 +0200, Laurent Navet wrote:
> > The same code is executed regardless ret value, so this test can be
> > removed.
> []
> > diff --git a/drivers/staging/gdm72xx/usb_boot.c 
> > b/drivers/staging/gdm72xx/usb_boot.c
> []
> > @@ -255,8 +255,6 @@ static int em_wait_ack(struct usb_device *usbdev, int 
> > send_zlp)
> >  
> > /*Wait for ACK*/
> > ret = gdm_wibro_recv(usbdev, &ack, sizeof(ack));
> > -   if (ret < 0)
> > -   goto out;
> >  out:
> > return ret;
> >  }
> 
> Perhaps all of the uses like:
> 
>   goto ;
> :
> 
> could be modified.  There are ~150 in the kernel.

Joe, these are a kind of style.  You're just directing a newbie into a
hornets nest.  Laurant, don't do listen to Joe unless you like getting
flamed.

regards,
dan carpenter

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: gdm72xx: remove unneeded test

2015-05-28 Thread Dan Carpenter
Obviously, I endorse this idea.  :)  Every out label in this file is
a do-nothing label or a do-everything label, but with bugs.  usb_boot()
should look like:

free_tx_buf:
kfree(tx_buf);
release_firm:
release_firmware(firm);

ret;

If we fail to allocate "tx_buf" then we should release the firmware.
em_download_image() has the same bug as well.

regards,
dan carpenter

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] fixing code style in sm750_accel.c

2015-05-28 Thread Dan Carpenter
You didn't try to compile this.

regards,
dan carpenter

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] Staging: vt6655: Remove unnecessary equality checks in rxtx.c

2015-05-28 Thread Harisangam, Sharvari (S.)
Modified the if-else statements to remove unnecessary comparisons in rxtx.c.
This change was detected with the help of coccinelle tool

Signed-off-by: Harisangam Sharvari 
---
 drivers/staging/vt6655/rxtx.c |8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/vt6655/rxtx.c b/drivers/staging/vt6655/rxtx.c
index 7468776..7fedde3 100644
--- a/drivers/staging/vt6655/rxtx.c
+++ b/drivers/staging/vt6655/rxtx.c
@@ -1093,7 +1093,7 @@ s_cbFillTxBufHead(struct vnt_private *pDevice, unsigned 
char byPktType,
if (byPktType == PK_TYPE_11GB || byPktType == PK_TYPE_11GA) {/* 802.11g 
packet */
 
if (byFBOption == AUTO_FB_NONE) {
-   if (bRTS == true) {/* RTS_need */
+   if (bRTS) {/* RTS_need */
pvRrvTime = (void *)(pbyTxBufferAddr + 
wTxBufSize);
pMICHDR = (struct vnt_mic_hdr 
*)(pbyTxBufferAddr + wTxBufSize + sizeof(struct vnt_rrv_time_rts));
pvRTS = (void *)(pbyTxBufferAddr + wTxBufSize + 
sizeof(struct vnt_rrv_time_rts) + cbMICHDR);
@@ -1115,7 +1115,7 @@ s_cbFillTxBufHead(struct vnt_private *pDevice, unsigned 
char byPktType,
}
} else {
/* Auto Fall Back */
-   if (bRTS == true) {/* RTS_need */
+   if (bRTS) {/* RTS_need */
pvRrvTime = (void *)(pbyTxBufferAddr + 
wTxBufSize);
pMICHDR = (struct vnt_mic_hdr *) 
(pbyTxBufferAddr + wTxBufSize + sizeof(struct vnt_rrv_time_rts));
pvRTS = (void *) (pbyTxBufferAddr + wTxBufSize 
+ sizeof(struct vnt_rrv_time_rts) + cbMICHDR);
@@ -1138,7 +1138,7 @@ s_cbFillTxBufHead(struct vnt_private *pDevice, unsigned 
char byPktType,
} else {/* 802.11a/b packet */
 
if (byFBOption == AUTO_FB_NONE) {
-   if (bRTS == true) {
+   if (bRTS) {
pvRrvTime = (void *)(pbyTxBufferAddr + 
wTxBufSize);
pMICHDR = (struct vnt_mic_hdr *) 
(pbyTxBufferAddr + wTxBufSize + sizeof(struct vnt_rrv_time_ab));
pvRTS = (void *)(pbyTxBufferAddr + wTxBufSize + 
sizeof(struct vnt_rrv_time_ab) + cbMICHDR);
@@ -1158,7 +1158,7 @@ s_cbFillTxBufHead(struct vnt_private *pDevice, unsigned 
char byPktType,
}
} else {
/* Auto Fall Back */
-   if (bRTS == true) { /* RTS_need */
+   if (bRTS) { /* RTS_need */
pvRrvTime = (void *)(pbyTxBufferAddr + 
wTxBufSize);
pMICHDR = (struct vnt_mic_hdr *) 
(pbyTxBufferAddr + wTxBufSize + sizeof(struct vnt_rrv_time_ab));
pvRTS = (void *)(pbyTxBufferAddr + wTxBufSize + 
sizeof(struct vnt_rrv_time_ab) + cbMICHDR);
-- 
1.7.9.5
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] Staging: vt6655: Remove unnecessary equality checks for a bool variable

2015-05-28 Thread Joe Perches
On Thu, 2015-05-28 at 06:10 +, Harisangam, Sharvari (S.) wrote:
> Modified the if-else statements to remove unnecessary comparisons.
> This change was detected with the help of coccinelle tool

Your commit subject implies you are doing this for the
directory, not a single file.

If you are going to do this, please do it for all files
in the directory.  

$ git grep  -w -E "if\s*\(.*(true|false)" drivers/staging/vt6655/
drivers/staging/vt6655/card.c:  if (pDevice->bRadioOff == true)
drivers/staging/vt6655/card.c:  if (pDevice->bRadioControlOff == true) {
drivers/staging/vt6655/card.c:  if (pDevice->bHWRadioOff == true)
drivers/staging/vt6655/card.c:  if (pDevice->bRadioControlOff == true)
drivers/staging/vt6655/card.c:  if (pDevice->bRadioOff == false) {
drivers/staging/vt6655/rxtx.c:  if (bRTS == true) {/* RTS_need 
*/
drivers/staging/vt6655/rxtx.c:  if (bRTS == true) {/* RTS_need 
*/
drivers/staging/vt6655/rxtx.c:  if (bRTS == true) {
drivers/staging/vt6655/rxtx.c:  if (bRTS == true) { /* RTS_need 
*/


___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: gdm72xx: remove unneeded test

2015-05-28 Thread Julia Lawall
On Thu, 28 May 2015, Joe Perches wrote:

> On Thu, 2015-05-28 at 10:14 +0300, Dan Carpenter wrote:
> > On Wed, May 27, 2015 at 01:30:08PM -0700, Joe Perches wrote:
> > > Perhaps all of the uses like:
> > >   goto ;
> > > :
> > >
> > > could be modified.  There are ~150 in the kernel.
> >
> > Joe, these are a kind of style.  You're just directing a newbie into a
> > hornets nest.  Laurant, don't do listen to Joe unless you like getting
> > flamed.
>
> Hey Dan.
>
> I didn't direct anyone to do anything, but that's
> why I added Julia to cc's.
>
> Anyway, I think these are very equivalent style to
> the repeated:
>
>   ret = foo();
>   if (ret < 0)
>   return ret;
> ...
>   ret = bar();
>   if (ret < 0)
>   return ret;
>
>   return ret;
>
> and people seem to prefer changing those.

Maybe if there is a whole sequence of them, it it is reasonable to keep
them.  But if there is just one, it seems complicated for nothing.  In the
big scheme of things, though, there are probably better things one could
do than changing all of them.

julia
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCHv2] staging: sm750fb: Add missing Kconfig dependency

2015-05-28 Thread Gujulan Elango, Hari Prasath (H.)
The sm750fb driver has few Framebuffer configuration dependencies that
need to be selected in order to get compiled successfully.

Signed-off-by: Gujulan Elango Hari Prasath 
---
v2:Addressed the review comments by Sudhip Mukherjee as I had
missed out a few other dependencies for this driver in my previous
version of the patch.
---
 drivers/staging/sm750fb/Kconfig | 4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/staging/sm750fb/Kconfig b/drivers/staging/sm750fb/Kconfig
index c40d088..59d7c52 100644
--- a/drivers/staging/sm750fb/Kconfig
+++ b/drivers/staging/sm750fb/Kconfig
@@ -1,6 +1,10 @@
 config FB_SM750
tristate "Silicon Motion SM750 framebuffer support"
depends on FB && PCI
+   select FB_MODE_HELPERS
+select FB_CFB_FILLRECT
+select FB_CFB_COPYAREA
+select FB_CFB_IMAGEBLIT
help
  Frame buffer driver for the Silicon Motion SM750 chip
  with 2D accelearion and dual head support.
-- 
1.9.1
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: gdm72xx: remove unneeded test

2015-05-28 Thread Joe Perches
On Thu, 2015-05-28 at 10:33 +0200, Julia Lawall wrote:
> On Thu, 28 May 2015, Joe Perches wrote:
> I think these are very equivalent style to
> > the repeated:
> >
> > ret = foo();
> > if (ret < 0)
> > return ret;
> > ...
> > ret = bar();
> > if (ret < 0)
> > return ret;
> >
> > return ret;
> >
> > and people seem to prefer changing those.
> 
> Maybe if there is a whole sequence of them, it it is reasonable to keep
> them.  But if there is just one, it seems complicated for nothing.

Agree with that.
https://lkml.org/lkml/2015/1/2/321

> In the
> big scheme of things, though, there are probably better things one could
> do than changing all of them.

Agree with that too.


___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: gdm72xx: remove unneeded test

2015-05-28 Thread Joe Perches
On Thu, 2015-05-28 at 10:14 +0300, Dan Carpenter wrote:
> On Wed, May 27, 2015 at 01:30:08PM -0700, Joe Perches wrote:
> > Perhaps all of the uses like:
> > goto ;
> > :
> > 
> > could be modified.  There are ~150 in the kernel.
> 
> Joe, these are a kind of style.  You're just directing a newbie into a
> hornets nest.  Laurant, don't do listen to Joe unless you like getting
> flamed.

Hey Dan.

I didn't direct anyone to do anything, but that's
why I added Julia to cc's.

Anyway, I think these are very equivalent style to
the repeated:

ret = foo();
if (ret < 0)
return ret;
...
ret = bar();
if (ret < 0)
return ret;

return ret;

and people seem to prefer changing those.

cheers, Joe

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCHv2] staging: sm750fb: Add missing Kconfig dependency

2015-05-28 Thread Dan Carpenter
On Thu, May 28, 2015 at 08:40:41AM +, Gujulan Elango, Hari Prasath (H.) 
wrote:
> diff --git a/drivers/staging/sm750fb/Kconfig b/drivers/staging/sm750fb/Kconfig
> index c40d088..59d7c52 100644
> --- a/drivers/staging/sm750fb/Kconfig
> +++ b/drivers/staging/sm750fb/Kconfig
> @@ -1,6 +1,10 @@
>  config FB_SM750
>   tristate "Silicon Motion SM750 framebuffer support"
>   depends on FB && PCI
> + select FB_MODE_HELPERS
> +select FB_CFB_FILLRECT
> +select FB_CFB_COPYAREA
> +select FB_CFB_IMAGEBLIT

These don't line up correctly.  Use tabs instead of spaces.

regards,
dan carpenter

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCHv3] staging: sm750fb: Add missing Kconfig dependency

2015-05-28 Thread Gujulan Elango, Hari Prasath (H.)
The sm750fb driver has few Framebuffer configuration dependencies that
need to be selected in order to get compiled successfully.

Signed-off-by: Gujulan Elango Hari Prasath 
---
v3: Fix alignment issues addressed by Dan Carpenter.

v2:Addressed the review comments by Sudhip Mukherjee as I had
missed out a few other dependencies for this driver in my previous
version of the patch.

Signed-off-by: Gujulan Elango Hari Prasath 
---
 drivers/staging/sm750fb/Kconfig | 4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/staging/sm750fb/Kconfig b/drivers/staging/sm750fb/Kconfig
index c40d088..ccebc25 100644
--- a/drivers/staging/sm750fb/Kconfig
+++ b/drivers/staging/sm750fb/Kconfig
@@ -1,6 +1,10 @@
 config FB_SM750
tristate "Silicon Motion SM750 framebuffer support"
depends on FB && PCI
+   select FB_MODE_HELPERS
+   select FB_CFB_FILLRECT
+   select FB_CFB_COPYAREA
+   select FB_CFB_IMAGEBLIT
help
  Frame buffer driver for the Silicon Motion SM750 chip
  with 2D accelearion and dual head support.
-- 
1.9.1
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCHv2] staging: sm750fb: Add missing Kconfig dependency

2015-05-28 Thread Gujulan Elango, Hari Prasath (H.)
On Thu, May 28, 2015 at 11:45:28AM +0300, Dan Carpenter wrote:
> On Thu, May 28, 2015 at 08:40:41AM +, Gujulan Elango, Hari Prasath (H.) 
> wrote:
> > diff --git a/drivers/staging/sm750fb/Kconfig 
> > b/drivers/staging/sm750fb/Kconfig
> > index c40d088..59d7c52 100644
> > --- a/drivers/staging/sm750fb/Kconfig
> > +++ b/drivers/staging/sm750fb/Kconfig
> > @@ -1,6 +1,10 @@
> >  config FB_SM750
> > tristate "Silicon Motion SM750 framebuffer support"
> > depends on FB && PCI
> > +   select FB_MODE_HELPERS
> > +select FB_CFB_FILLRECT
> > +select FB_CFB_COPYAREA
> > +select FB_CFB_IMAGEBLIT
> 
> These don't line up correctly.  Use tabs instead of spaces.
> 
> regards,
> dan carpenter
> 

I resend v3 but it seems there is a duplicate signature.Please dicard it
as well.I am sending v4 now.
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCHv2] staging: sm750fb: Add missing Kconfig dependency

2015-05-28 Thread Dan Carpenter
On Thu, May 28, 2015 at 08:54:12AM +, Gujulan Elango, Hari Prasath (H.) 
wrote:
> 
> I resend v3 but it seems there is a duplicate signature.Please dicard it
> as well.I am sending v4 now.

v3 is fine.  The duplicate sign-off is below the cut off line --- so it
will be removed automatically.

regards,
dan carpenter

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCHv3] staging: sm750fb: Add missing Kconfig dependency

2015-05-28 Thread Gujulan Elango, Hari Prasath (H.)
The sm750fb driver has few Framebuffer configuration dependencies that
need to be selected in order to get compiled successfully

Signed-off-by: Gujulan Elango Hari Prasath 
---
v3: Fix alignment issues addressed by Dan Carpenter.

v2:Addressed the review comments by Sudhip Mukherjee as I had
missed out a few other dependencies for this driver in my previous
version of the patch.
---
 drivers/staging/sm750fb/Kconfig | 4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/staging/sm750fb/Kconfig b/drivers/staging/sm750fb/Kconfig
index c40d088..ccebc25 100644
--- a/drivers/staging/sm750fb/Kconfig
+++ b/drivers/staging/sm750fb/Kconfig
@@ -1,6 +1,10 @@
 config FB_SM750
tristate "Silicon Motion SM750 framebuffer support"
depends on FB && PCI
+   select FB_MODE_HELPERS
+   select FB_CFB_FILLRECT
+   select FB_CFB_COPYAREA
+   select FB_CFB_IMAGEBLIT
help
  Frame buffer driver for the Silicon Motion SM750 chip
  with 2D accelearion and dual head support.
-- 
1.9.1
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCHv2] staging: sm750fb: Add missing Kconfig dependency

2015-05-28 Thread Gujulan Elango, Hari Prasath (H.)
On Thu, May 28, 2015 at 11:57:54AM +0300, Dan Carpenter wrote:
> On Thu, May 28, 2015 at 08:54:12AM +, Gujulan Elango, Hari Prasath (H.) 
> wrote:
> > 
> > I resend v3 but it seems there is a duplicate signature.Please dicard it
> > as well.I am sending v4 now.
> 
> v3 is fine.  The duplicate sign-off is below the cut off line --- so it
> will be removed automatically.
> 
> regards,
> dan carpenter
> 

checkpatch warned about it & so I resend it.But it should have been send
as v4,I send it as v3.I screwed up a bit.
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v3] staging: lustre: fix non-static symbol warnings reported by sparse

2015-05-28 Thread Marcus Folkesson
Warnings reported by sparse:

drivers/staging/lustre/lustre/ptlrpc/pinger.c:94:5:
warning: symbol 'ptlrpc_ping' was not declared. Should it be static?

drivers/staging/lustre/lustre/ptlrpc/pinger.c:113:6:
warning: symbol 'ptlrpc_update_next_ping' was not declared. Should it be static

drivers/staging/lustre/lustre/ptlrpc/pinger.c:144:6:
warning: symbol 'pinger_check_timeout' was not declared. Should it be static?

drivers/staging/lustre/lustre/ptlrpc/pinger.c:425:21:
warning: symbol 'ptlrpc_new_timeout' was not declared. Should it be static?

drivers/staging/lustre/lustre/ptlrpc/pinger.c:551:1:
warning: symbol 'pet_list' was not declared. Should it be static?

Signed-off-by: Marcus Folkesson 
---
Changelog:
v3: put the changelog into the patch itself
v2: change commit message to be more descriptive

 drivers/staging/lustre/lustre/ptlrpc/pinger.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/lustre/lustre/ptlrpc/pinger.c 
b/drivers/staging/lustre/lustre/ptlrpc/pinger.c
index 5abb91c..9fc8156 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/pinger.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/pinger.c
@@ -91,7 +91,7 @@ int ptlrpc_obd_ping(struct obd_device *obd)
 }
 EXPORT_SYMBOL(ptlrpc_obd_ping);
 
-int ptlrpc_ping(struct obd_import *imp)
+static int ptlrpc_ping(struct obd_import *imp)
 {
struct ptlrpc_request *req;
 
@@ -110,7 +110,7 @@ int ptlrpc_ping(struct obd_import *imp)
return 0;
 }
 
-void ptlrpc_update_next_ping(struct obd_import *imp, int soon)
+static void ptlrpc_update_next_ping(struct obd_import *imp, int soon)
 {
int time = soon ? PING_INTERVAL_SHORT : PING_INTERVAL;
if (imp->imp_state == LUSTRE_IMP_DISCON) {
@@ -141,7 +141,7 @@ static inline int ptlrpc_next_reconnect(struct obd_import 
*imp)
return cfs_time_shift(obd_timeout);
 }
 
-long pinger_check_timeout(unsigned long time)
+static long pinger_check_timeout(unsigned long time)
 {
struct timeout_item *item;
unsigned long timeout = PING_INTERVAL;
@@ -422,8 +422,8 @@ EXPORT_SYMBOL(ptlrpc_pinger_del_import);
  * Register a timeout callback to the pinger list, and the callback will
  * be called when timeout happens.
  */
-struct timeout_item *ptlrpc_new_timeout(int time, enum timeout_event event,
-   timeout_cb_t cb, void *data)
+static struct timeout_item *ptlrpc_new_timeout(int time,
+   enum timeout_event event, timeout_cb_t cb, void *data)
 {
struct timeout_item *ti;
 
@@ -548,7 +548,7 @@ void ptlrpc_pinger_wake_up(void)
 static int pet_refcount;
 static intpet_state;
 static wait_queue_head_t   pet_waitq;
-LIST_HEAD(pet_list);
+static LIST_HEAD(pet_list);
 static DEFINE_SPINLOCK(pet_lock);
 
 int ping_evictor_wake(struct obd_export *exp)
-- 
1.9.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCHv2 00/16] vme DMA and user space driver improvements

2015-05-28 Thread Dmitry Kalinkin
The first item in this submission documents previously introduced
vme_master_mmap() call. Following, there are three fixes for the tsi148
driver's DMA.  There was one bug that rendered it imposible to use DMA
lists with more than one item. The other was related to the place where
dma_map_single was called on the first DMA descriptor in the DMA list. The 
last bug was about DMA transfer not stopping at interruption by signal,
which is a possible DoS attack vector. I also made an attempt to fix the
same issue in the ca91cx42 driver. I don't have access to this hardware to
test, so this is based only on my understanding of the datasheet (checked  
ca91c042's errata as well).

A new /sys/bus/vme/dma0 device with a new ioctl for making DMA transfers
was introduced in vme_user driver. The logic of the function is similar to 
the one found in existing drivers.

One question that I had while implementing this feature was whether we 
should keep vme_dma_attr objects until vme_dma_list_exec() call. API
doesn't specify this, the existing vme bridge drivers copy all information
from attributes during vme_dma_list_add(). So for simplicity this  
implementation frees vme_dma_attr's before vme_dma_list_exec() is done.

A simple test against AVM16 board displays speeds around 45 MiB/s for
A32/D32 reads for both BLT and MBLT (with MBLT being slightly faster). 
 
Changes in v2 [patches 1-6, now 1-5 and 8]:
 * vme_addr check for vme_user DMA 
 * limit on DMA operation length in vme_user
 * reorder dma_op ioctl struct to omit __packed attribute 
 * change dma_op->write into dma_op->dir   
 * use vme_check_window assure DMA operation correctness   

New changes include vme_user code cleanup, a couple of ca91cx42 fixes
(again, tested for compilation only).

I also propose a change to export some of VME subsytem related constants
to the user space. These can be useful if vme_user is to go into the kernel.
Also, email
http://driverdev.linuxdriverproject.org/pipermail/driverdev-devel/2012-July/029084.html
mentions that we probably can now get rid of this comment:
> /* XXX  We do not want to push aspace, cycle and width
>  *  to userspace as they are
>  */

Dmitry Kalinkin (16):
  Documentation: mention vme_master_mmap() in VME API
  vme: tsi148: fix DMA lists longer that one item
  vme: tsi148: fix first DMA item mapping
  vme: stop DMA transfer on interruption
  staging: vme_user: refactor llseek to switch(){}
  vme: check for A64 overflow in vme_check_window()
  vme: export vme_check_window()
  staging: vme_user: provide DMA functionality
  vme: ca91cx42: return error code on DMA error
  vme: ca91cx42: fix LM_CTL address mask
  staging: vme_user: remove unused counters
  staging: vme_user: remove forward declarations
  staging: vme_user: remove open/release
  staging: vme_user: remove buf_unalloc helper
  vme: tsi148: depend on HAS_DMA for Kconfig
  vme: provide uapi header

 Documentation/vme_api.txt  |   6 +
 drivers/staging/vme/devices/vme_user.c | 454 +++--
 drivers/staging/vme/devices/vme_user.h |  11 +
 drivers/vme/bridges/Kconfig|   2 +-
 drivers/vme/bridges/vme_ca91cx42.c |  18 +-
 drivers/vme/bridges/vme_ca91cx42.h |   2 +-
 drivers/vme/bridges/vme_tsi148.c   |  42 +--
 drivers/vme/vme.c  |  11 +-
 include/linux/vme.h|  56 +---
 include/uapi/linux/Kbuild  |   1 +
 include/uapi/linux/vme.h   |  56 
 11 files changed, 394 insertions(+), 265 deletions(-)
 create mode 100644 include/uapi/linux/vme.h

-- 
1.8.3.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCHv2 01/16] Documentation: mention vme_master_mmap() in VME API

2015-05-28 Thread Dmitry Kalinkin
Signed-off-by: Dmitry Kalinkin 
Cc: Igor Alekseev 
---
 Documentation/vme_api.txt | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/Documentation/vme_api.txt b/Documentation/vme_api.txt
index ffe6e22..ca5b827 100644
--- a/Documentation/vme_api.txt
+++ b/Documentation/vme_api.txt
@@ -171,6 +171,12 @@ This functions by reading the offset, applying the mask. 
If the bits selected in
 the mask match with the values of the corresponding bits in the compare field,
 the value of swap is written the specified offset.
 
+Parts of a VME window can be mapped into user space memory using the following
+function:
+
+   int vme_master_mmap(struct vme_resource *resource,
+   struct vm_area_struct *vma)
+
 
 Slave windows
 =
-- 
1.8.3.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCHv2 06/16] vme: check for A64 overflow in vme_check_window()

2015-05-28 Thread Dmitry Kalinkin
Signed-off-by: Dmitry Kalinkin 
Cc: Igor Alekseev 
---
 drivers/vme/vme.c | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/vme/vme.c b/drivers/vme/vme.c
index 6bab2c4..1b78d27 100644
--- a/drivers/vme/vme.c
+++ b/drivers/vme/vme.c
@@ -199,10 +199,8 @@ static int vme_check_window(u32 aspace, unsigned long long 
vme_base,
retval = -EFAULT;
break;
case VME_A64:
-   /*
-* Any value held in an unsigned long long can be used as the
-* base
-*/
+   if ((size != 0) && (vme_base > U64_MAX + 1 - size))
+   retval = -EFAULT;
break;
case VME_CRCSR:
if (((vme_base + size) > VME_CRCSR_MAX) ||
-- 
1.8.3.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCHv2 07/16] vme: export vme_check_window()

2015-05-28 Thread Dmitry Kalinkin
Signed-off-by: Dmitry Kalinkin 
Cc: Igor Alekseev 
---
 drivers/vme/vme.c   | 5 +++--
 include/linux/vme.h | 2 ++
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/vme/vme.c b/drivers/vme/vme.c
index 1b78d27..5670891 100644
--- a/drivers/vme/vme.c
+++ b/drivers/vme/vme.c
@@ -177,8 +177,8 @@ size_t vme_get_size(struct vme_resource *resource)
 }
 EXPORT_SYMBOL(vme_get_size);
 
-static int vme_check_window(u32 aspace, unsigned long long vme_base,
-   unsigned long long size)
+int vme_check_window(u32 aspace, unsigned long long vme_base,
+unsigned long long size)
 {
int retval = 0;
 
@@ -221,6 +221,7 @@ static int vme_check_window(u32 aspace, unsigned long long 
vme_base,
 
return retval;
 }
+EXPORT_SYMBOL(vme_check_window);
 
 /*
  * Request a slave image with specific attributes, return some unique
diff --git a/include/linux/vme.h b/include/linux/vme.h
index 79242e9..c013135 100644
--- a/include/linux/vme.h
+++ b/include/linux/vme.h
@@ -120,6 +120,8 @@ void vme_free_consistent(struct vme_resource *, size_t,  
void *,
dma_addr_t);
 
 size_t vme_get_size(struct vme_resource *);
+int vme_check_window(u32 aspace, unsigned long long vme_base,
+unsigned long long size);
 
 struct vme_resource *vme_slave_request(struct vme_dev *, u32, u32);
 int vme_slave_set(struct vme_resource *, int, unsigned long long,
-- 
1.8.3.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCHv2 11/16] staging: vme_user: remove unused counters

2015-05-28 Thread Dmitry Kalinkin
Signed-off-by: Dmitry Kalinkin 
Cc: Igor Alekseev 
---
 drivers/staging/vme/devices/vme_user.c | 31 ---
 1 file changed, 31 deletions(-)

diff --git a/drivers/staging/vme/devices/vme_user.c 
b/drivers/staging/vme/devices/vme_user.c
index ca7ea6b..ed374d9 100644
--- a/drivers/staging/vme/devices/vme_user.c
+++ b/drivers/staging/vme/devices/vme_user.c
@@ -107,18 +107,6 @@ struct image_desc {
 };
 static struct image_desc image[VME_DEVS];
 
-struct driver_stats {
-   unsigned long reads;
-   unsigned long writes;
-   unsigned long ioctls;
-   unsigned long irqs;
-   unsigned long berrs;
-   unsigned long dmaerrors;
-   unsigned long timeouts;
-   unsigned long external;
-};
-static struct driver_stats statistics;
-
 static struct cdev *vme_user_cdev; /* Character device */
 static struct class *vme_user_sysfs_class; /* Sysfs class */
 static struct vme_dev *vme_user_bridge;/* Pointer to user 
device */
@@ -170,20 +158,6 @@ static const struct vm_operations_struct vme_user_vm_ops = 
{
 };
 
 
-/*
- * Reset all the statistic counters
- */
-static void reset_counters(void)
-{
-   statistics.reads = 0;
-   statistics.writes = 0;
-   statistics.ioctls = 0;
-   statistics.irqs = 0;
-   statistics.berrs = 0;
-   statistics.dmaerrors = 0;
-   statistics.timeouts = 0;
-}
-
 static int vme_user_open(struct inode *inode, struct file *file)
 {
int err;
@@ -631,8 +605,6 @@ static int vme_user_ioctl(struct inode *inode, struct file 
*file,
dma_addr_t pci_addr;
void __user *argp = (void __user *)arg;
 
-   statistics.ioctls++;
-
switch (type[minor]) {
case CONTROL_MINOR:
switch (cmd) {
@@ -944,9 +916,6 @@ static int vme_user_probe(struct vme_dev *vdev)
image[i].users = 0;
}
 
-   /* Initialise statistics counters */
-   reset_counters();
-
/* Assign major and minor numbers for the driver */
err = register_chrdev_region(MKDEV(VME_MAJOR, 0), VME_DEVS,
driver_name);
-- 
1.8.3.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCHv2 08/16] staging: vme_user: provide DMA functionality

2015-05-28 Thread Dmitry Kalinkin
This introduces a new dma device that provides a single ioctl call that
provides DMA read and write functionality to the user space.

Signed-off-by: Dmitry Kalinkin 
Cc: Igor Alekseev 
---
 drivers/staging/vme/devices/vme_user.c | 201 -
 drivers/staging/vme/devices/vme_user.h |  11 ++
 2 files changed, 209 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/vme/devices/vme_user.c 
b/drivers/staging/vme/devices/vme_user.c
index da828f4..ca7ea6b 100644
--- a/drivers/staging/vme/devices/vme_user.c
+++ b/drivers/staging/vme/devices/vme_user.c
@@ -79,15 +79,18 @@ static unsigned int bus_num;
  * We shall support 4 masters and 4 slaves with this driver.
  */
 #define VME_MAJOR  221 /* VME Major Device Number */
-#define VME_DEVS   9   /* Number of dev entries */
+#define VME_DEVS   10  /* Number of dev entries */
 
 #define MASTER_MINOR   0
 #define MASTER_MAX 3
 #define SLAVE_MINOR4
 #define SLAVE_MAX  7
 #define CONTROL_MINOR  8
+#define DMA_MINOR  9
 
-#define PCI_BUF_SIZE  0x2  /* Size of one slave image buffer */
+#define PCI_BUF_SIZE   0x2 /* Size of one slave image buffer */
+
+#define VME_MAX_DMA_LEN0x400   /* Maximal DMA transfer length 
*/
 
 /*
  * Structure to handle image related parameters.
@@ -125,7 +128,7 @@ static const int type[VME_DEVS] = { MASTER_MINOR,   
MASTER_MINOR,
MASTER_MINOR,   MASTER_MINOR,
SLAVE_MINOR,SLAVE_MINOR,
SLAVE_MINOR,SLAVE_MINOR,
-   CONTROL_MINOR
+   CONTROL_MINOR,  DMA_MINOR
};
 
 
@@ -443,6 +446,168 @@ static loff_t vme_user_llseek(struct file *file, loff_t 
off, int whence)
return -EINVAL;
 }
 
+static int vme_user_sg_to_dma_list(const struct vme_dma_op *dma_op,
+  struct sg_table *sgt,
+  int sg_count, struct vme_dma_list *dma_list)
+{
+   ssize_t pos = 0;
+   struct scatterlist *sg;
+   int i, ret;
+
+   for_each_sg(sgt->sgl, sg, sg_count, i) {
+   struct vme_dma_attr *pci_attr, *vme_attr, *src, *dest;
+   dma_addr_t hw_address = sg_dma_address(sg);
+   unsigned int hw_len = sg_dma_len(sg);
+
+   vme_attr = vme_dma_vme_attribute(dma_op->vme_addr + pos,
+dma_op->aspace,
+dma_op->cycle,
+dma_op->dwidth);
+   if (!vme_attr)
+   return -ENOMEM;
+
+   pci_attr = vme_dma_pci_attribute(hw_address);
+   if (!pci_attr) {
+   vme_dma_free_attribute(vme_attr);
+   return -ENOMEM;
+   }
+
+   switch(dma_op->dir) {
+   case VME_DMA_MEM_TO_VME:
+   src = pci_attr;
+   dest = vme_attr;
+   break;
+   case VME_DMA_VME_TO_MEM:
+   src = vme_attr;
+   dest = pci_attr;
+   break;
+   }
+
+   ret = vme_dma_list_add(dma_list, src, dest, hw_len);
+
+   /*
+* XXX VME API doesn't mention whether we should keep
+* attributes around
+*/
+   vme_dma_free_attribute(vme_attr);
+   vme_dma_free_attribute(pci_attr);
+
+   if (ret)
+   return ret;
+
+   pos += hw_len;
+   }
+
+   return 0;
+}
+
+static enum dma_data_direction vme_dir_to_dma_dir(unsigned vme_dir)
+{
+   switch(vme_dir) {
+   case VME_DMA_VME_TO_MEM:
+   return DMA_FROM_DEVICE;
+   case VME_DMA_MEM_TO_VME:
+   return DMA_TO_DEVICE;
+   }
+
+   return DMA_NONE;
+}
+
+static ssize_t vme_user_dma_ioctl(unsigned int minor,
+ const struct vme_dma_op *dma_op)
+{
+   unsigned int offset = offset_in_page(dma_op->buf_vaddr);
+   unsigned long nr_pages;
+   enum dma_data_direction dir;
+   struct vme_dma_list *dma_list;
+   struct sg_table *sgt = NULL;
+   struct page **pages = NULL;
+   long got_pages;
+   ssize_t count;
+   int retval, sg_count;
+
+   /* Prevent WARN from dma_map_sg */
+   if (dma_op->count == 0)
+   return 0;
+
+   /*
+* This is a voluntary limit to prevent huge allocation for pages
+* array. VME_MAX_DMA_LEN is not a fundamental VME constraint.
+*/
+   count = min_t(size_t, dma_op->count, VME_MAX_DMA_LEN);
+   nr_pages = (offset + count + PAGE_SIZE - 1) >> PAGE_SHIFT;
+
+   dir = vme_dir_to_dma_dir(dma_op->dir);
+   if (dir 

[PATCHv2 03/16] vme: tsi148: fix first DMA item mapping

2015-05-28 Thread Dmitry Kalinkin
This moves DMA mapping of the first list element to vme_list_add, the
same place where other elements mappings occur. This prevents extra
mapping or over-unmapping in the cases when vme_list_exec is called more
or less than one time respectively.

Also adds dma_mapping_error check.

Signed-off-by: Dmitry Kalinkin 
Cc: Igor Alekseev 
---
 drivers/vme/bridges/vme_tsi148.c | 23 ---
 1 file changed, 12 insertions(+), 11 deletions(-)

diff --git a/drivers/vme/bridges/vme_tsi148.c b/drivers/vme/bridges/vme_tsi148.c
index 1be4136..6562348 100644
--- a/drivers/vme/bridges/vme_tsi148.c
+++ b/drivers/vme/bridges/vme_tsi148.c
@@ -1833,17 +1833,21 @@ static int tsi148_dma_list_add(struct vme_dma_list 
*list,
/* Add to list */
list_add_tail(&entry->list, &list->entries);
 
+   entry->dma_handle = dma_map_single(tsi148_bridge->parent,
+   &entry->descriptor,
+   sizeof(struct tsi148_dma_descriptor), DMA_TO_DEVICE);
+   if (dma_mapping_error(tsi148_bridge->parent, entry->dma_handle)) {
+   dev_err(tsi148_bridge->parent, "DMA mapping error\n");
+   retval = -EINVAL;
+   goto err_dma;
+   }
+
/* Fill out previous descriptors "Next Address" */
if (entry->list.prev != &list->entries) {
-   prev = list_entry(entry->list.prev, struct tsi148_dma_entry,
-   list);
-   /* We need the bus address for the pointer */
-   entry->dma_handle = dma_map_single(tsi148_bridge->parent,
-   &entry->descriptor,
-   sizeof(struct tsi148_dma_descriptor), DMA_TO_DEVICE);
-
reg_split((unsigned long long)entry->dma_handle, &address_high,
&address_low);
+   prev = list_entry(entry->list.prev, struct tsi148_dma_entry,
+ list);
prev->descriptor.dnlau = cpu_to_be32(address_high);
prev->descriptor.dnlal = cpu_to_be32(address_low);
 
@@ -1851,6 +1855,7 @@ static int tsi148_dma_list_add(struct vme_dma_list *list,
 
return 0;
 
+err_dma:
 err_dest:
 err_source:
 err_align:
@@ -1921,10 +1926,6 @@ static int tsi148_dma_list_exec(struct vme_dma_list 
*list)
entry = list_first_entry(&list->entries, struct tsi148_dma_entry,
list);
 
-   entry->dma_handle = dma_map_single(tsi148_bridge->parent,
-   &entry->descriptor,
-   sizeof(struct tsi148_dma_descriptor), DMA_TO_DEVICE);
-
mutex_unlock(&ctrlr->mtx);
 
reg_split(entry->dma_handle, &bus_addr_high, &bus_addr_low);
-- 
1.8.3.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCHv2 09/16] vme: ca91cx42: return error code on DMA error

2015-05-28 Thread Dmitry Kalinkin
Signed-off-by: Dmitry Kalinkin 
Cc: Igor Alekseev 
---
 drivers/vme/bridges/vme_ca91cx42.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/vme/bridges/vme_ca91cx42.c 
b/drivers/vme/bridges/vme_ca91cx42.c
index e9bd657..f692efc 100644
--- a/drivers/vme/bridges/vme_ca91cx42.c
+++ b/drivers/vme/bridges/vme_ca91cx42.c
@@ -1269,6 +1269,7 @@ static int ca91cx42_dma_list_exec(struct vme_dma_list 
*list)
 
dev_err(dev, "ca91c042: DMA Error. DGCS=%08X\n", val);
val = ioread32(bridge->base + DCTL);
+   retval = -EIO;
}
 
 exit:
-- 
1.8.3.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCHv2 04/16] vme: stop DMA transfer on interruption

2015-05-28 Thread Dmitry Kalinkin
Signed-off-by: Dmitry Kalinkin 
Cc: Igor Alekseev 
---
 drivers/vme/bridges/vme_ca91cx42.c | 17 ++---
 drivers/vme/bridges/vme_tsi148.c   | 15 +--
 2 files changed, 27 insertions(+), 5 deletions(-)

diff --git a/drivers/vme/bridges/vme_ca91cx42.c 
b/drivers/vme/bridges/vme_ca91cx42.c
index 18078ec..e9bd657 100644
--- a/drivers/vme/bridges/vme_ca91cx42.c
+++ b/drivers/vme/bridges/vme_ca91cx42.c
@@ -1192,7 +1192,7 @@ static int ca91cx42_dma_list_exec(struct vme_dma_list 
*list)
 {
struct vme_dma_resource *ctrlr;
struct ca91cx42_dma_entry *entry;
-   int retval = 0;
+   int retval;
dma_addr_t bus_addr;
u32 val;
struct device *dev;
@@ -1245,8 +1245,18 @@ static int ca91cx42_dma_list_exec(struct vme_dma_list 
*list)
 
iowrite32(val, bridge->base + DGCS);
 
-   wait_event_interruptible(bridge->dma_queue,
-   ca91cx42_dma_busy(ctrlr->parent));
+   retval = wait_event_interruptible(bridge->dma_queue,
+ ca91cx42_dma_busy(ctrlr->parent));
+
+   if (retval) {
+   val = ioread32(bridge->base + DGCS);
+   iowrite32(val | CA91CX42_DGCS_STOP_REQ, bridge->base + DGCS);
+   /* Wait for the operation to abort */
+   wait_event(bridge->dma_queue,
+  ca91cx42_dma_busy(ctrlr->parent));
+   retval = -EINTR;
+   goto exit;
+   }
 
/*
 * Read status register, this register is valid until we kick off a
@@ -1261,6 +1271,7 @@ static int ca91cx42_dma_list_exec(struct vme_dma_list 
*list)
val = ioread32(bridge->base + DCTL);
}
 
+exit:
/* Remove list from running list */
mutex_lock(&ctrlr->mtx);
list_del(&list->list);
diff --git a/drivers/vme/bridges/vme_tsi148.c b/drivers/vme/bridges/vme_tsi148.c
index 6562348..fb1e7ad 100644
--- a/drivers/vme/bridges/vme_tsi148.c
+++ b/drivers/vme/bridges/vme_tsi148.c
@@ -1892,7 +1892,7 @@ static int tsi148_dma_busy(struct vme_bridge 
*tsi148_bridge, int channel)
 static int tsi148_dma_list_exec(struct vme_dma_list *list)
 {
struct vme_dma_resource *ctrlr;
-   int channel, retval = 0;
+   int channel, retval;
struct tsi148_dma_entry *entry;
u32 bus_addr_high, bus_addr_low;
u32 val, dctlreg = 0;
@@ -1942,9 +1942,19 @@ static int tsi148_dma_list_exec(struct vme_dma_list 
*list)
iowrite32be(dctlreg | TSI148_LCSR_DCTL_DGO, bridge->base +
TSI148_LCSR_DMA[channel] + TSI148_LCSR_OFFSET_DCTL);
 
-   wait_event_interruptible(bridge->dma_queue[channel],
+   retval = wait_event_interruptible(bridge->dma_queue[channel],
tsi148_dma_busy(ctrlr->parent, channel));
 
+   if (retval) {
+   iowrite32be(dctlreg | TSI148_LCSR_DCTL_ABT, bridge->base +
+   TSI148_LCSR_DMA[channel] + TSI148_LCSR_OFFSET_DCTL);
+   /* Wait for the operation to abort */
+   wait_event(bridge->dma_queue[channel],
+  tsi148_dma_busy(ctrlr->parent, channel));
+   retval = -EINTR;
+   goto exit;
+   }
+
/*
 * Read status register, this register is valid until we kick off a
 * new transfer.
@@ -1957,6 +1967,7 @@ static int tsi148_dma_list_exec(struct vme_dma_list *list)
retval = -EIO;
}
 
+exit:
/* Remove list from running list */
mutex_lock(&ctrlr->mtx);
list_del(&list->list);
-- 
1.8.3.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCHv2 05/16] staging: vme_user: refactor llseek to switch(){}

2015-05-28 Thread Dmitry Kalinkin
This makes vme_user_llseek ignore all minors that don't have llseek
implementation.

Signed-off-by: Dmitry Kalinkin 
Cc: Igor Alekseev 
---
 drivers/staging/vme/devices/vme_user.c | 18 ++
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/drivers/staging/vme/devices/vme_user.c 
b/drivers/staging/vme/devices/vme_user.c
index 19ba749..da828f4 100644
--- a/drivers/staging/vme/devices/vme_user.c
+++ b/drivers/staging/vme/devices/vme_user.c
@@ -430,15 +430,17 @@ static loff_t vme_user_llseek(struct file *file, loff_t 
off, int whence)
size_t image_size;
loff_t res;
 
-   if (minor == CONTROL_MINOR)
-   return -EINVAL;
-
-   mutex_lock(&image[minor].mutex);
-   image_size = vme_get_size(image[minor].resource);
-   res = fixed_size_llseek(file, off, whence, image_size);
-   mutex_unlock(&image[minor].mutex);
+   switch (type[minor]) {
+   case MASTER_MINOR:
+   case SLAVE_MINOR:
+   mutex_lock(&image[minor].mutex);
+   image_size = vme_get_size(image[minor].resource);
+   res = fixed_size_llseek(file, off, whence, image_size);
+   mutex_unlock(&image[minor].mutex);
+   return res;
+   }
 
-   return res;
+   return -EINVAL;
 }
 
 /*
-- 
1.8.3.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCHv2 10/16] vme: ca91cx42: fix LM_CTL address mask

2015-05-28 Thread Dmitry Kalinkin
Universe II datasheet defines following address space values
for LM_CTL[16:18]

000=A16
001=A24
010=A32
011,100,101=Reserved
110=User1
111=User2

Mask 5<<16 is not the right one for matching [16:18], instead we should
use 7<<16.

Signed-off-by: Dmitry Kalinkin 
Cc: Igor Alekseev 
Reported-by: Dan Carpenter 
---
 drivers/vme/bridges/vme_ca91cx42.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/vme/bridges/vme_ca91cx42.h 
b/drivers/vme/bridges/vme_ca91cx42.h
index d46b12d..d54119e 100644
--- a/drivers/vme/bridges/vme_ca91cx42.h
+++ b/drivers/vme/bridges/vme_ca91cx42.h
@@ -547,7 +547,7 @@ static const int CA91CX42_LINT_LM[] = { CA91CX42_LINT_LM0, 
CA91CX42_LINT_LM1,
 #define CA91CX42_LM_CTL_DATA   (1<<22)
 #define CA91CX42_LM_CTL_SUPR   (1<<21)
 #define CA91CX42_LM_CTL_NPRIV  (1<<20)
-#define CA91CX42_LM_CTL_AS_M   (5<<16)
+#define CA91CX42_LM_CTL_AS_M   (7<<16)
 #define CA91CX42_LM_CTL_AS_A16 0
 #define CA91CX42_LM_CTL_AS_A24 (1<<16)
 #define CA91CX42_LM_CTL_AS_A32 (1<<17)
-- 
1.8.3.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCHv2 02/16] vme: tsi148: fix DMA lists longer that one item

2015-05-28 Thread Dmitry Kalinkin
DMA lists on tsi148 weren't processed further than the first item
because of the broken logic. This regression was introduced in:

ac1a4f2caf7b071 "Staging: VME: Ensure TSI148 link list descriptors..."

Signed-off-by: Dmitry Kalinkin 
Cc: Igor Alekseev 
---
 drivers/vme/bridges/vme_tsi148.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/vme/bridges/vme_tsi148.c b/drivers/vme/bridges/vme_tsi148.c
index 895c2a3..1be4136 100644
--- a/drivers/vme/bridges/vme_tsi148.c
+++ b/drivers/vme/bridges/vme_tsi148.c
@@ -1844,8 +1844,8 @@ static int tsi148_dma_list_add(struct vme_dma_list *list,
 
reg_split((unsigned long long)entry->dma_handle, &address_high,
&address_low);
-   entry->descriptor.dnlau = cpu_to_be32(address_high);
-   entry->descriptor.dnlal = cpu_to_be32(address_low);
+   prev->descriptor.dnlau = cpu_to_be32(address_high);
+   prev->descriptor.dnlal = cpu_to_be32(address_low);
 
}
 
-- 
1.8.3.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCHv2 15/16] vme: tsi148: depend on HAS_DMA for Kconfig

2015-05-28 Thread Dmitry Kalinkin
Signed-off-by: Dmitry Kalinkin 
Cc: Igor Alekseev 
---
 drivers/vme/bridges/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/vme/bridges/Kconfig b/drivers/vme/bridges/Kconfig
index 9331064..f6d8545 100644
--- a/drivers/vme/bridges/Kconfig
+++ b/drivers/vme/bridges/Kconfig
@@ -9,7 +9,7 @@ config VME_CA91CX42
 
 config VME_TSI148
tristate "Tempe"
-   depends on VIRT_TO_BUS
+   depends on HAS_DMA
help
 If you say Y here you get support for the Tundra TSI148 VME bridge
 chip.
-- 
1.8.3.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCHv2 14/16] staging: vme_user: remove buf_unalloc helper

2015-05-28 Thread Dmitry Kalinkin
buf_unalloc is essentially a vme_free_consistent:
1) image[i].kern_buf is never NULL in buf_alloc call
2) kern_buf, pci_buf and size_buf get zeroed in vme_user_probe anyway

Signed-off-by: Dmitry Kalinkin 
Cc: Igor Alekseev 
---
 drivers/staging/vme/devices/vme_user.c | 31 ---
 1 file changed, 4 insertions(+), 27 deletions(-)

diff --git a/drivers/staging/vme/devices/vme_user.c 
b/drivers/staging/vme/devices/vme_user.c
index ce4aacf..6b97bd2 100644
--- a/drivers/staging/vme/devices/vme_user.c
+++ b/drivers/staging/vme/devices/vme_user.c
@@ -742,31 +742,6 @@ static const struct file_operations vme_user_fops = {
.mmap = vme_user_mmap,
 };
 
-/*
- * Unallocate a previously allocated buffer
- */
-static void buf_unalloc(int num)
-{
-   if (image[num].kern_buf) {
-#ifdef VME_DEBUG
-   pr_debug("UniverseII:Releasing buffer at %p\n",
-image[num].pci_buf);
-#endif
-
-   vme_free_consistent(image[num].resource, image[num].size_buf,
-   image[num].kern_buf, image[num].pci_buf);
-
-   image[num].kern_buf = NULL;
-   image[num].pci_buf = 0;
-   image[num].size_buf = 0;
-
-#ifdef VME_DEBUG
-   } else {
-   pr_debug("UniverseII: Buffer not allocated\n");
-#endif
-   }
-}
-
 static int vme_user_match(struct vme_dev *vdev)
 {
int i;
@@ -958,7 +933,8 @@ err_master:
 err_slave:
while (i > SLAVE_MINOR) {
i--;
-   buf_unalloc(i);
+   vme_free_consistent(image[i].resource, image[i].size_buf,
+   image[i].kern_buf, image[i].pci_buf);
vme_slave_free(image[i].resource);
}
 err_class:
@@ -990,7 +966,8 @@ static int vme_user_remove(struct vme_dev *dev)
 
for (i = SLAVE_MINOR; i < (SLAVE_MAX + 1); i++) {
vme_slave_set(image[i].resource, 0, 0, 0, 0, VME_A32, 0);
-   buf_unalloc(i);
+   vme_free_consistent(image[i].resource, image[i].size_buf,
+   image[i].kern_buf, image[i].pci_buf);
vme_slave_free(image[i].resource);
}
 
-- 
1.8.3.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCHv2 12/16] staging: vme_user: remove forward declarations

2015-05-28 Thread Dmitry Kalinkin
Reorder code so that forward declarations are not needed.

Signed-off-by: Dmitry Kalinkin 
Cc: Igor Alekseev 
---
 drivers/staging/vme/devices/vme_user.c | 139 ++---
 1 file changed, 60 insertions(+), 79 deletions(-)

diff --git a/drivers/staging/vme/devices/vme_user.c 
b/drivers/staging/vme/devices/vme_user.c
index ed374d9..2493847 100644
--- a/drivers/staging/vme/devices/vme_user.c
+++ b/drivers/staging/vme/devices/vme_user.c
@@ -119,44 +119,11 @@ static const int type[VME_DEVS] = {   MASTER_MINOR,   
MASTER_MINOR,
CONTROL_MINOR,  DMA_MINOR
};
 
-
-static int vme_user_open(struct inode *, struct file *);
-static int vme_user_release(struct inode *, struct file *);
-static ssize_t vme_user_read(struct file *, char __user *, size_t, loff_t *);
-static ssize_t vme_user_write(struct file *, const char __user *, size_t,
-   loff_t *);
-static loff_t vme_user_llseek(struct file *, loff_t, int);
-static long vme_user_unlocked_ioctl(struct file *, unsigned int, unsigned 
long);
-static int vme_user_mmap(struct file *file, struct vm_area_struct *vma);
-
-static void vme_user_vm_open(struct vm_area_struct *vma);
-static void vme_user_vm_close(struct vm_area_struct *vma);
-
-static int vme_user_match(struct vme_dev *);
-static int vme_user_probe(struct vme_dev *);
-static int vme_user_remove(struct vme_dev *);
-
-static const struct file_operations vme_user_fops = {
-   .open = vme_user_open,
-   .release = vme_user_release,
-   .read = vme_user_read,
-   .write = vme_user_write,
-   .llseek = vme_user_llseek,
-   .unlocked_ioctl = vme_user_unlocked_ioctl,
-   .compat_ioctl = vme_user_unlocked_ioctl,
-   .mmap = vme_user_mmap,
-};
-
 struct vme_user_vma_priv {
unsigned int minor;
atomic_t refcnt;
 };
 
-static const struct vm_operations_struct vme_user_vm_ops = {
-   .open = vme_user_vm_open,
-   .close = vme_user_vm_close,
-};
-
 
 static int vme_user_open(struct inode *inode, struct file *file)
 {
@@ -761,6 +728,11 @@ static void vme_user_vm_close(struct vm_area_struct *vma)
kfree(vma_priv);
 }
 
+static const struct vm_operations_struct vme_user_vm_ops = {
+   .open = vme_user_vm_open,
+   .close = vme_user_vm_close,
+};
+
 static int vme_user_master_mmap(unsigned int minor, struct vm_area_struct *vma)
 {
int err;
@@ -802,6 +774,16 @@ static int vme_user_mmap(struct file *file, struct 
vm_area_struct *vma)
return -ENODEV;
 }
 
+static const struct file_operations vme_user_fops = {
+   .open = vme_user_open,
+   .release = vme_user_release,
+   .read = vme_user_read,
+   .write = vme_user_write,
+   .llseek = vme_user_llseek,
+   .unlocked_ioctl = vme_user_unlocked_ioctl,
+   .compat_ioctl = vme_user_unlocked_ioctl,
+   .mmap = vme_user_mmap,
+};
 
 /*
  * Unallocate a previously allocated buffer
@@ -828,52 +810,6 @@ static void buf_unalloc(int num)
}
 }
 
-static struct vme_driver vme_user_driver = {
-   .name = driver_name,
-   .match = vme_user_match,
-   .probe = vme_user_probe,
-   .remove = vme_user_remove,
-};
-
-
-static int __init vme_user_init(void)
-{
-   int retval = 0;
-
-   pr_info("VME User Space Access Driver\n");
-
-   if (bus_num == 0) {
-   pr_err("No cards, skipping registration\n");
-   retval = -ENODEV;
-   goto err_nocard;
-   }
-
-   /* Let's start by supporting one bus, we can support more than one
-* in future revisions if that ever becomes necessary.
-*/
-   if (bus_num > VME_USER_BUS_MAX) {
-   pr_err("Driver only able to handle %d buses\n",
-  VME_USER_BUS_MAX);
-   bus_num = VME_USER_BUS_MAX;
-   }
-
-   /*
-* Here we just register the maximum number of devices we can and
-* leave vme_user_match() to allow only 1 to go through to probe().
-* This way, if we later want to allow multiple user access devices,
-* we just change the code in vme_user_match().
-*/
-   retval = vme_register_driver(&vme_user_driver, VME_MAX_SLOTS);
-   if (retval != 0)
-   goto err_reg;
-
-   return retval;
-
-err_reg:
-err_nocard:
-   return retval;
-}
-
 static int vme_user_match(struct vme_dev *vdev)
 {
int i;
@@ -,6 +1047,51 @@ static int vme_user_remove(struct vme_dev *dev)
return 0;
 }
 
+static struct vme_driver vme_user_driver = {
+   .name = driver_name,
+   .match = vme_user_match,
+   .probe = vme_user_probe,
+   .remove = vme_user_remove,
+};
+
+static int __init vme_user_init(void)
+{
+   int retval = 0;
+
+   pr_info("VME User Space Access Driver\n");
+
+   if (bus_num == 0) {
+   pr_err("No cards, skipping registration\n");
+   retval = -ENODEV;
+   goto err_nocard;
+ 

[PATCHv2 16/16] vme: provide uapi header

2015-05-28 Thread Dmitry Kalinkin
This separates VME related constants that are a part of both kernel and
user space API into a common uapi header.

Signed-off-by: Dmitry Kalinkin 
Cc: Igor Alekseev 
---
 include/linux/vme.h   | 54 ++---
 include/uapi/linux/Kbuild |  1 +
 include/uapi/linux/vme.h  | 56 +++
 3 files changed, 59 insertions(+), 52 deletions(-)
 create mode 100644 include/uapi/linux/vme.h

diff --git a/include/linux/vme.h b/include/linux/vme.h
index c013135..ecfd389 100644
--- a/include/linux/vme.h
+++ b/include/linux/vme.h
@@ -1,6 +1,8 @@
 #ifndef _VME_H_
 #define _VME_H_
 
+#include 
+
 /* Resource Type */
 enum vme_resource_type {
VME_MASTER,
@@ -9,47 +11,6 @@ enum vme_resource_type {
VME_LM
 };
 
-/* VME Address Spaces */
-#define VME_A160x1
-#define VME_A240x2
-#defineVME_A32 0x4
-#define VME_A640x8
-#define VME_CRCSR  0x10
-#define VME_USER1  0x20
-#define VME_USER2  0x40
-#define VME_USER3  0x80
-#define VME_USER4  0x100
-
-#define VME_A16_MAX0x1ULL
-#define VME_A24_MAX0x100ULL
-#define VME_A32_MAX0x1ULL
-#define VME_A64_MAX0x1ULL
-#define VME_CRCSR_MAX  0x100ULL
-
-
-/* VME Cycle Types */
-#define VME_SCT0x1
-#define VME_BLT0x2
-#define VME_MBLT   0x4
-#define VME_2eVME  0x8
-#define VME_2eSST  0x10
-#define VME_2eSSTB 0x20
-
-#define VME_2eSST160   0x100
-#define VME_2eSST267   0x200
-#define VME_2eSST320   0x400
-
-#defineVME_SUPER   0x1000
-#defineVME_USER0x2000
-#defineVME_PROG0x4000
-#defineVME_DATA0x8000
-
-/* VME Data Widths */
-#define VME_D8 0x1
-#define VME_D160x2
-#define VME_D320x4
-#define VME_D640x8
-
 /* Arbitration Scheduling Modes */
 #define VME_R_ROBIN_MODE   0x1
 #define VME_PRIORITY_MODE  0x2
@@ -58,17 +19,6 @@ enum vme_resource_type {
 #define VME_DMA_PCI(1<<1)
 #define VME_DMA_VME(1<<2)
 
-#define VME_DMA_PATTERN_BYTE   (1<<0)
-#define VME_DMA_PATTERN_WORD   (1<<1)
-#define VME_DMA_PATTERN_INCREMENT  (1<<2)
-
-#define VME_DMA_VME_TO_MEM (1<<0)
-#define VME_DMA_MEM_TO_VME (1<<1)
-#define VME_DMA_VME_TO_VME (1<<2)
-#define VME_DMA_MEM_TO_MEM (1<<3)
-#define VME_DMA_PATTERN_TO_VME (1<<4)
-#define VME_DMA_PATTERN_TO_MEM (1<<5)
-
 struct vme_dma_attr {
u32 type;
void *private;
diff --git a/include/uapi/linux/Kbuild b/include/uapi/linux/Kbuild
index 1a0006a..ad25e3f 100644
--- a/include/uapi/linux/Kbuild
+++ b/include/uapi/linux/Kbuild
@@ -439,6 +439,7 @@ header-y += virtio_rng.h
 header-y += virtio_scsi.h
 header-y += virtio_types.h
 header-y += vm_sockets.h
+header-y += vme.h
 header-y += vt.h
 header-y += wait.h
 header-y += wanrouter.h
diff --git a/include/uapi/linux/vme.h b/include/uapi/linux/vme.h
new file mode 100644
index 000..3d49a56
--- /dev/null
+++ b/include/uapi/linux/vme.h
@@ -0,0 +1,56 @@
+#ifndef _UAPI_LINUX_VME
+#define _UAPI_LINUX_VME
+
+/* VME Address Spaces */
+#define VME_A160x1
+#define VME_A240x2
+#define VME_A320x4
+#define VME_A640x8
+#define VME_CRCSR  0x10
+#define VME_USER1  0x20
+#define VME_USER2  0x40
+#define VME_USER3  0x80
+#define VME_USER4  0x100
+
+#define VME_A16_MAX0x1ULL
+#define VME_A24_MAX0x100ULL
+#define VME_A32_MAX0x1ULL
+#define VME_A64_MAX0x1ULL
+#define VME_CRCSR_MAX  0x100ULL
+
+/* VME Cycle Types */
+#define VME_SCT0x1
+#define VME_BLT0x2
+#define VME_MBLT   0x4
+#define VME_2eVME  0x8
+#define VME_2eSST  0x10
+#define VME_2eSSTB 0x20
+
+#define VME_2eSST160   0x100
+#define VME_2eSST267   0x200
+#define VME_2eSST320   0x400
+
+#define VME_SUPER  0x1000
+#define VME_USER   0x2000
+#define VME_PROG   0x4000
+#define VME_DATA   0x8000
+
+/* VME Data Widths */
+#define VME_D8 0x1
+#define VME_D160x2
+#define VME_D320x4
+#define VME_D640x8
+
+/* VME Transfer Directions */
+#define VME_DMA_VME_TO_MEM (1<<0)
+#define VME_DMA_MEM_TO_VME (1<<1)
+#define VME_DMA_VME_TO_VME (1<<2)
+#define VME_DMA_MEM_TO_MEM (1<<3)
+#define VME_DMA_PATTERN_TO_VME (1<<4)
+#define VME_DMA_PATTERN_TO_MEM (1<<5)
+
+#define VME_DMA_PATTERN_BYTE   (1<<0)
+#define VME_DMA_PATTERN_WORD   (1<<1)
+#define VME_DMA_PATTERN_INCREMENT  (1<<2)
+
+#endif
-- 
1.8.3.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo

[PATCHv2 13/16] staging: vme_user: remove open/release

2015-05-28 Thread Dmitry Kalinkin
Checking for image[minor].resource != NULL is not needed since all
resources are allocated before device is created.

image[minor].users accounting is deleted because it's not being used.

Signed-off-by: Dmitry Kalinkin 
Cc: Igor Alekseev 
---
 drivers/staging/vme/devices/vme_user.c | 44 --
 1 file changed, 44 deletions(-)

diff --git a/drivers/staging/vme/devices/vme_user.c 
b/drivers/staging/vme/devices/vme_user.c
index 2493847..ce4aacf 100644
--- a/drivers/staging/vme/devices/vme_user.c
+++ b/drivers/staging/vme/devices/vme_user.c
@@ -102,7 +102,6 @@ struct image_desc {
struct mutex mutex; /* Mutex for locking image */
struct device *device;  /* Sysfs device */
struct vme_resource *resource;  /* VME resource */
-   int users;  /* Number of current users */
int mmap_count; /* Number of current mmap's */
 };
 static struct image_desc image[VME_DEVS];
@@ -125,46 +124,6 @@ struct vme_user_vma_priv {
 };
 
 
-static int vme_user_open(struct inode *inode, struct file *file)
-{
-   int err;
-   unsigned int minor = MINOR(inode->i_rdev);
-
-   mutex_lock(&image[minor].mutex);
-   /* Allow device to be opened if a resource is needed and allocated. */
-   if (minor < CONTROL_MINOR && image[minor].resource == NULL) {
-   pr_err("No resources allocated for device\n");
-   err = -EINVAL;
-   goto err_res;
-   }
-
-   /* Increment user count */
-   image[minor].users++;
-
-   mutex_unlock(&image[minor].mutex);
-
-   return 0;
-
-err_res:
-   mutex_unlock(&image[minor].mutex);
-
-   return err;
-}
-
-static int vme_user_release(struct inode *inode, struct file *file)
-{
-   unsigned int minor = MINOR(inode->i_rdev);
-
-   mutex_lock(&image[minor].mutex);
-
-   /* Decrement user count */
-   image[minor].users--;
-
-   mutex_unlock(&image[minor].mutex);
-
-   return 0;
-}
-
 /*
  * We are going ot alloc a page during init per window for small transfers.
  * Small transfers will go VME -> buffer -> user space. Larger (more than a
@@ -775,8 +734,6 @@ static int vme_user_mmap(struct file *file, struct 
vm_area_struct *vma)
 }
 
 static const struct file_operations vme_user_fops = {
-   .open = vme_user_open,
-   .release = vme_user_release,
.read = vme_user_read,
.write = vme_user_write,
.llseek = vme_user_llseek,
@@ -849,7 +806,6 @@ static int vme_user_probe(struct vme_dev *vdev)
mutex_init(&image[i].mutex);
image[i].device = NULL;
image[i].resource = NULL;
-   image[i].users = 0;
}
 
/* Assign major and minor numbers for the driver */
-- 
1.8.3.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: gs_fpgaboot: remove redundant code

2015-05-28 Thread Gujulan Elango, Hari Prasath (H.)
remove redundant code in this function by introducing a new retval
variable.

Signed-off-by: Gujulan Elango Hari Prasath 
---
 drivers/staging/gs_fpgaboot/gs_fpgaboot.c | 18 --
 1 file changed, 8 insertions(+), 10 deletions(-)

diff --git a/drivers/staging/gs_fpgaboot/gs_fpgaboot.c 
b/drivers/staging/gs_fpgaboot/gs_fpgaboot.c
index a3a10f9..cc0445c 100644
--- a/drivers/staging/gs_fpgaboot/gs_fpgaboot.c
+++ b/drivers/staging/gs_fpgaboot/gs_fpgaboot.c
@@ -290,6 +290,7 @@ static int gs_fpgaboot(void)
 {
int err;
struct fpgaimage*fimage;
+   int retval = 0;
 
fimage = kmalloc(sizeof(struct fpgaimage), GFP_KERNEL);
if (!fimage)
@@ -298,44 +299,41 @@ static int gs_fpgaboot(void)
err = gs_load_image(fimage, file);
if (err) {
pr_err("gs_load_image error\n");
+   retval = -1;
goto err_out1;
}
 
err = gs_read_image(fimage);
if (err) {
pr_err("gs_read_image error\n");
+   retval = -1;
goto err_out2;
}
 
err = gs_set_download_method(fimage);
if (err) {
pr_err("gs_set_download_method error\n");
+   retval = -1;
goto err_out2;
}
 
err = gs_download_image(fimage, bus_2byte);
if (err) {
pr_err("gs_download_image error\n");
+   retval = -1;
goto err_out2;
}
 
+err_out2:
err = gs_release_image(fimage);
if (err) {
+   retval = -1;
pr_err("gs_release_image error\n");
-   goto err_out1;
}
-
-   kfree(fimage);
-   return 0;
-
-err_out2:
-   err = gs_release_image(fimage);
-   if (err)
-   pr_err("gs_release_image error\n");
 err_out1:
kfree(fimage);
 
-   return -1;
+   return retval;
 
 }
 
-- 
1.9.1
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: gs_fpgaboot: remove redundant code

2015-05-28 Thread Dan Carpenter
On Thu, May 28, 2015 at 09:38:23AM +, Gujulan Elango, Hari Prasath (H.) 
wrote:
> remove redundant code in this function by introducing a new retval
> variable.
> 
> Signed-off-by: Gujulan Elango Hari Prasath 

No the original code is quite bad but this patch makes it worse.

gs_release_image() can't fail, and it should be a void function.

> ---
>  drivers/staging/gs_fpgaboot/gs_fpgaboot.c | 18 --
>  1 file changed, 8 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/staging/gs_fpgaboot/gs_fpgaboot.c 
> b/drivers/staging/gs_fpgaboot/gs_fpgaboot.c
> index a3a10f9..cc0445c 100644
> --- a/drivers/staging/gs_fpgaboot/gs_fpgaboot.c
> +++ b/drivers/staging/gs_fpgaboot/gs_fpgaboot.c
> @@ -290,6 +290,7 @@ static int gs_fpgaboot(void)
>  {
>   int err;
>   struct fpgaimage*fimage;
> + int retval = 0;
>  
>   fimage = kmalloc(sizeof(struct fpgaimage), GFP_KERNEL);
>   if (!fimage)
> @@ -298,44 +299,41 @@ static int gs_fpgaboot(void)
>   err = gs_load_image(fimage, file);
>   if (err) {

goto free_fimage;

>   pr_err("gs_load_image error\n");
> + retval = -1;
>   goto err_out1;
>   }
>  
>   err = gs_read_image(fimage);
>   if (err) {


goto release_image;

>   pr_err("gs_read_image error\n");
> + retval = -1;
>   goto err_out2;
>   }
>  
>   err = gs_set_download_method(fimage);
>   if (err) {

goto release_image;

>   pr_err("gs_set_download_method error\n");
> + retval = -1;
>   goto err_out2;
>   }
>  
>   err = gs_download_image(fimage, bus_2byte);


release_image:
gs_release_image(fimage);
free_fimage:
kfree(fimage);

return err;

regards,
dan carpenter
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: gs_fpgaboot: remove redundant code

2015-05-28 Thread Gujulan Elango, Hari Prasath (H.)
On Thu, May 28, 2015 at 01:08:36PM +0300, Dan Carpenter wrote:
> On Thu, May 28, 2015 at 09:38:23AM +, Gujulan Elango, Hari Prasath (H.) 
> wrote:
> > remove redundant code in this function by introducing a new retval
> > variable.
> > 
> > Signed-off-by: Gujulan Elango Hari Prasath 
> 
> No the original code is quite bad but this patch makes it worse.
> 
> gs_release_image() can't fail, and it should be a void function.
> 

Dan, I didn't note that the gs_release_image() always returns success.

> > ---
> >  drivers/staging/gs_fpgaboot/gs_fpgaboot.c | 18 --
> >  1 file changed, 8 insertions(+), 10 deletions(-)
> > 
> > diff --git a/drivers/staging/gs_fpgaboot/gs_fpgaboot.c 
> > b/drivers/staging/gs_fpgaboot/gs_fpgaboot.c
> > index a3a10f9..cc0445c 100644
> > --- a/drivers/staging/gs_fpgaboot/gs_fpgaboot.c
> > +++ b/drivers/staging/gs_fpgaboot/gs_fpgaboot.c
> > @@ -290,6 +290,7 @@ static int gs_fpgaboot(void)
> >  {
> > int err;
> > struct fpgaimage*fimage;
> > +   int retval = 0;
> >  
> > fimage = kmalloc(sizeof(struct fpgaimage), GFP_KERNEL);
> > if (!fimage)
> > @@ -298,44 +299,41 @@ static int gs_fpgaboot(void)
> > err = gs_load_image(fimage, file);
> > if (err) {
> 
>   goto free_fimage;
> 

I guess we should retain the debug message here and in the other cases
below.

> > pr_err("gs_load_image error\n");
> > +   retval = -1;
> > goto err_out1;
> > }
> >  
> > err = gs_read_image(fimage);
> > if (err) {
> 
> 
>   goto release_image;
> 
> > pr_err("gs_read_image error\n");
> > +   retval = -1;
> > goto err_out2;
> > }
> >  
> > err = gs_set_download_method(fimage);
> > if (err) {
> 
>   goto release_image;
> 
> > pr_err("gs_set_download_method error\n");
> > +   retval = -1;
> > goto err_out2;
> > }
> >  
> > err = gs_download_image(fimage, bus_2byte);
> 
> 
> release_image:
>   gs_release_image(fimage);
> free_fimage:
>   kfree(fimage);
> 
>   return err;
> 
> regards,
> dan carpenter

I will send a v2 with these changes if its fine or we could just leave
it as it is.

regards,
Hari Prasath
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: gs_fpgaboot: remove redundant code

2015-05-28 Thread Dan Carpenter
On Thu, May 28, 2015 at 10:19:40AM +, Gujulan Elango, Hari Prasath (H.) 
wrote:
> > >   fimage = kmalloc(sizeof(struct fpgaimage), GFP_KERNEL);
> > >   if (!fimage)
> > > @@ -298,44 +299,41 @@ static int gs_fpgaboot(void)
> > >   err = gs_load_image(fimage, file);
> > >   if (err) {
> > 
> > goto free_fimage;
> > 
> 
> I guess we should retain the debug message here and in the other cases
> below.

Just delete the debug messages.  It's fine.  Please send a v2.

If you want to rename "err" to "ret" that's also ok, or you can leave it
as is.  But don't introduce a new variable.

regards,
dan carpenter

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCHv2] staging: gs_fpgaboot: remove redundant code

2015-05-28 Thread Gujulan Elango, Hari Prasath (H.)
remove redundant code in this function.remove return value check for
function that always return success.

Signed-off-by: Gujulan Elango Hari Prasath 
---
v2:address review comments from Dan.Remove return value check
for the function gs_release_image as it always returns success and
rearrange the code accordingly.Also delete debug messages.
---
 drivers/staging/gs_fpgaboot/gs_fpgaboot.c | 44 ---
 1 file changed, 11 insertions(+), 33 deletions(-)

diff --git a/drivers/staging/gs_fpgaboot/gs_fpgaboot.c 
b/drivers/staging/gs_fpgaboot/gs_fpgaboot.c
index a3a10f9..a792c1a 100644
--- a/drivers/staging/gs_fpgaboot/gs_fpgaboot.c
+++ b/drivers/staging/gs_fpgaboot/gs_fpgaboot.c
@@ -288,7 +288,7 @@ static void finish_driver(void)
 
 static int gs_fpgaboot(void)
 {
-   int err;
+   int err = 0;
struct fpgaimage*fimage;
 
fimage = kmalloc(sizeof(struct fpgaimage), GFP_KERNEL);
@@ -296,47 +296,25 @@ static int gs_fpgaboot(void)
return -ENOMEM;
 
err = gs_load_image(fimage, file);
-   if (err) {
-   pr_err("gs_load_image error\n");
-   goto err_out1;
-   }
+   if (err)
+   goto free_image;
 
err = gs_read_image(fimage);
-   if (err) {
-   pr_err("gs_read_image error\n");
-   goto err_out2;
-   }
+   if (err)
+   goto release_image;
 
err = gs_set_download_method(fimage);
-   if (err) {
-   pr_err("gs_set_download_method error\n");
-   goto err_out2;
-   }
+   if (err)
+   goto release_image;
 
err = gs_download_image(fimage, bus_2byte);
-   if (err) {
-   pr_err("gs_download_image error\n");
-   goto err_out2;
-   }
-
-   err = gs_release_image(fimage);
-   if (err) {
-   pr_err("gs_release_image error\n");
-   goto err_out1;
-   }
-
-   kfree(fimage);
-   return 0;
 
-err_out2:
-   err = gs_release_image(fimage);
-   if (err)
-   pr_err("gs_release_image error\n");
-err_out1:
+release_image:
+   gs_release_image(fimage);
+free_image:
kfree(fimage);
 
-   return -1;
-
+   return err;
 }
 
 static int __init gs_fpgaboot_init(void)
-- 
1.9.1
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [oss-security] Re: [PATCH v2 4/4] ozwpan: unchecked signed subtraction leads to DoS

2015-05-28 Thread Dan Carpenter
On Tue, May 26, 2015 at 04:34:55PM +0200, Jason A. Donenfeld wrote:
> On Tue, May 26, 2015 at 4:06 PM, Dan Carpenter  
> wrote:
> > You sure do like wrapping to a high value and testing the result for
> > wrapping instead of validating before doing the subtraction...
> 
> I do indeed. It seems like asking "did it overflow?" is more
> straight-forward and easier to read than trying to come up with the
> necessary conditions to check for "will it overflow?". Personal
> preference, I guess.

It's really not simpler to understand though.  Also future static
checkers will complain that subtracting from a user variable and you
might underflow.  I am updating my static checker to detect these.
Also overflow and truncate might not be the right fix, maybe it's better
to just drop the invalid request (patch 2/4).

What's going on with the mailing list?  We seem to be losing people from
the CC.  I deliberately added Shigekatsu Tateno, and it says he was on
the CC in my outbox but now he isn't.

Maybe we should just delete these ozwpan drivers entirely...  They were
merged when Ozmodevices was its own company and I don't think anyone is
working on them any more.

regards,
dan carpenter

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCHv2] staging: gs_fpgaboot: remove redundant code

2015-05-28 Thread Dan Carpenter
On Thu, May 28, 2015 at 10:51:38AM +, Gujulan Elango, Hari Prasath (H.) 
wrote:
> remove redundant code in this function.remove return value check for
> function that always return success.
> 
> Signed-off-by: Gujulan Elango Hari Prasath 
> ---
>   v2:address review comments from Dan.Remove return value check
> for the function gs_release_image as it always returns success and
> rearrange the code accordingly.Also delete debug messages.
> ---
>  drivers/staging/gs_fpgaboot/gs_fpgaboot.c | 44 
> ---
>  1 file changed, 11 insertions(+), 33 deletions(-)
> 
> diff --git a/drivers/staging/gs_fpgaboot/gs_fpgaboot.c 
> b/drivers/staging/gs_fpgaboot/gs_fpgaboot.c
> index a3a10f9..a792c1a 100644
> --- a/drivers/staging/gs_fpgaboot/gs_fpgaboot.c
> +++ b/drivers/staging/gs_fpgaboot/gs_fpgaboot.c
> @@ -288,7 +288,7 @@ static void finish_driver(void)
>  
>  static int gs_fpgaboot(void)
>  {
> - int err;
> + int err = 0;

Don't do this.  It's just turns off GCC's warning about uninitialized
variables.

regards,
dan carpenter

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCHv2] staging: gs_fpgaboot: remove redundant code

2015-05-28 Thread Gujulan Elango, Hari Prasath (H.)
On Thu, May 28, 2015 at 02:07:36PM +0300, Dan Carpenter wrote:
> On Thu, May 28, 2015 at 10:51:38AM +, Gujulan Elango, Hari Prasath (H.) 
> wrote:
> > remove redundant code in this function.remove return value check for
> > function that always return success.
> > 
> > Signed-off-by: Gujulan Elango Hari Prasath 
> > ---
> > v2:address review comments from Dan.Remove return value check
> > for the function gs_release_image as it always returns success and
> > rearrange the code accordingly.Also delete debug messages.
> > ---
> >  drivers/staging/gs_fpgaboot/gs_fpgaboot.c | 44 
> > ---
> >  1 file changed, 11 insertions(+), 33 deletions(-)
> > 
> > diff --git a/drivers/staging/gs_fpgaboot/gs_fpgaboot.c 
> > b/drivers/staging/gs_fpgaboot/gs_fpgaboot.c
> > index a3a10f9..a792c1a 100644
> > --- a/drivers/staging/gs_fpgaboot/gs_fpgaboot.c
> > +++ b/drivers/staging/gs_fpgaboot/gs_fpgaboot.c
> > @@ -288,7 +288,7 @@ static void finish_driver(void)
> >  
> >  static int gs_fpgaboot(void)
> >  {
> > -   int err;
> > +   int err = 0;
> 
> Don't do this.  It's just turns off GCC's warning about uninitialized
> variables.
> 
> regards,
> dan carpenter
> 

The reason i did that was if the function doesn't hit any error
condition, then it needs to return 0. If the err variable is not
initialized to 0,I assume that it can take any value.Please correct me
if i am wrong. I removed the retval variable and just used the 'err'
variable itself.
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCHv2] staging: gs_fpgaboot: remove redundant code

2015-05-28 Thread Dan Carpenter
On Thu, May 28, 2015 at 11:32:21AM +, Gujulan Elango, Hari Prasath (H.) 
wrote:
> The reason i did that was if the function doesn't hit any error
> condition, then it needs to return 0. If the err variable is not
> initialized to 0,I assume that it can take any value.Please correct me
> if i am wrong.

You are wrong.  We always set err.

regards,
dan carpenter

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCHv2] staging: gs_fpgaboot: remove redundant code

2015-05-28 Thread Gujulan Elango, Hari Prasath (H.)
On Thu, May 28, 2015 at 02:37:43PM +0300, Dan Carpenter wrote:
> On Thu, May 28, 2015 at 11:32:21AM +, Gujulan Elango, Hari Prasath (H.) 
> wrote:
> > The reason i did that was if the function doesn't hit any error
> > condition, then it needs to return 0. If the err variable is not
> > initialized to 0,I assume that it can take any value.Please correct me
> > if i am wrong.
> 
> You are wrong.  We always set err.
> 
> regards,
> dan carpenter
> 

Ok I got it. I will send v3 of this patch.
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCHv3 01/16] Documentation: mention vme_master_mmap() in VME API

2015-05-28 Thread Dmitry Kalinkin
Signed-off-by: Dmitry Kalinkin 
Cc: Igor Alekseev 
---
 Documentation/vme_api.txt | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/Documentation/vme_api.txt b/Documentation/vme_api.txt
index ffe6e22..ca5b827 100644
--- a/Documentation/vme_api.txt
+++ b/Documentation/vme_api.txt
@@ -171,6 +171,12 @@ This functions by reading the offset, applying the mask. 
If the bits selected in
 the mask match with the values of the corresponding bits in the compare field,
 the value of swap is written the specified offset.
 
+Parts of a VME window can be mapped into user space memory using the following
+function:
+
+   int vme_master_mmap(struct vme_resource *resource,
+   struct vm_area_struct *vma)
+
 
 Slave windows
 =
-- 
1.8.3.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCHv3 00/16] vme DMA and user space driver improvements

2015-05-28 Thread Dmitry Kalinkin
The first item in this submission documents previously introduced
vme_master_mmap() call. Following, there are three fixes for the tsi148
driver's DMA.  There was one bug that rendered it imposible to use DMA
lists with more than one item. The other was related to the place where
dma_map_single was called on the first DMA descriptor in the DMA list. The 
last bug was about DMA transfer not stopping at interruption by signal,
which is a possible DoS attack vector. I also made an attempt to fix the
same issue in the ca91cx42 driver. I don't have access to this hardware to
test, so this is based only on my understanding of the datasheet (checked  
ca91c042's errata as well).

A new /sys/bus/vme/dma0 device with a new ioctl for making DMA transfers
was introduced in vme_user driver. The logic of the function is similar to 
the one found in existing drivers.

One question that I had while implementing this feature was whether we 
should keep vme_dma_attr objects until vme_dma_list_exec() call. API
doesn't specify this, the existing vme bridge drivers copy all information
from attributes during vme_dma_list_add(). So for simplicity this  
implementation frees vme_dma_attr's before vme_dma_list_exec() is done.

A simple test against AVM16 board displays speeds around 45 MiB/s for
A32/D32 reads for both BLT and MBLT (with MBLT being slightly faster). 
 
Changes in v2 [patches 1-6, now 1-5 and 8]:
 * vme_addr check for vme_user DMA 
 * limit on DMA operation length in vme_user
 * reorder dma_op ioctl struct to omit __packed attribute 
 * change dma_op->write into dma_op->dir   
 * use vme_check_window assure DMA operation correctness   

New changes include vme_user code cleanup, a couple of ca91cx42 fixes
(again, tested for compilation only).

I also propose a change to export some of VME subsytem related constants
to the user space. These can be useful if vme_user is to go into the kernel.
Also, email
http://driverdev.linuxdriverproject.org/pipermail/driverdev-devel/2012-July/029084.html
mentions that we probably can now get rid of this comment:
> /* XXX  We do not want to push aspace, cycle and width
>  *  to userspace as they are
>  */

v3 adresses code style problems

Dmitry Kalinkin (16):
  Documentation: mention vme_master_mmap() in VME API
  vme: tsi148: fix DMA lists longer that one item
  vme: tsi148: fix first DMA item mapping
  vme: stop DMA transfer on interruption
  staging: vme_user: refactor llseek to switch(){}
  vme: check for A64 overflow in vme_check_window()
  vme: export vme_check_window()
  staging: vme_user: provide DMA functionality
  vme: ca91cx42: return error code on DMA error
  vme: ca91cx42: fix LM_CTL address mask
  staging: vme_user: remove unused counters
  staging: vme_user: remove forward declarations
  staging: vme_user: remove open/release
  staging: vme_user: remove buf_unalloc helper
  vme: tsi148: depend on HAS_DMA for Kconfig
  vme: provide uapi header

 Documentation/vme_api.txt  |   6 +
 drivers/staging/vme/devices/vme_user.c | 454 +++--
 drivers/staging/vme/devices/vme_user.h |  11 +
 drivers/vme/bridges/Kconfig|   2 +-
 drivers/vme/bridges/vme_ca91cx42.c |  18 +-
 drivers/vme/bridges/vme_ca91cx42.h |   2 +-
 drivers/vme/bridges/vme_tsi148.c   |  42 +--
 drivers/vme/vme.c  |  11 +-
 include/linux/vme.h|  56 +---
 include/uapi/linux/Kbuild  |   1 +
 include/uapi/linux/vme.h   |  56 
 11 files changed, 394 insertions(+), 265 deletions(-)
 create mode 100644 include/uapi/linux/vme.h

-- 
1.8.3.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCHv3 07/16] vme: export vme_check_window()

2015-05-28 Thread Dmitry Kalinkin
Signed-off-by: Dmitry Kalinkin 
Cc: Igor Alekseev 
---
 drivers/vme/vme.c   | 5 +++--
 include/linux/vme.h | 2 ++
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/vme/vme.c b/drivers/vme/vme.c
index 1b78d27..5670891 100644
--- a/drivers/vme/vme.c
+++ b/drivers/vme/vme.c
@@ -177,8 +177,8 @@ size_t vme_get_size(struct vme_resource *resource)
 }
 EXPORT_SYMBOL(vme_get_size);
 
-static int vme_check_window(u32 aspace, unsigned long long vme_base,
-   unsigned long long size)
+int vme_check_window(u32 aspace, unsigned long long vme_base,
+unsigned long long size)
 {
int retval = 0;
 
@@ -221,6 +221,7 @@ static int vme_check_window(u32 aspace, unsigned long long 
vme_base,
 
return retval;
 }
+EXPORT_SYMBOL(vme_check_window);
 
 /*
  * Request a slave image with specific attributes, return some unique
diff --git a/include/linux/vme.h b/include/linux/vme.h
index 79242e9..c013135 100644
--- a/include/linux/vme.h
+++ b/include/linux/vme.h
@@ -120,6 +120,8 @@ void vme_free_consistent(struct vme_resource *, size_t,  
void *,
dma_addr_t);
 
 size_t vme_get_size(struct vme_resource *);
+int vme_check_window(u32 aspace, unsigned long long vme_base,
+unsigned long long size);
 
 struct vme_resource *vme_slave_request(struct vme_dev *, u32, u32);
 int vme_slave_set(struct vme_resource *, int, unsigned long long,
-- 
1.8.3.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCHv3 04/16] vme: stop DMA transfer on interruption

2015-05-28 Thread Dmitry Kalinkin
Signed-off-by: Dmitry Kalinkin 
Cc: Igor Alekseev 
---
 drivers/vme/bridges/vme_ca91cx42.c | 17 ++---
 drivers/vme/bridges/vme_tsi148.c   | 15 +--
 2 files changed, 27 insertions(+), 5 deletions(-)

diff --git a/drivers/vme/bridges/vme_ca91cx42.c 
b/drivers/vme/bridges/vme_ca91cx42.c
index 18078ec..e9bd657 100644
--- a/drivers/vme/bridges/vme_ca91cx42.c
+++ b/drivers/vme/bridges/vme_ca91cx42.c
@@ -1192,7 +1192,7 @@ static int ca91cx42_dma_list_exec(struct vme_dma_list 
*list)
 {
struct vme_dma_resource *ctrlr;
struct ca91cx42_dma_entry *entry;
-   int retval = 0;
+   int retval;
dma_addr_t bus_addr;
u32 val;
struct device *dev;
@@ -1245,8 +1245,18 @@ static int ca91cx42_dma_list_exec(struct vme_dma_list 
*list)
 
iowrite32(val, bridge->base + DGCS);
 
-   wait_event_interruptible(bridge->dma_queue,
-   ca91cx42_dma_busy(ctrlr->parent));
+   retval = wait_event_interruptible(bridge->dma_queue,
+ ca91cx42_dma_busy(ctrlr->parent));
+
+   if (retval) {
+   val = ioread32(bridge->base + DGCS);
+   iowrite32(val | CA91CX42_DGCS_STOP_REQ, bridge->base + DGCS);
+   /* Wait for the operation to abort */
+   wait_event(bridge->dma_queue,
+  ca91cx42_dma_busy(ctrlr->parent));
+   retval = -EINTR;
+   goto exit;
+   }
 
/*
 * Read status register, this register is valid until we kick off a
@@ -1261,6 +1271,7 @@ static int ca91cx42_dma_list_exec(struct vme_dma_list 
*list)
val = ioread32(bridge->base + DCTL);
}
 
+exit:
/* Remove list from running list */
mutex_lock(&ctrlr->mtx);
list_del(&list->list);
diff --git a/drivers/vme/bridges/vme_tsi148.c b/drivers/vme/bridges/vme_tsi148.c
index 6562348..fb1e7ad 100644
--- a/drivers/vme/bridges/vme_tsi148.c
+++ b/drivers/vme/bridges/vme_tsi148.c
@@ -1892,7 +1892,7 @@ static int tsi148_dma_busy(struct vme_bridge 
*tsi148_bridge, int channel)
 static int tsi148_dma_list_exec(struct vme_dma_list *list)
 {
struct vme_dma_resource *ctrlr;
-   int channel, retval = 0;
+   int channel, retval;
struct tsi148_dma_entry *entry;
u32 bus_addr_high, bus_addr_low;
u32 val, dctlreg = 0;
@@ -1942,9 +1942,19 @@ static int tsi148_dma_list_exec(struct vme_dma_list 
*list)
iowrite32be(dctlreg | TSI148_LCSR_DCTL_DGO, bridge->base +
TSI148_LCSR_DMA[channel] + TSI148_LCSR_OFFSET_DCTL);
 
-   wait_event_interruptible(bridge->dma_queue[channel],
+   retval = wait_event_interruptible(bridge->dma_queue[channel],
tsi148_dma_busy(ctrlr->parent, channel));
 
+   if (retval) {
+   iowrite32be(dctlreg | TSI148_LCSR_DCTL_ABT, bridge->base +
+   TSI148_LCSR_DMA[channel] + TSI148_LCSR_OFFSET_DCTL);
+   /* Wait for the operation to abort */
+   wait_event(bridge->dma_queue[channel],
+  tsi148_dma_busy(ctrlr->parent, channel));
+   retval = -EINTR;
+   goto exit;
+   }
+
/*
 * Read status register, this register is valid until we kick off a
 * new transfer.
@@ -1957,6 +1967,7 @@ static int tsi148_dma_list_exec(struct vme_dma_list *list)
retval = -EIO;
}
 
+exit:
/* Remove list from running list */
mutex_lock(&ctrlr->mtx);
list_del(&list->list);
-- 
1.8.3.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCHv3 02/16] vme: tsi148: fix DMA lists longer that one item

2015-05-28 Thread Dmitry Kalinkin
DMA lists on tsi148 weren't processed further than the first item
because of the broken logic. This regression was introduced in:

ac1a4f2caf7b071 "Staging: VME: Ensure TSI148 link list descriptors..."

Signed-off-by: Dmitry Kalinkin 
Cc: Igor Alekseev 
---
 drivers/vme/bridges/vme_tsi148.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/vme/bridges/vme_tsi148.c b/drivers/vme/bridges/vme_tsi148.c
index 895c2a3..1be4136 100644
--- a/drivers/vme/bridges/vme_tsi148.c
+++ b/drivers/vme/bridges/vme_tsi148.c
@@ -1844,8 +1844,8 @@ static int tsi148_dma_list_add(struct vme_dma_list *list,
 
reg_split((unsigned long long)entry->dma_handle, &address_high,
&address_low);
-   entry->descriptor.dnlau = cpu_to_be32(address_high);
-   entry->descriptor.dnlal = cpu_to_be32(address_low);
+   prev->descriptor.dnlau = cpu_to_be32(address_high);
+   prev->descriptor.dnlal = cpu_to_be32(address_low);
 
}
 
-- 
1.8.3.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCHv3 10/16] vme: ca91cx42: fix LM_CTL address mask

2015-05-28 Thread Dmitry Kalinkin
Universe II datasheet defines following address space values
for LM_CTL[16:18]

000=A16
001=A24
010=A32
011,100,101=Reserved
110=User1
111=User2

Mask 5<<16 is not the right one for matching [16:18], instead we should
use 7<<16.

Signed-off-by: Dmitry Kalinkin 
Cc: Igor Alekseev 
Reported-by: Dan Carpenter 
---
 drivers/vme/bridges/vme_ca91cx42.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/vme/bridges/vme_ca91cx42.h 
b/drivers/vme/bridges/vme_ca91cx42.h
index d46b12d..d54119e 100644
--- a/drivers/vme/bridges/vme_ca91cx42.h
+++ b/drivers/vme/bridges/vme_ca91cx42.h
@@ -547,7 +547,7 @@ static const int CA91CX42_LINT_LM[] = { CA91CX42_LINT_LM0, 
CA91CX42_LINT_LM1,
 #define CA91CX42_LM_CTL_DATA   (1<<22)
 #define CA91CX42_LM_CTL_SUPR   (1<<21)
 #define CA91CX42_LM_CTL_NPRIV  (1<<20)
-#define CA91CX42_LM_CTL_AS_M   (5<<16)
+#define CA91CX42_LM_CTL_AS_M   (7<<16)
 #define CA91CX42_LM_CTL_AS_A16 0
 #define CA91CX42_LM_CTL_AS_A24 (1<<16)
 #define CA91CX42_LM_CTL_AS_A32 (1<<17)
-- 
1.8.3.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCHv3 06/16] vme: check for A64 overflow in vme_check_window()

2015-05-28 Thread Dmitry Kalinkin
Signed-off-by: Dmitry Kalinkin 
Cc: Igor Alekseev 
---
 drivers/vme/vme.c | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/vme/vme.c b/drivers/vme/vme.c
index 6bab2c4..1b78d27 100644
--- a/drivers/vme/vme.c
+++ b/drivers/vme/vme.c
@@ -199,10 +199,8 @@ static int vme_check_window(u32 aspace, unsigned long long 
vme_base,
retval = -EFAULT;
break;
case VME_A64:
-   /*
-* Any value held in an unsigned long long can be used as the
-* base
-*/
+   if ((size != 0) && (vme_base > U64_MAX + 1 - size))
+   retval = -EFAULT;
break;
case VME_CRCSR:
if (((vme_base + size) > VME_CRCSR_MAX) ||
-- 
1.8.3.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCHv3 08/16] staging: vme_user: provide DMA functionality

2015-05-28 Thread Dmitry Kalinkin
This introduces a new dma device that provides a single ioctl call that
provides DMA read and write functionality to the user space.

Signed-off-by: Dmitry Kalinkin 
Cc: Igor Alekseev 
---
 drivers/staging/vme/devices/vme_user.c | 201 -
 drivers/staging/vme/devices/vme_user.h |  11 ++
 2 files changed, 209 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/vme/devices/vme_user.c 
b/drivers/staging/vme/devices/vme_user.c
index da828f4..e8a1ca6 100644
--- a/drivers/staging/vme/devices/vme_user.c
+++ b/drivers/staging/vme/devices/vme_user.c
@@ -79,15 +79,18 @@ static unsigned int bus_num;
  * We shall support 4 masters and 4 slaves with this driver.
  */
 #define VME_MAJOR  221 /* VME Major Device Number */
-#define VME_DEVS   9   /* Number of dev entries */
+#define VME_DEVS   10  /* Number of dev entries */
 
 #define MASTER_MINOR   0
 #define MASTER_MAX 3
 #define SLAVE_MINOR4
 #define SLAVE_MAX  7
 #define CONTROL_MINOR  8
+#define DMA_MINOR  9
 
-#define PCI_BUF_SIZE  0x2  /* Size of one slave image buffer */
+#define PCI_BUF_SIZE   0x2 /* Size of one slave image buffer */
+
+#define VME_MAX_DMA_LEN0x400   /* Maximal DMA transfer length 
*/
 
 /*
  * Structure to handle image related parameters.
@@ -125,7 +128,7 @@ static const int type[VME_DEVS] = { MASTER_MINOR,   
MASTER_MINOR,
MASTER_MINOR,   MASTER_MINOR,
SLAVE_MINOR,SLAVE_MINOR,
SLAVE_MINOR,SLAVE_MINOR,
-   CONTROL_MINOR
+   CONTROL_MINOR,  DMA_MINOR
};
 
 
@@ -443,6 +446,168 @@ static loff_t vme_user_llseek(struct file *file, loff_t 
off, int whence)
return -EINVAL;
 }
 
+static int vme_user_sg_to_dma_list(const struct vme_dma_op *dma_op,
+  struct sg_table *sgt,
+  int sg_count, struct vme_dma_list *dma_list)
+{
+   ssize_t pos = 0;
+   struct scatterlist *sg;
+   int i, ret;
+
+   for_each_sg(sgt->sgl, sg, sg_count, i) {
+   struct vme_dma_attr *pci_attr, *vme_attr, *src, *dest;
+   dma_addr_t hw_address = sg_dma_address(sg);
+   unsigned int hw_len = sg_dma_len(sg);
+
+   vme_attr = vme_dma_vme_attribute(dma_op->vme_addr + pos,
+dma_op->aspace,
+dma_op->cycle,
+dma_op->dwidth);
+   if (!vme_attr)
+   return -ENOMEM;
+
+   pci_attr = vme_dma_pci_attribute(hw_address);
+   if (!pci_attr) {
+   vme_dma_free_attribute(vme_attr);
+   return -ENOMEM;
+   }
+
+   switch (dma_op->dir) {
+   case VME_DMA_MEM_TO_VME:
+   src = pci_attr;
+   dest = vme_attr;
+   break;
+   case VME_DMA_VME_TO_MEM:
+   src = vme_attr;
+   dest = pci_attr;
+   break;
+   }
+
+   ret = vme_dma_list_add(dma_list, src, dest, hw_len);
+
+   /*
+* XXX VME API doesn't mention whether we should keep
+* attributes around
+*/
+   vme_dma_free_attribute(vme_attr);
+   vme_dma_free_attribute(pci_attr);
+
+   if (ret)
+   return ret;
+
+   pos += hw_len;
+   }
+
+   return 0;
+}
+
+static enum dma_data_direction vme_dir_to_dma_dir(unsigned vme_dir)
+{
+   switch (vme_dir) {
+   case VME_DMA_VME_TO_MEM:
+   return DMA_FROM_DEVICE;
+   case VME_DMA_MEM_TO_VME:
+   return DMA_TO_DEVICE;
+   }
+
+   return DMA_NONE;
+}
+
+static ssize_t vme_user_dma_ioctl(unsigned int minor,
+ const struct vme_dma_op *dma_op)
+{
+   unsigned int offset = offset_in_page(dma_op->buf_vaddr);
+   unsigned long nr_pages;
+   enum dma_data_direction dir;
+   struct vme_dma_list *dma_list;
+   struct sg_table *sgt = NULL;
+   struct page **pages = NULL;
+   long got_pages;
+   ssize_t count;
+   int retval, sg_count;
+
+   /* Prevent WARN from dma_map_sg */
+   if (dma_op->count == 0)
+   return 0;
+
+   /*
+* This is a voluntary limit to prevent huge allocation for pages
+* array. VME_MAX_DMA_LEN is not a fundamental VME constraint.
+*/
+   count = min_t(size_t, dma_op->count, VME_MAX_DMA_LEN);
+   nr_pages = (offset + count + PAGE_SIZE - 1) >> PAGE_SHIFT;
+
+   dir = vme_dir_to_dma_dir(dma_op->dir);
+   if (di

[PATCHv3 11/16] staging: vme_user: remove unused counters

2015-05-28 Thread Dmitry Kalinkin
Signed-off-by: Dmitry Kalinkin 
Cc: Igor Alekseev 
---
 drivers/staging/vme/devices/vme_user.c | 31 ---
 1 file changed, 31 deletions(-)

diff --git a/drivers/staging/vme/devices/vme_user.c 
b/drivers/staging/vme/devices/vme_user.c
index e8a1ca6..cc0d3df 100644
--- a/drivers/staging/vme/devices/vme_user.c
+++ b/drivers/staging/vme/devices/vme_user.c
@@ -107,18 +107,6 @@ struct image_desc {
 };
 static struct image_desc image[VME_DEVS];
 
-struct driver_stats {
-   unsigned long reads;
-   unsigned long writes;
-   unsigned long ioctls;
-   unsigned long irqs;
-   unsigned long berrs;
-   unsigned long dmaerrors;
-   unsigned long timeouts;
-   unsigned long external;
-};
-static struct driver_stats statistics;
-
 static struct cdev *vme_user_cdev; /* Character device */
 static struct class *vme_user_sysfs_class; /* Sysfs class */
 static struct vme_dev *vme_user_bridge;/* Pointer to user 
device */
@@ -170,20 +158,6 @@ static const struct vm_operations_struct vme_user_vm_ops = 
{
 };
 
 
-/*
- * Reset all the statistic counters
- */
-static void reset_counters(void)
-{
-   statistics.reads = 0;
-   statistics.writes = 0;
-   statistics.ioctls = 0;
-   statistics.irqs = 0;
-   statistics.berrs = 0;
-   statistics.dmaerrors = 0;
-   statistics.timeouts = 0;
-}
-
 static int vme_user_open(struct inode *inode, struct file *file)
 {
int err;
@@ -631,8 +605,6 @@ static int vme_user_ioctl(struct inode *inode, struct file 
*file,
dma_addr_t pci_addr;
void __user *argp = (void __user *)arg;
 
-   statistics.ioctls++;
-
switch (type[minor]) {
case CONTROL_MINOR:
switch (cmd) {
@@ -944,9 +916,6 @@ static int vme_user_probe(struct vme_dev *vdev)
image[i].users = 0;
}
 
-   /* Initialise statistics counters */
-   reset_counters();
-
/* Assign major and minor numbers for the driver */
err = register_chrdev_region(MKDEV(VME_MAJOR, 0), VME_DEVS,
driver_name);
-- 
1.8.3.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCHv3 03/16] vme: tsi148: fix first DMA item mapping

2015-05-28 Thread Dmitry Kalinkin
This moves DMA mapping of the first list element to vme_list_add, the
same place where other elements mappings occur. This prevents extra
mapping or over-unmapping in the cases when vme_list_exec is called more
or less than one time respectively.

Also adds dma_mapping_error check.

Signed-off-by: Dmitry Kalinkin 
Cc: Igor Alekseev 
---
 drivers/vme/bridges/vme_tsi148.c | 23 ---
 1 file changed, 12 insertions(+), 11 deletions(-)

diff --git a/drivers/vme/bridges/vme_tsi148.c b/drivers/vme/bridges/vme_tsi148.c
index 1be4136..6562348 100644
--- a/drivers/vme/bridges/vme_tsi148.c
+++ b/drivers/vme/bridges/vme_tsi148.c
@@ -1833,17 +1833,21 @@ static int tsi148_dma_list_add(struct vme_dma_list 
*list,
/* Add to list */
list_add_tail(&entry->list, &list->entries);
 
+   entry->dma_handle = dma_map_single(tsi148_bridge->parent,
+   &entry->descriptor,
+   sizeof(struct tsi148_dma_descriptor), DMA_TO_DEVICE);
+   if (dma_mapping_error(tsi148_bridge->parent, entry->dma_handle)) {
+   dev_err(tsi148_bridge->parent, "DMA mapping error\n");
+   retval = -EINVAL;
+   goto err_dma;
+   }
+
/* Fill out previous descriptors "Next Address" */
if (entry->list.prev != &list->entries) {
-   prev = list_entry(entry->list.prev, struct tsi148_dma_entry,
-   list);
-   /* We need the bus address for the pointer */
-   entry->dma_handle = dma_map_single(tsi148_bridge->parent,
-   &entry->descriptor,
-   sizeof(struct tsi148_dma_descriptor), DMA_TO_DEVICE);
-
reg_split((unsigned long long)entry->dma_handle, &address_high,
&address_low);
+   prev = list_entry(entry->list.prev, struct tsi148_dma_entry,
+ list);
prev->descriptor.dnlau = cpu_to_be32(address_high);
prev->descriptor.dnlal = cpu_to_be32(address_low);
 
@@ -1851,6 +1855,7 @@ static int tsi148_dma_list_add(struct vme_dma_list *list,
 
return 0;
 
+err_dma:
 err_dest:
 err_source:
 err_align:
@@ -1921,10 +1926,6 @@ static int tsi148_dma_list_exec(struct vme_dma_list 
*list)
entry = list_first_entry(&list->entries, struct tsi148_dma_entry,
list);
 
-   entry->dma_handle = dma_map_single(tsi148_bridge->parent,
-   &entry->descriptor,
-   sizeof(struct tsi148_dma_descriptor), DMA_TO_DEVICE);
-
mutex_unlock(&ctrlr->mtx);
 
reg_split(entry->dma_handle, &bus_addr_high, &bus_addr_low);
-- 
1.8.3.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCHv3 09/16] vme: ca91cx42: return error code on DMA error

2015-05-28 Thread Dmitry Kalinkin
Signed-off-by: Dmitry Kalinkin 
Cc: Igor Alekseev 
---
 drivers/vme/bridges/vme_ca91cx42.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/vme/bridges/vme_ca91cx42.c 
b/drivers/vme/bridges/vme_ca91cx42.c
index e9bd657..f692efc 100644
--- a/drivers/vme/bridges/vme_ca91cx42.c
+++ b/drivers/vme/bridges/vme_ca91cx42.c
@@ -1269,6 +1269,7 @@ static int ca91cx42_dma_list_exec(struct vme_dma_list 
*list)
 
dev_err(dev, "ca91c042: DMA Error. DGCS=%08X\n", val);
val = ioread32(bridge->base + DCTL);
+   retval = -EIO;
}
 
 exit:
-- 
1.8.3.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCHv3 12/16] staging: vme_user: remove forward declarations

2015-05-28 Thread Dmitry Kalinkin
Reorder code so that forward declarations are not needed.

Signed-off-by: Dmitry Kalinkin 
Cc: Igor Alekseev 
---
 drivers/staging/vme/devices/vme_user.c | 139 ++---
 1 file changed, 60 insertions(+), 79 deletions(-)

diff --git a/drivers/staging/vme/devices/vme_user.c 
b/drivers/staging/vme/devices/vme_user.c
index cc0d3df..4755737 100644
--- a/drivers/staging/vme/devices/vme_user.c
+++ b/drivers/staging/vme/devices/vme_user.c
@@ -119,44 +119,11 @@ static const int type[VME_DEVS] = {   MASTER_MINOR,   
MASTER_MINOR,
CONTROL_MINOR,  DMA_MINOR
};
 
-
-static int vme_user_open(struct inode *, struct file *);
-static int vme_user_release(struct inode *, struct file *);
-static ssize_t vme_user_read(struct file *, char __user *, size_t, loff_t *);
-static ssize_t vme_user_write(struct file *, const char __user *, size_t,
-   loff_t *);
-static loff_t vme_user_llseek(struct file *, loff_t, int);
-static long vme_user_unlocked_ioctl(struct file *, unsigned int, unsigned 
long);
-static int vme_user_mmap(struct file *file, struct vm_area_struct *vma);
-
-static void vme_user_vm_open(struct vm_area_struct *vma);
-static void vme_user_vm_close(struct vm_area_struct *vma);
-
-static int vme_user_match(struct vme_dev *);
-static int vme_user_probe(struct vme_dev *);
-static int vme_user_remove(struct vme_dev *);
-
-static const struct file_operations vme_user_fops = {
-   .open = vme_user_open,
-   .release = vme_user_release,
-   .read = vme_user_read,
-   .write = vme_user_write,
-   .llseek = vme_user_llseek,
-   .unlocked_ioctl = vme_user_unlocked_ioctl,
-   .compat_ioctl = vme_user_unlocked_ioctl,
-   .mmap = vme_user_mmap,
-};
-
 struct vme_user_vma_priv {
unsigned int minor;
atomic_t refcnt;
 };
 
-static const struct vm_operations_struct vme_user_vm_ops = {
-   .open = vme_user_vm_open,
-   .close = vme_user_vm_close,
-};
-
 
 static int vme_user_open(struct inode *inode, struct file *file)
 {
@@ -761,6 +728,11 @@ static void vme_user_vm_close(struct vm_area_struct *vma)
kfree(vma_priv);
 }
 
+static const struct vm_operations_struct vme_user_vm_ops = {
+   .open = vme_user_vm_open,
+   .close = vme_user_vm_close,
+};
+
 static int vme_user_master_mmap(unsigned int minor, struct vm_area_struct *vma)
 {
int err;
@@ -802,6 +774,16 @@ static int vme_user_mmap(struct file *file, struct 
vm_area_struct *vma)
return -ENODEV;
 }
 
+static const struct file_operations vme_user_fops = {
+   .open = vme_user_open,
+   .release = vme_user_release,
+   .read = vme_user_read,
+   .write = vme_user_write,
+   .llseek = vme_user_llseek,
+   .unlocked_ioctl = vme_user_unlocked_ioctl,
+   .compat_ioctl = vme_user_unlocked_ioctl,
+   .mmap = vme_user_mmap,
+};
 
 /*
  * Unallocate a previously allocated buffer
@@ -828,52 +810,6 @@ static void buf_unalloc(int num)
}
 }
 
-static struct vme_driver vme_user_driver = {
-   .name = driver_name,
-   .match = vme_user_match,
-   .probe = vme_user_probe,
-   .remove = vme_user_remove,
-};
-
-
-static int __init vme_user_init(void)
-{
-   int retval = 0;
-
-   pr_info("VME User Space Access Driver\n");
-
-   if (bus_num == 0) {
-   pr_err("No cards, skipping registration\n");
-   retval = -ENODEV;
-   goto err_nocard;
-   }
-
-   /* Let's start by supporting one bus, we can support more than one
-* in future revisions if that ever becomes necessary.
-*/
-   if (bus_num > VME_USER_BUS_MAX) {
-   pr_err("Driver only able to handle %d buses\n",
-  VME_USER_BUS_MAX);
-   bus_num = VME_USER_BUS_MAX;
-   }
-
-   /*
-* Here we just register the maximum number of devices we can and
-* leave vme_user_match() to allow only 1 to go through to probe().
-* This way, if we later want to allow multiple user access devices,
-* we just change the code in vme_user_match().
-*/
-   retval = vme_register_driver(&vme_user_driver, VME_MAX_SLOTS);
-   if (retval != 0)
-   goto err_reg;
-
-   return retval;
-
-err_reg:
-err_nocard:
-   return retval;
-}
-
 static int vme_user_match(struct vme_dev *vdev)
 {
int i;
@@ -,6 +1047,51 @@ static int vme_user_remove(struct vme_dev *dev)
return 0;
 }
 
+static struct vme_driver vme_user_driver = {
+   .name = driver_name,
+   .match = vme_user_match,
+   .probe = vme_user_probe,
+   .remove = vme_user_remove,
+};
+
+static int __init vme_user_init(void)
+{
+   int retval = 0;
+
+   pr_info("VME User Space Access Driver\n");
+
+   if (bus_num == 0) {
+   pr_err("No cards, skipping registration\n");
+   retval = -ENODEV;
+   goto err_nocard;
+ 

[PATCHv3 05/16] staging: vme_user: refactor llseek to switch(){}

2015-05-28 Thread Dmitry Kalinkin
This makes vme_user_llseek ignore all minors that don't have llseek
implementation.

Signed-off-by: Dmitry Kalinkin 
Cc: Igor Alekseev 
---
 drivers/staging/vme/devices/vme_user.c | 18 ++
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/drivers/staging/vme/devices/vme_user.c 
b/drivers/staging/vme/devices/vme_user.c
index 19ba749..da828f4 100644
--- a/drivers/staging/vme/devices/vme_user.c
+++ b/drivers/staging/vme/devices/vme_user.c
@@ -430,15 +430,17 @@ static loff_t vme_user_llseek(struct file *file, loff_t 
off, int whence)
size_t image_size;
loff_t res;
 
-   if (minor == CONTROL_MINOR)
-   return -EINVAL;
-
-   mutex_lock(&image[minor].mutex);
-   image_size = vme_get_size(image[minor].resource);
-   res = fixed_size_llseek(file, off, whence, image_size);
-   mutex_unlock(&image[minor].mutex);
+   switch (type[minor]) {
+   case MASTER_MINOR:
+   case SLAVE_MINOR:
+   mutex_lock(&image[minor].mutex);
+   image_size = vme_get_size(image[minor].resource);
+   res = fixed_size_llseek(file, off, whence, image_size);
+   mutex_unlock(&image[minor].mutex);
+   return res;
+   }
 
-   return res;
+   return -EINVAL;
 }
 
 /*
-- 
1.8.3.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCHv3 14/16] staging: vme_user: remove buf_unalloc helper

2015-05-28 Thread Dmitry Kalinkin
buf_unalloc is essentially a vme_free_consistent:
1) image[i].kern_buf is never NULL in buf_alloc call
2) kern_buf, pci_buf and size_buf get zeroed in vme_user_probe anyway

Signed-off-by: Dmitry Kalinkin 
Cc: Igor Alekseev 
---
 drivers/staging/vme/devices/vme_user.c | 31 ---
 1 file changed, 4 insertions(+), 27 deletions(-)

diff --git a/drivers/staging/vme/devices/vme_user.c 
b/drivers/staging/vme/devices/vme_user.c
index 381b052..5cc782e 100644
--- a/drivers/staging/vme/devices/vme_user.c
+++ b/drivers/staging/vme/devices/vme_user.c
@@ -742,31 +742,6 @@ static const struct file_operations vme_user_fops = {
.mmap = vme_user_mmap,
 };
 
-/*
- * Unallocate a previously allocated buffer
- */
-static void buf_unalloc(int num)
-{
-   if (image[num].kern_buf) {
-#ifdef VME_DEBUG
-   pr_debug("UniverseII:Releasing buffer at %p\n",
-image[num].pci_buf);
-#endif
-
-   vme_free_consistent(image[num].resource, image[num].size_buf,
-   image[num].kern_buf, image[num].pci_buf);
-
-   image[num].kern_buf = NULL;
-   image[num].pci_buf = 0;
-   image[num].size_buf = 0;
-
-#ifdef VME_DEBUG
-   } else {
-   pr_debug("UniverseII: Buffer not allocated\n");
-#endif
-   }
-}
-
 static int vme_user_match(struct vme_dev *vdev)
 {
int i;
@@ -958,7 +933,8 @@ err_master:
 err_slave:
while (i > SLAVE_MINOR) {
i--;
-   buf_unalloc(i);
+   vme_free_consistent(image[i].resource, image[i].size_buf,
+   image[i].kern_buf, image[i].pci_buf);
vme_slave_free(image[i].resource);
}
 err_class:
@@ -990,7 +966,8 @@ static int vme_user_remove(struct vme_dev *dev)
 
for (i = SLAVE_MINOR; i < (SLAVE_MAX + 1); i++) {
vme_slave_set(image[i].resource, 0, 0, 0, 0, VME_A32, 0);
-   buf_unalloc(i);
+   vme_free_consistent(image[i].resource, image[i].size_buf,
+   image[i].kern_buf, image[i].pci_buf);
vme_slave_free(image[i].resource);
}
 
-- 
1.8.3.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCHv3 16/16] vme: provide uapi header

2015-05-28 Thread Dmitry Kalinkin
This separates VME related constants that are a part of both kernel and
user space API into a common uapi header.

Signed-off-by: Dmitry Kalinkin 
Cc: Igor Alekseev 
---
 include/linux/vme.h   | 54 ++---
 include/uapi/linux/Kbuild |  1 +
 include/uapi/linux/vme.h  | 56 +++
 3 files changed, 59 insertions(+), 52 deletions(-)
 create mode 100644 include/uapi/linux/vme.h

diff --git a/include/linux/vme.h b/include/linux/vme.h
index c013135..ecfd389 100644
--- a/include/linux/vme.h
+++ b/include/linux/vme.h
@@ -1,6 +1,8 @@
 #ifndef _VME_H_
 #define _VME_H_
 
+#include 
+
 /* Resource Type */
 enum vme_resource_type {
VME_MASTER,
@@ -9,47 +11,6 @@ enum vme_resource_type {
VME_LM
 };
 
-/* VME Address Spaces */
-#define VME_A160x1
-#define VME_A240x2
-#defineVME_A32 0x4
-#define VME_A640x8
-#define VME_CRCSR  0x10
-#define VME_USER1  0x20
-#define VME_USER2  0x40
-#define VME_USER3  0x80
-#define VME_USER4  0x100
-
-#define VME_A16_MAX0x1ULL
-#define VME_A24_MAX0x100ULL
-#define VME_A32_MAX0x1ULL
-#define VME_A64_MAX0x1ULL
-#define VME_CRCSR_MAX  0x100ULL
-
-
-/* VME Cycle Types */
-#define VME_SCT0x1
-#define VME_BLT0x2
-#define VME_MBLT   0x4
-#define VME_2eVME  0x8
-#define VME_2eSST  0x10
-#define VME_2eSSTB 0x20
-
-#define VME_2eSST160   0x100
-#define VME_2eSST267   0x200
-#define VME_2eSST320   0x400
-
-#defineVME_SUPER   0x1000
-#defineVME_USER0x2000
-#defineVME_PROG0x4000
-#defineVME_DATA0x8000
-
-/* VME Data Widths */
-#define VME_D8 0x1
-#define VME_D160x2
-#define VME_D320x4
-#define VME_D640x8
-
 /* Arbitration Scheduling Modes */
 #define VME_R_ROBIN_MODE   0x1
 #define VME_PRIORITY_MODE  0x2
@@ -58,17 +19,6 @@ enum vme_resource_type {
 #define VME_DMA_PCI(1<<1)
 #define VME_DMA_VME(1<<2)
 
-#define VME_DMA_PATTERN_BYTE   (1<<0)
-#define VME_DMA_PATTERN_WORD   (1<<1)
-#define VME_DMA_PATTERN_INCREMENT  (1<<2)
-
-#define VME_DMA_VME_TO_MEM (1<<0)
-#define VME_DMA_MEM_TO_VME (1<<1)
-#define VME_DMA_VME_TO_VME (1<<2)
-#define VME_DMA_MEM_TO_MEM (1<<3)
-#define VME_DMA_PATTERN_TO_VME (1<<4)
-#define VME_DMA_PATTERN_TO_MEM (1<<5)
-
 struct vme_dma_attr {
u32 type;
void *private;
diff --git a/include/uapi/linux/Kbuild b/include/uapi/linux/Kbuild
index 1a0006a..ad25e3f 100644
--- a/include/uapi/linux/Kbuild
+++ b/include/uapi/linux/Kbuild
@@ -439,6 +439,7 @@ header-y += virtio_rng.h
 header-y += virtio_scsi.h
 header-y += virtio_types.h
 header-y += vm_sockets.h
+header-y += vme.h
 header-y += vt.h
 header-y += wait.h
 header-y += wanrouter.h
diff --git a/include/uapi/linux/vme.h b/include/uapi/linux/vme.h
new file mode 100644
index 000..3dbf8b0
--- /dev/null
+++ b/include/uapi/linux/vme.h
@@ -0,0 +1,56 @@
+#ifndef _UAPI_LINUX_VME
+#define _UAPI_LINUX_VME
+
+/* VME Address Spaces */
+#define VME_A160x1
+#define VME_A240x2
+#define VME_A320x4
+#define VME_A640x8
+#define VME_CRCSR  0x10
+#define VME_USER1  0x20
+#define VME_USER2  0x40
+#define VME_USER3  0x80
+#define VME_USER4  0x100
+
+#define VME_A16_MAX0x1ULL
+#define VME_A24_MAX0x100ULL
+#define VME_A32_MAX0x1ULL
+#define VME_A64_MAX0x1ULL
+#define VME_CRCSR_MAX  0x100ULL
+
+/* VME Cycle Types */
+#define VME_SCT0x1
+#define VME_BLT0x2
+#define VME_MBLT   0x4
+#define VME_2eVME  0x8
+#define VME_2eSST  0x10
+#define VME_2eSSTB 0x20
+
+#define VME_2eSST160   0x100
+#define VME_2eSST267   0x200
+#define VME_2eSST320   0x400
+
+#define VME_SUPER  0x1000
+#define VME_USER   0x2000
+#define VME_PROG   0x4000
+#define VME_DATA   0x8000
+
+/* VME Data Widths */
+#define VME_D8 0x1
+#define VME_D160x2
+#define VME_D320x4
+#define VME_D640x8
+
+/* VME Transfer Directions */
+#define VME_DMA_VME_TO_MEM (1 << 0)
+#define VME_DMA_MEM_TO_VME (1 << 1)
+#define VME_DMA_VME_TO_VME (1 << 2)
+#define VME_DMA_MEM_TO_MEM (1 << 3)
+#define VME_DMA_PATTERN_TO_VME (1 << 4)
+#define VME_DMA_PATTERN_TO_MEM (1 << 5)
+
+#define VME_DMA_PATTERN_BYTE   (1 << 0)
+#define VME_DMA_PATTERN_WORD   (1 << 1)
+#define VME_DMA_PATTERN_INCREMENT  (1 << 2)
+
+#endif
-- 
1.8.3.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.or

[PATCHv3 13/16] staging: vme_user: remove open/release

2015-05-28 Thread Dmitry Kalinkin
Checking for image[minor].resource != NULL is not needed since all
resources are allocated before device is created.

image[minor].users accounting is deleted because it's not being used.

Signed-off-by: Dmitry Kalinkin 
Cc: Igor Alekseev 
---
 drivers/staging/vme/devices/vme_user.c | 44 --
 1 file changed, 44 deletions(-)

diff --git a/drivers/staging/vme/devices/vme_user.c 
b/drivers/staging/vme/devices/vme_user.c
index 4755737..381b052 100644
--- a/drivers/staging/vme/devices/vme_user.c
+++ b/drivers/staging/vme/devices/vme_user.c
@@ -102,7 +102,6 @@ struct image_desc {
struct mutex mutex; /* Mutex for locking image */
struct device *device;  /* Sysfs device */
struct vme_resource *resource;  /* VME resource */
-   int users;  /* Number of current users */
int mmap_count; /* Number of current mmap's */
 };
 static struct image_desc image[VME_DEVS];
@@ -125,46 +124,6 @@ struct vme_user_vma_priv {
 };
 
 
-static int vme_user_open(struct inode *inode, struct file *file)
-{
-   int err;
-   unsigned int minor = MINOR(inode->i_rdev);
-
-   mutex_lock(&image[minor].mutex);
-   /* Allow device to be opened if a resource is needed and allocated. */
-   if (minor < CONTROL_MINOR && image[minor].resource == NULL) {
-   pr_err("No resources allocated for device\n");
-   err = -EINVAL;
-   goto err_res;
-   }
-
-   /* Increment user count */
-   image[minor].users++;
-
-   mutex_unlock(&image[minor].mutex);
-
-   return 0;
-
-err_res:
-   mutex_unlock(&image[minor].mutex);
-
-   return err;
-}
-
-static int vme_user_release(struct inode *inode, struct file *file)
-{
-   unsigned int minor = MINOR(inode->i_rdev);
-
-   mutex_lock(&image[minor].mutex);
-
-   /* Decrement user count */
-   image[minor].users--;
-
-   mutex_unlock(&image[minor].mutex);
-
-   return 0;
-}
-
 /*
  * We are going ot alloc a page during init per window for small transfers.
  * Small transfers will go VME -> buffer -> user space. Larger (more than a
@@ -775,8 +734,6 @@ static int vme_user_mmap(struct file *file, struct 
vm_area_struct *vma)
 }
 
 static const struct file_operations vme_user_fops = {
-   .open = vme_user_open,
-   .release = vme_user_release,
.read = vme_user_read,
.write = vme_user_write,
.llseek = vme_user_llseek,
@@ -849,7 +806,6 @@ static int vme_user_probe(struct vme_dev *vdev)
mutex_init(&image[i].mutex);
image[i].device = NULL;
image[i].resource = NULL;
-   image[i].users = 0;
}
 
/* Assign major and minor numbers for the driver */
-- 
1.8.3.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCHv3 15/16] vme: tsi148: depend on HAS_DMA for Kconfig

2015-05-28 Thread Dmitry Kalinkin
Signed-off-by: Dmitry Kalinkin 
Cc: Igor Alekseev 
---
 drivers/vme/bridges/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/vme/bridges/Kconfig b/drivers/vme/bridges/Kconfig
index 9331064..f6d8545 100644
--- a/drivers/vme/bridges/Kconfig
+++ b/drivers/vme/bridges/Kconfig
@@ -9,7 +9,7 @@ config VME_CA91CX42
 
 config VME_TSI148
tristate "Tempe"
-   depends on VIRT_TO_BUS
+   depends on HAS_DMA
help
 If you say Y here you get support for the Tundra TSI148 VME bridge
 chip.
-- 
1.8.3.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCHv3] staging: gs_fpgaboot: remove redundant code

2015-05-28 Thread Gujulan Elango, Hari Prasath (H.)
remove redundant code in this function.remove return value check for
function that always return success

Signed-off-by: Gujulan Elango Hari Prasath 
---
v3:Remove initialization of the 'err' variable.

v2:address review comments from Dan.Remove return value check
for the function gs_release_image as it always returns success and
rearrange the code accordingly.Also delete debug messages.
---
 drivers/staging/gs_fpgaboot/gs_fpgaboot.c | 42 ---
 1 file changed, 10 insertions(+), 32 deletions(-)

diff --git a/drivers/staging/gs_fpgaboot/gs_fpgaboot.c 
b/drivers/staging/gs_fpgaboot/gs_fpgaboot.c
index a3a10f9..7d05510 100644
--- a/drivers/staging/gs_fpgaboot/gs_fpgaboot.c
+++ b/drivers/staging/gs_fpgaboot/gs_fpgaboot.c
@@ -296,47 +296,25 @@ static int gs_fpgaboot(void)
return -ENOMEM;
 
err = gs_load_image(fimage, file);
-   if (err) {
-   pr_err("gs_load_image error\n");
-   goto err_out1;
-   }
+   if (err)
+   goto free_image;
 
err = gs_read_image(fimage);
-   if (err) {
-   pr_err("gs_read_image error\n");
-   goto err_out2;
-   }
+   if (err)
+   goto release_image;
 
err = gs_set_download_method(fimage);
-   if (err) {
-   pr_err("gs_set_download_method error\n");
-   goto err_out2;
-   }
+   if (err)
+   goto release_image;
 
err = gs_download_image(fimage, bus_2byte);
-   if (err) {
-   pr_err("gs_download_image error\n");
-   goto err_out2;
-   }
-
-   err = gs_release_image(fimage);
-   if (err) {
-   pr_err("gs_release_image error\n");
-   goto err_out1;
-   }
-
-   kfree(fimage);
-   return 0;
 
-err_out2:
-   err = gs_release_image(fimage);
-   if (err)
-   pr_err("gs_release_image error\n");
-err_out1:
+release_image:
+   gs_release_image(fimage);
+free_image:
kfree(fimage);
 
-   return -1;
-
+   return err;
 }
 
 static int __init gs_fpgaboot_init(void)
-- 
1.9.1
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: dgnc: check return value before using pointer

2015-05-28 Thread Gujulan Elango, Hari Prasath (H.)
Check the return value of kcalloc first and then use the pointer.

Signed-off-by: Gujulan Elango Hari Prasath 
---
 drivers/staging/dgnc/dgnc_driver.c | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/dgnc/dgnc_driver.c 
b/drivers/staging/dgnc/dgnc_driver.c
index 805dc61..935e297 100644
--- a/drivers/staging/dgnc/dgnc_driver.c
+++ b/drivers/staging/dgnc/dgnc_driver.c
@@ -385,13 +385,14 @@ static int dgnc_found_board(struct pci_dev *pdev, int id)
 
/* make a temporary message buffer for the boot messages */
brd->msgbuf_head = kcalloc(8192, sizeof(u8), GFP_KERNEL);
-   brd->msgbuf = brd->msgbuf_head;
-
-   if (!brd->msgbuf) {
+   if (!brd->msgbuf_head) {
kfree(brd);
return -ENOMEM;
}
 
+   brd->msgbuf = brd->msgbuf_head;
+
+
/* store the info for the board we've found */
brd->magic = DGNC_BOARD_MAGIC;
brd->boardnum = dgnc_NumBoards;
-- 
1.9.1
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCHv3] staging: gs_fpgaboot: remove redundant code

2015-05-28 Thread Dan Carpenter
On Thu, May 28, 2015 at 12:08:56PM +, Gujulan Elango, Hari Prasath (H.) 
wrote:
> remove redundant code in this function.remove return value check for
> function that always return success
> 
> Signed-off-by: Gujulan Elango Hari Prasath 

Looks good.  Thanks!

regards,
dan carpenter

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: dgnc: check return value of kzalloc

2015-05-28 Thread Gujulan Elango, Hari Prasath (H.)
Check the return value of kzalloc & return error if it fails.

Signed-off-by: Gujulan Elango Hari Prasath 
---
 drivers/staging/dgnc/dgnc_driver.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/staging/dgnc/dgnc_driver.c 
b/drivers/staging/dgnc/dgnc_driver.c
index 935e297..2c729be 100644
--- a/drivers/staging/dgnc/dgnc_driver.c
+++ b/drivers/staging/dgnc/dgnc_driver.c
@@ -589,6 +589,8 @@ static int dgnc_found_board(struct pci_dev *pdev, int id)
 * context, and there are no locks held.
 */
brd->flipbuf = kzalloc(MYFLIPLEN, GFP_KERNEL);
+   if (!brd->flipbuf)
+   return -ENOMEM;
 
wake_up_interruptible(&brd->state_wait);
 
-- 
1.9.1
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: dgnc: check return value of kzalloc

2015-05-28 Thread Dan Carpenter
On Thu, May 28, 2015 at 01:23:57PM +, Gujulan Elango, Hari Prasath (H.) 
wrote:
> Check the return value of kzalloc & return error if it fails.
> 
> Signed-off-by: Gujulan Elango Hari Prasath 
> ---
>  drivers/staging/dgnc/dgnc_driver.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/staging/dgnc/dgnc_driver.c 
> b/drivers/staging/dgnc/dgnc_driver.c
> index 935e297..2c729be 100644
> --- a/drivers/staging/dgnc/dgnc_driver.c
> +++ b/drivers/staging/dgnc/dgnc_driver.c
> @@ -589,6 +589,8 @@ static int dgnc_found_board(struct pci_dev *pdev, int id)
>* context, and there are no locks held.
>*/
>   brd->flipbuf = kzalloc(MYFLIPLEN, GFP_KERNEL);
> + if (!brd->flipbuf)
> + return -ENOMEM;

Just delete flipbuf and all the references to it.

regards,
dan carpenter

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


RE: [PATCH net-next 1/1] hv_netvsc: Properly size the vrss queues

2015-05-28 Thread KY Srinivasan


> -Original Message-
> From: Dan Carpenter [mailto:dan.carpen...@oracle.com]
> Sent: Thursday, May 28, 2015 12:06 AM
> To: KY Srinivasan
> Cc: da...@davemloft.net; net...@vger.kernel.org; linux-
> ker...@vger.kernel.org; de...@linuxdriverproject.org; o...@aepfle.de;
> a...@canonical.com; jasow...@redhat.com
> Subject: Re: [PATCH net-next 1/1] hv_netvsc: Properly size the vrss queues
> 
> Since you're redoing this anyway.
> 
> On Tue, May 26, 2015 at 04:21:09PM -0700, K. Y. Srinivasan wrote:
> > diff --git a/drivers/net/hyperv/hyperv_net.h
> b/drivers/net/hyperv/hyperv_net.h
> > index ddcc7f8..dd45440 100644
> > --- a/drivers/net/hyperv/hyperv_net.h
> > +++ b/drivers/net/hyperv/hyperv_net.h
> > @@ -161,6 +161,7 @@ struct netvsc_device_info {
> > unsigned char mac_adr[ETH_ALEN];
> > bool link_state;/* 0 - link up, 1 - link down */
> > int  ring_size;
> > +   u32  max_num_vrss_chns;
> 
> We (Joe and I) have commented before that long names don't mix well with
> the 80 character limit.  You could just leave the "num_" out.  Almost
> all variables are numbers in C so it doesn't add anything.

Thanks Dan. Actually I sent out the revised patch yesterday and I currently 
don't
Have the 80 char issue. If it is ok with Dave, I will not re-spin the patch. 
However, I will
note this comment for future work.

K. Y
> 
> regards,
> dan carpenter
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH net-next 1/1] hv_netvsc: Properly size the vrss queues

2015-05-28 Thread Dan Carpenter
On Thu, May 28, 2015 at 01:52:47PM +, KY Srinivasan wrote:
> 
> 
> > -Original Message-
> > From: Dan Carpenter [mailto:dan.carpen...@oracle.com]
> > Sent: Thursday, May 28, 2015 12:06 AM
> > To: KY Srinivasan
> > Cc: da...@davemloft.net; net...@vger.kernel.org; linux-
> > ker...@vger.kernel.org; de...@linuxdriverproject.org; o...@aepfle.de;
> > a...@canonical.com; jasow...@redhat.com
> > Subject: Re: [PATCH net-next 1/1] hv_netvsc: Properly size the vrss queues
> > 
> > Since you're redoing this anyway.
> > 
> > On Tue, May 26, 2015 at 04:21:09PM -0700, K. Y. Srinivasan wrote:
> > > diff --git a/drivers/net/hyperv/hyperv_net.h
> > b/drivers/net/hyperv/hyperv_net.h
> > > index ddcc7f8..dd45440 100644
> > > --- a/drivers/net/hyperv/hyperv_net.h
> > > +++ b/drivers/net/hyperv/hyperv_net.h
> > > @@ -161,6 +161,7 @@ struct netvsc_device_info {
> > >   unsigned char mac_adr[ETH_ALEN];
> > >   bool link_state;/* 0 - link up, 1 - link down */
> > >   int  ring_size;
> > > + u32  max_num_vrss_chns;
> > 
> > We (Joe and I) have commented before that long names don't mix well with
> > the 80 character limit.  You could just leave the "num_" out.  Almost
> > all variables are numbers in C so it doesn't add anything.
> 
> Thanks Dan. Actually I sent out the revised patch yesterday and I currently 
> don't
> Have the 80 char issue. If it is ok with Dave, I will not re-spin the patch. 
> However, I will
> note this comment for future work.

Yes.  I saw that.  Fine fine.  It wasn't a redo the patch worthy
comment.  :P

regards,
dan carpenter

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging/wilc1000: fix Kconfig dependencies

2015-05-28 Thread Arnd Bergmann
The newly added wilc1000 driver lacks several Kconfig dependencies,
resulting in a multitude of randconfig build errors, e.g.:

drivers/built-in.o: In function `WILC_WFI_mgmt_tx_cancel_wait':
binder.c:(.text+0x12bd28): undefined reference to 
`cfg80211_remain_on_channel_expired'
drivers/built-in.o: In function `WILC_WFI_CfgSetChannel':
binder.c:(.text+0x12c9d8): undefined reference to 
`ieee80211_frequency_to_channel'
drivers/built-in.o: In function `WILC_WFI_CfgAlloc':
binder.c:(.text+0x132530): undefined reference to `wiphy_new_nm'
drivers/built-in.o: In function `wilc_netdev_init':
binder.c:(.text+0x1356d0): undefined reference to `register_inetaddr_notifier'
drivers/built-in.o: In function `linux_spi_init':
binder.c:(.text+0x210a68): undefined reference to `spi_register_driver'

This change ensures that we always have at least one of SPI or MMC
enabled, and are only able to pick an interface that works. It also
adds all the missing dependencies for networking infrastructure
(cfg80211, wext, and ipv4).

In order to make it readable, I also took the liberty of re-indenting
the Kconfig file to the normal conventions.

Signed-off-by: Arnd Bergmann 

diff --git a/drivers/staging/wilc1000/Kconfig b/drivers/staging/wilc1000/Kconfig
index 101f908bc9ed..02381521ff7f 100644
--- a/drivers/staging/wilc1000/Kconfig
+++ b/drivers/staging/wilc1000/Kconfig
@@ -1,55 +1,57 @@
 config WILC1000
tristate "WILC1000 support (WiFi only)"
+   depends on CFG80211 && WEXT_CORE && INET
+   depends on MMC || SPI
---help---
-   This module only support IEEE 802.11n WiFi.
+ This module only support IEEE 802.11n WiFi.
 
 choice
 prompt "Memory Allocation"
 depends on WILC1000
 default WILC1000_PREALLOCATE_AT_LOADING_DRIVER
 
-config WILC1000_PREALLOCATE_AT_LOADING_DRIVER
-bool "Preallocate memory at loading driver"
----help---
-This choice supports static allocation of the memory
-for the receive buffer. The driver will allocate the 
RX buffer 
-during initial time. The driver will also free the 
buffer
-by calling network device stop.
-
-config WILC1000_DYNAMICALLY_ALLOCATE_MEMROY
-bool "Dynamically allocate memory in real time"
----help---
-This choice supports dynamic allocation of the memory
-for the receive buffer. The driver will allocate the 
RX buffer
-when it is required.
+config WILC1000_PREALLOCATE_AT_LOADING_DRIVER
+   bool "Preallocate memory at loading driver"
+   ---help---
+ This choice supports static allocation of the memory
+ for the receive buffer. The driver will allocate the RX buffer
+ during initial time. The driver will also free the buffer
+ by calling network device stop.
+
+config WILC1000_DYNAMICALLY_ALLOCATE_MEMROY
+bool "Dynamically allocate memory in real time"
+---help---
+ This choice supports dynamic allocation of the memory
+ for the receive buffer. The driver will allocate the RX buffer
+ when it is required.
 endchoice
 
-
 choice
-prompt "Bus Type"
-depends on WILC1000 
-default WILC1000_SDIO
-
+   prompt "Bus Type"
+   depends on WILC1000
+   default WILC1000_SDIO
+
config WILC1000_SDIO
-   bool "SDIO support"
-   depends on MMC
-   ---help---
-   This module adds support for the SDIO interface of 
adapters using
-   WILC chipset. Select this if your platform is using the 
SDIO bus. 
+   bool "SDIO support"
+   depends on MMC
+   ---help---
+ This module adds support for the SDIO interface
+ of adapters using WILC chipset. Select this if
+ your platform is using the SDIO bus.
 
config WILC1000_SPI
-   bool "SPI support"
-   ---help---
-   This module adds support for the SPI interface of 
adapters using
-   WILC chipset. Select this if your platform is using the 
SPI bus. 
+   depends on SPI
+   bool "SPI support"
+   ---help---
+ This module adds support for the SPI interface
+ of adapters using WILC chipset. Select this if
+ your platform is using the SPI bus.
 endchoice
 
-
 config WILC1000_HW_OOB_INTR
-bool "Use out of band interrupt"
-depends on WILC1000 && WILC1000_SDIO
-default n
----help---
-   If your platform don't recognize SDIO IRQ, connect chipset 
external IRQ pin
-   and check this option. Or, Use this to get all interrupts 
including SDIO interrupts.
-
+   bool "Use out of band interrupt"
+   depends on WILC1000 && WILC1000_SDIO
+   default n
+   ---help---
+ If your platform don't recogn

[PATCH] staging: wilc1000: off by one in wilc_wfi_cfg80211_mgmt_types

2015-05-28 Thread Sasha Levin
NL80211_IFTYPE_MAX represents the largest interface type number defined,
so declaring the array with that size will actually leave out the last
interface.

This causes invalid memory access whenever this array is used, which starts
happening at boot.

Signed-off-by: Sasha Levin 
---
 drivers/staging/wilc1000/wilc_wfi_cfgoperations.h |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.h 
b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.h
index 9eb8f37..3a63fbd 100644
--- a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.h
+++ b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.h
@@ -82,7 +82,7 @@ static const u32 cipher_suites[] = {
 
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 37)
 static const struct ieee80211_txrx_stypes
-   wilc_wfi_cfg80211_mgmt_types[NL80211_IFTYPE_MAX] = {
+   wilc_wfi_cfg80211_mgmt_types[NUM_NL80211_IFTYPES] = {
[NL80211_IFTYPE_STATION] = {
.tx = 0x,
.rx = BIT(IEEE80211_STYPE_ACTION >> 4) |
-- 
1.7.10.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging/wilc1000: fix Kconfig dependencies

2015-05-28 Thread Nicolas Ferre
Le 28/05/2015 16:35, Arnd Bergmann a écrit :
> The newly added wilc1000 driver lacks several Kconfig dependencies,
> resulting in a multitude of randconfig build errors, e.g.:
> 
> drivers/built-in.o: In function `WILC_WFI_mgmt_tx_cancel_wait':
> binder.c:(.text+0x12bd28): undefined reference to 
> `cfg80211_remain_on_channel_expired'
> drivers/built-in.o: In function `WILC_WFI_CfgSetChannel':
> binder.c:(.text+0x12c9d8): undefined reference to 
> `ieee80211_frequency_to_channel'
> drivers/built-in.o: In function `WILC_WFI_CfgAlloc':
> binder.c:(.text+0x132530): undefined reference to `wiphy_new_nm'
> drivers/built-in.o: In function `wilc_netdev_init':
> binder.c:(.text+0x1356d0): undefined reference to `register_inetaddr_notifier'
> drivers/built-in.o: In function `linux_spi_init':
> binder.c:(.text+0x210a68): undefined reference to `spi_register_driver'
> 
> This change ensures that we always have at least one of SPI or MMC
> enabled, and are only able to pick an interface that works. It also
> adds all the missing dependencies for networking infrastructure
> (cfg80211, wext, and ipv4).
> 
> In order to make it readable, I also took the liberty of re-indenting
> the Kconfig file to the normal conventions.
> 
> Signed-off-by: Arnd Bergmann 

Acked-by: Nicolas Ferre 

Thanks a lot Arnd!

Bye,

> diff --git a/drivers/staging/wilc1000/Kconfig 
> b/drivers/staging/wilc1000/Kconfig
> index 101f908bc9ed..02381521ff7f 100644
> --- a/drivers/staging/wilc1000/Kconfig
> +++ b/drivers/staging/wilc1000/Kconfig
> @@ -1,55 +1,57 @@
>  config WILC1000
>   tristate "WILC1000 support (WiFi only)"
> + depends on CFG80211 && WEXT_CORE && INET
> + depends on MMC || SPI
>   ---help---
> - This module only support IEEE 802.11n WiFi.
> +   This module only support IEEE 802.11n WiFi.
>  
>  choice
>  prompt "Memory Allocation"
>  depends on WILC1000
>  default WILC1000_PREALLOCATE_AT_LOADING_DRIVER
>  
> -config WILC1000_PREALLOCATE_AT_LOADING_DRIVER
> -bool "Preallocate memory at loading driver"
> ----help---
> -This choice supports static allocation of the memory
> -for the receive buffer. The driver will allocate the 
> RX buffer 
> -during initial time. The driver will also free the 
> buffer
> -by calling network device stop.
> -
> -config WILC1000_DYNAMICALLY_ALLOCATE_MEMROY
> -bool "Dynamically allocate memory in real time"
> ----help---
> -This choice supports dynamic allocation of the memory
> -for the receive buffer. The driver will allocate the 
> RX buffer
> -when it is required.
> +config WILC1000_PREALLOCATE_AT_LOADING_DRIVER
> + bool "Preallocate memory at loading driver"
> + ---help---
> +   This choice supports static allocation of the memory
> +   for the receive buffer. The driver will allocate the RX buffer
> +   during initial time. The driver will also free the buffer
> +   by calling network device stop.
> +
> +config WILC1000_DYNAMICALLY_ALLOCATE_MEMROY
> +bool "Dynamically allocate memory in real time"
> +---help---
> +   This choice supports dynamic allocation of the memory
> +   for the receive buffer. The driver will allocate the RX buffer
> +   when it is required.
>  endchoice
>  
> -
>  choice
> -prompt "Bus Type"
> -depends on WILC1000 
> -default WILC1000_SDIO
> -
> + prompt "Bus Type"
> + depends on WILC1000
> + default WILC1000_SDIO
> +
>   config WILC1000_SDIO
> - bool "SDIO support"
> - depends on MMC
> - ---help---
> - This module adds support for the SDIO interface of 
> adapters using
> - WILC chipset. Select this if your platform is using the 
> SDIO bus. 
> + bool "SDIO support"
> + depends on MMC
> + ---help---
> +   This module adds support for the SDIO interface
> +   of adapters using WILC chipset. Select this if
> +   your platform is using the SDIO bus.
>  
>   config WILC1000_SPI
> - bool "SPI support"
> - ---help---
> - This module adds support for the SPI interface of 
> adapters using
> - WILC chipset. Select this if your platform is using the 
> SPI bus. 
> + depends on SPI
> + bool "SPI support"
> + ---help---
> +   This module adds support for the SPI interface
> +   of adapters using WILC chipset. Select this if
> +   your platform is using the SPI bus.
>  endchoice
>  
> -
>  config WILC1000_HW_OOB_INTR
> -bool "Use out of band interrupt"
> -depends on WILC1000 && WILC1000_SDIO
> -default n
> ----help---
> - If your platform don't recognize SDIO IRQ, connect chipset 
> external IRQ pin
> 

Re: [oss-security] Re: [PATCH v2 4/4] ozwpan: unchecked signed subtraction leads to DoS

2015-05-28 Thread Jason A. Donenfeld
On Thu, May 28, 2015 at 1:04 PM, Dan Carpenter  wrote:
> It's really not simpler to understand though.

Greg - do you want me to resubmit a v3 for this, or does it not really
matter and we can address this in another series? Personally, I'm
erring on the side of wanting to get *something* merged sooner, rather
than doing a v3.

> Maybe we should just delete these ozwpan drivers entirely...  They were
> merged when Ozmodevices was its own company and I don't think anyone is
> working on them any more.

The driver is most certainly still in widespread use. I'd caution
against dropping it from the tree entirely.

The maintainer was changed just last year with this commit, when
Shigekatsu Tateno became maintainer instead of Rupesh Gujare:

commit 96747a8f4e7d187f236ad392d86a37a4d1ba0b32
Author: Rupesh Gujare 
Date:   Mon May 19 15:17:30 2014 +0100

staging: ozwpan: Change Maintainer

I will be not able to work on ozwpan driver anymore.
Remove my name & add Tateno as maintainer.

Signed-off-by: Rupesh Gujare 
Acked-by: Shigekatsu Tateno 
Signed-off-by: Greg Kroah-Hartman 
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: ft1000: warning removal: extern functions to static ones

2015-05-28 Thread Xavier Roche
Local functions not used in other modules should be static, not extern.
(patch checked against linux-next and staging)

Signed-off-by: Xavier Roche 
---
 drivers/staging/ft1000/ft1000-pcmcia/ft1000_dnld.c | 24 +++---
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/drivers/staging/ft1000/ft1000-pcmcia/ft1000_dnld.c 
b/drivers/staging/ft1000/ft1000-pcmcia/ft1000_dnld.c
index 83683e9..3237ee73 100644
--- a/drivers/staging/ft1000/ft1000-pcmcia/ft1000_dnld.c
+++ b/drivers/staging/ft1000/ft1000-pcmcia/ft1000_dnld.c
@@ -82,12 +82,12 @@
 #define  STATE_DONE_PROV 0x06
 #define  STATE_DONE_FILE 0x07
 
-u16 get_handshake(struct net_device *dev, u16 expected_value);
-void put_handshake(struct net_device *dev, u16 handshake_value);
-u16 get_request_type(struct net_device *dev);
-long get_request_value(struct net_device *dev);
-void put_request_value(struct net_device *dev, long lvalue);
-u16 hdr_checksum(struct pseudo_hdr *pHdr);
+static u16 get_handshake(struct net_device *dev, u16 expected_value);
+static void put_handshake(struct net_device *dev, u16 handshake_value);
+static u16 get_request_type(struct net_device *dev);
+static long get_request_value(struct net_device *dev);
+static void put_request_value(struct net_device *dev, long lvalue);
+static u16 hdr_checksum(struct pseudo_hdr *pHdr);
 
 struct dsp_file_hdr {
u32  version_id;/* Version ID of this image format. */
@@ -146,7 +146,7 @@ void card_bootload(struct net_device *dev)
spin_unlock_irqrestore(&info->dpram_lock, flags);
 }
 
-u16 get_handshake(struct net_device *dev, u16 expected_value)
+static u16 get_handshake(struct net_device *dev, u16 expected_value)
 {
struct ft1000_info *info = netdev_priv(dev);
u16 handshake;
@@ -180,7 +180,7 @@ u16 get_handshake(struct net_device *dev, u16 
expected_value)
 
 }
 
-void put_handshake(struct net_device *dev, u16 handshake_value)
+static void put_handshake(struct net_device *dev, u16 handshake_value)
 {
struct ft1000_info *info = netdev_priv(dev);
u32 tempx;
@@ -196,7 +196,7 @@ void put_handshake(struct net_device *dev, u16 
handshake_value)
}
 }
 
-u16 get_request_type(struct net_device *dev)
+static u16 get_request_type(struct net_device *dev)
 {
struct ft1000_info *info = netdev_priv(dev);
u16 request_type;
@@ -215,7 +215,7 @@ u16 get_request_type(struct net_device *dev)
 
 }
 
-long get_request_value(struct net_device *dev)
+static long get_request_value(struct net_device *dev)
 {
struct ft1000_info *info = netdev_priv(dev);
long value;
@@ -244,7 +244,7 @@ long get_request_value(struct net_device *dev)
 
 }
 
-void put_request_value(struct net_device *dev, long lvalue)
+static void put_request_value(struct net_device *dev, long lvalue)
 {
struct ft1000_info *info = netdev_priv(dev);
u16 size;
@@ -271,7 +271,7 @@ void put_request_value(struct net_device *dev, long lvalue)
 
 }
 
-u16 hdr_checksum(struct pseudo_hdr *pHdr)
+static u16 hdr_checksum(struct pseudo_hdr *pHdr)
 {
u16 *usPtr = (u16 *)pHdr;
u16 chksum;
-- 
1.9.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] Drivers: hv: vmbus: use 'die' notification chain instead of 'panic'

2015-05-28 Thread Vitaly Kuznetsov
current_pt_regs() returns regs of the userspace process and in case of
kernel crash this is not what we need to report. E.g. when we trigger
crash with sysrq we see the following:
...
 RIP: 0010:[]  [] 
sysrq_handle_crash+0x16/0x20
 RSP: 0018:8800db0a7d88  EFLAGS: 00010246
 RAX: 000f RBX: 820a0660 RCX: 
...
at the same time current_pt_regs() give us:
ip=7f899ea7e9e0, ax=ffda, bx=26c81a0, cx=7f899ea7e9e0, ...
These registers come from the userspace process triggered the crash. As we
don't even know which process it was this information is rather useless.

When kernel crash happens proper regs are being passed to all receivers on
the die_chain (and panic_notifier_list is being notified with the string
passed to panic() only). Let's move our Hyper-V MSR reporter there. This
change has the following implication: when panic() is called manually from
some other part of kernel we won't be reporting crash to the hypervisor
(but we have no valuable information to report anyway).

Signed-off-by: Vitaly Kuznetsov 
---
 drivers/hv/vmbus_drv.c | 23 ++-
 1 file changed, 10 insertions(+), 13 deletions(-)

diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
index cf20400..9488ab2 100644
--- a/drivers/hv/vmbus_drv.c
+++ b/drivers/hv/vmbus_drv.c
@@ -39,6 +39,7 @@
 #include 
 #include 
 #include 
+#include 
 #include "hyperv_vmbus.h"
 
 static struct acpi_device  *hv_acpi_dev;
@@ -48,12 +49,11 @@ static struct completion probe_event;
 static int irq;
 
 
-static int hyperv_panic_event(struct notifier_block *nb,
-   unsigned long event, void *ptr)
+static int hyperv_die_event(struct notifier_block *nb, unsigned long val,
+   void *args)
 {
-   struct pt_regs *regs;
-
-   regs = current_pt_regs();
+   struct die_args *die = (struct die_args *)args;
+   struct pt_regs *regs = die->regs;
 
wrmsrl(HV_X64_MSR_CRASH_P0, regs->ip);
wrmsrl(HV_X64_MSR_CRASH_P1, regs->ax);
@@ -68,8 +68,8 @@ static int hyperv_panic_event(struct notifier_block *nb,
return NOTIFY_DONE;
 }
 
-static struct notifier_block hyperv_panic_block = {
-   .notifier_call = hyperv_panic_event,
+static struct notifier_block hyperv_die_block = {
+   .notifier_call = hyperv_die_event,
 };
 
 struct resource hyperv_mmio = {
@@ -842,8 +842,7 @@ static int vmbus_bus_init(int irq)
 * Only register if the crash MSRs are available
 */
if (ms_hyperv.features & HV_FEATURE_GUEST_CRASH_MSR_AVAILABLE) {
-   atomic_notifier_chain_register(&panic_notifier_list,
-  &hyperv_panic_block);
+   register_die_notifier(&hyperv_die_block);
}
 
vmbus_request_offers();
@@ -1110,10 +1109,8 @@ static void __exit vmbus_exit(void)
hv_remove_vmbus_irq();
tasklet_kill(&msg_dpc);
vmbus_free_channels();
-   if (ms_hyperv.features & HV_FEATURE_GUEST_CRASH_MSR_AVAILABLE) {
-   atomic_notifier_chain_unregister(&panic_notifier_list,
-&hyperv_panic_block);
-   }
+   if (ms_hyperv.features & HV_FEATURE_GUEST_CRASH_MSR_AVAILABLE)
+   unregister_die_notifier(&hyperv_die_block);
bus_unregister(&hv_bus);
hv_cleanup();
for_each_online_cpu(cpu) {
-- 
1.9.3

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: gdm72xx: remove unneeded test

2015-05-28 Thread Julia Lawall


On Wed, 27 May 2015, Joe Perches wrote:

> On Thu, 2015-05-28 at 07:43 +0200, Julia Lawall wrote:
> > On Wed, 27 May 2015, Joe Perches wrote:
> > > Perhaps all of the uses like:
> > >
> > >   goto ;
> > > :
> > >
> > > could be modified.  There are ~150 in the kernel.
> >
> > I wrote a semantic patch recently for that as well...  Maybe I can take
> > care of it.
>
> Great.  Thanks Julia.
>
> There may be some reorganization of code that is
> possible for many of these than coccinelle may
> not perform well though.

As what looks like an extreme example, wouldn't this function be better as
just return inet6_register_protosw(&rawv6_protosw); ?

int __init rawv6_init(void)
{
int ret;

ret = inet6_register_protosw(&rawv6_protosw);
if (ret)
goto out;
out:
return ret;
}

julia
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: ft1000: warning removal: extern functions to static ones

2015-05-28 Thread Greg KH
On Thu, May 28, 2015 at 05:24:56PM +0200, Xavier Roche wrote:
> Local functions not used in other modules should be static, not extern.
> (patch checked against linux-next and staging)

This line shouldn't be here, it should just be "implied" :)

> Signed-off-by: Xavier Roche 
> ---
>  drivers/staging/ft1000/ft1000-pcmcia/ft1000_dnld.c | 24 
> +++---
>  1 file changed, 12 insertions(+), 12 deletions(-)

In the future, always use scripts/get_maintainer.pl to determine who to
send patches to please.

thanks,

greg k-h
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: gdm72xx: remove unneeded test

2015-05-28 Thread Joe Perches
On Thu, 2015-05-28 at 18:21 +0200, Julia Lawall wrote:
> 
> On Wed, 27 May 2015, Joe Perches wrote:
> 
> > On Thu, 2015-05-28 at 07:43 +0200, Julia Lawall wrote:
> > > On Wed, 27 May 2015, Joe Perches wrote:
> > > > Perhaps all of the uses like:
> > > >
> > > > goto ;
> > > > :
> > > >
> > > > could be modified.  There are ~150 in the kernel.
> > >
> > > I wrote a semantic patch recently for that as well...  Maybe I can take
> > > care of it.
> >
> > Great.  Thanks Julia.
> >
> > There may be some reorganization of code that is
> > possible for many of these than coccinelle may
> > not perform well though.
> 
> As what looks like an extreme example, wouldn't this function be better as
> just return inet6_register_protosw(&rawv6_protosw); ?
> 
> int __init rawv6_init(void)
> {
> int ret;
> 
> ret = inet6_register_protosw(&rawv6_protosw);
> if (ret)
> goto out;
> out:
> return ret;
> }

That style is exactly what I was thinking about.

Yes, I think this would indeed be much better as a
single line and might have been better still removed
altogether but for the rawv6_protosw hiding.

There are a couple others just like it in net/


___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [oss-security] Re: [PATCH v2 4/4] ozwpan: unchecked signed subtraction leads to DoS

2015-05-28 Thread Greg Kroah-Hartman
On Thu, May 28, 2015 at 05:37:59PM +0200, Jason A. Donenfeld wrote:
> On Thu, May 28, 2015 at 1:04 PM, Dan Carpenter  
> wrote:
> > It's really not simpler to understand though.
> 
> Greg - do you want me to resubmit a v3 for this, or does it not really
> matter and we can address this in another series? Personally, I'm
> erring on the side of wanting to get *something* merged sooner, rather
> than doing a v3.

I'd prefer to get it right, there is no rush, these are staging drivers
that no distro enables by default.  Staging drivers are known to be full
of all sorts of crap, including issues like this, that's why they are in
the staging directory.

thanks,

greg k-h
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: gs_fpgaboot: remove redundant code

2015-05-28 Thread insop.s...@gainspeed.com
On Thu, May 28, 2015 at 01:08:36PM +0300, Dan Carpenter wrote:
> On Thu, May 28, 2015 at 09:38:23AM +, Gujulan Elango, Hari Prasath (H.) 
> wrote:
> > remove redundant code in this function by introducing a new retval
> > variable.
> > 
> > Signed-off-by: Gujulan Elango Hari Prasath 
> 
> No the original code is quite bad but this patch makes it worse.

Please elaborate what was 'quite bad' in the original code?

Regards,
ISS

> 
> gs_release_image() can't fail, and it should be a void function.
> 
> > ---
> >  drivers/staging/gs_fpgaboot/gs_fpgaboot.c | 18 --
> >  1 file changed, 8 insertions(+), 10 deletions(-)
> > 
> > diff --git a/drivers/staging/gs_fpgaboot/gs_fpgaboot.c 
> > b/drivers/staging/gs_fpgaboot/gs_fpgaboot.c
> > index a3a10f9..cc0445c 100644
> > --- a/drivers/staging/gs_fpgaboot/gs_fpgaboot.c
> > +++ b/drivers/staging/gs_fpgaboot/gs_fpgaboot.c
> > @@ -290,6 +290,7 @@ static int gs_fpgaboot(void)
> >  {
> > int err;
> > struct fpgaimage*fimage;
> > +   int retval = 0;
> >  
> > fimage = kmalloc(sizeof(struct fpgaimage), GFP_KERNEL);
> > if (!fimage)
> > @@ -298,44 +299,41 @@ static int gs_fpgaboot(void)
> > err = gs_load_image(fimage, file);
> > if (err) {
> 
>   goto free_fimage;
> 
> > pr_err("gs_load_image error\n");
> > +   retval = -1;
> > goto err_out1;
> > }
> >  
> > err = gs_read_image(fimage);
> > if (err) {
> 
> 
>   goto release_image;
> 
> > pr_err("gs_read_image error\n");
> > +   retval = -1;
> > goto err_out2;
> > }
> >  
> > err = gs_set_download_method(fimage);
> > if (err) {
> 
>   goto release_image;
> 
> > pr_err("gs_set_download_method error\n");
> > +   retval = -1;
> > goto err_out2;
> > }
> >  
> > err = gs_download_image(fimage, bus_2byte);
> 
> 
> release_image:
>   gs_release_image(fimage);
> free_fimage:
>   kfree(fimage);
> 
>   return err;
> 
> regards,
> dan carpenter
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: gs_fpgaboot: remove redundant code

2015-05-28 Thread Dan Carpenter
On Thu, May 28, 2015 at 09:39:14AM -0700, insop.s...@gainspeed.com wrote:
> On Thu, May 28, 2015 at 01:08:36PM +0300, Dan Carpenter wrote:
> > On Thu, May 28, 2015 at 09:38:23AM +, Gujulan Elango, Hari Prasath (H.) 
> > wrote:
> > > remove redundant code in this function by introducing a new retval
> > > variable.
> > > 
> > > Signed-off-by: Gujulan Elango Hari Prasath 
> > 
> > No the original code is quite bad but this patch makes it worse.
> 
> Please elaborate what was 'quite bad' in the original code?

GW-BASIC labels.
return -1 instead of proper error codes.
poorly thought out error messages.
The error handling of gs_release_image() was silly.

regards,
dan carpenter

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: gs_fpgaboot: remove redundant code

2015-05-28 Thread insop.s...@gainspeed.com
On Thu, May 28, 2015 at 09:50:23PM +0300, Dan Carpenter wrote:
> On Thu, May 28, 2015 at 09:39:14AM -0700, insop.s...@gainspeed.com wrote:
> > On Thu, May 28, 2015 at 01:08:36PM +0300, Dan Carpenter wrote:
> > > On Thu, May 28, 2015 at 09:38:23AM +, Gujulan Elango, Hari Prasath 
> > > (H.) wrote:
> > > > remove redundant code in this function by introducing a new retval
> > > > variable.
> > > > 
> > > > Signed-off-by: Gujulan Elango Hari Prasath 
> > > 
> > > No the original code is quite bad but this patch makes it worse.
> > 
> > Please elaborate what was 'quite bad' in the original code?
> 
> GW-BASIC labels.
what do you mean?

> return -1 instead of proper error codes.
Okay,

> poorly thought out error messages.
which one are you exactly refering?
I went through all error messages, but cannot find which one(s) you exactly 
mean.

> The error handling of gs_release_image() was silly.
I would say, ""The error handling of gs_release_image() was "unnecessary"""
instead.

So your feedback is mostly on error code and error messages
Thank you for your feedback.

Regards,

ISS
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH REPOST] staging: xgifb: use arch_phys_wc_add() and ioremap_wc()

2015-05-28 Thread Luis R. Rodriguez
From: "Luis R. Rodriguez" 

The same area used for ioremap() is used for the MTRR area.
Convert the driver from using the x86 specific MTRR code to
the architecture agnostic arch_phys_wc_add(). arch_phys_wc_add()
will avoid MTRR if write-combining is available, in order to
take advantage of that also ensure the ioremap'd area is requested
as write-combining.

There are a few motivations for this:

a) Take advantage of PAT when available

b) Help bury MTRR code away, MTRR is architecture specific and on
   x86 its replaced by PAT

c) Help with the goal of eventually using _PAGE_CACHE_UC over
   _PAGE_CACHE_UC_MINUS on x86 on ioremap_nocache() (see commit
   de33c442e titled "x86 PAT: fix performance drop for glx,
   use UC minus for ioremap(), ioremap_nocache() and
   pci_mmap_page_range()")

The conversion done is expressed by the following Coccinelle
SmPL patch, it additionally required manual intervention to
address all the #ifdery and removal of redundant things which
arch_phys_wc_add() already addresses such as verbose message
about when MTRR fails and doing nothing when we didn't get
an MTRR.

@ mtrr_found @
expression index, base, size;
@@

-index = mtrr_add(base, size, MTRR_TYPE_WRCOMB, 1);
+index = arch_phys_wc_add(base, size);

@ mtrr_rm depends on mtrr_found @
expression mtrr_found.index, mtrr_found.base, mtrr_found.size;
@@

-mtrr_del(index, base, size);
+arch_phys_wc_del(index);

@ mtrr_rm_zero_arg depends on mtrr_found @
expression mtrr_found.index;
@@

-mtrr_del(index, 0, 0);
+arch_phys_wc_del(index);

@ mtrr_rm_fb_info depends on mtrr_found @
struct fb_info *info;
expression mtrr_found.index;
@@

-mtrr_del(index, info->fix.smem_start, info->fix.smem_len);
+arch_phys_wc_del(index);

@ ioremap_replace_nocache depends on mtrr_found @
struct fb_info *info;
expression base, size;
@@

-info->screen_base = ioremap_nocache(base, size);
+info->screen_base = ioremap_wc(base, size);

@ ioremap_replace_default depends on mtrr_found @
struct fb_info *info;
expression base, size;
@@

-info->screen_base = ioremap(base, size);
+info->screen_base = ioremap_wc(base, size);

Generated-by: Coccinelle SmPL
Cc: Arnaud Patard 
Cc: Greg Kroah-Hartman 
Cc: Aaro Koskinen 
Cc: Brian Vandre 
Cc: Thomas Gummerer 
Cc: Aya Mahfouz 
Cc: Lubomir Rintel 
Cc: Vitor Braga 
Cc: Sudip Mukherjee 
Cc: Suresh Siddha 
Cc: Ingo Molnar 
Cc: Thomas Gleixner 
Cc: Juergen Gross 
Cc: Daniel Vetter 
Cc: Andy Lutomirski 
Cc: Dave Airlie 
Cc: Antonino Daplas 
Cc: Jean-Christophe Plagniol-Villard 
Cc: Tomi Valkeinen 
Cc: de...@driverdev.osuosl.org
Cc: linux-fb...@vger.kernel.org
Cc: linux-ker...@vger.kernel.org
Signed-off-by: Luis R. Rodriguez 
---

Greg, this is a respost from my March 20th submission which seems
to have fallen through the cracks likely due to me not directing it
to you. Apologies for that. This repost goes unchanged and is rebased
on top of linux-next next-20150528.

 drivers/staging/xgifb/XGI_main_26.c | 27 ++-
 1 file changed, 6 insertions(+), 21 deletions(-)

diff --git a/drivers/staging/xgifb/XGI_main_26.c 
b/drivers/staging/xgifb/XGI_main_26.c
index 74e8820..943d463 100644
--- a/drivers/staging/xgifb/XGI_main_26.c
+++ b/drivers/staging/xgifb/XGI_main_26.c
@@ -8,10 +8,7 @@
 
 #include 
 #include 
-
-#ifdef CONFIG_MTRR
-#include 
-#endif
+#include 
 
 #include "XGI_main.h"
 #include "vb_init.h"
@@ -1770,7 +1767,7 @@ static int xgifb_probe(struct pci_dev *pdev,
}
 
xgifb_info->video_vbase = hw_info->pjVideoMemoryAddress =
-   ioremap(xgifb_info->video_base, xgifb_info->video_size);
+   ioremap_wc(xgifb_info->video_base, xgifb_info->video_size);
xgifb_info->mmio_vbase = ioremap(xgifb_info->mmio_base,
xgifb_info->mmio_size);
 
@@ -2014,12 +2011,8 @@ static int xgifb_probe(struct pci_dev *pdev,
 
fb_alloc_cmap(&fb_info->cmap, 256, 0);
 
-#ifdef CONFIG_MTRR
-   xgifb_info->mtrr = mtrr_add(xgifb_info->video_base,
-   xgifb_info->video_size, MTRR_TYPE_WRCOMB, 1);
-   if (xgifb_info->mtrr >= 0)
-   dev_info(&pdev->dev, "Added MTRR\n");
-#endif
+   xgifb_info->mtrr = arch_phys_wc_add(xgifb_info->video_base,
+   xgifb_info->video_size);
 
if (register_framebuffer(fb_info) < 0) {
ret = -EINVAL;
@@ -2031,11 +2024,7 @@ static int xgifb_probe(struct pci_dev *pdev,
return 0;
 
 error_mtrr:
-#ifdef CONFIG_MTRR
-   if (xgifb_info->mtrr >= 0)
-   mtrr_del(xgifb_info->mtrr, xgifb_info->video_base,
-   xgifb_info->video_size);
-#endif /* CONFIG_MTRR */
+   arch_phys_wc_del(xgifb_info->mtrr);
 error_1:
iounmap(xgifb_info->mmio_vbase);
iounmap(xgifb_info->video_vbase);
@@ -2059,11 +2048,7 @@ stati

[PATCH] staging: wilc1000 dead code removal

2015-05-28 Thread Arnd Bergmann
Subject: [PATCH] staging: wilc1000 dead code removal

After finding some build errors in wilc1000, I played some more with
the driver and eliminated a lot of unused code. This is all code
meant for OS abstraction. Since we know we are running Linux,
and which version we use, it can all be removed.

Some minor changes are included that are necessary to remove
other code.

Signed-off-by: Arnd Bergmann 

diff --git a/drivers/staging/wilc1000/Makefile 
b/drivers/staging/wilc1000/Makefile
index 84bd975ff3be..4eda4cc69486 100644
--- a/drivers/staging/wilc1000/Makefile
+++ b/drivers/staging/wilc1000/Makefile
@@ -10,11 +10,10 @@ ccflags-y += -DSTA_FIRMWARE=\"atmel/wilc1000_fw.bin\" \
-DAP_FIRMWARE=\"atmel/wilc1000_ap_fw.bin\" \
-DP2P_CONCURRENCY_FIRMWARE=\"atmel/wilc1000_p2p_fw.bin\"
 
-ccflags-y += -I$(src)/ -DEXPORT_SYMTAB  -D__CHECK_ENDIAN__ -DWILC_ASIC_A0 \
+ccflags-y += -I$(src)/ -D__CHECK_ENDIAN__ -DWILC_ASIC_A0 \
-DPLL_WORKAROUND -DCONNECT_DIRECT  -DAGING_ALG \
-DWILC_PARSE_SCAN_IN_HOST -DDISABLE_PWRSAVE_AND_SCAN_DURING_IP \
-   -DWILC_PLATFORM=WILC_LINUXKERNEL -Wno-unused-function 
-DUSE_WIRELESS \
-   -DWILC_DEBUGFS
+   -Wno-unused-function -DUSE_WIRELESS -DWILC_DEBUGFS
 #ccflags-y += -DTCP_ACK_FILTER
 
 ccflags-$(CONFIG_WILC1000_PREALLOCATE_DURING_SYSTEM_BOOT) += -DMEMORY_STATIC \
@@ -28,14 +27,8 @@ ccflags-$(CONFIG_WILC1000_DYNAMICALLY_ALLOCATE_MEMROY) += 
-DWILC_NORMAL_ALLOC
 
 wilc1000-objs := wilc_wfi_netdevice.o wilc_wfi_cfgoperations.o linux_wlan.o 
linux_mon.o \
wilc_memory.o wilc_msgqueue.o wilc_semaphore.o 
wilc_sleep.o wilc_strutils.o \
-   wilc_thread.o wilc_time.o wilc_timer.o 
coreconfigurator.o host_interface.o \
+   wilc_time.o wilc_timer.o coreconfigurator.o 
host_interface.o \
fifo_buffer.o wilc_sdio.o wilc_spi.o wilc_wlan_cfg.o 
wilc_debugfs.o
 
 wilc1000-$(CONFIG_WILC1000_SDIO) += linux_wlan_sdio.o
 wilc1000-$(CONFIG_WILC1000_SPI) += linux_wlan_spi.o
-
-WILC1000_SRC_VERSION = 10.0
-PATCHLEVEL = 2
-WILC1000_FW_VERSION = 0
-
-ccflags-y += -D__DRIVER_VERSION__=\"$(WILC1000_SRC_VERSION).$(PATCHLEVEL)\"
diff --git a/drivers/staging/wilc1000/coreconfigurator.c 
b/drivers/staging/wilc1000/coreconfigurator.c
index 01625bdda454..d5a076ed2426 100644
--- a/drivers/staging/wilc1000/coreconfigurator.c
+++ b/drivers/staging/wilc1000/coreconfigurator.c
@@ -2123,7 +2123,6 @@ WILC_Sint32 CoreConfiguratorDeInit(void)
 
 
 #ifndef SIMULATION
-#if WILC_PLATFORM != WILC_WIN32
 /*Using the global handle of the driver*/
 extern wilc_wlan_oup_t *gpstrWlanOps;
 /**
@@ -2198,4 +2197,3 @@ WILC_Sint32 SendConfigPkt(WILC_Uint8 u8Mode, tstrWID 
*pstrWIDs,
return ret;
 }
 #endif
-#endif
diff --git a/drivers/staging/wilc1000/host_interface.c 
b/drivers/staging/wilc1000/host_interface.c
index fcbadd1885de..7c764a2ba573 100644
--- a/drivers/staging/wilc1000/host_interface.c
+++ b/drivers/staging/wilc1000/host_interface.c
@@ -543,7 +543,7 @@ tstrWILC_WFIDrv *gWFiDrvHandle = WILC_NULL;
 WILC_Bool g_obtainingIP = WILC_FALSE;
 #endif
 WILC_Uint8 P2P_LISTEN_STATE;
-static WILC_ThreadHandle HostIFthreadHandler;
+static struct task_struct *HostIFthreadHandler;
 static WILC_MsgQueueHandle gMsgQHostIF;
 static WILC_SemaphoreHandle hSemHostIFthrdEnd;
 
@@ -4370,7 +4370,7 @@ static WILC_Sint32 Handle_DelAllRxBASessions(void 
*drvHandler, tstrHostIfBASessi
  *  @date
  *  @version   1.0
  */
-static void hostIFthread(void *pvArg)
+static int hostIFthread(void *pvArg)
 {
WILC_Uint32 u32Ret;
tstrHostIFmsg strHostIFmsg;
@@ -4591,10 +4591,7 @@ static void hostIFthread(void *pvArg)
 
PRINT_D(HOSTINF_DBG, "Releasing thread exit semaphore\n");
WILC_SemaphoreRelease(&hSemHostIFthrdEnd, WILC_NULL);
-   return;
-   /* do_exit(error); */
-   /* PRINT_D(HOSTINF_DBG,"do_exit error code %d\n",error); */
-
+   return 0;
 }
 
 static void TimerCB_Scan(void *pvArg)
@@ -6683,9 +6680,10 @@ WILC_Sint32 host_int_init(WILC_WFIDrvHandle *phWFIDrv)
goto _fail_;
}
msgQ_created = 1;
-   s32Error = WILC_ThreadCreate(&HostIFthreadHandler, 
hostIFthread, WILC_NULL, WILC_NULL);
-   if (s32Error < 0) {
+   HostIFthreadHandler = kthread_run(hostIFthread, NULL, 
"WILC_kthread");
+   if (IS_ERR(HostIFthreadHandler)) {
PRINT_ER("Failed to creat Thread\n");
+   s32Error = WILC_FAIL;
goto _fail_mq_;
}
s32Error = WILC_TimerCreate(&(g_hPeriodicRSSI), 
GetPeriodicRSSI, WILC_NULL);
@@ -6788,7 +6786,7 @@ _fail_timer_2:
 _fail_timer_1:
WILC_TimerDestroy(&(pstrWFIDrv->hScanTimer), WILC_NULL);
 _fail_thread_:
-   WILC_ThreadDestroy(&HostIFthreadHandler, WILC_NULL);
+   kthread_stop(HostIFthreadHandler);
 _fail_mq_:

[PATCH 1/1] hv_netvsc: Allocate the receive buffer from the correct NUMA node

2015-05-28 Thread K. Y. Srinivasan
Allocate the receive bufer from the NUMA node assigned to the primary
channel.

Signed-off-by: K. Y. Srinivasan 
---
 drivers/net/hyperv/netvsc.c |7 ++-
 1 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/drivers/net/hyperv/netvsc.c b/drivers/net/hyperv/netvsc.c
index b024968..d187965 100644
--- a/drivers/net/hyperv/netvsc.c
+++ b/drivers/net/hyperv/netvsc.c
@@ -227,13 +227,18 @@ static int netvsc_init_buf(struct hv_device *device)
struct netvsc_device *net_device;
struct nvsp_message *init_packet;
struct net_device *ndev;
+   int node;
 
net_device = get_outbound_net_device(device);
if (!net_device)
return -ENODEV;
ndev = net_device->ndev;
 
-   net_device->recv_buf = vzalloc(net_device->recv_buf_size);
+   node = cpu_to_node(device->channel->target_cpu);
+   net_device->recv_buf = vzalloc_node(net_device->recv_buf_size, node);
+   if (!net_device->recv_buf)
+   net_device->recv_buf = vzalloc(net_device->recv_buf_size);
+
if (!net_device->recv_buf) {
netdev_err(ndev, "unable to allocate receive "
"buffer of size %d\n", net_device->recv_buf_size);
-- 
1.7.4.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: wilc1000 dead code removal

2015-05-28 Thread Greg KH
On Thu, May 28, 2015 at 10:23:35PM +0200, Arnd Bergmann wrote:
> Subject: [PATCH] staging: wilc1000 dead code removal
> 
> After finding some build errors in wilc1000, I played some more with
> the driver and eliminated a lot of unused code. This is all code
> meant for OS abstraction. Since we know we are running Linux,
> and which version we use, it can all be removed.
> 
> Some minor changes are included that are necessary to remove
> other code.

That's a lot of things all in one patch, I can't really review this.
Any chance you can break it out into logical pieces that I can review?

thanks,

greg k-h
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 0/9] drop unneeded goto

2015-05-28 Thread Julia Lawall
These patches drop gotos that jump to a label that is at the next
instruction, in the case that the label is not used elsewhere in the
function.  The complete semantic patch that performs this transformation is
as follows:

// 
@r@
position p;
identifier l;
@@

if (...) goto l@p;
l:

@script:ocaml s@
p << r.p;
nm;
@@

nm := (List.hd p).current_element

@ok exists@
identifier s.nm,l;
position p != r.p;
@@

nm(...) {
<+... goto l@p; ...+>
}

@depends on !ok@
identifier s.nm;
position r.p;
identifier l;
@@

nm(...) {
<...
- if(...) goto l@p; l:
...>
}
// 

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 8/9] staging/lustre/mdc: drop unneeded goto

2015-05-28 Thread Julia Lawall
From: Julia Lawall 

Delete jump to a label on the next line, when that label is not
used elsewhere.

A simplified version of the semantic patch that makes this change is as
follows: (http://coccinelle.lip6.fr/)

// 
@r@
identifier l;
@@

-if (...) goto l;
-l:
// 

Signed-off-by: Julia Lawall 

---
 drivers/staging/lustre/lustre/mdc/mdc_request.c |3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/staging/lustre/lustre/mdc/mdc_request.c 
b/drivers/staging/lustre/lustre/mdc/mdc_request.c
index cbbdfce..0f120f2 100644
--- a/drivers/staging/lustre/lustre/mdc/mdc_request.c
+++ b/drivers/staging/lustre/lustre/mdc/mdc_request.c
@@ -1818,10 +1818,7 @@ static int mdc_ioc_swap_layouts(struct obd_export *exp,
ptlrpc_request_set_replen(req);
 
rc = ptlrpc_queue_wait(req);
-   if (rc)
-   goto out;
 
-out:
ptlrpc_req_finished(req);
return rc;
 }

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: ft1000: warning removal: extern functions to static ones

2015-05-28 Thread Xavier Roche

Hi Greg & mailing-list members,

On Thu, 28 May 2015, Greg KH wrote:

In the future, always use scripts/get_maintainer.pl to determine who to
send patches to please.


Sorry, I did use the get_maintainer.pl script, but I did not want to 
bother too many people, and I only picked Marek in CC: (I also did not 
include commit_signer/authored emails)


I also did not include triv...@kernel.org  this time - wasn't sure is this 
was "trivial enough".


Thanks for the feedback! (and sorry for the direct reply - did not 
intended to be rude)


Xavier

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


RE: [PATCH 1/1] hv_netvsc: Allocate the receive buffer from the correct NUMA node

2015-05-28 Thread KY Srinivasan


> -Original Message-
> From: K. Y. Srinivasan [mailto:k...@microsoft.com]
> Sent: Thursday, May 28, 2015 2:56 PM
> To: da...@davemloft.net; net...@vger.kernel.org; linux-
> ker...@vger.kernel.org; de...@linuxdriverproject.org; o...@aepfle.de;
> a...@canonical.com; jasow...@redhat.com
> Cc: KY Srinivasan
> Subject: [PATCH 1/1] hv_netvsc: Allocate the receive buffer from the correct
> NUMA node
> 
> Allocate the receive bufer from the NUMA node assigned to the primary
> channel.
> 
> Signed-off-by: K. Y. Srinivasan 
> ---
>  drivers/net/hyperv/netvsc.c |7 ++-
>  1 files changed, 6 insertions(+), 1 deletions(-)
> 
> diff --git a/drivers/net/hyperv/netvsc.c b/drivers/net/hyperv/netvsc.c
> index b024968..d187965 100644
> --- a/drivers/net/hyperv/netvsc.c
> +++ b/drivers/net/hyperv/netvsc.c
> @@ -227,13 +227,18 @@ static int netvsc_init_buf(struct hv_device *device)
>   struct netvsc_device *net_device;
>   struct nvsp_message *init_packet;
>   struct net_device *ndev;
> + int node;
> 
>   net_device = get_outbound_net_device(device);
>   if (!net_device)
>   return -ENODEV;
>   ndev = net_device->ndev;
> 
> - net_device->recv_buf = vzalloc(net_device->recv_buf_size);
> + node = cpu_to_node(device->channel->target_cpu);
> + net_device->recv_buf = vzalloc_node(net_device->recv_buf_size,
> node);
> + if (!net_device->recv_buf)
> + net_device->recv_buf = vzalloc(net_device->recv_buf_size);
> +
>   if (!net_device->recv_buf) {
>   netdev_err(ndev, "unable to allocate receive "
>   "buffer of size %d\n", net_device->recv_buf_size);
> --
> 1.7.4.1

David,

Please drop this patch; I am going to resend this with another patch.

Regards,

K. Y
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH net-next 0/2] hv_netvsc: Implement NUMA aware memory allocation

2015-05-28 Thread K. Y. Srinivasan
Allocate both receive buffer and send buffer from the NUMA node assigned to the
primary channel.

K. Y. Srinivasan (2):
  hv_netvsc: Allocate the receive buffer from the correct NUMA node
  hv_netvsc: Allocate the sendbuf in a NUMA aware way

 drivers/net/hyperv/netvsc.c |   11 +--
 1 files changed, 9 insertions(+), 2 deletions(-)

-- 
1.7.4.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH V2 net-next 1/2] hv_netvsc: Allocate the receive buffer from the correct NUMA node

2015-05-28 Thread K. Y. Srinivasan
Allocate the receive bufer from the NUMA node assigned to the primary
channel.

Signed-off-by: K. Y. Srinivasan 
---
V2: Specify the tree for this patch.

 drivers/net/hyperv/netvsc.c |7 ++-
 1 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/drivers/net/hyperv/netvsc.c b/drivers/net/hyperv/netvsc.c
index b024968..d187965 100644
--- a/drivers/net/hyperv/netvsc.c
+++ b/drivers/net/hyperv/netvsc.c
@@ -227,13 +227,18 @@ static int netvsc_init_buf(struct hv_device *device)
struct netvsc_device *net_device;
struct nvsp_message *init_packet;
struct net_device *ndev;
+   int node;
 
net_device = get_outbound_net_device(device);
if (!net_device)
return -ENODEV;
ndev = net_device->ndev;
 
-   net_device->recv_buf = vzalloc(net_device->recv_buf_size);
+   node = cpu_to_node(device->channel->target_cpu);
+   net_device->recv_buf = vzalloc_node(net_device->recv_buf_size, node);
+   if (!net_device->recv_buf)
+   net_device->recv_buf = vzalloc(net_device->recv_buf_size);
+
if (!net_device->recv_buf) {
netdev_err(ndev, "unable to allocate receive "
"buffer of size %d\n", net_device->recv_buf_size);
-- 
1.7.4.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH net-next 2/2] hv_netvsc: Allocate the sendbuf in a NUMA aware way

2015-05-28 Thread K. Y. Srinivasan
Allocate the send buffer in a NUMA aware way.

Signed-off-by: K. Y. Srinivasan 
---
 drivers/net/hyperv/netvsc.c |4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/drivers/net/hyperv/netvsc.c b/drivers/net/hyperv/netvsc.c
index d187965..06de98a 100644
--- a/drivers/net/hyperv/netvsc.c
+++ b/drivers/net/hyperv/netvsc.c
@@ -326,7 +326,9 @@ static int netvsc_init_buf(struct hv_device *device)
 
/* Now setup the send buffer.
 */
-   net_device->send_buf = vzalloc(net_device->send_buf_size);
+   net_device->send_buf = vzalloc_node(net_device->send_buf_size, node);
+   if (!net_device->send_buf)
+   net_device->send_buf = vzalloc(net_device->send_buf_size);
if (!net_device->send_buf) {
netdev_err(ndev, "unable to allocate send "
   "buffer of size %d\n", net_device->send_buf_size);
-- 
1.7.4.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 09/13] android: binder: add function for finding prior thread in transaction stack

2015-05-28 Thread Riley Andrews
Add a helper function to find a thread within a transaction stack.

Signed-off-by: Riley Andrews 
---
 drivers/android/binder.c | 23 +++
 1 file changed, 15 insertions(+), 8 deletions(-)

diff --git a/drivers/android/binder.c b/drivers/android/binder.c
index f7f2217..abd5556 100644
--- a/drivers/android/binder.c
+++ b/drivers/android/binder.c
@@ -1634,6 +1634,19 @@ static int binder_tr_validate_stack(struct binder_thread 
*thread)
return BR_OK;
 }
 
+struct binder_thread *binder_find_used_thread(struct binder_proc *proc,
+ struct binder_transaction *stack)
+{
+   struct binder_transaction *tr = stack;
+
+   while (tr) {
+   if (tr->from && tr->from->proc == proc)
+   return tr->from;
+   tr = tr->from_parent;
+   }
+   return NULL;
+}
+
 static void binder_transaction(struct binder_thread *thread,
   struct binder_transaction_data *tr, int reply)
 {
@@ -1688,18 +1701,12 @@ static void binder_transaction(struct binder_thread 
*thread,
goto err_invalid_target_handle;
}
if (!(tr->flags & TF_ONE_WAY) && thread->transaction_stack) {
-   struct binder_transaction *tmp;
-
return_error = binder_tr_validate_stack(thread);
if (return_error != BR_OK)
goto err_bad_call_stack;
 
-   tmp = thread->transaction_stack;
-   while (tmp) {
-   if (tmp->from && tmp->from->proc == target_proc)
-   target_thread = tmp->from;
-   tmp = tmp->from_parent;
-   }
+   target_thread = binder_find_used_thread(target_proc,
+   thread->transaction_stack);
}
}
if (target_thread) {
-- 
2.2.0.rc0.207.ga3a616c

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 08/13] android: binder: add function for logging failed transactions

2015-05-28 Thread Riley Andrews
Add another helper function that adds log entries to failed log.

Signed-off-by: Riley Andrews 
---
 drivers/android/binder.c | 18 +++---
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/drivers/android/binder.c b/drivers/android/binder.c
index ed94121..f7f2217 100644
--- a/drivers/android/binder.c
+++ b/drivers/android/binder.c
@@ -211,6 +211,16 @@ static struct binder_transaction_log_entry 
*binder_transaction_log_add(
return e;
 }
 
+static void binder_transaction_log_add_copy(
+   struct binder_transaction_log *log,
+   struct binder_transaction_log_entry *entry)
+{
+   struct binder_transaction_log_entry *failed;
+
+   failed = binder_transaction_log_add(log);
+   *failed = *entry;
+}
+
 struct binder_work {
struct list_head entry;
enum {
@@ -1827,13 +1837,7 @@ err_invalid_target_handle:
 proc->pid, thread->pid, return_error,
 (u64)tr->data_size, (u64)tr->offsets_size);
 
-   {
-   struct binder_transaction_log_entry *fe;
-
-   fe = binder_transaction_log_add(&binder_transaction_log_failed);
-   *fe = *e;
-   }
-
+   binder_transaction_log_add_copy(&binder_transaction_log_failed, e);
BUG_ON(thread->return_error != BR_OK);
if (in_reply_to) {
thread->return_error = BR_TRANSACTION_COMPLETE;
-- 
2.2.0.rc0.207.ga3a616c

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 06/13] android: binder: add function to find target binder node

2015-05-28 Thread Riley Andrews
Pull the logic that determines the target_node of a transaction into a
dedicated function.

Signed-off-by: Riley Andrews 
---
 drivers/android/binder.c | 46 +++---
 1 file changed, 27 insertions(+), 19 deletions(-)

diff --git a/drivers/android/binder.c b/drivers/android/binder.c
index 407c1ee..99a3270 100644
--- a/drivers/android/binder.c
+++ b/drivers/android/binder.c
@@ -1536,6 +1536,29 @@ error:
return result;
 }
 
+static int binder_get_tr_target_node(struct binder_thread *thread,
+struct binder_transaction_data *tr,
+struct binder_node **target_node)
+{
+   struct binder_proc *proc = thread->proc;
+   struct binder_ref *ref;
+
+   if (tr->target.handle) {
+   ref = binder_get_ref(proc, tr->target.handle);
+   if (!ref) {
+   binder_user_error("%d:%d got transaction to invalid 
handle\n",
+ proc->pid, thread->pid);
+   return BR_FAILED_REPLY;
+   }
+   *target_node = ref->node;
+   } else {
+   *target_node = binder_context_mgr_node;
+   if (!(*target_node))
+   return BR_DEAD_REPLY;
+   }
+   return BR_OK;
+}
+
 static void binder_transaction(struct binder_thread *thread,
   struct binder_transaction_data *tr, int reply)
 {
@@ -1599,24 +1622,10 @@ static void binder_transaction(struct binder_thread 
*thread,
}
target_proc = target_thread->proc;
} else {
-   if (tr->target.handle) {
-   struct binder_ref *ref;
-
-   ref = binder_get_ref(proc, tr->target.handle);
-   if (ref == NULL) {
-   binder_user_error("%d:%d got transaction to 
invalid handle\n",
-   proc->pid, thread->pid);
-   return_error = BR_FAILED_REPLY;
-   goto err_invalid_target_handle;
-   }
-   target_node = ref->node;
-   } else {
-   target_node = binder_context_mgr_node;
-   if (target_node == NULL) {
-   return_error = BR_DEAD_REPLY;
-   goto err_no_context_mgr_node;
-   }
-   }
+   return_error = binder_get_tr_target_node(thread, tr,
+&target_node);
+   if (return_error != BR_OK)
+   goto err_invalid_target_handle;
e->to_node = target_node->debug_id;
target_proc = target_node->proc;
if (target_proc == NULL) {
@@ -1780,7 +1789,6 @@ err_bad_call_stack:
 err_empty_call_stack:
 err_dead_binder:
 err_invalid_target_handle:
-err_no_context_mgr_node:
binder_debug(BINDER_DEBUG_FAILED_TRANSACTION,
 "%d:%d transaction failed %d, size %lld-%lld\n",
 proc->pid, thread->pid, return_error,
-- 
2.2.0.rc0.207.ga3a616c

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 11/13] android: binder: add function to handle waiting for binder_thread_read

2015-05-28 Thread Riley Andrews
Add another helper function for binder_thread_read. All of the logic for
waiting for work to do has been pulled into this function.

Signed-off-by: Riley Andrews 
---
 drivers/android/binder.c | 104 ++-
 1 file changed, 66 insertions(+), 38 deletions(-)

diff --git a/drivers/android/binder.c b/drivers/android/binder.c
index b69ca0a..c98436c 100644
--- a/drivers/android/binder.c
+++ b/drivers/android/binder.c
@@ -2528,6 +2528,71 @@ static int binder_work_tr_complete(struct binder_thread 
*thread,
return 0;
 }
 
+static int binder_wait_for_thread_work(struct binder_thread *thread,
+  bool non_block)
+{
+   if (binder_has_thread_work(thread))
+   return 0;
+
+   if (non_block)
+   return -EAGAIN;
+
+   return wait_event_freezable(thread->wait,
+   binder_has_thread_work(thread));
+}
+
+static int binder_wait_for_proc_work(struct binder_thread *thread,
+bool non_block)
+{
+   struct binder_proc *proc = thread->proc;
+
+   if (!(thread->looper & (BINDER_LOOPER_STATE_REGISTERED |
+   BINDER_LOOPER_STATE_ENTERED))) {
+   binder_user_error("%d:%d ERROR: Thread waiting for process work 
before calling BC_REGISTER_LOOPER or BC_ENTER_LOOPER (state %x)\n",
+ proc->pid, thread->pid,
+ thread->looper);
+   wait_event_interruptible(binder_user_error_wait,
+binder_stop_on_user_error < 2);
+   }
+   binder_set_nice(proc->default_priority);
+
+   if (binder_has_proc_work(proc, thread))
+   return 0;
+
+   if (non_block)
+   return -EAGAIN;
+
+   return wait_event_freezable_exclusive(proc->wait,
+   binder_has_proc_work(proc, thread));
+}
+
+static int binder_wait_for_work(struct binder_thread *thread, int non_block,
+   int wait_for_proc_work)
+{
+   int ret;
+   struct binder_proc *proc = thread->proc;
+
+   trace_binder_wait_for_work(wait_for_proc_work,
+  !!thread->transaction_stack,
+  !list_empty(&thread->todo));
+   thread->looper |= BINDER_LOOPER_STATE_WAITING;
+   if (wait_for_proc_work)
+   proc->ready_threads++;
+
+   binder_unlock(__func__);
+   if (wait_for_proc_work)
+   ret = binder_wait_for_proc_work(thread, non_block);
+   else
+   ret = binder_wait_for_thread_work(thread, non_block);
+   binder_lock(__func__);
+
+   if (wait_for_proc_work)
+   proc->ready_threads--;
+   thread->looper &= ~BINDER_LOOPER_STATE_WAITING;
+
+   return ret;
+}
+
 static int binder_thread_read(struct binder_proc *proc,
  struct binder_thread *thread,
  binder_uintptr_t binder_buffer, size_t size,
@@ -2568,44 +2633,7 @@ retry:
goto done;
}
 
-
-   thread->looper |= BINDER_LOOPER_STATE_WAITING;
-   if (wait_for_proc_work)
-   proc->ready_threads++;
-
-   binder_unlock(__func__);
-
-   trace_binder_wait_for_work(wait_for_proc_work,
-  !!thread->transaction_stack,
-  !list_empty(&thread->todo));
-   if (wait_for_proc_work) {
-   if (!(thread->looper & (BINDER_LOOPER_STATE_REGISTERED |
-   BINDER_LOOPER_STATE_ENTERED))) {
-   binder_user_error("%d:%d ERROR: Thread waiting for 
process work before calling BC_REGISTER_LOOPER or BC_ENTER_LOOPER (state %x)\n",
-   proc->pid, thread->pid, thread->looper);
-   wait_event_interruptible(binder_user_error_wait,
-binder_stop_on_user_error < 2);
-   }
-   binder_set_nice(proc->default_priority);
-   if (non_block) {
-   if (!binder_has_proc_work(proc, thread))
-   ret = -EAGAIN;
-   } else
-   ret = wait_event_freezable_exclusive(proc->wait, 
binder_has_proc_work(proc, thread));
-   } else {
-   if (non_block) {
-   if (!binder_has_thread_work(thread))
-   ret = -EAGAIN;
-   } else
-   ret = wait_event_freezable(thread->wait, 
binder_has_thread_work(thread));
-   }
-
-   binder_lock(__func__);
-
-   if (wait_for_proc_work)
-   proc->ready_threads--;
-   thread->looper &= ~BINDER_LOOPER_STATE_WAITING;
-
+   ret = binder_wait_for_work(thread, non_block, wait_for_proc_work);
if (ret)
return ret;
 
-- 
2.2.0

[PATCH 03/13] android: binder: refactor binder_thread_write

2015-05-28 Thread Riley Andrews
Give every case in the switch statement its own dedicated function.
Remove the process argument to binder_transact, as it can be derived
from the thread argument as with all of the other newly created
functions.

Signed-off-by: Riley Andrews 
---
 drivers/android/binder.c | 613 +++
 1 file changed, 350 insertions(+), 263 deletions(-)

diff --git a/drivers/android/binder.c b/drivers/android/binder.c
index 2069759..e47c2d4 100644
--- a/drivers/android/binder.c
+++ b/drivers/android/binder.c
@@ -1314,8 +1314,7 @@ static void binder_transaction_buffer_release(struct 
binder_proc *proc,
}
 }
 
-static void binder_transaction(struct binder_proc *proc,
-  struct binder_thread *thread,
+static void binder_transaction(struct binder_thread *thread,
   struct binder_transaction_data *tr, int reply)
 {
struct binder_transaction *t;
@@ -1328,6 +1327,7 @@ static void binder_transaction(struct binder_proc *proc,
wait_queue_head_t *target_wait;
struct binder_transaction *in_reply_to = NULL;
struct binder_transaction_log_entry *e;
+   struct binder_proc *proc = thread->proc;
uint32_t return_error;
 
e = binder_transaction_log_add(&binder_transaction_log);
@@ -1752,10 +1752,329 @@ err_no_context_mgr_node:
thread->return_error = return_error;
 }
 
+static void binder_call_inc_dec_ref(struct binder_thread *thread,
+   uint32_t target, uint32_t cmd)
+{
+   struct binder_proc *proc = thread->proc;
+   struct binder_ref *ref;
+   const char *debug_string;
+
+   if (target == 0 && binder_context_mgr_node &&
+   (cmd == BC_INCREFS || cmd == BC_ACQUIRE)) {
+   ref = binder_get_ref_for_node(proc, binder_context_mgr_node);
+   if (ref->desc != target) {
+   binder_user_error("%d:%d tried to acquire reference to 
desc 0, got %d instead\n",
+ proc->pid, thread->pid, ref->desc);
+   return;
+   }
+   } else {
+   ref = binder_get_ref(proc, target);
+   }
+   if (!ref) {
+   binder_user_error("%d:%d refcount change on invalid ref %d\n",
+ proc->pid, thread->pid, target);
+   return;
+   }
+   switch (cmd) {
+   case BC_INCREFS:
+   debug_string = "IncRefs";
+   binder_inc_ref(ref, 0, NULL);
+   break;
+   case BC_ACQUIRE:
+   debug_string = "Acquire";
+   binder_inc_ref(ref, 1, NULL);
+   break;
+   case BC_RELEASE:
+   debug_string = "Release";
+   binder_dec_ref(ref, 1);
+   break;
+   case BC_DECREFS:
+   default:
+   debug_string = "DecRefs";
+   binder_dec_ref(ref, 0);
+   break;
+   }
+   binder_debug(BINDER_DEBUG_USER_REFS,
+"%d:%d %s ref %d desc %d s %d w %d for node %d\n",
+proc->pid, thread->pid, debug_string, ref->debug_id,
+ref->desc, ref->strong, ref->weak, ref->node->debug_id);
+}
+
+static void binder_call_inc_ref_done(struct binder_thread *thread,
+binder_uintptr_t node_ptr,
+binder_uintptr_t cookie, uint32_t cmd)
+{
+   struct binder_node *node;
+   struct binder_proc *proc = thread->proc;
+
+   node = binder_get_node(proc, node_ptr);
+   if (!node) {
+   binder_user_error("%d:%d %s u%016llx no match\n",
+ proc->pid, thread->pid,
+ cmd == BC_INCREFS_DONE ?
+ "BC_INCREFS_DONE" : "BC_ACQUIRE_DONE",
+ (u64)node_ptr);
+   return;
+   }
+   if (cookie != node->cookie) {
+   binder_user_error("%d:%d %s u%016llx node %d cookie mismatch 
%016llx != %016llx\n",
+ proc->pid, thread->pid,
+ cmd == BC_INCREFS_DONE ?
+ "BC_INCREFS_DONE" : "BC_ACQUIRE_DONE",
+ (u64)node_ptr, node->debug_id,
+ (u64)cookie, (u64)node->cookie);
+   return;
+   }
+   if (cmd == BC_ACQUIRE_DONE) {
+   if (node->pending_strong_ref == 0) {
+   binder_user_error("%d:%d BC_ACQUIRE_DONE node %d has no 
pending acquire request\n",
+ proc->pid, thread->pid,
+ node->debug_id);
+   return;
+   }
+   node->pending_strong_ref = 0;
+   } else {
+   if (node->pending_weak_ref == 0) {
+   binder

[PATCH 05/13] android: binder: refactor binder_transact transaction buffer loop

2015-05-28 Thread Riley Andrews
Pull the loop that translates the flat_binder_objects into a separate
function, binder_transaction_buffer_acquire.

Signed-off-by: Riley Andrews 
---
 drivers/android/binder.c | 128 ---
 1 file changed, 77 insertions(+), 51 deletions(-)

diff --git a/drivers/android/binder.c b/drivers/android/binder.c
index a9a160a..407c1ee 100644
--- a/drivers/android/binder.c
+++ b/drivers/android/binder.c
@@ -1464,12 +1464,84 @@ err_fd_not_accepted:
return BR_FAILED_REPLY;
 }
 
+static int binder_transaction_buffer_acquire(
+   struct binder_transaction *t, struct binder_transaction_data *tr,
+   struct binder_thread *thread, struct binder_transaction *in_reply_to)
+{
+   struct binder_proc *proc = thread->proc;
+   binder_size_t *offp, *off_end, off_min;
+   struct flat_binder_object *fp;
+   uint32_t result;
+
+   if (!IS_ALIGNED(tr->offsets_size, sizeof(binder_size_t))) {
+   binder_user_error("%d:%d got transaction with invalid offsets 
size, %lld\n",
+ proc->pid, thread->pid,
+ (u64)tr->offsets_size);
+   return BR_FAILED_REPLY;
+   }
+
+   if (t->buffer->target_node)
+   binder_inc_node(t->buffer->target_node, 1, 0, NULL);
+
+   off_min = 0;
+   offp = (binder_size_t *)(t->buffer->data +
+ALIGN(tr->data_size, sizeof(void *)));
+   off_end = (void *)offp + tr->offsets_size;
+   for (; offp < off_end; offp++) {
+   if (*offp > t->buffer->data_size - sizeof(*fp) ||
+   *offp < off_min ||
+   t->buffer->data_size < sizeof(*fp) ||
+   !IS_ALIGNED(*offp, sizeof(u32))) {
+   binder_user_error("%d:%d got transaction with invalid 
offset, %lld (min %lld, max %lld)\n",
+ proc->pid, thread->pid, (u64)*offp,
+ (u64)off_min,
+ (u64)(t->buffer->data_size -
+ sizeof(*fp)));
+   result = BR_FAILED_REPLY;
+   goto error;
+   }
+   fp = (struct flat_binder_object *)(t->buffer->data + *offp);
+   off_min = *offp + sizeof(struct flat_binder_object);
+   switch (fp->type) {
+   case BINDER_TYPE_BINDER:
+   case BINDER_TYPE_WEAK_BINDER:
+   result = binder_translate_object(fp, t, thread);
+   if (result != BR_OK)
+   goto error;
+   break;
+   case BINDER_TYPE_HANDLE:
+   case BINDER_TYPE_WEAK_HANDLE:
+   result = binder_translate_handle(fp, t, thread);
+   if (result != BR_OK)
+   goto error;
+   break;
+   case BINDER_TYPE_FD:
+   result = binder_translate_fd(fp, t, thread,
+in_reply_to);
+   if (result != BR_OK)
+   goto error;
+   break;
+   default:
+   binder_user_error("got transaction with invalid object 
type, %x\n",
+ fp->type);
+   result = BR_FAILED_REPLY;
+   goto error;
+   }
+   }
+   return BR_OK;
+
+error:
+   trace_binder_transaction_failed_buffer_release(t->buffer);
+   binder_transaction_buffer_release(t->to_proc, t->buffer, offp);
+   return result;
+}
+
 static void binder_transaction(struct binder_thread *thread,
   struct binder_transaction_data *tr, int reply)
 {
struct binder_transaction *t;
struct binder_work *tcomplete;
-   binder_size_t *offp, *off_end;
+   binder_size_t *offp;
struct binder_proc *target_proc;
struct binder_thread *target_thread = NULL;
struct binder_node *target_node = NULL;
@@ -1645,8 +1717,6 @@ static void binder_transaction(struct binder_thread 
*thread,
t->buffer->transaction = t;
t->buffer->target_node = target_node;
trace_binder_transaction_alloc_buf(t->buffer);
-   if (target_node)
-   binder_inc_node(target_node, 1, 0, NULL);
 
offp = (binder_size_t *)(t->buffer->data +
 ALIGN(tr->data_size, sizeof(void *)));
@@ -1665,51 +1735,11 @@ static void binder_transaction(struct binder_thread 
*thread,
return_error = BR_FAILED_REPLY;
goto err_copy_data_failed;
}
-   if (!IS_ALIGNED(tr->offsets_size, sizeof(binder_size_t))) {
-   binder_user_error("%d:%d got transaction with invalid offsets 
size, %lld\n",
- 

[PATCH 12/13] android: binder: add function to pass thread errors to userspace

2015-05-28 Thread Riley Andrews
Add a dedicated function for handling errors.

Signed-off-by: Riley Andrews 
---
 drivers/android/binder.c | 51 
 1 file changed, 34 insertions(+), 17 deletions(-)

diff --git a/drivers/android/binder.c b/drivers/android/binder.c
index c98436c..a3129d4 100644
--- a/drivers/android/binder.c
+++ b/drivers/android/binder.c
@@ -2593,6 +2593,35 @@ static int binder_wait_for_work(struct binder_thread 
*thread, int non_block,
return ret;
 }
 
+static int binder_handle_thread_error(struct binder_thread *thread,
+ void * __user *ptr, void __user *end)
+{
+   struct binder_proc *proc = thread->proc;
+
+   if (*ptr == end)
+   return 0;
+
+   if (thread->return_error2 != BR_OK) {
+   if (put_user(thread->return_error2, (uint32_t __user *)*ptr))
+   return -EFAULT;
+
+   *ptr += sizeof(uint32_t);
+   binder_stat_br(proc, thread, thread->return_error2);
+   thread->return_error2 = BR_OK;
+
+   if (*ptr == end)
+   return 0;
+   }
+
+   if (put_user(thread->return_error, (uint32_t __user *)*ptr))
+   return -EFAULT;
+
+   *ptr += sizeof(uint32_t);
+   binder_stat_br(proc, thread, thread->return_error);
+   thread->return_error = BR_OK;
+   return 0;
+}
+
 static int binder_thread_read(struct binder_proc *proc,
  struct binder_thread *thread,
  binder_uintptr_t binder_buffer, size_t size,
@@ -2613,23 +2642,11 @@ static int binder_thread_read(struct binder_proc *proc,
 
 retry:
wait_for_proc_work = thread->transaction_stack == NULL &&
-   list_empty(&thread->todo);
-
-   if (thread->return_error != BR_OK && ptr < end) {
-   if (thread->return_error2 != BR_OK) {
-   if (put_user(thread->return_error2, (uint32_t __user 
*)ptr))
-   return -EFAULT;
-   ptr += sizeof(uint32_t);
-   binder_stat_br(proc, thread, thread->return_error2);
-   thread->return_error2 = BR_OK;
-   if (ptr == end)
-   goto done;
-   }
-   if (put_user(thread->return_error, (uint32_t __user *)ptr))
-   return -EFAULT;
-   ptr += sizeof(uint32_t);
-   binder_stat_br(proc, thread, thread->return_error);
-   thread->return_error = BR_OK;
+list_empty(&thread->todo);
+   if (thread->return_error != BR_OK) {
+   ret =  binder_handle_thread_error(thread, &ptr, end);
+   if (ret < 0)
+   return ret;
goto done;
}
 
-- 
2.2.0.rc0.207.ga3a616c

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


  1   2   >