Re: [PATCH] staging/android/vsoc: Remove duplicate header

2019-01-14 Thread Souptick Joarder
On Wed, Jan 9, 2019 at 8:56 PM Brajeswar Ghosh
 wrote:
>
> Remove linux/mutex.h.h which is included more than once
>
> Signed-off-by: Brajeswar Ghosh 

Acked-by: Souptick Joarder 

> ---
>  drivers/staging/android/vsoc.c | 1 -
>  1 file changed, 1 deletion(-)
>
> diff --git a/drivers/staging/android/vsoc.c b/drivers/staging/android/vsoc.c
> index 22571abcaa4e..8a75bd27c413 100644
> --- a/drivers/staging/android/vsoc.c
> +++ b/drivers/staging/android/vsoc.c
> @@ -29,7 +29,6 @@
>  #include 
>  #include 
>  #include 
> -#include 
>  #include 
>  #include 
>  #include "uapi/vsoc_shm.h"
> --
> 2.17.1
>
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: rtl8188eu: Replace kzalloc with kcalloc

2019-01-14 Thread Gustavo A. R. Silva
Replace kzalloc() function with its 2-factor argument form, kcalloc().

This patch replaces cases of:

kzalloc(a * b, gfp)

with:
kcalloc(a, b, gfp)

This code was detected with the help of Coccinelle.

Signed-off-by: Gustavo A. R. Silva 
---
 drivers/staging/rtl8188eu/core/rtw_efuse.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/rtl8188eu/core/rtw_efuse.c 
b/drivers/staging/rtl8188eu/core/rtw_efuse.c
index b7be71f904ed..51c3dd6d7ffb 100644
--- a/drivers/staging/rtl8188eu/core/rtw_efuse.c
+++ b/drivers/staging/rtl8188eu/core/rtw_efuse.c
@@ -88,7 +88,9 @@ efuse_phymap_to_logical(u8 *phymap, u16 _offset, u16 
_size_byte, u8  *pbuf)
if (!efuseTbl)
return;
 
