Re: [PATCH 08/10] x86/hyper-v: use hypercall for remote TLB flush

2017-06-25 Thread kbuild test robot
Hi Vitaly,

[auto build test ERROR on next-20170619]
[cannot apply to tip/x86/core linus/master linux/master v4.12-rc6 v4.12-rc5 
v4.12-rc4 v4.12-rc7]
[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/kys-exchange-microsoft-com/x86-hyper-v-include-hyperv-only-when-CONFIG_HYPERV-is-set/20170626-133601
config: i386-randconfig-a0-06250447 (attached as .config)
compiler: gcc-5 (Debian 5.4.1-2) 5.4.1 20160904
reproduce:
# save the attached .config to linux build tree
make ARCH=i386 

All errors (new ones prefixed by >>):

   arch/x86/hyperv/mmu.c: In function 'hyperv_flush_tlb_others':
>> arch/x86/hyperv/mmu.c:120:32: error: passing argument 2 of 
>> 'native_flush_tlb_others' from incompatible pointer type 
>> [-Werror=incompatible-pointer-types]
 native_flush_tlb_others(cpus, mm, start, end);
   ^
   In file included from arch/x86/hyperv/mmu.c:9:0:
   arch/x86/include/asm/tlbflush.h:256:6: note: expected 'const struct 
flush_tlb_info *' but argument is of type 'struct mm_struct *'
void native_flush_tlb_others(const struct cpumask *cpumask,
 ^
>> arch/x86/hyperv/mmu.c:120:2: error: too many arguments to function 
>> 'native_flush_tlb_others'
 native_flush_tlb_others(cpus, mm, start, end);
 ^
   In file included from arch/x86/hyperv/mmu.c:9:0:
   arch/x86/include/asm/tlbflush.h:256:6: note: declared here
void native_flush_tlb_others(const struct cpumask *cpumask,
 ^
   arch/x86/hyperv/mmu.c: In function 'hyperv_setup_mmu_ops':
>> arch/x86/hyperv/mmu.c:127:31: error: assignment from incompatible pointer 
>> type [-Werror=incompatible-pointer-types]
  pv_mmu_ops.flush_tlb_others = hyperv_flush_tlb_others;
  ^
   cc1: some warnings being treated as errors

vim +/native_flush_tlb_others +120 arch/x86/hyperv/mmu.c

   114  
   115  local_irq_restore(flags);
   116  
   117  if (!(status & HV_HYPERCALL_RESULT_MASK))
   118  return;
   119  do_native:
 > 120  native_flush_tlb_others(cpus, mm, start, end);
   121  }
   122  
   123  void hyperv_setup_mmu_ops(void)
   124  {
   125  if (ms_hyperv.hints & HV_X64_REMOTE_TLB_FLUSH_RECOMMENDED) {
   126  pr_info("Hyper-V: Using hypercall for remote TLB 
flush\n");
 > 127  pv_mmu_ops.flush_tlb_others = hyperv_flush_tlb_others;
   128  }
   129  }
   130  

---
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] staging: sm750fb: always take the lock

2017-06-25 Thread Frans Klaver
There's no version number. Which one is the correct one?

On Mon, Jun 26, 2017 at 7:45 AM, AbdAllah-MEZITI
 wrote:
> This patch
> - will always take the lock
> - fix the sparse warning:
> drivers/staging/sm750fb/sm750.c:159:13: warning: context imbalance in 
> 'lynxfb_ops_fillrect' - different lock contexts for basic block
> drivers/staging/sm750fb/sm750.c:231:9: warning: context imbalance in 
> 'lynxfb_ops_copyarea' - different lock contexts for basic block
> drivers/staging/sm750fb/sm750.c:235:13: warning: context imbalance in 
> 'lynxfb_ops_imageblit' - different lock contexts for basic block
>
> Signed-off-by: AbdAllah MEZITI 
> ---
>  drivers/staging/sm750fb/sm750.c | 18 ++
>  1 file changed, 6 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/staging/sm750fb/sm750.c b/drivers/staging/sm750fb/sm750.c
> index 386d4ad..4a22190 100644
> --- a/drivers/staging/sm750fb/sm750.c
> +++ b/drivers/staging/sm750fb/sm750.c
> @@ -186,16 +186,14 @@ static void lynxfb_ops_fillrect(struct fb_info *info,
>  * If not use spin_lock,system will die if user load driver
>  * and immediately unload driver frequently (dual)
>  */
> -   if (sm750_dev->fb_count > 1)
> -   spin_lock(&sm750_dev->slock);
> +   spin_lock(&sm750_dev->slock);
>
> sm750_dev->accel.de_fillrect(&sm750_dev->accel,
>  base, pitch, Bpp,
>  region->dx, region->dy,
>  region->width, region->height,
>  color, rop);
> -   if (sm750_dev->fb_count > 1)
> -   spin_unlock(&sm750_dev->slock);
> +   spin_unlock(&sm750_dev->slock);
>  }
>
>  static void lynxfb_ops_copyarea(struct fb_info *info,
> @@ -220,16 +218,14 @@ static void lynxfb_ops_copyarea(struct fb_info *info,
>  * If not use spin_lock, system will die if user load driver
>  * and immediately unload driver frequently (dual)
>  */
> -   if (sm750_dev->fb_count > 1)
> -   spin_lock(&sm750_dev->slock);
> +   spin_lock(&sm750_dev->slock);
>
> sm750_dev->accel.de_copyarea(&sm750_dev->accel,
>  base, pitch, region->sx, region->sy,
>  base, pitch, Bpp, region->dx, region->dy,
>  region->width, region->height,
>  HW_ROP2_COPY);
> -   if (sm750_dev->fb_count > 1)
> -   spin_unlock(&sm750_dev->slock);
> +   spin_unlock(&sm750_dev->slock);
>  }
>
>  static void lynxfb_ops_imageblit(struct fb_info *info,
> @@ -269,8 +265,7 @@ static void lynxfb_ops_imageblit(struct fb_info *info,
>  * If not use spin_lock, system will die if user load driver
>  * and immediately unload driver frequently (dual)
>  */
> -   if (sm750_dev->fb_count > 1)
> -   spin_lock(&sm750_dev->slock);
> +   spin_lock(&sm750_dev->slock);
>
> sm750_dev->accel.de_imageblit(&sm750_dev->accel,
>   image->data, image->width >> 3, 0,
> @@ -278,8 +273,7 @@ static void lynxfb_ops_imageblit(struct fb_info *info,
>   image->dx, image->dy,
>   image->width, image->height,
>   fgcol, bgcol, HW_ROP2_COPY);
> -   if (sm750_dev->fb_count > 1)
> -   spin_unlock(&sm750_dev->slock);
> +   spin_unlock(&sm750_dev->slock);
>  }
>
>  static int lynxfb_ops_pan_display(struct fb_var_screeninfo *var,
> --
> 2.7.4
>
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: sm750fb: always take the lock

2017-06-25 Thread Frans Klaver
On Sun, Jun 25, 2017 at 11:39 PM, AbdAllah-MEZITI
 wrote:
> Subject: [PATCH] staging: sm750fb: always take the lock

When sending a new version of your patch, include a version number:

Subject: [PATCH V2] staging: ...

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


[PATCH] staging: sm750fb: always take the lock

2017-06-25 Thread AbdAllah-MEZITI
This patch
- will always take the lock
- fix the sparse warning:
drivers/staging/sm750fb/sm750.c:159:13: warning: context imbalance in 
'lynxfb_ops_fillrect' - different lock contexts for basic block
drivers/staging/sm750fb/sm750.c:231:9: warning: context imbalance in 
'lynxfb_ops_copyarea' - different lock contexts for basic block
drivers/staging/sm750fb/sm750.c:235:13: warning: context imbalance in 
'lynxfb_ops_imageblit' - different lock contexts for basic block

Signed-off-by: AbdAllah MEZITI 
---
 drivers/staging/sm750fb/sm750.c | 18 ++
 1 file changed, 6 insertions(+), 12 deletions(-)

diff --git a/drivers/staging/sm750fb/sm750.c b/drivers/staging/sm750fb/sm750.c
index 386d4ad..4a22190 100644
--- a/drivers/staging/sm750fb/sm750.c
+++ b/drivers/staging/sm750fb/sm750.c
@@ -186,16 +186,14 @@ static void lynxfb_ops_fillrect(struct fb_info *info,
 * If not use spin_lock,system will die if user load driver
 * and immediately unload driver frequently (dual)
 */
-   if (sm750_dev->fb_count > 1)
-   spin_lock(&sm750_dev->slock);
+   spin_lock(&sm750_dev->slock);
 
sm750_dev->accel.de_fillrect(&sm750_dev->accel,
 base, pitch, Bpp,
 region->dx, region->dy,
 region->width, region->height,
 color, rop);
-   if (sm750_dev->fb_count > 1)
-   spin_unlock(&sm750_dev->slock);
+   spin_unlock(&sm750_dev->slock);
 }
 
 static void lynxfb_ops_copyarea(struct fb_info *info,
@@ -220,16 +218,14 @@ static void lynxfb_ops_copyarea(struct fb_info *info,
 * If not use spin_lock, system will die if user load driver
 * and immediately unload driver frequently (dual)
 */
-   if (sm750_dev->fb_count > 1)
-   spin_lock(&sm750_dev->slock);
+   spin_lock(&sm750_dev->slock);
 
sm750_dev->accel.de_copyarea(&sm750_dev->accel,
 base, pitch, region->sx, region->sy,
 base, pitch, Bpp, region->dx, region->dy,
 region->width, region->height,
 HW_ROP2_COPY);
-   if (sm750_dev->fb_count > 1)
-   spin_unlock(&sm750_dev->slock);
+   spin_unlock(&sm750_dev->slock);
 }
 
 static void lynxfb_ops_imageblit(struct fb_info *info,
@@ -269,8 +265,7 @@ static void lynxfb_ops_imageblit(struct fb_info *info,
 * If not use spin_lock, system will die if user load driver
 * and immediately unload driver frequently (dual)
 */
-   if (sm750_dev->fb_count > 1)
-   spin_lock(&sm750_dev->slock);
+   spin_lock(&sm750_dev->slock);
 
sm750_dev->accel.de_imageblit(&sm750_dev->accel,
  image->data, image->width >> 3, 0,
@@ -278,8 +273,7 @@ static void lynxfb_ops_imageblit(struct fb_info *info,
  image->dx, image->dy,
  image->width, image->height,
  fgcol, bgcol, HW_ROP2_COPY);
-   if (sm750_dev->fb_count > 1)
-   spin_unlock(&sm750_dev->slock);
+   spin_unlock(&sm750_dev->slock);
 }
 
 static int lynxfb_ops_pan_display(struct fb_var_screeninfo *var,
-- 
2.7.4

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


Re: [PATCH 0/4] staging: ks7010: cfg80211 conversion

2017-06-25 Thread Greg Kroah-Hartman
On Mon, Jun 26, 2017 at 11:27:22AM +1000, Tobin C. Harding wrote:
> On Wed, Jun 14, 2017 at 04:30:34PM +1000, Tobin C. Harding wrote:
> [snip]
> 
> Please drop this series.

Oh it's long dropped :)
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: sm750fb: always take the lock

2017-06-25 Thread Greg Kroah-Hartman
On Sun, Jun 25, 2017 at 11:39:20PM +0200, AbdAllah-MEZITI wrote:
> Signed-off-by: AbdAllah MEZITI 

I can't take patches without any changelog text, sorry.

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


Re: [PATCH 0/4] staging: ks7010: cfg80211 conversion

2017-06-25 Thread Tobin C. Harding
On Wed, Jun 14, 2017 at 04:30:34PM +1000, Tobin C. Harding wrote:
[snip]

Please drop this series.

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


[PATCH] staging: sm750fb: always take the lock

2017-06-25 Thread AbdAllah-MEZITI
Signed-off-by: AbdAllah MEZITI 
---
 drivers/staging/sm750fb/sm750.c | 18 ++
 1 file changed, 6 insertions(+), 12 deletions(-)

diff --git a/drivers/staging/sm750fb/sm750.c b/drivers/staging/sm750fb/sm750.c
index 386d4ad..4a22190 100644
--- a/drivers/staging/sm750fb/sm750.c
+++ b/drivers/staging/sm750fb/sm750.c
@@ -186,16 +186,14 @@ static void lynxfb_ops_fillrect(struct fb_info *info,
 * If not use spin_lock,system will die if user load driver
 * and immediately unload driver frequently (dual)
 */
-   if (sm750_dev->fb_count > 1)
-   spin_lock(&sm750_dev->slock);
+   spin_lock(&sm750_dev->slock);
 
sm750_dev->accel.de_fillrect(&sm750_dev->accel,
 base, pitch, Bpp,
 region->dx, region->dy,
 region->width, region->height,
 color, rop);
-   if (sm750_dev->fb_count > 1)
-   spin_unlock(&sm750_dev->slock);
+   spin_unlock(&sm750_dev->slock);
 }
 
 static void lynxfb_ops_copyarea(struct fb_info *info,
@@ -220,16 +218,14 @@ static void lynxfb_ops_copyarea(struct fb_info *info,
 * If not use spin_lock, system will die if user load driver
 * and immediately unload driver frequently (dual)
 */
-   if (sm750_dev->fb_count > 1)
-   spin_lock(&sm750_dev->slock);
+   spin_lock(&sm750_dev->slock);
 
sm750_dev->accel.de_copyarea(&sm750_dev->accel,
 base, pitch, region->sx, region->sy,
 base, pitch, Bpp, region->dx, region->dy,
 region->width, region->height,
 HW_ROP2_COPY);
-   if (sm750_dev->fb_count > 1)
-   spin_unlock(&sm750_dev->slock);
+   spin_unlock(&sm750_dev->slock);
 }
 
 static void lynxfb_ops_imageblit(struct fb_info *info,
@@ -269,8 +265,7 @@ static void lynxfb_ops_imageblit(struct fb_info *info,
 * If not use spin_lock, system will die if user load driver
 * and immediately unload driver frequently (dual)
 */
-   if (sm750_dev->fb_count > 1)
-   spin_lock(&sm750_dev->slock);
+   spin_lock(&sm750_dev->slock);
 
sm750_dev->accel.de_imageblit(&sm750_dev->accel,
  image->data, image->width >> 3, 0,
@@ -278,8 +273,7 @@ static void lynxfb_ops_imageblit(struct fb_info *info,
  image->dx, image->dy,
  image->width, image->height,
  fgcol, bgcol, HW_ROP2_COPY);
-   if (sm750_dev->fb_count > 1)
-   spin_unlock(&sm750_dev->slock);
+   spin_unlock(&sm750_dev->slock);
 }
 
 static int lynxfb_ops_pan_display(struct fb_var_screeninfo *var,
-- 
2.7.4

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


Re: [PATCH] staging: sm750fb: fix sparce warning.

2017-06-25 Thread Frans Klaver


On 25 June 2017 21:10:36 CEST, AbdAllah-MEZITI  
wrote:
>This patch fixes the following sparce warnings: different lock contexts
>for basic block.
>
>drivers/staging/sm750fb//sm750.c:159:13: warning: context imbalance in
>'lynxfb_ops_fillrect' - different lock contexts for basic block
>drivers/staging/sm750fb//sm750.c:231:9: warning: context imbalance in
>'lynxfb_ops_copyarea' - different lock contexts for basic block
>drivers/staging/sm750fb//sm750.c:235:13: warning: context imbalance in
>'lynxfb_ops_imageblit' - different lock contexts for basic block
>
>Signed-off-by: AbdAllah-MEZITI 
>---
>drivers/staging/sm750fb/sm750.c | 69
>-
> 1 file changed, 47 insertions(+), 22 deletions(-)
>
>diff --git a/drivers/staging/sm750fb/sm750.c
>b/drivers/staging/sm750fb/sm750.c
>index 664c220..5494a29 100644
>--- a/drivers/staging/sm750fb/sm750.c
>+++ b/drivers/staging/sm750fb/sm750.c
>@@ -186,16 +186,24 @@ static void lynxfb_ops_fillrect(struct fb_info
>*info,
>* If not use spin_lock,system will die if user load driver
>* and immediately unload driver frequently (dual)
>*/
>-  if (sm750_dev->fb_count > 1)
>+  if (sm750_dev->fb_count > 1) {
>   spin_lock(&sm750_dev->slock);
> 
>-  sm750_dev->accel.de_fillrect(&sm750_dev->accel,
>-   base, pitch, Bpp,
>-   region->dx, region->dy,
>-   region->width, region->height,
>-   color, rop);
>-  if (sm750_dev->fb_count > 1)
>+  sm750_dev->accel.de_fillrect(&sm750_dev->accel,
>+   base, pitch, Bpp,
>+   region->dx, region->dy,
>+   region->width, region->height,
>+   color, rop);
>+
>   spin_unlock(&sm750_dev->slock);
>+  } else {
>+  sm750_dev->accel.de_fillrect(&sm750_dev->accel,
>+   base, pitch, Bpp,
>+   region->dx, region->dy,
>+   region->width, region->height,
>+   color, rop);
>+  }
>+
> }
> 
> static void lynxfb_ops_copyarea(struct fb_info *info,
>@@ -220,16 +228,24 @@ static void lynxfb_ops_copyarea(struct fb_info
>*info,
>* If not use spin_lock, system will die if user load driver
>* and immediately unload driver frequently (dual)
>*/
>-  if (sm750_dev->fb_count > 1)
>+  if (sm750_dev->fb_count > 1) {
>   spin_lock(&sm750_dev->slock);
> 
>-  sm750_dev->accel.de_copyarea(&sm750_dev->accel,
>-   base, pitch, region->sx, region->sy,
>-   base, pitch, Bpp, region->dx, region->dy,
>-   region->width, region->height,
>-   HW_ROP2_COPY);
>-  if (sm750_dev->fb_count > 1)
>+  sm750_dev->accel.de_copyarea(&sm750_dev->accel,
>+   base, pitch, region->sx, 
>region->sy,
>+   base, pitch, Bpp, region->dx, 
>region->dy,
>+   region->width, region->height,
>+   HW_ROP2_COPY);
>+
>   spin_unlock(&sm750_dev->slock);
>+  } else {
>+  sm750_dev->accel.de_copyarea(&sm750_dev->accel,
>+   base, pitch, region->sx, 
>region->sy,
>+   base, pitch, Bpp, region->dx, 
>region->dy,
>+   region->width, region->height,
>+   HW_ROP2_COPY);
>+  }
>+
> }
> 
> static void lynxfb_ops_imageblit(struct fb_info *info,
>@@ -269,17 +285,26 @@ static void lynxfb_ops_imageblit(struct fb_info
>*info,
>* If not use spin_lock, system will die if user load driver
>* and immediately unload driver frequently (dual)
>*/
>-  if (sm750_dev->fb_count > 1)
>+  if (sm750_dev->fb_count > 1) {
>   spin_lock(&sm750_dev->slock);
> 
>-  sm750_dev->accel.de_imageblit(&sm750_dev->accel,
>-image->data, image->width >> 3, 0,
>-base, pitch, Bpp,
>-image->dx, image->dy,
>-image->width, image->height,
>-fgcol, bgcol, HW_ROP2_COPY);
>-  if (sm750_dev->fb_count > 1)
>+  sm750_dev->accel.de_imageblit(&sm750_dev->accel,
>+image->data, image->width >> 3, 0,
>+base, pitch, Bpp,
>+  

[PATCH 2/2] vmbus: re-enable channel tasklet

2017-06-25 Thread kys
From: Stephen Hemminger 

This problem shows up in 4.11 when netvsc driver is removed and reloaded.
The problem is that the channel is closed during module removal and the
tasklet for processing responses is disabled. When module is reloaded
the channel is reopened but the tasklet is marked as disabled.
The fix is to re-enable tasklet at the end of close which gets it back
to the initial state.

The issue is less urgent in 4.12 since network driver now uses NAPI
and not the tasklet; and other VMBUS devices are rarely unloaded/reloaded.

Fixes: dad72a1d2844 ("vmbus: remove hv_event_tasklet_disable/enable")

Signed-off-by: Stephen Hemminger 
Signed-off-by: K. Y. Srinivasan 
Cc: sta...@vger.kernel.org
---
 drivers/hv/channel.c |2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/drivers/hv/channel.c b/drivers/hv/channel.c
index e9bf0bb..e57cc40 100644
--- a/drivers/hv/channel.c
+++ b/drivers/hv/channel.c
@@ -606,6 +606,8 @@ static int vmbus_close_internal(struct vmbus_channel 
*channel)
get_order(channel->ringbuffer_pagecount * PAGE_SIZE));
 
 out:
+   /* re-enable tasklet for use on re-open */
+   tasklet_enable(&channel->callback_event);
return ret;
 }
 
-- 
1.7.1

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


[PATCH 1/2] Tools: hv: vss: Skip freezing filesystems backed by loop

2017-06-25 Thread kys
From: Alex Ng 

Skip loop devices from the freeze/thaw operation.

Signed-off-by: Alex Ng 
Signed-off-by: Vyronas Tsingaras 
Signed-off-by: K. Y. Srinivasan 
---
 tools/hv/hv_vss_daemon.c |7 +++
 1 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/tools/hv/hv_vss_daemon.c b/tools/hv/hv_vss_daemon.c
index 7ba5419..b2b4ebf 100644
--- a/tools/hv/hv_vss_daemon.c
+++ b/tools/hv/hv_vss_daemon.c
@@ -21,6 +21,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -30,6 +31,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -70,6 +72,7 @@ static int vss_operate(int operation)
char match[] = "/dev/";
FILE *mounts;
struct mntent *ent;
+   struct stat sb;
char errdir[1024] = {0};
unsigned int cmd;
int error = 0, root_seen = 0, save_errno = 0;
@@ -92,6 +95,10 @@ static int vss_operate(int operation)
while ((ent = getmntent(mounts))) {
if (strncmp(ent->mnt_fsname, match, strlen(match)))
continue;
+   if (stat(ent->mnt_fsname, &sb) == -1)
+   continue;
+   if (S_ISBLK(sb.st_mode) && major(sb.st_rdev) == LOOP_MAJOR)
+   continue;
if (hasmntopt(ent, MNTOPT_RO) != NULL)
continue;
if (strcmp(ent->mnt_type, "vfat") == 0)
-- 
1.7.1

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


[PATCH 0/2] Drivers: hv: Miscellaneous fixes

2017-06-25 Thread kys
From: K. Y. Srinivasan 

Miscellaneous fixes.

Alex Ng (1):
  Tools: hv: vss: Skip freezing filesystems backed by loop

Stephen Hemminger (1):
  vmbus: re-enable channel tasklet

 drivers/hv/channel.c |2 ++
 tools/hv/hv_vss_daemon.c |7 +++
 2 files changed, 9 insertions(+), 0 deletions(-)

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


[PATCH 1/6] vmbus: simplify hv_ringbuffer_read

2017-06-25 Thread kys
From: Stephen Hemminger 

With new iterator functions (and the double mapping) the ring buffer
read function can be greatly simplified.

Signed-off-by: Stephen Hemminger 
Signed-off-by: K. Y. Srinivasan 
---
 drivers/hv/ring_buffer.c |  118 +++---
 1 files changed, 17 insertions(+), 101 deletions(-)

diff --git a/drivers/hv/ring_buffer.c b/drivers/hv/ring_buffer.c
index 1f450c3..f299817 100644
--- a/drivers/hv/ring_buffer.c
+++ b/drivers/hv/ring_buffer.c
@@ -94,30 +94,6 @@ static void hv_signal_on_write(u32 old_write, struct 
vmbus_channel *channel)
ring_info->ring_buffer->write_index = next_write_location;
 }
 
-/* Get the next read location for the specified ring buffer. */
-static inline u32
-hv_get_next_read_location(const struct hv_ring_buffer_info *ring_info)
-{
-   return ring_info->ring_buffer->read_index;
-}
-
-/*
- * Get the next read location + offset for the specified ring buffer.
- * This allows the caller to skip.
- */
-static inline u32
-hv_get_next_readlocation_withoffset(const struct hv_ring_buffer_info 
*ring_info,
-   u32 offset)
-{
-   u32 next = ring_info->ring_buffer->read_index;
-
-   next += offset;
-   if (next >= ring_info->ring_datasize)
-   next -= ring_info->ring_datasize;
-
-   return next;
-}
-
 /* Set the next read location for the specified ring buffer. */
 static inline void
 hv_set_next_read_location(struct hv_ring_buffer_info *ring_info,
@@ -142,29 +118,6 @@ static void hv_signal_on_write(u32 old_write, struct 
vmbus_channel *channel)
 }
 
 /*
- * Helper routine to copy to source from ring buffer.
- * Assume there is enough room. Handles wrap-around in src case only!!
- */
-static u32 hv_copyfrom_ringbuffer(
-   const struct hv_ring_buffer_info *ring_info,
-   void*dest,
-   u32 destlen,
-   u32 start_read_offset)
-{
-   void *ring_buffer = hv_get_ring_buffer(ring_info);
-   u32 ring_buffer_size = hv_get_ring_buffersize(ring_info);
-
-   memcpy(dest, ring_buffer + start_read_offset, destlen);
-
-   start_read_offset += destlen;
-   if (start_read_offset >= ring_buffer_size)
-   start_read_offset -= ring_buffer_size;
-
-   return start_read_offset;
-}
-
-
-/*
  * Helper routine to copy from source to ring buffer.
  * Assume there is enough room. Handles wrap-around in dest case only!!
  */
@@ -334,33 +287,22 @@ int hv_ringbuffer_write(struct vmbus_channel *channel,
return 0;
 }
 
-static inline void
-init_cached_read_index(struct hv_ring_buffer_info *rbi)
-{
-   rbi->cached_read_index = rbi->ring_buffer->read_index;
-}
-
 int hv_ringbuffer_read(struct vmbus_channel *channel,
   void *buffer, u32 buflen, u32 *buffer_actual_len,
   u64 *requestid, bool raw)
 {
-   u32 bytes_avail_toread;
-   u32 next_read_location;
-   u64 prev_indices = 0;
-   struct vmpacket_descriptor desc;
-   u32 offset;
-   u32 packetlen;
-   struct hv_ring_buffer_info *inring_info = &channel->inbound;
-
-   if (buflen <= 0)
+   struct vmpacket_descriptor *desc;
+   u32 packetlen, offset;
+
+   if (unlikely(buflen == 0))
return -EINVAL;
 
*buffer_actual_len = 0;
*requestid = 0;
 
-   bytes_avail_toread = hv_get_bytes_to_read(inring_info);
/* Make sure there is something to read */
-   if (bytes_avail_toread < sizeof(desc)) {
+   desc = hv_pkt_iter_first(channel);
+   if (desc == NULL) {
/*
 * No error is set when there is even no header, drivers are
 * supposed to analyze buffer_actual_len.
@@ -368,48 +310,22 @@ int hv_ringbuffer_read(struct vmbus_channel *channel,
return 0;
}
 
-   init_cached_read_index(inring_info);
-
-   next_read_location = hv_get_next_read_location(inring_info);
-   next_read_location = hv_copyfrom_ringbuffer(inring_info, &desc,
-   sizeof(desc),
-   next_read_location);
-
-   offset = raw ? 0 : (desc.offset8 << 3);
-   packetlen = (desc.len8 << 3) - offset;
+   offset = raw ? 0 : (desc->offset8 << 3);
+   packetlen = (desc->len8 << 3) - offset;
*buffer_actual_len = packetlen;
-   *requestid = desc.trans_id;
-
-   if (bytes_avail_toread < packetlen + offset)
-   return -EAGAIN;
+   *requestid = desc->trans_id;
 
-   if (packetlen > buflen)
+   if (unlikely(packetlen > buflen))
return -ENOBUFS;
 
-   next_read_location =
-   hv_get_next_readlocation_withoffset(inring_info, offset);
+   /* since ring is double mapped, only one copy is necessary */
+   memcpy(buffer, (const char *)desc + offset, packetlen);
 
-   n

[PATCH 6/6] vmbus: add prefetch to ring buffer iterator

2017-06-25 Thread kys
From: Stephen Hemminger 

When iterating over incoming ring elements from the host, prefetch
the next descriptor so that it is cache hot.

Signed-off-by: Stephen Hemminger 
Signed-off-by: K. Y. Srinivasan 
---
 drivers/hv/ring_buffer.c |7 ++-
 1 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/drivers/hv/ring_buffer.c b/drivers/hv/ring_buffer.c
index 741daa6..12eb8ca 100644
--- a/drivers/hv/ring_buffer.c
+++ b/drivers/hv/ring_buffer.c
@@ -357,11 +357,16 @@ static u32 hv_pkt_iter_avail(const struct 
hv_ring_buffer_info *rbi)
 struct vmpacket_descriptor *hv_pkt_iter_first(struct vmbus_channel *channel)
 {
struct hv_ring_buffer_info *rbi = &channel->inbound;
+   struct vmpacket_descriptor *desc;
 
if (hv_pkt_iter_avail(rbi) < sizeof(struct vmpacket_descriptor))
return NULL;
 
-   return hv_get_ring_buffer(rbi) + rbi->priv_read_index;
+   desc = hv_get_ring_buffer(rbi) + rbi->priv_read_index;
+   if (desc)
+   prefetch((char *)desc + (desc->len8 << 3));
+
+   return desc;
 }
 EXPORT_SYMBOL_GPL(hv_pkt_iter_first);
 
-- 
1.7.1

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


[PATCH 2/6] vmbus: drop unused ring_buffer_info elements

2017-06-25 Thread kys
From: Stephen Hemminger 

The elements ring_data_start_offset and priv_write_index
are not used.

Signed-off-by: Stephen Hemminger 
Signed-off-by: K. Y. Srinivasan 
---
 include/linux/hyperv.h |2 --
 1 files changed, 0 insertions(+), 2 deletions(-)

diff --git a/include/linux/hyperv.h b/include/linux/hyperv.h
index 9591ae7..b1549c9 100644
--- a/include/linux/hyperv.h
+++ b/include/linux/hyperv.h
@@ -124,8 +124,6 @@ struct hv_ring_buffer_info {
spinlock_t ring_lock;
 
u32 ring_datasize;  /* < ring_size */
-   u32 ring_data_startoffset;
-   u32 priv_write_index;
u32 priv_read_index;
u32 cached_read_index;
 };
-- 
1.7.1

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


[PATCH 4/6] vmbus: eliminate duplicate cached index

2017-06-25 Thread kys
From: Stephen Hemminger 

Don't need cached read index anymore now that packet iterator
is used. The iterator has the original read index until the
visible read_index is updated.

Signed-off-by: Stephen Hemminger 
Signed-off-by: K. Y. Srinivasan 
---
 drivers/hv/ring_buffer.c |   17 -
 include/linux/hyperv.h   |   14 --
 2 files changed, 4 insertions(+), 27 deletions(-)

diff --git a/drivers/hv/ring_buffer.c b/drivers/hv/ring_buffer.c
index a9021f1..b0f7952 100644
--- a/drivers/hv/ring_buffer.c
+++ b/drivers/hv/ring_buffer.c
@@ -358,9 +358,6 @@ struct vmpacket_descriptor *hv_pkt_iter_first(struct 
vmbus_channel *channel)
 {
struct hv_ring_buffer_info *rbi = &channel->inbound;
 
-   /* set state for later hv_pkt_iter_close */
-   rbi->cached_read_index = rbi->ring_buffer->read_index;
-
if (hv_pkt_iter_avail(rbi) < sizeof(struct vmpacket_descriptor))
return NULL;
 
@@ -388,10 +385,7 @@ struct vmpacket_descriptor *
rbi->priv_read_index -= dsize;
 
/* more data? */
-   if (hv_pkt_iter_avail(rbi) < sizeof(struct vmpacket_descriptor))
-   return NULL;
-   else
-   return hv_get_ring_buffer(rbi) + rbi->priv_read_index;
+   return hv_pkt_iter_first(channel);
 }
 EXPORT_SYMBOL_GPL(__hv_pkt_iter_next);
 
@@ -401,7 +395,7 @@ struct vmpacket_descriptor *
 void hv_pkt_iter_close(struct vmbus_channel *channel)
 {
struct hv_ring_buffer_info *rbi = &channel->inbound;
-   u32 cur_write_sz, cached_write_sz;
+   u32 orig_write_sz = hv_get_bytes_to_write(rbi);
u32 pending_sz;
 
/*
@@ -430,13 +424,10 @@ void hv_pkt_iter_close(struct vmbus_channel *channel)
if (pending_sz == 0)
return;
 
-   cur_write_sz = hv_get_bytes_to_write(rbi);
-
-   if (cur_write_sz < pending_sz)
+   if (hv_get_bytes_to_write(rbi) < pending_sz)
return;
 
-   cached_write_sz = hv_get_cached_bytes_to_write(rbi);
-   if (cached_write_sz < pending_sz)
+   if (orig_write_sz < pending_sz)
vmbus_setevent(channel);
 }
 EXPORT_SYMBOL_GPL(hv_pkt_iter_close);
diff --git a/include/linux/hyperv.h b/include/linux/hyperv.h
index 0262267..9ede1fb 100644
--- a/include/linux/hyperv.h
+++ b/include/linux/hyperv.h
@@ -125,7 +125,6 @@ struct hv_ring_buffer_info {
 
u32 ring_datasize;  /* < ring_size */
u32 priv_read_index;
-   u32 cached_read_index;
 };
 
 /*
@@ -178,19 +177,6 @@ static inline u32 hv_get_bytes_to_write(const struct 
hv_ring_buffer_info *rbi)
return write;
 }
 
-static inline u32 hv_get_cached_bytes_to_write(
-   const struct hv_ring_buffer_info *rbi)
-{
-   u32 read_loc, write_loc, dsize, write;
-
-   dsize = rbi->ring_datasize;
-   read_loc = rbi->cached_read_index;
-   write_loc = rbi->ring_buffer->write_index;
-
-   write = write_loc >= read_loc ? dsize - (write_loc - read_loc) :
-   read_loc - write_loc;
-   return write;
-}
 /*
  * VMBUS version is 32 bit entity broken up into
  * two 16 bit quantities: major_number. minor_number.
-- 
1.7.1

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


[PATCH 5/6] vmbus: more host signalling avoidance

2017-06-25 Thread kys
From: Stephen Hemminger 

Don't signal host if it has disabled interrupts for that
ring buffer. Check the feature bit to see if host supports
pending send size flag.

Signed-off-by: Stephen Hemminger 
Signed-off-by: K. Y. Srinivasan 
---
 drivers/hv/ring_buffer.c |   27 +++
 1 files changed, 19 insertions(+), 8 deletions(-)

diff --git a/drivers/hv/ring_buffer.c b/drivers/hv/ring_buffer.c
index b0f7952..741daa6 100644
--- a/drivers/hv/ring_buffer.c
+++ b/drivers/hv/ring_buffer.c
@@ -396,7 +396,6 @@ void hv_pkt_iter_close(struct vmbus_channel *channel)
 {
struct hv_ring_buffer_info *rbi = &channel->inbound;
u32 orig_write_sz = hv_get_bytes_to_write(rbi);
-   u32 pending_sz;
 
/*
 * Make sure all reads are done before we update the read index since
@@ -419,15 +418,27 @@ void hv_pkt_iter_close(struct vmbus_channel *channel)
 */
virt_mb();
 
-   pending_sz = READ_ONCE(rbi->ring_buffer->pending_send_sz);
-   /* If the other end is not blocked on write don't bother. */
-   if (pending_sz == 0)
+   /* If host has disabled notifications then skip */
+   if (rbi->ring_buffer->interrupt_mask)
return;
 
-   if (hv_get_bytes_to_write(rbi) < pending_sz)
-   return;
+   if (rbi->ring_buffer->feature_bits.feat_pending_send_sz) {
+   u32 pending_sz = READ_ONCE(rbi->ring_buffer->pending_send_sz);
 
-   if (orig_write_sz < pending_sz)
-   vmbus_setevent(channel);
+   /*
+* If there was space before we began iteration,
+* then host was not blocked. Also handles case where
+* pending_sz is zero then host has nothing pending
+* and does not need to be signaled.
+*/
+   if (orig_write_sz > pending_sz)
+   return;
+
+   /* If pending write will not fit, don't give false hope. */
+   if (hv_get_bytes_to_write(rbi) < pending_sz)
+   return;
+   }
+
+   vmbus_setevent(channel);
 }
 EXPORT_SYMBOL_GPL(hv_pkt_iter_close);
-- 
1.7.1

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


[PATCH 0/6] Drivers: hv: vmbus: Ringbuffer cleanup and optimizations

2017-06-25 Thread kys
From: K. Y. Srinivasan 

This patch set removes unused bits from vmbus internals, and also does some
optimization to the host signalling part of ring buffer logic.

Stephen Hemminger (6):
  vmbus: simplify hv_ringbuffer_read
  vmbus: drop unused ring_buffer_info elements
  vmbus: refactor hv_signal_on_read
  vmbus: eliminate duplicate cached index
  vmbus: more host signalling avoidance
  vmbus: add prefetch to ring buffer iterator

 drivers/hv/ring_buffer.c |  169 -
 include/linux/hyperv.h   |   65 --
 2 files changed, 60 insertions(+), 174 deletions(-)

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


[PATCH 3/6] vmbus: refactor hv_signal_on_read

2017-06-25 Thread kys
From: Stephen Hemminger 

The function hv_signal_on_read was defined in hyperv.h and
only used in one place in ring_buffer code. Clearer to just
move it inline there.

Signed-off-by: Stephen Hemminger 
Signed-off-by: K. Y. Srinivasan 
---
 drivers/hv/ring_buffer.c |   32 -
 include/linux/hyperv.h   |   49 --
 2 files changed, 30 insertions(+), 51 deletions(-)

diff --git a/drivers/hv/ring_buffer.c b/drivers/hv/ring_buffer.c
index f299817..a9021f1 100644
--- a/drivers/hv/ring_buffer.c
+++ b/drivers/hv/ring_buffer.c
@@ -29,6 +29,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "hyperv_vmbus.h"
 
@@ -357,7 +358,7 @@ struct vmpacket_descriptor *hv_pkt_iter_first(struct 
vmbus_channel *channel)
 {
struct hv_ring_buffer_info *rbi = &channel->inbound;
 
-   /* set state for later hv_signal_on_read() */
+   /* set state for later hv_pkt_iter_close */
rbi->cached_read_index = rbi->ring_buffer->read_index;
 
if (hv_pkt_iter_avail(rbi) < sizeof(struct vmpacket_descriptor))
@@ -400,6 +401,8 @@ struct vmpacket_descriptor *
 void hv_pkt_iter_close(struct vmbus_channel *channel)
 {
struct hv_ring_buffer_info *rbi = &channel->inbound;
+   u32 cur_write_sz, cached_write_sz;
+   u32 pending_sz;
 
/*
 * Make sure all reads are done before we update the read index since
@@ -409,6 +412,31 @@ void hv_pkt_iter_close(struct vmbus_channel *channel)
virt_rmb();
rbi->ring_buffer->read_index = rbi->priv_read_index;
 
-   hv_signal_on_read(channel);
+   /*
+* Issue a full memory barrier before making the signaling decision.
+* Here is the reason for having this barrier:
+* If the reading of the pend_sz (in this function)
+* were to be reordered and read before we commit the new read
+* index (in the calling function)  we could
+* have a problem. If the host were to set the pending_sz after we
+* have sampled pending_sz and go to sleep before we commit the
+* read index, we could miss sending the interrupt. Issue a full
+* memory barrier to address this.
+*/
+   virt_mb();
+
+   pending_sz = READ_ONCE(rbi->ring_buffer->pending_send_sz);
+   /* If the other end is not blocked on write don't bother. */
+   if (pending_sz == 0)
+   return;
+
+   cur_write_sz = hv_get_bytes_to_write(rbi);
+
+   if (cur_write_sz < pending_sz)
+   return;
+
+   cached_write_sz = hv_get_cached_bytes_to_write(rbi);
+   if (cached_write_sz < pending_sz)
+   vmbus_setevent(channel);
 }
 EXPORT_SYMBOL_GPL(hv_pkt_iter_close);
diff --git a/include/linux/hyperv.h b/include/linux/hyperv.h
index b1549c9..0262267 100644
--- a/include/linux/hyperv.h
+++ b/include/linux/hyperv.h
@@ -1458,55 +1458,6 @@ int vmbus_send_tl_connect_request(const uuid_le 
*shv_guest_servie_id,
 }
 
 /*
- * To optimize the flow management on the send-side,
- * when the sender is blocked because of lack of
- * sufficient space in the ring buffer, potential the
- * consumer of the ring buffer can signal the producer.
- * This is controlled by the following parameters:
- *
- * 1. pending_send_sz: This is the size in bytes that the
- *producer is trying to send.
- * 2. The feature bit feat_pending_send_sz set to indicate if
- *the consumer of the ring will signal when the ring
- *state transitions from being full to a state where
- *there is room for the producer to send the pending packet.
- */
-
-static inline  void hv_signal_on_read(struct vmbus_channel *channel)
-{
-   u32 cur_write_sz, cached_write_sz;
-   u32 pending_sz;
-   struct hv_ring_buffer_info *rbi = &channel->inbound;
-
-   /*
-* Issue a full memory barrier before making the signaling decision.
-* Here is the reason for having this barrier:
-* If the reading of the pend_sz (in this function)
-* were to be reordered and read before we commit the new read
-* index (in the calling function)  we could
-* have a problem. If the host were to set the pending_sz after we
-* have sampled pending_sz and go to sleep before we commit the
-* read index, we could miss sending the interrupt. Issue a full
-* memory barrier to address this.
-*/
-   virt_mb();
-
-   pending_sz = READ_ONCE(rbi->ring_buffer->pending_send_sz);
-   /* If the other end is not blocked on write don't bother. */
-   if (pending_sz == 0)
-   return;
-
-   cur_write_sz = hv_get_bytes_to_write(rbi);
-
-   if (cur_write_sz < pending_sz)
-   return;
-
-   cached_write_sz = hv_get_cached_bytes_to_write(rbi);
-   if (cached_write_sz < pending_sz)
-   vmbus_setevent(channel);
-}
-
-/*
  * Mask off host interrupt callback notifications
  */
 static inline void hv_begin_read(struct hv_ring_buffe

RE: [PATCH 0/6] Drivers: hv: vmbus: Ringbuffer cleanup and optimizations

2017-06-25 Thread KY Srinivasan


> -Original Message-
> From: k...@exchange.microsoft.com [mailto:k...@exchange.microsoft.com]
> Sent: Sunday, June 25, 2017 11:28 AM
> To: gre...@linuxfoundation.org; linux-ker...@vger.kernel.org;
> de...@linuxdriverproject.org; o...@aepfle.de; a...@canonical.com;
> vkuzn...@redhat.com; jasow...@redhat.com;
> leann.ogasaw...@canonical.com; marcelo.ce...@canonical.com; Stephen
> Hemminger 
> Cc: KY Srinivasan 
> Subject: [PATCH 0/6] Drivers: hv: vmbus: Ringbuffer cleanup and
> optimizations
> 
> [This sender failed our fraud detection checks and may not be who they
> appear to be. Learn about spoofing at http://aka.ms/LearnAboutSpoofing]
> 
> From: K. Y. Srinivasan 
> 
> This removes unused bits from vmbus internals, and also does some
> optimization to the host signalling part of ring buffer logic.
> 
> Stephen Hemminger (6):
>   vmbus: simplify hv_ringbuffer_read
>   vmbus: drop unused ring_buffer_info elements
>   vmbus: refactor hv_signal_on_read
>   vmbus: eliminate duplicate cached index
>   vmbus: more host signalling avoidance
>   vmbus: add prefetch to ring buffer iterator
> 
>  drivers/hv/ring_buffer.c |  169 -
>  include/linux/hyperv.h   |   65 --
>  2 files changed, 60 insertions(+), 174 deletions(-)
Greg,

Please drop this; I am going to resend shortly.

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


[PATCH] staging: sm750fb: fix sparce warning.

2017-06-25 Thread AbdAllah-MEZITI
This patch fixes the following sparce warnings: different lock contexts for 
basic block.

drivers/staging/sm750fb//sm750.c:159:13: warning: context imbalance in 
'lynxfb_ops_fillrect' - different lock contexts for basic block
drivers/staging/sm750fb//sm750.c:231:9: warning: context imbalance in 
'lynxfb_ops_copyarea' - different lock contexts for basic block
drivers/staging/sm750fb//sm750.c:235:13: warning: context imbalance in 
'lynxfb_ops_imageblit' - different lock contexts for basic block

Signed-off-by: AbdAllah-MEZITI 
---
 drivers/staging/sm750fb/sm750.c | 69 -
 1 file changed, 47 insertions(+), 22 deletions(-)

diff --git a/drivers/staging/sm750fb/sm750.c b/drivers/staging/sm750fb/sm750.c
index 664c220..5494a29 100644
--- a/drivers/staging/sm750fb/sm750.c
+++ b/drivers/staging/sm750fb/sm750.c
@@ -186,16 +186,24 @@ static void lynxfb_ops_fillrect(struct fb_info *info,
 * If not use spin_lock,system will die if user load driver
 * and immediately unload driver frequently (dual)
 */
-   if (sm750_dev->fb_count > 1)
+   if (sm750_dev->fb_count > 1) {
spin_lock(&sm750_dev->slock);
 
-   sm750_dev->accel.de_fillrect(&sm750_dev->accel,
-base, pitch, Bpp,
-region->dx, region->dy,
-region->width, region->height,
-color, rop);
-   if (sm750_dev->fb_count > 1)
+   sm750_dev->accel.de_fillrect(&sm750_dev->accel,
+base, pitch, Bpp,
+region->dx, region->dy,
+region->width, region->height,
+color, rop);
+
spin_unlock(&sm750_dev->slock);
+   } else {
+   sm750_dev->accel.de_fillrect(&sm750_dev->accel,
+base, pitch, Bpp,
+region->dx, region->dy,
+region->width, region->height,
+color, rop);
+   }
+
 }
 
 static void lynxfb_ops_copyarea(struct fb_info *info,
@@ -220,16 +228,24 @@ static void lynxfb_ops_copyarea(struct fb_info *info,
 * If not use spin_lock, system will die if user load driver
 * and immediately unload driver frequently (dual)
 */
-   if (sm750_dev->fb_count > 1)
+   if (sm750_dev->fb_count > 1) {
spin_lock(&sm750_dev->slock);
 
-   sm750_dev->accel.de_copyarea(&sm750_dev->accel,
-base, pitch, region->sx, region->sy,
-base, pitch, Bpp, region->dx, region->dy,
-region->width, region->height,
-HW_ROP2_COPY);
-   if (sm750_dev->fb_count > 1)
+   sm750_dev->accel.de_copyarea(&sm750_dev->accel,
+base, pitch, region->sx, 
region->sy,
+base, pitch, Bpp, region->dx, 
region->dy,
+region->width, region->height,
+HW_ROP2_COPY);
+
spin_unlock(&sm750_dev->slock);
+   } else {
+   sm750_dev->accel.de_copyarea(&sm750_dev->accel,
+base, pitch, region->sx, 
region->sy,
+base, pitch, Bpp, region->dx, 
region->dy,
+region->width, region->height,
+HW_ROP2_COPY);
+   }
+
 }
 
 static void lynxfb_ops_imageblit(struct fb_info *info,
@@ -269,17 +285,26 @@ static void lynxfb_ops_imageblit(struct fb_info *info,
 * If not use spin_lock, system will die if user load driver
 * and immediately unload driver frequently (dual)
 */
-   if (sm750_dev->fb_count > 1)
+   if (sm750_dev->fb_count > 1) {
spin_lock(&sm750_dev->slock);
 
-   sm750_dev->accel.de_imageblit(&sm750_dev->accel,
- image->data, image->width >> 3, 0,
- base, pitch, Bpp,
- image->dx, image->dy,
- image->width, image->height,
- fgcol, bgcol, HW_ROP2_COPY);
-   if (sm750_dev->fb_count > 1)
+   sm750_dev->accel.de_imageblit(&sm750_dev->accel,
+ image->data, image->width >> 3, 0,
+ base, pitch, Bpp,
+ image->dx, image->dy,
+ image->widt

[patch v4 1/3] tty: add function to convert device name to number

2017-06-25 Thread Okash Khawaja
The function converts strings like ttyS0 and ttyUSB0 to dev_t like
(4, 64) and (188, 0). It does this by scanning tty_drivers list for
corresponding device name and index. If the driver is not registered,
this function returns -ENODEV. It also acquires tty_mutex.

Signed-off-by: Okash Khawaja 

---
 drivers/tty/tty_io.c |   50 ++
 include/linux/tty.h  |3 +++
 2 files changed, 53 insertions(+)

--- a/drivers/tty/tty_io.c
+++ b/drivers/tty/tty_io.c
@@ -325,6 +325,56 @@ static struct tty_driver *get_tty_driver
return NULL;
 }
 
+/**
+ * tty_dev_name_to_number  -   return dev_t for device name
+ * @name: user space name of device under /dev
+ * @number: pointer to dev_t that this function will populate
+ *
+ * This function converts device names like ttyS0 or ttyUSB1 into dev_t
+ * like (4, 64) or (188, 1). If no corresponding driver is registered then
+ * the function returns -ENODEV.
+ *
+ * Locking: this acquires tty_mutex to protect the tty_drivers list from
+ * being modified while we are traversing it, and makes sure to
+ * release it before exiting.
+ */
+int tty_dev_name_to_number(const char *name, dev_t *number)
+{
+   struct tty_driver *p;
+   int ret;
+   int index, prefix_length = 0;
+   const char *str;
+
+   for (str = name; *str && !isdigit(*str); str++)
+   ;
+
+   if (!*str)
+   return -EINVAL;
+
+   ret = kstrtoint(str, 10, &index);
+   if (ret)
+   return ret;
+
+   prefix_length = str - name;
+   mutex_lock(&tty_mutex);
+
+   list_for_each_entry(p, &tty_drivers, tty_drivers)
+   if (prefix_length == strlen(p->name) && strncmp(name,
+   p->name, prefix_length) == 0) {
+   if (index < p->num) {
+   *number = MKDEV(p->major, p->minor_start + 
index);
+   goto out;
+   }
+   }
+
+   /* if here then driver wasn't found */
+   ret = -ENODEV;
+out:
+   mutex_unlock(&tty_mutex);
+   return ret;
+}
+EXPORT_SYMBOL_GPL(tty_dev_name_to_number);
+
 #ifdef CONFIG_CONSOLE_POLL
 
 /**
--- a/include/linux/tty.h
+++ b/include/linux/tty.h
@@ -401,6 +401,7 @@ extern int __init tty_init(void);
 extern const char *tty_name(const struct tty_struct *tty);
 extern struct tty_struct *tty_open_by_driver(dev_t device, struct inode *inode,
struct file *filp);
+extern int tty_dev_name_to_number(const char *name, dev_t *number);
 #else
 static inline void tty_kref_put(struct tty_struct *tty)
 { }
@@ -424,6 +425,8 @@ static inline const char *tty_name(const
 static inline struct tty_struct *tty_open_by_driver(dev_t device,
struct inode *inode, struct file *filp)
 { return NULL; }
+static inline int tty_dev_name_to_number(const char *name, dev_t *number)
+{ return -ENOTSUPP; }
 #endif
 
 extern struct ktermios tty_std_termios;

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


[patch v4 2/3] staging: speakup: check and convert dev name or ser to dev_t

2017-06-25 Thread Okash Khawaja
This patch adds functionality to validate and convert either a device
name or 'ser' memmber of synth into dev_t. Subsequent patch in this set
will call it to convert user-specified device into device number. For
device name, this patch does some basic sanity checks on the string
passed in. It currently supports ttyS*, ttyUSB* and, for selected
synths, lp*.

The patch also introduces a string member variable named 'dev_name' to
struct spk_synth. 'dev_name' represents the device name - ttyUSB0 etc -
which needs conversion to dev_t.

Signed-off-by: Okash Khawaja 
Reviewed-by: Andy Shevchenko 

---
 drivers/staging/speakup/spk_priv.h  |2 +
 drivers/staging/speakup/spk_ttyio.c |   42 
 drivers/staging/speakup/spk_types.h |1 
 3 files changed, 45 insertions(+)

--- a/drivers/staging/speakup/spk_priv.h
+++ b/drivers/staging/speakup/spk_priv.h
@@ -40,6 +40,8 @@
 
 #define KT_SPKUP 15
 #define SPK_SYNTH_TIMEOUT 10 /* in micro-seconds */
+#define SYNTH_DEFAULT_DEV "ttyS0"
+#define SYNTH_DEFAULT_SER 0
 
 const struct old_serial_port *spk_serial_init(int index);
 void spk_stop_serial_interrupt(void);
--- a/drivers/staging/speakup/spk_ttyio.c
+++ b/drivers/staging/speakup/spk_ttyio.c
@@ -7,6 +7,11 @@
 #include "spk_types.h"
 #include "spk_priv.h"
 
+#define DEV_PREFIX_LP "lp"
+
+static const char * const lp_supported[] = { "acntsa", "bns", "dummy",
+   "txprt" };
+
 struct spk_ldisc_data {
char buf;
struct semaphore sem;
@@ -16,6 +21,43 @@ struct spk_ldisc_data {
 static struct spk_synth *spk_ttyio_synth;
 static struct tty_struct *speakup_tty;
 
+int ser_to_dev(int ser, dev_t *dev_no)
+{
+   if (ser < 0 || ser > (255 - 64)) {
+   pr_err("speakup: Invalid ser param. Must be between 0 and 191 
inclusive.\n");
+   return -EINVAL;
+   }
+
+   *dev_no = MKDEV(4, (64 + ser));
+   return 0;
+}
+
+static int get_dev_to_use(struct spk_synth *synth, dev_t *dev_no)
+{
+   /* use ser only when dev is not specified */
+   if (strcmp(synth->dev_name, SYNTH_DEFAULT_DEV) ||
+   synth->ser == SYNTH_DEFAULT_SER) {
+   /* for /dev/lp* check if synth is supported */
+   if (strncmp(synth->dev_name, DEV_PREFIX_LP,
+   strlen(DEV_PREFIX_LP)) == 0)
+   if (match_string(lp_supported, ARRAY_SIZE(lp_supported),
+   synth->name) < 0)  {
+   int i;
+
+   pr_err("speakup: lp* is only supported on:");
+   for (i = 0; i < ARRAY_SIZE(lp_supported); i++)
+   pr_cont(" %s", lp_supported[i]);
+   pr_cont("\n");
+
+   return -ENOTSUPP;
+   }
+
+   return tty_dev_name_to_number(synth->dev_name, dev_no);
+   }
+
+   return ser_to_dev(synth->ser, dev_no);
+}
+
 static int spk_ttyio_ldisc_open(struct tty_struct *tty)
 {
struct spk_ldisc_data *ldisc_data;
--- a/drivers/staging/speakup/spk_types.h
+++ b/drivers/staging/speakup/spk_types.h
@@ -169,6 +169,7 @@ struct spk_synth {
int jiffies;
int full;
int ser;
+   char *dev_name;
short flags;
short startup;
const int checkval; /* for validating a proper synth module */

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


[patch v4 3/3] staging: speakup: make ttyio synths use device name

2017-06-25 Thread Okash Khawaja
This patch introduces new module parameter, dev, which takes a string
representing the device that the external synth is connected to, e.g.
ttyS0, ttyUSB0 etc. This is then used to communicate with the synth.
That way, speakup can support more than ttyS*. As of this patch, it
only supports ttyS*, ttyUSB* and selected synths for lp*. dev parameter
is only available for tty-migrated synths.

Users will either use dev or ser as both serve same purpose. This patch
maintains backward compatility by allowing ser to be specified. When
both are specified, whichever is non-default, i.e. not ttyS0, is used.
If both are non-default then dev is used.

Signed-off-by: Okash Khawaja 
Reviewed-by: Samuel Thibault 
Reviewed-by: Andy Shevchenko 

---
 drivers/staging/speakup/speakup_acntsa.c |3 +++
 drivers/staging/speakup/speakup_apollo.c |3 +++
 drivers/staging/speakup/speakup_audptr.c |3 +++
 drivers/staging/speakup/speakup_bns.c|3 +++
 drivers/staging/speakup/speakup_decext.c |3 +++
 drivers/staging/speakup/speakup_dectlk.c |3 +++
 drivers/staging/speakup/speakup_dummy.c  |3 +++
 drivers/staging/speakup/speakup_ltlk.c   |3 +++
 drivers/staging/speakup/speakup_spkout.c |3 +++
 drivers/staging/speakup/speakup_txprt.c  |3 +++
 drivers/staging/speakup/spk_ttyio.c  |   15 +++
 11 files changed, 37 insertions(+), 8 deletions(-)

--- a/drivers/staging/speakup/speakup_acntsa.c
+++ b/drivers/staging/speakup/speakup_acntsa.c
@@ -96,6 +96,7 @@ static struct spk_synth synth_acntsa = {
.trigger = 50,
.jiffies = 30,
.full = 4,
+   .dev_name = SYNTH_DEFAULT_DEV,
.startup = SYNTH_START,
.checkval = SYNTH_CHECK,
.vars = vars,
@@ -135,9 +136,11 @@ static int synth_probe(struct spk_synth
 }
 
 module_param_named(ser, synth_acntsa.ser, int, 0444);
+module_param_named(dev, synth_acntsa.dev_name, charp, S_IRUGO);
 module_param_named(start, synth_acntsa.startup, short, 0444);
 
 MODULE_PARM_DESC(ser, "Set the serial port for the synthesizer (0-based).");
+MODULE_PARM_DESC(dev, "Set the device e.g. ttyUSB0, for the synthesizer.");
 MODULE_PARM_DESC(start, "Start the synthesizer once it is loaded.");
 
 module_spk_synth(synth_acntsa);
--- a/drivers/staging/speakup/speakup_apollo.c
+++ b/drivers/staging/speakup/speakup_apollo.c
@@ -105,6 +105,7 @@ static struct spk_synth synth_apollo = {
.trigger = 50,
.jiffies = 50,
.full = 4,
+   .dev_name = SYNTH_DEFAULT_DEV,
.startup = SYNTH_START,
.checkval = SYNTH_CHECK,
.vars = vars,
@@ -199,9 +200,11 @@ static void do_catch_up(struct spk_synth
 }
 
 module_param_named(ser, synth_apollo.ser, int, 0444);
+module_param_named(dev, synth_apollo.dev_name, charp, S_IRUGO);
 module_param_named(start, synth_apollo.startup, short, 0444);
 
 MODULE_PARM_DESC(ser, "Set the serial port for the synthesizer (0-based).");
+MODULE_PARM_DESC(dev, "Set the device e.g. ttyUSB0, for the synthesizer.");
 MODULE_PARM_DESC(start, "Start the synthesizer once it is loaded.");
 
 module_spk_synth(synth_apollo);
--- a/drivers/staging/speakup/speakup_audptr.c
+++ b/drivers/staging/speakup/speakup_audptr.c
@@ -100,6 +100,7 @@ static struct spk_synth synth_audptr = {
.trigger = 50,
.jiffies = 30,
.full = 18000,
+   .dev_name = SYNTH_DEFAULT_DEV,
.startup = SYNTH_START,
.checkval = SYNTH_CHECK,
.vars = vars,
@@ -162,9 +163,11 @@ static int synth_probe(struct spk_synth
 }
 
 module_param_named(ser, synth_audptr.ser, int, 0444);
+module_param_named(dev, synth_audptr.dev_name, charp, S_IRUGO);
 module_param_named(start, synth_audptr.startup, short, 0444);
 
 MODULE_PARM_DESC(ser, "Set the serial port for the synthesizer (0-based).");
+MODULE_PARM_DESC(dev, "Set the device e.g. ttyUSB0, for the synthesizer.");
 MODULE_PARM_DESC(start, "Start the synthesizer once it is loaded.");
 
 module_spk_synth(synth_audptr);
--- a/drivers/staging/speakup/speakup_bns.c
+++ b/drivers/staging/speakup/speakup_bns.c
@@ -93,6 +93,7 @@ static struct spk_synth synth_bns = {
.trigger = 50,
.jiffies = 50,
.full = 4,
+   .dev_name = SYNTH_DEFAULT_DEV,
.startup = SYNTH_START,
.checkval = SYNTH_CHECK,
.vars = vars,
@@ -119,9 +120,11 @@ static struct spk_synth synth_bns = {
 };
 
 module_param_named(ser, synth_bns.ser, int, 0444);
+module_param_named(dev, synth_bns.dev_name, charp, S_IRUGO);
 module_param_named(start, synth_bns.startup, short, 0444);
 
 MODULE_PARM_DESC(ser, "Set the serial port for the synthesizer (0-based).");
+MODULE_PARM_DESC(dev, "Set the device e.g. ttyUSB0, for the synthesizer.");
 MODULE_PARM_DESC(start, "Start the synthesizer once it is loaded.");
 
 module_spk_synth(synth_bns);
--- a/drivers/staging/speakup/speakup_decext.c
+++ b/drivers/staging/speakup/speakup_decext.c
@@ -120,6 +120,7 @@ static struct spk_synth synth_decext = {
.jiffies = 50,
.fu

[patch v4 0/3] staging: speakup: support more than ttyS*

2017-06-25 Thread Okash Khawaja
Hi,

v3 of this patch set introduced the compiler warning:

drivers//tty/tty_io.c:348:11: warning: assignment discards 'const'
qualifier from pointer target type [-Wdiscarded-qualifiers]

This version fixes that warning in patch 1/3.

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


[PATCH 0/6] Drivers: hv: vmbus: Ringbuffer cleanup and optimizations

2017-06-25 Thread kys
From: K. Y. Srinivasan 

This removes unused bits from vmbus internals, and also does some
optimization to the host signalling part of ring buffer logic.

Stephen Hemminger (6):
  vmbus: simplify hv_ringbuffer_read
  vmbus: drop unused ring_buffer_info elements
  vmbus: refactor hv_signal_on_read
  vmbus: eliminate duplicate cached index
  vmbus: more host signalling avoidance
  vmbus: add prefetch to ring buffer iterator

 drivers/hv/ring_buffer.c |  169 -
 include/linux/hyperv.h   |   65 --
 2 files changed, 60 insertions(+), 174 deletions(-)

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


Re: [staging:staging-testing 383/386] drivers//tty/tty_io.c:348:11: warning: assignment discards 'const' qualifier from pointer target type

2017-06-25 Thread Greg Kroah-Hartman
On Sun, Jun 25, 2017 at 06:39:08PM +0100, Okash Khawaja wrote:
> Hi,
> 
> On Mon, Jun 26, 2017 at 01:24:43AM +0800, kbuild test robot wrote:
> > tree:   https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git 
> > staging-testing
> > head:   2a38eb6552c934a13e1f1b8c579147fac9c94efb
> > commit: 9a71d0257f1f63d64015f7d2c25485272df4d535 [383/386] tty: add 
> > function to convert device name to number
> > config: blackfin-allyesconfig (attached as .config)
> > compiler: bfin-uclinux-gcc (GCC) 6.2.0
> > reproduce:
> > wget 
> > https://raw.githubusercontent.com/01org/lkp-tests/master/sbin/make.cross -O 
> > ~/bin/make.cross
> > chmod +x ~/bin/make.cross
> > git checkout 9a71d0257f1f63d64015f7d2c25485272df4d535
> > # save the attached .config to linux build tree
> > make.cross ARCH=blackfin 
> > 
> > All warnings (new ones prefixed by >>):
> > 
> >drivers//tty/tty_io.c: In function 'tty_dev_name_to_number':
> > >> drivers//tty/tty_io.c:348:11: warning: assignment discards 'const' 
> > >> qualifier from pointer target type [-Wdiscarded-qualifiers]
> >  for (str = name; *str && !isdigit(*str); str++)
> >   ^
> How to send fix for this? Can I resend just this patch as v2? Or resend
> the patch set as v4 (it was a v3 last time).

Resend it as v4 and I can replace this.  Sorry I missed the build
warning, I should have caught it myself.

thanks,

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


Re: [staging:staging-testing 383/386] drivers//tty/tty_io.c:348:11: warning: assignment discards 'const' qualifier from pointer target type

2017-06-25 Thread Okash Khawaja
Hi,

On Mon, Jun 26, 2017 at 01:24:43AM +0800, kbuild test robot wrote:
> tree:   https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git 
> staging-testing
> head:   2a38eb6552c934a13e1f1b8c579147fac9c94efb
> commit: 9a71d0257f1f63d64015f7d2c25485272df4d535 [383/386] tty: add function 
> to convert device name to number
> config: blackfin-allyesconfig (attached as .config)
> compiler: bfin-uclinux-gcc (GCC) 6.2.0
> reproduce:
> wget 
> https://raw.githubusercontent.com/01org/lkp-tests/master/sbin/make.cross -O 
> ~/bin/make.cross
> chmod +x ~/bin/make.cross
> git checkout 9a71d0257f1f63d64015f7d2c25485272df4d535
> # save the attached .config to linux build tree
> make.cross ARCH=blackfin 
> 
> All warnings (new ones prefixed by >>):
> 
>drivers//tty/tty_io.c: In function 'tty_dev_name_to_number':
> >> drivers//tty/tty_io.c:348:11: warning: assignment discards 'const' 
> >> qualifier from pointer target type [-Wdiscarded-qualifiers]
>  for (str = name; *str && !isdigit(*str); str++)
>   ^
How to send fix for this? Can I resend just this patch as v2? Or resend
the patch set as v4 (it was a v3 last time).

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


[staging:staging-testing 383/386] drivers//tty/tty_io.c:348:11: warning: assignment discards 'const' qualifier from pointer target type

2017-06-25 Thread kbuild test robot
tree:   https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git 
staging-testing
head:   2a38eb6552c934a13e1f1b8c579147fac9c94efb
commit: 9a71d0257f1f63d64015f7d2c25485272df4d535 [383/386] tty: add function to 
convert device name to number
config: blackfin-allyesconfig (attached as .config)
compiler: bfin-uclinux-gcc (GCC) 6.2.0
reproduce:
wget 
https://raw.githubusercontent.com/01org/lkp-tests/master/sbin/make.cross -O 
~/bin/make.cross
chmod +x ~/bin/make.cross
git checkout 9a71d0257f1f63d64015f7d2c25485272df4d535
# save the attached .config to linux build tree
make.cross ARCH=blackfin 

All warnings (new ones prefixed by >>):

   drivers//tty/tty_io.c: In function 'tty_dev_name_to_number':
>> drivers//tty/tty_io.c:348:11: warning: assignment discards 'const' qualifier 
>> from pointer target type [-Wdiscarded-qualifiers]
 for (str = name; *str && !isdigit(*str); str++)
  ^

vim +/const +348 drivers//tty/tty_io.c

   332   *
   333   *  This function converts device names like ttyS0 or ttyUSB1 into 
dev_t
   334   *  like (4, 64) or (188, 1). If no corresponding driver is 
registered then
   335   *  the function returns -ENODEV.
   336   *
   337   *  Locking: this acquires tty_mutex to protect the tty_drivers 
list from
   338   *  being modified while we are traversing it, and makes 
sure to
   339   *  release it before exiting.
   340   */
   341  int tty_dev_name_to_number(const char *name, dev_t *number)
   342  {
   343  struct tty_driver *p;
   344  int ret;
   345  int index, prefix_length = 0;
   346  char *str;
   347  
 > 348  for (str = name; *str && !isdigit(*str); str++)
   349  ;
   350  
   351  if (!*str)
   352  return -EINVAL;
   353  
   354  ret = kstrtoint(str, 10, &index);
   355  if (ret)
   356  return ret;

---
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


[PATCH 07/10] hyper-v: globalize vp_index

2017-06-25 Thread kys
From: Vitaly Kuznetsov 

To support implementing remote TLB flushing on Hyper-V with a hypercall
we need to make vp_index available outside of vmbus module. Rename and
globalize.

Signed-off-by: Vitaly Kuznetsov 
Reviewed-by: Andy Shevchenko 
Signed-off-by: K. Y. Srinivasan 
---
 arch/x86/hyperv/hv_init.c   |   34 +-
 arch/x86/include/asm/mshyperv.h |   24 
 drivers/hv/channel_mgmt.c   |7 +++
 drivers/hv/connection.c |3 ++-
 drivers/hv/hv.c |9 -
 drivers/hv/hyperv_vmbus.h   |   11 ---
 drivers/hv/vmbus_drv.c  |   17 -
 drivers/pci/host/pci-hyperv.c   |   10 +-
 include/linux/hyperv.h  |1 -
 9 files changed, 67 insertions(+), 49 deletions(-)

diff --git a/arch/x86/hyperv/hv_init.c b/arch/x86/hyperv/hv_init.c
index 691603e..e93b9a0 100644
--- a/arch/x86/hyperv/hv_init.c
+++ b/arch/x86/hyperv/hv_init.c
@@ -26,6 +26,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 
 #ifdef CONFIG_HYPERV_TSCPAGE
 
@@ -80,6 +82,20 @@ static u64 read_hv_clock_msr(struct clocksource *arg)
 struct clocksource *hyperv_cs;
 EXPORT_SYMBOL_GPL(hyperv_cs);
 
+u32 *hv_vp_index;
+EXPORT_SYMBOL_GPL(hv_vp_index);
+
+static int hv_cpu_init(unsigned int cpu)
+{
+   u64 msr_vp_index;
+
+   hv_get_vp_index(msr_vp_index);
+
+   hv_vp_index[smp_processor_id()] = msr_vp_index;
+
+   return 0;
+}
+
 /*
  * This function is to be invoked early in the boot sequence after the
  * hypervisor has been detected.
@@ -95,6 +111,16 @@ void hyperv_init(void)
if (x86_hyper != &x86_hyper_ms_hyperv)
return;
 
+   /* Allocate percpu VP index */
+   hv_vp_index = kmalloc_array(num_possible_cpus(), sizeof(*hv_vp_index),
+   GFP_KERNEL);
+   if (!hv_vp_index)
+   return;
+
+   if (cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, "x86/hyperv_init:online",
+ hv_cpu_init, NULL) < 0)
+   goto free_vp_index;
+
/*
 * Setup the hypercall page and enable hypercalls.
 * 1. Register the guest ID
@@ -106,7 +132,7 @@ void hyperv_init(void)
hv_hypercall_pg  = __vmalloc(PAGE_SIZE, GFP_KERNEL, PAGE_KERNEL_RX);
if (hv_hypercall_pg == NULL) {
wrmsrl(HV_X64_MSR_GUEST_OS_ID, 0);
-   return;
+   goto free_vp_index;
}
 
rdmsrl(HV_X64_MSR_HYPERCALL, hypercall_msr.as_uint64);
@@ -149,6 +175,12 @@ void hyperv_init(void)
hyperv_cs = &hyperv_cs_msr;
if (ms_hyperv.features & HV_X64_MSR_TIME_REF_COUNT_AVAILABLE)
clocksource_register_hz(&hyperv_cs_msr, NSEC_PER_SEC/100);
+
+   return;
+
+free_vp_index:
+   kfree(hv_vp_index);
+   hv_vp_index = NULL;
 }
 
 /*
diff --git a/arch/x86/include/asm/mshyperv.h b/arch/x86/include/asm/mshyperv.h
index ed8107d..7581251 100644
--- a/arch/x86/include/asm/mshyperv.h
+++ b/arch/x86/include/asm/mshyperv.h
@@ -284,6 +284,30 @@ static inline u64 hv_do_rep_hypercall(u16 code, u16 
rep_count, u16 varhead_size,
return status;
 }
 
+/*
+ * Hypervisor's notion of virtual processor ID is different from
+ * Linux' notion of CPU ID. This information can only be retrieved
+ * in the context of the calling CPU. Setup a map for easy access
+ * to this information.
+ */
+extern u32 *hv_vp_index;
+
+/**
+ * hv_cpu_number_to_vp_number() - Map CPU to VP.
+ * @cpu_number: CPU number in Linux terms
+ *
+ * This function returns the mapping between the Linux processor
+ * number and the hypervisor's virtual processor number, useful
+ * in making hypercalls and such that talk about specific
+ * processors.
+ *
+ * Return: Virtual processor number in Hyper-V terms
+ */
+static inline int hv_cpu_number_to_vp_number(int cpu_number)
+{
+   return hv_vp_index[cpu_number];
+}
+
 void hyperv_init(void);
 void hyperv_report_panic(struct pt_regs *regs);
 bool hv_is_hypercall_page_setup(void);
diff --git a/drivers/hv/channel_mgmt.c b/drivers/hv/channel_mgmt.c
index f501ce1..331b314 100644
--- a/drivers/hv/channel_mgmt.c
+++ b/drivers/hv/channel_mgmt.c
@@ -600,7 +600,7 @@ static void init_vp_index(struct vmbus_channel *channel, 
u16 dev_type)
 */
channel->numa_node = 0;
channel->target_cpu = 0;
-   channel->target_vp = hv_context.vp_index[0];
+   channel->target_vp = hv_cpu_number_to_vp_number(0);
return;
}
 
@@ -684,7 +684,7 @@ static void init_vp_index(struct vmbus_channel *channel, 
u16 dev_type)
}
 
channel->target_cpu = cur_cpu;
-   channel->target_vp = hv_context.vp_index[cur_cpu];
+   channel->target_vp = hv_cpu_number_to_vp_number(cur_cpu);
 }
 
 static void vmbus_wait_for_unload(void)
@@ -1220,8 +1220,7 @@ struct vmbus_channel *vmbus_get_outgoing_channel(struct 
vmbus_channel *primary)
return ou

[PATCH 08/10] x86/hyper-v: use hypercall for remote TLB flush

2017-06-25 Thread kys
From: Vitaly Kuznetsov 

Hyper-V host can suggest us to use hypercall for doing remote TLB flush,
this is supposed to work faster than IPIs.

Implementation details: to do HvFlushVirtualAddress{Space,List} hypercalls
we need to put the input somewhere in memory and we don't really want to
have memory allocation on each call so we pre-allocate per cpu memory areas
on boot.

pv_ops patching is happening very early so we need to separate
hyperv_setup_mmu_ops() and hyper_alloc_mmu().

It is possible and easy to implement local TLB flushing too and there is
even a hint for that. However, I don't see a room for optimization on the
host side as both hypercall and native tlb flush will result in vmexit. The
hint is also not set on modern Hyper-V versions.

Signed-off-by: Vitaly Kuznetsov 
Signed-off-by: K. Y. Srinivasan 
---
 arch/x86/hyperv/Makefile   |2 +-
 arch/x86/hyperv/hv_init.c  |2 +
 arch/x86/hyperv/mmu.c  |  135 
 arch/x86/include/asm/mshyperv.h|4 +
 arch/x86/include/uapi/asm/hyperv.h |7 ++
 arch/x86/kernel/cpu/mshyperv.c |1 +
 6 files changed, 150 insertions(+), 1 deletions(-)
 create mode 100644 arch/x86/hyperv/mmu.c

diff --git a/arch/x86/hyperv/Makefile b/arch/x86/hyperv/Makefile
index 171ae09..367a820 100644
--- a/arch/x86/hyperv/Makefile
+++ b/arch/x86/hyperv/Makefile
@@ -1 +1 @@
-obj-y  := hv_init.o
+obj-y  := hv_init.o mmu.o
diff --git a/arch/x86/hyperv/hv_init.c b/arch/x86/hyperv/hv_init.c
index e93b9a0..1a8eb55 100644
--- a/arch/x86/hyperv/hv_init.c
+++ b/arch/x86/hyperv/hv_init.c
@@ -140,6 +140,8 @@ void hyperv_init(void)
hypercall_msr.guest_physical_address = vmalloc_to_pfn(hv_hypercall_pg);
wrmsrl(HV_X64_MSR_HYPERCALL, hypercall_msr.as_uint64);
 
+   hyper_alloc_mmu();
+
/*
 * Register Hyper-V specific clocksource.
 */
diff --git a/arch/x86/hyperv/mmu.c b/arch/x86/hyperv/mmu.c
new file mode 100644
index 000..fe87ffe
--- /dev/null
+++ b/arch/x86/hyperv/mmu.c
@@ -0,0 +1,135 @@
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+
+/* HvFlushVirtualAddressSpace, HvFlushVirtualAddressList hypercalls */
+struct hv_flush_pcpu {
+   u64 address_space;
+   u64 flags;
+   u64 processor_mask;
+   u64 gva_list[];
+};
+
+/* Each gva in gva_list encodes up to 4096 pages to flush */
+#define HV_TLB_FLUSH_UNIT (4096 * PAGE_SIZE)
+
+static struct hv_flush_pcpu __percpu *pcpu_flush;
+
+/*
+ * Fills in gva_list starting from offset. Returns the number of items filled
+ * in gva_list (including offset)
+ */
+static inline int fill_gva_list(u64 gva_list[], int offset,
+   unsigned long start, unsigned long end)
+{
+   int gva_n = offset;
+   unsigned long cur = start, diff;
+
+   do {
+   diff = end > cur ? end - cur : 0;
+
+   gva_list[gva_n] = cur & PAGE_MASK;
+   /*
+* Lower 12 bits encode the number of additional
+* pages to flush (in addition to the 'cur' page).
+*/
+   if (diff >= HV_TLB_FLUSH_UNIT)
+   gva_list[gva_n] |= ~PAGE_MASK;
+   else if (diff)
+   gva_list[gva_n] |= (diff - 1) >> PAGE_SHIFT;
+
+   cur += HV_TLB_FLUSH_UNIT;
+   gva_n++;
+
+   } while (cur < end);
+
+   return gva_n;
+}
+
+static void hyperv_flush_tlb_others(const struct cpumask *cpus,
+   struct mm_struct *mm, unsigned long start,
+   unsigned long end)
+{
+   int cpu, vcpu, gva_n, max_gvas;
+   struct hv_flush_pcpu *flush;
+   u64 status = U64_MAX;
+   unsigned long flags;
+
+   if (!pcpu_flush || !hv_hypercall_pg)
+   goto do_native;
+
+   if (cpumask_empty(cpus))
+   return;
+
+   local_irq_save(flags);
+
+   flush = this_cpu_ptr(pcpu_flush);
+
+   if (mm) {
+   flush->address_space = virt_to_phys(mm->pgd);
+   flush->flags = 0;
+   } else {
+   flush->address_space = 0;
+   flush->flags = HV_FLUSH_ALL_VIRTUAL_ADDRESS_SPACES;
+   }
+
+   flush->processor_mask = 0;
+   if (cpumask_equal(cpus, cpu_present_mask)) {
+   flush->flags |= HV_FLUSH_ALL_PROCESSORS;
+   } else {
+   for_each_cpu(cpu, cpus) {
+   vcpu = hv_cpu_number_to_vp_number(cpu);
+   if (vcpu < 64)
+   __set_bit(vcpu, (unsigned long *)
+ &flush->processor_mask);
+   else
+   goto do_native;
+   }
+   }
+
+   /*
+* We can flush not more than max_gvas with one hypercall. Flush the
+* whole address space if we were asked to do more.
+*/
+  

[PATCH 10/10] tracing/hyper-v: trace hyperv_mmu_flush_tlb_others()

2017-06-25 Thread kys
From: Vitaly Kuznetsov 

Add Hyper-V tracing subsystem and trace hyperv_mmu_flush_tlb_others().
Tracing is done the same way we do xen_mmu_flush_tlb_others().

Signed-off-by: Vitaly Kuznetsov 
Signed-off-by: K. Y. Srinivasan 
---
 MAINTAINERS |1 +
 arch/x86/hyperv/mmu.c   |7 ++
 arch/x86/include/asm/trace/hyperv.h |   38 +++
 3 files changed, 46 insertions(+), 0 deletions(-)
 create mode 100644 arch/x86/include/asm/trace/hyperv.h

diff --git a/MAINTAINERS b/MAINTAINERS
index 2e7c834..a0967d9 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -6169,6 +6169,7 @@ M:Stephen Hemminger 
 L: de...@linuxdriverproject.org
 S: Maintained
 F: arch/x86/include/asm/mshyperv.h
+F: arch/x86/include/asm/trace/hyperv.h
 F: arch/x86/include/uapi/asm/hyperv.h
 F: arch/x86/kernel/cpu/mshyperv.c
 F: arch/x86/hyperv
diff --git a/arch/x86/hyperv/mmu.c b/arch/x86/hyperv/mmu.c
index 0712111..cb35453 100644
--- a/arch/x86/hyperv/mmu.c
+++ b/arch/x86/hyperv/mmu.c
@@ -8,6 +8,9 @@
 #include 
 #include 
 
+#define CREATE_TRACE_POINTS
+#include 
+
 /* HvFlushVirtualAddressSpace, HvFlushVirtualAddressList hypercalls */
 struct hv_flush_pcpu {
u64 address_space;
@@ -103,6 +106,8 @@ static void hyperv_flush_tlb_others(const struct cpumask 
*cpus,
u64 status = U64_MAX;
unsigned long flags;
 
+   trace_hyperv_mmu_flush_tlb_others(cpus, mm, start, end);
+
if (!pcpu_flush || !hv_hypercall_pg)
goto do_native;
 
@@ -172,6 +177,8 @@ static void hyperv_flush_tlb_others_ex(const struct cpumask 
*cpus,
u64 status = U64_MAX;
unsigned long flags;
 
+   trace_hyperv_mmu_flush_tlb_others(cpus, mm, start, end);
+
if (!pcpu_flush_ex || !hv_hypercall_pg)
goto do_native;
 
diff --git a/arch/x86/include/asm/trace/hyperv.h 
b/arch/x86/include/asm/trace/hyperv.h
new file mode 100644
index 000..e44ece1
--- /dev/null
+++ b/arch/x86/include/asm/trace/hyperv.h
@@ -0,0 +1,38 @@
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM hyperv
+
+#if !defined(_TRACE_HYPERV_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _TRACE_HYPERV_H
+
+#include 
+
+#if IS_ENABLED(CONFIG_HYPERV)
+
+TRACE_EVENT(hyperv_mmu_flush_tlb_others,
+   TP_PROTO(const struct cpumask *cpus, struct mm_struct *mm,
+unsigned long addr, unsigned long end),
+   TP_ARGS(cpus, mm, addr, end),
+   TP_STRUCT__entry(
+   __field(unsigned int, ncpus)
+   __field(struct mm_struct *, mm)
+   __field(unsigned long, addr)
+   __field(unsigned long, end)
+   ),
+   TP_fast_assign(__entry->ncpus = cpumask_weight(cpus);
+  __entry->mm = mm;
+  __entry->addr = addr,
+  __entry->end = end),
+   TP_printk("ncpus %d mm %p addr %lx, end %lx",
+ __entry->ncpus, __entry->mm, __entry->addr, __entry->end)
+   );
+
+#endif /* CONFIG_HYPERV */
+
+#undef TRACE_INCLUDE_PATH
+#define TRACE_INCLUDE_PATH asm/trace/
+#undef TRACE_INCLUDE_FILE
+#define TRACE_INCLUDE_FILE hyperv
+#endif /* _TRACE_HYPERV_H */
+
+/* This part must be outside protection */
+#include 
-- 
1.7.1

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


[PATCH 09/10] x86/hyper-v: support extended CPU ranges for TLB flush hypercalls

2017-06-25 Thread kys
From: Vitaly Kuznetsov 

Hyper-V hosts may support more than 64 vCPUs, we need to use
HVCALL_FLUSH_VIRTUAL_ADDRESS_SPACE_EX/LIST_EX hypercalls in this
case.

Signed-off-by: Vitaly Kuznetsov 
Signed-off-by: K. Y. Srinivasan 
---
 arch/x86/hyperv/mmu.c  |  130 +++-
 arch/x86/include/uapi/asm/hyperv.h |   10 +++
 2 files changed, 138 insertions(+), 2 deletions(-)

diff --git a/arch/x86/hyperv/mmu.c b/arch/x86/hyperv/mmu.c
index fe87ffe..0712111 100644
--- a/arch/x86/hyperv/mmu.c
+++ b/arch/x86/hyperv/mmu.c
@@ -16,11 +16,25 @@ struct hv_flush_pcpu {
u64 gva_list[];
 };
 
+/* HvFlushVirtualAddressSpaceEx, HvFlushVirtualAddressListEx hypercalls */
+struct hv_flush_pcpu_ex {
+   u64 address_space;
+   u64 flags;
+   struct {
+   u64 format;
+   u64 valid_bank_mask;
+   u64 bank_contents[];
+   } hv_vp_set;
+   u64 gva_list[];
+};
+
 /* Each gva in gva_list encodes up to 4096 pages to flush */
 #define HV_TLB_FLUSH_UNIT (4096 * PAGE_SIZE)
 
 static struct hv_flush_pcpu __percpu *pcpu_flush;
 
+static struct hv_flush_pcpu_ex __percpu *pcpu_flush_ex;
+
 /*
  * Fills in gva_list starting from offset. Returns the number of items filled
  * in gva_list (including offset)
@@ -52,6 +66,34 @@ static inline int fill_gva_list(u64 gva_list[], int offset,
return gva_n;
 }
 
+/* Return the number of banks in the resulting vp_set */
+static inline int cpumask_to_vp_set(struct hv_flush_pcpu_ex *flush,
+   const struct cpumask *cpus)
+{
+   int cpu, vcpu, vcpu_bank, vcpu_offset, nr_bank = 1;
+
+   /*
+* Some banks may end up being empty but this is acceptable.
+*/
+   for_each_cpu(cpu, cpus) {
+   vcpu = hv_cpu_number_to_vp_number(cpu);
+   vcpu_bank = vcpu / 64;
+   vcpu_offset = vcpu % 64;
+
+   /* valid_bank_mask can represent up to 64 banks */
+   if (vcpu_bank >= 64)
+   return 0;
+
+   __set_bit(vcpu_offset, (unsigned long *)
+ &flush->hv_vp_set.bank_contents[vcpu_bank]);
+   if (vcpu_bank >= nr_bank)
+   nr_bank = vcpu_bank + 1;
+   }
+   flush->hv_vp_set.valid_bank_mask = GENMASK_ULL(nr_bank - 1, 0);
+
+   return nr_bank;
+}
+
 static void hyperv_flush_tlb_others(const struct cpumask *cpus,
struct mm_struct *mm, unsigned long start,
unsigned long end)
@@ -120,16 +162,100 @@ static void hyperv_flush_tlb_others(const struct cpumask 
*cpus,
native_flush_tlb_others(cpus, mm, start, end);
 }
 
+static void hyperv_flush_tlb_others_ex(const struct cpumask *cpus,
+  struct mm_struct *mm,
+  unsigned long start,
+  unsigned long end)
+{
+   int nr_bank = 0, max_gvas, gva_n;
+   struct hv_flush_pcpu_ex *flush;
+   u64 status = U64_MAX;
+   unsigned long flags;
+
+   if (!pcpu_flush_ex || !hv_hypercall_pg)
+   goto do_native;
+
+   if (cpumask_empty(cpus))
+   return;
+
+   local_irq_save(flags);
+
+   flush = this_cpu_ptr(pcpu_flush_ex);
+
+   if (mm) {
+   flush->address_space = virt_to_phys(mm->pgd);
+   flush->flags = 0;
+   } else {
+   flush->address_space = 0;
+   flush->flags = HV_FLUSH_ALL_VIRTUAL_ADDRESS_SPACES;
+   }
+
+   flush->hv_vp_set.valid_bank_mask = 0;
+
+   if (!cpumask_equal(cpus, cpu_present_mask)) {
+   flush->hv_vp_set.format = HV_GENERIC_SET_SPARCE_4K;
+   nr_bank = cpumask_to_vp_set(flush, cpus);
+   }
+
+   if (!nr_bank) {
+   flush->hv_vp_set.format = HV_GENERIC_SET_ALL;
+   flush->flags |= HV_FLUSH_ALL_PROCESSORS;
+   }
+
+   /*
+* We can flush not more than max_gvas with one hypercall. Flush the
+* whole address space if we were asked to do more.
+*/
+   max_gvas =
+   (PAGE_SIZE - sizeof(*flush) - nr_bank *
+sizeof(flush->hv_vp_set.bank_contents[0])) /
+   sizeof(flush->gva_list[0]);
+
+   if (end == TLB_FLUSH_ALL) {
+   flush->flags |= HV_FLUSH_NON_GLOBAL_MAPPINGS_ONLY;
+   status = hv_do_rep_hypercall(
+   HVCALL_FLUSH_VIRTUAL_ADDRESS_SPACE_EX,
+   0, nr_bank + 2, flush, NULL);
+   } else if (end && ((end - start)/HV_TLB_FLUSH_UNIT) > max_gvas) {
+   status = hv_do_rep_hypercall(
+   HVCALL_FLUSH_VIRTUAL_ADDRESS_SPACE_EX,
+   0, nr_bank + 2, flush, NULL);
+   } else {
+   gva_n = fill_gva_list(flush->gva_list, nr_bank, start, end);
+   status = hv_do_rep_hypercall(
+

[PATCH 02/10] x86/hyper-v: stash the max number of virtual/logical processor

2017-06-25 Thread kys
From: Vitaly Kuznetsov 

Max virtual processor will be needed for 'extended' hypercalls supporting
more than 64 vCPUs. While on it, unify on 'Hyper-V' in mshyperv.c as we
currently have a mix, report acquired misc features as well.

Signed-off-by: Vitaly Kuznetsov 
Reviewed-by: Andy Shevchenko 
Signed-off-by: K. Y. Srinivasan 
---
 arch/x86/include/asm/mshyperv.h |2 ++
 arch/x86/kernel/cpu/mshyperv.c  |   12 +---
 2 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/arch/x86/include/asm/mshyperv.h b/arch/x86/include/asm/mshyperv.h
index 66f9f2a..115a0e2 100644
--- a/arch/x86/include/asm/mshyperv.h
+++ b/arch/x86/include/asm/mshyperv.h
@@ -29,6 +29,8 @@ struct ms_hyperv_info {
u32 features;
u32 misc_features;
u32 hints;
+   u32 max_vp_index;
+   u32 max_lp_index;
 };
 
 extern struct ms_hyperv_info ms_hyperv;
diff --git a/arch/x86/kernel/cpu/mshyperv.c b/arch/x86/kernel/cpu/mshyperv.c
index 04cb8d3..f259e01 100644
--- a/arch/x86/kernel/cpu/mshyperv.c
+++ b/arch/x86/kernel/cpu/mshyperv.c
@@ -175,9 +175,15 @@ static void __init ms_hyperv_init_platform(void)
ms_hyperv.misc_features = cpuid_edx(HYPERV_CPUID_FEATURES);
ms_hyperv.hints= cpuid_eax(HYPERV_CPUID_ENLIGHTMENT_INFO);
 
-   pr_info("HyperV: features 0x%x, hints 0x%x\n",
+   pr_info("Hyper-V: features 0x%x, hints 0x%x\n",
ms_hyperv.features, ms_hyperv.hints);
 
+   ms_hyperv.max_vp_index = cpuid_eax(HVCPUID_IMPLEMENTATION_LIMITS);
+   ms_hyperv.max_lp_index = cpuid_ebx(HVCPUID_IMPLEMENTATION_LIMITS);
+
+   pr_debug("Hyper-V: max %u virtual processors, %u logical processors\n",
+ms_hyperv.max_vp_index, ms_hyperv.max_lp_index);
+
/*
 * Extract host information.
 */
@@ -203,7 +209,7 @@ static void __init ms_hyperv_init_platform(void)
rdmsrl(HV_X64_MSR_APIC_FREQUENCY, hv_lapic_frequency);
hv_lapic_frequency = div_u64(hv_lapic_frequency, HZ);
lapic_timer_frequency = hv_lapic_frequency;
-   pr_info("HyperV: LAPIC Timer Frequency: %#x\n",
+   pr_info("Hyper-V: LAPIC Timer Frequency: %#x\n",
lapic_timer_frequency);
}
 
@@ -237,7 +243,7 @@ static void __init ms_hyperv_init_platform(void)
 }
 
 const __refconst struct hypervisor_x86 x86_hyper_ms_hyperv = {
-   .name   = "Microsoft HyperV",
+   .name   = "Microsoft Hyper-V",
.detect = ms_hyperv_platform,
.init_platform  = ms_hyperv_init_platform,
 };
-- 
1.7.1

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


[PATCH 05/10] hyper-v: use fast hypercall for HVCALL_SIGNAL_EVENT

2017-06-25 Thread kys
From: Vitaly Kuznetsov 

We need to pass only 8 bytes of input for HvSignalEvent which makes it a
perfect fit for fast hypercall. hv_input_signal_event_buffer is not needed
any more and hv_input_signal_event is converted to union for convenience.

Signed-off-by: Vitaly Kuznetsov 
Reviewed-by: Andy Shevchenko 
Signed-off-by: K. Y. Srinivasan 
---
 drivers/hv/channel_mgmt.c |   13 ++---
 drivers/hv/connection.c   |2 +-
 include/linux/hyperv.h|   15 +--
 3 files changed, 4 insertions(+), 26 deletions(-)

diff --git a/drivers/hv/channel_mgmt.c b/drivers/hv/channel_mgmt.c
index 0fabd41..f501ce1 100644
--- a/drivers/hv/channel_mgmt.c
+++ b/drivers/hv/channel_mgmt.c
@@ -806,21 +806,12 @@ static void vmbus_onoffer(struct 
vmbus_channel_message_header *hdr)
/*
 * Setup state for signalling the host.
 */
-   newchannel->sig_event = (struct hv_input_signal_event *)
-   (ALIGN((unsigned long)
-   &newchannel->sig_buf,
-   HV_HYPERCALL_PARAM_ALIGN));
-
-   newchannel->sig_event->connectionid.asu32 = 0;
-   newchannel->sig_event->connectionid.u.id = VMBUS_EVENT_CONNECTION_ID;
-   newchannel->sig_event->flag_number = 0;
-   newchannel->sig_event->rsvdz = 0;
+   newchannel->sig_event = VMBUS_EVENT_CONNECTION_ID;
 
if (vmbus_proto_version != VERSION_WS2008) {
newchannel->is_dedicated_interrupt =
(offer->is_dedicated_interrupt != 0);
-   newchannel->sig_event->connectionid.u.id =
-   offer->connection_id;
+   newchannel->sig_event = offer->connection_id;
}
 
memcpy(&newchannel->offermsg, offer,
diff --git a/drivers/hv/connection.c b/drivers/hv/connection.c
index 45e806e..37ecf51 100644
--- a/drivers/hv/connection.c
+++ b/drivers/hv/connection.c
@@ -408,6 +408,6 @@ void vmbus_set_event(struct vmbus_channel *channel)
if (!channel->is_dedicated_interrupt)
vmbus_send_interrupt(child_relid);
 
-   hv_do_hypercall(HVCALL_SIGNAL_EVENT, channel->sig_event, NULL);
+   hv_do_fast_hypercall8(HVCALL_SIGNAL_EVENT, channel->sig_event);
 }
 EXPORT_SYMBOL_GPL(vmbus_set_event);
diff --git a/include/linux/hyperv.h b/include/linux/hyperv.h
index d1ae02d..2c9a2c8 100644
--- a/include/linux/hyperv.h
+++ b/include/linux/hyperv.h
@@ -677,18 +677,6 @@ struct vmbus_close_msg {
} u;
 };
 
-/* Definition of the hv_signal_event hypercall input structure. */
-struct hv_input_signal_event {
-   union hv_connection_id connectionid;
-   u16 flag_number;
-   u16 rsvdz;
-};
-
-struct hv_input_signal_event_buffer {
-   u64 align8;
-   struct hv_input_signal_event event;
-};
-
 enum hv_numa_policy {
HV_BALANCED = 0,
HV_LOCALIZED,
@@ -771,8 +759,7 @@ struct vmbus_channel {
} callback_mode;
 
bool is_dedicated_interrupt;
-   struct hv_input_signal_event_buffer sig_buf;
-   struct hv_input_signal_event *sig_event;
+   u64 sig_event;
 
/*
 * Starting with win8, this field will be used to specify
-- 
1.7.1

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


[PATCH 03/10] x86/hyper-v: make hv_do_hypercall() inline

2017-06-25 Thread kys
From: Vitaly Kuznetsov 

We have only three call sites for hv_do_hypercall() and we're going to
change HVCALL_SIGNAL_EVENT to doing fast hypercall so we can inline this
function for optimization.

Hyper-V top level functional specification states that r9-r11 registers
and flags may be clobbered by the hypervisor during hypercall and with
inlining this is somewhat important, add the clobbers.

Signed-off-by: Vitaly Kuznetsov 
Reviewed-by: Andy Shevchenko 
Signed-off-by: K. Y. Srinivasan 
---
 arch/x86/hyperv/hv_init.c   |   54 +++---
 arch/x86/include/asm/mshyperv.h |   39 
 drivers/hv/connection.c |2 +
 include/linux/hyperv.h  |1 -
 4 files changed, 46 insertions(+), 50 deletions(-)

diff --git a/arch/x86/hyperv/hv_init.c b/arch/x86/hyperv/hv_init.c
index 5b882cc..691603e 100644
--- a/arch/x86/hyperv/hv_init.c
+++ b/arch/x86/hyperv/hv_init.c
@@ -75,7 +75,8 @@ static u64 read_hv_clock_msr(struct clocksource *arg)
.flags  = CLOCK_SOURCE_IS_CONTINUOUS,
 };
 
-static void *hypercall_pg;
+void *hv_hypercall_pg;
+EXPORT_SYMBOL_GPL(hv_hypercall_pg);
 struct clocksource *hyperv_cs;
 EXPORT_SYMBOL_GPL(hyperv_cs);
 
@@ -102,15 +103,15 @@ void hyperv_init(void)
guest_id = generate_guest_id(0, LINUX_VERSION_CODE, 0);
wrmsrl(HV_X64_MSR_GUEST_OS_ID, guest_id);
 
-   hypercall_pg  = __vmalloc(PAGE_SIZE, GFP_KERNEL, PAGE_KERNEL_RX);
-   if (hypercall_pg == NULL) {
+   hv_hypercall_pg  = __vmalloc(PAGE_SIZE, GFP_KERNEL, PAGE_KERNEL_RX);
+   if (hv_hypercall_pg == NULL) {
wrmsrl(HV_X64_MSR_GUEST_OS_ID, 0);
return;
}
 
rdmsrl(HV_X64_MSR_HYPERCALL, hypercall_msr.as_uint64);
hypercall_msr.enable = 1;
-   hypercall_msr.guest_physical_address = vmalloc_to_pfn(hypercall_pg);
+   hypercall_msr.guest_physical_address = vmalloc_to_pfn(hv_hypercall_pg);
wrmsrl(HV_X64_MSR_HYPERCALL, hypercall_msr.as_uint64);
 
/*
@@ -170,51 +171,6 @@ void hyperv_cleanup(void)
 }
 EXPORT_SYMBOL_GPL(hyperv_cleanup);
 
-/*
- * hv_do_hypercall- Invoke the specified hypercall
- */
-u64 hv_do_hypercall(u64 control, void *input, void *output)
-{
-   u64 input_address = (input) ? virt_to_phys(input) : 0;
-   u64 output_address = (output) ? virt_to_phys(output) : 0;
-#ifdef CONFIG_X86_64
-   u64 hv_status = 0;
-
-   if (!hypercall_pg)
-   return (u64)ULLONG_MAX;
-
-   __asm__ __volatile__("mov %0, %%r8" : : "r" (output_address) : "r8");
-   __asm__ __volatile__("call *%3" : "=a" (hv_status) :
-"c" (control), "d" (input_address),
-"m" (hypercall_pg));
-
-   return hv_status;
-
-#else
-
-   u32 control_hi = control >> 32;
-   u32 control_lo = control & 0x;
-   u32 hv_status_hi = 1;
-   u32 hv_status_lo = 1;
-   u32 input_address_hi = input_address >> 32;
-   u32 input_address_lo = input_address & 0x;
-   u32 output_address_hi = output_address >> 32;
-   u32 output_address_lo = output_address & 0x;
-
-   if (!hypercall_pg)
-   return (u64)ULLONG_MAX;
-
-   __asm__ __volatile__ ("call *%8" : "=d"(hv_status_hi),
- "=a"(hv_status_lo) : "d" (control_hi),
- "a" (control_lo), "b" (input_address_hi),
- "c" (input_address_lo), "D"(output_address_hi),
- "S"(output_address_lo), "m" (hypercall_pg));
-
-   return hv_status_lo | ((u64)hv_status_hi << 32);
-#endif /* !x86_64 */
-}
-EXPORT_SYMBOL_GPL(hv_do_hypercall);
-
 void hyperv_report_panic(struct pt_regs *regs)
 {
static bool panic_reported;
diff --git a/arch/x86/include/asm/mshyperv.h b/arch/x86/include/asm/mshyperv.h
index 115a0e2..a004b3b 100644
--- a/arch/x86/include/asm/mshyperv.h
+++ b/arch/x86/include/asm/mshyperv.h
@@ -171,6 +171,45 @@ static inline void vmbus_signal_eom(struct hv_message 
*msg, u32 old_msg_type)
 
 #if IS_ENABLED(CONFIG_HYPERV)
 extern struct clocksource *hyperv_cs;
+extern void *hv_hypercall_pg;
+
+static inline u64 hv_do_hypercall(u64 control, void *input, void *output)
+{
+   u64 input_address = input ? virt_to_phys(input) : 0;
+   u64 output_address = output ? virt_to_phys(output) : 0;
+   u64 hv_status;
+   register void *__sp asm(_ASM_SP);
+
+#ifdef CONFIG_X86_64
+   if (!hv_hypercall_pg)
+   return U64_MAX;
+
+   __asm__ __volatile__("mov %4, %%r8\n"
+"call *%5"
+: "=a" (hv_status), "+r" (__sp),
+  "+c" (control), "+d" (input_address)
+:  "r" (output_address), "m" (hv_hypercall_pg)
+: "cc", "memory", "r8", "r9", "r10", "r11");
+#else
+   u32 input_address_hi = upper_32_bits(input_address);
+   u32 input_add

[PATCH 06/10] x86/hyper-v: implement rep hypercalls

2017-06-25 Thread kys
From: Vitaly Kuznetsov 

Rep hypercalls are normal hypercalls which perform multiple actions at
once. Hyper-V guarantees to return exectution to the caller in not more
than 50us and the caller needs to use hypercall continuation. Touch NMI
watchdog between hypercall invocations.

This is going to be used for HvFlushVirtualAddressList hypercall for
remote TLB flushing.

Signed-off-by: Vitaly Kuznetsov 
Reviewed-by: Andy Shevchenko 
Signed-off-by: K. Y. Srinivasan 
---
 arch/x86/include/asm/mshyperv.h |   39 +++
 1 files changed, 39 insertions(+), 0 deletions(-)

diff --git a/arch/x86/include/asm/mshyperv.h b/arch/x86/include/asm/mshyperv.h
index f3bedb4..ed8107d 100644
--- a/arch/x86/include/asm/mshyperv.h
+++ b/arch/x86/include/asm/mshyperv.h
@@ -4,6 +4,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 /*
@@ -211,7 +212,13 @@ static inline u64 hv_do_hypercall(u64 control, void 
*input, void *output)
return hv_status;
 }
 
+#define HV_HYPERCALL_RESULT_MASK   GENMASK_ULL(15, 0)
 #define HV_HYPERCALL_FAST_BIT  BIT(16)
+#define HV_HYPERCALL_VARHEAD_OFFSET17
+#define HV_HYPERCALL_REP_COMP_OFFSET   32
+#define HV_HYPERCALL_REP_COMP_MASK GENMASK_ULL(43, 32)
+#define HV_HYPERCALL_REP_START_OFFSET  48
+#define HV_HYPERCALL_REP_START_MASKGENMASK_ULL(59, 48)
 
 /* Fast hypercall with 8 bytes of input and no output */
 static inline u64 hv_do_fast_hypercall8(u16 code, u64 input1)
@@ -245,6 +252,38 @@ static inline u64 hv_do_fast_hypercall8(u16 code, u64 
input1)
return hv_status;
 }
 
+/*
+ * Rep hypercalls. Callers of this functions are supposed to ensure that
+ * rep_count and varhead_size comply with Hyper-V hypercall definition.
+ */
+static inline u64 hv_do_rep_hypercall(u16 code, u16 rep_count, u16 
varhead_size,
+ void *input, void *output)
+{
+   u64 control = code;
+   u64 status;
+   u16 rep_comp;
+
+   control |= (u64)varhead_size << HV_HYPERCALL_VARHEAD_OFFSET;
+   control |= (u64)rep_count << HV_HYPERCALL_REP_COMP_OFFSET;
+
+   do {
+   status = hv_do_hypercall(control, input, output);
+   if ((status & HV_HYPERCALL_RESULT_MASK) != HV_STATUS_SUCCESS)
+   return status;
+
+   /* Bits 32-43 of status have 'Reps completed' data. */
+   rep_comp = (status & HV_HYPERCALL_REP_COMP_MASK) >>
+   HV_HYPERCALL_REP_COMP_OFFSET;
+
+   control &= ~HV_HYPERCALL_REP_START_MASK;
+   control |= (u64)rep_comp << HV_HYPERCALL_REP_START_OFFSET;
+
+   touch_nmi_watchdog();
+   } while (rep_comp < rep_count);
+
+   return status;
+}
+
 void hyperv_init(void);
 void hyperv_report_panic(struct pt_regs *regs);
 bool hv_is_hypercall_page_setup(void);
-- 
1.7.1

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


[PATCH 00/10] Hyper-V: paravirtualized remote TLB flushing and hypercall improvements

2017-06-25 Thread kys
From: K. Y. Srinivasan 

Hyper-V supports hypercalls for doing local and remote TLB flushing and
gives its guests hints when using hypercall is preferred. While doing
hypercalls for local TLB flushes is probably not practical (and is not
being suggested by modern Hyper-V versions) remote TLB flush with a
hypercall brings significant improvement.

To test the series I wrote a special 'TLB trasher': on a 16 vCPU guest I
was creating 32 threads which were doing 10 mmap/munmaps each on
some
big file. Here are the results:

Before:
# time ./pthread_mmap ./randfile 
real3m33.118s
user0m3.698s
sys 3m16.624s

After:
# time ./pthread_mmap ./randfile 
real2m19.920s
user0m2.662s
sys 2m9.948s

This series brings a number of small improvements along the way: fast
hypercall implementation and using it for event signaling, rep
hypercalls
implementation, hyperv tracing subsystem (which only traces the newly
added
remote TLB flush for now).

Vitaly Kuznetsov (10):
  x86/hyper-v: include hyperv/ only when CONFIG_HYPERV is set
  x86/hyper-v: stash the max number of virtual/logical processor
  x86/hyper-v: make hv_do_hypercall() inline
  x86/hyper-v: fast hypercall implementation
  hyper-v: use fast hypercall for HVCALL_SIGNAL_EVENT
  x86/hyper-v: implement rep hypercalls
  hyper-v: globalize vp_index
  x86/hyper-v: use hypercall for remote TLB flush
  x86/hyper-v: support extended CPU ranges for TLB flush hypercalls
  tracing/hyper-v: trace hyperv_mmu_flush_tlb_others()

 MAINTAINERS |1 +
 arch/x86/Kbuild |2 +-
 arch/x86/hyperv/Makefile|2 +-
 arch/x86/hyperv/hv_init.c   |   90 +---
 arch/x86/hyperv/mmu.c   |  268 +++
 arch/x86/include/asm/mshyperv.h |  149 +++-
 arch/x86/include/asm/trace/hyperv.h |   38 +
 arch/x86/include/uapi/asm/hyperv.h  |   17 +++
 arch/x86/kernel/cpu/mshyperv.c  |   13 ++-
 drivers/hv/channel_mgmt.c   |   20 +--
 drivers/hv/connection.c |7 +-
 drivers/hv/hv.c |9 --
 drivers/hv/hyperv_vmbus.h   |   11 --
 drivers/hv/vmbus_drv.c  |   17 ---
 drivers/pci/host/pci-hyperv.c   |   10 +-
 include/linux/hyperv.h  |   17 +--
 16 files changed, 540 insertions(+), 131 deletions(-)
 create mode 100644 arch/x86/hyperv/mmu.c
 create mode 100644 arch/x86/include/asm/trace/hyperv.h

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


[PATCH 01/10] x86/hyper-v: include hyperv/ only when CONFIG_HYPERV is set

2017-06-25 Thread kys
From: Vitaly Kuznetsov 

Code is arch/x86/hyperv/ is only needed when CONFIG_HYPERV is set, the
'basic' support and detection lives in arch/x86/kernel/cpu/mshyperv.c
which is included when CONFIG_HYPERVISOR_GUEST is set.

Signed-off-by: Vitaly Kuznetsov 
Reviewed-by: Andy Shevchenko 
Signed-off-by: K. Y. Srinivasan 
---
 arch/x86/Kbuild |2 +-
 arch/x86/include/asm/mshyperv.h |7 ++-
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/arch/x86/Kbuild b/arch/x86/Kbuild
index 586b786..3e6f640 100644
--- a/arch/x86/Kbuild
+++ b/arch/x86/Kbuild
@@ -8,7 +8,7 @@ obj-$(CONFIG_KVM) += kvm/
 obj-$(CONFIG_XEN) += xen/
 
 # Hyper-V paravirtualization support
-obj-$(CONFIG_HYPERVISOR_GUEST) += hyperv/
+obj-$(subst m,y,$(CONFIG_HYPERV)) += hyperv/
 
 # lguest paravirtualization support
 obj-$(CONFIG_LGUEST_GUEST) += lguest/
diff --git a/arch/x86/include/asm/mshyperv.h b/arch/x86/include/asm/mshyperv.h
index 18325dc..66f9f2a 100644
--- a/arch/x86/include/asm/mshyperv.h
+++ b/arch/x86/include/asm/mshyperv.h
@@ -174,7 +174,12 @@ static inline void vmbus_signal_eom(struct hv_message 
*msg, u32 old_msg_type)
 void hyperv_report_panic(struct pt_regs *regs);
 bool hv_is_hypercall_page_setup(void);
 void hyperv_cleanup(void);
-#endif
+#else /* CONFIG_HYPERV */
+static inline void hyperv_init(void) {}
+static inline bool hv_is_hypercall_page_setup(void) { return false; }
+static inline hyperv_cleanup(void) {}
+#endif /* CONFIG_HYPERV */
+
 #ifdef CONFIG_HYPERV_TSCPAGE
 struct ms_hyperv_tsc_page *hv_get_tsc_page(void);
 static inline u64 hv_read_tsc_page(const struct ms_hyperv_tsc_page *tsc_pg)
-- 
1.7.1

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


[PATCH 04/10] x86/hyper-v: fast hypercall implementation

2017-06-25 Thread kys
From: Vitaly Kuznetsov 

Hyper-V supports 'fast' hypercalls when all parameters are passed through
registers. Implement an inline version of a simpliest of these calls:
hypercall with one 8-byte input and no output.

Signed-off-by: Vitaly Kuznetsov 
Reviewed-by: Andy Shevchenko 
Signed-off-by: K. Y. Srinivasan 
---
 arch/x86/include/asm/mshyperv.h |   34 ++
 1 files changed, 34 insertions(+), 0 deletions(-)

diff --git a/arch/x86/include/asm/mshyperv.h b/arch/x86/include/asm/mshyperv.h
index a004b3b..f3bedb4 100644
--- a/arch/x86/include/asm/mshyperv.h
+++ b/arch/x86/include/asm/mshyperv.h
@@ -211,6 +211,40 @@ static inline u64 hv_do_hypercall(u64 control, void 
*input, void *output)
return hv_status;
 }
 
+#define HV_HYPERCALL_FAST_BIT  BIT(16)
+
+/* Fast hypercall with 8 bytes of input and no output */
+static inline u64 hv_do_fast_hypercall8(u16 code, u64 input1)
+{
+   u64 hv_status, control = (u64)code | HV_HYPERCALL_FAST_BIT;
+   register void *__sp asm(_ASM_SP);
+
+#ifdef CONFIG_X86_64
+   {
+   __asm__ __volatile__("call *%4"
+: "=a" (hv_status), "+r" (__sp),
+  "+c" (control), "+d" (input1)
+: "m" (hv_hypercall_pg)
+: "cc", "r8", "r9", "r10", "r11");
+   }
+#else
+   {
+   u32 input1_hi = upper_32_bits(input1);
+   u32 input1_lo = lower_32_bits(input1);
+
+   __asm__ __volatile__ ("call *%5"
+ : "=A"(hv_status),
+   "+c"(input1_lo),
+   "+r"(__sp)
+ : "A" (control),
+   "b" (input1_hi),
+   "m" (hv_hypercall_pg)
+ : "cc", "edi", "esi");
+   }
+#endif
+   return hv_status;
+}
+
 void hyperv_init(void);
 void hyperv_report_panic(struct pt_regs *regs);
 bool hv_is_hypercall_page_setup(void);
-- 
1.7.1

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


Re: [PATCH 1/2] staging: sm750fb: avoid conflicting vesafb

2017-06-25 Thread Sudip Mukherjee
On Sun, Jun 25, 2017 at 04:27:23PM +0200, Greg Kroah-Hartman wrote:
> On Sun, Jun 25, 2017 at 02:54:29PM +0100, Sudip Mukherjee wrote:
> > On Sun, Jun 25, 2017 at 02:54:51PM +0200, Greg Kroah-Hartman wrote:
> > > On Sun, Jun 25, 2017 at 01:43:34PM +0100, Sudip Mukherjee wrote:
> > > > On Mon, Jun 19, 2017 at 09:32:57PM +0100, Sudip Mukherjee wrote:
> > > > > From: Teddy Wang 
> > > > > 
> > > > > If vesafb is enabled in the config then /dev/fb0 is created by vesa
> > > > > and this sm750 driver gets fb1, fb2. But we need to be fb0 and fb1 to
> > > > > effectively work with xorg.
> > > > > So if it has been alloted fb1, then try to remove the other fb0.
> > > > > 
> > > > > Signed-off-by: Teddy Wang 
> > > > > Signed-off-by: Sudip Mukherjee 
> > > > > ---
> > > > 
> > > > Hi Greg,
> > > > You applied the second patch but not this one. Did I miss any review
> > > > comments from you about this one?
> > > 
> > > All of the other complaints about this patch were not sufficient for me
> > > to justify ignoring it?  Why would I not listen to them?
> > 
> > This patch is doing what all the drm drivers are doing. So you want
> > us to do something completely new rather than following the established
> > practice of a drm driver?
> 
> I despise cargo-cult programming.  You could not answer the "why", so
> why would I accept such a patch?

Did a quick research into "why".
The patch d8801e4df91e ("x86/PCI: Set IORESOURCE_ROM_SHADOW only for the
default VGA device") has started setting IORESOURCE_ROM_SHADOW in flags
for a default VGA device and that is being done only for x86.
And so, we will need that #ifdef to check IORESOURCE_ROM_SHADOW as that
needs to be checked only for a x86 and not for other arch.

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


Re: [PATCH v2] Staging: vc04_services: bcm2835-audio: bcm2835-ctl.c: Fixed alignment to match open parenthesis.

2017-06-25 Thread Srishti Sharma
On Sun, Jun 25, 2017 at 8:01 PM, Greg KH  wrote:
> On Sat, Jun 24, 2017 at 08:58:10AM +0530, srishti sharma wrote:
>> Fixed alignment so that it matched open parenthesis.
>>
>> Signed-off-by: srishti sharma 
>
> Does your legal name not have capital letters?  Please fix and resend.

 Sorry , yes ! I have re-sent it .
>
> thanks,
>
> greg k-h

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


[PATCH v2] Staging: vc04_services: bcm2835-audio: bcm2835-ctl.c: Fixed alignment to match open parenthesis.

2017-06-25 Thread Srishti Sharma
Fixed alignment so that it matched open parenthesis.

Signed-off-by: Srishti Sharma 
---
Changes in v2:
 -Fix all checks of the type "alignment should match open parenthesis" for a 
file in the same patch.

 .../staging/vc04_services/bcm2835-audio/bcm2835-ctl.c  | 18 +-
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/vc04_services/bcm2835-audio/bcm2835-ctl.c 
b/drivers/staging/vc04_services/bcm2835-audio/bcm2835-ctl.c
index f484bb0..ce8ab36 100644
--- a/drivers/staging/vc04_services/bcm2835-audio/bcm2835-ctl.c
+++ b/drivers/staging/vc04_services/bcm2835-audio/bcm2835-ctl.c
@@ -105,7 +105,7 @@ static int snd_bcm2835_ctl_get(struct snd_kcontrol 
*kcontrol,
 }

 static int snd_bcm2835_ctl_put(struct snd_kcontrol *kcontrol,
-   struct snd_ctl_elem_value *ucontrol)
+  struct snd_ctl_elem_value *ucontrol)
 {
struct bcm2835_chip *chip = snd_kcontrol_chip(kcontrol);
int changed = 0;
@@ -185,7 +185,7 @@ static struct snd_kcontrol_new snd_bcm2835_ctl[] = {
 };

 static int snd_bcm2835_spdif_default_info(struct snd_kcontrol *kcontrol,
-   struct snd_ctl_elem_info *uinfo)
+ struct snd_ctl_elem_info *uinfo)
 {
uinfo->type = SNDRV_CTL_ELEM_TYPE_IEC958;
uinfo->count = 1;
@@ -193,7 +193,7 @@ static int snd_bcm2835_spdif_default_info(struct 
snd_kcontrol *kcontrol,
 }

 static int snd_bcm2835_spdif_default_get(struct snd_kcontrol *kcontrol,
-   struct snd_ctl_elem_value *ucontrol)
+struct snd_ctl_elem_value *ucontrol)
 {
struct bcm2835_chip *chip = snd_kcontrol_chip(kcontrol);
int i;
@@ -210,7 +210,7 @@ static int snd_bcm2835_spdif_default_get(struct 
snd_kcontrol *kcontrol,
 }

 static int snd_bcm2835_spdif_default_put(struct snd_kcontrol *kcontrol,
-   struct snd_ctl_elem_value *ucontrol)
+struct snd_ctl_elem_value *ucontrol)
 {
struct bcm2835_chip *chip = snd_kcontrol_chip(kcontrol);
unsigned int val = 0;
@@ -230,7 +230,7 @@ static int snd_bcm2835_spdif_default_put(struct 
snd_kcontrol *kcontrol,
 }

 static int snd_bcm2835_spdif_mask_info(struct snd_kcontrol *kcontrol,
-   struct snd_ctl_elem_info *uinfo)
+  struct snd_ctl_elem_info *uinfo)
 {
uinfo->type = SNDRV_CTL_ELEM_TYPE_IEC958;
uinfo->count = 1;
@@ -238,7 +238,7 @@ static int snd_bcm2835_spdif_mask_info(struct snd_kcontrol 
*kcontrol,
 }

 static int snd_bcm2835_spdif_mask_get(struct snd_kcontrol *kcontrol,
-   struct snd_ctl_elem_value *ucontrol)
+ struct snd_ctl_elem_value *ucontrol)
 {
/*
 * bcm2835 supports only consumer mode and sets all other format flags
@@ -249,7 +249,7 @@ static int snd_bcm2835_spdif_mask_get(struct snd_kcontrol 
*kcontrol,
 }

 static int snd_bcm2835_spdif_stream_info(struct snd_kcontrol *kcontrol,
-   struct snd_ctl_elem_info *uinfo)
+struct snd_ctl_elem_info *uinfo)
 {
uinfo->type = SNDRV_CTL_ELEM_TYPE_IEC958;
uinfo->count = 1;
@@ -257,7 +257,7 @@ static int snd_bcm2835_spdif_stream_info(struct 
snd_kcontrol *kcontrol,
 }

 static int snd_bcm2835_spdif_stream_get(struct snd_kcontrol *kcontrol,
-   struct snd_ctl_elem_value *ucontrol)
+   struct snd_ctl_elem_value *ucontrol)
 {
struct bcm2835_chip *chip = snd_kcontrol_chip(kcontrol);
int i;
@@ -274,7 +274,7 @@ static int snd_bcm2835_spdif_stream_get(struct snd_kcontrol 
*kcontrol,
 }

 static int snd_bcm2835_spdif_stream_put(struct snd_kcontrol *kcontrol,
-   struct snd_ctl_elem_value *ucontrol)
+   struct snd_ctl_elem_value *ucontrol)
 {
struct bcm2835_chip *chip = snd_kcontrol_chip(kcontrol);
unsigned int val = 0;
--
2.7.4

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


Re: [PATCH] staging: wlan-ng: Fix sparse warning: incorrect type in assignment This patch fixes the following sparse warning

2017-06-25 Thread Greg KH
On Fri, Jun 23, 2017 at 04:21:54AM +0200, AbdAllah-MEZITI wrote:
> drivers/staging/wlan-ng/prism2mgmt.c:188:25: warning: incorrect type in 
> assignment (different base types)
> drivers/staging/wlan-ng/prism2mgmt.c:188:25:expected unsigned short 
> [unsigned] [addressable] [usertype] tx_rate
> drivers/staging/wlan-ng/prism2mgmt.c:188:25:got restricted __le16 
> [usertype] 
> drivers/staging/wlan-ng/prism2mgmt.c:200:30: warning: incorrect type in 
> assignment (different base types)
> drivers/staging/wlan-ng/prism2mgmt.c:200:30:expected unsigned short 
> [unsigned] [addressable] [usertype] channel_list
> drivers/staging/wlan-ng/prism2mgmt.c:200:30:got restricted __le16 
> [usertype] 
> drivers/staging/wlan-ng/prism2mgmt.c:203:26: warning: incorrect type in 
> assignment (different base types)
> drivers/staging/wlan-ng/prism2mgmt.c:203:26:expected unsigned short 
> [unsigned] [addressable] [usertype] len
> drivers/staging/wlan-ng/prism2mgmt.c:203:26:got restricted __le16 
> [usertype] 
> drivers/staging/wlan-ng/prism2mgmt.c:232:28: warning: incorrect type in 
> assignment (different base types)
> drivers/staging/wlan-ng/prism2mgmt.c:232:28:expected unsigned short 
> [unsigned] [short] 
> drivers/staging/wlan-ng/prism2mgmt.c:232:28:got restricted __le16 
> [usertype] 
> 
> Signed-off-by: AbdAllah-MEZITI 
> ---
>  drivers/staging/wlan-ng/hfa384x.h| 6 +++---
>  drivers/staging/wlan-ng/prism2mgmt.c | 2 +-
>  2 files changed, 4 insertions(+), 4 deletions(-)

Does not apply to my staging-next branch at all :(
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v2] Staging: vc04_services: bcm2835-audio: bcm2835-ctl.c: Fixed alignment to match open parenthesis.

2017-06-25 Thread Greg KH
On Sat, Jun 24, 2017 at 08:58:10AM +0530, srishti sharma wrote:
> Fixed alignment so that it matched open parenthesis.
> 
> Signed-off-by: srishti sharma 

Does your legal name not have capital letters?  Please fix and resend.

thanks,

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


Re: [PATCH 1/2] staging: sm750fb: avoid conflicting vesafb

2017-06-25 Thread Greg Kroah-Hartman
On Sun, Jun 25, 2017 at 02:54:29PM +0100, Sudip Mukherjee wrote:
> On Sun, Jun 25, 2017 at 02:54:51PM +0200, Greg Kroah-Hartman wrote:
> > On Sun, Jun 25, 2017 at 01:43:34PM +0100, Sudip Mukherjee wrote:
> > > On Mon, Jun 19, 2017 at 09:32:57PM +0100, Sudip Mukherjee wrote:
> > > > From: Teddy Wang 
> > > > 
> > > > If vesafb is enabled in the config then /dev/fb0 is created by vesa
> > > > and this sm750 driver gets fb1, fb2. But we need to be fb0 and fb1 to
> > > > effectively work with xorg.
> > > > So if it has been alloted fb1, then try to remove the other fb0.
> > > > 
> > > > Signed-off-by: Teddy Wang 
> > > > Signed-off-by: Sudip Mukherjee 
> > > > ---
> > > 
> > > Hi Greg,
> > > You applied the second patch but not this one. Did I miss any review
> > > comments from you about this one?
> > 
> > All of the other complaints about this patch were not sufficient for me
> > to justify ignoring it?  Why would I not listen to them?
> 
> This patch is doing what all the drm drivers are doing. So you want
> us to do something completely new rather than following the established
> practice of a drm driver?

I despise cargo-cult programming.  You could not answer the "why", so
why would I accept such a patch?

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


Re: [PATCH 1/2] staging: sm750fb: avoid conflicting vesafb

2017-06-25 Thread Sudip Mukherjee
On Sun, Jun 25, 2017 at 02:54:51PM +0200, Greg Kroah-Hartman wrote:
> On Sun, Jun 25, 2017 at 01:43:34PM +0100, Sudip Mukherjee wrote:
> > On Mon, Jun 19, 2017 at 09:32:57PM +0100, Sudip Mukherjee wrote:
> > > From: Teddy Wang 
> > > 
> > > If vesafb is enabled in the config then /dev/fb0 is created by vesa
> > > and this sm750 driver gets fb1, fb2. But we need to be fb0 and fb1 to
> > > effectively work with xorg.
> > > So if it has been alloted fb1, then try to remove the other fb0.
> > > 
> > > Signed-off-by: Teddy Wang 
> > > Signed-off-by: Sudip Mukherjee 
> > > ---
> > 
> > Hi Greg,
> > You applied the second patch but not this one. Did I miss any review
> > comments from you about this one?
> 
> All of the other complaints about this patch were not sufficient for me
> to justify ignoring it?  Why would I not listen to them?

This patch is doing what all the drm drivers are doing. So you want
us to do something completely new rather than following the established
practice of a drm driver?

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


Re: [PATCH 1/2] staging: sm750fb: avoid conflicting vesafb

2017-06-25 Thread Greg Kroah-Hartman
On Sun, Jun 25, 2017 at 01:43:34PM +0100, Sudip Mukherjee wrote:
> On Mon, Jun 19, 2017 at 09:32:57PM +0100, Sudip Mukherjee wrote:
> > From: Teddy Wang 
> > 
> > If vesafb is enabled in the config then /dev/fb0 is created by vesa
> > and this sm750 driver gets fb1, fb2. But we need to be fb0 and fb1 to
> > effectively work with xorg.
> > So if it has been alloted fb1, then try to remove the other fb0.
> > 
> > Signed-off-by: Teddy Wang 
> > Signed-off-by: Sudip Mukherjee 
> > ---
> 
> Hi Greg,
> You applied the second patch but not this one. Did I miss any review
> comments from you about this one?

All of the other complaints about this patch were not sufficient for me
to justify ignoring it?  Why would I not listen to them?

Please fix and resend if you want it applied.

thanks,

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


[PATCH] staging: lustre: replace kmalloc with kmalloc_array

2017-06-25 Thread Denis Petrovic
This patch fixes the following checkpatch.pl warning:

WARNING: Prefer kmalloc_array over kmalloc with multiply

Signed-off-by: Denis Petrovic 
---
 drivers/staging/lustre/lnet/libcfs/linux/linux-tracefile.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/lustre/lnet/libcfs/linux/linux-tracefile.c 
b/drivers/staging/lustre/lnet/libcfs/linux/linux-tracefile.c
index 75eb84e7f0f8..a5a94788f11f 100644
--- a/drivers/staging/lustre/lnet/libcfs/linux/linux-tracefile.c
+++ b/drivers/staging/lustre/lnet/libcfs/linux/linux-tracefile.c
@@ -57,8 +57,9 @@ int cfs_tracefile_init_arch(void)
memset(cfs_trace_data, 0, sizeof(cfs_trace_data));
for (i = 0; i < CFS_TCD_TYPE_MAX; i++) {
cfs_trace_data[i] =
-   kmalloc(sizeof(union cfs_trace_data_union) *
-   num_possible_cpus(), GFP_KERNEL);
+   kmalloc_array(num_possible_cpus(),
+ sizeof(union cfs_trace_data_union),
+ GFP_KERNEL);
if (!cfs_trace_data[i])
goto out;
}
-- 
2.11.0

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


Re: [PATCH 1/2] staging: sm750fb: avoid conflicting vesafb

2017-06-25 Thread Sudip Mukherjee
On Mon, Jun 19, 2017 at 09:32:57PM +0100, Sudip Mukherjee wrote:
> From: Teddy Wang 
> 
> If vesafb is enabled in the config then /dev/fb0 is created by vesa
> and this sm750 driver gets fb1, fb2. But we need to be fb0 and fb1 to
> effectively work with xorg.
> So if it has been alloted fb1, then try to remove the other fb0.
> 
> Signed-off-by: Teddy Wang 
> Signed-off-by: Sudip Mukherjee 
> ---

Hi Greg,
You applied the second patch but not this one. Did I miss any review
comments from you about this one?

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


[PATCH v3 3/6] staging: ccree: remove unused function

2017-06-25 Thread Gilad Ben-Yossef
The function set_ack_last was not used anywhere. Remove it.

Signed-off-by: Gilad Ben-Yossef 
---
 drivers/staging/ccree/cc_hw_queue_defs.h | 12 
 1 file changed, 12 deletions(-)

diff --git a/drivers/staging/ccree/cc_hw_queue_defs.h 
b/drivers/staging/ccree/cc_hw_queue_defs.h
index aaa56c8..f11487a 100644
--- a/drivers/staging/ccree/cc_hw_queue_defs.h
+++ b/drivers/staging/ccree/cc_hw_queue_defs.h
@@ -226,18 +226,6 @@ static inline void set_queue_last_ind(struct cc_hw_desc 
*pdesc)
 }
 
 /*
- * Signs the end of HW descriptors flow by asking for completion ack,
- * and release the HW engines
- *
- * @pdesc: pointer HW descriptor struct
- */
-static inline void set_ack_last(struct cc_hw_desc *pdesc)
-{
-   pdesc->word[3] |= FIELD_PREP(WORD3_QUEUE_LAST_IND, 1);
-   pdesc->word[4] |= FIELD_PREP(WORD4_ACK_NEEDED, 1);
-}
-
-/*
  * Set the DIN field of a HW descriptors
  *
  * @pdesc: pointer HW descriptor struct
-- 
2.1.4

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


[PATCH v3 5/6] staging: ccree: add DT bus coherency detection

2017-06-25 Thread Gilad Ben-Yossef
The ccree driver has build time configurable support
to work on top of coherent (e.g. ACP) vs. none coherent bus
connections. Turn it to run-time configurable option
based on device tree.

Signed-off-by: Gilad Ben-Yossef 
---
 drivers/staging/ccree/Kconfig  |  9 -
 drivers/staging/ccree/ssi_buffer_mgr.c | 37 ++
 drivers/staging/ccree/ssi_config.h | 20 --
 drivers/staging/ccree/ssi_driver.c | 12 ---
 drivers/staging/ccree/ssi_driver.h |  3 +++
 5 files changed, 32 insertions(+), 49 deletions(-)

diff --git a/drivers/staging/ccree/Kconfig b/drivers/staging/ccree/Kconfig
index 4be87f5..ec3749d 100644
--- a/drivers/staging/ccree/Kconfig
+++ b/drivers/staging/ccree/Kconfig
@@ -32,12 +32,3 @@ config CCREE_FIPS_SUPPORT
  Say 'Y' to enable support for FIPS compliant mode by the
  CCREE driver.
  If unsure say N.
-
-config CCREE_DISABLE_COHERENT_DMA_OPS
-   bool "Disable Coherent DMA operations for the CCREE driver"
-   depends on CRYPTO_DEV_CCREE
-   default n
-   help
- Say 'Y' to disable the use of coherent DMA operations by the
- CCREE driver for debugging purposes.  
- If unsure say N.
diff --git a/drivers/staging/ccree/ssi_buffer_mgr.c 
b/drivers/staging/ccree/ssi_buffer_mgr.c
index 88ebda8..4373d1d 100644
--- a/drivers/staging/ccree/ssi_buffer_mgr.c
+++ b/drivers/staging/ccree/ssi_buffer_mgr.c
@@ -627,6 +627,7 @@ void ssi_buffer_mgr_unmap_aead_request(
struct aead_req_ctx *areq_ctx = aead_request_ctx(req);
unsigned int hw_iv_size = areq_ctx->hw_iv_size;
struct crypto_aead *tfm = crypto_aead_reqtfm(req);
+   struct ssi_drvdata *drvdata = dev_get_drvdata(dev);
u32 dummy;
bool chained;
u32 size_to_unmap = 0;
@@ -700,8 +701,8 @@ void ssi_buffer_mgr_unmap_aead_request(
dma_unmap_sg(dev, req->dst, 
ssi_buffer_mgr_get_sgl_nents(req->dst,size_to_unmap,&dummy,&chained),
DMA_BIDIRECTIONAL);
}
-#if DX_HAS_ACP
-   if ((areq_ctx->gen_ctx.op_type == DRV_CRYPTO_DIRECTION_DECRYPT) &&
+   if (drvdata->coherent &&
+   (areq_ctx->gen_ctx.op_type == DRV_CRYPTO_DIRECTION_DECRYPT) &&
likely(req->src == req->dst))
{
u32 size_to_skip = req->assoclen;
@@ -716,7 +717,6 @@ void ssi_buffer_mgr_unmap_aead_request(
size_to_skip+ req->cryptlen - areq_ctx->req_authsize,
size_to_skip+ req->cryptlen, SSI_SG_FROM_BUF);
}
-#endif
 }
 
 static inline int ssi_buffer_mgr_get_aead_icv_nents(
@@ -981,20 +981,24 @@ static inline int ssi_buffer_mgr_prepare_aead_data_mlli(
 * MAC verification upon request completion
 */
if (direct == DRV_CRYPTO_DIRECTION_DECRYPT) {
-#if !DX_HAS_ACP
-   /* In ACP platform we already copying ICV
-* for any INPLACE-DECRYPT operation, hence
+   if (!drvdata->coherent) {
+   /* In coherent platforms (e.g. ACP)
+* already copying ICV for any
+* INPLACE-DECRYPT operation, hence
 * we must neglect this code.
 */
-   u32 size_to_skip = req->assoclen;
-   if (areq_ctx->is_gcm4543) {
-   size_to_skip += crypto_aead_ivsize(tfm);
+   u32 skip = req->assoclen;
+
+   if (areq_ctx->is_gcm4543)
+   skip += crypto_aead_ivsize(tfm);
+
+   ssi_buffer_mgr_copy_scatterlist_portion(
+   areq_ctx->backup_mac, req->src,
+   (skip + req->cryptlen -
+areq_ctx->req_authsize),
+   skip + req->cryptlen,
+   SSI_SG_TO_BUF);
}
-   ssi_buffer_mgr_copy_scatterlist_portion(
-   areq_ctx->backup_mac, req->src,
-   size_to_skip+ req->cryptlen - 
areq_ctx->req_authsize,
-   size_to_skip+ req->cryptlen, 
SSI_SG_TO_BUF);
-#endif
areq_ctx->icv_virt_addr = areq_ctx->backup_mac;
} else {
areq_ctx->icv_virt_addr = areq_ctx->mac_buf;
@@ -1281,8 +1285,8 @@ int ssi_buffer_mgr_map_aead_request(
mlli_params->curr_pool = NULL;
sg_data.num_of_buffers = 0;
 
-#if DX_HAS_ACP
-   if

[PATCH v3 2/6] staging: ccree: register setkey for none hash macs

2017-06-25 Thread Gilad Ben-Yossef
The original ccree driver was registering a useless setkey
method even for non-MAC hash transformations. Somewhere
around v4.9 a check was added that failed hash operations
if a setkey method was registered but was not called,
so during the initial upstream port code was added to
only register the setkey method for MAC type hash transform.

Unfortunately, the ccree driver also registers non-hash based
MAC transforms and the code had a logic error that stopped
it registering a setkey callback even for those, thus rendering
them useless.

This commit fixes the logic mistake, thus correctly registering
a setkey method only for MAC transformations, leaving it out
for non-MAC ones, whether they are hash based on not.

Fixes: 50cfbbb7e627 ("staging: ccree: add ahash support").

Signed-off-by: Gilad Ben-Yossef 
---
 drivers/staging/ccree/ssi_hash.c | 83 
 1 file changed, 42 insertions(+), 41 deletions(-)

diff --git a/drivers/staging/ccree/ssi_hash.c b/drivers/staging/ccree/ssi_hash.c
index ffe8e1a..bfe2bec 100644
--- a/drivers/staging/ccree/ssi_hash.c
+++ b/drivers/staging/ccree/ssi_hash.c
@@ -1877,8 +1877,8 @@ static int ssi_ahash_setkey(struct crypto_ahash *ahash,
 struct ssi_hash_template {
char name[CRYPTO_MAX_ALG_NAME];
char driver_name[CRYPTO_MAX_ALG_NAME];
-   char hmac_name[CRYPTO_MAX_ALG_NAME];
-   char hmac_driver_name[CRYPTO_MAX_ALG_NAME];
+   char mac_name[CRYPTO_MAX_ALG_NAME];
+   char mac_driver_name[CRYPTO_MAX_ALG_NAME];
unsigned int blocksize;
bool synchronize;
struct ahash_alg template_ahash;
@@ -1897,8 +1897,8 @@ static struct ssi_hash_template driver_hash[] = {
{
.name = "sha1",
.driver_name = "sha1-dx",
-   .hmac_name = "hmac(sha1)",
-   .hmac_driver_name = "hmac-sha1-dx",
+   .mac_name = "hmac(sha1)",
+   .mac_driver_name = "hmac-sha1-dx",
.blocksize = SHA1_BLOCK_SIZE,
.synchronize = false,
.template_ahash = {
@@ -1922,8 +1922,8 @@ static struct ssi_hash_template driver_hash[] = {
{
.name = "sha256",
.driver_name = "sha256-dx",
-   .hmac_name = "hmac(sha256)",
-   .hmac_driver_name = "hmac-sha256-dx",
+   .mac_name = "hmac(sha256)",
+   .mac_driver_name = "hmac-sha256-dx",
.blocksize = SHA256_BLOCK_SIZE,
.template_ahash = {
.init = ssi_ahash_init,
@@ -1946,8 +1946,8 @@ static struct ssi_hash_template driver_hash[] = {
{
.name = "sha224",
.driver_name = "sha224-dx",
-   .hmac_name = "hmac(sha224)",
-   .hmac_driver_name = "hmac-sha224-dx",
+   .mac_name = "hmac(sha224)",
+   .mac_driver_name = "hmac-sha224-dx",
.blocksize = SHA224_BLOCK_SIZE,
.template_ahash = {
.init = ssi_ahash_init,
@@ -1971,8 +1971,8 @@ static struct ssi_hash_template driver_hash[] = {
{
.name = "sha384",
.driver_name = "sha384-dx",
-   .hmac_name = "hmac(sha384)",
-   .hmac_driver_name = "hmac-sha384-dx",
+   .mac_name = "hmac(sha384)",
+   .mac_driver_name = "hmac-sha384-dx",
.blocksize = SHA384_BLOCK_SIZE,
.template_ahash = {
.init = ssi_ahash_init,
@@ -1995,8 +1995,8 @@ static struct ssi_hash_template driver_hash[] = {
{
.name = "sha512",
.driver_name = "sha512-dx",
-   .hmac_name = "hmac(sha512)",
-   .hmac_driver_name = "hmac-sha512-dx",
+   .mac_name = "hmac(sha512)",
+   .mac_driver_name = "hmac-sha512-dx",
.blocksize = SHA512_BLOCK_SIZE,
.template_ahash = {
.init = ssi_ahash_init,
@@ -2020,8 +2020,8 @@ static struct ssi_hash_template driver_hash[] = {
{
.name = "md5",
.driver_name = "md5-dx",
-   .hmac_name = "hmac(md5)",
-   .hmac_driver_name = "hmac-md5-dx",
+   .mac_name = "hmac(md5)",
+   .mac_driver_name = "hmac-md5-dx",
.blocksize = MD5_HMAC_BLOCK_SIZE,
.template_ahash = {
.init = ssi_ahash_init,
@@ -2042,8 +2042,8 @@ static struct ssi_hash_template driver_hash[] = {
.inter_digestsize = MD5_DIGEST_SIZE,
},
{
-   .name = "xcbc(aes)",
-   .driver_name = "xcbc-aes-dx",
+   .mac_name = "xcbc(aes)",
+   .mac_driver_name = "xcbc-aes-dx",
.blocksize = AES_BLOCK_SIZE,
.template_ahash = {
.init = ssi_ahash_init,
@@ -2065,8 +2065,8 @@ static struct s

[PATCH v3 6/6] staging: ccree: use signal safe completion wait

2017-06-25 Thread Gilad Ben-Yossef
We were waiting for a completion notification of HW DMA
operation using an interruptible wait which can result
in data corruption if a signal interrupted us while
DMA was not yet completed.

Fix this by moving to uninterrupted wait.

Fixes: abefd6741d ("staging: ccree: introduce CryptoCell HW driver").

Signed-off-by: Gilad Ben-Yossef 
---
 drivers/staging/ccree/ssi_request_mgr.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/ccree/ssi_request_mgr.c 
b/drivers/staging/ccree/ssi_request_mgr.c
index 7c2d88a..2c6937a 100644
--- a/drivers/staging/ccree/ssi_request_mgr.c
+++ b/drivers/staging/ccree/ssi_request_mgr.c
@@ -382,7 +382,8 @@ int send_request(
/* Wait upon sequence completion.
 *  Return "0" -Operation done successfully.
 */
-   return wait_for_completion_interruptible(&ssi_req->seq_compl);
+   wait_for_completion(&ssi_req->seq_compl);
+   return 0;
} else {
/* Operation still in process */
return -EINPROGRESS;
-- 
2.1.4

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


[PATCH v3 4/6] staging: ccree: add clock management support

2017-06-25 Thread Gilad Ben-Yossef
Some SoC which implement CryptoCell have a dedicated clock
tied to it, some do not. Implement clock support if exists
based on device tree data and tie power management to it.

Signed-off-by: Gilad Ben-Yossef 
---
 drivers/staging/ccree/Makefile |  2 +-
 drivers/staging/ccree/ssi_driver.c | 43 +++
 drivers/staging/ccree/ssi_driver.h |  5 +++-
 drivers/staging/ccree/ssi_pm.c | 13 +
 drivers/staging/ccree/ssi_pm_ext.c | 60 --
 drivers/staging/ccree/ssi_pm_ext.h | 33 -
 6 files changed, 50 insertions(+), 106 deletions(-)
 delete mode 100644 drivers/staging/ccree/ssi_pm_ext.c
 delete mode 100644 drivers/staging/ccree/ssi_pm_ext.h

diff --git a/drivers/staging/ccree/Makefile b/drivers/staging/ccree/Makefile
index 44f3e3e..318c2b3 100644
--- a/drivers/staging/ccree/Makefile
+++ b/drivers/staging/ccree/Makefile
@@ -1,3 +1,3 @@
 obj-$(CONFIG_CRYPTO_DEV_CCREE) := ccree.o
-ccree-y := ssi_driver.o ssi_sysfs.o ssi_buffer_mgr.o ssi_request_mgr.o 
ssi_cipher.o ssi_hash.o ssi_aead.o ssi_ivgen.o ssi_sram_mgr.o ssi_pm.o 
ssi_pm_ext.o
+ccree-y := ssi_driver.o ssi_sysfs.o ssi_buffer_mgr.o ssi_request_mgr.o 
ssi_cipher.o ssi_hash.o ssi_aead.o ssi_ivgen.o ssi_sram_mgr.o ssi_pm.o
 ccree-$(CCREE_FIPS_SUPPORT) += ssi_fips.o ssi_fips_ll.o ssi_fips_ext.o 
ssi_fips_local.o
diff --git a/drivers/staging/ccree/ssi_driver.c 
b/drivers/staging/ccree/ssi_driver.c
index b9d0dd27..c516675 100644
--- a/drivers/staging/ccree/ssi_driver.c
+++ b/drivers/staging/ccree/ssi_driver.c
@@ -57,6 +57,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "ssi_config.h"
 #include "ssi_driver.h"
@@ -219,6 +220,8 @@ static int init_cc_resources(struct platform_device 
*plat_dev)
void __iomem *cc_base = NULL;
bool irq_registered = false;
struct ssi_drvdata *new_drvdata = kzalloc(sizeof(struct ssi_drvdata), 
GFP_KERNEL);
+   struct device *dev = &plat_dev->dev;
+   struct device_node *np = dev->of_node;
u32 signature_val;
int rc = 0;
 
@@ -228,6 +231,8 @@ static int init_cc_resources(struct platform_device 
*plat_dev)
goto init_cc_res_err;
}
 
+   new_drvdata->clk = of_clk_get(np, 0);
+
/*Initialize inflight counter used in dx_ablkcipher_secure_complete 
used for count of BYSPASS blocks operations*/
new_drvdata->inflight_counter = 0;
 
@@ -286,6 +291,10 @@ static int init_cc_resources(struct platform_device 
*plat_dev)
 
new_drvdata->plat_dev = plat_dev;
 
+   rc = cc_clk_on(new_drvdata);
+   if (rc)
+   goto init_cc_res_err;
+
if(new_drvdata->plat_dev->dev.dma_mask == NULL)
{
new_drvdata->plat_dev->dev.dma_mask = & 
new_drvdata->plat_dev->dev.coherent_dma_mask;
@@ -450,14 +459,11 @@ static void cleanup_cc_resources(struct platform_device 
*plat_dev)
ssi_sysfs_fini();
 #endif
 
-   /* Mask all interrupts */
-   WRITE_REGISTER(drvdata->cc_base + CC_REG_OFFSET(HOST_RGF, HOST_IMR),
-   0x);
+   fini_cc_regs(drvdata);
+   cc_clk_off(drvdata);
free_irq(drvdata->res_irq->start, drvdata);
drvdata->res_irq = NULL;
 
-   fini_cc_regs(drvdata);
-
if (drvdata->cc_base != NULL) {
iounmap(drvdata->cc_base);
release_mem_region(drvdata->res_mem->start,
@@ -470,6 +476,33 @@ static void cleanup_cc_resources(struct platform_device 
*plat_dev)
dev_set_drvdata(&plat_dev->dev, NULL);
 }
 
+int cc_clk_on(struct ssi_drvdata *drvdata)
+{
+   struct clk *clk = drvdata->clk;
+   int rc;
+
+   if (IS_ERR(clk))
+   /* Not all devices have a clock associated with CCREE  */
+   return 0;
+
+   rc = clk_prepare_enable(clk);
+   if (rc)
+   return rc;
+
+   return 0;
+}
+
+void cc_clk_off(struct ssi_drvdata *drvdata)
+{
+   struct clk *clk = drvdata->clk;
+
+   if (IS_ERR(clk))
+   /* Not all devices have a clock associated with CCREE */
+   return;
+
+   clk_disable_unprepare(clk);
+}
+
 static int cc7x_probe(struct platform_device *plat_dev)
 {
int rc;
diff --git a/drivers/staging/ccree/ssi_driver.h 
b/drivers/staging/ccree/ssi_driver.h
index 78a327a..faf47b1 100644
--- a/drivers/staging/ccree/ssi_driver.h
+++ b/drivers/staging/ccree/ssi_driver.h
@@ -36,6 +36,7 @@
 #include 
 #include 
 #include 
+#include 
 
 /* Registers definitions from shared/hw/ree_include */
 #include "dx_reg_base_host.h"
@@ -148,7 +149,7 @@ struct ssi_drvdata {
void *ivgen_handle;
void *sram_mgr_handle;
u32 inflight_counter;
-
+   struct clk *clk;
 };
 
 struct ssi_crypto_alg {
@@ -193,6 +194,8 @@ void dump_byte_array(const char *name, const u8 *the_array, 
unsigned long size);
 
 int init_cc_regs(struct ssi_drvdata *drvdata, bool is_probe);
 void fini_cc_regs(struct ssi_drvdata *drvdata);
+int cc_clk_on(struct ssi_drvdata *

[PATCH v3 1/6] staging: ccree: fix hash import/export

2017-06-25 Thread Gilad Ben-Yossef
Hash import and export was saving and restoring the wrong context
and therefore disabled. Fix it by restoring intermediate digest
and additional state needed.

The hash and mac transform now pass testmgr partial hash tests.

Signed-off-by: Gilad Ben-Yossef 
---
 drivers/staging/ccree/ssi_hash.c | 143 +++
 drivers/staging/ccree/ssi_hash.h |   2 +
 2 files changed, 101 insertions(+), 44 deletions(-)

diff --git a/drivers/staging/ccree/ssi_hash.c b/drivers/staging/ccree/ssi_hash.c
index ed1c672..ffe8e1a 100644
--- a/drivers/staging/ccree/ssi_hash.c
+++ b/drivers/staging/ccree/ssi_hash.c
@@ -976,22 +976,6 @@ static int ssi_hash_init(struct ahash_req_ctx *state, 
struct ssi_hash_ctx *ctx)
return 0;
 }
 
-#ifdef EXPORT_FIXED
-static int ssi_hash_export(struct ssi_hash_ctx *ctx, void *out)
-{
-   CHECK_AND_RETURN_UPON_FIPS_ERROR();
-   memcpy(out, ctx, sizeof(struct ssi_hash_ctx));
-   return 0;
-}
-
-static int ssi_hash_import(struct ssi_hash_ctx *ctx, const void *in)
-{
-   CHECK_AND_RETURN_UPON_FIPS_ERROR();
-   memcpy(ctx, in, sizeof(struct ssi_hash_ctx));
-   return 0;
-}
-#endif
-
 static int ssi_hash_setkey(void *hash,
   const u8 *key,
   unsigned int keylen,
@@ -1782,23 +1766,107 @@ static int ssi_ahash_init(struct ahash_request *req)
return ssi_hash_init(state, ctx);
 }
 
-#ifdef EXPORT_FIXED
 static int ssi_ahash_export(struct ahash_request *req, void *out)
 {
struct crypto_ahash *ahash = crypto_ahash_reqtfm(req);
struct ssi_hash_ctx *ctx = crypto_ahash_ctx(ahash);
+   struct device *dev = &ctx->drvdata->plat_dev->dev;
+   struct ahash_req_ctx *state = ahash_request_ctx(req);
+   u8 *curr_buff = state->buff_index ? state->buff1 : state->buff0;
+   u32 curr_buff_cnt = state->buff_index ? state->buff1_cnt :
+   state->buff0_cnt;
+   const u32 tmp = CC_EXPORT_MAGIC;
+
+   CHECK_AND_RETURN_UPON_FIPS_ERROR();
 
-   return ssi_hash_export(ctx, out);
+   memcpy(out, &tmp, sizeof(u32));
+   out += sizeof(u32);
+
+   dma_sync_single_for_cpu(dev, state->digest_buff_dma_addr,
+   ctx->inter_digestsize, DMA_BIDIRECTIONAL);
+   memcpy(out, state->digest_buff, ctx->inter_digestsize);
+   out += ctx->inter_digestsize;
+
+   if (state->digest_bytes_len_dma_addr) {
+   dma_sync_single_for_cpu(dev, state->digest_bytes_len_dma_addr,
+   HASH_LEN_SIZE, DMA_BIDIRECTIONAL);
+   memcpy(out, state->digest_bytes_len, HASH_LEN_SIZE);
+   } else {
+   /* Poison the unused exported digest len field. */
+   memset(out, 0x5F, HASH_LEN_SIZE);
+   }
+   out += HASH_LEN_SIZE;
+
+   memcpy(out, &curr_buff_cnt, sizeof(u32));
+   out += sizeof(u32);
+
+   memcpy(out, curr_buff, curr_buff_cnt);
+
+   /* No sync for device ineeded since we did not change the data,
+* we only copy it
+*/
+
+   return 0;
 }
 
 static int ssi_ahash_import(struct ahash_request *req, const void *in)
 {
struct crypto_ahash *ahash = crypto_ahash_reqtfm(req);
struct ssi_hash_ctx *ctx = crypto_ahash_ctx(ahash);
+   struct device *dev = &ctx->drvdata->plat_dev->dev;
+   struct ahash_req_ctx *state = ahash_request_ctx(req);
+   u32 tmp;
+   int rc;
+
+   CHECK_AND_RETURN_UPON_FIPS_ERROR();
 
-   return ssi_hash_import(ctx, in);
+   memcpy(&tmp, in, sizeof(u32));
+   if (tmp != CC_EXPORT_MAGIC) {
+   rc = -EINVAL;
+   goto out;
+   }
+   in += sizeof(u32);
+
+   rc = ssi_hash_init(state, ctx);
+   if (rc)
+   goto out;
+
+   dma_sync_single_for_cpu(dev, state->digest_buff_dma_addr,
+   ctx->inter_digestsize, DMA_BIDIRECTIONAL);
+   memcpy(state->digest_buff, in, ctx->inter_digestsize);
+   in += ctx->inter_digestsize;
+
+   if (state->digest_bytes_len_dma_addr) {
+   dma_sync_single_for_cpu(dev, state->digest_bytes_len_dma_addr,
+   HASH_LEN_SIZE, DMA_BIDIRECTIONAL);
+   memcpy(state->digest_bytes_len, in, HASH_LEN_SIZE);
+   }
+   in += HASH_LEN_SIZE;
+
+   dma_sync_single_for_device(dev, state->digest_buff_dma_addr,
+  ctx->inter_digestsize, DMA_BIDIRECTIONAL);
+
+   if (state->digest_bytes_len_dma_addr)
+   dma_sync_single_for_device(dev,
+  state->digest_bytes_len_dma_addr,
+  HASH_LEN_SIZE, DMA_BIDIRECTIONAL);
+
+   state->buff_index = 0;
+
+   /* Sanity check the data as much as possible */
+   memcpy(&tmp, in, sizeof(u32));
+   if (tmp > SSI_MAX_HASH_BLCK_SIZE) {
+   rc = -EINVAL;
+   goto out;
+   }
+  

[PATCH v3 0/6] staging: ccree: bug fixes and TODO items for 4.13

2017-06-25 Thread Gilad Ben-Yossef
An assortment of bug fixes and staging TODO items.
Highlights includes the driver passing crypto testmgr boot tests
and relying on device tree for various HW config options as
opposed to build time configuration.

CC: Dan Carpenter 

Gilad Ben-Yossef (6):
  staging: ccree: fix hash import/export
  staging: ccree: register setkey for none hash macs
  staging: ccree: remove unused function
  staging: ccree: add clock management support
  staging: ccree: add DT bus coherency detection
  staging: ccree: use signal safe completion wait

Changes from v2:
- Rebased on latest staging-next.
- Added poison of unused hash import field based
  on review discussions with Dan Carpenter.
- Dropped older HW support patches for staging
  at GregKH request.
- Rewrote for clarity hash setkey fix commit
  message.
- Added now no longer needed KConfig option to
  code dropped by bus coherency being set by DT
  patch.

Changes from v1:
- Rebased on top of latest patches sent to mailing
  list but not yet marged for same driver.
- Address Dan Carpenter style review comments
- Fix clk de-init being called on clk init failure
  error path pointed out by Dan Carpenter.

 drivers/staging/ccree/Kconfig|   9 --
 drivers/staging/ccree/Makefile   |   2 +-
 drivers/staging/ccree/cc_hw_queue_defs.h |  12 --
 drivers/staging/ccree/ssi_buffer_mgr.c   |  37 ++---
 drivers/staging/ccree/ssi_config.h   |  20 ---
 drivers/staging/ccree/ssi_driver.c   |  55 ++--
 drivers/staging/ccree/ssi_driver.h   |   8 +-
 drivers/staging/ccree/ssi_hash.c | 226 +++
 drivers/staging/ccree/ssi_hash.h |   2 +
 drivers/staging/ccree/ssi_pm.c   |  13 +-
 drivers/staging/ccree/ssi_pm_ext.c   |  60 
 drivers/staging/ccree/ssi_pm_ext.h   |  33 -
 drivers/staging/ccree/ssi_request_mgr.c  |   3 +-
 13 files changed, 227 insertions(+), 253 deletions(-)
 delete mode 100644 drivers/staging/ccree/ssi_pm_ext.c
 delete mode 100644 drivers/staging/ccree/ssi_pm_ext.h

-- 
2.1.4

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