Re: [PATCH] staging: lustre: add error handling for try_module_get

2018-06-11 Thread NeilBrown
On Tue, Jun 12 2018, Zhouyang Jia wrote:

> When try_module_get fails, the lack of error-handling code may
> cause unexpected results.
>
> This patch adds error-handling code after calling try_module_get.
>
> Signed-off-by: Zhouyang Jia 
> ---
>  drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c | 5 -
>  1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c 
> b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c
> index 7086678..72a42bd 100644
> --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c
> +++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c
> @@ -2422,7 +2422,10 @@ ksocknal_base_startup(void)
>  
>   /* flag lists/ptrs/locks initialised */
>   ksocknal_data.ksnd_init = SOCKNAL_INIT_DATA;
> - try_module_get(THIS_MODULE);
> + if (!try_module_get(THIS_MODULE)) {
> + CERROR("%s: cannot get module\n", __func__);
> + goto failed;
> + }
>  
>   ksocknal_data.ksnd_sched_info = cfs_percpt_alloc(lnet_cpt_table(),
>sizeof(*info));

Thanks for the patch
I agree that this is probably a bug, but the code is still buggy after
you patch, just in a different way.
Try following through the code and see what happens when you 'goto
failed'.

NeilBrown




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


Re: [PATCH v5 2/4] resource: Use list_head to link sibling resource

2018-06-11 Thread kbuild test robot
Hi Baoquan,

I love your patch! Perhaps something to improve:

[auto build test WARNING on linus/master]
[also build test WARNING on v4.17 next-20180608]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improve the system]

url:
https://github.com/0day-ci/linux/commits/Baoquan-He/resource-Use-list_head-to-link-sibling-resource/20180612-113600
config: x86_64-randconfig-x011-201823 (attached as .config)
compiler: gcc-7 (Debian 7.3.0-16) 7.3.0
reproduce:
# save the attached .config to linux build tree
make ARCH=x86_64 

All warnings (new ones prefixed by >>):

   kernel/resource.c: In function 'reparent_resources':
   kernel/resource.c:1005:26: error: passing argument 2 of 'list_add' from 
incompatible pointer type [-Werror=incompatible-pointer-types]
 list_add(>sibling, >sibling.prev);
 ^
   In file included from include/linux/ioport.h:15:0,
from kernel/resource.c:14:
   include/linux/list.h:77:20: note: expected 'struct list_head *' but argument 
is of type 'struct list_head **'
static inline void list_add(struct list_head *new, struct list_head *head)
   ^~~~
   In file included from include/linux/list.h:9:0,