-   tmp = kzalloc(EFUSE_MAX_SECTION_88E * (sizeof(void *) + 
EFUSE_MAX_WORD_UNIT * sizeof(u16)), GFP_KERNEL);
+   tmp = kcalloc(EFUSE_MAX_SECTION_88E,
+ sizeof(void *) + EFUSE_MAX_WORD_UNIT * sizeof(u16),
+ GFP_KERNEL);
if (!tmp) {
DBG_88E("%s: alloc eFuseWord fail!\n", __func__);
goto eFuseWord_failed;
-- 
2.20.1

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


[PATCH v2] Staging: fbtft: Switch to the gpio descriptor interface

2019-01-14 Thread Nishad Kamdar
This switches the fbtft driver to use GPIO descriptors
rather than numerical gpios:

Utilize the GPIO library's intrinsic handling of OF GPIOs
and polarity. If the line is flagged active low, gpiolib
will deal with this.

Remove gpios from platform device structure. Neither assign
statically numbers to gpios in platform device nor allow
gpios to be parsed as module parameters.

Signed-off-by: Nishad Kamdar 
Changes in v2:
 - Merge all patches in a single patch. This is because the
   first patch changes par->gpio from an int to a pointer
   so all the checks have to be updated in the same patch.
   Otherwie it breaks 'git bisect'.
---
 drivers/staging/fbtft/fb_agm1264k-fl.c |  52 ++--
 drivers/staging/fbtft/fb_bd663474.c|   6 +-
 drivers/staging/fbtft/fb_ili9163.c |   6 +-
 drivers/staging/fbtft/fb_ili9320.c |   2 +-
 drivers/staging/fbtft/fb_ili9325.c |   6 +-
 drivers/staging/fbtft/fb_ili9340.c |   2 +-
 drivers/staging/fbtft/fb_pcd8544.c |   4 +-
 drivers/staging/fbtft/fb_ra8875.c  |   4 +-
 drivers/staging/fbtft/fb_s6d1121.c |   6 +-
 drivers/staging/fbtft/fb_sh1106.c  |   2 +-
 drivers/staging/fbtft/fb_ssd1289.c |   6 +-
 drivers/staging/fbtft/fb_ssd1305.c |   4 +-
 drivers/staging/fbtft/fb_ssd1306.c |   4 +-
 drivers/staging/fbtft/fb_ssd1325.c |   6 +-
 drivers/staging/fbtft/fb_ssd1331.c |  10 +-
 drivers/staging/fbtft/fb_ssd1351.c |   2 +-
 drivers/staging/fbtft/fb_tls8204.c |   6 +-
 drivers/staging/fbtft/fb_uc1611.c  |   4 +-
 drivers/staging/fbtft/fb_uc1701.c  |   6 +-
 drivers/staging/fbtft/fb_upd161704.c   |   6 +-
 drivers/staging/fbtft/fb_watterott.c   |   4 +-
 drivers/staging/fbtft/fbtft-bus.c  |   6 +-
 drivers/staging/fbtft/fbtft-core.c | 173 +++--
 drivers/staging/fbtft/fbtft-io.c   |  26 +-
 drivers/staging/fbtft/fbtft.h  |  21 +-
 drivers/staging/fbtft/fbtft_device.c   | 344 +
 drivers/staging/fbtft/flexfb.c |  12 +-
 27 files changed, 143 insertions(+), 587 deletions(-)

diff --git a/drivers/staging/fbtft/fb_agm1264k-fl.c 
b/drivers/staging/fbtft/fb_agm1264k-fl.c
index f6f30f5bf15a..8f27bd8da17d 100644
--- a/drivers/staging/fbtft/fb_agm1264k-fl.c
+++ b/drivers/staging/fbtft/fb_agm1264k-fl.c
@@ -8,7 +8,7 @@
 #include 
 #include 
 #include 
-#include 
+#include 
 #include 
 #include 
 
@@ -79,14 +79,14 @@ static int init_display(struct fbtft_par *par)
 
 static void reset(struct fbtft_par *par)
 {
-   if (par->gpio.reset == -1)
+   if (!par->gpio.reset)
return;
 
dev_dbg(par->info->device, "%s()\n", __func__);
 
-   gpio_set_value(par->gpio.reset, 0);
+   gpiod_set_value(par->gpio.reset, 0);
udelay(20);
-   gpio_set_value(par->gpio.reset, 1);
+   gpiod_set_value(par->gpio.reset, 1);
mdelay(120);
 }
 
@@ -98,30 +98,30 @@ static int verify_gpios(struct fbtft_par *par)
dev_dbg(par->info->device,
"%s()\n", __func__);
 
-   if (par->EPIN < 0) {
+   if (!par->EPIN) {
dev_err(par->info->device,
"Missing info about 'wr' (aka E) gpio. Aborting.\n");
return -EINVAL;
}
for (i = 0; i < 8; ++i) {
-   if (par->gpio.db[i] < 0) {
+   if (!par->gpio.db[i]) {
dev_err(par->info->device,
"Missing info about 'db[%i]' gpio. Aborting.\n",
i);
return -EINVAL;
}
}
-   if (par->CS0 < 0) {
+   if (!par->CS0) {
dev_err(par->info->device,
"Missing info about 'cs0' gpio. Aborting.\n");
return -EINVAL;
}
-   if (par->CS1 < 0) {
+   if (!par->CS1) {
dev_err(par->info->device,
"Missing info about 'cs1' gpio. Aborting.\n");
return -EINVAL;
}
-   if (par->RW < 0) {
+   if (!par->RW) {
dev_err(par->info->device,
"Missing info about 'rw' gpio. Aborting.\n");
return -EINVAL;
@@ -139,22 +139,22 @@ request_gpios_match(struct fbtft_par *par, const struct 
fbtft_gpio *gpio)
if (strcasecmp(gpio->name, "wr") == 0) {
/* left ks0108 E pin */
par->EPIN = gpio->gpio;
-   return GPIOF_OUT_INIT_LOW;
+   return GPIOD_OUT_LOW;
} else if (strcasecmp(gpio->name, "cs0") == 0) {
/* left ks0108 controller pin */
par->CS0 = gpio->gpio;
-   return GPIOF_OUT_INIT_HIGH;
+   return GPIOD_OUT_HIGH;
} else if (strcasecmp(gpio->name, "cs1") == 0) {
/* right ks0108 controller pin */
par->CS1 = gpio->gpio;
-   return GPIOF_OUT_INIT_HIGH;
+   return GPIOD_OUT_HIGH;
}
 
/* if write (rw = 0) 

[PATCH v2] Staging: fbtft: Switch to the gpio descriptor interface

2019-01-14 Thread Nishad Kamdar
This switches the fbtft driver to use GPIO descriptors
rather than numerical gpios:

Utilize the GPIO library's intrinsic handling of OF GPIOs
and polarity. If the line is flagged active low, gpiolib
will deal with this.

Remove gpios from platform device structure. Neither assign
statically numbers to gpios in platform device nor allow
gpios to be parsed as module parameters.

Signed-off-by: Nishad Kamdar 
Changes in v2:
 - Merge all patches in a single patch. This is because the
   first patch changes par->gpio from an int to a pointer
   so all the checks have to be updated in the same patch.
   Otherwie it breaks 'git bisect'.
---
 drivers/staging/fbtft/fb_agm1264k-fl.c |  52 ++--
 drivers/staging/fbtft/fb_bd663474.c|   6 +-
 drivers/staging/fbtft/fb_ili9163.c |   6 +-
 drivers/staging/fbtft/fb_ili9320.c |   2 +-
 drivers/staging/fbtft/fb_ili9325.c |   6 +-
 drivers/staging/fbtft/fb_ili9340.c |   2 +-
 drivers/staging/fbtft/fb_pcd8544.c |   4 +-
 drivers/staging/fbtft/fb_ra8875.c  |   4 +-
 drivers/staging/fbtft/fb_s6d1121.c |   6 +-
 drivers/staging/fbtft/fb_sh1106.c  |   2 +-
 drivers/staging/fbtft/fb_ssd1289.c |   6 +-
 drivers/staging/fbtft/fb_ssd1305.c |   4 +-
 drivers/staging/fbtft/fb_ssd1306.c |   4 +-
 drivers/staging/fbtft/fb_ssd1325.c |   6 +-
 drivers/staging/fbtft/fb_ssd1331.c |  10 +-
 drivers/staging/fbtft/fb_ssd1351.c |   2 +-
 drivers/staging/fbtft/fb_tls8204.c |   6 +-
 drivers/staging/fbtft/fb_uc1611.c  |   4 +-
 drivers/staging/fbtft/fb_uc1701.c  |   6 +-
 drivers/staging/fbtft/fb_upd161704.c   |   6 +-
 drivers/staging/fbtft/fb_watterott.c   |   4 +-
 drivers/staging/fbtft/fbtft-bus.c  |   6 +-
 drivers/staging/fbtft/fbtft-core.c | 173 +++--
 drivers/staging/fbtft/fbtft-io.c   |  26 +-
 drivers/staging/fbtft/fbtft.h  |  21 +-
 drivers/staging/fbtft/fbtft_device.c   | 344 +
 drivers/staging/fbtft/flexfb.c |  12 +-
 27 files changed, 143 insertions(+), 587 deletions(-)

diff --git a/drivers/staging/fbtft/fb_agm1264k-fl.c 
b/drivers/staging/fbtft/fb_agm1264k-fl.c
index f6f30f5bf15a..8f27bd8da17d 100644
--- a/drivers/staging/fbtft/fb_agm1264k-fl.c
+++ b/drivers/staging/fbtft/fb_agm1264k-fl.c
@@ -8,7 +8,7 @@
 #include 
 #include 
 #include 
-#include 
+#include 
 #include 
 #include 
 
@@ -79,14 +79,14 @@ static int init_display(struct fbtft_par *par)
 
 static void reset(struct fbtft_par *par)
 {
-   if (par->gpio.reset == -1)
+   if (!par->gpio.reset)
return;
 
dev_dbg(par->info->device, "%s()\n", __func__);
 
-   gpio_set_value(par->gpio.reset, 0);
+   gpiod_set_value(par->gpio.reset, 0);
udelay(20);
-   gpio_set_value(par->gpio.reset, 1);
+   gpiod_set_value(par->gpio.reset, 1);
mdelay(120);
 }
 
@@ -98,30 +98,30 @@ static int verify_gpios(struct fbtft_par *par)
dev_dbg(par->info->device,
"%s()\n", __func__);
 
-   if (par->EPIN < 0) {
+   if (!par->EPIN) {
dev_err(par->info->device,
"Missing info about 'wr' (aka E) gpio. Aborting.\n");
return -EINVAL;
}
for (i = 0; i < 8; ++i) {
-   if (par->gpio.db[i] < 0) {
+   if (!par->gpio.db[i]) {
dev_err(par->info->device,
"Missing info about 'db[%i]' gpio. Aborting.\n",
i);
return -EINVAL;
}
}
-   if (par->CS0 < 0) {
+   if (!par->CS0) {
dev_err(par->info->device,
"Missing info about 'cs0' gpio. Aborting.\n");
return -EINVAL;
}
-   if (par->CS1 < 0) {
+   if (!par->CS1) {
dev_err(par->info->device,
"Missing info about 'cs1' gpio. Aborting.\n");
return -EINVAL;
}
-   if (par->RW < 0) {
+   if (!par->RW) {
dev_err(par->info->device,
"Missing info about 'rw' gpio. Aborting.\n");
return -EINVAL;
@@ -139,22 +139,22 @@ request_gpios_match(struct fbtft_par *par, const struct 
fbtft_gpio *gpio)
if (strcasecmp(gpio->name, "wr") == 0) {
/* left ks0108 E pin */
par->EPIN = gpio->gpio;
-   return GPIOF_OUT_INIT_LOW;
+   return GPIOD_OUT_LOW;
} else if (strcasecmp(gpio->name, "cs0") == 0) {
/* left ks0108 controller pin */
par->CS0 = gpio->gpio;
-   return GPIOF_OUT_INIT_HIGH;
+   return GPIOD_OUT_HIGH;
} else if (strcasecmp(gpio->name, "cs1") == 0) {
/* right ks0108 controller pin */
par->CS1 = gpio->gpio;
-   return GPIOF_OUT_INIT_HIGH;
+   return GPIOD_OUT_HIGH;
}
 
/* if write (rw = 0) 

RE: [PATCH] staging: android: ion: add buffer flag update ioctl

2019-01-14 Thread Zengtao (B)
>-Original Message-
>From: Laura Abbott [mailto:labb...@redhat.com]
>Sent: Friday, January 04, 2019 9:53 AM
>To: Zengtao (B) ; sumit.sem...@linaro.org
>Cc: Greg Kroah-Hartman ; Arve Hjønnevåg
>; Todd Kjos ; Martijn Coenen
>; Joel Fernandes ;
>de...@driverdev.osuosl.org; dri-de...@lists.freedesktop.org;
>linaro-mm-...@lists.linaro.org; linux-ker...@vger.kernel.org
>Subject: Re: [PATCH] staging: android: ion: add buffer flag update ioctl
>
>On 1/3/19 5:42 PM, Zengtao (B) wrote:
>>> -Original Message-
>>> From: Laura Abbott [mailto:labb...@redhat.com]
>>> Sent: Thursday, January 03, 2019 6:31 AM
>>> To: Zengtao (B) ;
>sumit.sem...@linaro.org
>>> Cc: Greg Kroah-Hartman ; Arve
>Hjønnevåg
>>> ; Todd Kjos ; Martijn
>Coenen
>>> ; Joel Fernandes ;
>>> de...@driverdev.osuosl.org; dri-de...@lists.freedesktop.org;
>>> linaro-mm-...@lists.linaro.org; linux-ker...@vger.kernel.org
>>> Subject: Re: [PATCH] staging: android: ion: add buffer flag update
>>> ioctl
>>>
>>> On 12/23/18 6:47 PM, Zengtao (B) wrote:
 Hi laura:

> -Original Message-
> From: Laura Abbott [mailto:labb...@redhat.com]
> Sent: Friday, December 21, 2018 4:50 AM
> To: Zengtao (B) ;
>>> sumit.sem...@linaro.org
> Cc: Greg Kroah-Hartman ; Arve
>>> Hjønnevåg
> ; Todd Kjos ; Martijn
>>> Coenen
> ; Joel Fernandes ;
> de...@driverdev.osuosl.org; dri-de...@lists.freedesktop.org;
> linaro-mm-...@lists.linaro.org; linux-ker...@vger.kernel.org
> Subject: Re: [PATCH] staging: android: ion: add buffer flag update
> ioctl
>
> On 12/19/18 5:39 PM, Zengtao (B) wrote:
>> Hi laura:
>>
>>> -Original Message-
>>> From: Laura Abbott [mailto:labb...@redhat.com]
>>> Sent: Thursday, December 20, 2018 2:10 AM
>>> To: Zengtao (B) ;
> sumit.sem...@linaro.org
>>> Cc: Greg Kroah-Hartman ; Arve
> Hjønnevåg
>>> ; Todd Kjos ; Martijn
> Coenen
>>> ; Joel Fernandes ;
>>> de...@driverdev.osuosl.org; dri-de...@lists.freedesktop.org;
>>> linaro-mm-...@lists.linaro.org; linux-ker...@vger.kernel.org
>>> Subject: Re: [PATCH] staging: android: ion: add buffer flag
>>> update ioctl
>>>
>>> On 12/19/18 9:19 AM, Zeng Tao wrote:
 In some usecases, the buffer cached attribute is not determined
 at allocation time, it's determined just before the real cpu
>mapping.
 And from the memory view of point, a buffer should not have
>the
>>> cached
 attribute util is really mapped by the cpu. So in this patch, we
 introduced the new ioctl command to target the requirement.

>>>
>>> This is racy and error prone. Can you explain more what problem
>>> you
>>> are trying to solve?
>>
>> My use case is like this:
>> 1.  There are two process A and B, A takes case of ion buffer
>> allocation,
> and
>> pass the buffer fd to B, then B maps and uses it.
>> 2.  Process B need to map the buffer with different cached
>> attribute for different use case, for example, if the buffer is
>> used for pure software algorithm, then we need to map it as
>> cached, otherwise non-cached, and B needs to deal with both
>cases.
>> And unfortunately the mmap syscall takes no cached flags and we
>> can't decide the cache attribute when we are doing the mmap, so I
>> introduce new the ioctl even though I think the solution is not as
>>> good.
>>
>>
>
> Thanks for the explanation, this was about the use case I expected.
> I'm pretty sure I had this exact problem once upon a time and we
> didn't come up with a solution. I'd still like to get rid of
> uncached buffers in general and just use cached buffers (see
> http://driverdev.linuxdriverproject.org/pipermail/driverdev-devel/2
> 01
> 8-N
> ovember/128842.html)
> What's your usecase for uncached buffers?

 Some buffers are only used by HW, in this case, we tend to use
>>> uncached buffers.
 But sometimes the SW need to read few buffer contents for debug
 purpose and no synchronization is needed.

>>>
>>> If this is primarily for debug, that's not really a compelling reason
>>> to support uncached buffers. It's incredibly difficult to do uncached
>>> buffers correctly I'd rather spend effort on making the cached use
>>> cases work better.
>>>
>> No, not only for debug, I meant if the buffers are uncached, the SW
>> will only mmap them for debug or even don't need to mmap them.
>> So for the two kinds of buffers:
>> 1.  uncached: only the HW need to access it, the SW don't need to
>mmap it or just for debug.
>> 2.  cached: both the HW and the SW need to access it.
>> The ION is designed as a generalized memory manager, I think we
>should
>> cover as many requirements as we can in the ION design, so I 'd rather
>that we keep the uncached support.
>> And I don’t quite understand the difficulty you mentioned to support
>> the uncached buffers, 

Re: [PATCH 00/14] Misc ION cleanups and adding unmapped heap

2019-01-14 Thread Laura Abbott

On 1/11/19 10:05 AM, Andrew F. Davis wrote:

Hello all,

This is a set of (hopefully) non-controversial cleanups for the ION
framework and current set of heaps. These were found as I start to
familiarize myself with the framework to help in whatever way I
can in getting all this up to the standards needed for de-staging.

I would like to get some ideas of what is left to work on to get ION
out of staging. Has there been some kind of agreement on what ION should
eventually end up being? To me it looks like it is being whittled away at
to it's most core functions. To me that is looking like being a DMA-BUF
user-space front end, simply advertising available memory backings in a
system and providing allocations as DMA-BUF handles. If this is the case
then it looks close to being ready to me at least, but I would love to
hear any other opinions and concerns.



Yes, at this point the only functionality that people are really
depending on is the ability to allocate a dma_buf easily from userspace.


Back to this patchset, the last patch may be a bit different than the
others, it adds an unmapped heaps type and creation helper. I wanted to
get this in to show off another heap type and maybe some issues we may
have with the current ION framework. The unmapped heap is used when the
backing memory should not (or cannot) be touched. Currently this kind
of heap is used for firewalled secure memory that can be allocated like
normal heap memory but only used by secure devices (OP-TEE, crypto HW,
etc). It is basically just copied from the "carveout" heap type with the
only difference being it is not mappable to userspace and we do not clear
the memory (as we should not map it either). So should this really be a
new heap type? Or maybe advertised as a carveout heap but with an
additional allocation flag? Perhaps we do away with "types" altogether
and just have flags, coherent/non-coherent, mapped/unmapped, etc.

Maybe more thinking will be needed afterall..



So the cleanup looks okay (I need to finish reviewing) but I'm not a
fan of adding another heaptype without solving the problem of adding
some sort of devicetree binding or other method of allocating and
placing Ion heaps. That plus uncached buffers are one of the big
open problems that need to be solved for destaging Ion. See
https://lore.kernel.org/lkml/20181120164636.jcw7li2uaa3cmwc3@DESKTOP-E1NTVVP.localdomain/
for some background on that problem.

Thanks,
Laura


Thanks,
Andrew

Andrew F. Davis (14):
   staging: android: ion: Add proper header information
   staging: android: ion: Remove empty ion_ioctl_dir() function
   staging: android: ion: Merge ion-ioctl.c into ion.c
   staging: android: ion: Remove leftover comment
   staging: android: ion: Remove struct ion_platform_heap
   staging: android: ion: Fixup some white-space issues
   staging: android: ion: Sync comment docs with struct ion_buffer
   staging: android: ion: Remove base from ion_carveout_heap
   staging: android: ion: Remove base from ion_chunk_heap
   staging: android: ion: Remove unused headers
   staging: android: ion: Allow heap name to be null
   staging: android: ion: Declare helpers for carveout and chunk heaps
   staging: android: ion: Do not sync CPU cache on map/unmap
   staging: android: ion: Add UNMAPPED heap type and helper

  drivers/staging/android/ion/Kconfig   |  10 ++
  drivers/staging/android/ion/Makefile  |   3 +-
  drivers/staging/android/ion/ion-ioctl.c   |  98 --
  drivers/staging/android/ion/ion.c |  93 +++--
  drivers/staging/android/ion/ion.h |  87 -
  .../staging/android/ion/ion_carveout_heap.c   |  19 +--
  drivers/staging/android/ion/ion_chunk_heap.c  |  25 ++--
  drivers/staging/android/ion/ion_cma_heap.c|   6 +-
  drivers/staging/android/ion/ion_heap.c|   8 +-
  drivers/staging/android/ion/ion_page_pool.c   |   2 +-
  drivers/staging/android/ion/ion_system_heap.c |   8 +-
  .../staging/android/ion/ion_unmapped_heap.c   | 123 ++
  drivers/staging/android/uapi/ion.h|   3 +
  13 files changed, 307 insertions(+), 178 deletions(-)
  delete mode 100644 drivers/staging/android/ion/ion-ioctl.c
  create mode 100644 drivers/staging/android/ion/ion_unmapped_heap.c



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


Re: [PATCH 14/14] staging: android: ion: Add UNMAPPED heap type and helper

2019-01-14 Thread Laura Abbott

On 1/11/19 10:05 AM, Andrew F. Davis wrote:

The "unmapped" heap is very similar to the carveout heap except
the backing memory is presumed to be unmappable by the host, in
my specific case due to firewalls. This memory can still be
allocated from and used by devices that do have access to the
backing memory.

Based originally on the secure/unmapped heap from Linaro for
the OP-TEE SDP implementation, this was re-written to match
the carveout heap helper code.

Suggested-by: Etienne Carriere 
Signed-off-by: Andrew F. Davis 
---
  drivers/staging/android/ion/Kconfig   |  10 ++
  drivers/staging/android/ion/Makefile  |   1 +
  drivers/staging/android/ion/ion.h |  16 +++
  .../staging/android/ion/ion_unmapped_heap.c   | 123 ++
  drivers/staging/android/uapi/ion.h|   3 +
  5 files changed, 153 insertions(+)
  create mode 100644 drivers/staging/android/ion/ion_unmapped_heap.c

diff --git a/drivers/staging/android/ion/Kconfig 
b/drivers/staging/android/ion/Kconfig
index 0fdda6f62953..a117b8b91b14 100644
--- a/drivers/staging/android/ion/Kconfig
+++ b/drivers/staging/android/ion/Kconfig
@@ -42,3 +42,13 @@ config ION_CMA_HEAP
  Choose this option to enable CMA heaps with Ion. This heap is backed
  by the Contiguous Memory Allocator (CMA). If your system has these
  regions, you should say Y here.
+
+config ION_UNMAPPED_HEAP
+   bool "ION unmapped heap support"
+   depends on ION
+   help
+ Choose this option to enable UNMAPPED heaps with Ion. This heap is
+ backed in specific memory pools, carveout from the Linux memory.
+ Unlike carveout heaps these are assumed to be not mappable by
+ kernel or user-space.
+ Unless you know your system has these regions, you should say N here.
diff --git a/drivers/staging/android/ion/Makefile 
b/drivers/staging/android/ion/Makefile
index 17f3a7569e3d..c71a1f3de581 100644
--- a/drivers/staging/android/ion/Makefile
+++ b/drivers/staging/android/ion/Makefile
@@ -4,3 +4,4 @@ obj-$(CONFIG_ION_SYSTEM_HEAP) += ion_system_heap.o 
ion_page_pool.o
  obj-$(CONFIG_ION_CARVEOUT_HEAP) += ion_carveout_heap.o
  obj-$(CONFIG_ION_CHUNK_HEAP) += ion_chunk_heap.o
  obj-$(CONFIG_ION_CMA_HEAP) += ion_cma_heap.o
+obj-$(CONFIG_ION_UNMAPPED_HEAP) += ion_unmapped_heap.o
diff --git a/drivers/staging/android/ion/ion.h 
b/drivers/staging/android/ion/ion.h
index 97b2876b165a..ce74332018ba 100644
--- a/drivers/staging/android/ion/ion.h
+++ b/drivers/staging/android/ion/ion.h
@@ -341,4 +341,20 @@ static inline struct ion_heap 
*ion_chunk_heap_create(phys_addr_t base, size_t si
  }
  #endif
  
+#ifdef CONFIG_ION_UNMAPPED_HEAP

+/**
+ * ion_unmapped_heap_create
+ * @base:  base address of carveout memory
+ * @size:  size of carveout memory region
+ *
+ * Creates an unmapped ion_heap using the passed in data
+ */
+struct ion_heap *ion_unmapped_heap_create(phys_addr_t base, size_t size);
+#else
+struct ion_heap *ion_unmapped_heap_create(phys_addr_t base, size_t size)
+{
+   return ERR_PTR(-ENODEV);
+}
+#endif
+
  #endif /* _ION_H */
diff --git a/drivers/staging/android/ion/ion_unmapped_heap.c 
b/drivers/staging/android/ion/ion_unmapped_heap.c
new file mode 100644
index ..7602b659c2ec
--- /dev/null
+++ b/drivers/staging/android/ion/ion_unmapped_heap.c
@@ -0,0 +1,123 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * ION Memory Allocator unmapped heap helper
+ *
+ * Copyright (C) 2015-2016 Texas Instruments Incorporated - http://www.ti.com/
+ * Andrew F. Davis 
+ *
+ * ION "unmapped" heaps are physical memory heaps not by default mapped into
+ * a virtual address space. The buffer owner can explicitly request kernel
+ * space mappings but the underlying memory may still not be accessible for
+ * various reasons, such as firewalls.
+ */
+
+#include 
+#include 
+#include 
+#include 
+
+#include "ion.h"
+
+#define ION_UNMAPPED_ALLOCATE_FAIL -1
+
+struct ion_unmapped_heap {
+   struct ion_heap heap;
+   struct gen_pool *pool;
+};
+
+static phys_addr_t ion_unmapped_allocate(struct ion_heap *heap,
+unsigned long size)
+{
+   struct ion_unmapped_heap *unmapped_heap =
+   container_of(heap, struct ion_unmapped_heap, heap);
+   unsigned long offset;
+
+   offset = gen_pool_alloc(unmapped_heap->pool, size);
+   if (!offset)
+   return ION_UNMAPPED_ALLOCATE_FAIL;
+
+   return offset;
+}
+
+static void ion_unmapped_free(struct ion_heap *heap, phys_addr_t addr,
+ unsigned long size)
+{
+   struct ion_unmapped_heap *unmapped_heap =
+   container_of(heap, struct ion_unmapped_heap, heap);
+
+   gen_pool_free(unmapped_heap->pool, addr, size);
+}
+
+static int ion_unmapped_heap_allocate(struct ion_heap *heap,
+ struct ion_buffer *buffer,
+ unsigned long 

[PATCH v2 5/5] staging: erofs: clean up erofs_map_blocks_iter

2019-01-14 Thread Chao Yu
This patch cleans up erofs_map_blocks* function and structure family,
just simply the code, no logic change.

Reviewed-by: Gao Xiang 
Signed-off-by: Chao Yu 
Signed-off-by: Gao Xiang 
---
v2:
- remove unneed semicolon in definition of z_erofs_map_blocks_iter
 drivers/staging/erofs/data.c  | 31 +--
 drivers/staging/erofs/internal.h  | 28 +++-
 drivers/staging/erofs/unzip_vle.c | 30 +++---
 3 files changed, 35 insertions(+), 54 deletions(-)

diff --git a/drivers/staging/erofs/data.c b/drivers/staging/erofs/data.c
index 329fa4fa3e9c..9c471f08ffd4 100644
--- a/drivers/staging/erofs/data.c
+++ b/drivers/staging/erofs/data.c
@@ -165,37 +165,16 @@ static int erofs_map_blocks_flatmode(struct inode *inode,
return err;
 }
 
-int erofs_map_blocks_iter(struct inode *inode,
- struct erofs_map_blocks *map,
- struct page **mpage_ret, int flags)
-{
-   /* by default, reading raw data never use erofs_map_blocks_iter */
-   if (unlikely(!is_inode_layout_compression(inode))) {
-   if (*mpage_ret)
-   put_page(*mpage_ret);
-   *mpage_ret = NULL;
-
-   return erofs_map_blocks(inode, map, flags);
-   }
-
-#ifdef CONFIG_EROFS_FS_ZIP
-   return z_erofs_map_blocks_iter(inode, map, mpage_ret, flags);
-#else
-   /* data compression is not available */
-   return -ENOTSUPP;
-#endif
-}
-
 int erofs_map_blocks(struct inode *inode,
 struct erofs_map_blocks *map, int flags)
 {
if (unlikely(is_inode_layout_compression(inode))) {
-   struct page *mpage = NULL;
-   int err;
+   int err = z_erofs_map_blocks_iter(inode, map, flags);
 
-   err = erofs_map_blocks_iter(inode, map, , flags);
-   if (mpage)
-   put_page(mpage);
+   if (map->mpage) {
+   put_page(map->mpage);
+   map->mpage = NULL;
+   }
return err;
}
return erofs_map_blocks_flatmode(inode, map, flags);
diff --git a/drivers/staging/erofs/internal.h b/drivers/staging/erofs/internal.h
index 99b50b981335..c3de24e7fb67 100644
--- a/drivers/staging/erofs/internal.h
+++ b/drivers/staging/erofs/internal.h
@@ -461,11 +461,26 @@ struct erofs_map_blocks {
u64 m_plen, m_llen;
 
unsigned int m_flags;
+
+   struct page *mpage;
 };
 
 /* Flags used by erofs_map_blocks() */
 #define EROFS_GET_BLOCKS_RAW0x0001
 
+#ifdef CONFIG_EROFS_FS_ZIP
+int z_erofs_map_blocks_iter(struct inode *inode,
+   struct erofs_map_blocks *map,
+   int flags);
+#else
+static inline int z_erofs_map_blocks_iter(struct inode *inode,
+ struct erofs_map_blocks *map,
+ int flags)
+{
+   return -ENOTSUPP;
+}
+#endif
+
 /* data.c */
 static inline struct bio *
 erofs_grab_bio(struct super_block *sb,
@@ -522,19 +537,6 @@ static inline struct page 
*erofs_get_meta_page_nofail(struct super_block *sb,
 }
 
 extern int erofs_map_blocks(struct inode *, struct erofs_map_blocks *, int);
-extern int erofs_map_blocks_iter(struct inode *, struct erofs_map_blocks *,
-   struct page **, int);
-
-struct erofs_map_blocks_iter {
-   struct erofs_map_blocks map;
-   struct page *mpage;
-};
-
-#ifdef CONFIG_EROFS_FS_ZIP
-extern int z_erofs_map_blocks_iter(struct inode *,
-  struct erofs_map_blocks *,
-  struct page **, int);
-#endif
 
 static inline struct page *
 erofs_get_inline_page(struct inode *inode,
diff --git a/drivers/staging/erofs/unzip_vle.c 
b/drivers/staging/erofs/unzip_vle.c
index 584612b47369..29b3b1dc67f1 100644
--- a/drivers/staging/erofs/unzip_vle.c
+++ b/drivers/staging/erofs/unzip_vle.c
@@ -636,7 +636,7 @@ struct z_erofs_vle_frontend {
struct inode *const inode;
 
struct z_erofs_vle_work_builder builder;
-   struct erofs_map_blocks_iter m_iter;
+   struct erofs_map_blocks map;
 
z_erofs_vle_owned_workgrp_t owned_head;
 
@@ -647,8 +647,9 @@ struct z_erofs_vle_frontend {
 
 #define VLE_FRONTEND_INIT(__i) { \
.inode = __i, \
-   .m_iter = { \
-   { .m_llen = 0, .m_plen = 0 }, \
+   .map = { \
+   .m_llen = 0, \
+   .m_plen = 0, \
.mpage = NULL \
}, \
.builder = VLE_WORK_BUILDER_INIT(), \
@@ -681,8 +682,7 @@ static int z_erofs_do_read_page(struct z_erofs_vle_frontend 
*fe,
 {
struct super_block *const sb = fe->inode->i_sb;
struct erofs_sb_info *const sbi __maybe_unused = EROFS_SB(sb);
-   struct erofs_map_blocks_iter *const m = >m_iter;
-   struct erofs_map_blocks *const map = >map;
+   struct erofs_map_blocks *const map = >map;
struct 

[PATCH hyperv-fixes,3/3] Fix hash key value reset after other ops

2019-01-14 Thread Haiyang Zhang
From: Haiyang Zhang 

Changing mtu, channels, or buffer sizes ops call to netvsc_attach(),
rndis_set_subchannel(), which always reset the hash key to default
value. That will override hash key changed previously. This patch
fixes the problem by save the hash key, then restore it when we re-
add the netvsc device.

Fixes: ff4a44199012 ("netvsc: allow get/set of RSS indirection table")
Signed-off-by: Haiyang Zhang 
---
 drivers/net/hyperv/hyperv_net.h   | 10 +++---
 drivers/net/hyperv/netvsc.c   |  2 +-
 drivers/net/hyperv/netvsc_drv.c   |  5 -
 drivers/net/hyperv/rndis_filter.c |  9 +++--
 4 files changed, 19 insertions(+), 7 deletions(-)

diff --git a/drivers/net/hyperv/hyperv_net.h b/drivers/net/hyperv/hyperv_net.h
index ef6f766f6389..e598a684700b 100644
--- a/drivers/net/hyperv/hyperv_net.h
+++ b/drivers/net/hyperv/hyperv_net.h
@@ -144,6 +144,8 @@ struct hv_netvsc_packet {
u32 total_data_buflen;
 };
 
+#define NETVSC_HASH_KEYLEN 40
+
 struct netvsc_device_info {
unsigned char mac_adr[ETH_ALEN];
u32  num_chn;
@@ -151,6 +153,8 @@ struct netvsc_device_info {
u32  recv_sections;
u32  send_section_size;
u32  recv_section_size;
+
+   u8 rss_key[NETVSC_HASH_KEYLEN];
 };
 
 enum rndis_device_state {
@@ -160,8 +164,6 @@ enum rndis_device_state {
RNDIS_DEV_DATAINITIALIZED,
 };
 
-#define NETVSC_HASH_KEYLEN 40
-
 struct rndis_device {
struct net_device *ndev;
 
@@ -209,7 +211,9 @@ int netvsc_recv_callback(struct net_device *net,
 void netvsc_channel_cb(void *context);
 int netvsc_poll(struct napi_struct *napi, int budget);
 
-int rndis_set_subchannel(struct net_device *ndev, struct netvsc_device *nvdev);
+int rndis_set_subchannel(struct net_device *ndev,
+struct netvsc_device *nvdev,
+struct netvsc_device_info *dev_info);
 int rndis_filter_open(struct netvsc_device *nvdev);
 int rndis_filter_close(struct netvsc_device *nvdev);
 struct netvsc_device *rndis_filter_device_add(struct hv_device *dev,
diff --git a/drivers/net/hyperv/netvsc.c b/drivers/net/hyperv/netvsc.c
index 922054c1d544..1910810e55bd 100644
--- a/drivers/net/hyperv/netvsc.c
+++ b/drivers/net/hyperv/netvsc.c
@@ -84,7 +84,7 @@ static void netvsc_subchan_work(struct work_struct *w)
 
rdev = nvdev->extension;
if (rdev) {
-   ret = rndis_set_subchannel(rdev->ndev, nvdev);
+   ret = rndis_set_subchannel(rdev->ndev, nvdev, NULL);
if (ret == 0) {
netif_device_attach(rdev->ndev);
} else {
diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c
index f424327f7206..e281829a04ef 100644
--- a/drivers/net/hyperv/netvsc_drv.c
+++ b/drivers/net/hyperv/netvsc_drv.c
@@ -877,6 +877,9 @@ static struct netvsc_device_info *netvsc_devinfo_get
dev_info->send_section_size = nvdev->send_section_size;
dev_info->recv_sections = nvdev->recv_section_cnt;
dev_info->recv_section_size = nvdev->recv_section_size;
+
+   memcpy(dev_info->rss_key, nvdev->extension->rss_key,
+  NETVSC_HASH_KEYLEN);
} else {
dev_info->num_chn = VRSS_CHANNEL_DEFAULT;
dev_info->send_sections = NETVSC_DEFAULT_TX;
@@ -939,7 +942,7 @@ static int netvsc_attach(struct net_device *ndev,
return PTR_ERR(nvdev);
 
if (nvdev->num_chn > 1) {
-   ret = rndis_set_subchannel(ndev, nvdev);
+   ret = rndis_set_subchannel(ndev, nvdev, dev_info);
 
/* if unavailable, just proceed with one queue */
if (ret) {
diff --git a/drivers/net/hyperv/rndis_filter.c 
b/drivers/net/hyperv/rndis_filter.c
index a4661d396e3c..db81378e6624 100644
--- a/drivers/net/hyperv/rndis_filter.c
+++ b/drivers/net/hyperv/rndis_filter.c
@@ -1134,7 +1134,9 @@ static void netvsc_sc_open(struct vmbus_channel *new_sc)
  * This breaks overlap of processing the host message for the
  * new primary channel with the initialization of sub-channels.
  */
-int rndis_set_subchannel(struct net_device *ndev, struct netvsc_device *nvdev)
+int rndis_set_subchannel(struct net_device *ndev,
+struct netvsc_device *nvdev,
+struct netvsc_device_info *dev_info)
 {
struct nvsp_message *init_packet = >channel_init_pkt;
struct net_device_context *ndev_ctx = netdev_priv(ndev);
@@ -1175,7 +1177,10 @@ int rndis_set_subchannel(struct net_device *ndev, struct 
netvsc_device *nvdev)
   atomic_read(>open_chn) == nvdev->num_chn);
 
/* ignore failues from setting rss parameters, still have channels */
-   rndis_filter_set_rss_param(rdev, netvsc_hash_key);
+   if (dev_info)
+   rndis_filter_set_rss_param(rdev, dev_info->rss_key);
+   else
+   rndis_filter_set_rss_param(rdev, netvsc_hash_key);
 

[PATCH hyperv-fixes,0/3] fixes for hash key setting issues

2019-01-14 Thread Haiyang Zhang
From: Haiyang Zhang 

Using ethtool to change Hash key failed on Linux VM runnig on
Hyper-V. This patch set fix them.
It targets Hyper-V tree, hyperv-fixes branch managed by 
Sasha Levin .

Haiyang Zhang (3):
  Fix ethtool change hash key error
  Refactor assignments of struct netvsc_device_info
  Fix hash key value reset after other ops

 drivers/net/hyperv/hyperv_net.h   |  10 ++-
 drivers/net/hyperv/netvsc.c   |   2 +-
 drivers/net/hyperv/netvsc_drv.c   | 139 +++---
 drivers/net/hyperv/rndis_filter.c |  34 ++--
 4 files changed, 123 insertions(+), 62 deletions(-)

-- 
2.19.1

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


[PATCH hyperv-fixes,1/3] Fix ethtool change hash key error

2019-01-14 Thread Haiyang Zhang
From: Haiyang Zhang 

Hyper-V hosts require us to disable RSS before changing RSS key,
otherwise the changing request will fail. This patch fixes the
coding error.

Fixes: ff4a44199012 ("netvsc: allow get/set of RSS indirection table")
Reported-by: Wei Hu 
Signed-off-by: Haiyang Zhang 
---
 drivers/net/hyperv/rndis_filter.c | 25 +++--
 1 file changed, 19 insertions(+), 6 deletions(-)

diff --git a/drivers/net/hyperv/rndis_filter.c 
b/drivers/net/hyperv/rndis_filter.c
index 8b537a049c1e..a4661d396e3c 100644
--- a/drivers/net/hyperv/rndis_filter.c
+++ b/drivers/net/hyperv/rndis_filter.c
@@ -774,8 +774,8 @@ rndis_filter_set_offload_params(struct net_device *ndev,
return ret;
 }
 
-int rndis_filter_set_rss_param(struct rndis_device *rdev,
-  const u8 *rss_key)
+static int rndis_set_rss_param_msg(struct rndis_device *rdev,
+  const u8 *rss_key, u16 flag)
 {
struct net_device *ndev = rdev->ndev;
struct rndis_request *request;
@@ -804,7 +804,7 @@ int rndis_filter_set_rss_param(struct rndis_device *rdev,
rssp->hdr.type = NDIS_OBJECT_TYPE_RSS_PARAMETERS;
rssp->hdr.rev = NDIS_RECEIVE_SCALE_PARAMETERS_REVISION_2;
rssp->hdr.size = sizeof(struct ndis_recv_scale_param);
-   rssp->flag = 0;
+   rssp->flag = flag;
rssp->hashinfo = NDIS_HASH_FUNC_TOEPLITZ | NDIS_HASH_IPV4 |
 NDIS_HASH_TCP_IPV4 | NDIS_HASH_IPV6 |
 NDIS_HASH_TCP_IPV6;
@@ -829,9 +829,12 @@ int rndis_filter_set_rss_param(struct rndis_device *rdev,
 
wait_for_completion(>wait_event);
set_complete = >response_msg.msg.set_complete;
-   if (set_complete->status == RNDIS_STATUS_SUCCESS)
-   memcpy(rdev->rss_key, rss_key, NETVSC_HASH_KEYLEN);
-   else {
+   if (set_complete->status == RNDIS_STATUS_SUCCESS) {
+   if (!(flag & NDIS_RSS_PARAM_FLAG_DISABLE_RSS) &&
+   !(flag & NDIS_RSS_PARAM_FLAG_HASH_KEY_UNCHANGED))
+   memcpy(rdev->rss_key, rss_key, NETVSC_HASH_KEYLEN);
+
+   } else {
netdev_err(ndev, "Fail to set RSS parameters:0x%x\n",
   set_complete->status);
ret = -EINVAL;
@@ -842,6 +845,16 @@ int rndis_filter_set_rss_param(struct rndis_device *rdev,
return ret;
 }
 
+int rndis_filter_set_rss_param(struct rndis_device *rdev,
+  const u8 *rss_key)
+{
+   /* Disable RSS before change */
+   rndis_set_rss_param_msg(rdev, rss_key,
+   NDIS_RSS_PARAM_FLAG_DISABLE_RSS);
+
+   return rndis_set_rss_param_msg(rdev, rss_key, 0);
+}
+
 static int rndis_filter_query_device_link_status(struct rndis_device *dev,
 struct netvsc_device 
*net_device)
 {
-- 
2.19.1

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


[PATCH hyperv-fixes, 2/3] Refactor assignments of struct netvsc_device_info

2019-01-14 Thread Haiyang Zhang
From: Haiyang Zhang 

These assignments occur in multiple places. The patch refactor them
to a function for simplicity. It also puts the struct to heap area
for future expension.

Signed-off-by: Haiyang Zhang 
---
 drivers/net/hyperv/netvsc_drv.c | 134 
 1 file changed, 85 insertions(+), 49 deletions(-)

diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c
index 91ed15ea5883..f424327f7206 100644
--- a/drivers/net/hyperv/netvsc_drv.c
+++ b/drivers/net/hyperv/netvsc_drv.c
@@ -858,6 +858,36 @@ static void netvsc_get_channels(struct net_device *net,
}
 }
 
+/* Alloc struct netvsc_device_info, and initialize it from either existing
+ * struct netvsc_device, or from default values.
+ */
+static struct netvsc_device_info *netvsc_devinfo_get
+   (struct netvsc_device *nvdev)
+{
+   struct netvsc_device_info *dev_info;
+
+   dev_info = kzalloc(sizeof(*dev_info), GFP_ATOMIC);
+
+   if (!dev_info)
+   return NULL;
+
+   if (nvdev) {
+   dev_info->num_chn = nvdev->num_chn;
+   dev_info->send_sections = nvdev->send_section_cnt;
+   dev_info->send_section_size = nvdev->send_section_size;
+   dev_info->recv_sections = nvdev->recv_section_cnt;
+   dev_info->recv_section_size = nvdev->recv_section_size;
+   } else {
+   dev_info->num_chn = VRSS_CHANNEL_DEFAULT;
+   dev_info->send_sections = NETVSC_DEFAULT_TX;
+   dev_info->send_section_size = NETVSC_SEND_SECTION_SIZE;
+   dev_info->recv_sections = NETVSC_DEFAULT_RX;
+   dev_info->recv_section_size = NETVSC_RECV_SECTION_SIZE;
+   }
+
+   return dev_info;
+}
+
 static int netvsc_detach(struct net_device *ndev,
 struct netvsc_device *nvdev)
 {
@@ -943,7 +973,7 @@ static int netvsc_set_channels(struct net_device *net,
struct net_device_context *net_device_ctx = netdev_priv(net);
struct netvsc_device *nvdev = rtnl_dereference(net_device_ctx->nvdev);
unsigned int orig, count = channels->combined_count;
-   struct netvsc_device_info device_info;
+   struct netvsc_device_info *device_info;
int ret;
 
/* We do not support separate count for rx, tx, or other */
@@ -962,24 +992,26 @@ static int netvsc_set_channels(struct net_device *net,
 
orig = nvdev->num_chn;
 
-   memset(_info, 0, sizeof(device_info));
-   device_info.num_chn = count;
-   device_info.send_sections = nvdev->send_section_cnt;
-   device_info.send_section_size = nvdev->send_section_size;
-   device_info.recv_sections = nvdev->recv_section_cnt;
-   device_info.recv_section_size = nvdev->recv_section_size;
+   device_info = netvsc_devinfo_get(nvdev);
+
+   if (!device_info)
+   return -ENOMEM;
+
+   device_info->num_chn = count;
 
ret = netvsc_detach(net, nvdev);
if (ret)
-   return ret;
+   goto out;
 
-   ret = netvsc_attach(net, _info);
+   ret = netvsc_attach(net, device_info);
if (ret) {
-   device_info.num_chn = orig;
-   if (netvsc_attach(net, _info))
+   device_info->num_chn = orig;
+   if (netvsc_attach(net, device_info))
netdev_err(net, "restoring channel setting failed\n");
}
 
+out:
+   kfree(device_info);
return ret;
 }
 
@@ -1048,48 +1080,45 @@ static int netvsc_change_mtu(struct net_device *ndev, 
int mtu)
struct net_device *vf_netdev = rtnl_dereference(ndevctx->vf_netdev);
struct netvsc_device *nvdev = rtnl_dereference(ndevctx->nvdev);
int orig_mtu = ndev->mtu;
-   struct netvsc_device_info device_info;
+   struct netvsc_device_info *device_info;
int ret = 0;
 
if (!nvdev || nvdev->destroy)
return -ENODEV;
 
+   device_info = netvsc_devinfo_get(nvdev);
+
+   if (!device_info)
+   return -ENOMEM;
+
/* Change MTU of underlying VF netdev first. */
if (vf_netdev) {
ret = dev_set_mtu(vf_netdev, mtu);
if (ret)
-   return ret;
+   goto out;
}
 
-   memset(_info, 0, sizeof(device_info));
-   device_info.num_chn = nvdev->num_chn;
-   device_info.send_sections = nvdev->send_section_cnt;
-   device_info.send_section_size = nvdev->send_section_size;
-   device_info.recv_sections = nvdev->recv_section_cnt;
-   device_info.recv_section_size = nvdev->recv_section_size;
-
ret = netvsc_detach(ndev, nvdev);
if (ret)
goto rollback_vf;
 
ndev->mtu = mtu;
 
-   ret = netvsc_attach(ndev, _info);
-   if (ret)
-   goto rollback;
-
-   return 0;
+   ret = netvsc_attach(ndev, device_info);
+   if (!ret)
+   goto out;
 
-rollback:
   

Re: [PATCH v3] binder: create node flag to request sender's security context

2019-01-14 Thread Joel Fernandes
On Mon, Jan 14, 2019 at 10:50:24AM -0800, Todd Kjos wrote:
> On Mon, Jan 14, 2019 at 10:33 AM Joel Fernandes  wrote:
> >
> > On Mon, Jan 14, 2019 at 09:10:21AM -0800, Todd Kjos wrote:
> > > To allow servers to verify client identity, allow a node
> > > flag to be set that causes the sender's security context
> > > to be delivered with the transaction. The BR_TRANSACTION
> > > command is extended in BR_TRANSACTION_SEC_CTX to
> > > contain a pointer to the security context string.
> > >
> > > Signed-off-by: Todd Kjos 
> > > ---
> > > v2: fix 32-bit build warning
> > > v3: fix smatch warning on unitialized struct element
> > >
> > >  drivers/android/binder.c| 106 ++--
> > >  include/uapi/linux/android/binder.h |  19 +
> > >  2 files changed, 102 insertions(+), 23 deletions(-)
> > >
> > > diff --git a/drivers/android/binder.c b/drivers/android/binder.c
> > > index cdfc87629efb8..5f6ef5e63b91e 100644
> > > --- a/drivers/android/binder.c
> > > +++ b/drivers/android/binder.c
> > > @@ -329,6 +329,8 @@ struct binder_error {
> > >   *(invariant after initialized)
> > >   * @min_priority: minimum scheduling priority
> > >   *(invariant after initialized)
> > > + * @txn_security_ctx: require sender's security context
> > > + *(invariant after initialized)
> > >   * @async_todo:   list of async work items
> > >   *(protected by @proc->inner_lock)
> > >   *
> > > @@ -365,6 +367,7 @@ struct binder_node {
> > >* invariant after initialization
> > >*/
> > >   u8 accept_fds:1;
> > > + u8 txn_security_ctx:1;
> > >   u8 min_priority;
> > >   };
> > >   bool has_async_transaction;
> > > @@ -615,6 +618,7 @@ struct binder_transaction {
> > >   longsaved_priority;
> > >   kuid_t  sender_euid;
> > >   struct list_head fd_fixups;
> > > + binder_uintptr_t security_ctx;
> > >   /**
> > >* @lock:  protects @from, @to_proc, and @to_thread
> > >*
> > > @@ -1152,6 +1156,7 @@ static struct binder_node *binder_init_node_ilocked(
> > >   node->work.type = BINDER_WORK_NODE;
> > >   node->min_priority = flags & FLAT_BINDER_FLAG_PRIORITY_MASK;
> > >   node->accept_fds = !!(flags & FLAT_BINDER_FLAG_ACCEPTS_FDS);
> > > + node->txn_security_ctx = !!(flags & 
> > > FLAT_BINDER_FLAG_TXN_SECURITY_CTX);
> > >   spin_lock_init(>lock);
> > >   INIT_LIST_HEAD(>work.entry);
> > >   INIT_LIST_HEAD(>async_todo);
> > > @@ -2778,6 +2783,8 @@ static void binder_transaction(struct binder_proc 
> > > *proc,
> > >   binder_size_t last_fixup_min_off = 0;
> > >   struct binder_context *context = proc->context;
> > >   int t_debug_id = atomic_inc_return(_last_id);
> > > + char *secctx = NULL;
> > > + u32 secctx_sz = 0;
> > >
> > >   e = binder_transaction_log_add(_transaction_log);
> > >   e->debug_id = t_debug_id;
> > > @@ -3020,6 +3027,20 @@ static void binder_transaction(struct binder_proc 
> > > *proc,
> > >   t->flags = tr->flags;
> > >   t->priority = task_nice(current);
> > >
> > > + if (target_node && target_node->txn_security_ctx) {
> > > + u32 secid;
> > > +
> > > + security_task_getsecid(proc->tsk, );
> > > + ret = security_secid_to_secctx(secid, , _sz);
> > > + if (ret) {
> > > + return_error = BR_FAILED_REPLY;
> > > + return_error_param = ret;
> > > + return_error_line = __LINE__;
> > > + goto err_get_secctx_failed;
> > > + }
> > > + extra_buffers_size += ALIGN(secctx_sz, sizeof(u64));
> > > + }
> > > +
> > >   trace_binder_transaction(reply, t, target_node);
> > >
> > >   t->buffer = binder_alloc_new_buf(_proc->alloc, tr->data_size,
> > > @@ -3036,6 +3057,19 @@ static void binder_transaction(struct binder_proc 
> > > *proc,
> > >   t->buffer = NULL;
> > >   goto err_binder_alloc_buf_failed;
> > >   }
> > > + if (secctx) {
> > > + size_t buf_offset = ALIGN(tr->data_size, sizeof(void *)) +
> > > + ALIGN(tr->offsets_size, sizeof(void *)) 
> > > +
> > > + ALIGN(extra_buffers_size, sizeof(void 
> > > *)) -
> > > + ALIGN(secctx_sz, sizeof(u64));
> > > + char *kptr = t->buffer->data + buf_offset;
> > > +
> > > + t->security_ctx = (uintptr_t)kptr +
> > > + 
> > > binder_alloc_get_user_buffer_offset(_proc->alloc);
> > > + memcpy(kptr, secctx, secctx_sz);
> >
> > Just for my clarification, instead of storing the string in the transaction
> > buffer, would it not be better to store the security context id in
> > t->security_ctx, and then do the conversion to string later, during

Re: [PATCH v3] binder: create node flag to request sender's security context

2019-01-14 Thread Joel Fernandes
On Mon, Jan 14, 2019 at 09:10:21AM -0800, Todd Kjos wrote:
> To allow servers to verify client identity, allow a node
> flag to be set that causes the sender's security context
> to be delivered with the transaction. The BR_TRANSACTION
> command is extended in BR_TRANSACTION_SEC_CTX to
> contain a pointer to the security context string.
> 
> Signed-off-by: Todd Kjos 
> ---
> v2: fix 32-bit build warning
> v3: fix smatch warning on unitialized struct element
> 
>  drivers/android/binder.c| 106 ++--
>  include/uapi/linux/android/binder.h |  19 +
>  2 files changed, 102 insertions(+), 23 deletions(-)
> 
> diff --git a/drivers/android/binder.c b/drivers/android/binder.c
> index cdfc87629efb8..5f6ef5e63b91e 100644
> --- a/drivers/android/binder.c
> +++ b/drivers/android/binder.c
> @@ -329,6 +329,8 @@ struct binder_error {
>   *(invariant after initialized)
>   * @min_priority: minimum scheduling priority
>   *(invariant after initialized)
> + * @txn_security_ctx: require sender's security context
> + *(invariant after initialized)
>   * @async_todo:   list of async work items
>   *(protected by @proc->inner_lock)
>   *
> @@ -365,6 +367,7 @@ struct binder_node {
>* invariant after initialization
>*/
>   u8 accept_fds:1;
> + u8 txn_security_ctx:1;
>   u8 min_priority;
>   };
>   bool has_async_transaction;
> @@ -615,6 +618,7 @@ struct binder_transaction {
>   longsaved_priority;
>   kuid_t  sender_euid;
>   struct list_head fd_fixups;
> + binder_uintptr_t security_ctx;
>   /**
>* @lock:  protects @from, @to_proc, and @to_thread
>*
> @@ -1152,6 +1156,7 @@ static struct binder_node *binder_init_node_ilocked(
>   node->work.type = BINDER_WORK_NODE;
>   node->min_priority = flags & FLAT_BINDER_FLAG_PRIORITY_MASK;
>   node->accept_fds = !!(flags & FLAT_BINDER_FLAG_ACCEPTS_FDS);
> + node->txn_security_ctx = !!(flags & FLAT_BINDER_FLAG_TXN_SECURITY_CTX);
>   spin_lock_init(>lock);
>   INIT_LIST_HEAD(>work.entry);
>   INIT_LIST_HEAD(>async_todo);
> @@ -2778,6 +2783,8 @@ static void binder_transaction(struct binder_proc *proc,
>   binder_size_t last_fixup_min_off = 0;
>   struct binder_context *context = proc->context;
>   int t_debug_id = atomic_inc_return(_last_id);
> + char *secctx = NULL;
> + u32 secctx_sz = 0;
>  
>   e = binder_transaction_log_add(_transaction_log);
>   e->debug_id = t_debug_id;
> @@ -3020,6 +3027,20 @@ static void binder_transaction(struct binder_proc 
> *proc,
>   t->flags = tr->flags;
>   t->priority = task_nice(current);
>  
> + if (target_node && target_node->txn_security_ctx) {
> + u32 secid;
> +
> + security_task_getsecid(proc->tsk, );
> + ret = security_secid_to_secctx(secid, , _sz);
> + if (ret) {
> + return_error = BR_FAILED_REPLY;
> + return_error_param = ret;
> + return_error_line = __LINE__;
> + goto err_get_secctx_failed;
> + }
> + extra_buffers_size += ALIGN(secctx_sz, sizeof(u64));
> + }
> +
>   trace_binder_transaction(reply, t, target_node);
>  
>   t->buffer = binder_alloc_new_buf(_proc->alloc, tr->data_size,
> @@ -3036,6 +3057,19 @@ static void binder_transaction(struct binder_proc 
> *proc,
>   t->buffer = NULL;
>   goto err_binder_alloc_buf_failed;
>   }
> + if (secctx) {
> + size_t buf_offset = ALIGN(tr->data_size, sizeof(void *)) +
> + ALIGN(tr->offsets_size, sizeof(void *)) +
> + ALIGN(extra_buffers_size, sizeof(void *)) -
> + ALIGN(secctx_sz, sizeof(u64));
> + char *kptr = t->buffer->data + buf_offset;
> +
> + t->security_ctx = (uintptr_t)kptr +
> + binder_alloc_get_user_buffer_offset(_proc->alloc);
> + memcpy(kptr, secctx, secctx_sz);

Just for my clarification, instead of storing the string in the transaction
buffer, would it not be better to store the security context id in
t->security_ctx, and then do the conversion to string later, during
binder_thread_read? Then some space will also be saved in the transaction
buffer?

thanks,

 - Joel


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


[PATCH v2] staging: erofs: add document

2019-01-14 Thread Gao Xiang
From: Gao Xiang 

This documents key feature, usage, and on-disk design of erofs.

Reviewed-by: Chao Yu 
Cc: 
Signed-off-by: Gao Xiang 
---
change log v2:
 - fix some incorrect descriptions, such as namelen -> nameoff;
 - add description about target EROFS users.

Thanks,
Gao Xiang

 .../erofs/Documentation/filesystems/erofs.txt  | 206 +
 1 file changed, 206 insertions(+)
 create mode 100644 drivers/staging/erofs/Documentation/filesystems/erofs.txt

diff --git a/drivers/staging/erofs/Documentation/filesystems/erofs.txt 
b/drivers/staging/erofs/Documentation/filesystems/erofs.txt
new file mode 100644
index ..a9cbbd7196b8
--- /dev/null
+++ b/drivers/staging/erofs/Documentation/filesystems/erofs.txt
@@ -0,0 +1,206 @@
+Overview
+
+
+EROFS file-system stands for Enhanced Read-Only File System. Different
+from other read-only file systems, it aims to be designed for flexibility,
+scalability, but be kept simple and high performance.
+
+It is designed as a better filesystem solution for the following scenarios:
+ - read-only storage media or
+
+ - part of a fully trusted read-only solution, which means it needs to be
+   immutable and bit-for-bit identical to the official golden image for
+   their releases due to security and other considerations and
+
+ - hope to save some extra storage space with guaranteed end-to-end performance
+   by using reduced metadata and transparent file compression, especially
+   for those embedded devices with limited memory (ex, smartphone);
+
+Here is the main features of EROFS:
+ - Little endian on-disk design;
+
+ - Currently 4KB block size (nobh) and therefore maximum 16TB address space;
+
+ - Metadata & data could be mixed by design;
+
+ - 2 inode versions for different requirements:
+  v1v2
+   Inode metadata size:   32 bytes  64 bytes
+   Max file size: 4 GB  16 EB (also limited by max. vol size)
+   Max uids/gids: 65536 4294967296
+   File creation time:noyes (64 + 32-bit timestamp)
+   Max hardlinks: 65536 4294967296
+   Metadata reserved: 4 bytes   14 bytes
+
+ - Support extended attributes (xattrs) as an option;
+
+ - Support xattr inline and tail-end data inline for all files;
+
+ - Support transparent file compression as an option:
+   LZ4 algorithm with 4 KB fixed-output compression for high performance;
+
+The following git tree provides the file system user-space tools under
+development (ex, formatting tool mkfs.erofs):
+>> git://git.kernel.org/pub/scm/linux/kernel/git/xiang/erofs-utils.git
+
+Bugs and patches are welcome, please kindly help us and send to the following
+linux-erofs mailing list:
+>> linux-erofs mailing list   
+
+Note that EROFS is still working in progress as a Linux staging driver,
+Cc the staging mailing list as well is highly recommended:
+>> Linux Driver Project Developer List 
+
+Mount options
+=
+
+fault_injection=%d Enable fault injection in all supported types with
+   specified injection rate. Supported injection type:
+   Type_NameType_Value
+   FAULT_KMALLOC0x1
+(no)user_xattr Setup Extended User Attributes. Note: xattr is enabled
+   by default if CONFIG_EROFS_FS_XATTR is selected.
+(no)aclSetup POSIX Access Control List. Note: acl is enabled
+   by default if CONFIG_EROFS_FS_POSIX_ACL is selected.
+
+On-disk details
+===
+
+Summary
+---
+Different from other read-only file systems, an EROFS volume is designed
+to be as simple as possible:
+
+|-> aligned with the block size
+   
+  | |SB| | ... | Metadata | ... | Data | Metadata | ... | Data |
+  |_|__|_|_|__|_|__|__|_|__|
+  0 +1K
+
+All data areas should be aligned with the block size, but metadata areas
+may not. All metadatas can be now observed in two different spaces (views):
+ 1. Inode metadata space
+Each valid inode should be aligned with an inode slot, which is a fixed
+value (32 bytes) and designed to be kept in line with v1 inode size.
+
+Each inode can be directly found with the following formula:
+ inode offset = meta_blkaddr * block_size + 32 * nid
+
+|-> aligned with 8B
+   |-> followed closely
++ meta_blkaddr blocks  |-> another slot
+ _
+|  ...   | inode |  xattrs  | extents  | data inline | ... | inode ...
+||___|(optional)|(optional)|__(optional)_|_|__
+ |-> aligned with the inode slot size
+  .   .
+. 

Re: [PATCH 13/14] staging: android: ion: Do not sync CPU cache on map/unmap

2019-01-14 Thread Liam Mark
On Fri, 11 Jan 2019, Andrew F. Davis wrote:

> Buffers may not be mapped from the CPU so skip cache maintenance here.
> Accesses from the CPU to a cached heap should be bracketed with
> {begin,end}_cpu_access calls so maintenance should not be needed anyway.
> 
> Signed-off-by: Andrew F. Davis 
> ---
>  drivers/staging/android/ion/ion.c | 7 ---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/staging/android/ion/ion.c 
> b/drivers/staging/android/ion/ion.c
> index 14e48f6eb734..09cb5a8e2b09 100644
> --- a/drivers/staging/android/ion/ion.c
> +++ b/drivers/staging/android/ion/ion.c
> @@ -261,8 +261,8 @@ static struct sg_table *ion_map_dma_buf(struct 
> dma_buf_attachment *attachment,
>  
>   table = a->table;
>  
> - if (!dma_map_sg(attachment->dev, table->sgl, table->nents,
> - direction))
> + if (!dma_map_sg_attrs(attachment->dev, table->sgl, table->nents,
> +   direction, DMA_ATTR_SKIP_CPU_SYNC))

Unfortunately I don't think you can do this for a couple reasons.
You can't rely on {begin,end}_cpu_access calls to do cache maintenance.
If the calls to {begin,end}_cpu_access were made before the call to 
dma_buf_attach then there won't have been a device attached so the calls 
to {begin,end}_cpu_access won't have done any cache maintenance.

Also ION no longer provides DMA ready memory, so if you are not doing CPU 
access then there is no requirement (that I am aware of) for you to call 
{begin,end}_cpu_access before passing the buffer to the device and if this 
buffer is cached and your device is not IO-coherent then the cache maintenance
in ion_map_dma_buf and ion_unmap_dma_buf is required.

>   return ERR_PTR(-ENOMEM);
>  
>   return table;
> @@ -272,7 +272,8 @@ static void ion_unmap_dma_buf(struct dma_buf_attachment 
> *attachment,
> struct sg_table *table,
> enum dma_data_direction direction)
>  {
> - dma_unmap_sg(attachment->dev, table->sgl, table->nents, direction);
> + dma_unmap_sg_attrs(attachment->dev, table->sgl, table->nents,
> +direction, DMA_ATTR_SKIP_CPU_SYNC);
>  }
>  
>  static int ion_mmap(struct dma_buf *dmabuf, struct vm_area_struct *vma)
> -- 
> 2.19.1
> 
> ___
> devel mailing list
> de...@linuxdriverproject.org
> http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
> 

Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v3] binder: create node flag to request sender's security context

2019-01-14 Thread Todd Kjos
To allow servers to verify client identity, allow a node
flag to be set that causes the sender's security context
to be delivered with the transaction. The BR_TRANSACTION
command is extended in BR_TRANSACTION_SEC_CTX to
contain a pointer to the security context string.

Signed-off-by: Todd Kjos 
---
v2: fix 32-bit build warning
v3: fix smatch warning on unitialized struct element

 drivers/android/binder.c| 106 ++--
 include/uapi/linux/android/binder.h |  19 +
 2 files changed, 102 insertions(+), 23 deletions(-)

diff --git a/drivers/android/binder.c b/drivers/android/binder.c
index cdfc87629efb8..5f6ef5e63b91e 100644
--- a/drivers/android/binder.c
+++ b/drivers/android/binder.c
@@ -329,6 +329,8 @@ struct binder_error {
  *(invariant after initialized)
  * @min_priority: minimum scheduling priority
  *(invariant after initialized)
+ * @txn_security_ctx: require sender's security context
+ *(invariant after initialized)
  * @async_todo:   list of async work items
  *(protected by @proc->inner_lock)
  *
@@ -365,6 +367,7 @@ struct binder_node {
 * invariant after initialization
 */
u8 accept_fds:1;
+   u8 txn_security_ctx:1;
u8 min_priority;
};
bool has_async_transaction;
@@ -615,6 +618,7 @@ struct binder_transaction {
longsaved_priority;
kuid_t  sender_euid;
struct list_head fd_fixups;
+   binder_uintptr_t security_ctx;
/**
 * @lock:  protects @from, @to_proc, and @to_thread
 *
@@ -1152,6 +1156,7 @@ static struct binder_node *binder_init_node_ilocked(
node->work.type = BINDER_WORK_NODE;
node->min_priority = flags & FLAT_BINDER_FLAG_PRIORITY_MASK;
node->accept_fds = !!(flags & FLAT_BINDER_FLAG_ACCEPTS_FDS);
+   node->txn_security_ctx = !!(flags & FLAT_BINDER_FLAG_TXN_SECURITY_CTX);
spin_lock_init(>lock);
INIT_LIST_HEAD(>work.entry);
INIT_LIST_HEAD(>async_todo);
@@ -2778,6 +2783,8 @@ static void binder_transaction(struct binder_proc *proc,
binder_size_t last_fixup_min_off = 0;
struct binder_context *context = proc->context;
int t_debug_id = atomic_inc_return(_last_id);
+   char *secctx = NULL;
+   u32 secctx_sz = 0;
 
e = binder_transaction_log_add(_transaction_log);
e->debug_id = t_debug_id;
@@ -3020,6 +3027,20 @@ static void binder_transaction(struct binder_proc *proc,
t->flags = tr->flags;
t->priority = task_nice(current);
 
+   if (target_node && target_node->txn_security_ctx) {
+   u32 secid;
+
+   security_task_getsecid(proc->tsk, );
+   ret = security_secid_to_secctx(secid, , _sz);
+   if (ret) {
+   return_error = BR_FAILED_REPLY;
+   return_error_param = ret;
+   return_error_line = __LINE__;
+   goto err_get_secctx_failed;
+   }
+   extra_buffers_size += ALIGN(secctx_sz, sizeof(u64));
+   }
+
trace_binder_transaction(reply, t, target_node);
 
t->buffer = binder_alloc_new_buf(_proc->alloc, tr->data_size,
@@ -3036,6 +3057,19 @@ static void binder_transaction(struct binder_proc *proc,
t->buffer = NULL;
goto err_binder_alloc_buf_failed;
}
+   if (secctx) {
+   size_t buf_offset = ALIGN(tr->data_size, sizeof(void *)) +
+   ALIGN(tr->offsets_size, sizeof(void *)) +
+   ALIGN(extra_buffers_size, sizeof(void *)) -
+   ALIGN(secctx_sz, sizeof(u64));
+   char *kptr = t->buffer->data + buf_offset;
+
+   t->security_ctx = (uintptr_t)kptr +
+   binder_alloc_get_user_buffer_offset(_proc->alloc);
+   memcpy(kptr, secctx, secctx_sz);
+   security_release_secctx(secctx, secctx_sz);
+   secctx = NULL;
+   }
t->buffer->debug_id = t->debug_id;
t->buffer->transaction = t;
t->buffer->target_node = target_node;
@@ -3305,6 +3339,9 @@ static void binder_transaction(struct binder_proc *proc,
t->buffer->transaction = NULL;
binder_alloc_free_buf(_proc->alloc, t->buffer);
 err_binder_alloc_buf_failed:
+   if (secctx)
+   security_release_secctx(secctx, secctx_sz);
+err_get_secctx_failed:
kfree(tcomplete);
binder_stats_deleted(BINDER_STAT_TRANSACTION_COMPLETE);
 err_alloc_tcomplete_failed:
@@ -4036,11 +4073,13 @@ static int binder_thread_read(struct binder_proc *proc,
 
while (1) {
uint32_t cmd;
-   struct binder_transaction_data tr;
+   struct binder_transaction_data_secctx tr;
+   

Re: [PATCH v6 0/2] greybus: gpio: Switch to the gpio descriptor interface

2019-01-14 Thread Nishad Kamdar
On Mon, Jan 14, 2019 at 10:05:17AM +0100, Johan Hovold wrote:
> On Fri, Jan 11, 2019 at 09:03:16PM +0530, Nishad Kamdar wrote:
> > This patch series converts uses of the old GPIO API to the GPIO
> > descriptor API. It also converts the GPIO driver to use the
> > GPIO irqchip library GPIOLIB_IRQCHIP instead of repimplementing
> > the same.
> > 
> > Changes in v6:
> >  - Patchset now contains two patches as the patch
> >1 has been accepted.
> 
> All three patches look good now, but since Greg picks these up directly
> and applies them to the staging tree, it is best if you submit all three
> patches (with my reviewed-by tag) in a series.
> 
Sure, I'll do that.
> One last resend as v7?
> 
> Thanks again for doing this.
> 
> Johan

Thanks for all the reviews.

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


Re: [PATCH v7 0/3] greybus: gpio: Switch to the gpio descriptor interface

2019-01-14 Thread Johan Hovold
On Mon, Jan 14, 2019 at 08:25:07PM +0530, Nishad Kamdar wrote:
> This patch series converts uses of the old GPIO API to the GPIO
> descriptor API. It also converts the GPIO driver to use the
> GPIO irqchip library GPIOLIB_IRQCHIP instead of repimplementing
> the same.
> 
> Chnages in v7:
>  - Combine the three patches together.

Thanks for resending, all looks good now.

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


[PATCH v7 3/3] staging: greybus: arche-platform: Switch to the gpio descriptor interface

2019-01-14 Thread Nishad Kamdar
Use the gpiod interface instead of the deprecated old non-descriptor
interface while continuing to ignore gpio flags from device tree in
"svc_reset_onoff()" for now.

Reviewed-by: Johan Hovold 
Signed-off-by: Nishad Kamdar 
---
Changes in v7:
  - No change.
Changes in v6:
  - Make error messages consistent.
Changes in v5:
  - Change the commit message.
  - Restore the names of the gpio device-tree properties without
the "-gpio" suffix.
Changes in v4:
 - Move 'gpio_desc *svc_sysboot' below the reset flag
   as it is more logical to have reset flag below
   reset gpio.
 - Remove a few unnecessary line breaks.
Changes in v3:
 - Add this patch to a patchset.
Changes in v2:
 - Move comment to the same line as to what it applies to.
---
 drivers/staging/greybus/arche-platform.c | 124 ---
 1 file changed, 41 insertions(+), 83 deletions(-)

diff --git a/drivers/staging/greybus/arche-platform.c 
b/drivers/staging/greybus/arche-platform.c
index 4c36e88766e7..6eb842040c22 100644
--- a/drivers/staging/greybus/arche-platform.c
+++ b/drivers/staging/greybus/arche-platform.c
@@ -8,10 +8,9 @@
 
 #include 
 #include 
-#include 
+#include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -45,14 +44,14 @@ enum svc_wakedetect_state {
 
 struct arche_platform_drvdata {
/* Control GPIO signals to and from AP <=> SVC */
-   int svc_reset_gpio;
+   struct gpio_desc *svc_reset;
bool is_reset_act_hi;
-   int svc_sysboot_gpio;
-   int wake_detect_gpio; /* bi-dir,maps to WAKE_MOD & WAKE_FRAME signals */
+   struct gpio_desc *svc_sysboot;
+   struct gpio_desc *wake_detect; /* bi-dir,maps to WAKE_MOD & WAKE_FRAME 
signals */
 
enum arche_platform_state state;
 
-   int svc_refclk_req;
+   struct gpio_desc *svc_refclk_req;
struct clk *svc_ref_clk;
 
struct pinctrl *pinctrl;
@@ -85,9 +84,9 @@ static void arche_platform_set_wake_detect_state(
arche_pdata->wake_detect_state = state;
 }
 
-static inline void svc_reset_onoff(unsigned int gpio, bool onoff)
+static inline void svc_reset_onoff(struct gpio_desc *gpio, bool onoff)
 {
-   gpio_set_value(gpio, onoff);
+   gpiod_set_raw_value(gpio, onoff);
 }
 
 static int apb_cold_boot(struct device *dev, void *data)
@@ -116,7 +115,6 @@ static int apb_poweroff(struct device *dev, void *data)
 static void arche_platform_wd_irq_en(struct arche_platform_drvdata 
*arche_pdata)
 {
/* Enable interrupt here, to read event back from SVC */
-   gpio_direction_input(arche_pdata->wake_detect_gpio);
enable_irq(arche_pdata->wake_detect_irq);
 }
 
@@ -160,7 +158,7 @@ static irqreturn_t arche_platform_wd_irq(int irq, void 
*devid)
 
spin_lock_irqsave(_pdata->wake_lock, flags);
 
-   if (gpio_get_value(arche_pdata->wake_detect_gpio)) {
+   if (gpiod_get_value(arche_pdata->wake_detect)) {
/* wake/detect rising */
 
/*
@@ -224,10 +222,9 @@ arche_platform_coldboot_seq(struct arche_platform_drvdata 
*arche_pdata)
 
dev_info(arche_pdata->dev, "Booting from cold boot state\n");
 
-   svc_reset_onoff(arche_pdata->svc_reset_gpio,
-   arche_pdata->is_reset_act_hi);
+   svc_reset_onoff(arche_pdata->svc_reset, arche_pdata->is_reset_act_hi);
 
-   gpio_set_value(arche_pdata->svc_sysboot_gpio, 0);
+   gpiod_set_value(arche_pdata->svc_sysboot, 0);
usleep_range(100, 200);
 
ret = clk_prepare_enable(arche_pdata->svc_ref_clk);
@@ -238,8 +235,7 @@ arche_platform_coldboot_seq(struct arche_platform_drvdata 
*arche_pdata)
}
 
/* bring SVC out of reset */
-   svc_reset_onoff(arche_pdata->svc_reset_gpio,
-   !arche_pdata->is_reset_act_hi);
+   svc_reset_onoff(arche_pdata->svc_reset, !arche_pdata->is_reset_act_hi);
 
arche_platform_set_state(arche_pdata, ARCHE_PLATFORM_STATE_ACTIVE);
 
@@ -259,10 +255,9 @@ arche_platform_fw_flashing_seq(struct 
arche_platform_drvdata *arche_pdata)
 
dev_info(arche_pdata->dev, "Switching to FW flashing state\n");
 
-   svc_reset_onoff(arche_pdata->svc_reset_gpio,
-   arche_pdata->is_reset_act_hi);
+   svc_reset_onoff(arche_pdata->svc_reset, arche_pdata->is_reset_act_hi);
 
-   gpio_set_value(arche_pdata->svc_sysboot_gpio, 1);
+   gpiod_set_value(arche_pdata->svc_sysboot, 1);
 
usleep_range(100, 200);
 
@@ -273,8 +268,7 @@ arche_platform_fw_flashing_seq(struct 
arche_platform_drvdata *arche_pdata)
return ret;
}
 
-   svc_reset_onoff(arche_pdata->svc_reset_gpio,
-   !arche_pdata->is_reset_act_hi);
+   svc_reset_onoff(arche_pdata->svc_reset, !arche_pdata->is_reset_act_hi);
 
arche_platform_set_state(arche_pdata, ARCHE_PLATFORM_STATE_FW_FLASHING);
 
@@ -305,8 +299,7 @@ arche_platform_poweroff_seq(struct arche_platform_drvdata 
*arche_pdata)

[PATCH v7 2/3] staging: greybus: arche-apb-ctrl.c: Switch to the gpio descriptor interface

2019-01-14 Thread Nishad Kamdar
Use the gpiod interface instead of the deprecated old non-descriptor
interface while continuing to ignore gpio flags from device tree in
functions "deassert_reset()" and "assert_reset()" for now.

Reviewed-by: Johan Hovold 
Signed-off-by: Nishad Kamdar 
---
Changes in v7:
 - No change.
Changes in v6:
 - Remove some unnecessary line breaks.
Changes in v5:
 - Change the commit message.
 - Restore the names of the gpio device-tree properties without
   the "-gpio" suffix.
Changes in v4:
 - Use gpiod_set_raw_value() for deassert_reset() and
   assert_reset() as gpiod_set_value() will change the
   sematics of these calls by taking any gpio flags
   into account.
 - Remove some unnecesssary line breaks.
 - Restore 'spi_en' gpio check in fw_flashing_seq()
   as it is currently optional.
Changes in v3:
 - Add this patch in a patchset.
Changes in v2:
 - Resolved compilation errors.
---
 drivers/staging/greybus/arche-apb-ctrl.c | 152 +--
 1 file changed, 61 insertions(+), 91 deletions(-)

diff --git a/drivers/staging/greybus/arche-apb-ctrl.c 
b/drivers/staging/greybus/arche-apb-ctrl.c
index be5ffed90bcf..bbf3ba744fc4 100644
--- a/drivers/staging/greybus/arche-apb-ctrl.c
+++ b/drivers/staging/greybus/arche-apb-ctrl.c
@@ -8,9 +8,8 @@
 
 #include 
 #include 
-#include 
+#include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -24,12 +23,12 @@ static void apb_bootret_deassert(struct device *dev);
 
 struct arche_apb_ctrl_drvdata {
/* Control GPIO signals to and from AP <=> AP Bridges */
-   int resetn_gpio;
-   int boot_ret_gpio;
-   int pwroff_gpio;
-   int wake_in_gpio;
-   int wake_out_gpio;
-   int pwrdn_gpio;
+   struct gpio_desc *resetn;
+   struct gpio_desc *boot_ret;
+   struct gpio_desc *pwroff;
+   struct gpio_desc *wake_in;
+   struct gpio_desc *wake_out;
+   struct gpio_desc *pwrdn;
 
enum arche_platform_state state;
bool init_disabled;
@@ -37,28 +36,28 @@ struct arche_apb_ctrl_drvdata {
struct regulator *vcore;
struct regulator *vio;
 
-   int clk_en_gpio;
+   struct gpio_desc *clk_en;
struct clk *clk;
 
struct pinctrl *pinctrl;
struct pinctrl_state *pin_default;
 
/* V2: SPI Bus control  */
-   int spi_en_gpio;
+   struct gpio_desc *spi_en;
bool spi_en_polarity_high;
 };
 
 /*
  * Note that these low level api's are active high
  */
-static inline void deassert_reset(unsigned int gpio)
+static inline void deassert_reset(struct gpio_desc *gpio)
 {
-   gpio_set_value(gpio, 1);
+   gpiod_set_raw_value(gpio, 1);
 }
 
-static inline void assert_reset(unsigned int gpio)
+static inline void assert_reset(struct gpio_desc *gpio)
 {
-   gpio_set_value(gpio, 0);
+   gpiod_set_raw_value(gpio, 0);
 }
 
 /*
@@ -75,11 +74,10 @@ static int coldboot_seq(struct platform_device *pdev)
return 0;
 
/* Hold APB in reset state */
-   assert_reset(apb->resetn_gpio);
+   assert_reset(apb->resetn);
 
-   if (apb->state == ARCHE_PLATFORM_STATE_FW_FLASHING &&
-   gpio_is_valid(apb->spi_en_gpio))
-   devm_gpio_free(dev, apb->spi_en_gpio);
+   if (apb->state == ARCHE_PLATFORM_STATE_FW_FLASHING && apb->spi_en)
+   devm_gpiod_put(dev, apb->spi_en);
 
/* Enable power to APB */
if (!IS_ERR(apb->vcore)) {
@@ -101,13 +99,13 @@ static int coldboot_seq(struct platform_device *pdev)
apb_bootret_deassert(dev);
 
/* On DB3 clock was not mandatory */
-   if (gpio_is_valid(apb->clk_en_gpio))
-   gpio_set_value(apb->clk_en_gpio, 1);
+   if (apb->clk_en)
+   gpiod_set_value(apb->clk_en, 1);
 
usleep_range(100, 200);
 
/* deassert reset to APB : Active-low signal */
-   deassert_reset(apb->resetn_gpio);
+   deassert_reset(apb->resetn);
 
apb->state = ARCHE_PLATFORM_STATE_ACTIVE;
 
@@ -136,25 +134,25 @@ static int fw_flashing_seq(struct platform_device *pdev)
return ret;
}
 
-   if (gpio_is_valid(apb->spi_en_gpio)) {
+   if (apb->spi_en) {
unsigned long flags;
 
if (apb->spi_en_polarity_high)
-   flags = GPIOF_OUT_INIT_HIGH;
+   flags = GPIOD_OUT_HIGH;
else
-   flags = GPIOF_OUT_INIT_LOW;
+   flags = GPIOD_OUT_LOW;
 
-   ret = devm_gpio_request_one(dev, apb->spi_en_gpio,
-   flags, "apb_spi_en");
-   if (ret) {
-   dev_err(dev, "Failed requesting SPI bus en gpio %d\n",
-   apb->spi_en_gpio);
+   apb->spi_en = devm_gpiod_get(dev, "spi-en", flags);
+   if (IS_ERR(apb->spi_en)) {
+   ret = PTR_ERR(apb->spi_en);
+   dev_err(dev, "Failed requesting SPI bus en GPIO: %d\n",
+ 

[PATCH v7 1/3] staging: greybus: gpio: switch GPIO portions to use GPIOLIB_IRQCHIP

2019-01-14 Thread Nishad Kamdar
Convert the GPIO driver to use the GPIO irqchip library
GPIOLIB_IRQCHIP instead of reimplementing the same.

Reviewed-by: Johan Hovold 
Signed-off-by: Nishad Kamdar 
---
Changes in v7:
 - No change.
Changes in v5:
 - Restore "struct irq_chip irqc" in "struct gb_gpio_controller"
   This is because we cannot use the gpio-chip irqchip, as that
   will register the irqchip automatically and possibly in an
   incompatible way.
Changes in v4:
 - Remove changes related to conversion to gpiochip_get_data() to
   include it as a new patch.
 - Remove the 'struct irq_chip' field from 'struct gb_gpio_controller'
   as struct gpio_chip will have an irqchip whenever
   CONFIG_GPIOLIB_IRQCHIP is selected.
 - Update the TODO file as per the changes.
Changes in v3:
 - Combine patches as into a patch series.
Changes in v2:
 - Retained irq.h and irqdomain.h headers.
 - Dropped function gb_gpio_irqchip_add() and
   called gpiochip_irqchip_add() from probe().
 - Referred 
https://lkml.kernel.org/r/1476054589-28422-1-git-send-email-linus.wall...@linaro.org.
---
 drivers/staging/greybus/Kconfig |   1 +
 drivers/staging/greybus/TODO|   2 -
 drivers/staging/greybus/gpio.c  | 156 ++--
 3 files changed, 11 insertions(+), 148 deletions(-)

diff --git a/drivers/staging/greybus/Kconfig b/drivers/staging/greybus/Kconfig
index ab096bcef98c..b571e4e8060b 100644
--- a/drivers/staging/greybus/Kconfig
+++ b/drivers/staging/greybus/Kconfig
@@ -148,6 +148,7 @@ if GREYBUS_BRIDGED_PHY
 config GREYBUS_GPIO
tristate "Greybus GPIO Bridged PHY driver"
depends on GPIOLIB
+   select GPIOLIB_IRQCHIP
---help---
  Select this option if you have a device that follows the
  Greybus GPIO Bridged PHY Class specification.
diff --git a/drivers/staging/greybus/TODO b/drivers/staging/greybus/TODO
index 3b90a5711998..31f1f2cb401c 100644
--- a/drivers/staging/greybus/TODO
+++ b/drivers/staging/greybus/TODO
@@ -1,5 +1,3 @@
 * Convert all uses of the old GPIO API from  to the
   GPIO descriptor API in  and look up GPIO
   lines from device tree or ACPI.
-* Convert the GPIO driver to use the GPIO irqchip library
-  GPIOLIB_IRQCHIP instead of reimplementing the same.
diff --git a/drivers/staging/greybus/gpio.c b/drivers/staging/greybus/gpio.c
index e110681e6f86..3151004d26fb 100644
--- a/drivers/staging/greybus/gpio.c
+++ b/drivers/staging/greybus/gpio.c
@@ -9,9 +9,9 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
+#include 
 #include 
 
 #include "greybus.h"
@@ -39,11 +39,6 @@ struct gb_gpio_controller {
 
struct gpio_chipchip;
struct irq_chip irqc;
-   struct irq_chip *irqchip;
-   struct irq_domain   *irqdomain;
-   unsigned intirq_base;
-   irq_flow_handler_t  irq_handler;
-   unsigned intirq_default_type;
struct mutexirq_lock;
 };
 #define gpio_chip_to_gb_gpio_controller(chip) \
@@ -391,7 +386,7 @@ static int gb_gpio_request_handler(struct gb_operation *op)
return -EINVAL;
}
 
-   irq = irq_find_mapping(ggc->irqdomain, event->which);
+   irq = irq_find_mapping(ggc->chip.irq.domain, event->which);
if (!irq) {
dev_err(dev, "failed to find IRQ\n");
return -EINVAL;
@@ -506,135 +501,6 @@ static int gb_gpio_controller_setup(struct 
gb_gpio_controller *ggc)
return ret;
 }
 
-/**
- * gb_gpio_irq_map() - maps an IRQ into a GB gpio irqchip
- * @d: the irqdomain used by this irqchip
- * @irq: the global irq number used by this GB gpio irqchip irq
- * @hwirq: the local IRQ/GPIO line offset on this GB gpio
- *
- * This function will set up the mapping for a certain IRQ line on a
- * GB gpio by assigning the GB gpio as chip data, and using the irqchip
- * stored inside the GB gpio.
- */
-static int gb_gpio_irq_map(struct irq_domain *domain, unsigned int irq,
-  irq_hw_number_t hwirq)
-{
-   struct gpio_chip *chip = domain->host_data;
-   struct gb_gpio_controller *ggc = gpio_chip_to_gb_gpio_controller(chip);
-
-   irq_set_chip_data(irq, ggc);
-   irq_set_chip_and_handler(irq, ggc->irqchip, ggc->irq_handler);
-   irq_set_noprobe(irq);
-   /*
-* No set-up of the hardware will happen if IRQ_TYPE_NONE
-* is passed as default type.
-*/
-   if (ggc->irq_default_type != IRQ_TYPE_NONE)
-   irq_set_irq_type(irq, ggc->irq_default_type);
-
-   return 0;
-}
-
-static void gb_gpio_irq_unmap(struct irq_domain *d, unsigned int irq)
-{
-   irq_set_chip_and_handler(irq, NULL, NULL);
-   irq_set_chip_data(irq, NULL);
-}
-
-static const struct irq_domain_ops gb_gpio_domain_ops = {
-   .map= gb_gpio_irq_map,
-   .unmap  = gb_gpio_irq_unmap,
-};
-
-/**
- * gb_gpio_irqchip_remove() - removes an irqchip added to a gb_gpio_controller
- * @ggc: the gb_gpio_controller to remove the irqchip from
- *
- * This 

[PATCH v7 0/3] greybus: gpio: Switch to the gpio descriptor interface

2019-01-14 Thread Nishad Kamdar
This patch series converts uses of the old GPIO API to the GPIO
descriptor API. It also converts the GPIO driver to use the
GPIO irqchip library GPIOLIB_IRQCHIP instead of repimplementing
the same.

Chnages in v7:
 - Combine the three patches together.
Changes in v6:
 - Patchset now contains two patches as the patch
   1 has been accepted.
 - Changes mentioned in individual patches of the set.
Changes in v5:
 - Drop the patch which uses gpiochip_get_data() in place of
   gpio_chip_to_gb_gpio_controller() as of now.
 - This is because it currently breaks the driver, since
   gpiochip_add() sets the data pointer to NULL.  
Changes in v4:
 - Changes mentioned in individual patches of the set.
Changes in v3:
 - Combines the latest versions of the three greybus patches together
   in a patch series.

Nishad Kamdar (3):
  staging: greybus: gpio: switch GPIO portions to use GPIOLIB_IRQCHIP
  staging: greybus: arche-apb-ctrl.c: Switch to the gpio descriptor
interface
  staging: greybus: arche-platform: Switch to the gpio descriptor
interface

 drivers/staging/greybus/Kconfig  |   1 +
 drivers/staging/greybus/TODO |   2 -
 drivers/staging/greybus/arche-apb-ctrl.c | 152 +-
 drivers/staging/greybus/arche-platform.c | 124 ++
 drivers/staging/greybus/gpio.c   | 156 ++-
 5 files changed, 113 insertions(+), 322 deletions(-)

-- 
2.17.1

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


[PATCH RFC 3/4] media: cedrus: Request access to reference buffers when decoding

2019-01-14 Thread Paul Kocialkowski
Because we need to request and release access to reference buffers
that are backed by a dma-buf import, keep track of the buffers used
as reference and add the appropriate calls in the device_run and
job_done m2m callbacks. The latter is introduced for this purpose.

Signed-off-by: Paul Kocialkowski 
---
 drivers/staging/media/sunxi/cedrus/cedrus.c|  1 +
 drivers/staging/media/sunxi/cedrus/cedrus.h|  1 +
 .../staging/media/sunxi/cedrus/cedrus_dec.c| 18 ++
 .../staging/media/sunxi/cedrus/cedrus_dec.h|  1 +
 .../staging/media/sunxi/cedrus/cedrus_mpeg2.c  |  8 
 5 files changed, 29 insertions(+)

diff --git a/drivers/staging/media/sunxi/cedrus/cedrus.c 
b/drivers/staging/media/sunxi/cedrus/cedrus.c
index ff11cbeba205..a2c75eb01c2c 100644
--- a/drivers/staging/media/sunxi/cedrus/cedrus.c
+++ b/drivers/staging/media/sunxi/cedrus/cedrus.c
@@ -250,6 +250,7 @@ static const struct video_device cedrus_video_device = {
 
 static const struct v4l2_m2m_ops cedrus_m2m_ops = {
.device_run = cedrus_device_run,
+   .job_done   = cedrus_job_done,
 };
 
 static const struct media_device_ops cedrus_m2m_media_ops = {
diff --git a/drivers/staging/media/sunxi/cedrus/cedrus.h 
b/drivers/staging/media/sunxi/cedrus/cedrus.h
index 4aedd24a9848..c1ce3c4ae2a1 100644
--- a/drivers/staging/media/sunxi/cedrus/cedrus.h
+++ b/drivers/staging/media/sunxi/cedrus/cedrus.h
@@ -77,6 +77,7 @@ struct cedrus_ctx {
struct v4l2_ctrl**ctrls;
 
struct vb2_buffer   *dst_bufs[VIDEO_MAX_FRAME];
+   boolreference_bufs[VIDEO_MAX_FRAME];
 };
 
 struct cedrus_dec_ops {
diff --git a/drivers/staging/media/sunxi/cedrus/cedrus_dec.c 
b/drivers/staging/media/sunxi/cedrus/cedrus_dec.c
index 2c295286766c..90bf51e71f4f 100644
--- a/drivers/staging/media/sunxi/cedrus/cedrus_dec.c
+++ b/drivers/staging/media/sunxi/cedrus/cedrus_dec.c
@@ -41,6 +41,7 @@ void cedrus_device_run(void *priv)
struct cedrus_dev *dev = ctx->dev;
struct cedrus_run run = {};
struct media_request *src_req;
+   unsigned int i;
 
run.src = v4l2_m2m_next_src_buf(ctx->fh.m2m_ctx);
run.dst = v4l2_m2m_next_dst_buf(ctx->fh.m2m_ctx);
@@ -63,10 +64,17 @@ void cedrus_device_run(void *priv)
break;
}
 
+   for (i = 0; i < VIDEO_MAX_FRAME; i++)
+   ctx->reference_bufs[i] = false;
+
v4l2_m2m_buf_copy_data(run.src, run.dst, true);
 
dev->dec_ops[ctx->current_codec]->setup(ctx, );
 
+   for (i = 0; i < VIDEO_MAX_FRAME; i++)
+   if (ctx->reference_bufs[i] && ctx->dst_bufs[i])
+   vb2_buffer_access_request(ctx->dst_bufs[i]);
+
/* Complete request(s) controls if needed. */
 
if (src_req)
@@ -74,3 +82,13 @@ void cedrus_device_run(void *priv)
 
dev->dec_ops[ctx->current_codec]->trigger(ctx);
 }
+
+void cedrus_job_done(void *priv)
+{
+   struct cedrus_ctx *ctx = priv;
+   unsigned int i;
+
+   for (i = 0; i < VIDEO_MAX_FRAME; i++)
+   if (ctx->reference_bufs[i] && ctx->dst_bufs[i])
+   vb2_buffer_access_release(ctx->dst_bufs[i]);
+}
diff --git a/drivers/staging/media/sunxi/cedrus/cedrus_dec.h 
b/drivers/staging/media/sunxi/cedrus/cedrus_dec.h
index 8d0fc248220f..9265f28e6dbe 100644
--- a/drivers/staging/media/sunxi/cedrus/cedrus_dec.h
+++ b/drivers/staging/media/sunxi/cedrus/cedrus_dec.h
@@ -19,5 +19,6 @@
 int cedrus_reference_index_find(struct vb2_queue *queue,
struct vb2_buffer *vb2_buf, u64 timestamp);
 void cedrus_device_run(void *priv);
+void cedrus_job_done(void *priv);
 
 #endif
diff --git a/drivers/staging/media/sunxi/cedrus/cedrus_mpeg2.c 
b/drivers/staging/media/sunxi/cedrus/cedrus_mpeg2.c
index 81c66a8aa1ac..2e7deded17aa 100644
--- a/drivers/staging/media/sunxi/cedrus/cedrus_mpeg2.c
+++ b/drivers/staging/media/sunxi/cedrus/cedrus_mpeg2.c
@@ -162,6 +162,10 @@ static void cedrus_mpeg2_setup(struct cedrus_ctx *ctx, 
struct cedrus_run *run)
/* Forward and backward prediction reference buffers. */
forward_idx = cedrus_reference_index_find(cap_q, >dst->vb2_buf,
  slice_params->forward_ref_ts);
+   if (forward_idx < 0)
+   return;
+
+   ctx->reference_bufs[forward_idx] = true;
 
fwd_luma_addr = cedrus_dst_buf_addr(ctx, forward_idx, 0);
fwd_chroma_addr = cedrus_dst_buf_addr(ctx, forward_idx, 1);
@@ -171,6 +175,10 @@ static void cedrus_mpeg2_setup(struct cedrus_ctx *ctx, 
struct cedrus_run *run)
 
backward_idx = cedrus_reference_index_find(cap_q, >dst->vb2_buf,
   
slice_params->backward_ref_ts);
+   if (forward_idx < 0)
+   return;
+
+   ctx->reference_bufs[backward_idx] = true;
 
bwd_luma_addr = cedrus_dst_buf_addr(ctx, backward_idx, 0);
bwd_chroma_addr = 

[PATCH RFC 2/4] media: v4l2-mem2mem: Add an optional job_done operation

2019-01-14 Thread Paul Kocialkowski
Introduce a new optional job_done operation, which allows calling back
to the driver when a job is done. Since the job might be completed
from interrupt context where some operations are not available, having
a callback from non-atomic context allows performing these operations
upon completion of a job. This is particularly useful for releasing
access to a reference buffer, which cannot be done in atomic context.

Use the already existing v4l2_m2m_device_run_work work queue for that
and clear the M2M device current context after calling job_done in the
worker thread, so that the private data can be passed to the operation.

Delaying the current context clearing should not be a problem since the
next call to v4l2_m2m_try_run happens right after that.

Signed-off-by: Paul Kocialkowski 
---
 drivers/media/v4l2-core/v4l2-mem2mem.c | 8 ++--
 include/media/v4l2-mem2mem.h   | 4 
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/drivers/media/v4l2-core/v4l2-mem2mem.c 
b/drivers/media/v4l2-core/v4l2-mem2mem.c
index 631f4e2aa942..d5bccb0192f9 100644
--- a/drivers/media/v4l2-core/v4l2-mem2mem.c
+++ b/drivers/media/v4l2-core/v4l2-mem2mem.c
@@ -376,6 +376,11 @@ static void v4l2_m2m_device_run_work(struct work_struct 
*work)
struct v4l2_m2m_dev *m2m_dev =
container_of(work, struct v4l2_m2m_dev, job_work);
 
+   if (m2m_dev->m2m_ops->job_done && m2m_dev->curr_ctx)
+   m2m_dev->m2m_ops->job_done(m2m_dev->curr_ctx->priv);
+
+   m2m_dev->curr_ctx = NULL;
+
v4l2_m2m_try_run(m2m_dev);
 }
 
@@ -431,8 +436,7 @@ void v4l2_m2m_job_finish(struct v4l2_m2m_dev *m2m_dev,
list_del(_dev->curr_ctx->queue);
m2m_dev->curr_ctx->job_flags &= ~(TRANS_QUEUED | TRANS_RUNNING);
wake_up(_dev->curr_ctx->finished);
-   m2m_dev->curr_ctx = NULL;
-
+   /* The current context pointer is cleared after the job_done step. */
spin_unlock_irqrestore(_dev->job_spinlock, flags);
 
/* This instance might have more buffers ready, but since we do not
diff --git a/include/media/v4l2-mem2mem.h b/include/media/v4l2-mem2mem.h
index 43e447dcf69d..261bcd661b2d 100644
--- a/include/media/v4l2-mem2mem.h
+++ b/include/media/v4l2-mem2mem.h
@@ -40,11 +40,15 @@
  * v4l2_m2m_job_finish() (as if the transaction ended normally).
  * This function does not have to (and will usually not) wait
  * until the device enters a state when it can be stopped.
+ * @job_done:  optional. Informs the driver that the current job was completed.
+ * This can be useful to release access to extra buffers that were
+ * required for the job, such as reference buffers for decoding.
  */
 struct v4l2_m2m_ops {
void (*device_run)(void *priv);
int (*job_ready)(void *priv);
void (*job_abort)(void *priv);
+   void (*job_done)(void *priv);
 };
 
 struct video_device;
-- 
2.20.1

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


[PATCH RFC 1/4] media: vb2: Add helpers to access unselected buffers

2019-01-14 Thread Paul Kocialkowski
Introduce helpers to request and release access to buffers that are
not currently selected as current output or capture buffers.

This is useful to ensure proper access to buffers imported via dma-buf
that are used as reference and thus require associated map/unmap calls
before access.

Signed-off-by: Paul Kocialkowski 
---
 .../media/common/videobuf2/videobuf2-core.c   | 46 +++
 include/media/videobuf2-core.h| 15 ++
 2 files changed, 61 insertions(+)

diff --git a/drivers/media/common/videobuf2/videobuf2-core.c 
b/drivers/media/common/videobuf2/videobuf2-core.c
index 70e8c3366f9c..2a0c5de4d683 100644
--- a/drivers/media/common/videobuf2/videobuf2-core.c
+++ b/drivers/media/common/videobuf2/videobuf2-core.c
@@ -986,6 +986,52 @@ void vb2_discard_done(struct vb2_queue *q)
 }
 EXPORT_SYMBOL_GPL(vb2_discard_done);
 
+int vb2_buffer_access_request(struct vb2_buffer *vb)
+{
+   struct vb2_queue *q = vb->vb2_queue;
+   unsigned int plane;
+   int ret;
+
+   /* Only dmabuf-imported buffers need to be mapped before access. */
+   if (q->memory != VB2_MEMORY_DMABUF)
+   return -EINVAL;
+
+   for (plane = 0; plane < vb->num_planes; ++plane) {
+   if (vb->planes[plane].dbuf_mapped)
+   continue;
+
+   ret = call_memop(vb, map_dmabuf, vb->planes[plane].mem_priv);
+   if (ret) {
+   dprintk(1, "failed to map dmabuf for plane %d\n",
+   plane);
+   return ret;
+   }
+   vb->planes[plane].dbuf_mapped = 1;
+   }
+
+   return 0;
+}
+EXPORT_SYMBOL_GPL(vb2_buffer_access_request);
+
+void vb2_buffer_access_release(struct vb2_buffer *vb)
+{
+   struct vb2_queue *q = vb->vb2_queue;
+   unsigned int plane;
+
+   /* Only dmabuf-imported buffers need to be unmapped after access. */
+   if (q->memory != VB2_MEMORY_DMABUF)
+   return;
+
+   for (plane = 0; plane < vb->num_planes; ++plane) {
+   if (!vb->planes[plane].dbuf_mapped)
+   continue;
+
+   call_void_memop(vb, unmap_dmabuf, vb->planes[plane].mem_priv);
+   vb->planes[plane].dbuf_mapped = 0;
+   }
+}
+EXPORT_SYMBOL_GPL(vb2_buffer_access_release);
+
 /*
  * __prepare_mmap() - prepare an MMAP buffer
  */
diff --git a/include/media/videobuf2-core.h b/include/media/videobuf2-core.h
index 4a737b2c610b..bf378c1e718b 100644
--- a/include/media/videobuf2-core.h
+++ b/include/media/videobuf2-core.h
@@ -1199,4 +1199,19 @@ bool vb2_request_object_is_buffer(struct 
media_request_object *obj);
  */
 unsigned int vb2_request_buffer_cnt(struct media_request *req);
 
+/**
+ * vb2_buffer_access_request() - request out-of-band data access to a buffer
+ *
+ * @vb:buffer to request data access for
+ */
+int vb2_buffer_access_request(struct vb2_buffer *vb);
+
+
+/**
+ * vb2_buffer_access_release() - release out-of-band data access to a buffer
+ *
+ * @vb:buffer to release data access for
+ */
+void vb2_buffer_access_release(struct vb2_buffer *vb);
+
 #endif /* _MEDIA_VIDEOBUF2_CORE_H */
-- 
2.20.1

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


[PATCH RFC 0/3] media: Ensure access to dma-buf-imported reference buffers

2019-01-14 Thread Paul Kocialkowski
This is a first attempt at implementing proper access to buffers
imported with dma-buf and used as reference frames for decoding
subsequent frames.

The main concern associated with this scenario was that memory could be
liberated while the buffer is not in a queued state. After careful
checking, it appears that this is not the case as the refcount is
always increased when importing the buffer. It is only decreased when
the same buffer is queued with a different dma-buf fd or when all
buffers are liberated. In the meantime (when decoding using the frame as
a reference happens), the buffer is thus guaranteed to stay alive.

However, buffers imported with dma-buf require calls to dma-buf-specific
map/unmap memops before they are accessed. This introduces the plumbing
for allowing that.

One major issue is that it cannot be done in atomic context, where
the job is marked as completed. To solve this, a new m2m operation
(job_done) is introduced which allows releasing access to the
reference buffers from the m2m worker thread.

Since this series touches the core of vb2 and m2m and may not be the
best way to implement this, it is marked as RFC.

This series is based on the series starting with:
  media: cedrus: Cleanup duplicate declarations from cedrus_dec header

Paul Kocialkowski (4):
  media: vb2: Add helpers to access unselected buffers
  media: v4l2-mem2mem: Add an optional job_done operation
  media: cedrus: Request access to reference buffers when decoding
  media: cedrus: Remove completed item from TODO list (dma-buf
references)

 .../media/common/videobuf2/videobuf2-core.c   | 46 +++
 drivers/media/v4l2-core/v4l2-mem2mem.c|  8 +++-
 drivers/staging/media/sunxi/cedrus/TODO   |  5 --
 drivers/staging/media/sunxi/cedrus/cedrus.c   |  1 +
 drivers/staging/media/sunxi/cedrus/cedrus.h   |  1 +
 .../staging/media/sunxi/cedrus/cedrus_dec.c   | 18 
 .../staging/media/sunxi/cedrus/cedrus_dec.h   |  1 +
 .../staging/media/sunxi/cedrus/cedrus_mpeg2.c |  8 
 include/media/v4l2-mem2mem.h  |  4 ++
 include/media/videobuf2-core.h| 15 ++
 10 files changed, 100 insertions(+), 7 deletions(-)

-- 
2.20.1

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


[PATCH RFC 4/4] media: cedrus: Remove completed item from TODO list (dma-buf references)

2019-01-14 Thread Paul Kocialkowski
Access to reference frames that were imported from dma-buf was taken
care of and is no longer a pending item on the driver's TODO list.

Signed-off-by: Paul Kocialkowski 
---
 drivers/staging/media/sunxi/cedrus/TODO | 5 -
 1 file changed, 5 deletions(-)

diff --git a/drivers/staging/media/sunxi/cedrus/TODO 
b/drivers/staging/media/sunxi/cedrus/TODO
index a951b3fd1ea1..ec277ece47af 100644
--- a/drivers/staging/media/sunxi/cedrus/TODO
+++ b/drivers/staging/media/sunxi/cedrus/TODO
@@ -5,8 +5,3 @@ Before this stateless decoder driver can leave the staging area:
 * Userspace support for the Request API needs to be reviewed;
 * Another stateless decoder driver should be submitted;
 * At least one stateless encoder driver should be submitted.
-* When queueing a request containing references to I frames, the
-  refcount of the memory for those I frames needs to be incremented
-  and decremented when the request is completed. This will likely
-  require some help from vb2. The driver should fail the request
-  if the memory/buffer is gone.
-- 
2.20.1

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


Re: rtl8192e: need help with variable naming convention

2019-01-14 Thread Dan Carpenter
On Mon, Jan 14, 2019 at 05:39:24PM +0530, Himadri Pandya wrote:
> On Mon, 14 Jan, 2019, 4:21 PM Dan Carpenter  
> Naming is hard.  Having "_array" in the name isn't great either.  It's
> > normally obvious it's an array because of the [] characters.
> >
> 
> Okay. How about renaming it to "_list[ ]" ? But I'm not sure if calling it
> a list will introduce redundancy or increase readability by showing we're
> implementing a list with an array?

_list is fine.  Or _array is fine, really.  Even channal_plan[] seems
Ok to me.  Something that mentions region, perhaps?  It's all fine.

So long as you're thinking about naming and trying to say something
then it's probably fine.  We're not trying to be ogres or to reject
patches.

regards,
dan carpenter

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


[PATCH 4/5] staging: erofs: move erofs_xattr_handlers to xattr.h

2019-01-14 Thread Gao Xiang
Let's move independent xattr-related stuffs to xattr.h.
No logic changes.

Reviewed-by: Chao Yu 
Signed-off-by: Gao Xiang 
---
 drivers/staging/erofs/internal.h | 5 -
 drivers/staging/erofs/super.c| 1 +
 drivers/staging/erofs/xattr.h| 2 ++
 3 files changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/erofs/internal.h b/drivers/staging/erofs/internal.h
index ae4f2555f497..99b50b981335 100644
--- a/drivers/staging/erofs/internal.h
+++ b/drivers/staging/erofs/internal.h
@@ -580,11 +580,6 @@ int erofs_namei(struct inode *dir, struct qstr *name,
 /* dir.c */
 extern const struct file_operations erofs_dir_fops;
 
-#ifdef CONFIG_EROFS_FS_XATTR
-/* xattr.c */
-extern const struct xattr_handler *erofs_xattr_handlers[];
-#endif
-
 static inline void *erofs_vmap(struct page **pages, unsigned int count)
 {
 #ifdef CONFIG_EROFS_FS_USE_VM_MAP_RAM
diff --git a/drivers/staging/erofs/super.c b/drivers/staging/erofs/super.c
index 1c2eb69682ef..45c7f6ddb9f5 100644
--- a/drivers/staging/erofs/super.c
+++ b/drivers/staging/erofs/super.c
@@ -16,6 +16,7 @@
 #include 
 #include 
 #include "internal.h"
+#include "xattr.h"
 
 #define CREATE_TRACE_POINTS
 #include 
diff --git a/drivers/staging/erofs/xattr.h b/drivers/staging/erofs/xattr.h
index 810fc947701d..634dae9aaa0b 100644
--- a/drivers/staging/erofs/xattr.h
+++ b/drivers/staging/erofs/xattr.h
@@ -68,6 +68,8 @@ static const struct xattr_handler *xattr_handler_map[] = {
 }
 
 #ifdef CONFIG_EROFS_FS_XATTR
+extern const struct xattr_handler *erofs_xattr_handlers[];
+
 int erofs_getxattr(struct inode *, int, const char *, void *, size_t);
 ssize_t erofs_listxattr(struct dentry *, char *, size_t);
 #else
-- 
2.14.4

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


[PATCH 2/5] staging: erofs: fix fast symlink w/o xattr when fs xattr is on

2019-01-14 Thread Gao Xiang
Currently, this will hit a BUG_ON for these symlinks as follows:

- kernel message
[ cut here ]
kernel BUG at drivers/staging/erofs/xattr.c:59!
SMP PTI
CPU: 1 PID: 1170 Comm: getllxattr Not tainted 4.20.0-rc6+ #92
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.10.2-2.fc27 
04/01/2014
RIP: 0010:init_inode_xattrs+0x22b/0x270
Code: 48 0f 45 ea f0 ff 4d 34 74 0d 41 83 4c 24 e0 01 31 c0 e9 00 fe ff ff 48 
89 ef e8 e0 31 9e ff eb e9 89 e8 e9 ef fd ff ff 0f 0$
 <0f> 0b 48 89 ef e8 fb f6 9c ff 48 8b 45 08 a8 01 75 24 f0 ff 4d 34
RSP: 0018:a03ac026bdf8 EFLAGS: 00010246
[ cut here ]
...
Call Trace:
 erofs_listxattr+0x30/0x2c0
 ? selinux_inode_listxattr+0x5a/0x80
 ? kmem_cache_alloc+0x33/0x170
 ? security_inode_listxattr+0x27/0x40
 listxattr+0xaf/0xc0
 path_listxattr+0x5a/0xa0
 do_syscall_64+0x43/0xf0
 entry_SYSCALL_64_after_hwframe+0x44/0xa9
...
---[ end trace 3c24b49408dc0c72 ]---

Fix it by checking ->xattr_isize in init_inode_xattrs(),
and it also fixes improper return value -ENOTSUPP
(it should be -ENODATA if xattr is enabled) for those inodes.

Fixes: b17500a0fdba ("staging: erofs: introduce xattr & acl support")
Cc:  # 4.19+
Reported-by: Li Guifu 
Tested-by: Li Guifu 
Reviewed-by: Chao Yu 
Signed-off-by: Gao Xiang 
---
 drivers/staging/erofs/inode.c |  8 
 drivers/staging/erofs/xattr.c | 25 -
 2 files changed, 24 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/erofs/inode.c b/drivers/staging/erofs/inode.c
index d7fbf5f4600f..f99954dbfdb5 100644
--- a/drivers/staging/erofs/inode.c
+++ b/drivers/staging/erofs/inode.c
@@ -185,16 +185,16 @@ static int fill_inode(struct inode *inode, int isdir)
/* setup the new inode */
if (S_ISREG(inode->i_mode)) {
 #ifdef CONFIG_EROFS_FS_XATTR
-   if (vi->xattr_isize)
-   inode->i_op = _generic_xattr_iops;
+   inode->i_op = _generic_xattr_iops;
 #endif
inode->i_fop = _ro_fops;
} else if (S_ISDIR(inode->i_mode)) {
inode->i_op =
 #ifdef CONFIG_EROFS_FS_XATTR
-   vi->xattr_isize ? _dir_xattr_iops :
-#endif
+   _dir_xattr_iops;
+#else
_dir_iops;
+#endif
inode->i_fop = _dir_fops;
} else if (S_ISLNK(inode->i_mode)) {
/* by default, page_get_link is used for symlink */
diff --git a/drivers/staging/erofs/xattr.c b/drivers/staging/erofs/xattr.c
index 80dca6a4adbe..e30de2476fd0 100644
--- a/drivers/staging/erofs/xattr.c
+++ b/drivers/staging/erofs/xattr.c
@@ -56,7 +56,26 @@ static int init_inode_xattrs(struct inode *inode)
return 0;
 
vi = EROFS_V(inode);
-   BUG_ON(!vi->xattr_isize);
+
+   /*
+* bypass all xattr operations if ->xattr_isize is not greater than
+* sizeof(struct erofs_xattr_ibody_header), in detail:
+* 1) it is not enough to contain erofs_xattr_ibody_header then
+*->xattr_isize should be 0 (it means no xattr);
+* 2) it is just to contain erofs_xattr_ibody_header, which is on-disk
+*undefined right now (maybe use later with some new sb feature).
+*/
+   if (vi->xattr_isize == sizeof(struct erofs_xattr_ibody_header)) {
+   errln("xattr_isize %d of nid %llu is not supported yet",
+ vi->xattr_isize, vi->nid);
+   return -ENOTSUPP;
+   } else if (vi->xattr_isize < sizeof(struct erofs_xattr_ibody_header)) {
+   if (unlikely(vi->xattr_isize)) {
+   DBG_BUGON(1);
+   return -EIO;/* xattr ondisk layout error */
+   }
+   return -ENOATTR;
+   }
 
sb = inode->i_sb;
sbi = EROFS_SB(sb);
@@ -422,7 +441,6 @@ static int erofs_xattr_generic_get(const struct 
xattr_handler *handler,
struct dentry *unused, struct inode *inode,
const char *name, void *buffer, size_t size)
 {
-   struct erofs_vnode *const vi = EROFS_V(inode);
struct erofs_sb_info *const sbi = EROFS_I_SB(inode);
 
switch (handler->flags) {
@@ -440,9 +458,6 @@ static int erofs_xattr_generic_get(const struct 
xattr_handler *handler,
return -EINVAL;
}
 
-   if (!vi->xattr_isize)
-   return -ENOATTR;
-
return erofs_getxattr(inode, handler->flags, name, buffer, size);
 }
 
-- 
2.14.4

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


[PATCH 5/5] staging: erofs: clean up erofs_map_blocks_iter

2019-01-14 Thread Gao Xiang
From: Chao Yu 

This patch cleans up erofs_map_blocks* function and structure family,
just simply the code, no logic change.

Reviewed-by: Gao Xiang 
Signed-off-by: Chao Yu 
Signed-off-by: Gao Xiang 
---
 drivers/staging/erofs/data.c  | 31 +--
 drivers/staging/erofs/internal.h  | 28 +++-
 drivers/staging/erofs/unzip_vle.c | 30 +++---
 3 files changed, 35 insertions(+), 54 deletions(-)

diff --git a/drivers/staging/erofs/data.c b/drivers/staging/erofs/data.c
index 329fa4fa3e9c..9c471f08ffd4 100644
--- a/drivers/staging/erofs/data.c
+++ b/drivers/staging/erofs/data.c
@@ -165,37 +165,16 @@ static int erofs_map_blocks_flatmode(struct inode *inode,
return err;
 }
 
-int erofs_map_blocks_iter(struct inode *inode,
- struct erofs_map_blocks *map,
- struct page **mpage_ret, int flags)
-{
-   /* by default, reading raw data never use erofs_map_blocks_iter */
-   if (unlikely(!is_inode_layout_compression(inode))) {
-   if (*mpage_ret)
-   put_page(*mpage_ret);
-   *mpage_ret = NULL;
-
-   return erofs_map_blocks(inode, map, flags);
-   }
-
-#ifdef CONFIG_EROFS_FS_ZIP
-   return z_erofs_map_blocks_iter(inode, map, mpage_ret, flags);
-#else
-   /* data compression is not available */
-   return -ENOTSUPP;
-#endif
-}
-
 int erofs_map_blocks(struct inode *inode,
 struct erofs_map_blocks *map, int flags)
 {
if (unlikely(is_inode_layout_compression(inode))) {
-   struct page *mpage = NULL;
-   int err;
+   int err = z_erofs_map_blocks_iter(inode, map, flags);
 
-   err = erofs_map_blocks_iter(inode, map, , flags);
-   if (mpage)
-   put_page(mpage);
+   if (map->mpage) {
+   put_page(map->mpage);
+   map->mpage = NULL;
+   }
return err;
}
return erofs_map_blocks_flatmode(inode, map, flags);
diff --git a/drivers/staging/erofs/internal.h b/drivers/staging/erofs/internal.h
index 99b50b981335..e2103804584b 100644
--- a/drivers/staging/erofs/internal.h
+++ b/drivers/staging/erofs/internal.h
@@ -461,11 +461,26 @@ struct erofs_map_blocks {
u64 m_plen, m_llen;
 
unsigned int m_flags;
+
+   struct page *mpage;
 };
 
 /* Flags used by erofs_map_blocks() */
 #define EROFS_GET_BLOCKS_RAW0x0001
 
+#ifdef CONFIG_EROFS_FS_ZIP
+int z_erofs_map_blocks_iter(struct inode *inode,
+   struct erofs_map_blocks *map,
+   int flags);
+#else
+static inline int z_erofs_map_blocks_iter(struct inode *inode,
+ struct erofs_map_blocks *map,
+ int flags);
+{
+   return -ENOTSUPP;
+}
+#endif
+
 /* data.c */
 static inline struct bio *
 erofs_grab_bio(struct super_block *sb,
@@ -522,19 +537,6 @@ static inline struct page 
*erofs_get_meta_page_nofail(struct super_block *sb,
 }
 
 extern int erofs_map_blocks(struct inode *, struct erofs_map_blocks *, int);
-extern int erofs_map_blocks_iter(struct inode *, struct erofs_map_blocks *,
-   struct page **, int);
-
-struct erofs_map_blocks_iter {
-   struct erofs_map_blocks map;
-   struct page *mpage;
-};
-
-#ifdef CONFIG_EROFS_FS_ZIP
-extern int z_erofs_map_blocks_iter(struct inode *,
-  struct erofs_map_blocks *,
-  struct page **, int);
-#endif
 
 static inline struct page *
 erofs_get_inline_page(struct inode *inode,
diff --git a/drivers/staging/erofs/unzip_vle.c 
b/drivers/staging/erofs/unzip_vle.c
index 584612b47369..29b3b1dc67f1 100644
--- a/drivers/staging/erofs/unzip_vle.c
+++ b/drivers/staging/erofs/unzip_vle.c
@@ -636,7 +636,7 @@ struct z_erofs_vle_frontend {
struct inode *const inode;
 
struct z_erofs_vle_work_builder builder;
-   struct erofs_map_blocks_iter m_iter;
+   struct erofs_map_blocks map;
 
z_erofs_vle_owned_workgrp_t owned_head;
 
@@ -647,8 +647,9 @@ struct z_erofs_vle_frontend {
 
 #define VLE_FRONTEND_INIT(__i) { \
.inode = __i, \
-   .m_iter = { \
-   { .m_llen = 0, .m_plen = 0 }, \
+   .map = { \
+   .m_llen = 0, \
+   .m_plen = 0, \
.mpage = NULL \
}, \
.builder = VLE_WORK_BUILDER_INIT(), \
@@ -681,8 +682,7 @@ static int z_erofs_do_read_page(struct z_erofs_vle_frontend 
*fe,
 {
struct super_block *const sb = fe->inode->i_sb;
struct erofs_sb_info *const sbi __maybe_unused = EROFS_SB(sb);
-   struct erofs_map_blocks_iter *const m = >m_iter;
-   struct erofs_map_blocks *const map = >map;
+   struct erofs_map_blocks *const map = >map;
struct z_erofs_vle_work_builder *const builder = >builder;
   

[PATCH 3/5] staging: erofs: remove unneeded inode_operations

2019-01-14 Thread Gao Xiang
Currently, EROFS uses generic iops when xattr is off,
it seems unnecessary and a lot of extra code is there.
Let's follow what other filesystems do instead.

Reviewed-by: Chao Yu 
Signed-off-by: Gao Xiang 
---
 drivers/staging/erofs/inode.c| 38 
 drivers/staging/erofs/internal.h | 42 +---
 drivers/staging/erofs/namei.c|  4 
 drivers/staging/erofs/xattr.h|  4 
 4 files changed, 30 insertions(+), 58 deletions(-)

diff --git a/drivers/staging/erofs/inode.c b/drivers/staging/erofs/inode.c
index f99954dbfdb5..4f04f7c38cf2 100644
--- a/drivers/staging/erofs/inode.c
+++ b/drivers/staging/erofs/inode.c
@@ -184,32 +184,18 @@ static int fill_inode(struct inode *inode, int isdir)
if (!err) {
/* setup the new inode */
if (S_ISREG(inode->i_mode)) {
-#ifdef CONFIG_EROFS_FS_XATTR
-   inode->i_op = _generic_xattr_iops;
-#endif
+   inode->i_op = _generic_iops;
inode->i_fop = _ro_fops;
} else if (S_ISDIR(inode->i_mode)) {
-   inode->i_op =
-#ifdef CONFIG_EROFS_FS_XATTR
-   _dir_xattr_iops;
-#else
-   _dir_iops;
-#endif
+   inode->i_op = _dir_iops;
inode->i_fop = _dir_fops;
} else if (S_ISLNK(inode->i_mode)) {
/* by default, page_get_link is used for symlink */
-   inode->i_op =
-#ifdef CONFIG_EROFS_FS_XATTR
-   _symlink_xattr_iops,
-#else
-   _symlink_inode_operations;
-#endif
+   inode->i_op = _symlink_iops;
inode_nohighmem(inode);
} else if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode) ||
S_ISFIFO(inode->i_mode) || S_ISSOCK(inode->i_mode)) {
-#ifdef CONFIG_EROFS_FS_XATTR
-   inode->i_op = _special_inode_operations;
-#endif
+   inode->i_op = _generic_iops;
init_special_inode(inode, inode->i_mode, inode->i_rdev);
} else {
err = -EIO;
@@ -297,23 +283,23 @@ struct inode *erofs_iget(struct super_block *sb,
return inode;
 }
 
+const struct inode_operations erofs_generic_iops = {
 #ifdef CONFIG_EROFS_FS_XATTR
-const struct inode_operations erofs_generic_xattr_iops = {
.listxattr = erofs_listxattr,
+#endif
 };
 
-const struct inode_operations erofs_symlink_xattr_iops = {
+const struct inode_operations erofs_symlink_iops = {
.get_link = page_get_link,
+#ifdef CONFIG_EROFS_FS_XATTR
.listxattr = erofs_listxattr,
+#endif
 };
 
-const struct inode_operations erofs_special_inode_operations = {
-   .listxattr = erofs_listxattr,
-};
-
-const struct inode_operations erofs_fast_symlink_xattr_iops = {
+const struct inode_operations erofs_fast_symlink_iops = {
.get_link = simple_get_link,
+#ifdef CONFIG_EROFS_FS_XATTR
.listxattr = erofs_listxattr,
-};
 #endif
+};
 
diff --git a/drivers/staging/erofs/internal.h b/drivers/staging/erofs/internal.h
index 192f4028d85d..ae4f2555f497 100644
--- a/drivers/staging/erofs/internal.h
+++ b/drivers/staging/erofs/internal.h
@@ -414,8 +414,6 @@ static inline bool is_inode_layout_inline(struct inode 
*inode)
 }
 
 extern const struct super_operations erofs_sops;
-extern const struct inode_operations erofs_dir_iops;
-extern const struct file_operations erofs_dir_fops;
 
 extern const struct address_space_operations erofs_raw_access_aops;
 #ifdef CONFIG_EROFS_FS_ZIP
@@ -559,37 +557,33 @@ static inline unsigned long erofs_inode_hash(erofs_nid_t 
nid)
 extern struct inode *erofs_iget(struct super_block *sb,
erofs_nid_t nid, bool dir);
 
-/* dir.c */
-int erofs_namei(struct inode *dir, struct qstr *name,
-   erofs_nid_t *nid, unsigned *d_type);
-
-#ifdef CONFIG_EROFS_FS_XATTR
-/* xattr.c */
-extern const struct xattr_handler *erofs_xattr_handlers[];
-
-/* symlink and special inode */
-extern const struct inode_operations erofs_symlink_xattr_iops;
-extern const struct inode_operations erofs_fast_symlink_xattr_iops;
-extern const struct inode_operations erofs_special_inode_operations;
-#endif
+extern const struct inode_operations erofs_generic_iops;
+extern const struct inode_operations erofs_symlink_iops;
+extern const struct inode_operations erofs_fast_symlink_iops;
 
 static inline void set_inode_fast_symlink(struct inode *inode)
 {
-#ifdef CONFIG_EROFS_FS_XATTR
-   inode->i_op = _fast_symlink_xattr_iops;
-#else
-   inode->i_op = _symlink_inode_operations;
-#endif
+   inode->i_op = _fast_symlink_iops;
 }
 
 static inline bool is_inode_fast_symlink(struct inode *inode)
 {
+   return inode->i_op == _fast_symlink_iops;
+}
+
+/* namei.c */
+extern const struct inode_operations erofs_dir_iops;
+
+int 

[PATCH 0/5] staging: erofs: document, bugfix and cleanups

2019-01-14 Thread Gao Xiang
Hi,
This is the first EROFS patchset for this new round.

An initial document describing the details of EROFS is added in this
patchset and it was previewed in
https://lists.ozlabs.org/pipermail/linux-erofs/2019-January/001227.html

In addition, Li Guifu found an unexpected crash related to fast symlink
in our internal test, this patchset also addresses this issue:
https://lists.ozlabs.org/pipermail/linux-erofs/2019-January/001190.html

and the rest patches are all cleanups, nothing special.

Thanks,
Gao Xiang

Chao Yu (1):
  staging: erofs: clean up erofs_map_blocks_iter

Gao Xiang (4):
  staging: erofs: add document
  staging: erofs: fix fast symlink w/o xattr when fs xattr is on
  staging: erofs: remove unneeded inode_operations
  staging: erofs: move erofs_xattr_handlers to xattr.h

 .../erofs/Documentation/filesystems/erofs.txt  | 195 +
 drivers/staging/erofs/data.c   |  31 +---
 drivers/staging/erofs/inode.c  |  38 ++--
 drivers/staging/erofs/internal.h   |  67 +++
 drivers/staging/erofs/namei.c  |   4 -
 drivers/staging/erofs/super.c  |   1 +
 drivers/staging/erofs/unzip_vle.c  |  30 ++--
 drivers/staging/erofs/xattr.c  |  25 ++-
 drivers/staging/erofs/xattr.h  |   4 +-
 9 files changed, 278 insertions(+), 117 deletions(-)
 create mode 100644 drivers/staging/erofs/Documentation/filesystems/erofs.txt

-- 
2.14.4

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


[PATCH 1/5] staging: erofs: add document

2019-01-14 Thread Gao Xiang
This documents key feature, usage, and on-disk design of erofs.

Reviewed-by: Chao Yu 
Cc: 
Signed-off-by: Gao Xiang 
---
 .../erofs/Documentation/filesystems/erofs.txt  | 195 +
 1 file changed, 195 insertions(+)
 create mode 100644 drivers/staging/erofs/Documentation/filesystems/erofs.txt

diff --git a/drivers/staging/erofs/Documentation/filesystems/erofs.txt 
b/drivers/staging/erofs/Documentation/filesystems/erofs.txt
new file mode 100644
index ..2e1bda8b5f83
--- /dev/null
+++ b/drivers/staging/erofs/Documentation/filesystems/erofs.txt
@@ -0,0 +1,195 @@
+Overview
+
+
+EROFS file-system stands for Enhanced Read-Only File System. Different
+from other read-only file systems, it aims to be designed for flexibility,
+scalability, but be kept simple and high performance.
+
+Here is the main features of EROFS:
+ - Little endian on-disk design;
+
+ - Currently 4KB block size (nobh) and therefore maximum 16TB address space;
+
+ - Metadata & data could be mixed by design;
+
+ - 2 inode versions for different requirements:
+  v1v2
+   Inode metadata size:   32 bytes  64 bytes
+   Max file size: 4 GB  16 EB (also limited by max. vol size)
+   Max uids/gids: 65536 4294967296
+   File creation time:noyes (64 + 32-bit timestamp)
+   Max hardlinks: 65536 4294967296
+   Metadata reserved: 4 bytes   14 bytes
+
+ - Support extended attributes (xattrs)
+
+ - Support xattr inline and tail-end data inline for all files;
+
+ - Support transparent file compression as an option:
+   LZ4 algorithm with 4 KB fixed-output compression for high performance;
+
+The following git tree provides the file system user-space tools under
+development (ex, formatting tool mkfs.erofs):
+>> git://git.kernel.org/pub/scm/linux/kernel/git/xiang/erofs-utils.git
+
+Bugs and patches are welcome, please kindly help us and send to the following
+linux-erofs mailing list:
+>> linux-erofs mailing list   
+
+Note that EROFS is still working in progress as a Linux staging driver,
+Cc the staging mailing list as well is highly recommended:
+>> Linux Driver Project Developer List 
+
+Mount options
+=
+
+fault_injection=%d Enable fault injection in all supported types with
+   specified injection rate. Supported injection type:
+   Type_NameType_Value
+   FAULT_KMALLOC0x1
+(no)user_xattr Setup Extended User Attributes. Note: xattr is enabled
+   by default if CONFIG_EROFS_FS_XATTR is selected.
+(no)aclSetup POSIX Access Control List. Note: acl is enabled
+   by default if CONFIG_EROFS_FS_POSIX_ACL is selected.
+
+On-disk details
+===
+
+Summary
+---
+Different from other read-only file systems, an EROFS volume is designed
+to be as simple as possible:
+
+|-> aligned with the block size
+   
+  | |SB| | ... | Metadata | ... | Data | Metadata | ... | Data |
+  |_|__|_|_|__|_|__|__|_|__|
+  0 +1K
+
+All data areas should be aligned with the block size, but metadata areas
+may not. All metadatas can be now observed in two different spaces (views):
+ 1. Inode metadata space
+Each valid inode should be aligned with an inode slot, which is a fixed
+value (32 bytes) and designed to be kept in line with v1 inode size.
+
+Each inode can be directly found with the following formula:
+ inode offset = meta_blkaddr * block_size + 32 * nid
+
+|-> aligned with 8B
+   |-> followed closely
++ meta_blkaddr blocks  |-> another slot
+ _
+|  ...   | inode |  xattrs  | extents  | data inline | ... | inode ...
+||___|(optional)|(optional)|__(optional)_|_|__
+ |-> aligned with the inode slot size
+  .   .
+. .
+  .  .
+..
+  . .
+.  .
+  .|-> aligned with 4B
+  | xattr_ibody_header | shared xattrs | inline xattrs |
+  ||___|___|
+  |->12 bytes<-|->x * 4 bytes<-|   .
+  .. .
+.  .   .
+   .   . .
+   

Re: rtl8192e: need help with variable naming convention

2019-01-14 Thread Dan Carpenter
On Sat, Jan 12, 2019 at 10:31:08PM -0800, Himadri Pandya wrote:
> On Mon, Jan 7, 2019 at 5:04 AM Dan Carpenter 
> wrote:
> 
> >
> > Ending a name with an underscore is quite ugly.
> 
> 
> Yeah. That's right. So renaming it to channel_array[ ] instead.
> 

Naming is hard.  Having "_array" in the name isn't great either.  It's
normally obvious it's an array because of the [] characters.

regards,
dan carpenter

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


Re: staging/android: questions regarding TODO entries

2019-01-14 Thread Greg Kroah-Hartman
On Mon, Jan 14, 2019 at 09:27:15AM +0100, Hugo Lefeuvre wrote:
> Hi,
> 
> This todo entry from staging/android/TODO intriguates me:
> 
> vsoc.c, uapi/vsoc_shm.h
>  - The current driver uses the same wait queue for all of the futexes in a
>region. This will cause false wakeups in regions with a large number of
>waiting threads. We should eventually use multiple queues and select 
> the
>queue based on the region.
> 
> I am not sure to understand it very well.
> 
> What does "select the queue based on the region" mean here ? We already
> have one queue per region, right ?
> 
> What I understand: there is one wait queue per region, meaning that if
> threads T1 to Tn are waiting at offsets O1 to On (same region), then a
> wakeup at offset Om will wake them all. In this case there is a perf issue
> because only Tm (waiting for changes at offset Om) really wants to be
> waken up here, the rest is a bunch of spurious wakeups.
> 
> Does the todo suggest to have one queue per offset ?
> 
> Also, this comment (drivers/staging/android/vsoc.c) mentions a worst case
> of ten threads:
> 
> /*
>  * TODO(b/73664181): Use multiple futex wait queues.
>  * We need to wake every sleeper when the condition changes. Typically
>  * only a single thread will be waiting on the condition, but there
>  * are exceptions. The worst case is about 10 threads.
>  */
> 
> It is not clear to me how this value has been obtained, nor under which
> conditions it might be true. There is no maximum to the number of threads
> fitting in the wait queue, so how can we be sure that at most ten threads
> will wait at the same offset ?
> 
> second, unrelated question:
> 
> In the VSOC_SELF_INTERRUPT ioctl (which might be removed in the future if
> VSOC_WAIT_FOR_INCOMING_INTERRUPT disappears, right ?), incoming_signalled
> is set to 1 but at no other place in the driver we reset it to zero. So,
> once VSOC_SELF_INTERRUPT has been executed once,
> VSOC_WAIT_FOR_INCOMING_INTERRUPT doesn't work anymore ?
> 
> Thanks for your work !
> 
> cheers,
> Hugo
> 
> PS: cc-ing the result of get_maintainer.pl + contacts from todo. Please
> tell me if this is not the right way to go.

Yes, it is the right thing to do but for some reason Greg Hartman (who
wrote the code) and Alistair (who knows the code better than I), were
not included in that list.  I've added them to the to: now...

Either of them can answer these questions better than I can, as I have
no idea what this code does anymore.  They are the ones who worked on
it.

thanks,

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


Re: [PATCH v6 0/2] greybus: gpio: Switch to the gpio descriptor interface

2019-01-14 Thread Johan Hovold
On Fri, Jan 11, 2019 at 09:03:16PM +0530, Nishad Kamdar wrote:
> This patch series converts uses of the old GPIO API to the GPIO
> descriptor API. It also converts the GPIO driver to use the
> GPIO irqchip library GPIOLIB_IRQCHIP instead of repimplementing
> the same.
> 
> Changes in v6:
>  - Patchset now contains two patches as the patch
>1 has been accepted.

All three patches look good now, but since Greg picks these up directly
and applies them to the staging tree, it is best if you submit all three
patches (with my reviewed-by tag) in a series.

One last resend as v7?

Thanks again for doing this.

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


staging/android: questions regarding TODO entries

2019-01-14 Thread Hugo Lefeuvre
Hi,

This todo entry from staging/android/TODO intriguates me:

vsoc.c, uapi/vsoc_shm.h
 - The current driver uses the same wait queue for all of the futexes in a
   region. This will cause false wakeups in regions with a large number of
   waiting threads. We should eventually use multiple queues and select the
   queue based on the region.

I am not sure to understand it very well.

What does "select the queue based on the region" mean here ? We already
have one queue per region, right ?

What I understand: there is one wait queue per region, meaning that if
threads T1 to Tn are waiting at offsets O1 to On (same region), then a
wakeup at offset Om will wake them all. In this case there is a perf issue
because only Tm (waiting for changes at offset Om) really wants to be
waken up here, the rest is a bunch of spurious wakeups.

Does the todo suggest to have one queue per offset ?

Also, this comment (drivers/staging/android/vsoc.c) mentions a worst case
of ten threads:

/*
 * TODO(b/73664181): Use multiple futex wait queues.
 * We need to wake every sleeper when the condition changes. Typically
 * only a single thread will be waiting on the condition, but there
 * are exceptions. The worst case is about 10 threads.
 */

It is not clear to me how this value has been obtained, nor under which
conditions it might be true. There is no maximum to the number of threads
fitting in the wait queue, so how can we be sure that at most ten threads
will wait at the same offset ?

second, unrelated question:

In the VSOC_SELF_INTERRUPT ioctl (which might be removed in the future if
VSOC_WAIT_FOR_INCOMING_INTERRUPT disappears, right ?), incoming_signalled
is set to 1 but at no other place in the driver we reset it to zero. So,
once VSOC_SELF_INTERRUPT has been executed once,
VSOC_WAIT_FOR_INCOMING_INTERRUPT doesn't work anymore ?

Thanks for your work !

cheers,
Hugo

PS: cc-ing the result of get_maintainer.pl + contacts from todo. Please
tell me if this is not the right way to go.

-- 
Hugo Lefeuvre (hle)|www.owl.eu.com
RSA4096_ 360B 03B3 BF27 4F4D 7A3F D5E8 14AA 1EB8 A247 3DFD
ed25519_ 37B2 6D38 0B25 B8A2 6B9F 3A65 A36F 5357 5F2D DC4C


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


Re: [PATCH] binder: create node flag to request sender's security context

2019-01-14 Thread Dan Carpenter
Hi Todd,

url:
https://github.com/0day-ci/linux/commits/Todd-Kjos/binder-create-node-flag-to-request-sender-s-security-context/20190111-095225

New smatch warnings:
drivers/android/binder.c:4364 binder_thread_read() warn: check that 'tr.secctx' 
doesn't leak information

# 
https://github.com/0day-ci/linux/commit/17c44224a75b813d0f0e29430f77576e8453d174
git remote add linux-review https://github.com/0day-ci/linux
git remote update linux-review
git checkout 17c44224a75b813d0f0e29430f77576e8453d174
vim +4364 drivers/android/binder.c

44d8047f1 drivers/android/binder.c Todd Kjos  2018-08-28  4022  
355b0502f drivers/staging/android/binder.c Greg Kroah-Hartman 2011-11-30  4023  
static int binder_thread_read(struct binder_proc *proc,
355b0502f drivers/staging/android/binder.c Greg Kroah-Hartman 2011-11-30  4024  
  struct binder_thread *thread,
da49889de drivers/staging/android/binder.c Arve Hjønnevåg 2014-02-21  4025  
  binder_uintptr_t binder_buffer, size_t size,
da49889de drivers/staging/android/binder.c Arve Hjønnevåg 2014-02-21  4026  
  binder_size_t *consumed, int non_block)
355b0502f drivers/staging/android/binder.c Greg Kroah-Hartman 2011-11-30  4027  
{
da49889de drivers/staging/android/binder.c Arve Hjønnevåg 2014-02-21  4028  
void __user *buffer = (void __user *)(uintptr_t)binder_buffer;
355b0502f drivers/staging/android/binder.c Greg Kroah-Hartman 2011-11-30  4029  
void __user *ptr = buffer + *consumed;
355b0502f drivers/staging/android/binder.c Greg Kroah-Hartman 2011-11-30  4030  
void __user *end = buffer + size;
355b0502f drivers/staging/android/binder.c Greg Kroah-Hartman 2011-11-30  4031  
355b0502f drivers/staging/android/binder.c Greg Kroah-Hartman 2011-11-30  4032  
int ret = 0;
355b0502f drivers/staging/android/binder.c Greg Kroah-Hartman 2011-11-30  4033  
int wait_for_proc_work;
355b0502f drivers/staging/android/binder.c Greg Kroah-Hartman 2011-11-30  4034  
355b0502f drivers/staging/android/binder.c Greg Kroah-Hartman 2011-11-30  4035  
if (*consumed == 0) {
355b0502f drivers/staging/android/binder.c Greg Kroah-Hartman 2011-11-30  4036  
if (put_user(BR_NOOP, (uint32_t __user *)ptr))
355b0502f drivers/staging/android/binder.c Greg Kroah-Hartman 2011-11-30  4037  
return -EFAULT;
355b0502f drivers/staging/android/binder.c Greg Kroah-Hartman 2011-11-30  4038  
ptr += sizeof(uint32_t);
355b0502f drivers/staging/android/binder.c Greg Kroah-Hartman 2011-11-30  4039  
}
355b0502f drivers/staging/android/binder.c Greg Kroah-Hartman 2011-11-30  4040  
355b0502f drivers/staging/android/binder.c Greg Kroah-Hartman 2011-11-30  4041  
retry:
0b89d69a9 drivers/android/binder.c Martijn Coenen 2017-06-29  4042  
binder_inner_proc_lock(proc);
1b77e9dcc drivers/android/binder.c Martijn Coenen 2017-08-31  4043  
wait_for_proc_work = binder_available_for_proc_work_ilocked(thread);
0b89d69a9 drivers/android/binder.c Martijn Coenen 2017-06-29  4044  
binder_inner_proc_unlock(proc);
355b0502f drivers/staging/android/binder.c Greg Kroah-Hartman 2011-11-30  4045  
355b0502f drivers/staging/android/binder.c Greg Kroah-Hartman 2011-11-30  4046  
thread->looper |= BINDER_LOOPER_STATE_WAITING;
975a1ac9a drivers/staging/android/binder.c Arve Hjønnevåg 2012-10-16  4047  
975a1ac9a drivers/staging/android/binder.c Arve Hjønnevåg 2012-10-16  4048  
trace_binder_wait_for_work(wait_for_proc_work,
975a1ac9a drivers/staging/android/binder.c Arve Hjønnevåg 2012-10-16  4049  
   !!thread->transaction_stack,
72196393a drivers/android/binder.c Todd Kjos  2017-06-29  4050  
   !binder_worklist_empty(proc, >todo));
355b0502f drivers/staging/android/binder.c Greg Kroah-Hartman 2011-11-30  4051  
if (wait_for_proc_work) {
355b0502f drivers/staging/android/binder.c Greg Kroah-Hartman 2011-11-30  4052  
if (!(thread->looper & (BINDER_LOOPER_STATE_REGISTERED |
355b0502f drivers/staging/android/binder.c Greg Kroah-Hartman 2011-11-30  4053  
BINDER_LOOPER_STATE_ENTERED))) {
56b468fc7 drivers/staging/android/binder.c Anmol Sarma2012-10-30  4054  
binder_user_error("%d:%d ERROR: Thread waiting for 
process work before calling BC_REGISTER_LOOPER or BC_ENTER_LOOPER (state %x)\n",
355b0502f drivers/staging/android/binder.c Greg Kroah-Hartman 2011-11-30  4055  
proc->pid, thread->pid, thread->looper);
355b0502f drivers/staging/android/binder.c Greg Kroah-Hartman 2011-11-30  4056  
wait_event_interruptible(binder_user_error_wait,
355b0502f drivers/staging/android/binder.c Greg Kroah-Hartman