from include/linux/ioport.h:15,
from kernel/resource.c:14:
   kernel/resource.c:1013:26: error: 'new' undeclared (first use in this 
function); did you mean 'net'?
 list_for_each_entry(p, >child, sibling) {
 ^
   include/linux/kernel.h:963:26: note: in definition of macro 'container_of'
 void *__mptr = (void *)(ptr); \
 ^~~
   include/linux/list.h:377:2: note: in expansion of macro 'list_entry'
 list_entry((ptr)->next, type, member)
 ^~
   include/linux/list.h:464:13: note: in expansion of macro 'list_first_entry'
 for (pos = list_first_entry(head, typeof(*pos), member); \
^~~~
>> kernel/resource.c:1013:2: note: in expansion of macro 'list_for_each_entry'
 list_for_each_entry(p, >child, sibling) {
 ^~~
   kernel/resource.c:1013:26: note: each undeclared identifier is reported only 
once for each function it appears in
 list_for_each_entry(p, >child, sibling) {
 ^
   include/linux/kernel.h:963:26: note: in definition of macro 'container_of'
 void *__mptr = (void *)(ptr); \
 ^~~
   include/linux/list.h:377:2: note: in expansion of macro 'list_entry'
 list_entry((ptr)->next, type, member)
 ^~
   include/linux/list.h:464:13: note: in expansion of macro 'list_first_entry'
 for (pos = list_first_entry(head, typeof(*pos), member); \
^~~~
>> kernel/resource.c:1013:2: note: in expansion of macro 'list_for_each_entry'
 list_for_each_entry(p, >child, sibling) {
 ^~~
   cc1: some warnings being treated as errors

vim +/list_for_each_entry +1013 kernel/resource.c

   983  
   984  /*
   985   * Reparent resource children of pr that conflict with res
   986   * under res, and make res replace those children.
   987   */
   988  int reparent_resources(struct resource *parent, struct resource *res)
   989  {
   990  struct resource *p, *first = NULL;
   991  
   992  list_for_each_entry(p, >child, sibling) {
   993  if (p->end < res->start)
   994  continue;
   995  if (res->end < p->start)
   996  break;
   997  if (p->start < res->start || p->end > res->end)
   998  return -1;  /* not completely contained */
   999  if (first == NULL)
  1000  first = p;
  1001  }
  1002  if (first == NULL)
  1003  return -1;  /* didn't find any conflicting entries? 
*/
  1004  res->parent = parent;
  1005  list_add(>sibling, >sibling.prev);
  1006  INIT_LIST_HEAD(>child);
  1007  
  1008  /*
  1009   * From first to p's previous sibling, they all fall into
  1010   * res's region, change them as res's children.
  1011   */
  1012  list_cut_position(>child, first->sibling.prev, 
res->sibling.prev);
> 1013  list_for_each_entry(p, >child, sibling) {
  1014  p->parent = new;
  1015  pr_debug("PCI: Reparented %s %pR under %s\n",
  1016   p->name, p, res->name);
  1017  }
  1018  return 0;
  1019  }
  1020  EXPORT_SYMBOL(reparent_resources);
  1021  

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


.config.gz
Description: application/gzip
___
devel mailing list

[PATCH] staging: lustre: add error handling for try_module_get

2018-06-11 Thread Zhouyang Jia
When try_module_get fails, the lack of error-handling code may
cause unexpected results.

This patch adds error-handling code after calling try_module_get.

Signed-off-by: Zhouyang Jia 
---
 drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c 
b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c
index 7086678..72a42bd 100644
--- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c
+++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c
@@ -2422,7 +2422,10 @@ ksocknal_base_startup(void)
 
/* flag lists/ptrs/locks initialised */
ksocknal_data.ksnd_init = SOCKNAL_INIT_DATA;
-   try_module_get(THIS_MODULE);
+   if (!try_module_get(THIS_MODULE)) {
+   CERROR("%s: cannot get module\n", __func__);
+   goto failed;
+   }
 
ksocknal_data.ksnd_sched_info = cfs_percpt_alloc(lnet_cpt_table(),
 sizeof(*info));
-- 
2.7.4

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


Re: [PATCH v5 2/4] resource: Use list_head to link sibling resource

2018-06-11 Thread kbuild test robot
Hi Baoquan,

I love your patch! Yet something to improve:

[auto build test ERROR on linus/master]
[also build test ERROR on v4.17 next-20180608]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improve the system]

url:
https://github.com/0day-ci/linux/commits/Baoquan-He/resource-Use-list_head-to-link-sibling-resource/20180612-113600
config: i386-tinyconfig (attached as .config)
compiler: gcc-7 (Debian 7.3.0-16) 7.3.0
reproduce:
# save the attached .config to linux build tree
make ARCH=i386 

All errors (new ones prefixed by >>):

   kernel/resource.c: In function 'reparent_resources':
>> kernel/resource.c:1005:26: error: passing argument 2 of 'list_add' from 
>> incompatible pointer type [-Werror=incompatible-pointer-types]
 list_add(>sibling, >sibling.prev);
 ^
   In file included from include/linux/ioport.h:15:0,
from kernel/resource.c:14:
   include/linux/list.h:77:20: note: expected 'struct list_head *' but argument 
is of type 'struct list_head **'
static inline void list_add(struct list_head *new, struct list_head *head)
   ^~~~
   In file included from include/linux/list.h:9:0,
from include/linux/ioport.h:15,
from kernel/resource.c:14:
>> kernel/resource.c:1013:26: error: 'new' undeclared (first use in this 
>> function); did you mean 'net'?
 list_for_each_entry(p, >child, sibling) {
 ^
   include/linux/kernel.h:963:26: note: in definition of macro 'container_of'
 void *__mptr = (void *)(ptr); \
 ^~~
   include/linux/list.h:377:2: note: in expansion of macro 'list_entry'
 list_entry((ptr)->next, type, member)
 ^~
   include/linux/list.h:464:13: note: in expansion of macro 'list_first_entry'
 for (pos = list_first_entry(head, typeof(*pos), member); \
^~~~
   kernel/resource.c:1013:2: note: in expansion of macro 'list_for_each_entry'
 list_for_each_entry(p, >child, sibling) {
 ^~~
   kernel/resource.c:1013:26: note: each undeclared identifier is reported only 
once for each function it appears in
 list_for_each_entry(p, >child, sibling) {
 ^
   include/linux/kernel.h:963:26: note: in definition of macro 'container_of'
 void *__mptr = (void *)(ptr); \
 ^~~
   include/linux/list.h:377:2: note: in expansion of macro 'list_entry'
 list_entry((ptr)->next, type, member)
 ^~
   include/linux/list.h:464:13: note: in expansion of macro 'list_first_entry'
 for (pos = list_first_entry(head, typeof(*pos), member); \
^~~~
   kernel/resource.c:1013:2: note: in expansion of macro 'list_for_each_entry'
 list_for_each_entry(p, >child, sibling) {
 ^~~
   cc1: some warnings being treated as errors

vim +/list_add +1005 kernel/resource.c

   983  
   984  /*
   985   * Reparent resource children of pr that conflict with res
   986   * under res, and make res replace those children.
   987   */
   988  int reparent_resources(struct resource *parent, struct resource *res)
   989  {
   990  struct resource *p, *first = NULL;
   991  
   992  list_for_each_entry(p, >child, sibling) {
   993  if (p->end < res->start)
   994  continue;
   995  if (res->end < p->start)
   996  break;
   997  if (p->start < res->start || p->end > res->end)
   998  return -1;  /* not completely contained */
   999  if (first == NULL)
  1000  first = p;
  1001  }
  1002  if (first == NULL)
  1003  return -1;  /* didn't find any conflicting entries? 
*/
  1004  res->parent = parent;
> 1005  list_add(>sibling, >sibling.prev);
  1006  INIT_LIST_HEAD(>child);
  1007  
  1008  /*
  1009   * From first to p's previous sibling, they all fall into
  1010   * res's region, change them as res's children.
  1011   */
  1012  list_cut_position(>child, first->sibling.prev, 
res->sibling.prev);
> 1013  list_for_each_entry(p, >child, sibling) {
  1014  p->parent = new;
  1015  pr_debug("PCI: Reparented %s %pR under %s\n",
  1016   p->name, p, res->name);
  1017  }
  1018  return 0;
  1019  }
  1020  EXPORT_SYMBOL(reparent_resources);
  1021  

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


.config.gz
Description: application/gzip
___
devel mailing list
de...@linuxdriverproject.org

Re: [PATCH v5 1/4] resource: Move reparent_resources() to kernel/resource.c and make it public

2018-06-11 Thread kbuild test robot
Hi Baoquan,

I love your patch! Yet something to improve:

[auto build test ERROR on linus/master]
[also build test ERROR on v4.17 next-20180608]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improve the system]

url:
https://github.com/0day-ci/linux/commits/Baoquan-He/resource-Use-list_head-to-link-sibling-resource/20180612-113600
config: i386-tinyconfig (attached as .config)
compiler: gcc-7 (Debian 7.3.0-16) 7.3.0
reproduce:
# save the attached .config to linux build tree
make ARCH=i386 

Note: the 
linux-review/Baoquan-He/resource-Use-list_head-to-link-sibling-resource/20180612-113600
 HEAD 5545e79eef6387857faf41cdffa7be6b1f5d4efe builds fine.
  It only hurts bisectibility.

All errors (new ones prefixed by >>):

>> kernel/resource.c:990:12: error: static declaration of 'reparent_resources' 
>> follows non-static declaration
static int reparent_resources(struct resource *parent,
   ^~
   In file included from kernel/resource.c:14:0:
   include/linux/ioport.h:195:5: note: previous declaration of 
'reparent_resources' was here
int reparent_resources(struct resource *parent, struct resource *res);
^~
   kernel/resource.c:990:12: warning: 'reparent_resources' defined but not used 
[-Wunused-function]
static int reparent_resources(struct resource *parent,
   ^~

vim +/reparent_resources +990 kernel/resource.c

   985  
   986  /*
   987   * Reparent resource children of pr that conflict with res
   988   * under res, and make res replace those children.
   989   */
 > 990  static int reparent_resources(struct resource *parent,
   991   struct resource *res)
   992  {
   993  struct resource *p, **pp;
   994  struct resource **firstpp = NULL;
   995  
   996  for (pp = >child; (p = *pp) != NULL; pp = >sibling) {
   997  if (p->end < res->start)
   998  continue;
   999  if (res->end < p->start)
  1000  break;
  1001  if (p->start < res->start || p->end > res->end)
  1002  return -1;  /* not completely contained */
  1003  if (firstpp == NULL)
  1004  firstpp = pp;
  1005  }
  1006  if (firstpp == NULL)
  1007  return -1;  /* didn't find any conflicting entries? 
*/
  1008  res->parent = parent;
  1009  res->child = *firstpp;
  1010  res->sibling = *pp;
  1011  *firstpp = res;
  1012  *pp = NULL;
  1013  for (p = res->child; p != NULL; p = p->sibling) {
  1014  p->parent = res;
  1015  pr_debug("PCI: Reparented %s %pR under %s\n",
  1016   p->name, p, res->name);
  1017  }
  1018  return 0;
  1019  }
  1020  EXPORT_SYMBOL(reparent_resources);
  1021  

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


.config.gz
Description: application/gzip
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v5 1/4] resource: Move reparent_resources() to kernel/resource.c and make it public

2018-06-11 Thread Baoquan He
On 06/12/18 at 11:28am, Baoquan He wrote:
> reparent_resources() is duplicated in arch/microblaze/pci/pci-common.c
> and arch/powerpc/kernel/pci-common.c, so move it to kernel/resource.c
> so that it's shared. Later its code also need be updated using list_head
> to replace singly linked list.
> 
> Signed-off-by: Baoquan He 
> Cc: Michal Simek 
> Cc: Benjamin Herrenschmidt 
> Cc: Paul Mackerras 
> Cc: Michael Ellerman 
> ---
> v4->v5:
>   Fix several code bugs reported by test robot on ARCH powerpc and
>   microblaze.

Oops, I mistakenly added the patch change log of the current patch 0002
here. This patch is a newly added one.

> 
> v3->v4:
>   Fix several bugs test robot reported. And change patch log.
> 
> v2->v3:
>   Rename resource functions first_child() and sibling() to
>   resource_first_chils() and resource_sibling(). Dan suggested this.
> 
>   Move resource_first_chils() and resource_sibling() to linux/ioport.h
>   and make them as inline function. Rob suggested this. Accordingly add
>   linux/list.h including in linux/ioport.h, please help review if this
>   bring efficiency degradation or code redundancy.
> 
>   The change on struct resource {} bring two pointers of size increase,
>   mention this in git log to make it more specifically, Rob suggested
>   this.
> 
>  arch/microblaze/pci/pci-common.c | 37 -
>  arch/powerpc/kernel/pci-common.c | 35 ---
>  include/linux/ioport.h   |  1 +
>  kernel/resource.c| 36 
>  4 files changed, 37 insertions(+), 72 deletions(-)
> 
> diff --git a/arch/microblaze/pci/pci-common.c 
> b/arch/microblaze/pci/pci-common.c
> index f34346d56095..7899bafab064 100644
> --- a/arch/microblaze/pci/pci-common.c
> +++ b/arch/microblaze/pci/pci-common.c
> @@ -619,43 +619,6 @@ int pcibios_add_device(struct pci_dev *dev)
>  EXPORT_SYMBOL(pcibios_add_device);
>  
>  /*
> - * Reparent resource children of pr that conflict with res
> - * under res, and make res replace those children.
> - */
> -static int __init reparent_resources(struct resource *parent,
> -  struct resource *res)
> -{
> - struct resource *p, **pp;
> - struct resource **firstpp = NULL;
> -
> - for (pp = >child; (p = *pp) != NULL; pp = >sibling) {
> - if (p->end < res->start)
> - continue;
> - if (res->end < p->start)
> - break;
> - if (p->start < res->start || p->end > res->end)
> - return -1;  /* not completely contained */
> - if (firstpp == NULL)
> - firstpp = pp;
> - }
> - if (firstpp == NULL)
> - return -1;  /* didn't find any conflicting entries? */
> - res->parent = parent;
> - res->child = *firstpp;
> - res->sibling = *pp;
> - *firstpp = res;
> - *pp = NULL;
> - for (p = res->child; p != NULL; p = p->sibling) {
> - p->parent = res;
> - pr_debug("PCI: Reparented %s [%llx..%llx] under %s\n",
> -  p->name,
> -  (unsigned long long)p->start,
> -  (unsigned long long)p->end, res->name);
> - }
> - return 0;
> -}
> -
> -/*
>   *  Handle resources of PCI devices.  If the world were perfect, we could
>   *  just allocate all the resource regions and do nothing more.  It isn't.
>   *  On the other hand, we cannot just re-allocate all devices, as it would
> diff --git a/arch/powerpc/kernel/pci-common.c 
> b/arch/powerpc/kernel/pci-common.c
> index fe9733aa..926035bb378d 100644
> --- a/arch/powerpc/kernel/pci-common.c
> +++ b/arch/powerpc/kernel/pci-common.c
> @@ -1088,41 +1088,6 @@ resource_size_t pcibios_align_resource(void *data, 
> const struct resource *res,
>  EXPORT_SYMBOL(pcibios_align_resource);
>  
>  /*
> - * Reparent resource children of pr that conflict with res
> - * under res, and make res replace those children.
> - */
> -static int reparent_resources(struct resource *parent,
> -  struct resource *res)
> -{
> - struct resource *p, **pp;
> - struct resource **firstpp = NULL;
> -
> - for (pp = >child; (p = *pp) != NULL; pp = >sibling) {
> - if (p->end < res->start)
> - continue;
> - if (res->end < p->start)
> - break;
> - if (p->start < res->start || p->end > res->end)
> - return -1;  /* not completely contained */
> - if (firstpp == NULL)
> - firstpp = pp;
> - }
> - if (firstpp == NULL)
> - return -1;  /* didn't find any conflicting entries? */
> - res->parent = parent;
> - res->child = *firstpp;
> - res->sibling = *pp;
> - *firstpp = res;
> - *pp = NULL;
> - for (p = res->child; p != NULL; p = p->sibling) {
> - p->parent = res;
> 

[PATCH v5 3/4] resource: add walk_system_ram_res_rev()

2018-06-11 Thread Baoquan He
This function, being a variant of walk_system_ram_res() introduced in
commit 8c86e70acead ("resource: provide new functions to walk through
resources"), walks through a list of all the resources of System RAM
in reversed order, i.e., from higher to lower.

It will be used in kexec_file code.

Signed-off-by: Baoquan He 
Cc: Andrew Morton 
Cc: Thomas Gleixner 
Cc: Brijesh Singh 
Cc: "Jérôme Glisse" 
Cc: Borislav Petkov 
Cc: Tom Lendacky 
Cc: Wei Yang 
---
 include/linux/ioport.h |  3 +++
 kernel/resource.c  | 40 
 2 files changed, 43 insertions(+)

diff --git a/include/linux/ioport.h b/include/linux/ioport.h
index b7456ae889dd..066cc263e2cc 100644
--- a/include/linux/ioport.h
+++ b/include/linux/ioport.h
@@ -279,6 +279,9 @@ extern int
 walk_system_ram_res(u64 start, u64 end, void *arg,
int (*func)(struct resource *, void *));
 extern int
+walk_system_ram_res_rev(u64 start, u64 end, void *arg,
+   int (*func)(struct resource *, void *));
+extern int
 walk_iomem_res_desc(unsigned long desc, unsigned long flags, u64 start, u64 
end,
void *arg, int (*func)(struct resource *, void *));
 
diff --git a/kernel/resource.c b/kernel/resource.c
index ef9a20b75234..3128ac938f38 100644
--- a/kernel/resource.c
+++ b/kernel/resource.c
@@ -23,6 +23,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 #include 
 
 
@@ -443,6 +445,44 @@ int walk_system_ram_res(u64 start, u64 end, void *arg,
 }
 
 /*
+ * This function, being a variant of walk_system_ram_res(), calls the @func
+ * callback against all memory ranges of type System RAM which are marked as
+ * IORESOURCE_SYSTEM_RAM and IORESOUCE_BUSY in reversed order, i.e., from
+ * higher to lower.
+ */
+int walk_system_ram_res_rev(u64 start, u64 end, void *arg,
+   int (*func)(struct resource *, void *))
+{
+   unsigned long flags;
+   struct resource *res;
+   int ret = -1;
+
+   flags = IORESOURCE_SYSTEM_RAM | IORESOURCE_BUSY;
+
+   read_lock(_lock);
+   list_for_each_entry_reverse(res, _resource.child, sibling) {
+   if (start >= end)
+   break;
+   if ((res->flags & flags) != flags)
+   continue;
+   if (res->desc != IORES_DESC_NONE)
+   continue;
+   if (res->end < start)
+   break;
+
+   if ((res->end >= start) && (res->start < end)) {
+   ret = (*func)(res, arg);
+   if (ret)
+   break;
+   }
+   end = res->start - 1;
+
+   }
+   read_unlock(_lock);
+   return ret;
+}
+
+/*
  * This function calls the @func callback against all memory ranges, which
  * are ranges marked as IORESOURCE_MEM and IORESOUCE_BUSY.
  */
-- 
2.13.6

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


[PATCH v5 4/4] kexec_file: Load kernel at top of system RAM if required

2018-06-11 Thread Baoquan He
For kexec_file loading, if kexec_buf.top_down is 'true', the memory which
is used to load kernel/initrd/purgatory is supposed to be allocated from
top to down. This is what we have been doing all along in the old kexec
loading interface and the kexec loading is still default setting in some
distributions. However, the current kexec_file loading interface doesn't
do likt this. The function arch_kexec_walk_mem() it calls ignores checking
kexec_buf.top_down, but calls walk_system_ram_res() directly to go through
all resources of System RAM from bottom to up, to try to find memory region
which can contain the specific kexec buffer, then call 
locate_mem_hole_callback()
to allocate memory in that found memory region from top to down. This brings
confusion especially when KASLR is widely supported , users have to make clear
why kexec/kdump kernel loading position is different between these two
interfaces in order to exclude unnecessary noises. Hence these two interfaces
need be unified on behaviour.

Here add checking if kexec_buf.top_down is 'true' in arch_kexec_walk_mem(),
if yes, call the newly added walk_system_ram_res_rev() to find memory region
from top to down to load kernel.

Signed-off-by: Baoquan He 
Cc: Eric Biederman 
Cc: Vivek Goyal 
Cc: Dave Young 
Cc: Andrew Morton 
Cc: Yinghai Lu 
Cc: ke...@lists.infradead.org
---
 kernel/kexec_file.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/kernel/kexec_file.c b/kernel/kexec_file.c
index 75d8e7cf040e..7a66d9d5a534 100644
--- a/kernel/kexec_file.c
+++ b/kernel/kexec_file.c
@@ -518,6 +518,8 @@ int __weak arch_kexec_walk_mem(struct kexec_buf *kbuf,
   IORESOURCE_SYSTEM_RAM | 
IORESOURCE_BUSY,
   crashk_res.start, crashk_res.end,
   kbuf, func);
+   else if (kbuf->top_down)
+   return walk_system_ram_res_rev(0, ULONG_MAX, kbuf, func);
else
return walk_system_ram_res(0, ULONG_MAX, kbuf, func);
 }
-- 
2.13.6

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


[PATCH v5 1/4] resource: Move reparent_resources() to kernel/resource.c and make it public

2018-06-11 Thread Baoquan He
reparent_resources() is duplicated in arch/microblaze/pci/pci-common.c
and arch/powerpc/kernel/pci-common.c, so move it to kernel/resource.c
so that it's shared. Later its code also need be updated using list_head
to replace singly linked list.

Signed-off-by: Baoquan He 
Cc: Michal Simek 
Cc: Benjamin Herrenschmidt 
Cc: Paul Mackerras 
Cc: Michael Ellerman 
---
v4->v5:
  Fix several code bugs reported by test robot on ARCH powerpc and
  microblaze.

v3->v4:
  Fix several bugs test robot reported. And change patch log.

v2->v3:
  Rename resource functions first_child() and sibling() to
  resource_first_chils() and resource_sibling(). Dan suggested this.

  Move resource_first_chils() and resource_sibling() to linux/ioport.h
  and make them as inline function. Rob suggested this. Accordingly add
  linux/list.h including in linux/ioport.h, please help review if this
  bring efficiency degradation or code redundancy.

  The change on struct resource {} bring two pointers of size increase,
  mention this in git log to make it more specifically, Rob suggested
  this.

 arch/microblaze/pci/pci-common.c | 37 -
 arch/powerpc/kernel/pci-common.c | 35 ---
 include/linux/ioport.h   |  1 +
 kernel/resource.c| 36 
 4 files changed, 37 insertions(+), 72 deletions(-)

diff --git a/arch/microblaze/pci/pci-common.c b/arch/microblaze/pci/pci-common.c
index f34346d56095..7899bafab064 100644
--- a/arch/microblaze/pci/pci-common.c
+++ b/arch/microblaze/pci/pci-common.c
@@ -619,43 +619,6 @@ int pcibios_add_device(struct pci_dev *dev)
 EXPORT_SYMBOL(pcibios_add_device);
 
 /*
- * Reparent resource children of pr that conflict with res
- * under res, and make res replace those children.
- */
-static int __init reparent_resources(struct resource *parent,
-struct resource *res)
-{
-   struct resource *p, **pp;
-   struct resource **firstpp = NULL;
-
-   for (pp = >child; (p = *pp) != NULL; pp = >sibling) {
-   if (p->end < res->start)
-   continue;
-   if (res->end < p->start)
-   break;
-   if (p->start < res->start || p->end > res->end)
-   return -1;  /* not completely contained */
-   if (firstpp == NULL)
-   firstpp = pp;
-   }
-   if (firstpp == NULL)
-   return -1;  /* didn't find any conflicting entries? */
-   res->parent = parent;
-   res->child = *firstpp;
-   res->sibling = *pp;
-   *firstpp = res;
-   *pp = NULL;
-   for (p = res->child; p != NULL; p = p->sibling) {
-   p->parent = res;
-   pr_debug("PCI: Reparented %s [%llx..%llx] under %s\n",
-p->name,
-(unsigned long long)p->start,
-(unsigned long long)p->end, res->name);
-   }
-   return 0;
-}
-
-/*
  *  Handle resources of PCI devices.  If the world were perfect, we could
  *  just allocate all the resource regions and do nothing more.  It isn't.
  *  On the other hand, we cannot just re-allocate all devices, as it would
diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c
index fe9733aa..926035bb378d 100644
--- a/arch/powerpc/kernel/pci-common.c
+++ b/arch/powerpc/kernel/pci-common.c
@@ -1088,41 +1088,6 @@ resource_size_t pcibios_align_resource(void *data, const 
struct resource *res,
 EXPORT_SYMBOL(pcibios_align_resource);
 
 /*
- * Reparent resource children of pr that conflict with res
- * under res, and make res replace those children.
- */
-static int reparent_resources(struct resource *parent,
-struct resource *res)
-{
-   struct resource *p, **pp;
-   struct resource **firstpp = NULL;
-
-   for (pp = >child; (p = *pp) != NULL; pp = >sibling) {
-   if (p->end < res->start)
-   continue;
-   if (res->end < p->start)
-   break;
-   if (p->start < res->start || p->end > res->end)
-   return -1;  /* not completely contained */
-   if (firstpp == NULL)
-   firstpp = pp;
-   }
-   if (firstpp == NULL)
-   return -1;  /* didn't find any conflicting entries? */
-   res->parent = parent;
-   res->child = *firstpp;
-   res->sibling = *pp;
-   *firstpp = res;
-   *pp = NULL;
-   for (p = res->child; p != NULL; p = p->sibling) {
-   p->parent = res;
-   pr_debug("PCI: Reparented %s %pR under %s\n",
-p->name, p, res->name);
-   }
-   return 0;
-}
-
-/*
  *  Handle resources of PCI devices.  If the world were perfect, we could
  *  just allocate all the resource regions and do nothing more.  It isn't.
  *  On 

[PATCH v5 2/4] resource: Use list_head to link sibling resource

2018-06-11 Thread Baoquan He
The struct resource uses singly linked list to link siblings, implemented
by pointer operation. Replace it with list_head for better code readability.

Based on this list_head replacement, it will be very easy to do reverse
iteration on iomem_resource's sibling list in later patch.

Besides, type of member variables of struct resource, sibling and child, are
changed from 'struct resource *' to 'struct list_head'. This brings two
pointers of size increase.

Suggested-by: Andrew Morton 
Signed-off-by: Baoquan He 
Cc: Patrik Jakobsson 
Cc: David Airlie 
Cc: "K. Y. Srinivasan" 
Cc: Haiyang Zhang 
Cc: Stephen Hemminger 
Cc: Dmitry Torokhov 
Cc: Dan Williams 
Cc: Rob Herring 
Cc: Frank Rowand 
Cc: Keith Busch 
Cc: Jonathan Derrick 
Cc: Lorenzo Pieralisi 
Cc: Bjorn Helgaas 
Cc: Thomas Gleixner 
Cc: Brijesh Singh 
Cc: "Jérôme Glisse" 
Cc: Borislav Petkov 
Cc: Tom Lendacky 
Cc: Greg Kroah-Hartman 
Cc: Yaowei Bai 
Cc: Wei Yang 
Cc: de...@linuxdriverproject.org
Cc: linux-in...@vger.kernel.org
Cc: linux-nvd...@lists.01.org
Cc: devicet...@vger.kernel.org
Cc: linux-...@vger.kernel.org
---
 arch/arm/plat-samsung/pm-check.c|   6 +-
 arch/microblaze/pci/pci-common.c|   4 +-
 arch/powerpc/kernel/pci-common.c|   4 +-
 arch/sparc/kernel/ioport.c  |   2 +-
 arch/xtensa/include/asm/pci-bridge.h|   4 +-
 drivers/eisa/eisa-bus.c |   2 +
 drivers/gpu/drm/drm_memory.c|   3 +-
 drivers/gpu/drm/gma500/gtt.c|   5 +-
 drivers/hv/vmbus_drv.c  |  52 +++
 drivers/input/joystick/iforce/iforce-main.c |   4 +-
 drivers/nvdimm/namespace_devs.c |   6 +-
 drivers/nvdimm/nd.h |   5 +-
 drivers/of/address.c|   4 +-
 drivers/parisc/lba_pci.c|   4 +-
 drivers/pci/host/vmd.c  |   8 +-
 drivers/pci/probe.c |   2 +
 drivers/pci/setup-bus.c |   2 +-
 include/linux/ioport.h  |  17 ++-
 kernel/resource.c   | 211 ++--
 19 files changed, 176 insertions(+), 169 deletions(-)

diff --git a/arch/arm/plat-samsung/pm-check.c b/arch/arm/plat-samsung/pm-check.c
index cd2c02c68bc3..5494355b1c49 100644
--- a/arch/arm/plat-samsung/pm-check.c
+++ b/arch/arm/plat-samsung/pm-check.c
@@ -46,8 +46,8 @@ typedef u32 *(run_fn_t)(struct resource *ptr, u32 *arg);
 static void s3c_pm_run_res(struct resource *ptr, run_fn_t fn, u32 *arg)
 {
while (ptr != NULL) {
-   if (ptr->child != NULL)
-   s3c_pm_run_res(ptr->child, fn, arg);
+   if (!list_empty(>child))
+   s3c_pm_run_res(resource_first_child(>child), fn, 
arg);
 
if ((ptr->flags & IORESOURCE_SYSTEM_RAM)
== IORESOURCE_SYSTEM_RAM) {
@@ -57,7 +57,7 @@ static void s3c_pm_run_res(struct resource *ptr, run_fn_t fn, 
u32 *arg)
arg = (fn)(ptr, arg);
}
 
-   ptr = ptr->sibling;
+   ptr = resource_sibling(ptr);
}
 }
 
diff --git a/arch/microblaze/pci/pci-common.c b/arch/microblaze/pci/pci-common.c
index 7899bafab064..2bf73e27e231 100644
--- a/arch/microblaze/pci/pci-common.c
+++ b/arch/microblaze/pci/pci-common.c
@@ -533,7 +533,9 @@ void pci_process_bridge_OF_ranges(struct pci_controller 
*hose,
res->flags = range.flags;
res->start = range.cpu_addr;
res->end = range.cpu_addr + range.size - 1;
-   res->parent = res->child = res->sibling = NULL;
+   res->parent = NULL;
+   INIT_LIST_HEAD(>child);
+   INIT_LIST_HEAD(>sibling);
}
}
 
diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c
index 926035bb378d..28fbe83c9daf 100644
--- a/arch/powerpc/kernel/pci-common.c
+++ b/arch/powerpc/kernel/pci-common.c
@@ -761,7 +761,9 @@ void pci_process_bridge_OF_ranges(struct pci_controller 
*hose,
res->flags = range.flags;
res->start = range.cpu_addr;
res->end = range.cpu_addr + range.size - 1;
-   res->parent = res->child = res->sibling = NULL;
+   res->parent = NULL;
+   INIT_LIST_HEAD(>child);
+   INIT_LIST_HEAD(>sibling);
}
}
 }
diff --git a/arch/sparc/kernel/ioport.c b/arch/sparc/kernel/ioport.c
index cca9134cfa7d..99efe4e98b16 100644
--- a/arch/sparc/kernel/ioport.c
+++ b/arch/sparc/kernel/ioport.c
@@ -669,7 +669,7 @@ static int sparc_io_proc_show(struct seq_file *m, void *v)
struct resource *root = m->private, *r;
const char *nm;
 
-   for (r = root->child; r != NULL; r = r->sibling) {
+   list_for_each_entry(r, 

[PATCH v5 0/4] resource: Use list_head to link sibling resource

2018-06-11 Thread Baoquan He
This patchset is doing:
1) Replace struct resource's sibling list from singly linked list to
list_head. Clearing out those pointer operation within singly linked
list for better code readability.
2) Based on list_head replacement, add a new function
walk_system_ram_res_rev() which can does reversed iteration on
iomem_resource's siblings.
3) Change kexec_file loading to search system RAM top down for kernel
loadin, using walk_system_ram_res_rev().

Note:
This patchset passed testing on my kvm guest, x86_64 arch with network
enabling. The thing we need pay attetion to is that a root resource's
child member need be initialized specifically with LIST_HEAD_INIT() if
statically defined or INIT_LIST_HEAD() for dynamically definition. Here
Just like we do for iomem_resource/ioport_resource, or the change in
get_pci_domain_busn_res().


Links of the old post (Boris pointed out that we should use
https://lkml.kernel.org/r/Message-ID, while it can't be opened from
my side, so paste all of them here.):
v4:
https://lkml.kernel.org/r/20180507063224.24229-1-...@redhat.com
https://lkml.org/lkml/2018/5/7/36

v3:
https://lkml.kernel.org/r/20180419001848.3041-1-...@redhat.com
https://lkml.org/lkml/2018/4/18/767

v2:
https://lkml.kernel.org/r/20180408024724.16812-1-...@redhat.com
https://lkml.org/lkml/2018/4/7/169

v1:
https://lkml.kernel.org/r/20180322033722.9279-1-...@redhat.com
https://lkml.org/lkml/2018/3/21/952

Changelog:
v4->v5:
  Add new patch 0001 to move duplicated reparent_resources() to
  kernel/resource.c to make it be shared by different ARCH-es.

  Fix several code bugs reported by test robot on ARCH powerpc and
  microblaze.
v3->v4:
  Fix several bugs test robot reported. Rewrite cover letter and patch
  log according to reviewer's comment.

v2->v3:
  Rename resource functions first_child() and sibling() to
  resource_first_chils() and resource_sibling(). Dan suggested this.

  Move resource_first_chils() and resource_sibling() to linux/ioport.h
  and make them as inline function. Rob suggested this. Accordingly add
  linux/list.h including in linux/ioport.h, please help review if this
  bring efficiency degradation or code redundancy.

  The change on struct resource {} bring two pointers of size increase,
  mention this in git log to make it more specifically, Rob suggested
  this.

v1->v2:
  Use list_head instead to link resource siblings. This is suggested by
  Andrew.

  Rewrite walk_system_ram_res_rev() after list_head is taken to link
  resouce siblings.

Baoquan He (4):
  resource: Move reparent_resources() to kernel/resource.c and make it
public
  resource: Use list_head to link sibling resource
  resource: add walk_system_ram_res_rev()
  kexec_file: Load kernel at top of system RAM if required

 arch/arm/plat-samsung/pm-check.c|   6 +-
 arch/microblaze/pci/pci-common.c|  41 +
 arch/powerpc/kernel/pci-common.c|  39 +
 arch/sparc/kernel/ioport.c  |   2 +-
 arch/xtensa/include/asm/pci-bridge.h|   4 +-
 drivers/eisa/eisa-bus.c |   2 +
 drivers/gpu/drm/drm_memory.c|   3 +-
 drivers/gpu/drm/gma500/gtt.c|   5 +-
 drivers/hv/vmbus_drv.c  |  52 +++---
 drivers/input/joystick/iforce/iforce-main.c |   4 +-
 drivers/nvdimm/namespace_devs.c |   6 +-
 drivers/nvdimm/nd.h |   5 +-
 drivers/of/address.c|   4 +-
 drivers/parisc/lba_pci.c|   4 +-
 drivers/pci/host/vmd.c  |   8 +-
 drivers/pci/probe.c |   2 +
 drivers/pci/setup-bus.c |   2 +-
 include/linux/ioport.h  |  21 ++-
 kernel/kexec_file.c |   2 +
 kernel/resource.c   | 259 ++--
 20 files changed, 244 insertions(+), 227 deletions(-)

-- 
2.13.6

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


[PATCH] staging: comedi: add error handling for vmap

2018-06-11 Thread Zhouyang Jia
When vmap fails, the lack of error-handling code may
cause unexpected results.

This patch adds error-handling code after calling vmap.

Signed-off-by: Zhouyang Jia 
---
 drivers/staging/comedi/comedi_buf.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/comedi/comedi_buf.c 
b/drivers/staging/comedi/comedi_buf.c
index f693c2c..5e48693 100644
--- a/drivers/staging/comedi/comedi_buf.c
+++ b/drivers/staging/comedi/comedi_buf.c
@@ -132,9 +132,12 @@ static void __comedi_buf_alloc(struct comedi_device *dev,
spin_unlock_irqrestore(>spin_lock, flags);
 
/* vmap the prealloc_buf if all the pages were allocated */
-   if (i == n_pages)
+   if (i == n_pages) {
async->prealloc_buf = vmap(pages, n_pages, VM_MAP,
   COMEDI_PAGE_PROTECTION);
+   if (!async->prealloc_buf)
+   dev_err(dev->class_dev, "failed to vmap pages\n");
+   }
 
vfree(pages);
 }
-- 
2.7.4

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


[PATCH] staging: rtl8712: add error handling for register_netdev

2018-06-11 Thread Zhouyang Jia
When register_netdev fails, the lack of error-handling code may
cause unexpected results.

This patch adds error-handling code after calling register_netdev.

Signed-off-by: Zhouyang Jia 
---
 drivers/staging/rtl8712/hal_init.c | 8 +++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/rtl8712/hal_init.c 
b/drivers/staging/rtl8712/hal_init.c
index 2a3f074..2b47e75 100644
--- a/drivers/staging/rtl8712/hal_init.c
+++ b/drivers/staging/rtl8712/hal_init.c
@@ -40,6 +40,7 @@
 static void rtl871x_load_fw_cb(const struct firmware *firmware, void *context)
 {
struct _adapter *padapter = context;
+   int rc;
 
complete(>rtl8712_fw_ready);
if (!firmware) {
@@ -53,7 +54,12 @@ static void rtl871x_load_fw_cb(const struct firmware 
*firmware, void *context)
}
padapter->fw = firmware;
/* firmware available - start netdev */
-   register_netdev(padapter->pnetdev);
+   rc = register_netdev(padapter->pnetdev);
+   if (rc) {
+   struct usb_device *udev = padapter->dvobjpriv.pusbdev;
+
+   dev_err(>dev, "r8712u: Unable to register netdev\n");
+   }
 }
 
 static const char firmware_file[] = "rtlwifi/rtl8712u.bin";
-- 
2.7.4

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


Re: [PATCH v3 0/8] staging: mt7621-gpio: last cleanups

2018-06-11 Thread NeilBrown
On Mon, Jun 11 2018, Sergio Paracuellos wrote:

> After submiting this driver to try to get mainlined and get
> out of staging some new cleanups seems to be necessary.
> According to this main of Linus Walleij:
>
> http://driverdev.linuxdriverproject.org/pipermail/driverdev-devel/2018-June/121742.html
>
> this series tries to fix all of the issues in order to send
> v2 and give it a new try. Because I don't have to hardware to
> test my changes I send new cleanups first in staging to make
> easier to NeilBrown test it and get a feedback about them.
>
> Changes in v3:
> - PATCH 7: refactor irq_type to make better code.
> - Add PATCH 8 avoiding the use of custom domain and requesting
>   manually a 'IRQF_SHARED'. It should be working now??

Yes, it is working now - thanks.
With this series, the driver again works for all the tests I can
perform - except that some names aren't unique, as I've mentioned
separately.

Looking over the new code:

- I don't think we need PIN_MASK() any more.  We needed that
  when we had 1 irq_chip which handled 96 irqs.  Now we have
  3 irq_chips with 32 irqs each.

- documentation for 'struct mtk_data' says it is a single
  irqchip, but I don't think it is any more - there is one
  per gpio chip.
  Related: doco for 'struct mtk_gc' contains data for both
   the gpio_chip and the irq_chip.  I don't know if that
   needs to be spelled out.

- In
if (pending) {
for_each_set_bit(bit, , MTK_BANK_WIDTH) {
  I wouldn't bother with the "if (pending)".
  If pending is zero, then find_each_set_bit() won't find anything.
  It is at most a minor optimization.
  This is a personal preference and if you like it that way, leave it.
  Though if you are keen to optimize, then instead of calling
  mtk_gpio_w32(...BIT(bit)) for every found bit, just call
  mtk_gpio_w32(... pending) once at the top.
  
- to_mediatek_gpio() cannot return NULL, so testing "if (!rg)" in
  several places is pointless.

- If the dts file doesn't specify an irq, the irq_of_parse_and_map()
  will return -1 (I think).  This might deserve a warning and probably
  shouldn't cause the probe to fail, but it should cause
  mediatek_gpio_bank_probe to avoid trying to set up interrupts.


Nothing serious, but some might be worth fixing.

Thanks a lot,
NeilBrown


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


Re: [PATCH v2 0/7] staging: mt7621-gpio: last cleanups

2018-06-11 Thread NeilBrown
On Mon, Jun 11 2018, Sergio Paracuellos wrote:

> On Mon, Jun 11, 2018 at 06:33:44PM +1000, NeilBrown wrote:
>> On Mon, Jun 11 2018, Sergio Paracuellos wrote:
>> 
>> > After submiting this driver to try to get mainlined and get
>> > out of staging some new cleanups seems to be necessary.
>> > According to this main of Linus Walleij:
>> >
>> > http://driverdev.linuxdriverproject.org/pipermail/driverdev-devel/2018-June/121742.html
>> >
>> > this series tries to fix all of the issues in order to send
>> > v2 and give it a new try. Because I don't have to hardware to
>> > test my changes I send new cleanups first in staging to make
>> > easier to NeilBrown test it and get a feedback about them.
>> >
>> > Changes in v2:
>> > - Patch where GPIOLIB_IRQCHIP was used avoiding
>> >   the use of a custom irq domain has been dropped to
>> >   be sure after this changes all is working properly.
>> >   (This was PATCH 7 in previous series)
>> > - PATCH 1: 
>> >  * avoid introducing new macros and use 'bank'
>> >field of mtk_gc with register offset.
>> >  * Make correct use of bgpio_init passing new
>> >void __iomem pointers instead of use the
>> >macros. 
>> > - Previous series PATCH 8 now is PATCH 7. Avoid the
>> >   use of a switch-case statement which was wrong and
>> >   distinc if we have RISSING AND FALLING EDGE interrupt
>> >   or HIGH LOW level ones. This last two are exclusive and
>> >   cannot be generated at the same time.
>> >
>> > Also, I think is we finally avoid to use a new irq_domain the
>> > need for the new functions introduced for request and release
>> > resources dissapears. I was diving down the other drivers code
>> > and I see that these two only are used in drivers which use its
>> > own irq_domain. Correct me if I am wrong, please.
>> >
>> > Hope this helps.
>> >
>> > Thanks in advance.
>> 
>> Thanks a lot.
>> This series appears to work, though I sent a separate comment on one
>> piece of code.
>
> Thanks for testing, review and feedback.
>
> I have resent a complete v3 of this series taking into account
> your comments there.
>
>> However the gpio are numbers
>> 480-511
>> 448-479
>> 416-447
>> 
>> instead of
>> 0-31
>> 32-63
>> 64-95
>> 
>> which would be more normal.
>> Maybe when you resubmit I'll raid it with Linus Walleij and see if he
>> can explain why I can't have 0-95.
>
> This change is because the chip.base property changed to be -1 for
> dynamic enumeration of the gpio's. In this mail there is some explanation
> about it:
>
> http://lists.infradead.org/pipermail/linux-rpi-kernel/2014-October/001045.html

Interesting - thanks for the link.

It seems that the goal is to focus more on names than on numbers, and
that probably makes sense.
It means that we need to make sure that the names are useful.

Currently the driver defines 3 gpiochips, one for each bank.

# grep . /sys/class/gpio/gpiochip4*/label
/sys/class/gpio/gpiochip416/label:1e000600.gpio
/sys/class/gpio/gpiochip448/label:1e000600.gpio
/sys/class/gpio/gpiochip480/label:1e000600.gpio

Unfortunately they all have the same label :-(
It would be good if there was a way to add 0, 1, and 2 to the labels, or
something like that.

In /proc/interrupts we now have:

 17:  0  0  0  0  MIPS GIC  19  mt7621, mt7621, 
mt7621

which is the interrupt from the GPIO controller.
It is a little weird that all three banks are named "mt7621" here.
We also have:

 26:  0  0  0  0  GPIO  18  reset

which is the interrupt from GPIO which provides the "reset" button.
I suspect that if I had interrupts form two different banks they would
both be called "GPIO" which would be a little confusing.
We could declare three different 'struct irq_chip' with three different
names, but that would be ugly.  Hopefully there is a better way.

Thanks,
NeilBrown


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


Re: [kbuild-all] [PATCH v3] Drivers: HV: Send one page worth of kmsg dump over Hyper-V during panic

2018-06-11 Thread Ye Xiaolong
Hi,

On 06/11, Sunil Muthuswamy wrote:
>I haven't gotten any test build bot reports for the newer version of the 
>patches that were
>Submitted last week. Is there a way to know what's going on there or force a 
>submission?

If there is no reports for the newer version, it's likely that the new version 
is just fine
and currently 0day bot won't notify build success for lkml patches.

Thanks,
Xiaolong

>
>- sunil
>
>> -Original Message-
>> From: kbuild test robot 
>> Sent: Wednesday, May 23, 2018 7:57 PM
>> To: Sunil Muthuswamy 
>> Cc: kbuild-...@01.org; Haiyang Zhang ;
>> de...@linuxdriverproject.org; Sunil Muthuswamy
>> ; Stephen Hemminger
>> 
>> Subject: Re: [PATCH v3] Drivers: HV: Send one page worth of kmsg dump
>> over Hyper-V during panic
>> 
>> Hi Sunil,
>> 
>> Thank you for the patch! Perhaps something to improve:
>> 
>> [auto build test WARNING on linus/master]
>> [also build test WARNING on v4.17-rc6 next-20180517]
>> [cannot apply to tip/x86/core]
>> [if your patch is applied to the wrong git tree, please drop us a note to 
>> help
>> improve the system]
>> 
>> url:
>> https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub
>> .com%2F0day-ci%2Flinux%2Fcommits%2FSunil-Muthuswamy%2FDrivers-HV-
>> Send-one-page-worth-of-kmsg-dump-over-Hyper-V-during-
>> panic%2F20180523-
>> 035336=02%7C01%7Csunilmut%40microsoft.com%7Cea8837620518441
>> e279808d5c1221032%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C6
>> 36627274402211081=aRiQw64FhftuwLijjsPJigInUHEYBFWWl%2BMcgqI
>> yNl4%3D=0
>> reproduce:
>> # apt-get install sparse
>> make ARCH=x86_64 allmodconfig
>> make C=1 CF=-D__CHECK_ENDIAN__
>> 
>> 
>> sparse warnings: (new ones prefixed by >>)
>> 
>> >> drivers/hv/vmbus_drv.c:1028:5: sparse: symbol
>> 'sysctl_record_panic_msg' was not declared. Should it be static?
>>drivers/hv/vmbus_drv.c:1631:32: sparse: expression using sizeof(void)
>>drivers/hv/vmbus_drv.c:1633:32: sparse: expression using sizeof(void)
>>include/asm-generic/atomic-instrumented.h:358:24: sparse: cast truncates
>> bits from constant value (8010 becomes 10)
>>include/asm-generic/atomic-instrumented.h:360:24: sparse: cast truncates
>> bits from constant value (8010 becomes 10)
>> 
>> Please review and possibly fold the followup patch.
>> 
>> ---
>> 0-DAY kernel test infrastructureOpen Source Technology Center
>> https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.01
>> .org%2Fpipermail%2Fkbuild-
>> all=02%7C01%7Csunilmut%40microsoft.com%7Cea8837620518441e279
>> 808d5c1221032%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C63662
>> 7274402211081=HhJj%2BMSiTeoaxbBDEdMLquOAO%2B5AuQR0yENX
>> BZ%2B77gQ%3D=0   Intel Corporation
>___
>kbuild-all mailing list
>kbuild-...@lists.01.org
>https://lists.01.org/mailman/listinfo/kbuild-all
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging:iio:accel:adis16240: sign extend function avoiding code duplication

2018-06-11 Thread Joe Perches
On Tue, 2018-06-12 at 01:38 +0200, Karim Eshapa wrote:
> Use sign_extend32 kernel function instead of code duplication.
> Safe also for 16 bit.

Perhaps remove the bits declaration and assignments
and just use 9 directly.

> diff --git a/drivers/staging/iio/accel/adis16240.c 
> b/drivers/staging/iio/accel/adis16240.c
[]
> @@ -292,9 +292,7 @@ static int adis16240_read_raw(struct iio_dev *indio_dev,
>   ret = adis_read_reg_16(st, addr, );
>   if (ret)
>   return ret;
> - val16 &= (1 << bits) - 1;
> - val16 = (s16)(val16 << (16 - bits)) >> (16 - bits);
> - *val = val16;
> + *val = sign_extend32(val16, bits - 1);
>   return IIO_VAL_INT;
>   case IIO_CHAN_INFO_PEAK:
>   bits = 10;
> @@ -302,9 +300,7 @@ static int adis16240_read_raw(struct iio_dev *indio_dev,
>   ret = adis_read_reg_16(st, addr, );
>   if (ret)
>   return ret;
> - val16 &= (1 << bits) - 1;
> - val16 = (s16)(val16 << (16 - bits)) >> (16 - bits);
> - *val = val16;
> + *val = sign_extend32(val16, bits - 1);
>   return IIO_VAL_INT;
>   }
>   return -EINVAL;
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: pi433: add mutex fixing race condition when accessing tx_cfg

2018-06-11 Thread Hugo Lefeuvre
In the PI433_IOC_WR_TX_CFG case in pi433_ioctl, instance->tx_cfg is
modified using

copy_from_user(>tx_cfg, argp, sizeof(struct pi433_tx_cfg)))

without any kind of synchronization. In the case where two threads
would execute this same command concurrently the tx_cfg field might
enter in an inconsistent state.

Add a mutex making sure that the PI433_IOC_WR_TX_CFG case will never
be run by several threads concurrently.

Signed-off-by: Hugo Lefeuvre 
---
 drivers/staging/pi433/pi433_if.c | 9 -
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/pi433/pi433_if.c b/drivers/staging/pi433/pi433_if.c
index d1e0ddbc79ce..94c9d5482f44 100644
--- a/drivers/staging/pi433/pi433_if.c
+++ b/drivers/staging/pi433/pi433_if.c
@@ -115,6 +115,7 @@ struct pi433_device {
 
 struct pi433_instance {
struct pi433_device *device;
+   struct mutextx_cfg_lock; /* guards race conditions when 
updating tx config */
struct pi433_tx_cfg tx_cfg;
 };
 
@@ -889,9 +890,13 @@ pi433_ioctl(struct file *filp, unsigned int cmd, unsigned 
long arg)
return -EFAULT;
break;
case PI433_IOC_WR_TX_CFG:
+   mutex_lock(>tx_cfg_lock);
if (copy_from_user(>tx_cfg, argp,
-  sizeof(struct pi433_tx_cfg)))
+  sizeof(struct pi433_tx_cfg))) {
+   mutex_unlock(>tx_cfg_lock);
return -EFAULT;
+   }
+   mutex_unlock(>tx_cfg_lock);
break;
case PI433_IOC_RD_RX_CFG:
if (copy_to_user(argp, >rx_cfg,
@@ -966,6 +971,8 @@ static int pi433_open(struct inode *inode, struct file 
*filp)
instance->tx_cfg.bit_rate = 4711;
// TODO: fill instance->tx_cfg;
 
+   mutex_init(>tx_cfg_lock);
+
/* instance data as context */
filp->private_data = instance;
nonseekable_open(inode, filp);
-- 
2.17.1
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging:iio:accel:adis16240: sign extend function avoiding code duplication

2018-06-11 Thread Karim Eshapa
Use sign_extend32 kernel function instead of code duplication.
Safe also for 16 bit.

Signed-off-by: Karim Eshapa 
---
 drivers/staging/iio/accel/adis16240.c | 11 ++-
 1 file changed, 2 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/iio/accel/adis16240.c 
b/drivers/staging/iio/accel/adis16240.c
index fff6d99089cc..24e525f1ef25 100644
--- a/drivers/staging/iio/accel/adis16240.c
+++ b/drivers/staging/iio/accel/adis16240.c
@@ -250,7 +250,6 @@ static int adis16240_read_raw(struct iio_dev *indio_dev,
 {
struct adis *st = iio_priv(indio_dev);
int ret;
-   int bits;
u8 addr;
s16 val16;
 
@@ -287,24 +286,18 @@ static int adis16240_read_raw(struct iio_dev *indio_dev,
*val = 25000 / 244 - 0x133; /* 25 C = 0x133 */
return IIO_VAL_INT;
case IIO_CHAN_INFO_CALIBBIAS:
-   bits = 10;
addr = adis16240_addresses[chan->scan_index][0];
ret = adis_read_reg_16(st, addr, );
if (ret)
return ret;
-   val16 &= (1 << bits) - 1;
-   val16 = (s16)(val16 << (16 - bits)) >> (16 - bits);
-   *val = val16;
+   *val = sign_extend32(val16, 9);
return IIO_VAL_INT;
case IIO_CHAN_INFO_PEAK:
-   bits = 10;
addr = adis16240_addresses[chan->scan_index][1];
ret = adis_read_reg_16(st, addr, );
if (ret)
return ret;
-   val16 &= (1 << bits) - 1;
-   val16 = (s16)(val16 << (16 - bits)) >> (16 - bits);
-   *val = val16;
+   *val = sign_extend32(val16, 9);
return IIO_VAL_INT;
}
return -EINVAL;
-- 
2.17.1

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


Re: [PATCH] staging: speakup: refactor synths array to use a list

2018-06-11 Thread John Covici
Maybe I can do it, I have a kernel with speakup, using 4.9.43.  Will
the patch fit there?

On Mon, 11 Jun 2018 18:57:03 -0400,
Samuel Thibault wrote:
> 
> [1  ]
> Hello,
> 
> Samuel Thibault, le mer. 06 juin 2018 15:26:28 +0200, a ecrit:
> > I'd also rather see it tested in the real wild before committing. Could
> > somebody on the speakup mailing list test the patch? (which I have
> > re-attached as a file for conveniency).
> 
> Anybody up for testing please?
> 
> If people want to see speakup get mainlined instead of staging, please
> help.
> 
> Samuel
> [2 patch ]
> ---
>  drivers/staging/speakup/spk_types.h |  2 ++
>  drivers/staging/speakup/synth.c | 40 ++---
>  2 files changed, 15 insertions(+), 27 deletions(-)
> 
> diff --git a/drivers/staging/speakup/spk_types.h 
> b/drivers/staging/speakup/spk_types.h
> index 3e082dc3d45c..a2fc72c29894 100644
> --- a/drivers/staging/speakup/spk_types.h
> +++ b/drivers/staging/speakup/spk_types.h
> @@ -160,6 +160,8 @@ struct spk_io_ops {
>  };
>  
>  struct spk_synth {
> + struct list_head node;
> +
>   const char *name;
>   const char *version;
>   const char *long_name;
> diff --git a/drivers/staging/speakup/synth.c b/drivers/staging/speakup/synth.c
> index 7deeb7061018..25f259ee4ffc 100644
> --- a/drivers/staging/speakup/synth.c
> +++ b/drivers/staging/speakup/synth.c
> @@ -18,8 +18,7 @@
>  #include "speakup.h"
>  #include "serialio.h"
>  
> -#define MAXSYNTHS   16  /* Max number of synths in array. */
> -static struct spk_synth *synths[MAXSYNTHS + 1];
> +static LIST_HEAD(synths);
>  struct spk_synth *synth;
>  char spk_pitch_buff[32] = "";
>  static int module_status;
> @@ -355,9 +354,8 @@ struct var_t synth_time_vars[] = {
>  /* called by: speakup_init() */
>  int synth_init(char *synth_name)
>  {
> - int i;
>   int ret = 0;
> - struct spk_synth *synth = NULL;
> + struct spk_synth *tmp, *synth = NULL;
>  
>   if (!synth_name)
>   return 0;
> @@ -371,9 +369,10 @@ int synth_init(char *synth_name)
>  
>   mutex_lock(_mutex);
>   /* First, check if we already have it loaded. */
> - for (i = 0; i < MAXSYNTHS && synths[i]; i++)
> - if (strcmp(synths[i]->name, synth_name) == 0)
> - synth = synths[i];
> + list_for_each_entry(tmp, , node) {
> + if (strcmp(tmp->name, synth_name) == 0)
> + synth = tmp;
> + }
>  
>   /* If we got one, initialize it now. */
>   if (synth)
> @@ -448,29 +447,23 @@ void synth_release(void)
>  /* called by: all_driver_init() */
>  int synth_add(struct spk_synth *in_synth)
>  {
> - int i;
>   int status = 0;
> + struct spk_synth *tmp;
>  
>   mutex_lock(_mutex);
> - for (i = 0; i < MAXSYNTHS && synths[i]; i++)
> - /* synth_remove() is responsible for rotating the array down */
> - if (in_synth == synths[i]) {
> +
> + list_for_each_entry(tmp, , node) {
> + if (tmp == in_synth) {
>   mutex_unlock(_mutex);
>   return 0;
>   }
> - if (i == MAXSYNTHS) {
> - pr_warn("Error: attempting to add a synth past end of array\n");
> - mutex_unlock(_mutex);
> - return -1;
>   }
>  
>   if (in_synth->startup)
>   status = do_synth_init(in_synth);
>  
> - if (!status) {
> - synths[i++] = in_synth;
> - synths[i] = NULL;
> - }
> + if (!status)
> + list_add_tail(_synth->node, );
>  
>   mutex_unlock(_mutex);
>   return status;
> @@ -479,17 +472,10 @@ EXPORT_SYMBOL_GPL(synth_add);
>  
>  void synth_remove(struct spk_synth *in_synth)
>  {
> - int i;
> -
>   mutex_lock(_mutex);
>   if (synth == in_synth)
>   synth_release();
> - for (i = 0; synths[i]; i++) {
> - if (in_synth == synths[i])
> - break;
> - }
> - for ( ; synths[i]; i++) /* compress table */
> - synths[i] = synths[i + 1];
> + list_del(_synth->node);
>   module_status = 0;
>   mutex_unlock(_mutex);
>  }
> -- 
> 2.17.1
> [3  ]
> ___
> Speakup mailing list
> spea...@linux-speakup.org
> http://linux-speakup.org/cgi-bin/mailman/listinfo/speakup

-- 
Your life is like a penny.  You're going to lose it.  The question is:
How do
you spend it?

 John Covici wb2una
 cov...@ccs.covici.com
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: speakup: refactor synths array to use a list

2018-06-11 Thread Gregory Nowak
On Tue, Jun 12, 2018 at 12:57:03AM +0200, Samuel Thibault wrote:
> Anybody up for testing please?
> 
> If people want to see speakup get mainlined instead of staging, please
> help.

If I understand right, this patch changes how synthesizers are loaded
and unloaded through /sys/accessibility/speakup/synth, correct? If
yes, then would for example verifying that

echo bns >/sys/accessibility/speakup/synth
echo soft >/sys/accessibility/speakup/synth

does what it should be good enough of a test? If this would not be
good enough, please describe exactly what needs testing.

I likely won't be able to do a kernel build until this weekend, but
should be able to report back next Monday on the 18th.

Greg


-- 
web site: http://www.gregn.net
gpg public key: http://www.gregn.net/pubkey.asc
skype: gregn1
(authorization required, add me to your contacts list first)
If we haven't been in touch before, e-mail me before adding me to your contacts.

--
Free domains: http://www.eu.org/ or mail dns-mana...@eu.org
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging:iio:accel:adis16240: sign extend function avoiding code duplication

2018-06-11 Thread Karim Eshapa
Use sign_extend32 kernel function instead of code duplication.
Safe also for 16 bit.

Signed-off-by: Karim Eshapa 
---
 drivers/staging/iio/accel/adis16240.c | 8 ++--
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/iio/accel/adis16240.c 
b/drivers/staging/iio/accel/adis16240.c
index fff6d99089cc..9adb5badb915 100644
--- a/drivers/staging/iio/accel/adis16240.c
+++ b/drivers/staging/iio/accel/adis16240.c
@@ -292,9 +292,7 @@ static int adis16240_read_raw(struct iio_dev *indio_dev,
ret = adis_read_reg_16(st, addr, );
if (ret)
return ret;
-   val16 &= (1 << bits) - 1;
-   val16 = (s16)(val16 << (16 - bits)) >> (16 - bits);
-   *val = val16;
+   *val = sign_extend32(val16, bits - 1);
return IIO_VAL_INT;
case IIO_CHAN_INFO_PEAK:
bits = 10;
@@ -302,9 +300,7 @@ static int adis16240_read_raw(struct iio_dev *indio_dev,
ret = adis_read_reg_16(st, addr, );
if (ret)
return ret;
-   val16 &= (1 << bits) - 1;
-   val16 = (s16)(val16 << (16 - bits)) >> (16 - bits);
-   *val = val16;
+   *val = sign_extend32(val16, bits - 1);
return IIO_VAL_INT;
}
return -EINVAL;
-- 
2.17.1

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


Re: [PATCH] staging: speakup: refactor synths array to use a list

2018-06-11 Thread Samuel Thibault
Hello,

Samuel Thibault, le mer. 06 juin 2018 15:26:28 +0200, a ecrit:
> I'd also rather see it tested in the real wild before committing. Could
> somebody on the speakup mailing list test the patch? (which I have
> re-attached as a file for conveniency).

Anybody up for testing please?

If people want to see speakup get mainlined instead of staging, please
help.

Samuel
---
 drivers/staging/speakup/spk_types.h |  2 ++
 drivers/staging/speakup/synth.c | 40 ++---
 2 files changed, 15 insertions(+), 27 deletions(-)

diff --git a/drivers/staging/speakup/spk_types.h 
b/drivers/staging/speakup/spk_types.h
index 3e082dc3d45c..a2fc72c29894 100644
--- a/drivers/staging/speakup/spk_types.h
+++ b/drivers/staging/speakup/spk_types.h
@@ -160,6 +160,8 @@ struct spk_io_ops {
 };
 
 struct spk_synth {
+   struct list_head node;
+
const char *name;
const char *version;
const char *long_name;
diff --git a/drivers/staging/speakup/synth.c b/drivers/staging/speakup/synth.c
index 7deeb7061018..25f259ee4ffc 100644
--- a/drivers/staging/speakup/synth.c
+++ b/drivers/staging/speakup/synth.c
@@ -18,8 +18,7 @@
 #include "speakup.h"
 #include "serialio.h"
 
-#define MAXSYNTHS   16  /* Max number of synths in array. */
-static struct spk_synth *synths[MAXSYNTHS + 1];
+static LIST_HEAD(synths);
 struct spk_synth *synth;
 char spk_pitch_buff[32] = "";
 static int module_status;
@@ -355,9 +354,8 @@ struct var_t synth_time_vars[] = {
 /* called by: speakup_init() */
 int synth_init(char *synth_name)
 {
-   int i;
int ret = 0;
-   struct spk_synth *synth = NULL;
+   struct spk_synth *tmp, *synth = NULL;
 
if (!synth_name)
return 0;
@@ -371,9 +369,10 @@ int synth_init(char *synth_name)
 
mutex_lock(_mutex);
/* First, check if we already have it loaded. */
-   for (i = 0; i < MAXSYNTHS && synths[i]; i++)
-   if (strcmp(synths[i]->name, synth_name) == 0)
-   synth = synths[i];
+   list_for_each_entry(tmp, , node) {
+   if (strcmp(tmp->name, synth_name) == 0)
+   synth = tmp;
+   }
 
/* If we got one, initialize it now. */
if (synth)
@@ -448,29 +447,23 @@ void synth_release(void)
 /* called by: all_driver_init() */
 int synth_add(struct spk_synth *in_synth)
 {
-   int i;
int status = 0;
+   struct spk_synth *tmp;
 
mutex_lock(_mutex);
-   for (i = 0; i < MAXSYNTHS && synths[i]; i++)
-   /* synth_remove() is responsible for rotating the array down */
-   if (in_synth == synths[i]) {
+
+   list_for_each_entry(tmp, , node) {
+   if (tmp == in_synth) {
mutex_unlock(_mutex);
return 0;
}
-   if (i == MAXSYNTHS) {
-   pr_warn("Error: attempting to add a synth past end of array\n");
-   mutex_unlock(_mutex);
-   return -1;
}
 
if (in_synth->startup)
status = do_synth_init(in_synth);
 
-   if (!status) {
-   synths[i++] = in_synth;
-   synths[i] = NULL;
-   }
+   if (!status)
+   list_add_tail(_synth->node, );
 
mutex_unlock(_mutex);
return status;
@@ -479,17 +472,10 @@ EXPORT_SYMBOL_GPL(synth_add);
 
 void synth_remove(struct spk_synth *in_synth)
 {
-   int i;
-
mutex_lock(_mutex);
if (synth == in_synth)
synth_release();
-   for (i = 0; synths[i]; i++) {
-   if (in_synth == synths[i])
-   break;
-   }
-   for ( ; synths[i]; i++) /* compress table */
-   synths[i] = synths[i + 1];
+   list_del(_synth->node);
module_status = 0;
mutex_unlock(_mutex);
 }
-- 
2.17.1
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v3] staging: lustre: Change return type to vm_fault_t

2018-06-11 Thread Greg KH
On Tue, Jun 12, 2018 at 02:30:27AM +0530, Souptick Joarder wrote:
> > >
> > > If no further comment, we would like to get this patch in 4.18-rc-X.
> >
> > Why?  Is it a regression fix?  That's all that is allowed after -rc1.
> 
> No, this is not regression fix. We need to get this into 4.18-rc-1.  But
> mostly it can't make into linus tree in rc-1 :)

Why does it _have_ to get into 4.18-rc1?  My tree is long-closed and
Linus already has all of my patches in his tree for the staging section
of the kernel.

> > And have you tried applying it to Linus's current tree?  :)
> 
> Last tested on 4.17-rc-6 and it worked fine. Let me verify in current tree.

Try it, you might be surprised :)

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


Re: [PATCH v3] staging: lustre: Change return type to vm_fault_t

2018-06-11 Thread Greg KH
On Tue, Jun 12, 2018 at 02:00:47AM +0530, Souptick Joarder wrote:
> On Mon, May 21, 2018 at 11:39 PM, Souptick Joarder  
> wrote:
> > Use new return type vm_fault_t for fault handler. For
> > now, this is just documenting that the function returns
> > a VM_FAULT value rather than an errno. Once all instances
> > are converted, vm_fault_t will become a distinct type.
> >
> > Ref-> commit 1c8f422059ae ("mm: change return type to
> > vm_fault_t") was added in 4.17-rc1 to introduce the new
> > typedef vm_fault_t. Currently we are making change to all
> > drivers to return vm_fault_t for page fault handlers. As
> > part of that lustre driver is also getting changed to
> > return vm_fault_t type.
> >
> > Signed-off-by: Souptick Joarder 
> > ---
> > v2: updated the change log
> >
> > v3: updated the change log
> >
> >  drivers/staging/lustre/lustre/llite/llite_mmap.c | 35 
> > 
> >  1 file changed, 18 insertions(+), 17 deletions(-)
> >
> > diff --git a/drivers/staging/lustre/lustre/llite/llite_mmap.c 
> > b/drivers/staging/lustre/lustre/llite/llite_mmap.c
> > index c0533bd..5b8fd10 100644
> > --- a/drivers/staging/lustre/lustre/llite/llite_mmap.c
> > +++ b/drivers/staging/lustre/lustre/llite/llite_mmap.c
> > @@ -231,7 +231,7 @@ static int ll_page_mkwrite0(struct vm_area_struct *vma, 
> > struct page *vmpage,
> > return result;
> >  }
> >
> > -static inline int to_fault_error(int result)
> > +static inline vm_fault_t to_fault_error(int result)
> >  {
> > switch (result) {
> > case 0:
> > @@ -261,7 +261,7 @@ static inline int to_fault_error(int result)
> >   * \retval VM_FAULT_ERROR on general error
> >   * \retval NOPAGE_OOM not have memory for allocate new page
> >   */
> > -static int ll_fault0(struct vm_area_struct *vma, struct vm_fault *vmf)
> > +static vm_fault_t ll_fault0(struct vm_area_struct *vma, struct vm_fault 
> > *vmf)
> >  {
> > struct lu_env  *env;
> > struct cl_io*io;
> > @@ -269,16 +269,16 @@ static int ll_fault0(struct vm_area_struct *vma, 
> > struct vm_fault *vmf)
> > struct page  *vmpage;
> > unsigned long   ra_flags;
> > int   result = 0;
> > -   int   fault_ret = 0;
> > +   vm_fault_t  fault_ret = 0;
> > u16 refcheck;
> >
> > env = cl_env_get();
> > if (IS_ERR(env))
> > -   return PTR_ERR(env);
> > +   return VM_FAULT_ERROR;
> >
> > io = ll_fault_io_init(env, vma, vmf->pgoff, _flags);
> > if (IS_ERR(io)) {
> > -   result = to_fault_error(PTR_ERR(io));
> > +   fault_ret = to_fault_error(PTR_ERR(io));
> > goto out;
> > }
> >
> > @@ -319,15 +319,15 @@ static int ll_fault0(struct vm_area_struct *vma, 
> > struct vm_fault *vmf)
> > if (result != 0 && !(fault_ret & VM_FAULT_RETRY))
> > fault_ret |= to_fault_error(result);
> >
> > -   CDEBUG(D_MMAP, "%s fault %d/%d\n", current->comm, fault_ret, 
> > result);
> > +   CDEBUG(D_MMAP, "%s fault %x/%d\n", current->comm, fault_ret, 
> > result);
> > return fault_ret;
> >  }
> >
> > -static int ll_fault(struct vm_fault *vmf)
> > +static vm_fault_t ll_fault(struct vm_fault *vmf)
> >  {
> > int count = 0;
> > bool printed = false;
> > -   int result;
> > +   vm_fault_t result;
> > sigset_t set;
> >
> > /* Only SIGKILL and SIGTERM are allowed for fault/nopage/mkwrite
> > @@ -364,18 +364,19 @@ static int ll_fault(struct vm_fault *vmf)
> > return result;
> >  }
> >
> > -static int ll_page_mkwrite(struct vm_fault *vmf)
> > +static vm_fault_t ll_page_mkwrite(struct vm_fault *vmf)
> >  {
> > struct vm_area_struct *vma = vmf->vma;
> > int count = 0;
> > bool printed = false;
> > bool retry;
> > -   int result;
> > +   int err;
> > +   vm_fault_t ret;
> >
> > file_update_time(vma->vm_file);
> > do {
> > retry = false;
> > -   result = ll_page_mkwrite0(vma, vmf->page, );
> > +   err = ll_page_mkwrite0(vma, vmf->page, );
> >
> > if (!printed && ++count > 16) {
> > const struct dentry *de = 
> > vma->vm_file->f_path.dentry;
> > @@ -387,25 +388,25 @@ static int ll_page_mkwrite(struct vm_fault *vmf)
> > }
> > } while (retry);
> >
> > -   switch (result) {
> > +   switch (err) {
> > case 0:
> > LASSERT(PageLocked(vmf->page));
> > -   result = VM_FAULT_LOCKED;
> > +   ret = VM_FAULT_LOCKED;
> > break;
> > case -ENODATA:
> > case -EAGAIN:
> > case -EFAULT:
> > -   result = VM_FAULT_NOPAGE;
> > +   ret = VM_FAULT_NOPAGE;
> > break;
> > case -ENOMEM:
> > -   result = VM_FAULT_OOM;
> > +   

Re: [PATCH v4 2/2] media: staging/imx: fill vb2_v4l2_buffer sequence entry

2018-06-11 Thread Peter Seiderer
Hello *,

On Fri, 16 Mar 2018 10:05:44 -0700, Steve Longerbeam  
wrote:

> Reviewed-by: Steve Longerbeam 

Ping? Anybody taking this one?

Regards,
Peter

> 
> 
> On 03/15/2018 12:13 PM, Peter Seiderer wrote:
> > - enables gstreamer v4l2src lost frame detection, e.g:
> >
> >0:00:08.685185668  348  0x54f520 WARN  v4l2src 
> > gstv4l2src.c:970:gst_v4l2src_create: lost frames detected: count 
> > = 141 - ts: 0:00:08.330177332
> >
> > - fixes v4l2-compliance test failure:
> >
> >Streaming ioctls:
> >test read/write: OK (Not Supported)
> >Video Capture:
> >Buffer: 0 Sequence: 0 Field: None Timestamp: 92.991450s
> >Buffer: 1 Sequence: 0 Field: None Timestamp: 93.008135s
> >fail: v4l2-test-buffers.cpp(294): (int)g_sequence() < 
> > seq.last_seq + 1
> >fail: v4l2-test-buffers.cpp(707): buf.check(q, last_seq)
> >
> > Signed-off-by: Peter Seiderer 
> > ---
> > Changes in v2:
> >- fill vb2_v4l2_buffer sequence entry in imx-ic-prpencvf too
> >  (suggested by Steve Longerbeam)
> >
> > Changes in v3:
> >- add changelog (suggested by Greg Kroah-Hartman, Fabio Estevam
> >  and Dan Carpenter) and patch history
> >- use u32 (instead of __u32) (suggested by Dan Carpenter)
> >- let sequence counter start with zero, keeping v4l2-compliance
> >  testing happy (needs additional setting of field to a valid
> >  value, patch will follow soon)
> >
> > Changes in v4:
> >- add v4l2-compliance test failure to changelog
> >- reorder frame_sequence increment and assignement to
> >  avoid -1 as start value (suggeted by Steve Longerbeam)
> > ---
> >   drivers/staging/media/imx/imx-ic-prpencvf.c | 4 
> >   drivers/staging/media/imx/imx-media-csi.c   | 4 
> >   2 files changed, 8 insertions(+)
> >
> > diff --git a/drivers/staging/media/imx/imx-ic-prpencvf.c 
> > b/drivers/staging/media/imx/imx-ic-prpencvf.c
> > index ffeb017c73b2..28f41caba05d 100644
> > --- a/drivers/staging/media/imx/imx-ic-prpencvf.c
> > +++ b/drivers/staging/media/imx/imx-ic-prpencvf.c
> > @@ -103,6 +103,7 @@ struct prp_priv {
> > int nfb4eof_irq;
> >   
> > int stream_count;
> > +   u32 frame_sequence; /* frame sequence counter */
> > bool last_eof;  /* waiting for last EOF at stream off */
> > bool nfb4eof;/* NFB4EOF encountered during streaming */
> > struct completion last_eof_comp;
> > @@ -211,12 +212,14 @@ static void prp_vb2_buf_done(struct prp_priv *priv, 
> > struct ipuv3_channel *ch)
> > done = priv->active_vb2_buf[priv->ipu_buf_num];
> > if (done) {
> > done->vbuf.field = vdev->fmt.fmt.pix.field;
> > +   done->vbuf.sequence = priv->frame_sequence;
> > vb = >vbuf.vb2_buf;
> > vb->timestamp = ktime_get_ns();
> > vb2_buffer_done(vb, priv->nfb4eof ?
> > VB2_BUF_STATE_ERROR : VB2_BUF_STATE_DONE);
> > }
> >   
> > +   priv->frame_sequence++;
> > priv->nfb4eof = false;
> >   
> > /* get next queued buffer */
> > @@ -638,6 +641,7 @@ static int prp_start(struct prp_priv *priv)
> >   
> > /* init EOF completion waitq */
> > init_completion(>last_eof_comp);
> > +   priv->frame_sequence = 0;
> > priv->last_eof = false;
> > priv->nfb4eof = false;
> >   
> > diff --git a/drivers/staging/media/imx/imx-media-csi.c 
> > b/drivers/staging/media/imx/imx-media-csi.c
> > index 5f69117b5811..3f2ce05848f3 100644
> > --- a/drivers/staging/media/imx/imx-media-csi.c
> > +++ b/drivers/staging/media/imx/imx-media-csi.c
> > @@ -111,6 +111,7 @@ struct csi_priv {
> > struct v4l2_ctrl_handler ctrl_hdlr;
> >   
> > int stream_count; /* streaming counter */
> > +   u32 frame_sequence; /* frame sequence counter */
> > bool last_eof;   /* waiting for last EOF at stream off */
> > bool nfb4eof;/* NFB4EOF encountered during streaming */
> > struct completion last_eof_comp;
> > @@ -237,12 +238,14 @@ static void csi_vb2_buf_done(struct csi_priv *priv)
> > done = priv->active_vb2_buf[priv->ipu_buf_num];
> > if (done) {
> > done->vbuf.field = vdev->fmt.fmt.pix.field;
> > +   done->vbuf.sequence = priv->frame_sequence;
> > vb = >vbuf.vb2_buf;
> > vb->timestamp = ktime_get_ns();
> > vb2_buffer_done(vb, priv->nfb4eof ?
> > VB2_BUF_STATE_ERROR : VB2_BUF_STATE_DONE);
> > }
> >   
> > +   priv->frame_sequence++;
> > priv->nfb4eof = false;
> >   
> > /* get next queued buffer */
> > @@ -544,6 +547,7 @@ static int csi_idmac_start(struct csi_priv *priv)
> >   
> > /* init EOF completion waitq */
> > init_completion(>last_eof_comp);
> > +   priv->frame_sequence = 0;
> > priv->last_eof = false;
> > priv->nfb4eof = false;
> > 
> 

___
devel mailing list
de...@linuxdriverproject.org

Re: [PATCH v4 1/2] media: staging/imx: fill vb2_v4l2_buffer field entry

2018-06-11 Thread Peter Seiderer
Hello *,

On Fri, 16 Mar 2018 10:02:47 -0700, Steve Longerbeam  
wrote:

> Reviewed-by: Steve Longerbeam 

Ping? Anybody taking this one?

Regards,
Peter

> 
> 
> On 03/15/2018 12:13 PM, Peter Seiderer wrote:
> > - fixes gstreamer v4l2src warning:
> >
> >0:00:00.716640334  349  0x164f720 WARN  v4l2bufferpool 
> > gstv4l2bufferpool.c:1195:gst_v4l2_buffer_pool_dqbuf: 
> > Driver should never set v4l2_buffer.field to ANY
> >
> > - fixes v4l2-compliance test failure:
> >
> >Streaming ioctls:
> >test read/write: OK (Not Supported)
> >Video Capture:
> >Buffer: 0 Sequence: 0 Field: Any Timestamp: 58.383658s
> >fail: v4l2-test-buffers.cpp(297): g_field() == 
> > V4L2_FIELD_ANY
> >
> > Signed-off-by: Peter Seiderer 
> > ---
> > Changes in v4:
> >- new patch (put first because patch is needed to advance with
> >  the v4l2-compliance test), thanks to Philipp Zabel
> >   for suggested solution for the right
> >  field value source
> > ---
> >   drivers/staging/media/imx/imx-ic-prpencvf.c | 1 +
> >   drivers/staging/media/imx/imx-media-csi.c   | 1 +
> >   2 files changed, 2 insertions(+)
> >
> > diff --git a/drivers/staging/media/imx/imx-ic-prpencvf.c 
> > b/drivers/staging/media/imx/imx-ic-prpencvf.c
> > index ae453fd422f0..ffeb017c73b2 100644
> > --- a/drivers/staging/media/imx/imx-ic-prpencvf.c
> > +++ b/drivers/staging/media/imx/imx-ic-prpencvf.c
> > @@ -210,6 +210,7 @@ static void prp_vb2_buf_done(struct prp_priv *priv, 
> > struct ipuv3_channel *ch)
> >   
> > done = priv->active_vb2_buf[priv->ipu_buf_num];
> > if (done) {
> > +   done->vbuf.field = vdev->fmt.fmt.pix.field;
> > vb = >vbuf.vb2_buf;
> > vb->timestamp = ktime_get_ns();
> > vb2_buffer_done(vb, priv->nfb4eof ?
> > diff --git a/drivers/staging/media/imx/imx-media-csi.c 
> > b/drivers/staging/media/imx/imx-media-csi.c
> > index 5a195f80a24d..5f69117b5811 100644
> > --- a/drivers/staging/media/imx/imx-media-csi.c
> > +++ b/drivers/staging/media/imx/imx-media-csi.c
> > @@ -236,6 +236,7 @@ static void csi_vb2_buf_done(struct csi_priv *priv)
> >   
> > done = priv->active_vb2_buf[priv->ipu_buf_num];
> > if (done) {
> > +   done->vbuf.field = vdev->fmt.fmt.pix.field;
> > vb = >vbuf.vb2_buf;
> > vb->timestamp = ktime_get_ns();
> > vb2_buffer_done(vb, priv->nfb4eof ?  
> 

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


Re: [PATCH v3] staging: lustre: Change return type to vm_fault_t

2018-06-11 Thread Souptick Joarder
On Mon, May 21, 2018 at 11:39 PM, Souptick Joarder  wrote:
> Use new return type vm_fault_t for fault handler. For
> now, this is just documenting that the function returns
> a VM_FAULT value rather than an errno. Once all instances
> are converted, vm_fault_t will become a distinct type.
>
> Ref-> commit 1c8f422059ae ("mm: change return type to
> vm_fault_t") was added in 4.17-rc1 to introduce the new
> typedef vm_fault_t. Currently we are making change to all
> drivers to return vm_fault_t for page fault handlers. As
> part of that lustre driver is also getting changed to
> return vm_fault_t type.
>
> Signed-off-by: Souptick Joarder 
> ---
> v2: updated the change log
>
> v3: updated the change log
>
>  drivers/staging/lustre/lustre/llite/llite_mmap.c | 35 
> 
>  1 file changed, 18 insertions(+), 17 deletions(-)
>
> diff --git a/drivers/staging/lustre/lustre/llite/llite_mmap.c 
> b/drivers/staging/lustre/lustre/llite/llite_mmap.c
> index c0533bd..5b8fd10 100644
> --- a/drivers/staging/lustre/lustre/llite/llite_mmap.c
> +++ b/drivers/staging/lustre/lustre/llite/llite_mmap.c
> @@ -231,7 +231,7 @@ static int ll_page_mkwrite0(struct vm_area_struct *vma, 
> struct page *vmpage,
> return result;
>  }
>
> -static inline int to_fault_error(int result)
> +static inline vm_fault_t to_fault_error(int result)
>  {
> switch (result) {
> case 0:
> @@ -261,7 +261,7 @@ static inline int to_fault_error(int result)
>   * \retval VM_FAULT_ERROR on general error
>   * \retval NOPAGE_OOM not have memory for allocate new page
>   */
> -static int ll_fault0(struct vm_area_struct *vma, struct vm_fault *vmf)
> +static vm_fault_t ll_fault0(struct vm_area_struct *vma, struct vm_fault *vmf)
>  {
> struct lu_env  *env;
> struct cl_io*io;
> @@ -269,16 +269,16 @@ static int ll_fault0(struct vm_area_struct *vma, struct 
> vm_fault *vmf)
> struct page  *vmpage;
> unsigned long   ra_flags;
> int   result = 0;
> -   int   fault_ret = 0;
> +   vm_fault_t  fault_ret = 0;
> u16 refcheck;
>
> env = cl_env_get();
> if (IS_ERR(env))
> -   return PTR_ERR(env);
> +   return VM_FAULT_ERROR;
>
> io = ll_fault_io_init(env, vma, vmf->pgoff, _flags);
> if (IS_ERR(io)) {
> -   result = to_fault_error(PTR_ERR(io));
> +   fault_ret = to_fault_error(PTR_ERR(io));
> goto out;
> }
>
> @@ -319,15 +319,15 @@ static int ll_fault0(struct vm_area_struct *vma, struct 
> vm_fault *vmf)
> if (result != 0 && !(fault_ret & VM_FAULT_RETRY))
> fault_ret |= to_fault_error(result);
>
> -   CDEBUG(D_MMAP, "%s fault %d/%d\n", current->comm, fault_ret, result);
> +   CDEBUG(D_MMAP, "%s fault %x/%d\n", current->comm, fault_ret, result);
> return fault_ret;
>  }
>
> -static int ll_fault(struct vm_fault *vmf)
> +static vm_fault_t ll_fault(struct vm_fault *vmf)
>  {
> int count = 0;
> bool printed = false;
> -   int result;
> +   vm_fault_t result;
> sigset_t set;
>
> /* Only SIGKILL and SIGTERM are allowed for fault/nopage/mkwrite
> @@ -364,18 +364,19 @@ static int ll_fault(struct vm_fault *vmf)
> return result;
>  }
>
> -static int ll_page_mkwrite(struct vm_fault *vmf)
> +static vm_fault_t ll_page_mkwrite(struct vm_fault *vmf)
>  {
> struct vm_area_struct *vma = vmf->vma;
> int count = 0;
> bool printed = false;
> bool retry;
> -   int result;
> +   int err;
> +   vm_fault_t ret;
>
> file_update_time(vma->vm_file);
> do {
> retry = false;
> -   result = ll_page_mkwrite0(vma, vmf->page, );
> +   err = ll_page_mkwrite0(vma, vmf->page, );
>
> if (!printed && ++count > 16) {
> const struct dentry *de = vma->vm_file->f_path.dentry;
> @@ -387,25 +388,25 @@ static int ll_page_mkwrite(struct vm_fault *vmf)
> }
> } while (retry);
>
> -   switch (result) {
> +   switch (err) {
> case 0:
> LASSERT(PageLocked(vmf->page));
> -   result = VM_FAULT_LOCKED;
> +   ret = VM_FAULT_LOCKED;
> break;
> case -ENODATA:
> case -EAGAIN:
> case -EFAULT:
> -   result = VM_FAULT_NOPAGE;
> +   ret = VM_FAULT_NOPAGE;
> break;
> case -ENOMEM:
> -   result = VM_FAULT_OOM;
> +   ret = VM_FAULT_OOM;
> break;
> default:
> -   result = VM_FAULT_SIGBUS;
> +   ret = VM_FAULT_SIGBUS;
> break;
> }
>
> -   return result;
> +   return ret;
>  }
>
>  /**
> --
> 1.9.1
>

If no further comment, we would like to get this patch in 4.18-rc-X.

[PATCH 12/34] staging: mt7621-mmc: Remove register debugging structures

2018-06-11 Thread Christian Lütke-Stetzkamp
Current code has structures for all the registers of the device, but
these are never used and there are also masks for all of them, so
these structures do not contain any useful information.

Signed-off-by: Christian Lütke-Stetzkamp 
---
 drivers/staging/mt7621-mmc/mt6575_sd.h | 411 -
 1 file changed, 411 deletions(-)

diff --git a/drivers/staging/mt7621-mmc/mt6575_sd.h 
b/drivers/staging/mt7621-mmc/mt6575_sd.h
index 375cb109806e..07f48d526888 100644
--- a/drivers/staging/mt7621-mmc/mt6575_sd.h
+++ b/drivers/staging/mt7621-mmc/mt6575_sd.h
@@ -478,417 +478,6 @@ struct bd {
u32  rsv3:16;
 };
 
-/*--*/
-/* Register Debugging Structure */
-/*--*/
-
-struct msdc_cfg_reg {
-   u32 msdc:1;
-   u32 ckpwn:1;
-   u32 rst:1;
-   u32 pio:1;
-   u32 ckdrven:1;
-   u32 start18v:1;
-   u32 pass18v:1;
-   u32 ckstb:1;
-   u32 ckdiv:8;
-   u32 ckmod:2;
-   u32 pad:14;
-};
-
-struct msdc_iocon_reg {
-   u32 sdr104cksel:1;
-   u32 rsmpl:1;
-   u32 dsmpl:1;
-   u32 ddlysel:1;
-   u32 ddr50ckd:1;
-   u32 dsplsel:1;
-   u32 pad1:10;
-   u32 d0spl:1;
-   u32 d1spl:1;
-   u32 d2spl:1;
-   u32 d3spl:1;
-   u32 d4spl:1;
-   u32 d5spl:1;
-   u32 d6spl:1;
-   u32 d7spl:1;
-   u32 riscsz:1;
-   u32 pad2:7;
-};
-
-struct msdc_ps_reg {
-   u32 cden:1;
-   u32 cdsts:1;
-   u32 pad1:10;
-   u32 cddebounce:4;
-   u32 dat:8;
-   u32 cmd:1;
-   u32 pad2:6;
-   u32 wp:1;
-};
-
-struct msdc_int_reg {
-   u32 mmcirq:1;
-   u32 cdsc:1;
-   u32 pad1:1;
-   u32 atocmdrdy:1;
-   u32 atocmdtmo:1;
-   u32 atocmdcrc:1;
-   u32 dmaqempty:1;
-   u32 sdioirq:1;
-   u32 cmdrdy:1;
-   u32 cmdtmo:1;
-   u32 rspcrc:1;
-   u32 csta:1;
-   u32 xfercomp:1;
-   u32 dxferdone:1;
-   u32 dattmo:1;
-   u32 datcrc:1;
-   u32 atocmd19done:1;
-   u32 pad2:15;
-};
-
-struct msdc_inten_reg {
-   u32 mmcirq:1;
-   u32 cdsc:1;
-   u32 pad1:1;
-   u32 atocmdrdy:1;
-   u32 atocmdtmo:1;
-   u32 atocmdcrc:1;
-   u32 dmaqempty:1;
-   u32 sdioirq:1;
-   u32 cmdrdy:1;
-   u32 cmdtmo:1;
-   u32 rspcrc:1;
-   u32 csta:1;
-   u32 xfercomp:1;
-   u32 dxferdone:1;
-   u32 dattmo:1;
-   u32 datcrc:1;
-   u32 atocmd19done:1;
-   u32 pad2:15;
-};
-
-struct msdc_fifocs_reg {
-   u32 rxcnt:8;
-   u32 pad1:8;
-   u32 txcnt:8;
-   u32 pad2:7;
-   u32 clr:1;
-};
-
-struct msdc_txdat_reg {
-   u32 val;
-};
-
-struct msdc_rxdat_reg {
-   u32 val;
-};
-
-struct sdc_cfg_reg {
-   u32 sdiowkup:1;
-   u32 inswkup:1;
-   u32 pad1:14;
-   u32 buswidth:2;
-   u32 pad2:1;
-   u32 sdio:1;
-   u32 sdioide:1;
-   u32 intblkgap:1;
-   u32 pad4:2;
-   u32 dtoc:8;
-};
-
-struct sdc_cmd_reg {
-   u32 cmd:6;
-   u32 brk:1;
-   u32 rsptyp:3;
-   u32 pad1:1;
-   u32 dtype:2;
-   u32 rw:1;
-   u32 stop:1;
-   u32 goirq:1;
-   u32 blklen:12;
-   u32 atocmd:2;
-   u32 volswth:1;
-   u32 pad2:1;
-};
-
-struct sdc_arg_reg {
-   u32 arg;
-};
-
-struct sdc_sts_reg {
-   u32 sdcbusy:1;
-   u32 cmdbusy:1;
-   u32 pad:29;
-   u32 swrcmpl:1;
-};
-
-struct sdc_resp0_reg {
-   u32 val;
-};
-
-struct sdc_resp1_reg {
-   u32 val;
-};
-
-struct sdc_resp2_reg {
-   u32 val;
-};
-
-struct sdc_resp3_reg {
-   u32 val;
-};
-
-struct sdc_blknum_reg {
-   u32 num;
-};
-
-struct sdc_csts_reg {
-   u32 sts;
-};
-
-struct sdc_cstsen_reg {
-   u32 sts;
-};
-
-struct sdc_datcrcsts_reg {
-   u32 datcrcsts:8;
-   u32 ddrcrcsts:4;
-   u32 pad:20;
-};
-
-struct emmc_cfg0_reg {
-   u32 bootstart:1;
-   u32 bootstop:1;
-   u32 bootmode:1;
-   u32 pad1:9;
-   u32 bootwaidly:3;
-   u32 bootsupp:1;
-   u32 pad2:16;
-};
-
-struct emmc_cfg1_reg {
-   u32 bootcrctmc:16;
-   u32 pad:4;
-   u32 bootacktmc:12;
-};
-
-struct emmc_sts_reg {
-   u32 bootcrcerr:1;
-   u32 bootackerr:1;
-   u32 bootdattmo:1;
-   u32 bootacktmo:1;
-   u32 bootupstate:1;
-   u32 bootackrcv:1;
-   u32 bootdatrcv:1;
-   u32 pad:25;
-};
-
-struct emmc_iocon_reg {
-   u32 bootrst:1;
-   u32 pad:31;
-};
-
-struct msdc_acmd_resp_reg {
-   u32 val;
-};
-
-struct msdc_acmd19_trg_reg {
-   u32 tunesel:4;
-   u32 pad:28;
-};
-
-struct msdc_acmd19_sts_reg {
-   u32 val;
-};
-
-struct msdc_dma_sa_reg {
-   u32 addr;
-};
-
-struct msdc_dma_ca_reg {
-   u32 addr;
-};
-
-struct msdc_dma_ctrl_reg {
-   u32 start:1;
-   u32 stop:1;
-   u32 resume:1;
-   u32 pad1:5;
-   u32 mode:1;
-   

[PATCH 15/34] staging: mt7621-mmc: Refactor dma setup process

2018-06-11 Thread Christian Lütke-Stetzkamp
Current code uses two functions for dma setup, msdc_dma_config and
msdc_dma_setup. By now msdc_dma_setup is nearly empty and mainly calls
msdc_dma_config, so the later one can be inline into the first
one. While doing this there is also some refactoring done.

Signed-off-by: Christian Lütke-Stetzkamp 
---
 drivers/staging/mt7621-mmc/sd.c | 34 +-
 1 file changed, 13 insertions(+), 21 deletions(-)

diff --git a/drivers/staging/mt7621-mmc/sd.c b/drivers/staging/mt7621-mmc/sd.c
index 3066fa3799ac..923b0687918d 100644
--- a/drivers/staging/mt7621-mmc/sd.c
+++ b/drivers/staging/mt7621-mmc/sd.c
@@ -1030,18 +1030,24 @@ static u8 msdc_dma_calcs(u8 *buf, u32 len)
return 0xFF - (u8)sum;
 }
 
-/* gpd bd setup + dma registers */
-static void msdc_dma_config(struct msdc_host *host, struct msdc_dma *dma)
+static void msdc_dma_setup(struct msdc_host *host, struct msdc_dma *dma,
+  struct scatterlist *sg_cmd, unsigned int sglen)
 {
void __iomem *base = host->base;
-   //u32 i, j, num, bdlen, arg, xfersz;
-   u32 j, num;
struct scatterlist *sg;
struct gpd *gpd;
struct bd *bd;
+   u32 j, num;
+
+   BUG_ON(sglen > MAX_BD_NUM); /* not support currently */
+
+   dma->sg = sg_cmd;
+   dma->sglen = sglen;
+
+   N_MSG(DMA, "DMA sglen<%d> xfersz<%d>", sglen, host->xfer_size);
 
/* calculate the required number of gpd */
-   num = (dma->sglen + MAX_BD_PER_GPD - 1) / MAX_BD_PER_GPD;
+   num = (sglen + MAX_BD_PER_GPD - 1) / MAX_BD_PER_GPD;
BUG_ON(num != 1);
 
gpd = dma->gpd;
@@ -1055,13 +1061,13 @@ static void msdc_dma_config(struct msdc_host *host, 
struct msdc_dma *dma)
gpd->chksum = msdc_dma_calcs((u8 *)gpd, 16);
 
/* modify bd*/
-   for_each_sg(dma->sg, sg, dma->sglen, j) {
+   for_each_sg(sg_cmd, sg, sglen, j) {
bd[j].blkpad = 0;
bd[j].dwpad = 0;
bd[j].ptr = (void *)sg_dma_address(sg);
bd[j].buflen = sg_dma_len(sg);
 
-   if (j == dma->sglen - 1)
+   if (j == sglen - 1)
bd[j].eol = 1;  /* the last bd */
else
bd[j].eol = 0;
@@ -1080,20 +1086,6 @@ static void msdc_dma_config(struct msdc_host *host, 
struct msdc_dma *dma)
N_MSG(DMA, "DMA_CTRL = 0x%x", readl(MSDC_DMA_CTRL));
N_MSG(DMA, "DMA_CFG  = 0x%x", readl(MSDC_DMA_CFG));
N_MSG(DMA, "DMA_SA   = 0x%x", readl(MSDC_DMA_SA));
-
-}
-
-static void msdc_dma_setup(struct msdc_host *host, struct msdc_dma *dma,
-  struct scatterlist *sg, unsigned int sglen)
-{
-   BUG_ON(sglen > MAX_BD_NUM); /* not support currently */
-
-   dma->sg = sg;
-   dma->sglen = sglen;
-
-   N_MSG(DMA, "DMA sglen<%d> xfersz<%d>", dma->sglen, host->xfer_size);
-
-   msdc_dma_config(host, dma);
 }
 
 static int msdc_do_request(struct mmc_host *mmc, struct mmc_request *mrq)
-- 
2.16.1

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


[PATCH 01/34] staging: mt7621-mmc: Remove unused variable in msdc_command_resp

2018-06-11 Thread Christian Lütke-Stetzkamp
The variable resp in msdc_command_resp is once set and never read,
delete it.

Signed-off-by: Christian Lütke-Stetzkamp 
---
 drivers/staging/mt7621-mmc/sd.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/staging/mt7621-mmc/sd.c b/drivers/staging/mt7621-mmc/sd.c
index 648a2dd1436e..7cfadb41a53d 100644
--- a/drivers/staging/mt7621-mmc/sd.c
+++ b/drivers/staging/mt7621-mmc/sd.c
@@ -886,13 +886,10 @@ static unsigned int msdc_command_resp(struct msdc_host   
*host,
void __iomem *base = host->base;
u32 opcode = cmd->opcode;
//u32 rawcmd;
-   u32 resp;
u32 wints = MSDC_INT_CMDRDY  | MSDC_INT_RSPCRCERR  | MSDC_INT_CMDTMO  |
MSDC_INT_ACMDRDY | MSDC_INT_ACMDCRCERR | MSDC_INT_ACMDTMO |
MSDC_INT_ACMD19_DONE;
 
-   resp = host->cmd_rsp;
-
BUG_ON(in_interrupt());
//init_completion(>cmd_done);
//sdr_set_bits(MSDC_INTEN, wints);
-- 
2.16.1

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


[PATCH 21/34] staging: mt7621-mmc: Remove unused macro msdc_retry

2018-06-11 Thread Christian Lütke-Stetzkamp
The macro msdc_retry is never used, so remove it.

Signed-off-by: Christian Lütke-Stetzkamp 
---
 drivers/staging/mt7621-mmc/sd.c | 13 -
 1 file changed, 13 deletions(-)

diff --git a/drivers/staging/mt7621-mmc/sd.c b/drivers/staging/mt7621-mmc/sd.c
index 01a925ae662e..0e94bb0d5927 100644
--- a/drivers/staging/mt7621-mmc/sd.c
+++ b/drivers/staging/mt7621-mmc/sd.c
@@ -149,19 +149,6 @@ static int msdc_rsp[] = {
 
 #define msdc_dma_on()sdr_clr_bits(MSDC_CFG, MSDC_CFG_PIO)
 
-#define msdc_retry(expr, retry, cnt) \
-   do {\
-   int backup = cnt;   \
-   while (retry) { \
-   if (!(expr))\
-   break;  \
-   if (cnt-- == 0) {   \
-   retry--; mdelay(1); cnt = backup;   \
-   }   \
-   }   \
-   WARN_ON(retry == 0);\
-   } while (0)
-
 static void msdc_reset_hw(struct msdc_host *host)
 {
void __iomem *base = host->base;
-- 
2.16.1

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


[PATCH 06/34] staging: mt7621-mmc: Remove unused macro msdc_txfifocnt

2018-06-11 Thread Christian Lütke-Stetzkamp
The macro msdc_txfifocnt is never used, so remove it.

Signed-off-by: Christian Lütke-Stetzkamp 
---
 drivers/staging/mt7621-mmc/sd.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/staging/mt7621-mmc/sd.c b/drivers/staging/mt7621-mmc/sd.c
index 0f9cba918586..c6aced0c0a6a 100644
--- a/drivers/staging/mt7621-mmc/sd.c
+++ b/drivers/staging/mt7621-mmc/sd.c
@@ -147,7 +147,6 @@ static int msdc_rsp[] = {
7,  /* RESP_R1b */
 };
 
-#define msdc_txfifocnt()   ((sdr_read32(MSDC_FIFOCS) & MSDC_FIFOCS_TXCNT) >> 
16)
 #define msdc_rxfifocnt()   ((sdr_read32(MSDC_FIFOCS) & MSDC_FIFOCS_RXCNT) >> 0)
 
 #define msdc_dma_on()sdr_clr_bits(MSDC_CFG, MSDC_CFG_PIO)
-- 
2.16.1

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


[PATCH 23/34] staging: mt7621-mmc: Remove unused variable from msdc_tune_request

2018-06-11 Thread Christian Lütke-Stetzkamp
The variable cmd in the function msdc_tune_request is set but never
used, so remove it.

Signed-off-by: Christian Lütke-Stetzkamp 
---
 drivers/staging/mt7621-mmc/sd.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/staging/mt7621-mmc/sd.c b/drivers/staging/mt7621-mmc/sd.c
index e99a12002646..c5139a20e10f 100644
--- a/drivers/staging/mt7621-mmc/sd.c
+++ b/drivers/staging/mt7621-mmc/sd.c
@@ -1556,12 +1556,10 @@ static int msdc_check_busy(struct mmc_host *mmc, struct 
msdc_host *host)
 static int msdc_tune_request(struct mmc_host *mmc, struct mmc_request *mrq)
 {
struct msdc_host *host = mmc_priv(mmc);
-   struct mmc_command *cmd;
struct mmc_data *data;
//u32 base = host->base;
int ret = 0, read;
 
-   cmd  = mrq->cmd;
data = mrq->cmd->data;
 
read = data->flags & MMC_DATA_READ ? 1 : 0;
-- 
2.16.1

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


[PATCH 25/34] staging: mt7621-mmc: Cleanup source of base address for io

2018-06-11 Thread Christian Lütke-Stetzkamp
Currently the base address for all io operations is hidden behind a
macro, REG_ADD. This macro uses the symbol "base" as the base address
and all functions set base = host->base. This is hard to read, so the
whole wrapping is removed and host->base is directly inserted in the
io access.

Signed-off-by: Christian Lütke-Stetzkamp 
---
 drivers/staging/mt7621-mmc/mt6575_sd.h | 161 --
 drivers/staging/mt7621-mmc/sd.c| 378 +
 2 files changed, 236 insertions(+), 303 deletions(-)

diff --git a/drivers/staging/mt7621-mmc/mt6575_sd.h 
b/drivers/staging/mt7621-mmc/mt6575_sd.h
index 9b6cd6db37df..4e287c140acb 100644
--- a/drivers/staging/mt7621-mmc/mt6575_sd.h
+++ b/drivers/staging/mt7621-mmc/mt6575_sd.h
@@ -41,11 +41,6 @@
 
 // #include  /* --- by chhung */
 
-/*--*/
-/* Common Macro */
-/*--*/
-#define REG_ADDR(x) (base + OFFSET_##x)
-
 /*--*/
 /* Common Definition*/
 /*--*/
@@ -95,117 +90,51 @@ enum {
 /*--*/
 /* Register Offset  */
 /*--*/
-#define OFFSET_MSDC_CFG (0x0)
-#define OFFSET_MSDC_IOCON   (0x04)
-#define OFFSET_MSDC_PS  (0x08)
-#define OFFSET_MSDC_INT (0x0c)
-#define OFFSET_MSDC_INTEN   (0x10)
-#define OFFSET_MSDC_FIFOCS  (0x14)
-#define OFFSET_MSDC_TXDATA  (0x18)
-#define OFFSET_MSDC_RXDATA  (0x1c)
-#define OFFSET_SDC_CFG  (0x30)
-#define OFFSET_SDC_CMD  (0x34)
-#define OFFSET_SDC_ARG  (0x38)
-#define OFFSET_SDC_STS  (0x3c)
-#define OFFSET_SDC_RESP0(0x40)
-#define OFFSET_SDC_RESP1(0x44)
-#define OFFSET_SDC_RESP2(0x48)
-#define OFFSET_SDC_RESP3(0x4c)
-#define OFFSET_SDC_BLK_NUM  (0x50)
-#define OFFSET_SDC_CSTS (0x58)
-#define OFFSET_SDC_CSTS_EN  (0x5c)
-#define OFFSET_SDC_DCRC_STS (0x60)
-#define OFFSET_EMMC_CFG0(0x70)
-#define OFFSET_EMMC_CFG1(0x74)
-#define OFFSET_EMMC_STS (0x78)
-#define OFFSET_EMMC_IOCON   (0x7c)
-#define OFFSET_SDC_ACMD_RESP(0x80)
-#define OFFSET_SDC_ACMD19_TRG   (0x84)
-#define OFFSET_SDC_ACMD19_STS   (0x88)
-#define OFFSET_MSDC_DMA_SA  (0x90)
-#define OFFSET_MSDC_DMA_CA  (0x94)
-#define OFFSET_MSDC_DMA_CTRL(0x98)
-#define OFFSET_MSDC_DMA_CFG (0x9c)
-#define OFFSET_MSDC_DBG_SEL (0xa0)
-#define OFFSET_MSDC_DBG_OUT (0xa4)
-#define OFFSET_MSDC_PATCH_BIT   (0xb0)
-#define OFFSET_MSDC_PATCH_BIT1  (0xb4)
-#define OFFSET_MSDC_PAD_CTL0(0xe0)
-#define OFFSET_MSDC_PAD_CTL1(0xe4)
-#define OFFSET_MSDC_PAD_CTL2(0xe8)
-#define OFFSET_MSDC_PAD_TUNE(0xec)
-#define OFFSET_MSDC_DAT_RDDLY0  (0xf0)
-#define OFFSET_MSDC_DAT_RDDLY1  (0xf4)
-#define OFFSET_MSDC_HW_DBG  (0xf8)
-#define OFFSET_MSDC_VERSION (0x100)
-#define OFFSET_MSDC_ECO_VER (0x104)
-
-/*--*/
-/* Register Address */
-/*--*/
-
-/* common register */
-#define MSDC_CFGREG_ADDR(MSDC_CFG)
-#define MSDC_IOCON  REG_ADDR(MSDC_IOCON)
-#define MSDC_PS REG_ADDR(MSDC_PS)
-#define MSDC_INTREG_ADDR(MSDC_INT)
-#define MSDC_INTEN  REG_ADDR(MSDC_INTEN)
-#define MSDC_FIFOCS REG_ADDR(MSDC_FIFOCS)
-#define MSDC_TXDATA REG_ADDR(MSDC_TXDATA)
-#define MSDC_RXDATA REG_ADDR(MSDC_RXDATA)
-#define MSDC_PATCH_BIT0 REG_ADDR(MSDC_PATCH_BIT)
-
-/* sdmmc register */
-#define SDC_CFG REG_ADDR(SDC_CFG)
-#define SDC_CMD REG_ADDR(SDC_CMD)
-#define SDC_ARG REG_ADDR(SDC_ARG)
-#define SDC_STS REG_ADDR(SDC_STS)
-#define SDC_RESP0   REG_ADDR(SDC_RESP0)
-#define SDC_RESP1   REG_ADDR(SDC_RESP1)
-#define SDC_RESP2   REG_ADDR(SDC_RESP2)
-#define SDC_RESP3   REG_ADDR(SDC_RESP3)
-#define SDC_BLK_NUM REG_ADDR(SDC_BLK_NUM)
-#define SDC_CSTSREG_ADDR(SDC_CSTS)
-#define SDC_CSTS_EN REG_ADDR(SDC_CSTS_EN)
-#define SDC_DCRC_STSREG_ADDR(SDC_DCRC_STS)
-
-/* emmc register*/
-#define EMMC_CFG0   REG_ADDR(EMMC_CFG0)
-#define EMMC_CFG1   REG_ADDR(EMMC_CFG1)
-#define EMMC_STSREG_ADDR(EMMC_STS)
-#define EMMC_IOCON 

[PATCH 00/34] staging: mt7621-mmc: Cleanup continues

2018-06-11 Thread Christian Lütke-Stetzkamp
Here are the next cleanups for the mt7621-mmc driver. Again much of
unused code is removed and the IO is cleaned up.  The next major step
will be the complete refactoring of the tuning, because it does not
use the tuning capabilities of sd-core, but kind of re-implements that.

Christian Lütke-Stetzkamp (34):
  staging: mt7621-mmc: Remove unused variable in msdc_command_resp
  staging: mt7621-mmc: Remove unused macro msdc_fifo_write8
  staging: mt7621-mmc: Remove unused macro msdc_fifo_read8
  staging: mt7621-mmc: Remove unused macro msdc_fifo_write32
  staging: mt7621-mmc: Remove unused macro msdc_fifo_read32
  staging: mt7621-mmc: Remove unused macro msdc_txfifocnt
  staging: mt7621-mmc: Remove unused macro msdc_rxfifocnt
  staging: mt7621-mmc: Replace sdr_write32 with writel
  staging: mt7621-mmc: Replace sdr_read32 with readl
  staging: mt7621-mmc: Remove unused macro sdr_read8
  staging: mt7621-mmc: Remove unused macro sdr_write8
  staging: mt7621-mmc: Remove register debugging structures
  staging: mt7621-mmc: Remove DMA basic mode code
  staging: mt7621-mmc: Remove unused field mode from msdc_dma
  staging: mt7621-mmc: Refactor dma setup process
  staging: mt7621-mmc: Remove unused field sg from msdc_dma
  staging: mt7621-mmc: Remove unused field sglen from msdc_dma
  staging: mt7621-mmc: Remove variable num form msdc_dma_setup
  staging: mt7621-mmc: Remove unnecessary BUG_ON() in msdc_dma_setup
  staging: mt7621-mmc: Make msdc_clr_fifo a function and relax cpu
  staging: mt7621-mmc: Remove unused macro msdc_retry
  staging: mt7621-mmc: Remove unused macro MAX_BD_PER_GPD
  staging: mt7621-mmc: Remove unused variable from msdc_tune_request
  staging: mt7621-mmc: Remove MSDC_MODE_* defines
  staging: mt7621-mmc: Cleanup source of base address for io
  staging: mt7621-mmc: Remove unused define RALINK_MSDC_BASE
  staging: mt7621-mmc: Remove unused define IRQ_SDC
  staging: mt7621-mmc: Remove unused enum msdc_mode
  staging: mt7621-mmc: Remove unused define MAX_PHY_SGMTS
  staging: mt7621-mmc: Remove unused macro is_card_present
  staging: mt7621-mmc: Remove unused argument from msdc_do_command
  staging: mt7621-mmc: Factor out from msdc_command_start()
  staging: mt7621-mmc: Find response of MMC_SEND_OP_COND by default
  staging: mt7621-mmc: Find response of SD_APP_OP_COND by default

 drivers/staging/mt7621-mmc/dbg.h   |   6 -
 drivers/staging/mt7621-mmc/mt6575_sd.h | 588 +++--
 drivers/staging/mt7621-mmc/sd.c| 584 +++-
 3 files changed, 305 insertions(+), 873 deletions(-)

-- 
2.16.1

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


[PATCH 17/34] staging: mt7621-mmc: Remove unused field sglen from msdc_dma

2018-06-11 Thread Christian Lütke-Stetzkamp
The field sglen from struct msdc_dma is once set and never read, so
remove it.

Signed-off-by: Christian Lütke-Stetzkamp 
---
 drivers/staging/mt7621-mmc/mt6575_sd.h | 2 --
 drivers/staging/mt7621-mmc/sd.c| 2 --
 2 files changed, 4 deletions(-)

diff --git a/drivers/staging/mt7621-mmc/mt6575_sd.h 
b/drivers/staging/mt7621-mmc/mt6575_sd.h
index c8c5c349adf8..4b56d9a37b84 100644
--- a/drivers/staging/mt7621-mmc/mt6575_sd.h
+++ b/drivers/staging/mt7621-mmc/mt6575_sd.h
@@ -479,8 +479,6 @@ struct bd {
 };
 
 struct msdc_dma {
-   u32 sglen;   /* size of scatter list */
-
struct gpd *gpd;  /* pointer to gpd array */
struct bd  *bd;   /* pointer to bd array */
dma_addr_t gpd_addr; /* the physical address of gpd array */
diff --git a/drivers/staging/mt7621-mmc/sd.c b/drivers/staging/mt7621-mmc/sd.c
index 050c4a910aef..e1077068604d 100644
--- a/drivers/staging/mt7621-mmc/sd.c
+++ b/drivers/staging/mt7621-mmc/sd.c
@@ -1041,8 +1041,6 @@ static void msdc_dma_setup(struct msdc_host *host, struct 
msdc_dma *dma,
 
BUG_ON(sglen > MAX_BD_NUM); /* not support currently */
 
-   dma->sglen = sglen;
-
N_MSG(DMA, "DMA sglen<%d> xfersz<%d>", sglen, host->xfer_size);
 
/* calculate the required number of gpd */
-- 
2.16.1

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


RE: [PATCH v3] Drivers: HV: Send one page worth of kmsg dump over Hyper-V during panic

2018-06-11 Thread Sunil Muthuswamy
I haven't gotten any test build bot reports for the newer version of the 
patches that were
Submitted last week. Is there a way to know what's going on there or force a 
submission?

- sunil

> -Original Message-
> From: kbuild test robot 
> Sent: Wednesday, May 23, 2018 7:57 PM
> To: Sunil Muthuswamy 
> Cc: kbuild-...@01.org; Haiyang Zhang ;
> de...@linuxdriverproject.org; Sunil Muthuswamy
> ; Stephen Hemminger
> 
> Subject: Re: [PATCH v3] Drivers: HV: Send one page worth of kmsg dump
> over Hyper-V during panic
> 
> Hi Sunil,
> 
> Thank you for the patch! Perhaps something to improve:
> 
> [auto build test WARNING on linus/master]
> [also build test WARNING on v4.17-rc6 next-20180517]
> [cannot apply to tip/x86/core]
> [if your patch is applied to the wrong git tree, please drop us a note to help
> improve the system]
> 
> url:
> https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub
> .com%2F0day-ci%2Flinux%2Fcommits%2FSunil-Muthuswamy%2FDrivers-HV-
> Send-one-page-worth-of-kmsg-dump-over-Hyper-V-during-
> panic%2F20180523-
> 035336=02%7C01%7Csunilmut%40microsoft.com%7Cea8837620518441
> e279808d5c1221032%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C6
> 36627274402211081=aRiQw64FhftuwLijjsPJigInUHEYBFWWl%2BMcgqI
> yNl4%3D=0
> reproduce:
> # apt-get install sparse
> make ARCH=x86_64 allmodconfig
> make C=1 CF=-D__CHECK_ENDIAN__
> 
> 
> sparse warnings: (new ones prefixed by >>)
> 
> >> drivers/hv/vmbus_drv.c:1028:5: sparse: symbol
> 'sysctl_record_panic_msg' was not declared. Should it be static?
>drivers/hv/vmbus_drv.c:1631:32: sparse: expression using sizeof(void)
>drivers/hv/vmbus_drv.c:1633:32: sparse: expression using sizeof(void)
>include/asm-generic/atomic-instrumented.h:358:24: sparse: cast truncates
> bits from constant value (8010 becomes 10)
>include/asm-generic/atomic-instrumented.h:360:24: sparse: cast truncates
> bits from constant value (8010 becomes 10)
> 
> Please review and possibly fold the followup patch.
> 
> ---
> 0-DAY kernel test infrastructureOpen Source Technology Center
> https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.01
> .org%2Fpipermail%2Fkbuild-
> all=02%7C01%7Csunilmut%40microsoft.com%7Cea8837620518441e279
> 808d5c1221032%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C63662
> 7274402211081=HhJj%2BMSiTeoaxbBDEdMLquOAO%2B5AuQR0yENX
> BZ%2B77gQ%3D=0   Intel Corporation
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 18/34] staging: mt7621-mmc: Remove variable num form msdc_dma_setup

2018-06-11 Thread Christian Lütke-Stetzkamp
The variable num in msdc_dma_setup is only used for a BUG_ON
statement, so it can be removed by inlining the condition.

Signed-off-by: Christian Lütke-Stetzkamp 
---
 drivers/staging/mt7621-mmc/sd.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/mt7621-mmc/sd.c b/drivers/staging/mt7621-mmc/sd.c
index e1077068604d..68dfbf38b0ea 100644
--- a/drivers/staging/mt7621-mmc/sd.c
+++ b/drivers/staging/mt7621-mmc/sd.c
@@ -1037,15 +1037,14 @@ static void msdc_dma_setup(struct msdc_host *host, 
struct msdc_dma *dma,
struct scatterlist *sg;
struct gpd *gpd;
struct bd *bd;
-   u32 j, num;
+   u32 j;
 
BUG_ON(sglen > MAX_BD_NUM); /* not support currently */
 
N_MSG(DMA, "DMA sglen<%d> xfersz<%d>", sglen, host->xfer_size);
 
/* calculate the required number of gpd */
-   num = (sglen + MAX_BD_PER_GPD - 1) / MAX_BD_PER_GPD;
-   BUG_ON(num != 1);
+   BUG_ON(((sglen + MAX_BD_PER_GPD - 1) / MAX_BD_PER_GPD) != 1);
 
gpd = dma->gpd;
bd  = dma->bd;
-- 
2.16.1

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


[PATCH 22/34] staging: mt7621-mmc: Remove unused macro MAX_BD_PER_GPD

2018-06-11 Thread Christian Lütke-Stetzkamp
The macro MAX_BD_PER_GPD is never used, so remove it.

Signed-off-by: Christian Lütke-Stetzkamp 
---
 drivers/staging/mt7621-mmc/sd.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/staging/mt7621-mmc/sd.c b/drivers/staging/mt7621-mmc/sd.c
index 0e94bb0d5927..e99a12002646 100644
--- a/drivers/staging/mt7621-mmc/sd.c
+++ b/drivers/staging/mt7621-mmc/sd.c
@@ -91,7 +91,6 @@
 
 #define MAX_GPD_NUM (1 + 1)  /* one null gpd */
 #define MAX_BD_NUM  (1024)
-#define MAX_BD_PER_GPD  (MAX_BD_NUM)
 
 #define MAX_HW_SGMTS(MAX_BD_NUM)
 #define MAX_PHY_SGMTS   (MAX_BD_NUM)
-- 
2.16.1

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


[PATCH 09/34] staging: mt7621-mmc: Replace sdr_read32 with readl

2018-06-11 Thread Christian Lütke-Stetzkamp
The current code uses a macro (sdr_read32) for reading from hardware,
but it is only a readl, so replace it to get nearer to upstream code.

Signed-off-by: Christian Lütke-Stetzkamp 
---
 drivers/staging/mt7621-mmc/mt6575_sd.h |  1 -
 drivers/staging/mt7621-mmc/sd.c| 98 +-
 2 files changed, 49 insertions(+), 50 deletions(-)

diff --git a/drivers/staging/mt7621-mmc/mt6575_sd.h 
b/drivers/staging/mt7621-mmc/mt6575_sd.h
index e8e79aab52f8..29e2ede6816b 100644
--- a/drivers/staging/mt7621-mmc/mt6575_sd.h
+++ b/drivers/staging/mt7621-mmc/mt6575_sd.h
@@ -948,7 +948,6 @@ struct msdc_host {
 };
 
 #define sdr_read8(reg)readb(reg)
-#define sdr_read32(reg)   readl(reg)
 #define sdr_write8(reg, val)  writeb(val, reg)
 
 static inline void sdr_set_bits(void __iomem *reg, u32 bs)
diff --git a/drivers/staging/mt7621-mmc/sd.c b/drivers/staging/mt7621-mmc/sd.c
index e6232f5ac6a8..1d0829e6 100644
--- a/drivers/staging/mt7621-mmc/sd.c
+++ b/drivers/staging/mt7621-mmc/sd.c
@@ -167,13 +167,13 @@ static void msdc_reset_hw(struct msdc_host *host)
void __iomem *base = host->base;
 
sdr_set_bits(MSDC_CFG, MSDC_CFG_RST);
-   while (sdr_read32(MSDC_CFG) & MSDC_CFG_RST)
+   while (readl(MSDC_CFG) & MSDC_CFG_RST)
cpu_relax();
 }
 
 #define msdc_clr_int() \
do {\
-   volatile u32 val = sdr_read32(MSDC_INT);\
+   volatile u32 val = readl(MSDC_INT); \
writel(val, MSDC_INT);  \
} while (0)
 
@@ -181,12 +181,12 @@ static void msdc_reset_hw(struct msdc_host *host)
do {\
int retry = 3, cnt = 1000;  \
sdr_set_bits(MSDC_FIFOCS, MSDC_FIFOCS_CLR); \
-   msdc_retry(sdr_read32(MSDC_FIFOCS) & MSDC_FIFOCS_CLR, retry, 
cnt); \
+   msdc_retry(readl(MSDC_FIFOCS) & MSDC_FIFOCS_CLR, retry, cnt); \
} while (0)
 
 #define msdc_irq_save(val) \
do {\
-   val = sdr_read32(MSDC_INTEN);   \
+   val = readl(MSDC_INTEN);\
sdr_clr_bits(MSDC_INTEN, val);  \
} while (0)
 
@@ -230,8 +230,8 @@ static u32 hclks[] = {5000}; /* +/- by chhung */
(void)hwPowerDown(MT65XX_POWER_LDO_VMCH, "SD"); \
} while (0)
 
-#define sdc_is_busy()  (sdr_read32(SDC_STS) & SDC_STS_SDCBUSY)
-#define sdc_is_cmd_busy()  (sdr_read32(SDC_STS) & SDC_STS_CMDBUSY)
+#define sdc_is_busy()  (readl(SDC_STS) & SDC_STS_SDCBUSY)
+#define sdc_is_cmd_busy()  (readl(SDC_STS) & SDC_STS_CMDBUSY)
 
 #define sdc_send_cmd(cmd, arg) \
do {\
@@ -240,7 +240,7 @@ static u32 hclks[] = {5000}; /* +/- by chhung */
} while (0)
 
 // can modify to read h/w register.
-//#define is_card_present(h)   ((sdr_read32(MSDC_PS) & MSDC_PS_CDSTS) ? 0 : 1);
+//#define is_card_present(h)   ((readl(MSDC_PS) & MSDC_PS_CDSTS) ? 0 : 1);
 #define is_card_present(h) (((struct msdc_host *)(h))->card_inserted)
 
 /* +++ by chhung */
@@ -426,7 +426,7 @@ static void msdc_tasklet_card(struct work_struct *work)
 
spin_lock(>lock);
 
-   status = sdr_read32(MSDC_PS);
+   status = readl(MSDC_PS);
if (cd_active_low)
inserted = (status & MSDC_PS_CDSTS) ? 0 : 1;
else
@@ -469,8 +469,8 @@ static void msdc_select_clksrc(struct msdc_host *host, 
unsigned char clksrc)
BUG_ON(clksrc > 3);
INIT_MSG("set clock source to <%d>", clksrc);
 
-   val = sdr_read32(MSDC_CLKSRC_REG);
-   if (sdr_read32(MSDC_ECO_VER) >= 4) {
+   val = readl(MSDC_CLKSRC_REG);
+   if (readl(MSDC_ECO_VER) >= 4) {
val &= ~(0x3  << clk_src_bit[host->id]);
val |= clksrc << clk_src_bit[host->id];
} else {
@@ -531,7 +531,7 @@ static void msdc_set_mclk(struct msdc_host *host, int ddr, 
unsigned int hz)
sdr_set_field(MSDC_CFG, MSDC_CFG_CKDIV, div);
 
/* wait clock stable */
-   while (!(sdr_read32(MSDC_CFG) & MSDC_CFG_CKSTB))
+   while (!(readl(MSDC_CFG) & MSDC_CFG_CKSTB))
cpu_relax();
 
host->sclk = sclk;
@@ -940,7 +940,7 @@ static unsigned int msdc_command_resp(struct msdc_host   
*host,
 
/* memory card CRC */
if (host->hw->flags & MSDC_REMOVABLE && cmd->error == -EIO) {
-   if (sdr_read32(SDC_CMD) & 0x1800) { /* check if has data phase 
*/
+   if (readl(SDC_CMD) & 0x1800) { /* check if has data phase */
msdc_abort_data(host);
} else {
/* do basic: reset*/
@@ -953,7 +953,7 @@ static unsigned int msdc_command_resp(struct msdc_host   
*host,
 
//  check DAT0
/* if (resp == RESP_R1B) {
-

[PATCH 03/34] staging: mt7621-mmc: Remove unused macro msdc_fifo_read8

2018-06-11 Thread Christian Lütke-Stetzkamp
The macro msdc_fifo_read8 is never used, so remove it.

Signed-off-by: Christian Lütke-Stetzkamp 
---
 drivers/staging/mt7621-mmc/sd.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/staging/mt7621-mmc/sd.c b/drivers/staging/mt7621-mmc/sd.c
index 4a69bc84bbd2..98bcb0fe6f40 100644
--- a/drivers/staging/mt7621-mmc/sd.c
+++ b/drivers/staging/mt7621-mmc/sd.c
@@ -151,7 +151,6 @@ static int msdc_rsp[] = {
 #define msdc_rxfifocnt()   ((sdr_read32(MSDC_FIFOCS) & MSDC_FIFOCS_RXCNT) >> 0)
 #define msdc_fifo_write32(v)   sdr_write32(MSDC_TXDATA, (v))
 #define msdc_fifo_read32()   sdr_read32(MSDC_RXDATA)
-#define msdc_fifo_read8()sdr_read8(MSDC_RXDATA)
 
 #define msdc_dma_on()sdr_clr_bits(MSDC_CFG, MSDC_CFG_PIO)
 
-- 
2.16.1

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


[PATCH 24/34] staging: mt7621-mmc: Remove MSDC_MODE_* defines

2018-06-11 Thread Christian Lütke-Stetzkamp
The MSDC_MODE_* defines are all never used and do not contain any
information about the device, so remove them.

Signed-off-by: Christian Lütke-Stetzkamp 
---
 drivers/staging/mt7621-mmc/mt6575_sd.h | 7 ---
 1 file changed, 7 deletions(-)

diff --git a/drivers/staging/mt7621-mmc/mt6575_sd.h 
b/drivers/staging/mt7621-mmc/mt6575_sd.h
index 4b56d9a37b84..9b6cd6db37df 100644
--- a/drivers/staging/mt7621-mmc/mt6575_sd.h
+++ b/drivers/staging/mt7621-mmc/mt6575_sd.h
@@ -56,13 +56,6 @@
 #define MSDC_MS (0)
 #define MSDC_SDMMC  (1)
 
-#define MSDC_MODE_UNKNOWN   (0)
-#define MSDC_MODE_PIO   (1)
-#define MSDC_MODE_DMA_BASIC (2)
-#define MSDC_MODE_DMA_DESC  (3)
-#define MSDC_MODE_DMA_ENHANCED  (4)
-#define MSDC_MODE_MMC_STREAM(5)
-
 #define MSDC_BUS_1BITS  (0)
 #define MSDC_BUS_4BITS  (1)
 #define MSDC_BUS_8BITS  (2)
-- 
2.16.1

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


[PATCH 31/34] staging: mt7621-mmc: Remove unused argument from msdc_do_command

2018-06-11 Thread Christian Lütke-Stetzkamp
The argument tune of msdc_do_command is never used, so remove it.

Signed-off-by: Christian Lütke-Stetzkamp 
---
 drivers/staging/mt7621-mmc/sd.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/mt7621-mmc/sd.c b/drivers/staging/mt7621-mmc/sd.c
index cfe7517f8bdf..93f14c9694b9 100644
--- a/drivers/staging/mt7621-mmc/sd.c
+++ b/drivers/staging/mt7621-mmc/sd.c
@@ -710,7 +710,6 @@ static void msdc_pm(pm_message_t state, void *data)
 /*--*/
 static unsigned int msdc_command_start(struct msdc_host   *host,
   struct mmc_command *cmd,
-  int tune,   /* not used 
*/
   unsigned long   timeout)
 {
u32 opcode = cmd->opcode;
@@ -932,7 +931,7 @@ static unsigned int msdc_do_command(struct msdc_host   
*host,
int tune,
unsigned long   timeout)
 {
-   if (msdc_command_start(host, cmd, tune, timeout))
+   if (msdc_command_start(host, cmd, timeout))
goto end;
 
if (msdc_command_resp(host, cmd, tune, timeout))
@@ -1098,7 +1097,7 @@ static int msdc_do_request(struct mmc_host *mmc, struct 
mmc_request *mrq)
init_completion(>xfer_done);
 
/* start the command first*/
-   if (msdc_command_start(host, cmd, 1, CMD_TIMEOUT) != 0)
+   if (msdc_command_start(host, cmd, CMD_TIMEOUT) != 0)
goto done;
 
data->sg_count = dma_map_sg(mmc_dev(mmc), data->sg,
-- 
2.16.1

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


[PATCH 29/34] staging: mt7621-mmc: Remove unused define MAX_PHY_SGMTS

2018-06-11 Thread Christian Lütke-Stetzkamp
The define MAX_PHY_SGMTS is never used, so remove it.

Signed-off-by: Christian Lütke-Stetzkamp 
---
 drivers/staging/mt7621-mmc/sd.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/staging/mt7621-mmc/sd.c b/drivers/staging/mt7621-mmc/sd.c
index 31ee9c533f35..45d9b62f4a58 100644
--- a/drivers/staging/mt7621-mmc/sd.c
+++ b/drivers/staging/mt7621-mmc/sd.c
@@ -89,7 +89,6 @@
 #define MAX_BD_NUM  (1024)
 
 #define MAX_HW_SGMTS(MAX_BD_NUM)
-#define MAX_PHY_SGMTS   (MAX_BD_NUM)
 #define MAX_SGMT_SZ (MAX_DMA_CNT)
 #define MAX_REQ_SZ  (MAX_SGMT_SZ * 8)
 
-- 
2.16.1

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


[PATCH 10/34] staging: mt7621-mmc: Remove unused macro sdr_read8

2018-06-11 Thread Christian Lütke-Stetzkamp
The macro sdr_read8 is never used, so remove it.

Signed-off-by: Christian Lütke-Stetzkamp 
---
 drivers/staging/mt7621-mmc/mt6575_sd.h | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/staging/mt7621-mmc/mt6575_sd.h 
b/drivers/staging/mt7621-mmc/mt6575_sd.h
index 29e2ede6816b..adccabe32660 100644
--- a/drivers/staging/mt7621-mmc/mt6575_sd.h
+++ b/drivers/staging/mt7621-mmc/mt6575_sd.h
@@ -947,7 +947,6 @@ struct msdc_host {
u32 app_cmd_arg;
 };
 
-#define sdr_read8(reg)readb(reg)
 #define sdr_write8(reg, val)  writeb(val, reg)
 
 static inline void sdr_set_bits(void __iomem *reg, u32 bs)
-- 
2.16.1

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


[PATCH 27/34] staging: mt7621-mmc: Remove unused define IRQ_SDC

2018-06-11 Thread Christian Lütke-Stetzkamp
The define IRQ_SDC is never used, so remove it.

Signed-off-by: Christian Lütke-Stetzkamp 
---
 drivers/staging/mt7621-mmc/sd.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/staging/mt7621-mmc/sd.c b/drivers/staging/mt7621-mmc/sd.c
index 101ceca2ee4c..31ee9c533f35 100644
--- a/drivers/staging/mt7621-mmc/sd.c
+++ b/drivers/staging/mt7621-mmc/sd.c
@@ -50,13 +50,11 @@
 #include "dbg.h"
 #include "mt6575_sd.h"
 
-//#define IRQ_SDC 14   //MT7620 /*FIXME*/
 #ifdef CONFIG_SOC_MT7621
 #define RALINK_SYSCTL_BASE 0xbe00
 #else
 #define RALINK_SYSCTL_BASE 0xb000
 #endif
-#define IRQ_SDC22  /*FIXME*/
 
 #define DRV_NAME"mtk-sd"
 
-- 
2.16.1

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


[PATCH 14/34] staging: mt7621-mmc: Remove unused field mode from msdc_dma

2018-06-11 Thread Christian Lütke-Stetzkamp
The field mode of struct msdc_dma has no remaining use, so remove it.

Signed-off-by: Christian Lütke-Stetzkamp 
---
 drivers/staging/mt7621-mmc/mt6575_sd.h | 1 -
 drivers/staging/mt7621-mmc/sd.c| 5 +
 2 files changed, 1 insertion(+), 5 deletions(-)

diff --git a/drivers/staging/mt7621-mmc/mt6575_sd.h 
b/drivers/staging/mt7621-mmc/mt6575_sd.h
index 07f48d526888..8eb30d908f9d 100644
--- a/drivers/staging/mt7621-mmc/mt6575_sd.h
+++ b/drivers/staging/mt7621-mmc/mt6575_sd.h
@@ -481,7 +481,6 @@ struct bd {
 struct msdc_dma {
u32 sglen;   /* size of scatter list */
struct scatterlist *sg;  /* I/O scatter list */
-   u8  mode;/* dma mode*/
 
struct gpd *gpd;  /* pointer to gpd array */
struct bd  *bd;   /* pointer to bd array */
diff --git a/drivers/staging/mt7621-mmc/sd.c b/drivers/staging/mt7621-mmc/sd.c
index 1196e8eb86c5..3066fa3799ac 100644
--- a/drivers/staging/mt7621-mmc/sd.c
+++ b/drivers/staging/mt7621-mmc/sd.c
@@ -1091,10 +1091,7 @@ static void msdc_dma_setup(struct msdc_host *host, 
struct msdc_dma *dma,
dma->sg = sg;
dma->sglen = sglen;
 
-   dma->mode = MSDC_MODE_DMA_DESC;
-
-   N_MSG(DMA, "DMA mode<%d> sglen<%d> xfersz<%d>", dma->mode, dma->sglen,
- host->xfer_size);
+   N_MSG(DMA, "DMA sglen<%d> xfersz<%d>", dma->sglen, host->xfer_size);
 
msdc_dma_config(host, dma);
 }
-- 
2.16.1

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


[PATCH 32/34] staging: mt7621-mmc: Factor out from msdc_command_start()

2018-06-11 Thread Christian Lütke-Stetzkamp
Currently msdc_command_start does multiple things and is hard to read,
so factor out the finding of the response type.

Signed-off-by: Christian Lütke-Stetzkamp 
---
 drivers/staging/mt7621-mmc/sd.c | 40 +---
 1 file changed, 25 insertions(+), 15 deletions(-)

diff --git a/drivers/staging/mt7621-mmc/sd.c b/drivers/staging/mt7621-mmc/sd.c
index 93f14c9694b9..c02799acb9e4 100644
--- a/drivers/staging/mt7621-mmc/sd.c
+++ b/drivers/staging/mt7621-mmc/sd.c
@@ -705,25 +705,11 @@ static void msdc_pm(pm_message_t state, void *data)
 }
 #endif
 
-/*--*/
-/* mmc_host_ops members  */
-/*--*/
-static unsigned int msdc_command_start(struct msdc_host   *host,
-  struct mmc_command *cmd,
-  unsigned long   timeout)
+static inline u32 msdc_cmd_find_resp(struct mmc_command cmd)
 {
u32 opcode = cmd->opcode;
-   u32 rawcmd;
-   u32 wints = MSDC_INT_CMDRDY  | MSDC_INT_RSPCRCERR  | MSDC_INT_CMDTMO  |
-   MSDC_INT_ACMDRDY | MSDC_INT_ACMDCRCERR | MSDC_INT_ACMDTMO |
-   MSDC_INT_ACMD19_DONE;
-
u32 resp;
-   unsigned long tmo;
 
-   /* Protocol layer does not provide response type, but our hardware needs
-* to know exact type, not just size!
-*/
if (opcode == MMC_SEND_OP_COND || opcode == SD_APP_OP_COND) {
resp = RESP_R3;
} else if (opcode == MMC_SET_RELATIVE_ADDR) {
@@ -759,6 +745,30 @@ static unsigned int msdc_command_start(struct msdc_host   
*host,
}
}
 
+   return resp;
+}
+
+/*--*/
+/* mmc_host_ops members  */
+/*--*/
+static unsigned int msdc_command_start(struct msdc_host   *host,
+  struct mmc_command *cmd,
+  unsigned long   timeout)
+{
+   u32 opcode = cmd->opcode;
+   u32 rawcmd;
+   u32 wints = MSDC_INT_CMDRDY  | MSDC_INT_RSPCRCERR  | MSDC_INT_CMDTMO  |
+   MSDC_INT_ACMDRDY | MSDC_INT_ACMDCRCERR | MSDC_INT_ACMDTMO |
+   MSDC_INT_ACMD19_DONE;
+
+   u32 resp;
+   unsigned long tmo;
+
+   /* Protocol layer does not provide response type, but our hardware needs
+* to know exact type, not just size!
+*/
+   resp = msdc_cmd_find_resp(cmd);
+
cmd->error = 0;
/* rawcmd :
 * vol_swt << 30 | auto_cmd << 28 | blklen << 16 | go_irq << 15 |
-- 
2.16.1

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


[PATCH 20/34] staging: mt7621-mmc: Make msdc_clr_fifo a function and relax cpu

2018-06-11 Thread Christian Lütke-Stetzkamp
In the current code, msdc_clr_fifo is a macro and just busy waits for
a limited amount of time for the fifo clear to finish. That is not
correct, the programming manual hits, that the user should wait until
the bit is cleared by hardware and not a limited amount of time.

So the code is changed to a function, that also relaxes the cpu while
busy waiting.

Signed-off-by: Christian Lütke-Stetzkamp 
---
 drivers/staging/mt7621-mmc/sd.c | 28 +++-
 1 file changed, 15 insertions(+), 13 deletions(-)

diff --git a/drivers/staging/mt7621-mmc/sd.c b/drivers/staging/mt7621-mmc/sd.c
index a506c7e19086..01a925ae662e 100644
--- a/drivers/staging/mt7621-mmc/sd.c
+++ b/drivers/staging/mt7621-mmc/sd.c
@@ -177,12 +177,14 @@ static void msdc_reset_hw(struct msdc_host *host)
writel(val, MSDC_INT);  \
} while (0)
 
-#define msdc_clr_fifo() \
-   do {\
-   int retry = 3, cnt = 1000;  \
-   sdr_set_bits(MSDC_FIFOCS, MSDC_FIFOCS_CLR); \
-   msdc_retry(readl(MSDC_FIFOCS) & MSDC_FIFOCS_CLR, retry, cnt); \
-   } while (0)
+static void msdc_clr_fifo(struct msdc_host *host)
+{
+   void __iomem *base = host->base;
+
+   sdr_set_bits(MSDC_FIFOCS, MSDC_FIFOCS_CLR);
+   while (readl(MSDC_FIFOCS) & MSDC_FIFOCS_CLR)
+   cpu_relax();
+}
 
 #define msdc_irq_save(val) \
do {\
@@ -554,7 +556,7 @@ static void msdc_abort_data(struct msdc_host *host)
ERR_MSG("Need to Abort.");
 
msdc_reset_hw(host);
-   msdc_clr_fifo();
+   msdc_clr_fifo(host);
msdc_clr_int();
 
// need to check FIFO count 0 ?
@@ -945,7 +947,7 @@ static unsigned int msdc_command_resp(struct msdc_host   
*host,
} else {
/* do basic: reset*/
msdc_reset_hw(host);
-   msdc_clr_fifo();
+   msdc_clr_fifo(host);
msdc_clr_int();
}
cmd->error = msdc_tune_cmdrsp(host, cmd);
@@ -1131,7 +1133,7 @@ static int msdc_do_request(struct mmc_host *mmc, struct 
mmc_request *mrq)
}
 
writel(data->blocks, SDC_BLK_NUM);
-   //msdc_clr_fifo();  /* no need */
+   //msdc_clr_fifo(host);  /* no need */
 
msdc_dma_on();  /* enable DMA mode first!! */
init_completion(>xfer_done);
@@ -1165,7 +1167,7 @@ static int msdc_do_request(struct mmc_host *mmc, struct 
mmc_request *mrq)
data->error = -ETIMEDOUT;
 
msdc_reset_hw(host);
-   msdc_clr_fifo();
+   msdc_clr_fifo(host);
msdc_clr_int();
}
spin_lock(>lock);
@@ -1868,7 +1870,7 @@ static irqreturn_t msdc_irq(int irq, void *dev_id)
if (intsts & datsts) {
/* do basic reset, or stop command will sdc_busy */
msdc_reset_hw(host);
-   msdc_clr_fifo();
+   msdc_clr_fifo(host);
msdc_clr_int();
 
if (intsts & MSDC_INT_DATTMO) {
@@ -1917,7 +1919,7 @@ static irqreturn_t msdc_irq(int irq, void *dev_id)
IRQ_MSG("XXX CMD<%d> MSDC_INT_CMDTMO", 
cmd->opcode);
cmd->error = -ETIMEDOUT;
msdc_reset_hw(host);
-   msdc_clr_fifo();
+   msdc_clr_fifo(host);
msdc_clr_int();
}
complete(>cmd_done);
@@ -2029,7 +2031,7 @@ static void msdc_init_hw(struct msdc_host *host)
 
/* Reset */
msdc_reset_hw(host);
-   msdc_clr_fifo();
+   msdc_clr_fifo(host);
 
/* Disable card detection */
sdr_clr_bits(MSDC_PS, MSDC_PS_CDEN);
-- 
2.16.1

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


[PATCH 11/34] staging: mt7621-mmc: Remove unused macro sdr_write8

2018-06-11 Thread Christian Lütke-Stetzkamp
The macro sdr_write8 is never used, so remove it.

Signed-off-by: Christian Lütke-Stetzkamp 
---
 drivers/staging/mt7621-mmc/mt6575_sd.h | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/staging/mt7621-mmc/mt6575_sd.h 
b/drivers/staging/mt7621-mmc/mt6575_sd.h
index adccabe32660..375cb109806e 100644
--- a/drivers/staging/mt7621-mmc/mt6575_sd.h
+++ b/drivers/staging/mt7621-mmc/mt6575_sd.h
@@ -947,8 +947,6 @@ struct msdc_host {
u32 app_cmd_arg;
 };
 
-#define sdr_write8(reg, val)  writeb(val, reg)
-
 static inline void sdr_set_bits(void __iomem *reg, u32 bs)
 {
u32 val = readl(reg);
-- 
2.16.1

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


[PATCH 05/34] staging: mt7621-mmc: Remove unused macro msdc_fifo_read32

2018-06-11 Thread Christian Lütke-Stetzkamp
The macro msdc_fifo_read32 is never used, so remove it.

Signed-off-by: Christian Lütke-Stetzkamp 
---
 drivers/staging/mt7621-mmc/sd.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/staging/mt7621-mmc/sd.c b/drivers/staging/mt7621-mmc/sd.c
index 9e00f86a0398..0f9cba918586 100644
--- a/drivers/staging/mt7621-mmc/sd.c
+++ b/drivers/staging/mt7621-mmc/sd.c
@@ -149,7 +149,6 @@ static int msdc_rsp[] = {
 
 #define msdc_txfifocnt()   ((sdr_read32(MSDC_FIFOCS) & MSDC_FIFOCS_TXCNT) >> 
16)
 #define msdc_rxfifocnt()   ((sdr_read32(MSDC_FIFOCS) & MSDC_FIFOCS_RXCNT) >> 0)
-#define msdc_fifo_read32()   sdr_read32(MSDC_RXDATA)
 
 #define msdc_dma_on()sdr_clr_bits(MSDC_CFG, MSDC_CFG_PIO)
 
-- 
2.16.1

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


[PATCH 08/34] staging: mt7621-mmc: Replace sdr_write32 with writel

2018-06-11 Thread Christian Lütke-Stetzkamp
The current code uses a macro (sdr_write32) for writing to hardware,
but it is only a writel with switched arguments, so replace it to get
nearer to upstream code.

Signed-off-by: Christian Lütke-Stetzkamp 
---
 drivers/staging/mt7621-mmc/mt6575_sd.h |  1 -
 drivers/staging/mt7621-mmc/sd.c| 64 +-
 2 files changed, 32 insertions(+), 33 deletions(-)

diff --git a/drivers/staging/mt7621-mmc/mt6575_sd.h 
b/drivers/staging/mt7621-mmc/mt6575_sd.h
index 33fa59a019ec..e8e79aab52f8 100644
--- a/drivers/staging/mt7621-mmc/mt6575_sd.h
+++ b/drivers/staging/mt7621-mmc/mt6575_sd.h
@@ -950,7 +950,6 @@ struct msdc_host {
 #define sdr_read8(reg)readb(reg)
 #define sdr_read32(reg)   readl(reg)
 #define sdr_write8(reg, val)  writeb(val, reg)
-#define sdr_write32(reg, val) writel(val, reg)
 
 static inline void sdr_set_bits(void __iomem *reg, u32 bs)
 {
diff --git a/drivers/staging/mt7621-mmc/sd.c b/drivers/staging/mt7621-mmc/sd.c
index 78a681a72f11..e6232f5ac6a8 100644
--- a/drivers/staging/mt7621-mmc/sd.c
+++ b/drivers/staging/mt7621-mmc/sd.c
@@ -174,7 +174,7 @@ static void msdc_reset_hw(struct msdc_host *host)
 #define msdc_clr_int() \
do {\
volatile u32 val = sdr_read32(MSDC_INT);\
-   sdr_write32(MSDC_INT, val); \
+   writel(val, MSDC_INT);  \
} while (0)
 
 #define msdc_clr_fifo() \
@@ -235,8 +235,8 @@ static u32 hclks[] = {5000}; /* +/- by chhung */
 
 #define sdc_send_cmd(cmd, arg) \
do {\
-   sdr_write32(SDC_ARG, (arg));\
-   sdr_write32(SDC_CMD, (cmd));\
+   writel((arg), SDC_ARG); \
+   writel((cmd), SDC_CMD); \
} while (0)
 
 // can modify to read h/w register.
@@ -476,7 +476,7 @@ static void msdc_select_clksrc(struct msdc_host *host, 
unsigned char clksrc)
} else {
val &= ~0x3; val |= clksrc;
}
-   sdr_write32(MSDC_CLKSRC_REG, val);
+   writel(val, MSDC_CLKSRC_REG);
 
host->hclk = hclks[clksrc];
host->hw->clk_src = clksrc;
@@ -1044,14 +1044,14 @@ static void msdc_dma_config(struct msdc_host *host, 
struct msdc_dma *dma)
case MSDC_MODE_DMA_BASIC:
BUG_ON(host->xfer_size > 65535);
BUG_ON(dma->sglen != 1);
-   sdr_write32(MSDC_DMA_SA, PHYSADDR(sg_dma_address(sg)));
+   writel(PHYSADDR(sg_dma_address(sg)), MSDC_DMA_SA);
sdr_set_field(MSDC_DMA_CTRL, MSDC_DMA_CTRL_LASTBUF, 1);
 //#if defined (CONFIG_RALINK_MT7620)
if (ralink_soc == MT762X_SOC_MT7620A)
sdr_set_field(MSDC_DMA_CTRL, MSDC_DMA_CTRL_XFERSZ, 
sg_dma_len(sg));
 //#elif defined (CONFIG_RALINK_MT7621) || defined (CONFIG_RALINK_MT7628)
else
-   sdr_write32((void __iomem *)(RALINK_MSDC_BASE + 0xa8), 
sg_dma_len(sg));
+   writel(sg_dma_len(sg), (void __iomem 
*)(RALINK_MSDC_BASE + 0xa8));
 //#endif
sdr_set_field(MSDC_DMA_CTRL, MSDC_DMA_CTRL_BRUSTSZ,
  MSDC_BRUST_64B);
@@ -1094,7 +1094,7 @@ static void msdc_dma_config(struct msdc_host *host, 
struct msdc_dma *dma)
  MSDC_BRUST_64B);
sdr_set_field(MSDC_DMA_CTRL, MSDC_DMA_CTRL_MODE, 1);
 
-   sdr_write32(MSDC_DMA_SA, PHYSADDR((u32)dma->gpd_addr));
+   writel(PHYSADDR((u32)dma->gpd_addr), MSDC_DMA_SA);
break;
 
default:
@@ -1172,7 +1172,7 @@ static int msdc_do_request(struct mmc_host *mmc, struct 
mmc_request *mrq)
}
}
 
-   sdr_write32(SDC_BLK_NUM, data->blocks);
+   writel(data->blocks, SDC_BLK_NUM);
//msdc_clr_fifo();  /* no need */
 
msdc_dma_on();  /* enable DMA mode first!! */
@@ -1465,8 +1465,8 @@ static int msdc_tune_bread(struct mmc_host *mmc, struct 
mmc_request *mrq)
cur_rxdly0 = (cur_dat0 << 24) | (cur_dat1 << 16) | (cur_dat2 << 
8) | (cur_dat3 << 0);
cur_rxdly1 = (cur_dat4 << 24) | (cur_dat5 << 16) | (cur_dat6 << 
8) | (cur_dat7 << 0);
 
-   sdr_write32(MSDC_DAT_RDDLY0, cur_rxdly0);
-   sdr_write32(MSDC_DAT_RDDLY1, cur_rxdly1);
+   writel(cur_rxdly0, MSDC_DAT_RDDLY0);
+   writel(cur_rxdly1, MSDC_DAT_RDDLY1);
 
} while (++rxdly < 32);
 
@@ -1555,7 +1555,7 @@ static int msdc_tune_bwrite(struct mmc_host *mmc, struct 
mmc_request *mrq)
cur_dat3 = orig_dat3;
 
cur_rxdly0 = (cur_dat0 << 24) | (cur_dat1 << 16) | (cur_dat2 << 
8) | (cur_dat3 << 0);
-   sdr_write32(MSDC_DAT_RDDLY0, cur_rxdly0);
+   writel(cur_rxdly0, MSDC_DAT_RDDLY0);
} while (++rxdly < 32);
 
 done:
@@ -1726,7 

[PATCH 34/34] staging: mt7621-mmc: Find response of SD_APP_OP_COND by default

2018-06-11 Thread Christian Lütke-Stetzkamp
The response type of the SD_APP_OP_COND command is correctly
determined using the mmc_resp_type macro, because the only use of that
opcode, mmc_send_app_op_cond, correctly places MMC_RSP_R3 in cmd.flags.

So there is no need to treat that opcode separately.

Signed-off-by: Christian Lütke-Stetzkamp 
---
 drivers/staging/mt7621-mmc/sd.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/staging/mt7621-mmc/sd.c b/drivers/staging/mt7621-mmc/sd.c
index 3f4de63b25a8..f1b3472b96c3 100644
--- a/drivers/staging/mt7621-mmc/sd.c
+++ b/drivers/staging/mt7621-mmc/sd.c
@@ -710,9 +710,7 @@ static inline u32 msdc_cmd_find_resp(struct mmc_command cmd)
u32 opcode = cmd->opcode;
u32 resp;
 
-   if (opcode == SD_APP_OP_COND) {
-   resp = RESP_R3;
-   } else if (opcode == MMC_SET_RELATIVE_ADDR) {
+   if (opcode == MMC_SET_RELATIVE_ADDR) {
resp = (mmc_cmd_type(cmd) == MMC_CMD_BCR) ? RESP_R6 : RESP_R1;
} else if (opcode == MMC_FAST_IO) {
resp = RESP_R4;
-- 
2.16.1

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


[PATCH 19/34] staging: mt7621-mmc: Remove unnecessary BUG_ON() in msdc_dma_setup

2018-06-11 Thread Christian Lütke-Stetzkamp
The BUG_ON() removed by this patch is just a duplicate of a prior
BUG_ON() statement. There the condition is just clearer, it checks
weather sglen > MAX_BD_NUM and MAX_BD_NUM is equal MAX_BD_PER_GPD. So
this statement can be safely removed.

Signed-off-by: Christian Lütke-Stetzkamp 
---
 drivers/staging/mt7621-mmc/sd.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/staging/mt7621-mmc/sd.c b/drivers/staging/mt7621-mmc/sd.c
index 68dfbf38b0ea..a506c7e19086 100644
--- a/drivers/staging/mt7621-mmc/sd.c
+++ b/drivers/staging/mt7621-mmc/sd.c
@@ -1043,9 +1043,6 @@ static void msdc_dma_setup(struct msdc_host *host, struct 
msdc_dma *dma,
 
N_MSG(DMA, "DMA sglen<%d> xfersz<%d>", sglen, host->xfer_size);
 
-   /* calculate the required number of gpd */
-   BUG_ON(((sglen + MAX_BD_PER_GPD - 1) / MAX_BD_PER_GPD) != 1);
-
gpd = dma->gpd;
bd  = dma->bd;
 
-- 
2.16.1

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


[PATCH 28/34] staging: mt7621-mmc: Remove unused enum msdc_mode

2018-06-11 Thread Christian Lütke-Stetzkamp
The enum msdc_mode is never used, so remove it.

Signed-off-by: Christian Lütke-Stetzkamp 
---
 drivers/staging/mt7621-mmc/dbg.h | 6 --
 1 file changed, 6 deletions(-)

diff --git a/drivers/staging/mt7621-mmc/dbg.h b/drivers/staging/mt7621-mmc/dbg.h
index 5a25a69b00c9..2f2c56b73987 100644
--- a/drivers/staging/mt7621-mmc/dbg.h
+++ b/drivers/staging/mt7621-mmc/dbg.h
@@ -73,12 +73,6 @@ enum msdc_dbg {
SD_TOOL_SDIO_PROFILE = 3,
 };
 
-enum msdc_mode {
-   MODE_PIO = 0,
-   MODE_DMA = 1,
-   MODE_SIZE_DEP = 2,
-};
-
 /* Debug message event */
 #define DBG_EVT_NONE(0)   /* No event */
 #define DBG_EVT_DMA (1 << 0)  /* DMA related event */
-- 
2.16.1

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


[PATCH 16/34] staging: mt7621-mmc: Remove unused field sg from msdc_dma

2018-06-11 Thread Christian Lütke-Stetzkamp
The field sg from struct msdc_dma is once set and never read, so
remove it.

Signed-off-by: Christian Lütke-Stetzkamp 
---
 drivers/staging/mt7621-mmc/mt6575_sd.h | 1 -
 drivers/staging/mt7621-mmc/sd.c| 1 -
 2 files changed, 2 deletions(-)

diff --git a/drivers/staging/mt7621-mmc/mt6575_sd.h 
b/drivers/staging/mt7621-mmc/mt6575_sd.h
index 8eb30d908f9d..c8c5c349adf8 100644
--- a/drivers/staging/mt7621-mmc/mt6575_sd.h
+++ b/drivers/staging/mt7621-mmc/mt6575_sd.h
@@ -480,7 +480,6 @@ struct bd {
 
 struct msdc_dma {
u32 sglen;   /* size of scatter list */
-   struct scatterlist *sg;  /* I/O scatter list */
 
struct gpd *gpd;  /* pointer to gpd array */
struct bd  *bd;   /* pointer to bd array */
diff --git a/drivers/staging/mt7621-mmc/sd.c b/drivers/staging/mt7621-mmc/sd.c
index 923b0687918d..050c4a910aef 100644
--- a/drivers/staging/mt7621-mmc/sd.c
+++ b/drivers/staging/mt7621-mmc/sd.c
@@ -1041,7 +1041,6 @@ static void msdc_dma_setup(struct msdc_host *host, struct 
msdc_dma *dma,
 
BUG_ON(sglen > MAX_BD_NUM); /* not support currently */
 
-   dma->sg = sg_cmd;
dma->sglen = sglen;
 
N_MSG(DMA, "DMA sglen<%d> xfersz<%d>", sglen, host->xfer_size);
-- 
2.16.1

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


[PATCH 02/34] staging: mt7621-mmc: Remove unused macro msdc_fifo_write8

2018-06-11 Thread Christian Lütke-Stetzkamp
The macro msdc_fifo_write8 is never used, so remove it.

Signed-off-by: Christian Lütke-Stetzkamp 
---
 drivers/staging/mt7621-mmc/sd.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/staging/mt7621-mmc/sd.c b/drivers/staging/mt7621-mmc/sd.c
index 7cfadb41a53d..4a69bc84bbd2 100644
--- a/drivers/staging/mt7621-mmc/sd.c
+++ b/drivers/staging/mt7621-mmc/sd.c
@@ -150,7 +150,6 @@ static int msdc_rsp[] = {
 #define msdc_txfifocnt()   ((sdr_read32(MSDC_FIFOCS) & MSDC_FIFOCS_TXCNT) >> 
16)
 #define msdc_rxfifocnt()   ((sdr_read32(MSDC_FIFOCS) & MSDC_FIFOCS_RXCNT) >> 0)
 #define msdc_fifo_write32(v)   sdr_write32(MSDC_TXDATA, (v))
-#define msdc_fifo_write8(v)sdr_write8(MSDC_TXDATA, (v))
 #define msdc_fifo_read32()   sdr_read32(MSDC_RXDATA)
 #define msdc_fifo_read8()sdr_read8(MSDC_RXDATA)
 
-- 
2.16.1

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


[PATCH 30/34] staging: mt7621-mmc: Remove unused macro is_card_present

2018-06-11 Thread Christian Lütke-Stetzkamp
The macro is_card_present is unused and also a duplicate of a macro in
mmc, so remove it.

Signed-off-by: Christian Lütke-Stetzkamp 
---
 drivers/staging/mt7621-mmc/sd.c | 4 
 1 file changed, 4 deletions(-)

diff --git a/drivers/staging/mt7621-mmc/sd.c b/drivers/staging/mt7621-mmc/sd.c
index 45d9b62f4a58..cfe7517f8bdf 100644
--- a/drivers/staging/mt7621-mmc/sd.c
+++ b/drivers/staging/mt7621-mmc/sd.c
@@ -218,10 +218,6 @@ static u32 hclks[] = {5000}; /* +/- by chhung */
writel((cmd), host->base + SDC_CMD);\
} while (0)
 
-// can modify to read h/w register.
-//#define is_card_present(h)   ((readl(MSDC_PS) & MSDC_PS_CDSTS) ? 0 : 1);
-#define is_card_present(h) (((struct msdc_host *)(h))->card_inserted)
-
 /* +++ by chhung */
 #ifndef __ASSEMBLY__
 #define PHYSADDR(a) (((unsigned long)(a)) & 0x1fff)
-- 
2.16.1

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


[PATCH 04/34] staging: mt7621-mmc: Remove unused macro msdc_fifo_write32

2018-06-11 Thread Christian Lütke-Stetzkamp
The macro msdc_fifo_write32 is never used, so remove it.

Signed-off-by: Christian Lütke-Stetzkamp 
---
 drivers/staging/mt7621-mmc/sd.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/staging/mt7621-mmc/sd.c b/drivers/staging/mt7621-mmc/sd.c
index 98bcb0fe6f40..9e00f86a0398 100644
--- a/drivers/staging/mt7621-mmc/sd.c
+++ b/drivers/staging/mt7621-mmc/sd.c
@@ -149,7 +149,6 @@ static int msdc_rsp[] = {
 
 #define msdc_txfifocnt()   ((sdr_read32(MSDC_FIFOCS) & MSDC_FIFOCS_TXCNT) >> 
16)
 #define msdc_rxfifocnt()   ((sdr_read32(MSDC_FIFOCS) & MSDC_FIFOCS_RXCNT) >> 0)
-#define msdc_fifo_write32(v)   sdr_write32(MSDC_TXDATA, (v))
 #define msdc_fifo_read32()   sdr_read32(MSDC_RXDATA)
 
 #define msdc_dma_on()sdr_clr_bits(MSDC_CFG, MSDC_CFG_PIO)
-- 
2.16.1

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


[PATCH 33/34] staging: mt7621-mmc: Find response of MMC_SEND_OP_COND by default

2018-06-11 Thread Christian Lütke-Stetzkamp
The response type of the MMC_SEND_OP_COND command is correctly
determined using the mmc_resp_type macro, because the only use of that
opcode, mmc_send_op_cond, correctly places MMC_RSP_R3 in cmd.flags.

So there is no need to treat that opcode separately.

Signed-off-by: Christian Lütke-Stetzkamp 
---
 drivers/staging/mt7621-mmc/sd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/mt7621-mmc/sd.c b/drivers/staging/mt7621-mmc/sd.c
index c02799acb9e4..3f4de63b25a8 100644
--- a/drivers/staging/mt7621-mmc/sd.c
+++ b/drivers/staging/mt7621-mmc/sd.c
@@ -710,7 +710,7 @@ static inline u32 msdc_cmd_find_resp(struct mmc_command cmd)
u32 opcode = cmd->opcode;
u32 resp;
 
-   if (opcode == MMC_SEND_OP_COND || opcode == SD_APP_OP_COND) {
+   if (opcode == SD_APP_OP_COND) {
resp = RESP_R3;
} else if (opcode == MMC_SET_RELATIVE_ADDR) {
resp = (mmc_cmd_type(cmd) == MMC_CMD_BCR) ? RESP_R6 : RESP_R1;
-- 
2.16.1

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


[PATCH 07/34] staging: mt7621-mmc: Remove unused macro msdc_rxfifocnt

2018-06-11 Thread Christian Lütke-Stetzkamp
The macro msdc_rxfifocnt is never used, so remove it.

Signed-off-by: Christian Lütke-Stetzkamp 
---
 drivers/staging/mt7621-mmc/sd.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/staging/mt7621-mmc/sd.c b/drivers/staging/mt7621-mmc/sd.c
index c6aced0c0a6a..78a681a72f11 100644
--- a/drivers/staging/mt7621-mmc/sd.c
+++ b/drivers/staging/mt7621-mmc/sd.c
@@ -147,8 +147,6 @@ static int msdc_rsp[] = {
7,  /* RESP_R1b */
 };
 
-#define msdc_rxfifocnt()   ((sdr_read32(MSDC_FIFOCS) & MSDC_FIFOCS_RXCNT) >> 0)
-
 #define msdc_dma_on()sdr_clr_bits(MSDC_CFG, MSDC_CFG_PIO)
 
 #define msdc_retry(expr, retry, cnt) \
-- 
2.16.1

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


[PATCH 26/34] staging: mt7621-mmc: Remove unused define RALINK_MSDC_BASE

2018-06-11 Thread Christian Lütke-Stetzkamp
The define RALINK_MSDC_BASE is never used, so remove it.

Signed-off-by: Christian Lütke-Stetzkamp 
---
 drivers/staging/mt7621-mmc/sd.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/staging/mt7621-mmc/sd.c b/drivers/staging/mt7621-mmc/sd.c
index e639ceb2ba85..101ceca2ee4c 100644
--- a/drivers/staging/mt7621-mmc/sd.c
+++ b/drivers/staging/mt7621-mmc/sd.c
@@ -53,10 +53,8 @@
 //#define IRQ_SDC 14   //MT7620 /*FIXME*/
 #ifdef CONFIG_SOC_MT7621
 #define RALINK_SYSCTL_BASE 0xbe00
-#define RALINK_MSDC_BASE   0xbe13
 #else
 #define RALINK_SYSCTL_BASE 0xb000
-#define RALINK_MSDC_BASE   0xb013
 #endif
 #define IRQ_SDC22  /*FIXME*/
 
-- 
2.16.1

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


[PATCH 13/34] staging: mt7621-mmc: Remove DMA basic mode code

2018-06-11 Thread Christian Lütke-Stetzkamp
The driver currently only uses DMA linked mode and the upstream
driver does the same, so remove the basic mode code.

Signed-off-by: Christian Lütke-Stetzkamp 
---
 drivers/staging/mt7621-mmc/sd.c | 88 +++--
 1 file changed, 32 insertions(+), 56 deletions(-)

diff --git a/drivers/staging/mt7621-mmc/sd.c b/drivers/staging/mt7621-mmc/sd.c
index 1d0829e6..1196e8eb86c5 100644
--- a/drivers/staging/mt7621-mmc/sd.c
+++ b/drivers/staging/mt7621-mmc/sd.c
@@ -1040,66 +1040,42 @@ static void msdc_dma_config(struct msdc_host *host, 
struct msdc_dma *dma)
struct gpd *gpd;
struct bd *bd;
 
-   switch (dma->mode) {
-   case MSDC_MODE_DMA_BASIC:
-   BUG_ON(host->xfer_size > 65535);
-   BUG_ON(dma->sglen != 1);
-   writel(PHYSADDR(sg_dma_address(sg)), MSDC_DMA_SA);
-   sdr_set_field(MSDC_DMA_CTRL, MSDC_DMA_CTRL_LASTBUF, 1);
-//#if defined (CONFIG_RALINK_MT7620)
-   if (ralink_soc == MT762X_SOC_MT7620A)
-   sdr_set_field(MSDC_DMA_CTRL, MSDC_DMA_CTRL_XFERSZ, 
sg_dma_len(sg));
-//#elif defined (CONFIG_RALINK_MT7621) || defined (CONFIG_RALINK_MT7628)
+   /* calculate the required number of gpd */
+   num = (dma->sglen + MAX_BD_PER_GPD - 1) / MAX_BD_PER_GPD;
+   BUG_ON(num != 1);
+
+   gpd = dma->gpd;
+   bd  = dma->bd;
+
+   /* modify gpd*/
+   //gpd->intr = 0;
+   gpd->hwo = 1;  /* hw will clear it */
+   gpd->bdp = 1;
+   gpd->chksum = 0;  /* need to clear first. */
+   gpd->chksum = msdc_dma_calcs((u8 *)gpd, 16);
+
+   /* modify bd*/
+   for_each_sg(dma->sg, sg, dma->sglen, j) {
+   bd[j].blkpad = 0;
+   bd[j].dwpad = 0;
+   bd[j].ptr = (void *)sg_dma_address(sg);
+   bd[j].buflen = sg_dma_len(sg);
+
+   if (j == dma->sglen - 1)
+   bd[j].eol = 1;  /* the last bd */
else
-   writel(sg_dma_len(sg), (void __iomem 
*)(RALINK_MSDC_BASE + 0xa8));
-//#endif
-   sdr_set_field(MSDC_DMA_CTRL, MSDC_DMA_CTRL_BRUSTSZ,
- MSDC_BRUST_64B);
-   sdr_set_field(MSDC_DMA_CTRL, MSDC_DMA_CTRL_MODE, 0);
-   break;
-   case MSDC_MODE_DMA_DESC:
-
-   /* calculate the required number of gpd */
-   num = (dma->sglen + MAX_BD_PER_GPD - 1) / MAX_BD_PER_GPD;
-   BUG_ON(num != 1);
-
-   gpd = dma->gpd;
-   bd  = dma->bd;
-
-   /* modify gpd*/
-   //gpd->intr = 0;
-   gpd->hwo = 1;  /* hw will clear it */
-   gpd->bdp = 1;
-   gpd->chksum = 0;  /* need to clear first. */
-   gpd->chksum = msdc_dma_calcs((u8 *)gpd, 16);
-
-   /* modify bd*/
-   for_each_sg(dma->sg, sg, dma->sglen, j) {
-   bd[j].blkpad = 0;
-   bd[j].dwpad = 0;
-   bd[j].ptr = (void *)sg_dma_address(sg);
-   bd[j].buflen = sg_dma_len(sg);
-
-   if (j == dma->sglen - 1)
-   bd[j].eol = 1;  /* the last bd */
-   else
-   bd[j].eol = 0;
+   bd[j].eol = 0;
 
-   bd[j].chksum = 0; /* checksume need to clear first */
-   bd[j].chksum = msdc_dma_calcs((u8 *)([j]), 16);
-   }
+   bd[j].chksum = 0; /* checksume need to clear first */
+   bd[j].chksum = msdc_dma_calcs((u8 *)([j]), 16);
+   }
 
-   sdr_set_field(MSDC_DMA_CFG, MSDC_DMA_CFG_DECSEN, 1);
-   sdr_set_field(MSDC_DMA_CTRL, MSDC_DMA_CTRL_BRUSTSZ,
- MSDC_BRUST_64B);
-   sdr_set_field(MSDC_DMA_CTRL, MSDC_DMA_CTRL_MODE, 1);
+   sdr_set_field(MSDC_DMA_CFG, MSDC_DMA_CFG_DECSEN, 1);
+   sdr_set_field(MSDC_DMA_CTRL, MSDC_DMA_CTRL_BRUSTSZ,
+ MSDC_BRUST_64B);
+   sdr_set_field(MSDC_DMA_CTRL, MSDC_DMA_CTRL_MODE, 1);
 
-   writel(PHYSADDR((u32)dma->gpd_addr), MSDC_DMA_SA);
-   break;
-
-   default:
-   break;
-   }
+   writel(PHYSADDR((u32)dma->gpd_addr), MSDC_DMA_SA);
 
N_MSG(DMA, "DMA_CTRL = 0x%x", readl(MSDC_DMA_CTRL));
N_MSG(DMA, "DMA_CFG  = 0x%x", readl(MSDC_DMA_CFG));
-- 
2.16.1

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


[PATCH v6] Drivers: HV: Send one page worth of kmsg dump over Hyper-V during panic

2018-06-11 Thread Sunil Muthuswamy
In the VM mode on Hyper-V, currently, when the kernel panics, an error
code and few register values are populated in an MSR and the Hypervisor
notified. This information is collected on the host. The amount of
information currently collected is found to be limited and not very
actionable. To gather more actionable data, such as stack trace, the
proposal is to write one page worth of kmsg data on an allocated page
and the Hypervisor notified of the page address through the MSR.

- Sysctl option to control the behavior, with ON by default.

Cc: K. Y. Srinivasan 
Cc: Stephen Hemminger 
Signed-off-by: Sunil Muthuswamy 
---
Changes since v1:
- Added a sysctl config option to allow the user to control if panic message
  should be reported to Hyper-V.

Changes since v2:
- Addressed comments from Greg KH.
- Moved the sysctl config option from 'kernel.hyperv' to 'kernel.' since the
  likelihood of having many Hyper-V specific sysctl config options seemed less
  and so having a specific dir for Hyper-V seemed unnecessary overhead.

Changes since v3:
- The feature is only enabled if the capability is supported by the hypervisor.
  This is done by reading the crash control MSR, in addition to the pre-existing
  check for the hypervisor feature using the CPUID.

Changes since v4:
- Addressed comments from Dexuan Cui: moved the global variable to static.

Changes since v5:
- Addressed comments from KY Srinivasan: errors during panic message
  initialization are no longer fatal.
---
 Documentation/sysctl/kernel.txt|  11 
 arch/x86/hyperv/hv_init.c  |  27 +
 arch/x86/include/asm/hyperv-tlfs.h |   5 +-
 arch/x86/include/asm/mshyperv.h|   1 +
 drivers/hv/vmbus_drv.c | 110 +
 5 files changed, 152 insertions(+), 2 deletions(-)

diff --git a/Documentation/sysctl/kernel.txt b/Documentation/sysctl/kernel.txt
index eded671d..5958503 100644
--- a/Documentation/sysctl/kernel.txt
+++ b/Documentation/sysctl/kernel.txt
@@ -39,6 +39,7 @@ show up in /proc/sys/kernel:
 - hung_task_check_count
 - hung_task_timeout_secs
 - hung_task_warnings
+- hyperv_record_panic_msg
 - kexec_load_disabled
 - kptr_restrict
 - l2cr[ PPC only ]
@@ -374,6 +375,16 @@ This file shows up if CONFIG_DETECT_HUNG_TASK is enabled.
 
 ==
 
+hyperv_record_panic_msg:
+
+Controls whether the panic kmsg data should be reported to Hyper-V.
+
+0: do not report panic kmsg data.
+
+1: report the panic kmsg data. This is the default behavior.
+
+==
+
 kexec_load_disabled:
 
 A toggle indicating if the kexec_load syscall has been disabled. This
diff --git a/arch/x86/hyperv/hv_init.c b/arch/x86/hyperv/hv_init.c
index cfecc22..af57162 100644
--- a/arch/x86/hyperv/hv_init.c
+++ b/arch/x86/hyperv/hv_init.c
@@ -395,6 +395,33 @@ void hyperv_report_panic(struct pt_regs *regs, long err)
 }
 EXPORT_SYMBOL_GPL(hyperv_report_panic);
 
+/**
+ * hyperv_report_panic_msg - report panic message to Hyper-V
+ * @pa: physical address of the panic page containing the message
+ * @size: size of the message in the page
+ */
+void hyperv_report_panic_msg(phys_addr_t pa, size_t size)
+{
+   /*
+* P3 to contain the physical address of the panic page & P4 to
+* contain the size of the panic data in that page. Rest of the
+* registers are no-op when the NOTIFY_MSG flag is set.
+*/
+   wrmsrl(HV_X64_MSR_CRASH_P0, 0);
+   wrmsrl(HV_X64_MSR_CRASH_P1, 0);
+   wrmsrl(HV_X64_MSR_CRASH_P2, 0);
+   wrmsrl(HV_X64_MSR_CRASH_P3, pa);
+   wrmsrl(HV_X64_MSR_CRASH_P4, size);
+
+   /*
+* Let Hyper-V know there is crash data available along with
+* the panic message.
+*/
+   wrmsrl(HV_X64_MSR_CRASH_CTL,
+  (HV_CRASH_CTL_CRASH_NOTIFY | HV_CRASH_CTL_CRASH_NOTIFY_MSG));
+}
+EXPORT_SYMBOL_GPL(hyperv_report_panic_msg);
+
 bool hv_is_hyperv_initialized(void)
 {
union hv_x64_msr_hypercall_contents hypercall_msr;
diff --git a/arch/x86/include/asm/hyperv-tlfs.h 
b/arch/x86/include/asm/hyperv-tlfs.h
index 416cb0e..76c58af 100644
--- a/arch/x86/include/asm/hyperv-tlfs.h
+++ b/arch/x86/include/asm/hyperv-tlfs.h
@@ -171,9 +171,10 @@
 #define HV_X64_ENLIGHTENED_VMCS_RECOMMENDED(1 << 14)
 
 /*
- * Crash notification flag.
+ * Crash notification flags.
  */
-#define HV_CRASH_CTL_CRASH_NOTIFY (1ULL << 63)
+#define HV_CRASH_CTL_CRASH_NOTIFY_MSG  BIT_ULL(62)
+#define HV_CRASH_CTL_CRASH_NOTIFY  BIT_ULL(63)
 
 /* MSR used to identify the guest OS. */
 #define HV_X64_MSR_GUEST_OS_ID 0x4000
diff --git a/arch/x86/include/asm/mshyperv.h b/arch/x86/include/asm/mshyperv.h
index b90e796..ac83f2d 100644
--- a/arch/x86/include/asm/mshyperv.h
+++ b/arch/x86/include/asm/mshyperv.h
@@ -262,6 +262,7 @@ void hyperv_init(void);
 void hyperv_setup_mmu_ops(void);
 void hyper_alloc_mmu(void);
 void 

[PATCH net 2/3] hv_netvsc: fix network namespace issues with VF support

2018-06-11 Thread Stephen Hemminger
When finding the parent netvsc device, the search needs to be across
all netvsc device instances (independent of network namespace).

Find parent device of VF using upper_dev_get routine which
searches only adjacent list.

Fixes: e8ff40d4bff1 ("hv_netvsc: improve VF device matching")
Signed-off-by: Stephen Hemminger 

netns aware byref
---
 drivers/net/hyperv/hyperv_net.h |  2 ++
 drivers/net/hyperv/netvsc_drv.c | 43 +++--
 2 files changed, 22 insertions(+), 23 deletions(-)

diff --git a/drivers/net/hyperv/hyperv_net.h b/drivers/net/hyperv/hyperv_net.h
index 1be34d2e3563..c0b3f3c125d4 100644
--- a/drivers/net/hyperv/hyperv_net.h
+++ b/drivers/net/hyperv/hyperv_net.h
@@ -902,6 +902,8 @@ struct net_device_context {
struct hv_device *device_ctx;
/* netvsc_device */
struct netvsc_device __rcu *nvdev;
+   /* list of netvsc net_devices */
+   struct list_head list;
/* reconfigure work */
struct delayed_work dwork;
/* last reconfig time */
diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c
index 2d4370c94b6e..8cb21e013d1d 100644
--- a/drivers/net/hyperv/netvsc_drv.c
+++ b/drivers/net/hyperv/netvsc_drv.c
@@ -69,6 +69,8 @@ static int debug = -1;
 module_param(debug, int, 0444);
 MODULE_PARM_DESC(debug, "Debug level (0=none,...,16=all)");
 
+static LIST_HEAD(netvsc_dev_list);
+
 static void netvsc_change_rx_flags(struct net_device *net, int change)
 {
struct net_device_context *ndev_ctx = netdev_priv(net);
@@ -1783,13 +1785,10 @@ static void netvsc_link_change(struct work_struct *w)
 
 static struct net_device *get_netvsc_bymac(const u8 *mac)
 {
-   struct net_device *dev;
-
-   ASSERT_RTNL();
+   struct net_device_context *ndev_ctx;
 
-   for_each_netdev(_net, dev) {
-   if (dev->netdev_ops != _ops)
-   continue;   /* not a netvsc device */
+   list_for_each_entry(ndev_ctx, _dev_list, list) {
+   struct net_device *dev = hv_get_drvdata(ndev_ctx->device_ctx);
 
if (ether_addr_equal(mac, dev->perm_addr))
return dev;
@@ -1800,25 +1799,18 @@ static struct net_device *get_netvsc_bymac(const u8 
*mac)
 
 static struct net_device *get_netvsc_byref(struct net_device *vf_netdev)
 {
+   struct net_device_context *net_device_ctx;
struct net_device *dev;
 
-   ASSERT_RTNL();
-
-   for_each_netdev(_net, dev) {
-   struct net_device_context *net_device_ctx;
+   dev = netdev_master_upper_dev_get(vf_netdev);
+   if (!dev || dev->netdev_ops != _ops)
+   return NULL;/* not a netvsc device */
 
-   if (dev->netdev_ops != _ops)
-   continue;   /* not a netvsc device */
+   net_device_ctx = netdev_priv(dev);
+   if (!rtnl_dereference(net_device_ctx->nvdev))
+   return NULL;/* device is removed */
 
-   net_device_ctx = netdev_priv(dev);
-   if (!rtnl_dereference(net_device_ctx->nvdev))
-   continue;   /* device is removed */
-
-   if (rtnl_dereference(net_device_ctx->vf_netdev) == vf_netdev)
-   return dev; /* a match */
-   }
-
-   return NULL;
+   return dev;
 }
 
 /* Called when VF is injecting data into network stack.
@@ -2095,15 +2087,19 @@ static int netvsc_probe(struct hv_device *dev,
else
net->max_mtu = ETH_DATA_LEN;
 
-   ret = register_netdev(net);
+   rtnl_lock();
+   ret = register_netdevice(net);
if (ret != 0) {
pr_err("Unable to register netdev.\n");
goto register_failed;
}
 
-   return ret;
+   list_add(_device_ctx->list, _dev_list);
+   rtnl_unlock();
+   return 0;
 
 register_failed:
+   rtnl_unlock();
rndis_filter_device_remove(dev, nvdev);
 rndis_failed:
free_percpu(net_device_ctx->vf_stats);
@@ -2149,6 +2145,7 @@ static int netvsc_remove(struct hv_device *dev)
rndis_filter_device_remove(dev, nvdev);
 
unregister_netdevice(net);
+   list_del(_ctx->list);
 
rtnl_unlock();
rcu_read_unlock();
-- 
2.17.1

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


[PATCH net 3/3] hv_netvsc: move VF to same namespace as netvsc device

2018-06-11 Thread Stephen Hemminger
When VF is added, the paravirtual device is already present
and may have been moved to another network namespace. For example,
sometimes the management interface is put in another net namespace
in some environments.

The VF should get moved to where the netvsc device is when the
VF is discovered. The user can move it later (if desired).

Signed-off-by: Stephen Hemminger 
---
 drivers/net/hyperv/netvsc_drv.c | 21 -
 1 file changed, 20 insertions(+), 1 deletion(-)

diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c
index 8cb21e013d1d..bf1b845c1147 100644
--- a/drivers/net/hyperv/netvsc_drv.c
+++ b/drivers/net/hyperv/netvsc_drv.c
@@ -1930,6 +1930,7 @@ static int netvsc_register_vf(struct net_device 
*vf_netdev)
struct net_device *ndev;
struct net_device_context *net_device_ctx;
struct netvsc_device *netvsc_dev;
+   int ret;
 
if (vf_netdev->addr_len != ETH_ALEN)
return NOTIFY_DONE;
@@ -1948,11 +1949,29 @@ static int netvsc_register_vf(struct net_device 
*vf_netdev)
if (!netvsc_dev || rtnl_dereference(net_device_ctx->vf_netdev))
return NOTIFY_DONE;
 
-   if (netvsc_vf_join(vf_netdev, ndev) != 0)
+   /* if syntihetic interface is a different namespace,
+* then move the VF to that namespace; join will be
+* done again in that context.
+*/
+   if (!net_eq(dev_net(ndev), dev_net(vf_netdev))) {
+   ret = dev_change_net_namespace(vf_netdev,
+  dev_net(ndev), "eth%d");
+   if (ret)
+   netdev_err(vf_netdev,
+  "could not move to same namespace as %s: 
%d\n",
+  ndev->name, ret);
+   else
+   netdev_info(vf_netdev,
+   "VF moved to namespace with: %s\n",
+   ndev->name);
return NOTIFY_DONE;
+   }
 
netdev_info(ndev, "VF registering: %s\n", vf_netdev->name);
 
+   if (netvsc_vf_join(vf_netdev, ndev) != 0)
+   return NOTIFY_DONE;
+
dev_hold(vf_netdev);
rcu_assign_pointer(net_device_ctx->vf_netdev, vf_netdev);
return NOTIFY_OK;
-- 
2.17.1

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


[PATCH net 1/3] hv_netvsc: drop common code until callback model fixed

2018-06-11 Thread Stephen Hemminger
The callback model of handling network failover is not suitable
in the current form.
  1. It was merged without addressing all the review feedback.
  2. It was merged without approval of any of the netvsc maintainers.
  3. Design discussion on how to handle PV/VF fallback is still
 not complete.
  4. IMHO the code model using callbacks is trying to make
 something common which isn't.

Revert the netvsc specific changes for now. Does not impact ongoing
development of failover model for virtio.
Revisit this after a simpler library based failover kernel
routines are extracted.

This reverts
commit 9c6ffbacdb57 ("hv_netvsc: fix error return code in netvsc_probe()")
and
commit 1ff78076d8dd ("netvsc: refactor notifier/event handling code to use the 
failover framework")

Signed-off-by: Stephen Hemminger 
---
 drivers/net/hyperv/Kconfig  |   1 -
 drivers/net/hyperv/hyperv_net.h |   2 -
 drivers/net/hyperv/netvsc_drv.c | 224 +++-
 3 files changed, 165 insertions(+), 62 deletions(-)

diff --git a/drivers/net/hyperv/Kconfig b/drivers/net/hyperv/Kconfig
index 23a2d145813a..0765d5f61714 100644
--- a/drivers/net/hyperv/Kconfig
+++ b/drivers/net/hyperv/Kconfig
@@ -2,6 +2,5 @@ config HYPERV_NET
tristate "Microsoft Hyper-V virtual network driver"
depends on HYPERV
select UCS2_STRING
-   select FAILOVER
help
  Select this option to enable the Hyper-V virtual network driver.
diff --git a/drivers/net/hyperv/hyperv_net.h b/drivers/net/hyperv/hyperv_net.h
index 99d8e7398a5b..1be34d2e3563 100644
--- a/drivers/net/hyperv/hyperv_net.h
+++ b/drivers/net/hyperv/hyperv_net.h
@@ -932,8 +932,6 @@ struct net_device_context {
u32 vf_alloc;
/* Serial number of the VF to team with */
u32 vf_serial;
-
-   struct failover *failover;
 };
 
 /* Per channel data */
diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c
index 8eec156418ea..2d4370c94b6e 100644
--- a/drivers/net/hyperv/netvsc_drv.c
+++ b/drivers/net/hyperv/netvsc_drv.c
@@ -43,7 +43,6 @@
 #include 
 #include 
 #include 
-#include 
 
 #include "hyperv_net.h"
 
@@ -1782,6 +1781,46 @@ static void netvsc_link_change(struct work_struct *w)
rtnl_unlock();
 }
 
+static struct net_device *get_netvsc_bymac(const u8 *mac)
+{
+   struct net_device *dev;
+
+   ASSERT_RTNL();
+
+   for_each_netdev(_net, dev) {
+   if (dev->netdev_ops != _ops)
+   continue;   /* not a netvsc device */
+
+   if (ether_addr_equal(mac, dev->perm_addr))
+   return dev;
+   }
+
+   return NULL;
+}
+
+static struct net_device *get_netvsc_byref(struct net_device *vf_netdev)
+{
+   struct net_device *dev;
+
+   ASSERT_RTNL();
+
+   for_each_netdev(_net, dev) {
+   struct net_device_context *net_device_ctx;
+
+   if (dev->netdev_ops != _ops)
+   continue;   /* not a netvsc device */
+
+   net_device_ctx = netdev_priv(dev);
+   if (!rtnl_dereference(net_device_ctx->nvdev))
+   continue;   /* device is removed */
+
+   if (rtnl_dereference(net_device_ctx->vf_netdev) == vf_netdev)
+   return dev; /* a match */
+   }
+
+   return NULL;
+}
+
 /* Called when VF is injecting data into network stack.
  * Change the associated network device from VF to netvsc.
  * note: already called with rcu_read_lock
@@ -1804,6 +1843,46 @@ static rx_handler_result_t netvsc_vf_handle_frame(struct 
sk_buff **pskb)
return RX_HANDLER_ANOTHER;
 }
 
+static int netvsc_vf_join(struct net_device *vf_netdev,
+ struct net_device *ndev)
+{
+   struct net_device_context *ndev_ctx = netdev_priv(ndev);
+   int ret;
+
+   ret = netdev_rx_handler_register(vf_netdev,
+netvsc_vf_handle_frame, ndev);
+   if (ret != 0) {
+   netdev_err(vf_netdev,
+  "can not register netvsc VF receive handler (err = 
%d)\n",
+  ret);
+   goto rx_handler_failed;
+   }
+
+   ret = netdev_master_upper_dev_link(vf_netdev, ndev,
+  NULL, NULL, NULL);
+   if (ret != 0) {
+   netdev_err(vf_netdev,
+  "can not set master device %s (err = %d)\n",
+  ndev->name, ret);
+   goto upper_link_failed;
+   }
+
+   /* set slave flag before open to prevent IPv6 addrconf */
+   vf_netdev->flags |= IFF_SLAVE;
+
+   schedule_delayed_work(_ctx->vf_takeover, VF_TAKEOVER_INT);
+
+   call_netdevice_notifiers(NETDEV_JOIN, vf_netdev);
+
+   netdev_info(vf_netdev, "joined to %s\n", ndev->name);
+   return 0;
+
+upper_link_failed:
+   netdev_rx_handler_unregister(vf_netdev);
+rx_handler_failed:
+   return ret;
+}
+
 

[PATCH net 0/3] hv_netvsc: notification and namespace fixes

2018-06-11 Thread Stephen Hemminger
This set of patches addresses two set of fixes. First it backs out
the common callback model which was merged in net-next without
completing all the review feedback or getting maintainer approval.

Then it fixes the transparent VF management code to handle network
namespaces.

Stephen Hemminger (3):
  hv_netvsc: drop common code until callback model fixed
  hv_netvsc: fix network namespace issues with VF support
  hv_netvsc: move VF to same namespace as netvsc device

 drivers/net/hyperv/Kconfig  |   1 -
 drivers/net/hyperv/hyperv_net.h |   4 +-
 drivers/net/hyperv/netvsc_drv.c | 242 
 3 files changed, 184 insertions(+), 63 deletions(-)

-- 
2.17.1

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


RE: [PATCH v5] Drivers: HV: Send one page worth of kmsg dump over Hyper-V during panic

2018-06-11 Thread Sunil Muthuswamy



> -Original Message-
> From: KY Srinivasan
> Sent: Monday, June 11, 2018 11:39 AM
> To: Sunil Muthuswamy ; Haiyang Zhang
> 
> Cc: de...@linuxdriverproject.org; Stephen Hemminger
> 
> Subject: RE: [PATCH v5] Drivers: HV: Send one page worth of kmsg dump
> over Hyper-V during panic
> 
> 
> 
> > -Original Message-
> > From: Sunil Muthuswamy
> > Sent: Monday, June 11, 2018 10:44 AM
> > To: KY Srinivasan ; Haiyang Zhang
> > 
> > Cc: de...@linuxdriverproject.org; Stephen Hemminger
> > 
> > Subject: RE: [PATCH v5] Drivers: HV: Send one page worth of kmsg dump
> > over Hyper-V during panic
> >
> >
> >
> > > -Original Message-
> > > From: KY Srinivasan
> > > Sent: Sunday, June 10, 2018 2:54 PM
> > > To: Sunil Muthuswamy ; Haiyang Zhang
> > > 
> > > Cc: de...@linuxdriverproject.org; Stephen Hemminger
> > > 
> > > Subject: RE: [PATCH v5] Drivers: HV: Send one page worth of kmsg dump
> > > over Hyper-V during panic
> > >
> > >
> > >
> > > > -Original Message-
> > > > From: Sunil Muthuswamy
> > > > Sent: Friday, June 8, 2018 11:39 AM
> > > > To: Haiyang Zhang 
> > > > Cc: de...@linuxdriverproject.org; Sunil Muthuswamy
> > > > ; KY Srinivasan ;
> > Stephen
> > > > Hemminger 
> > > > Subject: [PATCH v5] Drivers: HV: Send one page worth of kmsg dump
> > over
> > > > Hyper-V during panic
> > > >
> > > > In the VM mode on Hyper-V, currently, when the kernel panics, an
> error
> > > > code and few register values are populated in an MSR and the
> Hypervisor
> > > > notified. This information is collected on the host. The amount of
> > > > information currently collected is found to be limited and not very
> > > > actionable. To gather more actionable data, such as stack trace, the
> > > > proposal is to write one page worth of kmsg data on an allocated page
> > > > and the Hypervisor notified of the page address through the MSR.
> > > >
> 
> Snip.
> 
> > > >  /*
> > > >   * vmbus_bus_init -Main vmbus driver initialization routine.
> > > > @@ -1065,6 +1136,38 @@ static int vmbus_bus_init(void)
> > > >  * Only register if the crash MSRs are available
> > > >  */
> > > > if (ms_hyperv.misc_features &
> > > > HV_FEATURE_GUEST_CRASH_MSR_AVAILABLE) {
> > > > +   u64 hyperv_crash_ctl;
> > > > +   if (!hv_ctl_table_hdr) {
> > > When vmus_bus_init is invoked, would hv_ctl_table_hdr  ever be
> > > Non-NULL?
> Ping.
Missed this somehow. It should not be. Will fix this as well in the next 
version.
> 
> Snip.
> 
> Regards,
> 
> K. Y
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


RE: [PATCH v5] Drivers: HV: Send one page worth of kmsg dump over Hyper-V during panic

2018-06-11 Thread KY Srinivasan



> -Original Message-
> From: Sunil Muthuswamy
> Sent: Monday, June 11, 2018 10:44 AM
> To: KY Srinivasan ; Haiyang Zhang
> 
> Cc: de...@linuxdriverproject.org; Stephen Hemminger
> 
> Subject: RE: [PATCH v5] Drivers: HV: Send one page worth of kmsg dump
> over Hyper-V during panic
> 
> 
> 
> > -Original Message-
> > From: KY Srinivasan
> > Sent: Sunday, June 10, 2018 2:54 PM
> > To: Sunil Muthuswamy ; Haiyang Zhang
> > 
> > Cc: de...@linuxdriverproject.org; Stephen Hemminger
> > 
> > Subject: RE: [PATCH v5] Drivers: HV: Send one page worth of kmsg dump
> > over Hyper-V during panic
> >
> >
> >
> > > -Original Message-
> > > From: Sunil Muthuswamy
> > > Sent: Friday, June 8, 2018 11:39 AM
> > > To: Haiyang Zhang 
> > > Cc: de...@linuxdriverproject.org; Sunil Muthuswamy
> > > ; KY Srinivasan ;
> Stephen
> > > Hemminger 
> > > Subject: [PATCH v5] Drivers: HV: Send one page worth of kmsg dump
> over
> > > Hyper-V during panic
> > >
> > > In the VM mode on Hyper-V, currently, when the kernel panics, an error
> > > code and few register values are populated in an MSR and the Hypervisor
> > > notified. This information is collected on the host. The amount of
> > > information currently collected is found to be limited and not very
> > > actionable. To gather more actionable data, such as stack trace, the
> > > proposal is to write one page worth of kmsg data on an allocated page
> > > and the Hypervisor notified of the page address through the MSR.
> > >

Snip.

> > >  /*
> > >   * vmbus_bus_init -Main vmbus driver initialization routine.
> > > @@ -1065,6 +1136,38 @@ static int vmbus_bus_init(void)
> > >* Only register if the crash MSRs are available
> > >*/
> > >   if (ms_hyperv.misc_features &
> > > HV_FEATURE_GUEST_CRASH_MSR_AVAILABLE) {
> > > + u64 hyperv_crash_ctl;
> > > + if (!hv_ctl_table_hdr) {
> > When vmus_bus_init is invoked, would hv_ctl_table_hdr  ever be
> > Non-NULL?
Ping.

Snip.

Regards,

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


[PATCH] staging: android: ion: Return an ERR_PTR in ion_map_kernel

2018-06-11 Thread Laura Abbott


The expected return value from ion_map_kernel is an ERR_PTR. The error
path for a vmalloc failure currently just returns NULL, triggering
a warning in ion_buffer_kmap_get. Encode the vmalloc failure as an ERR_PTR.

Reported-by: syzbot+55b1d9f811650de94...@syzkaller.appspotmail.com
Signed-off-by: Laura Abbott 
---
 drivers/staging/android/ion/ion_heap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/android/ion/ion_heap.c 
b/drivers/staging/android/ion/ion_heap.c
index 772dad65396e..f32c12439eee 100644
--- a/drivers/staging/android/ion/ion_heap.c
+++ b/drivers/staging/android/ion/ion_heap.c
@@ -29,7 +29,7 @@ void *ion_heap_map_kernel(struct ion_heap *heap,
struct page **tmp = pages;
 
if (!pages)
-   return NULL;
+   return ERR_PTR(-ENOMEM);
 
if (buffer->flags & ION_FLAG_CACHED)
pgprot = PAGE_KERNEL;
-- 
2.17.0

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


RE: [PATCH v5] Drivers: HV: Send one page worth of kmsg dump over Hyper-V during panic

2018-06-11 Thread Sunil Muthuswamy



> -Original Message-
> From: KY Srinivasan
> Sent: Sunday, June 10, 2018 2:54 PM
> To: Sunil Muthuswamy ; Haiyang Zhang
> 
> Cc: de...@linuxdriverproject.org; Stephen Hemminger
> 
> Subject: RE: [PATCH v5] Drivers: HV: Send one page worth of kmsg dump
> over Hyper-V during panic
> 
> 
> 
> > -Original Message-
> > From: Sunil Muthuswamy
> > Sent: Friday, June 8, 2018 11:39 AM
> > To: Haiyang Zhang 
> > Cc: de...@linuxdriverproject.org; Sunil Muthuswamy
> > ; KY Srinivasan ; Stephen
> > Hemminger 
> > Subject: [PATCH v5] Drivers: HV: Send one page worth of kmsg dump over
> > Hyper-V during panic
> >
> > In the VM mode on Hyper-V, currently, when the kernel panics, an error
> > code and few register values are populated in an MSR and the Hypervisor
> > notified. This information is collected on the host. The amount of
> > information currently collected is found to be limited and not very
> > actionable. To gather more actionable data, such as stack trace, the
> > proposal is to write one page worth of kmsg data on an allocated page
> > and the Hypervisor notified of the page address through the MSR.
> >
> > - Sysctl option to control the behavior, with ON by default.
> >
> > Cc: K. Y. Srinivasan 
> > Cc: Stephen Hemminger 
> > Signed-off-by: Sunil Muthuswamy 
> > ---
> > Changes since v1:
> > - Added a sysctl config option to allow the user to control if panic message
> >   should be reported to Hyper-V.
> >
> > Changes since v2:
> > - Addressed comments from Greg KH.
> > - Moved the sysctl config option from 'kernel.hyperv' to 'kernel.' since the
> >   likelihood of having many Hyper-V specific sysctl config options seemed
> less
> >   and so having a specific dir for Hyper-V seemed unnecessary overhead.
> >
> > Changes since v3:
> > - The feature is only enabled if the capability is supported by the
> hypervisor.
> >   This is done by reading the crash control MSR, in addition to the pre-
> existing
> >   check for the hypervisor feature using the CPUID.
> >
> > Changes since v4:
> > - Addressed comments from Dexuan Cui: moved the global variable to
> static.
> > ---
> >  Documentation/sysctl/kernel.txt|  11 
> >  arch/x86/hyperv/hv_init.c  |  27 +
> >  arch/x86/include/asm/hyperv-tlfs.h |   5 +-
> >  arch/x86/include/asm/mshyperv.h|   1 +
> >  drivers/hv/vmbus_drv.c | 116
> > +
> >  5 files changed, 158 insertions(+), 2 deletions(-)
> >
> > diff --git a/Documentation/sysctl/kernel.txt
> > b/Documentation/sysctl/kernel.txt
> > index eded671d..5958503 100644
> > --- a/Documentation/sysctl/kernel.txt
> > +++ b/Documentation/sysctl/kernel.txt
> > @@ -39,6 +39,7 @@ show up in /proc/sys/kernel:
> >  - hung_task_check_count
> >  - hung_task_timeout_secs
> >  - hung_task_warnings
> > +- hyperv_record_panic_msg
> >  - kexec_load_disabled
> >  - kptr_restrict
> >  - l2cr[ PPC only ]
> > @@ -374,6 +375,16 @@ This file shows up if CONFIG_DETECT_HUNG_TASK
> is
> > enabled.
> >
> >
> >
> ==
> > 
> >
> > +hyperv_record_panic_msg:
> > +
> > +Controls whether the panic kmsg data should be reported to Hyper-V.
> > +
> > +0: do not report panic kmsg data.
> > +
> > +1: report the panic kmsg data. This is the default behavior.
> > +
> >
> +=
> > =
> > +
> >  kexec_load_disabled:
> >
> >  A toggle indicating if the kexec_load syscall has been disabled. This
> > diff --git a/arch/x86/hyperv/hv_init.c b/arch/x86/hyperv/hv_init.c
> > index cfecc22..af57162 100644
> > --- a/arch/x86/hyperv/hv_init.c
> > +++ b/arch/x86/hyperv/hv_init.c
> > @@ -395,6 +395,33 @@ void hyperv_report_panic(struct pt_regs *regs,
> long
> > err)
> >  }
> >  EXPORT_SYMBOL_GPL(hyperv_report_panic);
> >
> > +/**
> > + * hyperv_report_panic_msg - report panic message to Hyper-V
> > + * @pa: physical address of the panic page containing the message
> > + * @size: size of the message in the page
> > + */
> > +void hyperv_report_panic_msg(phys_addr_t pa, size_t size)
> > +{
> > +   /*
> > +* P3 to contain the physical address of the panic page & P4 to
> > +* contain the size of the panic data in that page. Rest of the
> > +* registers are no-op when the NOTIFY_MSG flag is set.
> > +*/
> > +   wrmsrl(HV_X64_MSR_CRASH_P0, 0);
> > +   wrmsrl(HV_X64_MSR_CRASH_P1, 0);
> > +   wrmsrl(HV_X64_MSR_CRASH_P2, 0);
> > +   wrmsrl(HV_X64_MSR_CRASH_P3, pa);
> > +   wrmsrl(HV_X64_MSR_CRASH_P4, size);
> > +
> > +   /*
> > +* Let Hyper-V know there is crash data available along with
> > +* the panic message.
> > +*/
> > +   wrmsrl(HV_X64_MSR_CRASH_CTL,
> > +  (HV_CRASH_CTL_CRASH_NOTIFY |
> > HV_CRASH_CTL_CRASH_NOTIFY_MSG));
> > +}
> > +EXPORT_SYMBOL_GPL(hyperv_report_panic_msg);
> > +
> >  bool hv_is_hyperv_initialized(void)
> >  {
> > union hv_x64_msr_hypercall_contents hypercall_msr;
> > diff --git 

Important Notification

2018-06-11 Thread Information Update
Dear Recipent ,

This email address has won Three Million Pounds on the o2 mobile 
sweepstakes.Please Contact Payment Cordinator Mat on email :  
mrw...@o2loto.co.uk for explanation and payment processing .

Yours Faithfully 

Debbie Spence 

Cordinator O2 Mobile Promotional Sweepstakes.


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


Re: [PATCH v2] staging: mt7621-gpio: avoid custom irq_domain for gpio

2018-06-11 Thread Sergio Paracuellos
On Mon, Jun 11, 2018 at 06:26:09PM +1000, NeilBrown wrote:
> On Mon, Jun 11 2018, Sergio Paracuellos wrote:
> 
> > Instead of create a custom irq_domain for this chip, use
> > 'gpiochip_set_chained_irqchip' from GPIOLIB_IRQCHIP. It
> > is ok to call this function several times. You only have to
> > mark the line with 'IRQF_SHARED' and then loop over the
> > three banks until you find a hit. There were some problems
> > with removing an irqchip like that but this driver is a bool
> > so it might work just fine. After this changes the functions
> > 'mediatek_gpio_to_irq' is not needed anymore and also the
> > 'gpio_irq_domain' field from the state container. Instead of
> > use the custom irq domain in the irq handler use the associated
> > domain from the gpio_chip in 'irq_find_mapping' function.
> > Function 'mediatek_gpio_bank_probe' has been moved a it to the
> > botton to have all the irq related functions together and avoid
> > some forward declarations to resolve some symbols along the code.
> >
> > Signed-off-by: Sergio Paracuellos 
> 
> Thanks for this.
> The patch has two problems.
> 1/ it doesn't compile unless CONFIG_GPIOLIB_IRQCHIP is selected.
>   So we need "select GPIOLIB_IRQCHIP" in Kconfig
> 
> 2/ The interrupt line has not been marked IRQF_SHARED.
>  I cannot figure out how to mark it as IRQF_SHARED.
>  If I hack the code so that mediatek_gpio_bank_probe()
>  is only called for the first bank, then interrupt from
>  that bank work fine.
>  If I let it be called for all three banks, then on the first interrupt,
>  the system starts to hang.

The way to do this seems to mark IRQF_SHARED using devm_request_irq and then
passing out NULL as irq handler in gpiochip_set_chained_irqchip. The prototype
for the irq handler change also from the normal irqreturn_t stuff. I have just 
sent
a new PATCH (included in the v3 of 'last cleanups' series) following this 
approach. 

Hope this helps and works :-),

> 
> Thanks,
> NeilBrown

Best regards,
Sergio Paracuellos


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


Re: [PATCH v2 0/7] staging: mt7621-gpio: last cleanups

2018-06-11 Thread Sergio Paracuellos
On Mon, Jun 11, 2018 at 06:33:44PM +1000, NeilBrown wrote:
> On Mon, Jun 11 2018, Sergio Paracuellos wrote:
> 
> > After submiting this driver to try to get mainlined and get
> > out of staging some new cleanups seems to be necessary.
> > According to this main of Linus Walleij:
> >
> > http://driverdev.linuxdriverproject.org/pipermail/driverdev-devel/2018-June/121742.html
> >
> > this series tries to fix all of the issues in order to send
> > v2 and give it a new try. Because I don't have to hardware to
> > test my changes I send new cleanups first in staging to make
> > easier to NeilBrown test it and get a feedback about them.
> >
> > Changes in v2:
> > - Patch where GPIOLIB_IRQCHIP was used avoiding
> >   the use of a custom irq domain has been dropped to
> >   be sure after this changes all is working properly.
> >   (This was PATCH 7 in previous series)
> > - PATCH 1: 
> >  * avoid introducing new macros and use 'bank'
> >field of mtk_gc with register offset.
> >  * Make correct use of bgpio_init passing new
> >void __iomem pointers instead of use the
> >macros. 
> > - Previous series PATCH 8 now is PATCH 7. Avoid the
> >   use of a switch-case statement which was wrong and
> >   distinc if we have RISSING AND FALLING EDGE interrupt
> >   or HIGH LOW level ones. This last two are exclusive and
> >   cannot be generated at the same time.
> >
> > Also, I think is we finally avoid to use a new irq_domain the
> > need for the new functions introduced for request and release
> > resources dissapears. I was diving down the other drivers code
> > and I see that these two only are used in drivers which use its
> > own irq_domain. Correct me if I am wrong, please.
> >
> > Hope this helps.
> >
> > Thanks in advance.
> 
> Thanks a lot.
> This series appears to work, though I sent a separate comment on one
> piece of code.

Thanks for testing, review and feedback.

I have resent a complete v3 of this series taking into account
your comments there.

> However the gpio are numbers
> 480-511
> 448-479
> 416-447
> 
> instead of
> 0-31
> 32-63
> 64-95
> 
> which would be more normal.
> Maybe when you resubmit I'll raid it with Linus Walleij and see if he
> can explain why I can't have 0-95.

This change is because the chip.base property changed to be -1 for
dynamic enumeration of the gpio's. In this mail there is some explanation
about it:

http://lists.infradead.org/pipermail/linux-rpi-kernel/2014-October/001045.html

Best regards,
Sergio Paracuellos
> 
> Thanks,
> NeilBrown
> 
> 
> >
> > Best regards,
> > Sergio Paracuellos
> >
> > Sergio Paracuellos (7):
> >   staging: mt7621-gpio: make use 'bgpio_init' from GPIO_GENERIC
> >   staging: mt7621-gpio: avoid including 'gpio.h'
> >   staging: mt7621-gpio: make use of 'builtin_platform_driver'
> >   staging: mt7621-gpio: implement '.irq_[request|release]_resources'
> > functions
> >   staging: mt7621-gpio: add COMPILE_TEST
> >   staging: mt7621-gpio: add kerneldoc for state data containers
> >   staging: mt7621-gpio: implement high level and low level irqs
> >
> >  drivers/staging/mt7621-gpio/Kconfig   |   3 +-
> >  drivers/staging/mt7621-gpio/gpio-mt7621.c | 251 
> > --
> >  2 files changed, 138 insertions(+), 116 deletions(-)
> >
> > -- 
> > 2.7.4


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


[PATCH v3 7/8] staging: mt7621-gpio: implement high level and low level irqs

2018-06-11 Thread Sergio Paracuellos
This chip support high level and low level interrupts. Those
have to be implemented also to get a complete and clean driver.

Signed-off-by: Sergio Paracuellos 
---
 drivers/staging/mt7621-gpio/gpio-mt7621.c | 47 ---
 1 file changed, 37 insertions(+), 10 deletions(-)

diff --git a/drivers/staging/mt7621-gpio/gpio-mt7621.c 
b/drivers/staging/mt7621-gpio/gpio-mt7621.c
index 54c18c1..0c344a5 100644
--- a/drivers/staging/mt7621-gpio/gpio-mt7621.c
+++ b/drivers/staging/mt7621-gpio/gpio-mt7621.c
@@ -38,6 +38,8 @@
  * @bank: gpio bank number for the chip
  * @rising: mask for rising irqs
  * @falling: mask for falling irqs
+ * @hlevel: mask for high level irqs
+ * @llevel: mask for low level irqs
  */
 struct mtk_gc {
struct gpio_chip chip;
@@ -45,6 +47,8 @@ struct mtk_gc {
int bank;
u32 rising;
u32 falling;
+   u32 hlevel;
+   u32 llevel;
 };
 
 /**
@@ -184,7 +188,7 @@ mediatek_gpio_irq_unmask(struct irq_data *d)
int bank = pin / MTK_BANK_WIDTH;
struct mtk_gc *rg = _data->gc_map[bank];
unsigned long flags;
-   u32 rise, fall;
+   u32 rise, fall, high, low;
 
if (!rg)
return;
@@ -192,8 +196,12 @@ mediatek_gpio_irq_unmask(struct irq_data *d)
spin_lock_irqsave(>lock, flags);
rise = mtk_gpio_r32(rg, GPIO_REG_REDGE);
fall = mtk_gpio_r32(rg, GPIO_REG_FEDGE);
+   high = mtk_gpio_r32(rg, GPIO_REG_HLVL);
+   low = mtk_gpio_r32(rg, GPIO_REG_LLVL);
mtk_gpio_w32(rg, GPIO_REG_REDGE, rise | (PIN_MASK(pin) & rg->rising));
mtk_gpio_w32(rg, GPIO_REG_FEDGE, fall | (PIN_MASK(pin) & rg->falling));
+   mtk_gpio_w32(rg, GPIO_REG_HLVL, high | (PIN_MASK(pin) & rg->hlevel));
+   mtk_gpio_w32(rg, GPIO_REG_LLVL, low | (PIN_MASK(pin) & rg->llevel));
spin_unlock_irqrestore(>lock, flags);
 }
 
@@ -205,7 +213,7 @@ mediatek_gpio_irq_mask(struct irq_data *d)
int bank = pin / MTK_BANK_WIDTH;
struct mtk_gc *rg = _data->gc_map[bank];
unsigned long flags;
-   u32 rise, fall;
+   u32 rise, fall, high, low;
 
if (!rg)
return;
@@ -213,8 +221,12 @@ mediatek_gpio_irq_mask(struct irq_data *d)
spin_lock_irqsave(>lock, flags);
rise = mtk_gpio_r32(rg, GPIO_REG_REDGE);
fall = mtk_gpio_r32(rg, GPIO_REG_FEDGE);
+   high = mtk_gpio_r32(rg, GPIO_REG_HLVL);
+   low = mtk_gpio_r32(rg, GPIO_REG_LLVL);
mtk_gpio_w32(rg, GPIO_REG_FEDGE, fall & ~PIN_MASK(pin));
mtk_gpio_w32(rg, GPIO_REG_REDGE, rise & ~PIN_MASK(pin));
+   mtk_gpio_w32(rg, GPIO_REG_HLVL, high & ~PIN_MASK(pin));
+   mtk_gpio_w32(rg, GPIO_REG_LLVL, low & ~PIN_MASK(pin));
spin_unlock_irqrestore(>lock, flags);
 }
 
@@ -231,21 +243,36 @@ mediatek_gpio_irq_type(struct irq_data *d, unsigned int 
type)
return -1;
 
if (type == IRQ_TYPE_PROBE) {
-   if ((rg->rising | rg->falling) & mask)
+   if ((rg->rising | rg->falling |
+rg->hlevel | rg->llevel) & mask)
return 0;
 
type = IRQ_TYPE_EDGE_RISING | IRQ_TYPE_EDGE_FALLING;
}
 
-   if (type & IRQ_TYPE_EDGE_RISING)
-   rg->rising |= mask;
-   else
-   rg->rising &= ~mask;
+   rg->rising &= ~mask;
+   rg->falling &= ~mask;
+   rg->hlevel &= ~mask;
+   rg->llevel &= ~mask;
 
-   if (type & IRQ_TYPE_EDGE_FALLING)
+   switch (type & IRQ_TYPE_SENSE_MASK) {
+   case IRQ_TYPE_EDGE_BOTH:
+   rg->rising |= mask;
rg->falling |= mask;
-   else
-   rg->falling &= ~mask;
+   break;
+   case IRQ_TYPE_EDGE_RISING:
+   rg->rising |= mask;
+   break;
+   case IRQ_TYPE_EDGE_FALLING:
+   rg->falling |= mask;
+   break;
+   case IRQ_TYPE_LEVEL_HIGH:
+   rg->hlevel |= mask;
+   break;
+   case IRQ_TYPE_LEVEL_LOW:
+   rg->llevel |= mask;
+   break;
+   }
 
return 0;
 }
-- 
2.7.4

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


[PATCH v3 6/8] staging: mt7621-gpio: add kerneldoc for state data containers

2018-06-11 Thread Sergio Paracuellos
This commit adds kerneldoc for the two data containers in
order to better understanding of its existence.

Signed-off-by: Sergio Paracuellos 
---
 drivers/staging/mt7621-gpio/gpio-mt7621.c | 18 ++
 1 file changed, 18 insertions(+)

diff --git a/drivers/staging/mt7621-gpio/gpio-mt7621.c 
b/drivers/staging/mt7621-gpio/gpio-mt7621.c
index e5a7979..54c18c1 100644
--- a/drivers/staging/mt7621-gpio/gpio-mt7621.c
+++ b/drivers/staging/mt7621-gpio/gpio-mt7621.c
@@ -31,6 +31,14 @@
 #define GPIO_REG_STAT  0x90
 #define GPIO_REG_EDGE  0xA0
 
+/**
+ * struct mtk_gc - data for a single gpio-chip
+ * @chip: gpio chip instance
+ * @lock: spinlock to protect the chip
+ * @bank: gpio bank number for the chip
+ * @rising: mask for rising irqs
+ * @falling: mask for falling irqs
+ */
 struct mtk_gc {
struct gpio_chip chip;
spinlock_t lock;
@@ -39,6 +47,16 @@ struct mtk_gc {
u32 falling;
 };
 
+/**
+ * struct mtk_data - state container for
+ * data of the platform driver. It is a
+ * single irq-chip but 3 separate gpio-chip.
+ * @dev: device instance
+ * @gpio_membase: memory base address
+ * @gpio_irq: irq number from the device tree
+ * @gpio_irq_domain: irq domain for this chip
+ * @gc_map: array of the gpio chips
+ */
 struct mtk_data {
struct device *dev;
void __iomem *gpio_membase;
-- 
2.7.4

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


[PATCH v3 8/8] staging: mt7621-gpio: avoid custom irq_domain for gpio

2018-06-11 Thread Sergio Paracuellos
Instead of create a custom irq_domain for this chip, use
'gpiochip_set_chained_irqchip' from GPIOLIB_IRQCHIP. It
is ok to call this function several times. We have to
manually mark the line with 'IRQF_SHARED' and then loop
over the three banks until you find a hit. There were
some problems with removing an irqchip like that but this
driver is a bool so it might work just fine. After this
changes the functions 'mediatek_gpio_to_irq' is not needed
anymore and also the 'gpio_irq_domain' field from the state
container. Instead of use the custom irq domain in the irq
handler use the associated domain from the gpio_chip in
'irq_find_mapping' function. Function 'mediatek_gpio_bank_probe'
has been moved a it to the botton to have all the irq related
functions together and avoid some forward declarations to resolve
some symbols along the code.

Signed-off-by: Sergio Paracuellos 
---
 drivers/staging/mt7621-gpio/Kconfig   |   1 +
 drivers/staging/mt7621-gpio/gpio-mt7621.c | 221 +++---
 2 files changed, 81 insertions(+), 141 deletions(-)

diff --git a/drivers/staging/mt7621-gpio/Kconfig 
b/drivers/staging/mt7621-gpio/Kconfig
index 835998a..e32facb 100644
--- a/drivers/staging/mt7621-gpio/Kconfig
+++ b/drivers/staging/mt7621-gpio/Kconfig
@@ -2,6 +2,7 @@ config GPIO_MT7621
bool "Mediatek GPIO Support"
depends on SOC_MT7620 || SOC_MT7621 || COMPILE_TEST
select GPIO_GENERIC
+   select GPIOLIB_IRQCHIP
select ARCH_REQUIRE_GPIOLIB
help
  Say yes here to support the Mediatek SoC GPIO device
diff --git a/drivers/staging/mt7621-gpio/gpio-mt7621.c 
b/drivers/staging/mt7621-gpio/gpio-mt7621.c
index 0c344a5..d2a7512 100644
--- a/drivers/staging/mt7621-gpio/gpio-mt7621.c
+++ b/drivers/staging/mt7621-gpio/gpio-mt7621.c
@@ -8,7 +8,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -58,14 +57,12 @@ struct mtk_gc {
  * @dev: device instance
  * @gpio_membase: memory base address
  * @gpio_irq: irq number from the device tree
- * @gpio_irq_domain: irq domain for this chip
  * @gc_map: array of the gpio chips
  */
 struct mtk_data {
struct device *dev;
void __iomem *gpio_membase;
int gpio_irq;
-   struct irq_domain *gpio_irq_domain;
struct mtk_gc gc_map[MTK_BANK_CNT];
 };
 
@@ -95,98 +92,36 @@ mtk_gpio_r32(struct mtk_gc *rg, u32 offset)
return gc->read_reg(gpio_data->gpio_membase + offset);
 }
 
-static int
-mediatek_gpio_to_irq(struct gpio_chip *chip, unsigned int pin)
-{
-   struct mtk_data *gpio_data = gpiochip_get_data(chip);
-   struct mtk_gc *rg = to_mediatek_gpio(chip);
-
-   return irq_create_mapping(gpio_data->gpio_irq_domain,
- pin + (rg->bank * MTK_BANK_WIDTH));
-}
-
-static int
-mediatek_gpio_bank_probe(struct platform_device *pdev, struct device_node 
*bank)
-{
-   struct mtk_data *gpio = dev_get_drvdata(>dev);
-   const __be32 *id = of_get_property(bank, "reg", NULL);
-   struct mtk_gc *rg;
-   void __iomem *dat, *set, *ctrl, *diro;
-   int ret;
-
-   if (!id || be32_to_cpu(*id) >= MTK_BANK_CNT)
-   return -EINVAL;
-
-   rg = >gc_map[be32_to_cpu(*id)];
-   memset(rg, 0, sizeof(*rg));
-
-   spin_lock_init(>lock);
-   rg->chip.of_node = bank;
-   rg->bank = be32_to_cpu(*id);
-
-   dat = gpio->gpio_membase + GPIO_REG_DATA + (rg->bank * GPIO_BANK_WIDE);
-   set = gpio->gpio_membase + GPIO_REG_DSET + (rg->bank * GPIO_BANK_WIDE);
-   ctrl = gpio->gpio_membase + GPIO_REG_DCLR + (rg->bank * GPIO_BANK_WIDE);
-   diro = gpio->gpio_membase + GPIO_REG_CTRL + (rg->bank * GPIO_BANK_WIDE);
-
-   ret = bgpio_init(>chip, >dev, 4,
-dat, set, ctrl, diro, NULL, 0);
-   if (ret) {
-   dev_err(>dev, "bgpio_init() failed\n");
-   return ret;
-   }
-
-   if (gpio->gpio_irq_domain)
-   rg->chip.to_irq = mediatek_gpio_to_irq;
-
-   ret = devm_gpiochip_add_data(>dev, >chip, gpio);
-   if (ret < 0) {
-   dev_err(>dev, "Could not register gpio %d, ret=%d\n",
-   rg->chip.ngpio, ret);
-   return ret;
-   }
-
-   /* set polarity to low for all gpios */
-   mtk_gpio_w32(rg, GPIO_REG_POL, 0);
-
-   dev_info(>dev, "registering %d gpios\n", rg->chip.ngpio);
-
-   return 0;
-}
-
-static void
-mediatek_gpio_irq_handler(struct irq_desc *desc)
+static irqreturn_t
+mediatek_gpio_irq_handler(int irq, void *data)
 {
-   struct mtk_data *gpio_data = irq_desc_get_handler_data(desc);
-   int i;
-
-   for (i = 0; i < MTK_BANK_CNT; i++) {
-   struct mtk_gc *rg = _data->gc_map[i];
-   unsigned long pending;
-   int bit;
-
-   if (!rg)
-   continue;
+   struct gpio_chip *gc = data;
+   struct mtk_gc *rg = to_mediatek_gpio(gc);
+   irqreturn_t ret = IRQ_NONE;
+   

[PATCH v3 4/8] staging: mt7621-gpio: implement '.irq_[request|release]_resources' functions

2018-06-11 Thread Sergio Paracuellos
When implementing custom irqchips it is important to also
implement .irq_request_resources() and .irq_release_resources()
and make sure these call gpiochip_[un]lock_as_irq().
Add those two for this driver. Also store struct device pointer
in global state structure to be able to use 'dev_err' with the
device from 'mediatek_request_resources' function.

Signed-off-by: Sergio Paracuellos 
---
 drivers/staging/mt7621-gpio/gpio-mt7621.c | 42 +++
 1 file changed, 37 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/mt7621-gpio/gpio-mt7621.c 
b/drivers/staging/mt7621-gpio/gpio-mt7621.c
index 6a31f60..e5a7979 100644
--- a/drivers/staging/mt7621-gpio/gpio-mt7621.c
+++ b/drivers/staging/mt7621-gpio/gpio-mt7621.c
@@ -40,6 +40,7 @@ struct mtk_gc {
 };
 
 struct mtk_data {
+   struct device *dev;
void __iomem *gpio_membase;
int gpio_irq;
struct irq_domain *gpio_irq_domain;
@@ -231,12 +232,42 @@ mediatek_gpio_irq_type(struct irq_data *d, unsigned int 
type)
return 0;
 }
 
+static int mediatek_irq_reqres(struct irq_data *d)
+{
+   struct mtk_data *gpio_data = irq_data_get_irq_chip_data(d);
+   int bank = irqd_to_hwirq(d) / MTK_BANK_WIDTH;
+   struct mtk_gc *rg = _data->gc_map[bank];
+   struct gpio_chip *gc = >chip;
+   int ret;
+
+   ret = gpiochip_lock_as_irq(gc, irqd_to_hwirq(d));
+   if (ret) {
+   dev_err(gpio_data->dev, "unable to lock HW IRQ %lu for IRQ\n",
+   irqd_to_hwirq(d));
+   return -EINVAL;
+   }
+
+   return 0;
+}
+
+static void mediatek_irq_relres(struct irq_data *d)
+{
+   struct mtk_data *gpio_data = irq_data_get_irq_chip_data(d);
+   int bank = irqd_to_hwirq(d) / MTK_BANK_WIDTH;
+   struct mtk_gc *rg = _data->gc_map[bank];
+   struct gpio_chip *gc = >chip;
+
+   gpiochip_unlock_as_irq(gc, irqd_to_hwirq(d));
+}
+
 static struct irq_chip mediatek_gpio_irq_chip = {
-   .name   = "GPIO",
-   .irq_unmask = mediatek_gpio_irq_unmask,
-   .irq_mask   = mediatek_gpio_irq_mask,
-   .irq_mask_ack   = mediatek_gpio_irq_mask,
-   .irq_set_type   = mediatek_gpio_irq_type,
+   .name   = "GPIO",
+   .irq_unmask = mediatek_gpio_irq_unmask,
+   .irq_mask   = mediatek_gpio_irq_mask,
+   .irq_mask_ack   = mediatek_gpio_irq_mask,
+   .irq_set_type   = mediatek_gpio_irq_type,
+   .irq_request_resources  = mediatek_irq_reqres,
+   .irq_release_resources  = mediatek_irq_relres,
 };
 
 static int
@@ -284,6 +315,7 @@ mediatek_gpio_probe(struct platform_device *pdev)
dev_err(>dev, "irq_domain_add_linear failed\n");
}
 
+   gpio_data->dev = >dev;
platform_set_drvdata(pdev, gpio_data);
 
for_each_child_of_node(np, bank)
-- 
2.7.4

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


[PATCH v3 5/8] staging: mt7621-gpio: add COMPILE_TEST

2018-06-11 Thread Sergio Paracuellos
This driver is actually platform-agnostic.  Add COMPILE_TEST for
the compilation test coverage.

Signed-off-by: Sergio Paracuellos 
---
 drivers/staging/mt7621-gpio/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/mt7621-gpio/Kconfig 
b/drivers/staging/mt7621-gpio/Kconfig
index f4453e8..835998a 100644
--- a/drivers/staging/mt7621-gpio/Kconfig
+++ b/drivers/staging/mt7621-gpio/Kconfig
@@ -1,6 +1,6 @@
 config GPIO_MT7621
bool "Mediatek GPIO Support"
-   depends on SOC_MT7620 || SOC_MT7621
+   depends on SOC_MT7620 || SOC_MT7621 || COMPILE_TEST
select GPIO_GENERIC
select ARCH_REQUIRE_GPIOLIB
help
-- 
2.7.4

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


[PATCH v3 3/8] staging: mt7621-gpio: make use of 'builtin_platform_driver'

2018-06-11 Thread Sergio Paracuellos
This driver was being registered using 'module_platform_driver'
but it is not a module at all. Instead of this use
'builtin_platform_driver' which seems to be the correct one.

Signed-off-by: Sergio Paracuellos 
---
 drivers/staging/mt7621-gpio/gpio-mt7621.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/mt7621-gpio/gpio-mt7621.c 
b/drivers/staging/mt7621-gpio/gpio-mt7621.c
index f95310c..6a31f60 100644
--- a/drivers/staging/mt7621-gpio/gpio-mt7621.c
+++ b/drivers/staging/mt7621-gpio/gpio-mt7621.c
@@ -312,4 +312,4 @@ static struct platform_driver mediatek_gpio_driver = {
},
 };
 
-module_platform_driver(mediatek_gpio_driver);
+builtin_platform_driver(mediatek_gpio_driver);
-- 
2.7.4

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


[PATCH v3 2/8] staging: mt7621-gpio: avoid including 'gpio.h'

2018-06-11 Thread Sergio Paracuellos
Including file '' should be avoided in
new drivers code, so just remove it because it is
no necessary at all.

Signed-off-by: Sergio Paracuellos 
---
 drivers/staging/mt7621-gpio/gpio-mt7621.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/staging/mt7621-gpio/gpio-mt7621.c 
b/drivers/staging/mt7621-gpio/gpio-mt7621.c
index eb60dd4..f95310c 100644
--- a/drivers/staging/mt7621-gpio/gpio-mt7621.c
+++ b/drivers/staging/mt7621-gpio/gpio-mt7621.c
@@ -5,7 +5,6 @@
  */
 
 #include 
-#include 
 #include 
 #include 
 #include 
-- 
2.7.4

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


[PATCH v3 1/8] staging: mt7621-gpio: make use 'bgpio_init' from GPIO_GENERIC

2018-06-11 Thread Sergio Paracuellos
Gpio complexity is just masking the fact that offset is always
0..n and writes to bits 0..n of some memory address. Because
of this whole thing can just me converted to use GPIO_GENERIC
and avoid duplications of a lot of driver custom functions.
So use bgpio_init instead of custom code adding GPIO_GENERIC
dependency to the Kconfig file. Also to make easier using
bgpio_init function offset for each gpio bank, enumeration
where register were defined has been replaced in favour of
some macros which handle each gpio offset taking into account
the bank where are located. Because of this change write and
read functions which are being used for remaining irq handling
stuff have been updated also as well as its dependencies along
the code.

Signed-off-by: Sergio Paracuellos 
---
 drivers/staging/mt7621-gpio/Kconfig   |   1 +
 drivers/staging/mt7621-gpio/gpio-mt7621.c | 136 +-
 2 files changed, 42 insertions(+), 95 deletions(-)

diff --git a/drivers/staging/mt7621-gpio/Kconfig 
b/drivers/staging/mt7621-gpio/Kconfig
index c741ec3..f4453e8 100644
--- a/drivers/staging/mt7621-gpio/Kconfig
+++ b/drivers/staging/mt7621-gpio/Kconfig
@@ -1,6 +1,7 @@
 config GPIO_MT7621
bool "Mediatek GPIO Support"
depends on SOC_MT7620 || SOC_MT7621
+   select GPIO_GENERIC
select ARCH_REQUIRE_GPIOLIB
help
  Say yes here to support the Mediatek SoC GPIO device
diff --git a/drivers/staging/mt7621-gpio/gpio-mt7621.c 
b/drivers/staging/mt7621-gpio/gpio-mt7621.c
index 0c4fb4a..eb60dd4 100644
--- a/drivers/staging/mt7621-gpio/gpio-mt7621.c
+++ b/drivers/staging/mt7621-gpio/gpio-mt7621.c
@@ -19,19 +19,18 @@
 #define MTK_BANK_WIDTH 32
 #define PIN_MASK(nr)   (1UL << ((nr % MTK_BANK_WIDTH)))
 
-enum mediatek_gpio_reg {
-   GPIO_REG_CTRL = 0,
-   GPIO_REG_POL,
-   GPIO_REG_DATA,
-   GPIO_REG_DSET,
-   GPIO_REG_DCLR,
-   GPIO_REG_REDGE,
-   GPIO_REG_FEDGE,
-   GPIO_REG_HLVL,
-   GPIO_REG_LLVL,
-   GPIO_REG_STAT,
-   GPIO_REG_EDGE,
-};
+#define GPIO_BANK_WIDE 0x04
+#define GPIO_REG_CTRL  0x00
+#define GPIO_REG_POL   0x10
+#define GPIO_REG_DATA  0x20
+#define GPIO_REG_DSET  0x30
+#define GPIO_REG_DCLR  0x40
+#define GPIO_REG_REDGE 0x50
+#define GPIO_REG_FEDGE 0x60
+#define GPIO_REG_HLVL  0x70
+#define GPIO_REG_LLVL  0x80
+#define GPIO_REG_STAT  0x90
+#define GPIO_REG_EDGE  0xA0
 
 struct mtk_gc {
struct gpio_chip chip;
@@ -55,80 +54,23 @@ to_mediatek_gpio(struct gpio_chip *chip)
 }
 
 static inline void
-mtk_gpio_w32(struct mtk_gc *rg, u8 reg, u32 val)
+mtk_gpio_w32(struct mtk_gc *rg, u32 offset, u32 val)
 {
-   struct mtk_data *gpio_data = gpiochip_get_data(>chip);
-   u32 offset = (reg * 0x10) + (rg->bank * 0x4);
+   struct gpio_chip *gc = >chip;
+   struct mtk_data *gpio_data = gpiochip_get_data(gc);
 
-   iowrite32(val, gpio_data->gpio_membase + offset);
+   offset = (rg->bank * GPIO_BANK_WIDE) + offset;
+   gc->write_reg(gpio_data->gpio_membase + offset, val);
 }
 
 static inline u32
-mtk_gpio_r32(struct mtk_gc *rg, u8 reg)
-{
-   struct mtk_data *gpio_data = gpiochip_get_data(>chip);
-   u32 offset = (reg * 0x10) + (rg->bank * 0x4);
-
-   return ioread32(gpio_data->gpio_membase + offset);
-}
-
-static void
-mediatek_gpio_set(struct gpio_chip *chip, unsigned int offset, int value)
-{
-   struct mtk_gc *rg = to_mediatek_gpio(chip);
-
-   mtk_gpio_w32(rg, (value) ? GPIO_REG_DSET : GPIO_REG_DCLR, BIT(offset));
-}
-
-static int
-mediatek_gpio_get(struct gpio_chip *chip, unsigned int offset)
-{
-   struct mtk_gc *rg = to_mediatek_gpio(chip);
-
-   return !!(mtk_gpio_r32(rg, GPIO_REG_DATA) & BIT(offset));
-}
-
-static int
-mediatek_gpio_direction_input(struct gpio_chip *chip, unsigned int offset)
-{
-   struct mtk_gc *rg = to_mediatek_gpio(chip);
-   unsigned long flags;
-   u32 t;
-
-   spin_lock_irqsave(>lock, flags);
-   t = mtk_gpio_r32(rg, GPIO_REG_CTRL);
-   t &= ~BIT(offset);
-   mtk_gpio_w32(rg, GPIO_REG_CTRL, t);
-   spin_unlock_irqrestore(>lock, flags);
-
-   return 0;
-}
-
-static int
-mediatek_gpio_direction_output(struct gpio_chip *chip,
-   unsigned int offset, int value)
+mtk_gpio_r32(struct mtk_gc *rg, u32 offset)
 {
-   struct mtk_gc *rg = to_mediatek_gpio(chip);
-   unsigned long flags;
-   u32 t;
+   struct gpio_chip *gc = >chip;
+   struct mtk_data *gpio_data = gpiochip_get_data(gc);
 
-   spin_lock_irqsave(>lock, flags);
-   t = mtk_gpio_r32(rg, GPIO_REG_CTRL);
-   t |= BIT(offset);
-   mtk_gpio_w32(rg, GPIO_REG_CTRL, t);
-   mediatek_gpio_set(chip, offset, value);
-   spin_unlock_irqrestore(>lock, flags);
-
-   return 0;
-}
-
-static int
-mediatek_gpio_get_direction(struct gpio_chip *chip, unsigned int offset)
-{
-   struct mtk_gc *rg = to_mediatek_gpio(chip);
-   u32 t = mtk_gpio_r32(rg, GPIO_REG_CTRL);
-
- 

[PATCH v3 0/8] staging: mt7621-gpio: last cleanups

2018-06-11 Thread Sergio Paracuellos
After submiting this driver to try to get mainlined and get
out of staging some new cleanups seems to be necessary.
According to this main of Linus Walleij:

http://driverdev.linuxdriverproject.org/pipermail/driverdev-devel/2018-June/121742.html

this series tries to fix all of the issues in order to send
v2 and give it a new try. Because I don't have to hardware to
test my changes I send new cleanups first in staging to make
easier to NeilBrown test it and get a feedback about them.

Changes in v3:
- PATCH 7: refactor irq_type to make better code.
- Add PATCH 8 avoiding the use of custom domain and requesting
  manually a 'IRQF_SHARED'. It should be working now??

Changes in v2:
- Patch where GPIOLIB_IRQCHIP was used avoiding
  the use of a custom irq domain has been dropped to
  be sure after this changes all is working properly.
  (This was PATCH 7 in previous series)
- PATCH 1:
 * avoid introducing new macros and use 'bank'
   field of mtk_gc with register offset.
 * Make correct use of bgpio_init passing new
   void __iomem pointers instead of use the
   macros.
- Previous series PATCH 8 now is PATCH 7. Avoid the
  use of a switch-case statement which was wrong and
  distinc if we have RISSING AND FALLING EDGE interrupt
  or HIGH LOW level ones. This last two are exclusive and
  cannot be generated at the same time.

Hope this helps.

Thanks in advance.

Best regards,
Sergio Paracuellos

Sergio Paracuellos (8):
  staging: mt7621-gpio: make use 'bgpio_init' from GPIO_GENERIC
  staging: mt7621-gpio: avoid including 'gpio.h'
  staging: mt7621-gpio: make use of 'builtin_platform_driver'
  staging: mt7621-gpio: implement '.irq_[request|release]_resources'
functions
  staging: mt7621-gpio: add COMPILE_TEST
  staging: mt7621-gpio: add kerneldoc for state data containers
  staging: mt7621-gpio: implement high level and low level irqs
  staging: mt7621-gpio: avoid custom irq_domain for gpio

 drivers/staging/mt7621-gpio/Kconfig   |   4 +-
 drivers/staging/mt7621-gpio/gpio-mt7621.c | 369 +-
 2 files changed, 168 insertions(+), 205 deletions(-)

-- 
2.7.4

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


[PATCH V2 2/4] Staging:rtl8192e Fix Comparison to False is error prone

2018-06-11 Thread Janani Sankara Babu
This patch removes comparison to False and boolean in the code
which can be written as !var

Signed-off-by: Janani Sankara Babu 
---
changelog
v2 : remove comparison to 0 , replacing with !var
v1 : remove comparison to false

 drivers/staging/rtl8192e/rtl819x_BAProc.c | 16 
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/staging/rtl8192e/rtl819x_BAProc.c 
b/drivers/staging/rtl8192e/rtl819x_BAProc.c
index c466a5e7..f194705 100644
--- a/drivers/staging/rtl8192e/rtl819x_BAProc.c
+++ b/drivers/staging/rtl8192e/rtl819x_BAProc.c
@@ -257,8 +257,8 @@ int rtllib_rx_ADDBAReq(struct rtllib_device *ieee, struct 
sk_buff *skb)
pBaStartSeqCtrl = (union sequence_control *)(req + 7);

RT_TRACE(COMP_DBG, ">rx ADDBAREQ from : %pM\n", dst);
-   if (ieee->current_network.qos_data.active == 0  ||
-   (ieee->pHTInfo->bCurrentHTSupport == false) ||
+   if (!ieee->current_network.qos_data.active ||
+   !ieee->pHTInfo->bCurrentHTSupport ||
(ieee->pHTInfo->IOTAction & HT_IOT_ACT_REJECT_ADDBA_REQ)) {
rc = ADDBA_STATUS_REFUSED;
netdev_warn(ieee->dev,
@@ -340,9 +340,9 @@ int rtllib_rx_ADDBARsp(struct rtllib_device *ieee, struct 
sk_buff *skb)
pBaTimeoutVal = (u16 *)(tag + 7);

RT_TRACE(COMP_DBG, ">rx ADDBARSP from : %pM\n", dst);
-   if (ieee->current_network.qos_data.active == 0  ||
-   ieee->pHTInfo->bCurrentHTSupport == false ||
-   ieee->pHTInfo->bCurrentAMPDUEnable == false) {
+   if (!ieee->current_network.qos_data.active ||
+   !ieee->pHTInfo->bCurrentHTSupport ||
+   !ieee->pHTInfo->bCurrentAMPDUEnable) {
netdev_warn(ieee->dev,
"reject to ADDBA_RSP as some capability is not 
ready(%d, %d, %d)\n",
ieee->current_network.qos_data.active,
@@ -369,7 +369,7 @@ int rtllib_rx_ADDBARsp(struct rtllib_device *ieee, struct 
sk_buff *skb)
netdev_dbg(ieee->dev, "%s(): ADDBA response already admitted\n",
   __func__);
return -1;
-   } else if ((pPendingBA->bValid == false) ||
+   } else if (!pPendingBA->bValid ||
   (*pDialogToken != pPendingBA->DialogToken)) {
netdev_warn(ieee->dev,
"%s(): ADDBA Rsp. BA invalid, DELBA!\n",
@@ -431,8 +431,8 @@ int rtllib_rx_DELBA(struct rtllib_device *ieee, struct 
sk_buff *skb)
return -1;
}

-   if (ieee->current_network.qos_data.active == 0  ||
-   ieee->pHTInfo->bCurrentHTSupport == false) {
+   if (!ieee->current_network.qos_data.active ||
+   !ieee->pHTInfo->bCurrentHTSupport) {
netdev_warn(ieee->dev,
"received DELBA while QOS or HT is not 
supported(%d, %d)\n",
ieee->current_network. qos_data.active,
--
1.9.1

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


Re: [PATCH v2 0/7] staging: mt7621-gpio: last cleanups

2018-06-11 Thread NeilBrown
On Mon, Jun 11 2018, Sergio Paracuellos wrote:

> After submiting this driver to try to get mainlined and get
> out of staging some new cleanups seems to be necessary.
> According to this main of Linus Walleij:
>
> http://driverdev.linuxdriverproject.org/pipermail/driverdev-devel/2018-June/121742.html
>
> this series tries to fix all of the issues in order to send
> v2 and give it a new try. Because I don't have to hardware to
> test my changes I send new cleanups first in staging to make
> easier to NeilBrown test it and get a feedback about them.
>
> Changes in v2:
> - Patch where GPIOLIB_IRQCHIP was used avoiding
>   the use of a custom irq domain has been dropped to
>   be sure after this changes all is working properly.
>   (This was PATCH 7 in previous series)
> - PATCH 1: 
>  * avoid introducing new macros and use 'bank'
>field of mtk_gc with register offset.
>  * Make correct use of bgpio_init passing new
>void __iomem pointers instead of use the
>macros. 
> - Previous series PATCH 8 now is PATCH 7. Avoid the
>   use of a switch-case statement which was wrong and
>   distinc if we have RISSING AND FALLING EDGE interrupt
>   or HIGH LOW level ones. This last two are exclusive and
>   cannot be generated at the same time.
>
> Also, I think is we finally avoid to use a new irq_domain the
> need for the new functions introduced for request and release
> resources dissapears. I was diving down the other drivers code
> and I see that these two only are used in drivers which use its
> own irq_domain. Correct me if I am wrong, please.
>
> Hope this helps.
>
> Thanks in advance.

Thanks a lot.
This series appears to work, though I sent a separate comment on one
piece of code.
However the gpio are numbers
480-511
448-479
416-447

instead of
0-31
32-63
64-95

which would be more normal.
Maybe when you resubmit I'll raid it with Linus Walleij and see if he
can explain why I can't have 0-95.

Thanks,
NeilBrown


>
> Best regards,
> Sergio Paracuellos
>
> Sergio Paracuellos (7):
>   staging: mt7621-gpio: make use 'bgpio_init' from GPIO_GENERIC
>   staging: mt7621-gpio: avoid including 'gpio.h'
>   staging: mt7621-gpio: make use of 'builtin_platform_driver'
>   staging: mt7621-gpio: implement '.irq_[request|release]_resources'
> functions
>   staging: mt7621-gpio: add COMPILE_TEST
>   staging: mt7621-gpio: add kerneldoc for state data containers
>   staging: mt7621-gpio: implement high level and low level irqs
>
>  drivers/staging/mt7621-gpio/Kconfig   |   3 +-
>  drivers/staging/mt7621-gpio/gpio-mt7621.c | 251 
> --
>  2 files changed, 138 insertions(+), 116 deletions(-)
>
> -- 
> 2.7.4


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


[PATCH] staging: rtl8192u: add error handling for usb_alloc_urb

2018-06-11 Thread Zhouyang Jia
When usb_alloc_urb fails, the lack of error-handling code may
cause unexpected results.

This patch adds error-handling code after calling usb_alloc_urb.

Signed-off-by: Zhouyang Jia 
---
 drivers/staging/rtl8192u/r8192U_core.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/staging/rtl8192u/r8192U_core.c 
b/drivers/staging/rtl8192u/r8192U_core.c
index 7a0dbc0..3f09615 100644
--- a/drivers/staging/rtl8192u/r8192U_core.c
+++ b/drivers/staging/rtl8192u/r8192U_core.c
@@ -1666,6 +1666,9 @@ static short rtl8192_usb_initendpoints(struct net_device 
*dev)
void *oldaddr, *newaddr;
 
priv->rx_urb[16] = usb_alloc_urb(0, GFP_KERNEL);
+   if (!priv->rx_urb[16])
+   return -ENOMEM;
+
priv->oldaddr = kmalloc(16, GFP_KERNEL);
if (!priv->oldaddr)
return -ENOMEM;
-- 
2.7.4

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


Re: [PATCH] MAINTAINERS: update two greybus sections

2018-06-11 Thread Viresh Kumar
On 11-06-18, 09:42, Johan Hovold wrote:
> Fix a file entry typo and drop the obsolete timesync entries, which were
> all caught by:
> 
>   scripts/get_maintainer.pl --self-test=patterns
> 
> Reported-by: Joe Perches 
> Signed-off-by: Johan Hovold 
> ---
> 
> This has been reported and at least partially fixed in the past, but due
> to various other clean-up work that was going on in MAINTAINERS at the
> time, was never applied.
> 
> Johan
> 
> 
>  MAINTAINERS | 6 ++
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/MAINTAINERS b/MAINTAINERS
> index 9c125f705f78..09d7f9eb5c13 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -6065,7 +6065,7 @@ F:  drivers/staging/greybus/bootrom.c
>  F:   drivers/staging/greybus/firmware.h
>  F:   drivers/staging/greybus/fw-core.c
>  F:   drivers/staging/greybus/fw-download.c
> -F:   drivers/staging/greybus/fw-managament.c
> +F:   drivers/staging/greybus/fw-management.c
>  F:   drivers/staging/greybus/greybus_authentication.h
>  F:   drivers/staging/greybus/greybus_firmware.h
>  F:   drivers/staging/greybus/hid.c
> @@ -6074,12 +6074,10 @@ F:drivers/staging/greybus/spi.c
>  F:   drivers/staging/greybus/spilib.c
>  F:   drivers/staging/greybus/spilib.h
>  
> -GREYBUS LOOPBACK/TIME PROTOCOLS DRIVERS
> +GREYBUS LOOPBACK DRIVER
>  M:   Bryan O'Donoghue 
>  S:   Maintained
>  F:   drivers/staging/greybus/loopback.c
> -F:   drivers/staging/greybus/timesync.c
> -F:   drivers/staging/greybus/timesync_platform.c
>  
>  GREYBUS PLATFORM DRIVERS
>  M:   Vaibhav Hiremath 

Acked-by: Viresh Kumar 

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


Re: [PATCH v2] staging: mt7621-gpio: avoid custom irq_domain for gpio

2018-06-11 Thread NeilBrown
On Mon, Jun 11 2018, Sergio Paracuellos wrote:

> Instead of create a custom irq_domain for this chip, use
> 'gpiochip_set_chained_irqchip' from GPIOLIB_IRQCHIP. It
> is ok to call this function several times. You only have to
> mark the line with 'IRQF_SHARED' and then loop over the
> three banks until you find a hit. There were some problems
> with removing an irqchip like that but this driver is a bool
> so it might work just fine. After this changes the functions
> 'mediatek_gpio_to_irq' is not needed anymore and also the
> 'gpio_irq_domain' field from the state container. Instead of
> use the custom irq domain in the irq handler use the associated
> domain from the gpio_chip in 'irq_find_mapping' function.
> Function 'mediatek_gpio_bank_probe' has been moved a it to the
> botton to have all the irq related functions together and avoid
> some forward declarations to resolve some symbols along the code.
>
> Signed-off-by: Sergio Paracuellos 

Thanks for this.
The patch has two problems.
1/ it doesn't compile unless CONFIG_GPIOLIB_IRQCHIP is selected.
  So we need "select GPIOLIB_IRQCHIP" in Kconfig

2/ The interrupt line has not been marked IRQF_SHARED.
 I cannot figure out how to mark it as IRQF_SHARED.
 If I hack the code so that mediatek_gpio_bank_probe()
 is only called for the first bank, then interrupt from
 that bank work fine.
 If I let it be called for all three banks, then on the first interrupt,
 the system starts to hang.

Thanks,
NeilBrown


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


Re: [PATCH] staging:iio:accel: use sign extend function avoiding code duplication

2018-06-11 Thread Joe Perches
On Mon, 2018-06-11 at 00:09 +0200, Karim Eshapa wrote:
> Use sign_extend32 kernel function instead of code duplication.
> This function is also safe for 16 bits.

Firstly:

This file is not in staging anymore.
Please use the -next tree for patches.

> diff --git a/drivers/staging/iio/accel/adis16201.c 
> b/drivers/staging/iio/accel/adis16201.c
[]
> @@ -227,9 +227,7 @@ static int adis16201_read_raw(struct iio_dev *indio_dev,
>   ret = adis_read_reg_16(st, addr, );
>   if (ret)
>   return ret;
> - val16 &= (1 << bits) - 1;
> - val16 = (s16)(val16 << (16 - bits)) >> (16 - bits);
> - *val = val16;
> + *val = sign_extend32(val16, bits);
>   return IIO_VAL_INT;
>   }

Secondly:

A similar patch with a different bits value was
already applied.

Please verify the appropriate bits value.

commit e7f3bfb7eb7d9307c0c157f82fceb228f0aec1d9
Author: Himanshu Jha 
Date:   Sat Mar 17 01:36:23 2018 +0530

Staging: iio: accel: adis16201: Use sign_extend32 function

Use sign_extned32() for 32 bit sign extending rather than hard coding.

Signed-off-by: Himanshu Jha 
Signed-off-by: Jonathan Cameron 
---
 drivers/staging/iio/accel/adis16201.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/iio/accel/adis16201.c 
b/drivers/staging/iio/accel/adis16201.c
index 87ad3d421c12..526dde481f84 100644
--- a/drivers/staging/iio/accel/adis16201.c
+++ b/drivers/staging/iio/accel/adis16201.c
@@ -173,9 +173,8 @@ static int adis16201_read_raw(struct iio_dev *indio_dev,
ret = adis_read_reg_16(st, addr, );
if (ret)
return ret;
-   val16 &= (1 << bits) - 1;
-   val16 = (s16)(val16 << (16 - bits)) >> (16 - bits);
-   *val = val16;
+
+   *val = sign_extend32(val16, bits - 1);
return IIO_VAL_INT;
}
 
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] MAINTAINERS: update two greybus sections

2018-06-11 Thread Johan Hovold
Fix a file entry typo and drop the obsolete timesync entries, which were
all caught by:

scripts/get_maintainer.pl --self-test=patterns

Reported-by: Joe Perches 
Signed-off-by: Johan Hovold 
---

This has been reported and at least partially fixed in the past, but due
to various other clean-up work that was going on in MAINTAINERS at the
time, was never applied.

Johan


 MAINTAINERS | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/MAINTAINERS b/MAINTAINERS
index 9c125f705f78..09d7f9eb5c13 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -6065,7 +6065,7 @@ F:drivers/staging/greybus/bootrom.c
 F: drivers/staging/greybus/firmware.h
 F: drivers/staging/greybus/fw-core.c
 F: drivers/staging/greybus/fw-download.c
-F: drivers/staging/greybus/fw-managament.c
+F: drivers/staging/greybus/fw-management.c
 F: drivers/staging/greybus/greybus_authentication.h
 F: drivers/staging/greybus/greybus_firmware.h
 F: drivers/staging/greybus/hid.c
@@ -6074,12 +6074,10 @@ F:  drivers/staging/greybus/spi.c
 F: drivers/staging/greybus/spilib.c
 F: drivers/staging/greybus/spilib.h
 
-GREYBUS LOOPBACK/TIME PROTOCOLS DRIVERS
+GREYBUS LOOPBACK DRIVER
 M: Bryan O'Donoghue 
 S: Maintained
 F: drivers/staging/greybus/loopback.c
-F: drivers/staging/greybus/timesync.c
-F: drivers/staging/greybus/timesync_platform.c
 
 GREYBUS PLATFORM DRIVERS
 M: Vaibhav Hiremath 
-- 
2.17.1

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


Re: [PATCH v2 7/7] staging: mt7621-gpio: implement high level and low level irqs

2018-06-11 Thread NeilBrown
On Mon, Jun 11 2018, Sergio Paracuellos wrote:

> This chip support high level and low level interrupts. Those
> have to be implemented also to get a complete and clean driver.
>
> Signed-off-by: Sergio Paracuellos 
> ---
>  drivers/staging/mt7621-gpio/gpio-mt7621.c | 51 
> +++
>  1 file changed, 38 insertions(+), 13 deletions(-)
>
> diff --git a/drivers/staging/mt7621-gpio/gpio-mt7621.c 
> b/drivers/staging/mt7621-gpio/gpio-mt7621.c
> index 54c18c1..39874cb 100644
> --- a/drivers/staging/mt7621-gpio/gpio-mt7621.c
> +++ b/drivers/staging/mt7621-gpio/gpio-mt7621.c
> @@ -38,6 +38,8 @@
>   * @bank: gpio bank number for the chip
>   * @rising: mask for rising irqs
>   * @falling: mask for falling irqs
> + * @hlevel: mask for high level irqs
> + * @llevel: mask for low level irqs
>   */
>  struct mtk_gc {
>   struct gpio_chip chip;
> @@ -45,6 +47,8 @@ struct mtk_gc {
>   int bank;
>   u32 rising;
>   u32 falling;
> + u32 hlevel;
> + u32 llevel;
>  };
>  
>  /**
> @@ -184,7 +188,7 @@ mediatek_gpio_irq_unmask(struct irq_data *d)
>   int bank = pin / MTK_BANK_WIDTH;
>   struct mtk_gc *rg = _data->gc_map[bank];
>   unsigned long flags;
> - u32 rise, fall;
> + u32 rise, fall, high, low;
>  
>   if (!rg)
>   return;
> @@ -192,8 +196,12 @@ mediatek_gpio_irq_unmask(struct irq_data *d)
>   spin_lock_irqsave(>lock, flags);
>   rise = mtk_gpio_r32(rg, GPIO_REG_REDGE);
>   fall = mtk_gpio_r32(rg, GPIO_REG_FEDGE);
> + high = mtk_gpio_r32(rg, GPIO_REG_HLVL);
> + low = mtk_gpio_r32(rg, GPIO_REG_LLVL);
>   mtk_gpio_w32(rg, GPIO_REG_REDGE, rise | (PIN_MASK(pin) & rg->rising));
>   mtk_gpio_w32(rg, GPIO_REG_FEDGE, fall | (PIN_MASK(pin) & rg->falling));
> + mtk_gpio_w32(rg, GPIO_REG_HLVL, high | (PIN_MASK(pin) & rg->hlevel));
> + mtk_gpio_w32(rg, GPIO_REG_LLVL, low | (PIN_MASK(pin) & rg->llevel));
>   spin_unlock_irqrestore(>lock, flags);
>  }
>  
> @@ -205,7 +213,7 @@ mediatek_gpio_irq_mask(struct irq_data *d)
>   int bank = pin / MTK_BANK_WIDTH;
>   struct mtk_gc *rg = _data->gc_map[bank];
>   unsigned long flags;
> - u32 rise, fall;
> + u32 rise, fall, high, low;
>  
>   if (!rg)
>   return;
> @@ -213,8 +221,12 @@ mediatek_gpio_irq_mask(struct irq_data *d)
>   spin_lock_irqsave(>lock, flags);
>   rise = mtk_gpio_r32(rg, GPIO_REG_REDGE);
>   fall = mtk_gpio_r32(rg, GPIO_REG_FEDGE);
> + high = mtk_gpio_r32(rg, GPIO_REG_HLVL);
> + low = mtk_gpio_r32(rg, GPIO_REG_LLVL);
>   mtk_gpio_w32(rg, GPIO_REG_FEDGE, fall & ~PIN_MASK(pin));
>   mtk_gpio_w32(rg, GPIO_REG_REDGE, rise & ~PIN_MASK(pin));
> + mtk_gpio_w32(rg, GPIO_REG_HLVL, high & ~PIN_MASK(pin));
> + mtk_gpio_w32(rg, GPIO_REG_LLVL, low & ~PIN_MASK(pin));
>   spin_unlock_irqrestore(>lock, flags);
>  }
>  
> @@ -231,21 +243,34 @@ mediatek_gpio_irq_type(struct irq_data *d, unsigned int 
> type)
>   return -1;
>  
>   if (type == IRQ_TYPE_PROBE) {
> - if ((rg->rising | rg->falling) & mask)
> + if ((rg->rising | rg->falling |
> +  rg->hlevel | rg->llevel) & mask)
>   return 0;
>  
> - type = IRQ_TYPE_EDGE_RISING | IRQ_TYPE_EDGE_FALLING;
> + type = (IRQ_TYPE_EDGE_RISING | IRQ_TYPE_EDGE_FALLING |
> + IRQ_TYPE_LEVEL_HIGH | IRQ_TYPE_LEVEL_LOW);
>   }

This doesn't look right.
IRQ_TYPE_PROBE isn't very well documented and there aren't a lot of
examples of usage, but I think the idea is that if the interrupt type
is already set, then leave it along, otherwise choose a sane default,
which is IRQ_TYPE_EDGE_BOTH
(aka IRQ_TYPE_EDGE_RISING | IRQ_TYPE_EDGE_FALLING) in all the cases
that I've looked at.

Certainly setting the type to RISING and FALLING and LOW and HIGH cannot
be right as that would cause constant interrupts.

>  
> - if (type & IRQ_TYPE_EDGE_RISING)
> - rg->rising |= mask;
> - else
> - rg->rising &= ~mask;
> -
> - if (type & IRQ_TYPE_EDGE_FALLING)
> - rg->falling |= mask;
> - else
> - rg->falling &= ~mask;
> + if (type & IRQ_TYPE_EDGE_RISING ||
> + type & IRQ_TYPE_EDGE_FALLING) {
> + if (type & IRQ_TYPE_EDGE_RISING)
> + rg->rising |= mask;
> + else
> + rg->rising &= ~mask;
> +
> + if (type & IRQ_TYPE_EDGE_FALLING)
> + rg->falling |= mask;
> + else
> + rg->falling &= ~mask;
> + } else {
> + if (type & IRQ_TYPE_LEVEL_HIGH) {
> + rg->hlevel |= mask;
> + rg->llevel &= ~mask;
> + } else {
> + rg->llevel |= mask;
> + rg->hlevel &= ~mask;
> + }
> + }

I wonder if we should be clearing the mask bit for hlevel and llevel
when setting either 

[PATCH v3] staging: mt7621-gpio: avoid custom irq_domain for gpio

2018-06-11 Thread Sergio Paracuellos
Instead of create a custom irq_domain for this chip, use
'gpiochip_set_chained_irqchip' from GPIOLIB_IRQCHIP. It
is ok to call this function several times. You only have to
mark the line with 'IRQF_SHARED' and then loop over the
three banks until you find a hit. There were some problems
with removing an irqchip like that but this driver is a bool
so it might work just fine. After this changes the functions
'mediatek_gpio_to_irq' is not needed anymore and also the
'gpio_irq_domain' field from the state container. Instead of
use the custom irq domain in the irq handler use the associated
domain from the gpio_chip in 'irq_find_mapping' function.
Function 'mediatek_gpio_bank_probe' has been moved a it to the
botton to have all the irq related functions together and avoid
some forward declarations to resolve some symbols along the code.

Signed-off-by: Sergio Paracuellos 
---
Changes in v3:
  - Update Kconfig with new GPIOLIB_IRQCHIP dependency.

Changes in v2:
  - This patch was previously part of a series but it is send
now alone to be sure this is the one which is causing
problems with new interrupts stuff.
  - Send individually to allow Neil to test it.
  - Fix parameters type getters in irq related functions
general domain send us a pointer to gpio_chip. Use
to_mediatek_gpio to get its associated mtk_gc.
  - request and release functions for irq_domain are not
needed so delete them also.
 drivers/staging/mt7621-gpio/Kconfig   |   1 +
 drivers/staging/mt7621-gpio/gpio-mt7621.c | 202 ++
 2 files changed, 65 insertions(+), 138 deletions(-)

diff --git a/drivers/staging/mt7621-gpio/Kconfig 
b/drivers/staging/mt7621-gpio/Kconfig
index 835998a..e32facb 100644
--- a/drivers/staging/mt7621-gpio/Kconfig
+++ b/drivers/staging/mt7621-gpio/Kconfig
@@ -2,6 +2,7 @@ config GPIO_MT7621
bool "Mediatek GPIO Support"
depends on SOC_MT7620 || SOC_MT7621 || COMPILE_TEST
select GPIO_GENERIC
+   select GPIOLIB_IRQCHIP
select ARCH_REQUIRE_GPIOLIB
help
  Say yes here to support the Mediatek SoC GPIO device
diff --git a/drivers/staging/mt7621-gpio/gpio-mt7621.c 
b/drivers/staging/mt7621-gpio/gpio-mt7621.c
index 39874cb..30810a8 100644
--- a/drivers/staging/mt7621-gpio/gpio-mt7621.c
+++ b/drivers/staging/mt7621-gpio/gpio-mt7621.c
@@ -8,7 +8,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -58,14 +57,12 @@ struct mtk_gc {
  * @dev: device instance
  * @gpio_membase: memory base address
  * @gpio_irq: irq number from the device tree
- * @gpio_irq_domain: irq domain for this chip
  * @gc_map: array of the gpio chips
  */
 struct mtk_data {
struct device *dev;
void __iomem *gpio_membase;
int gpio_irq;
-   struct irq_domain *gpio_irq_domain;
struct mtk_gc gc_map[MTK_BANK_CNT];
 };
 
@@ -95,98 +92,37 @@ mtk_gpio_r32(struct mtk_gc *rg, u32 offset)
return gc->read_reg(gpio_data->gpio_membase + offset);
 }
 
-static int
-mediatek_gpio_to_irq(struct gpio_chip *chip, unsigned int pin)
-{
-   struct mtk_data *gpio_data = gpiochip_get_data(chip);
-   struct mtk_gc *rg = to_mediatek_gpio(chip);
-
-   return irq_create_mapping(gpio_data->gpio_irq_domain,
- pin + (rg->bank * MTK_BANK_WIDTH));
-}
-
-static int
-mediatek_gpio_bank_probe(struct platform_device *pdev, struct device_node 
*bank)
-{
-   struct mtk_data *gpio = dev_get_drvdata(>dev);
-   const __be32 *id = of_get_property(bank, "reg", NULL);
-   struct mtk_gc *rg;
-   void __iomem *dat, *set, *ctrl, *diro;
-   int ret;
-
-   if (!id || be32_to_cpu(*id) >= MTK_BANK_CNT)
-   return -EINVAL;
-
-   rg = >gc_map[be32_to_cpu(*id)];
-   memset(rg, 0, sizeof(*rg));
-
-   spin_lock_init(>lock);
-   rg->chip.of_node = bank;
-   rg->bank = be32_to_cpu(*id);
-
-   dat = gpio->gpio_membase + GPIO_REG_DATA + (rg->bank * GPIO_BANK_WIDE);
-   set = gpio->gpio_membase + GPIO_REG_DSET + (rg->bank * GPIO_BANK_WIDE);
-   ctrl = gpio->gpio_membase + GPIO_REG_DCLR + (rg->bank * GPIO_BANK_WIDE);
-   diro = gpio->gpio_membase + GPIO_REG_CTRL + (rg->bank * GPIO_BANK_WIDE);
-
-   ret = bgpio_init(>chip, >dev, 4,
-dat, set, ctrl, diro, NULL, 0);
-   if (ret) {
-   dev_err(>dev, "bgpio_init() failed\n");
-   return ret;
-   }
-
-   if (gpio->gpio_irq_domain)
-   rg->chip.to_irq = mediatek_gpio_to_irq;
-
-   ret = devm_gpiochip_add_data(>dev, >chip, gpio);
-   if (ret < 0) {
-   dev_err(>dev, "Could not register gpio %d, ret=%d\n",
-   rg->chip.ngpio, ret);
-   return ret;
-   }
-
-   /* set polarity to low for all gpios */
-   mtk_gpio_w32(rg, GPIO_REG_POL, 0);
-
-   dev_info(>dev, "registering %d gpios\n", rg->chip.ngpio);
-
-   return 0;
-}
-
 static void
 

[PATCH v2] staging: mt7621-gpio: avoid custom irq_domain for gpio

2018-06-11 Thread Sergio Paracuellos
Instead of create a custom irq_domain for this chip, use
'gpiochip_set_chained_irqchip' from GPIOLIB_IRQCHIP. It
is ok to call this function several times. You only have to
mark the line with 'IRQF_SHARED' and then loop over the
three banks until you find a hit. There were some problems
with removing an irqchip like that but this driver is a bool
so it might work just fine. After this changes the functions
'mediatek_gpio_to_irq' is not needed anymore and also the
'gpio_irq_domain' field from the state container. Instead of
use the custom irq domain in the irq handler use the associated
domain from the gpio_chip in 'irq_find_mapping' function.
Function 'mediatek_gpio_bank_probe' has been moved a it to the
botton to have all the irq related functions together and avoid
some forward declarations to resolve some symbols along the code.

Signed-off-by: Sergio Paracuellos 
---
Changes in v2:
  - This patch was previously part of a series but it is send
now alone to be sure this is the one which is causing
problems with new interrupts stuff.
  - Send individually to allow Neil to test it.
  - Fix parameters type getters in irq related functions
general domain send us a pointer to gpio_chip. Use 
to_mediatek_gpio to get its associated mtk_gc. 
  - request and release functions for irq_domain are not
needed so delete them also.
 
 drivers/staging/mt7621-gpio/gpio-mt7621.c | 202 ++
 1 file changed, 64 insertions(+), 138 deletions(-)

diff --git a/drivers/staging/mt7621-gpio/gpio-mt7621.c 
b/drivers/staging/mt7621-gpio/gpio-mt7621.c
index 39874cb..30810a8 100644
--- a/drivers/staging/mt7621-gpio/gpio-mt7621.c
+++ b/drivers/staging/mt7621-gpio/gpio-mt7621.c
@@ -8,7 +8,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -58,14 +57,12 @@ struct mtk_gc {
  * @dev: device instance
  * @gpio_membase: memory base address
  * @gpio_irq: irq number from the device tree
- * @gpio_irq_domain: irq domain for this chip
  * @gc_map: array of the gpio chips
  */
 struct mtk_data {
struct device *dev;
void __iomem *gpio_membase;
int gpio_irq;
-   struct irq_domain *gpio_irq_domain;
struct mtk_gc gc_map[MTK_BANK_CNT];
 };
 
@@ -95,98 +92,37 @@ mtk_gpio_r32(struct mtk_gc *rg, u32 offset)
return gc->read_reg(gpio_data->gpio_membase + offset);
 }
 
-static int
-mediatek_gpio_to_irq(struct gpio_chip *chip, unsigned int pin)
-{
-   struct mtk_data *gpio_data = gpiochip_get_data(chip);
-   struct mtk_gc *rg = to_mediatek_gpio(chip);
-
-   return irq_create_mapping(gpio_data->gpio_irq_domain,
- pin + (rg->bank * MTK_BANK_WIDTH));
-}
-
-static int
-mediatek_gpio_bank_probe(struct platform_device *pdev, struct device_node 
*bank)
-{
-   struct mtk_data *gpio = dev_get_drvdata(>dev);
-   const __be32 *id = of_get_property(bank, "reg", NULL);
-   struct mtk_gc *rg;
-   void __iomem *dat, *set, *ctrl, *diro;
-   int ret;
-
-   if (!id || be32_to_cpu(*id) >= MTK_BANK_CNT)
-   return -EINVAL;
-
-   rg = >gc_map[be32_to_cpu(*id)];
-   memset(rg, 0, sizeof(*rg));
-
-   spin_lock_init(>lock);
-   rg->chip.of_node = bank;
-   rg->bank = be32_to_cpu(*id);
-
-   dat = gpio->gpio_membase + GPIO_REG_DATA + (rg->bank * GPIO_BANK_WIDE);
-   set = gpio->gpio_membase + GPIO_REG_DSET + (rg->bank * GPIO_BANK_WIDE);
-   ctrl = gpio->gpio_membase + GPIO_REG_DCLR + (rg->bank * GPIO_BANK_WIDE);
-   diro = gpio->gpio_membase + GPIO_REG_CTRL + (rg->bank * GPIO_BANK_WIDE);
-
-   ret = bgpio_init(>chip, >dev, 4,
-dat, set, ctrl, diro, NULL, 0);
-   if (ret) {
-   dev_err(>dev, "bgpio_init() failed\n");
-   return ret;
-   }
-
-   if (gpio->gpio_irq_domain)
-   rg->chip.to_irq = mediatek_gpio_to_irq;
-
-   ret = devm_gpiochip_add_data(>dev, >chip, gpio);
-   if (ret < 0) {
-   dev_err(>dev, "Could not register gpio %d, ret=%d\n",
-   rg->chip.ngpio, ret);
-   return ret;
-   }
-
-   /* set polarity to low for all gpios */
-   mtk_gpio_w32(rg, GPIO_REG_POL, 0);
-
-   dev_info(>dev, "registering %d gpios\n", rg->chip.ngpio);
-
-   return 0;
-}
-
 static void
 mediatek_gpio_irq_handler(struct irq_desc *desc)
 {
-   struct mtk_data *gpio_data = irq_desc_get_handler_data(desc);
-   int i;
+   struct gpio_chip *gc = irq_desc_get_handler_data(desc);
+   struct mtk_gc *rg = to_mediatek_gpio(gc);
+   struct irq_chip *irqchip = irq_desc_get_chip(desc);
+   unsigned long pending;
+   int bit;
 
-   for (i = 0; i < MTK_BANK_CNT; i++) {
-   struct mtk_gc *rg = _data->gc_map[i];
-   unsigned long pending;
-   int bit;
+   chained_irq_enter(irqchip, desc);
 
-   if (!rg)
-   continue;
-
-