[PATCH v2] staging: emxx_udc: Fix styling issues

2016-12-20 Thread Afonso Bordado
Fix CamelCase styling issues with EP0_out_PIO
Remove unecessary temporary variables

Signed-off-by: Afonso Bordado 
---
 drivers/staging/emxx_udc/emxx_udc.c | 29 -
 1 file changed, 12 insertions(+), 17 deletions(-)

diff --git a/drivers/staging/emxx_udc/emxx_udc.c 
b/drivers/staging/emxx_udc/emxx_udc.c
index 3f42fa8..b0fbd10 100644
--- a/drivers/staging/emxx_udc/emxx_udc.c
+++ b/drivers/staging/emxx_udc/emxx_udc.c
@@ -553,28 +553,23 @@ static void _nbu2ss_dma_unmap_single(
 
 /*-*/
 /* Endpoint 0 OUT Transfer (PIO) */
-static int EP0_out_PIO(struct nbu2ss_udc *udc, u8 *pBuf, u32 length)
+static int ep0_out_pio(struct nbu2ss_udc *udc, u8 *buf, u32 length)
 {
-   u32 i;
-   int nret   = 0;
-   u32 iWordLength = 0;
-   union usb_reg_access *pBuf32 = (union usb_reg_access *)pBuf;
-
-   /**/
+   u32 i;
/* Read Length */
-   iWordLength = length / sizeof(u32);
+   u32 numreads = length / sizeof(u32);
+   union usb_reg_access *buf32 = (union usb_reg_access *)buf;
+
+   if (!numreads)
+   return 0;
 
-   /**/
/* PIO Read */
-   if (iWordLength) {
-   for (i = 0; i < iWordLength; i++) {
-   pBuf32->dw = _nbu2ss_readl(&udc->p_regs->EP0_READ);
-   pBuf32++;
-   }
-   nret = iWordLength * sizeof(u32);
+   for (i = 0; i < numreads; i++) {
+   buf32->dw = _nbu2ss_readl(&udc->p_regs->EP0_READ);
+   buf32++;
}
 
-   return nret;
+   return numreads * sizeof(u32);
 }
 
 /*-*/
@@ -758,7 +753,7 @@ static int _nbu2ss_ep0_out_transfer(
pBuffer = (u8 *)req->req.buf;
pBuffer += req->req.actual;
 
-   result = EP0_out_PIO(udc, pBuffer
+   result = ep0_out_pio(udc, pBuffer
, min(iRemainSize, iRecvLength));
if (result < 0)
return result;
-- 
2.9.3


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

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


Re: [PATCH v2] staging: emxx_udc: Fix styling issues

2016-12-20 Thread Greg KH
On Tue, Dec 20, 2016 at 09:48:48AM +, Afonso Bordado wrote:
> Fix CamelCase styling issues with EP0_out_PIO
> Remove unecessary temporary variables

Only do one-thing-per-patch please.

thanks,

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


Re: [greybus-dev] [PATCH 1/2] staging: greybus: loopback: use gb_loopback_async_wait_all don't spin

2016-12-20 Thread Johan Hovold
On Tue, Dec 20, 2016 at 01:12:08AM +, Bryan O'Donoghue wrote:
> Currently the greybus-loopback thread logic spins around waiting for
> send_count == iteration_max which on real hardware doesn't make a
> difference to us but in simulation is excruciatingly slow, anti-social and
> bad manners. Use the existing gb_loopback_async_wait_all() function to gate
> continuing when the send_count == iteration_max and go to sleep until
> there's something worthwhile to-do.
> 
> Signed-off-by: Bryan O'Donoghue 

You forgot to CC me and Alex.

> ---
>  drivers/staging/greybus/loopback.c | 12 
>  1 file changed, 12 insertions(+)
> 
> diff --git a/drivers/staging/greybus/loopback.c 
> b/drivers/staging/greybus/loopback.c
> index 7882306..d6302ef 100644
> --- a/drivers/staging/greybus/loopback.c
> +++ b/drivers/staging/greybus/loopback.c
> @@ -1008,11 +1008,23 @@ static int gb_loopback_fn(void *data)
>  
>   /* Optionally terminate */
>   if (gb->send_count == gb->iteration_max) {
> + mutex_unlock(&gb->mutex);
> +
> + /* Wait for synchronous and asynchronus completion */
> + gb_loopback_async_wait_all(gb);

This introduces a non-interruptible wait here, which should be ok given
that all outstanding operations will be cancelled by core as part of
connection disable before stopping the kthread during disconnect.

But this driver is full of such subtleties and really needs a clean up
(or rewrite).

> +
> + /* Mark complete unless user-space has poked us */
> + mutex_lock(&gb->mutex);
>   if (gb->iteration_count == gb->iteration_max) {
>   gb->type = 0;
>   gb->send_count = 0;
>   sysfs_notify(&gb->dev->kobj,  NULL,
>   "iteration_count");
> + dev_dbg(&gb->connection->bundle->dev,

You have a pointer to the bundle you should use here and below.

> + "load test complete\n");
> + } else {
> + dev_dbg(&gb->connection->bundle->dev,
> + "continuing on with new test set\n");

The fact that user-space can reset test counters and change parameters
while a test is running is really another bug.

>   }
>   mutex_unlock(&gb->mutex);
>   continue;

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


Re: [PATCH] staging: lustre: ldlm: use designated initializers

2016-12-20 Thread Dan Carpenter
On Mon, Dec 19, 2016 at 04:22:58PM +, James Simmons wrote:
> 
> > Prepare to mark sensitive kernel structures for randomization by making
> > sure they're using designated initializers. These were identified during
> > allyesconfig builds of x86, arm, and arm64, with most initializer fixes
> > extracted from grsecurity.
> > 
> > Signed-off-by: Kees Cook 
> > ---
> >  drivers/staging/lustre/lustre/ldlm/ldlm_flock.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c 
> > b/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c
> > index 722160784f83..f815827532dc 100644
> > --- a/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c
> > +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c
> > @@ -143,7 +143,7 @@ static int ldlm_process_flock_lock(struct ldlm_lock 
> > *req, __u64 *flags,
> > int added = (mode == LCK_NL);
> > int overlaps = 0;
> > int splitted = 0;
> > -   const struct ldlm_callback_suite null_cbs = { NULL };
> > +   const struct ldlm_callback_suite null_cbs = { };
> >  
> > CDEBUG(D_DLMTRACE,
> >"flags %#llx owner %llu pid %u mode %u start %llu end %llu\n",
> 
> Nak. Filling null_cbs with random data is a bad idea.

You've misunderstood.  The plugin just changes how the struct is laid
out, it doesn't put data into the struct.  So this is fine.

The places where it's not fine are when the layout is required because
it's shared with userspace or set by the hardware.

regards,
dan carpenter

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


PATCH] drivers/staging/dgnc/dgnc_mgmt.c add some goto statements

2016-12-20 Thread Francis Laniel
Hello.


As asked in the TODO file for this driver I added some goto statements to
handle errors.

I used Linus Torvalds tree, I compiled it and tested it with a virtual
machine, here is the proof :
[   42.394265] dgnc: module is from the staging directory, ...
[root@vm-nmv ~]# uname -r
4.9.0-11815-ge93b1cc-dirty

It is my first patch so I hope I did not break anything.


Good bye and thank you.

Signed-off-by: Francis Laniel 
---
 drivers/staging/dgnc/dgnc_mgmt.c | 19 ++-
 1 file changed, 14 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/dgnc/dgnc_mgmt.c b/drivers/staging/dgnc/
dgnc_mgmt.c
index 9d9b15d..6e41010 100644
--- a/drivers/staging/dgnc/dgnc_mgmt.c
+++ b/drivers/staging/dgnc/dgnc_mgmt.c
@@ -40,27 +40,34 @@ static int dgnc_mgmt_in_use[MAXMGMTDEVICES];
  */
 int dgnc_mgmt_open(struct inode *inode, struct file *file)
 {
+   int rc;
+
unsigned long flags;
unsigned int minor = iminor(inode);
 
spin_lock_irqsave(&dgnc_global_lock, flags);
 
+   rc = 0;
+
/* mgmt device */
if (minor < MAXMGMTDEVICES) {
/* Only allow 1 open at a time on mgmt device */
if (dgnc_mgmt_in_use[minor]) {
-   spin_unlock_irqrestore(&dgnc_global_lock, flags);
-   return -EBUSY;
+   rc = -EBUSY;
+
+   goto end;
}
dgnc_mgmt_in_use[minor]++;
} else {
-   spin_unlock_irqrestore(&dgnc_global_lock, flags);
-   return -ENXIO;
+   rc = -ENXIO;
+
+   goto end;
}
 
+end:
spin_unlock_irqrestore(&dgnc_global_lock, flags);
 
-   return 0;
+   return rc;
 }
 
 /*
@@ -110,6 +117,8 @@ long dgnc_mgmt_ioctl(struct file *file, unsigned int cmd,
unsigned long arg)
 
memset(&ddi, 0, sizeof(ddi));
ddi.dinfo_nboards = dgnc_num_boards;
+
+   /* Is it possible to use snprintf ? */
sprintf(ddi.dinfo_version, "%s", DG_PART);
 
spin_unlock_irqrestore(&dgnc_global_lock, flags);
-- 
2.9.3
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [greybus-dev] [PATCH 1/2] staging: greybus: loopback: use gb_loopback_async_wait_all don't spin

2016-12-20 Thread Bryan O'Donoghue
On 20/12/16 10:28, Johan Hovold wrote:
> On Tue, Dec 20, 2016 at 01:12:08AM +, Bryan O'Donoghue wrote:
>> Currently the greybus-loopback thread logic spins around waiting for
>> send_count == iteration_max which on real hardware doesn't make a
>> difference to us but in simulation is excruciatingly slow, anti-social and
>> bad manners. Use the existing gb_loopback_async_wait_all() function to gate
>> continuing when the send_count == iteration_max and go to sleep until
>> there's something worthwhile to-do.
>>
>> Signed-off-by: Bryan O'Donoghue 
> 
> You forgot to CC me and Alex.
> 
>> ---
>>  drivers/staging/greybus/loopback.c | 12 
>>  1 file changed, 12 insertions(+)
>>
>> diff --git a/drivers/staging/greybus/loopback.c 
>> b/drivers/staging/greybus/loopback.c
>> index 7882306..d6302ef 100644
>> --- a/drivers/staging/greybus/loopback.c
>> +++ b/drivers/staging/greybus/loopback.c
>> @@ -1008,11 +1008,23 @@ static int gb_loopback_fn(void *data)
>>  
>>  /* Optionally terminate */
>>  if (gb->send_count == gb->iteration_max) {
>> +mutex_unlock(&gb->mutex);
>> +
>> +/* Wait for synchronous and asynchronus completion */
>> +gb_loopback_async_wait_all(gb);
> 
> This introduces a non-interruptible wait here, which should be ok given
> that all outstanding operations will be cancelled by core as part of
> connection disable before stopping the kthread during disconnect.
> 
> But this driver is full of such subtleties and really needs a clean up
> (or rewrite).

A rewrite is on the bucket list at some point.

>> +
>> +/* Mark complete unless user-space has poked us */
>> +mutex_lock(&gb->mutex);
>>  if (gb->iteration_count == gb->iteration_max) {
>>  gb->type = 0;
>>  gb->send_count = 0;
>>  sysfs_notify(&gb->dev->kobj,  NULL,
>>  "iteration_count");
>> +dev_dbg(&gb->connection->bundle->dev,
> 
> You have a pointer to the bundle you should use here and below.

Will do.

> 
>> +"load test complete\n");
>> +} else {
>> +dev_dbg(&gb->connection->bundle->dev,
>> +"continuing on with new test set\n");
> 
> The fact that user-space can reset test counters and change parameters
> while a test is running is really another bug.

Agreed will be done on the rewrite.

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


Re: [PATCH] rtlwifi: Fix kernel oops introduced with commit e49656147359

2016-12-20 Thread Kalle Valo
Larry Finger  writes:

> With commit e49656147359 {"rtlwifi: Use dev_kfree_skb_irq instead of
> kfree_skb"), the method used to free an skb was changed because the
> kfree_skb() was inside a spinlock. What was forgotten is that kfree_skb()
> guards against a NULL value for the argument. Routine dev_kfree_skb_irq()
> does not, and a test is needed to prevent kernel panics.
>
> Fixes: commit e49656147359 {"rtlwifi: Use dev_kfree_skb_irq instead of 
> kfree_skb")

This should be:

Fixes: e49656147359 ("rtlwifi: Use dev_kfree_skb_irq instead of kfree_skb")

> Signed-off-by: Larry Finger 
> Cc: Stable  (4.9+)

And this:

Cc: Stable  # 4.9+

I can fix both of them.

> Cc: Wei Yongjun 
> ---
> Kalle,
>
> This change should be sent to mainline during the 4.10 merge period,
> or as soon as possible.

Ok, I'll queue this to 4.10. Most likely I'll send a pull request to
Dave later this week or so.

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


Re: PATCH] drivers/staging/dgnc/dgnc_mgmt.c add some goto statements

2016-12-20 Thread Dan Carpenter
This patch doesn't apply.  Read Documentation/process/email-clients.rst

On Tue, Dec 20, 2016 at 11:49:41AM +0100, Francis Laniel wrote:
> Hello.
> 
> 
> As asked in the TODO file for this driver I added some goto statements to
> handle errors.
> 
> I used Linus Torvalds tree, I compiled it and tested it with a virtual
> machine, here is the proof :
> [   42.394265] dgnc: module is from the staging directory, ...
> [root@vm-nmv ~]# uname -r
> 4.9.0-11815-ge93b1cc-dirty
> 
> It is my first patch so I hope I did not break anything.
> 
> 
> Good bye and thank you.

Don't put this stuff in the changelog text.

> 
> Signed-off-by: Francis Laniel 
> ---
>  drivers/staging/dgnc/dgnc_mgmt.c | 19 ++-
>  1 file changed, 14 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/staging/dgnc/dgnc_mgmt.c b/drivers/staging/dgnc/
> dgnc_mgmt.c
> index 9d9b15d..6e41010 100644
> --- a/drivers/staging/dgnc/dgnc_mgmt.c
> +++ b/drivers/staging/dgnc/dgnc_mgmt.c
> @@ -40,27 +40,34 @@ static int dgnc_mgmt_in_use[MAXMGMTDEVICES];
>   */
>  int dgnc_mgmt_open(struct inode *inode, struct file *file)
>  {
> +   int rc;
> +

No blank line.

> unsigned long flags;
> unsigned int minor = iminor(inode);
>  
> spin_lock_irqsave(&dgnc_global_lock, flags);
>  
> +   rc = 0;


Just do that at the start.

> +
> /* mgmt device */
> if (minor < MAXMGMTDEVICES) {
> /* Only allow 1 open at a time on mgmt device */
> if (dgnc_mgmt_in_use[minor]) {
> -   spin_unlock_irqrestore(&dgnc_global_lock, flags);
> -   return -EBUSY;
> +   rc = -EBUSY;
> +

Don't add the extra blank line.

> +   goto end;
> }
> dgnc_mgmt_in_use[minor]++;
> } else {
> -   spin_unlock_irqrestore(&dgnc_global_lock, flags);
> -   return -ENXIO;
> +   rc = -ENXIO;
> +
> +   goto end;
> }
>  
> +end:


unlock: is a better name.


> spin_unlock_irqrestore(&dgnc_global_lock, flags);
>  
> -   return 0;
> +   return rc;
>  }
>  
>  /*
> @@ -110,6 +117,8 @@ long dgnc_mgmt_ioctl(struct file *file, unsigned int cmd,
> unsigned long arg)
>  
> memset(&ddi, 0, sizeof(ddi));
> ddi.dinfo_nboards = dgnc_num_boards;
> +
> +   /* Is it possible to use snprintf ? */
> sprintf(ddi.dinfo_version, "%s", DG_PART);

This is not related, but yeah.  You could use snprintf() if you want.
It's not super important because we know that the original code is fine.

regards,
dan carpenter

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


[PATCH v3 2/4] staging: emxx_udc: Rename CamelCase variable

2016-12-20 Thread Afonso Bordado
The new name complies with the kernel styling guidelines and is more 
descriptive.

Signed-off-by: Afonso Bordado 
---
 drivers/staging/emxx_udc/emxx_udc.c | 12 
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/drivers/staging/emxx_udc/emxx_udc.c 
b/drivers/staging/emxx_udc/emxx_udc.c
index 51ad04b..0963533 100644
--- a/drivers/staging/emxx_udc/emxx_udc.c
+++ b/drivers/staging/emxx_udc/emxx_udc.c
@@ -557,21 +557,17 @@ static int ep0_out_pio(struct nbu2ss_udc *udc, u8 *pBuf, 
u32 length)
 {
u32 i;
int nret   = 0;
-   u32 iWordLength = 0;
+   u32 numreads = length / sizeof(u32);
union usb_reg_access *pBuf32 = (union usb_reg_access *)pBuf;
 
/**/
-   /* Read Length */
-   iWordLength = length / sizeof(u32);
-
-   /**/
/* PIO Read */
-   if (iWordLength) {
-   for (i = 0; i < iWordLength; i++) {
+   if (numreads) {
+   for (i = 0; i < numreads; i++) {
pBuf32->dw = _nbu2ss_readl(&udc->p_regs->EP0_READ);
pBuf32++;
}
-   nret = iWordLength * sizeof(u32);
+   nret = numreads * sizeof(u32);
}
 
return nret;
-- 
2.9.3


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


[PATCH v3 3/4] staging: emxx_udc: Remove unecessary temporary variable

2016-12-20 Thread Afonso Bordado
This improves code readability.

Signed-off-by: Afonso Bordado 
---
 drivers/staging/emxx_udc/emxx_udc.c | 16 +++-
 1 file changed, 7 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/emxx_udc/emxx_udc.c 
b/drivers/staging/emxx_udc/emxx_udc.c
index 0963533..45808ed 100644
--- a/drivers/staging/emxx_udc/emxx_udc.c
+++ b/drivers/staging/emxx_udc/emxx_udc.c
@@ -556,21 +556,19 @@ static void _nbu2ss_dma_unmap_single(
 static int ep0_out_pio(struct nbu2ss_udc *udc, u8 *pBuf, u32 length)
 {
u32 i;
-   int nret   = 0;
u32 numreads = length / sizeof(u32);
union usb_reg_access *pBuf32 = (union usb_reg_access *)pBuf;
 
-   /**/
+   if (!numreads)
+   return 0;
+
/* PIO Read */
-   if (numreads) {
-   for (i = 0; i < numreads; i++) {
-   pBuf32->dw = _nbu2ss_readl(&udc->p_regs->EP0_READ);
-   pBuf32++;
-   }
-   nret = numreads * sizeof(u32);
+   for (i = 0; i < numreads; i++) {
+   pBuf32->dw = _nbu2ss_readl(&udc->p_regs->EP0_READ);
+   pBuf32++;
}
 
-   return nret;
+   return  numreads * sizeof(u32);
 }
 
 /*-*/
-- 
2.9.3


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


[PATCH v3 1/4] staging: emxx_udc: Fix CamelCase function name

2016-12-20 Thread Afonso Bordado
Change EP0_out_PIO to use the kernel convention.

Signed-off-by: Afonso Bordado 
---
 drivers/staging/emxx_udc/emxx_udc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/emxx_udc/emxx_udc.c 
b/drivers/staging/emxx_udc/emxx_udc.c
index 3f42fa8..51ad04b 100644
--- a/drivers/staging/emxx_udc/emxx_udc.c
+++ b/drivers/staging/emxx_udc/emxx_udc.c
@@ -553,7 +553,7 @@ static void _nbu2ss_dma_unmap_single(
 
 /*-*/
 /* Endpoint 0 OUT Transfer (PIO) */
-static int EP0_out_PIO(struct nbu2ss_udc *udc, u8 *pBuf, u32 length)
+static int ep0_out_pio(struct nbu2ss_udc *udc, u8 *pBuf, u32 length)
 {
u32 i;
int nret   = 0;
@@ -758,7 +758,7 @@ static int _nbu2ss_ep0_out_transfer(
pBuffer = (u8 *)req->req.buf;
pBuffer += req->req.actual;
 
-   result = EP0_out_PIO(udc, pBuffer
+   result = ep0_out_pio(udc, pBuffer
, min(iRemainSize, iRecvLength));
if (result < 0)
return result;
-- 
2.9.3


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


[PATCH v3 0/4] staging: emxx_udc: Fix checkpatch.pl CamelCase issues

2016-12-20 Thread Afonso Bordado
Fix checkpatch.pl issues with CamelCase.
Improves readability by removing temporary variables.

Afonso Bordado (4):
  staging: emxx_udc: Fix CamelCase function name
  staging: emxx_udc: Rename CamelCase variable
  staging: emxx_udc: Remove unecessary temporary variable
  staging: emxx_udc: Fix CamelCase variable name

 drivers/staging/emxx_udc/emxx_udc.c | 26 ++
 1 file changed, 10 insertions(+), 16 deletions(-)

-- 
2.9.3


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


[PATCH v3 4/4] staging: emxx_udc: Fix CamelCase variable name

2016-12-20 Thread Afonso Bordado
Changes from CamelCase to a kernel format

Signed-off-by: Afonso Bordado 
---
 drivers/staging/emxx_udc/emxx_udc.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/emxx_udc/emxx_udc.c 
b/drivers/staging/emxx_udc/emxx_udc.c
index 45808ed..c19ce17 100644
--- a/drivers/staging/emxx_udc/emxx_udc.c
+++ b/drivers/staging/emxx_udc/emxx_udc.c
@@ -553,19 +553,19 @@ static void _nbu2ss_dma_unmap_single(
 
 /*-*/
 /* Endpoint 0 OUT Transfer (PIO) */
-static int ep0_out_pio(struct nbu2ss_udc *udc, u8 *pBuf, u32 length)
+static int ep0_out_pio(struct nbu2ss_udc *udc, u8 *buf, u32 length)
 {
u32 i;
u32 numreads = length / sizeof(u32);
-   union usb_reg_access *pBuf32 = (union usb_reg_access *)pBuf;
+   union usb_reg_access *buf32 = (union usb_reg_access *)buf;
 
if (!numreads)
return 0;
 
/* PIO Read */
for (i = 0; i < numreads; i++) {
-   pBuf32->dw = _nbu2ss_readl(&udc->p_regs->EP0_READ);
-   pBuf32++;
+   buf32->dw = _nbu2ss_readl(&udc->p_regs->EP0_READ);
+   buf32++;
}
 
return  numreads * sizeof(u32);
-- 
2.9.3


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


[PATCH] staging: lustre: osc: use rb_entry_safe

2016-12-20 Thread Geliang Tang
Use rb_entry_safe() instead of container_of() to simplify the code.

Signed-off-by: Geliang Tang 
---
 drivers/staging/lustre/lustre/osc/osc_cache.c | 5 +
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/staging/lustre/lustre/osc/osc_cache.c 
b/drivers/staging/lustre/lustre/osc/osc_cache.c
index b0f030c..6048df9 100644
--- a/drivers/staging/lustre/lustre/osc/osc_cache.c
+++ b/drivers/staging/lustre/lustre/osc/osc_cache.c
@@ -142,10 +142,7 @@ static const char *oes_strings[] = {
 
 static inline struct osc_extent *rb_extent(struct rb_node *n)
 {
-   if (!n)
-   return NULL;
-
-   return container_of(n, struct osc_extent, oe_node);
+   return rb_entry_safe(n, struct osc_extent, oe_node);
 }
 
 static inline struct osc_extent *next_extent(struct osc_extent *ext)
-- 
2.9.3

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


RE: [PATCH] staging: lustre: ldlm: use designated initializers

2016-12-20 Thread Hammond, John
> On Mon, Dec 19, 2016 at 08:47:50AM -0800, Bruce Korb wrote:
> > On Mon, Dec 19, 2016 at 8:22 AM, James Simmons
> > >> --- a/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c
> > >> +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c
> > >> @@ -143,7 +143,7 @@ static int ldlm_process_flock_lock(struct ldlm_lock
> *req, __u64 *flags,
> > >>   int added = (mode == LCK_NL);
> > >>   int overlaps = 0;
> > >>   int splitted = 0;
> > >> - const struct ldlm_callback_suite null_cbs = { NULL };
> > >> + const struct ldlm_callback_suite null_cbs = { };
> > >>
> > >>   CDEBUG(D_DLMTRACE,
> > >>  "flags %#llx owner %llu pid %u mode %u start %llu end
> > >> %llu\n",
> > >
> > > Nak. Filling null_cbs with random data is a bad idea. If you look at
> > > ldlm_lock_create() where this is used you have
> > >
> > > if (cbs) {
> > > lock->l_blocking_ast = cbs->lcs_blocking;
> > > lock->l_completion_ast = cbs->lcs_completion;
> > > lock->l_glimpse_ast = cbs->lcs_glimpse; }
> > >
> > > Having lock->l_* point to random addresses is a bad idea.
> > > What really needs to be done is proper initialization of that
> > > structure. A bunch of patches will be coming to address this.
> >
> > I'm not understanding the effect of the original difference.  If you
> > specify any initializer, then all fields not specified are filled with
> > zero bits. Any pointers are, perforce, NULL.  That should make both "{
> > NULL }" and "{}" equivalent.
> 
> They are equivalent, yes, but people want to use a GCC plugin that randomizes
> struct layouts for internal structures and the plugin doesn't work when you 
> use
> struct ordering to initialize the struct.  The plugin requires that you use
> designated intializers.

"{ NULL }" is valid ISO C, but unfortunately "{}" is not.
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] rtlwifi: Fix kernel oops introduced with commit e49656147359

2016-12-20 Thread Larry Finger

On 12/20/2016 05:21 AM, Kalle Valo wrote:

Larry Finger  writes:


With commit e49656147359 {"rtlwifi: Use dev_kfree_skb_irq instead of
kfree_skb"), the method used to free an skb was changed because the
kfree_skb() was inside a spinlock. What was forgotten is that kfree_skb()
guards against a NULL value for the argument. Routine dev_kfree_skb_irq()
does not, and a test is needed to prevent kernel panics.

Fixes: commit e49656147359 {"rtlwifi: Use dev_kfree_skb_irq instead of 
kfree_skb")


This should be:

Fixes: e49656147359 ("rtlwifi: Use dev_kfree_skb_irq instead of kfree_skb")


Signed-off-by: Larry Finger 
Cc: Stable  (4.9+)


And this:

Cc: Stable  # 4.9+

I can fix both of them.


Cc: Wei Yongjun 
---
Kalle,

This change should be sent to mainline during the 4.10 merge period,
or as soon as possible.


Ok, I'll queue this to 4.10. Most likely I'll send a pull request to
Dave later this week or so.


Thanks for the suggested changes, and for the quick action.

Larry


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


[PATCH 10/15] hyperv: uapi-fy PostMessage and SignalEvent hypercall structures

2016-12-20 Thread Roman Kagan
Expose structures used for PostMessage and SignalEvent hypercalls in a
uapi header.  While doing so, simplify alignment handling and drop
unnecessary complications in the connectionid field.

Signed-off-by: Roman Kagan 
---
 arch/x86/include/uapi/asm/hyperv.h | 18 ++
 drivers/hv/hyperv_vmbus.h  | 16 ++--
 include/linux/hyperv.h | 24 +---
 drivers/hv/channel_mgmt.c  | 14 --
 drivers/hv/connection.c|  9 +++--
 drivers/hv/hv.c|  2 +-
 drivers/hv/vmbus_drv.c |  2 +-
 7 files changed, 30 insertions(+), 55 deletions(-)

diff --git a/arch/x86/include/uapi/asm/hyperv.h 
b/arch/x86/include/uapi/asm/hyperv.h
index 749fbb25..eb8d42a 100644
--- a/arch/x86/include/uapi/asm/hyperv.h
+++ b/arch/x86/include/uapi/asm/hyperv.h
@@ -378,4 +378,22 @@ struct hv_synic_event_flags_page {
struct hv_synic_event_flags sintevent_flags[HV_SYNIC_SINT_COUNT];
 };
 
+#define HV_HYPERCALL_PARAM_ALIGN   8
+
+/* Definition of the hv_post_message hypercall input structure. */
+struct hv_input_post_message {
+   __u32 connectionid;
+   __u32 reserved;
+   __u32 message_type;
+   __u32 payload_size;
+   __u64 payload[HV_MESSAGE_PAYLOAD_BYTE_COUNT];
+} __attribute__((aligned(HV_HYPERCALL_PARAM_ALIGN)));
+
+/* Definition of the hv_signal_event hypercall input structure. */
+struct hv_input_signal_event {
+   __u32 connectionid;
+   __u16 flag_number;
+   __u16 rsvdz;
+} __attribute__((aligned(HV_HYPERCALL_PARAM_ALIGN)));
+
 #endif
diff --git a/drivers/hv/hyperv_vmbus.h b/drivers/hv/hyperv_vmbus.h
index ac73832..a96f021 100644
--- a/drivers/hv/hyperv_vmbus.h
+++ b/drivers/hv/hyperv_vmbus.h
@@ -104,7 +104,7 @@ union hv_monitor_trigger_group {
 };
 
 struct hv_monitor_parameter {
-   union hv_connection_id connectionid;
+   u32 connectionid;
u16 flagnumber;
u16 rsvdz;
 };
@@ -154,15 +154,6 @@ struct hv_monitor_page {
u8 rsvdz4[1984];
 };
 
-/* Definition of the hv_post_message hypercall input structure. */
-struct hv_input_post_message {
-   union hv_connection_id connectionid;
-   u32 reserved;
-   u32 message_type;
-   u32 payload_size;
-   u64 payload[HV_MESSAGE_PAYLOAD_QWORD_COUNT];
-};
-
 /*
  * Versioning definitions used for guests reporting themselves to the
  * hypervisor, and visa versa.
@@ -248,9 +239,6 @@ static inline  __u64 generate_guest_id(__u8 d_info1, __u32 
kernel_version,
 #define HV_CAPS_MAX8
 
 
-#define HV_HYPERCALL_PARAM_ALIGN   sizeof(u64)
-
-
 /* Service definitions */
 
 #define HV_SERVICE_PARENT_PORT (0)
@@ -351,7 +339,7 @@ extern int hv_init(void);
 
 extern void hv_cleanup(bool crash);
 
-extern int hv_post_message(union hv_connection_id connection_id,
+extern int hv_post_message(u32 connection_id,
 enum hv_message_type message_type,
 void *payload, size_t payload_size);
 
diff --git a/include/linux/hyperv.h b/include/linux/hyperv.h
index 42fe43f..e92446e 100644
--- a/include/linux/hyperv.h
+++ b/include/linux/hyperv.h
@@ -648,27 +648,6 @@ struct vmbus_close_msg {
struct vmbus_channel_close_channel msg;
 };
 
-/* Define connection identifier type. */
-union hv_connection_id {
-   u32 asu32;
-   struct {
-   u32 id:24;
-   u32 reserved:8;
-   } 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_signal_policy {
HV_SIGNAL_POLICY_DEFAULT = 0,
HV_SIGNAL_POLICY_EXPLICIT,
@@ -755,8 +734,7 @@ struct vmbus_channel {
bool batched_reading;
 
bool is_dedicated_interrupt;
-   struct hv_input_signal_event_buffer sig_buf;
-   struct hv_input_signal_event *sig_event;
+   struct hv_input_signal_event sig_event;
 
/*
 * Starting with win8, this field will be used to specify
diff --git a/drivers/hv/channel_mgmt.c b/drivers/hv/channel_mgmt.c
index 49eaae2..4a5cc11 100644
--- a/drivers/hv/channel_mgmt.c
+++ b/drivers/hv/channel_mgmt.c
@@ -766,20 +766,14 @@ 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;
+ 

[PATCH 00/15] hyperv: more stuff to uapi + cleanup

2016-12-20 Thread Roman Kagan
Expose more Hyper-V-related definitions in the uapi header for
consumption by userspace.

While doing so, get rid of a number of duplications between the KVM and
the guest driver code.  Also a few other cleanups are made which are not
strictly necessary for the main purpose of the series but appear
reasonable to do at the same time.

The most controversial is the last patch which modifies the stuff
already published in the uapi header, in the hope that no userspace
applications have started relying on it; I'm ok dropping it if this is
unacceptable.

Roman Kagan (15):
  hyperv: consolidate TSC ref page definitions
  hyperv: uapi-fy synic event flags definitions
  hyperv: use standard bitops
  hyperv: define VMBus message type
  hyperv: GFP_ATOMIC -> GFP_KERNEL
  hyperv: avoid unnecessary vmalloc
  hyperv: dedup cpuid definitions
  hyperv: dedup crash msr related definitions
  hyperv: unify Hyper-V msr definitions
  hyperv: uapi-fy PostMessage and SignalEvent hypercall structures
  hyperv: uapi-fy monitored notification structures
  hyperv: move VMBus connection ids to uapi
  hyperv: move function close to its only callsite
  hyperv_vmbus: drop unused definitions
  hyperv: redefine hv_message without bitfields

 arch/x86/include/asm/kvm_host.h|   2 +-
 arch/x86/include/uapi/asm/hyperv.h | 101 +++---
 drivers/hv/hyperv_vmbus.h  | 399 +
 include/linux/hyperv.h |  24 +--
 arch/x86/kvm/hyperv.c  |  14 +-
 drivers/hv/channel.c   |   8 +-
 drivers/hv/channel_mgmt.c  |  30 +--
 drivers/hv/connection.c|  65 ++
 drivers/hv/hv.c| 300 +---
 drivers/hv/vmbus_drv.c |  67 +++
 10 files changed, 288 insertions(+), 722 deletions(-)

-- 
2.9.3

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


[PATCH 02/15] hyperv: uapi-fy synic event flags definitions

2016-12-20 Thread Roman Kagan
Move definitions related to the Hyper-V SynIC event flags to a header
where they can be consumed by userspace.

While doing so, also clean up their use by switching to standard bitops
and struct-based dereferencing.  The latter is also done for message
pages.

Signed-off-by: Roman Kagan 
---
 arch/x86/include/uapi/asm/hyperv.h | 13 +
 drivers/hv/hyperv_vmbus.h  | 24 ++--
 drivers/hv/channel_mgmt.c  | 10 +++
 drivers/hv/connection.c| 47 ++-
 drivers/hv/vmbus_drv.c | 57 ++
 5 files changed, 54 insertions(+), 97 deletions(-)

diff --git a/arch/x86/include/uapi/asm/hyperv.h 
b/arch/x86/include/uapi/asm/hyperv.h
index 6098ab5..af542a3 100644
--- a/arch/x86/include/uapi/asm/hyperv.h
+++ b/arch/x86/include/uapi/asm/hyperv.h
@@ -363,4 +363,17 @@ struct hv_timer_message_payload {
 #define HV_STIMER_AUTOENABLE   (1ULL << 3)
 #define HV_STIMER_SINT(config) (__u8)(((config) >> 16) & 0x0F)
 
+/* Define synthetic interrupt controller flag constants. */
+#define HV_EVENT_FLAGS_COUNT   (256 * 8)
+
+/* Define the synthetic interrupt controller event flags format. */
+struct hv_synic_event_flags {
+   __u64 flags[HV_EVENT_FLAGS_COUNT / 64];
+};
+
+/* Define the synthetic interrupt flags page layout. */
+struct hv_synic_event_flags_page {
+   struct hv_synic_event_flags sintevent_flags[HV_SYNIC_SINT_COUNT];
+};
+
 #endif
diff --git a/drivers/hv/hyperv_vmbus.h b/drivers/hv/hyperv_vmbus.h
index 4516498..4fab154 100644
--- a/drivers/hv/hyperv_vmbus.h
+++ b/drivers/hv/hyperv_vmbus.h
@@ -26,7 +26,6 @@
 #define _HYPERV_VMBUS_H
 
 #include 
-#include 
 #include 
 #include 
 
@@ -75,11 +74,6 @@ enum hv_cpuid_function {
 
 #define HV_ANY_VP  (0x)
 
-/* Define synthetic interrupt controller flag constants. */
-#define HV_EVENT_FLAGS_COUNT   (256 * 8)
-#define HV_EVENT_FLAGS_BYTE_COUNT  (256)
-#define HV_EVENT_FLAGS_DWORD_COUNT (256 / sizeof(u32))
-
 /* Define invalid partition identifier. */
 #define HV_PARTITION_ID_INVALID((u64)0x0)
 
@@ -146,20 +140,6 @@ union hv_timer_config {
};
 };
 
-/* Define the number of message buffers associated with each port. */
-#define HV_PORT_MESSAGE_BUFFER_COUNT   (16)
-
-/* Define the synthetic interrupt controller event flags format. */
-union hv_synic_event_flags {
-   u8 flags8[HV_EVENT_FLAGS_BYTE_COUNT];
-   u32 flags32[HV_EVENT_FLAGS_DWORD_COUNT];
-};
-
-/* Define the synthetic interrupt flags page layout. */
-struct hv_synic_event_flags_page {
-   union hv_synic_event_flags sintevent_flags[HV_SYNIC_SINT_COUNT];
-};
-
 /* Define SynIC control register. */
 union hv_synic_scontrol {
u64 as_uint64;
@@ -434,8 +414,8 @@ struct hv_context {
 
bool synic_initialized;
 
-   void *synic_message_page[NR_CPUS];
-   void *synic_event_page[NR_CPUS];
+   struct hv_message_page *synic_message_page[NR_CPUS];
+   struct hv_synic_event_flags_page *synic_event_page[NR_CPUS];
/*
 * Hypervisor's notion of virtual processor ID is different from
 * Linux' notion of CPU ID. This information can only be retrieved
diff --git a/drivers/hv/channel_mgmt.c b/drivers/hv/channel_mgmt.c
index 26b4192..49eaae2 100644
--- a/drivers/hv/channel_mgmt.c
+++ b/drivers/hv/channel_mgmt.c
@@ -654,7 +654,6 @@ static void init_vp_index(struct vmbus_channel *channel, 
u16 dev_type)
 static void vmbus_wait_for_unload(void)
 {
int cpu;
-   void *page_addr;
struct hv_message *msg;
struct vmbus_channel_message_header *hdr;
u32 message_type;
@@ -673,9 +672,8 @@ static void vmbus_wait_for_unload(void)
break;
 
for_each_online_cpu(cpu) {
-   page_addr = hv_context.synic_message_page[cpu];
-   msg = (struct hv_message *)page_addr +
-   VMBUS_MESSAGE_SINT;
+   msg = &hv_context.synic_message_page[cpu]->
+   sint_message[VMBUS_MESSAGE_SINT];
 
message_type = READ_ONCE(msg->header.message_type);
if (message_type == HVMSG_NONE)
@@ -699,8 +697,8 @@ static void vmbus_wait_for_unload(void)
 * messages after we reconnect.
 */
for_each_online_cpu(cpu) {
-   page_addr = hv_context.synic_message_page[cpu];
-   msg = (struct hv_message *)page_addr + VMBUS_MESSAGE_SINT;
+   msg = &hv_context.synic_message_page[cpu]->
+   sint_message[VMBUS_MESSAGE_SINT];
msg->header.message_type = HVMSG_NONE;
}
 }
diff --git a/drivers/hv/connection.c b/drivers/hv/connection.c
index 6ce8b87..aaa2103 100644
--- a/drivers/hv/connection.c
+++ b/drivers/hv/connection.c
@@ -381,17 +381,12 @@ static void process_chn_event(u32 relid)
  */
 v

[PATCH 06/15] hyperv: avoid unnecessary vmalloc

2016-12-20 Thread Roman Kagan
Make hypercall and tsc page allocation similar to the rest of the
Hyper-V shared memory stuff instead of vmalloc-ing them.

Also perform cleanup unconditionally which is safe.

TODO: the skipping of free in case of a crash is probably no longer
necessary, too.

Signed-off-by: Roman Kagan 
---
 drivers/hv/hv.c | 42 ++
 1 file changed, 18 insertions(+), 24 deletions(-)

diff --git a/drivers/hv/hv.c b/drivers/hv/hv.c
index 6bbc0b09..b40c7d9 100644
--- a/drivers/hv/hv.c
+++ b/drivers/hv/hv.c
@@ -29,6 +29,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include "hyperv_vmbus.h"
@@ -208,14 +209,15 @@ int hv_init(void)
/* See if the hypercall page is already set */
rdmsrl(HV_X64_MSR_HYPERCALL, hypercall_msr.as_uint64);
 
-   virtaddr = __vmalloc(PAGE_SIZE, GFP_KERNEL, PAGE_KERNEL_EXEC);
-
-   if (!virtaddr)
+   virtaddr = (void *)get_zeroed_page(GFP_KERNEL);
+   if (!virtaddr || set_memory_x((unsigned long)virtaddr, 1))
goto cleanup;
+   hv_context.hypercall_page = virtaddr;
 
hypercall_msr.enable = 1;
 
-   hypercall_msr.guest_physical_address = vmalloc_to_pfn(virtaddr);
+   hypercall_msr.guest_physical_address =
+   virt_to_phys(virtaddr) >> PAGE_SHIFT;
wrmsrl(HV_X64_MSR_HYPERCALL, hypercall_msr.as_uint64);
 
/* Confirm that hypercall page did get setup. */
@@ -225,14 +227,12 @@ int hv_init(void)
if (!hypercall_msr.enable)
goto cleanup;
 
-   hv_context.hypercall_page = virtaddr;
-
 #ifdef CONFIG_X86_64
if (ms_hyperv.features & HV_X64_MSR_REFERENCE_TSC_AVAILABLE) {
union hv_x64_msr_hypercall_contents tsc_msr;
void *va_tsc;
 
-   va_tsc = __vmalloc(PAGE_SIZE, GFP_KERNEL, PAGE_KERNEL);
+   va_tsc = (void *)get_zeroed_page(GFP_KERNEL);
if (!va_tsc)
goto cleanup;
hv_context.tsc_page = va_tsc;
@@ -240,7 +240,8 @@ int hv_init(void)
rdmsrl(HV_X64_MSR_REFERENCE_TSC, tsc_msr.as_uint64);
 
tsc_msr.enable = 1;
-   tsc_msr.guest_physical_address = vmalloc_to_pfn(va_tsc);
+   tsc_msr.guest_physical_address =
+   virt_to_phys(va_tsc) >> PAGE_SHIFT;
 
wrmsrl(HV_X64_MSR_REFERENCE_TSC, tsc_msr.as_uint64);
clocksource_register_hz(&hyperv_cs_tsc, NSEC_PER_SEC/100);
@@ -249,14 +250,9 @@ int hv_init(void)
return 0;
 
 cleanup:
-   if (virtaddr) {
-   if (hypercall_msr.enable) {
-   hypercall_msr.as_uint64 = 0;
-   wrmsrl(HV_X64_MSR_HYPERCALL, hypercall_msr.as_uint64);
-   }
-
-   vfree(virtaddr);
-   }
+   hypercall_msr.as_uint64 = 0;
+   wrmsrl(HV_X64_MSR_HYPERCALL, hypercall_msr.as_uint64);
+   free_page((unsigned long)virtaddr);
 
return -ENOTSUPP;
 }
@@ -273,13 +269,11 @@ void hv_cleanup(bool crash)
/* Reset our OS id */
wrmsrl(HV_X64_MSR_GUEST_OS_ID, 0);
 
-   if (hv_context.hypercall_page) {
-   hypercall_msr.as_uint64 = 0;
-   wrmsrl(HV_X64_MSR_HYPERCALL, hypercall_msr.as_uint64);
-   if (!crash)
-   vfree(hv_context.hypercall_page);
-   hv_context.hypercall_page = NULL;
-   }
+   hypercall_msr.as_uint64 = 0;
+   wrmsrl(HV_X64_MSR_HYPERCALL, hypercall_msr.as_uint64);
+   if (!crash)
+   free_page((unsigned long)hv_context.hypercall_page);
+   hv_context.hypercall_page = NULL;
 
 #ifdef CONFIG_X86_64
/*
@@ -298,7 +292,7 @@ void hv_cleanup(bool crash)
hypercall_msr.as_uint64 = 0;
wrmsrl(HV_X64_MSR_REFERENCE_TSC, hypercall_msr.as_uint64);
if (!crash)
-   vfree(hv_context.tsc_page);
+   free_page((unsigned long)hv_context.tsc_page);
hv_context.tsc_page = NULL;
}
 #endif
-- 
2.9.3

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


Re: [PATCH] staging: lustre: ldlm: use designated initializers

2016-12-20 Thread Bruce Korb
>
> "{ NULL }" is valid ISO C, but unfortunately "{}" is not.

Just make the thing "static const" and don't use an initializer.
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 14/15] hyperv_vmbus: drop unused definitions

2016-12-20 Thread Roman Kagan
None of these is used in the kernel.

Signed-off-by: Roman Kagan 
---
 drivers/hv/hyperv_vmbus.h | 119 --
 1 file changed, 119 deletions(-)

diff --git a/drivers/hv/hyperv_vmbus.h b/drivers/hv/hyperv_vmbus.h
index fcb5d91..8ce6d64 100644
--- a/drivers/hv/hyperv_vmbus.h
+++ b/drivers/hv/hyperv_vmbus.h
@@ -39,125 +39,6 @@
  */
 #define HV_UTIL_NEGO_TIMEOUT 55
 
-/* Define version of the synthetic interrupt controller. */
-#define HV_SYNIC_VERSION   (1)
-
-#define HV_ANY_VP  (0x)
-
-/* Define invalid partition identifier. */
-#define HV_PARTITION_ID_INVALID((u64)0x0)
-
-/* Define port type. */
-enum hv_port_type {
-   HVPORT_MSG  = 1,
-   HVPORT_EVENT= 2,
-   HVPORT_MONITOR  = 3
-};
-
-/* Define port information structure. */
-struct hv_port_info {
-   enum hv_port_type port_type;
-   u32 padding;
-   union {
-   struct {
-   u32 target_sint;
-   u32 target_vp;
-   u64 rsvdz;
-   } message_port_info;
-   struct {
-   u32 target_sint;
-   u32 target_vp;
-   u16 base_flag_number;
-   u16 flag_count;
-   u32 rsvdz;
-   } event_port_info;
-   struct {
-   u64 monitor_address;
-   u64 rsvdz;
-   } monitor_port_info;
-   };
-};
-
-struct hv_connection_info {
-   enum hv_port_type port_type;
-   u32 padding;
-   union {
-   struct {
-   u64 rsvdz;
-   } message_connection_info;
-   struct {
-   u64 rsvdz;
-   } event_connection_info;
-   struct {
-   u64 monitor_address;
-   } monitor_connection_info;
-   };
-};
-
-/*
- * Versioning definitions used for guests reporting themselves to the
- * hypervisor, and visa versa.
- */
-
-/* Version info reported by guest OS's */
-enum hv_guest_os_vendor {
-   HVGUESTOS_VENDOR_MICROSOFT  = 0x0001
-};
-
-enum hv_guest_os_microsoft_ids {
-   HVGUESTOS_MICROSOFT_UNDEFINED   = 0x00,
-   HVGUESTOS_MICROSOFT_MSDOS   = 0x01,
-   HVGUESTOS_MICROSOFT_WINDOWS3X   = 0x02,
-   HVGUESTOS_MICROSOFT_WINDOWS9X   = 0x03,
-   HVGUESTOS_MICROSOFT_WINDOWSNT   = 0x04,
-   HVGUESTOS_MICROSOFT_WINDOWSCE   = 0x05
-};
-
-
-/* #defines */
-
-#define HV_PRESENT_BIT 0x8000
-
-#define HV_CPU_POWER_MANAGEMENT(1 << 0)
-#define HV_RECOMMENDATIONS_MAX 4
-
-#define HV_X64_MAX 5
-#define HV_CAPS_MAX8
-
-
-/* Service definitions */
-
-#define HV_SERVICE_PARENT_PORT (0)
-#define HV_SERVICE_PARENT_CONNECTION   (0)
-
-#define HV_SERVICE_CONNECT_RESPONSE_SUCCESS(0)
-#define HV_SERVICE_CONNECT_RESPONSE_INVALID_PARAMETER  (1)
-#define HV_SERVICE_CONNECT_RESPONSE_UNKNOWN_SERVICE(2)
-#define HV_SERVICE_CONNECT_RESPONSE_CONNECTION_REJECTED(3)
-
-#define HV_SERVICE_CONNECT_REQUEST_MESSAGE_ID  (1)
-#define HV_SERVICE_CONNECT_RESPONSE_MESSAGE_ID (2)
-#define HV_SERVICE_DISCONNECT_REQUEST_MESSAGE_ID   (3)
-#define HV_SERVICE_DISCONNECT_RESPONSE_MESSAGE_ID  (4)
-#define HV_SERVICE_MAX_MESSAGE_ID  (4)
-
-#define HV_SERVICE_PROTOCOL_VERSION (0x0010)
-#define HV_CONNECT_PAYLOAD_BYTE_COUNT 64
-
-/* #define VMBUS_REVISION_NUMBER   6 */
-
-/* Our local vmbus's port and connection id. Anything >0 is fine */
-/* #define VMBUS_PORT_ID   11 */
-
-/* 628180B8-308D-4c5e-B7DB-1BEB62E62EF4 */
-static const uuid_le VMBUS_SERVICE_ID = {
-   .b = {
-   0xb8, 0x80, 0x81, 0x62, 0x8d, 0x30, 0x5e, 0x4c,
-   0xb7, 0xdb, 0x1b, 0xeb, 0x62, 0xe6, 0x2e, 0xf4
-   },
-};
-
-
 
 struct hv_context {
/* We only support running on top of Hyper-V
-- 
2.9.3

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


[PATCH 13/15] hyperv: move function close to its only callsite

2016-12-20 Thread Roman Kagan
Signed-off-by: Roman Kagan 
---
 drivers/hv/hyperv_vmbus.h | 44 
 drivers/hv/hv.c   | 39 +++
 2 files changed, 39 insertions(+), 44 deletions(-)

diff --git a/drivers/hv/hyperv_vmbus.h b/drivers/hv/hyperv_vmbus.h
index c0a65f7..fcb5d91 100644
--- a/drivers/hv/hyperv_vmbus.h
+++ b/drivers/hv/hyperv_vmbus.h
@@ -118,50 +118,6 @@ enum hv_guest_os_microsoft_ids {
 
 #define HV_PRESENT_BIT 0x8000
 
-/*
- * The guest OS needs to register the guest ID with the hypervisor.
- * The guest ID is a 64 bit entity and the structure of this ID is
- * specified in the Hyper-V specification:
- *
- * 
http://msdn.microsoft.com/en-us/library/windows/hardware/ff542653%28v=vs.85%29.aspx
- *
- * While the current guideline does not specify how Linux guest ID(s)
- * need to be generated, our plan is to publish the guidelines for
- * Linux and other guest operating systems that currently are hosted
- * on Hyper-V. The implementation here conforms to this yet
- * unpublished guidelines.
- *
- *
- * Bit(s)
- * 63 - Indicates if the OS is Open Source or not; 1 is Open Source
- * 62:56 - Os Type; Linux is 0x100
- * 55:48 - Distro specific identification
- * 47:16 - Linux kernel version number
- * 15:0  - Distro specific identification
- *
- *
- */
-
-#define HV_LINUX_VENDOR_ID 0x8100
-
-/*
- * Generate the guest ID based on the guideline described above.
- */
-
-static inline  __u64 generate_guest_id(__u8 d_info1, __u32 kernel_version,
-   __u16 d_info2)
-{
-   __u64 guest_id = 0;
-
-   guest_id = (((__u64)HV_LINUX_VENDOR_ID) << 48);
-   guest_id |= (((__u64)(d_info1)) << 48);
-   guest_id |= (((__u64)(kernel_version)) << 16);
-   guest_id |= ((__u64)(d_info2));
-
-   return guest_id;
-}
-
-
 #define HV_CPU_POWER_MANAGEMENT(1 << 0)
 #define HV_RECOMMENDATIONS_MAX 4
 
diff --git a/drivers/hv/hv.c b/drivers/hv/hv.c
index b9f50de..3598090 100644
--- a/drivers/hv/hv.c
+++ b/drivers/hv/hv.c
@@ -45,6 +45,45 @@ struct hv_context hv_context = {
 #define HV_MIN_DELTA_TICKS 1
 
 /*
+ * The guest OS needs to register the guest ID with the hypervisor.
+ * The guest ID is a 64 bit entity and the structure of this ID is
+ * specified in the Hyper-V specification:
+ *
+ * 
http://msdn.microsoft.com/en-us/library/windows/hardware/ff542653%28v=vs.85%29.aspx
+ *
+ * While the current guideline does not specify how Linux guest ID(s)
+ * need to be generated, our plan is to publish the guidelines for
+ * Linux and other guest operating systems that currently are hosted
+ * on Hyper-V. The implementation here conforms to this yet
+ * unpublished guidelines.
+ *
+ * Bit(s)
+ * 63 - Indicates if the OS is Open Source or not; 1 is Open Source
+ * 62:56 - Os Type; Linux is 0x100
+ * 55:48 - Distro specific identification
+ * 47:16 - Linux kernel version number
+ * 15:0  - Distro specific identification
+ */
+
+#define HV_LINUX_VENDOR_ID 0x8100
+
+/*
+ * Generate the guest ID based on the guideline described above.
+ */
+
+static u64 generate_guest_id(u8 d_info1, u32 kernel_version, u16 d_info2)
+{
+   u64 guest_id;
+
+   guest_id = ((u64)HV_LINUX_VENDOR_ID) << 48;
+   guest_id |= ((u64)d_info1) << 48;
+   guest_id |= ((u64)kernel_version) << 16;
+   guest_id |= (u64)d_info2;
+
+   return guest_id;
+}
+
+/*
  * query_hypervisor_info - Get version info of the windows hypervisor
  */
 unsigned int host_info_eax;
-- 
2.9.3

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


[PATCH 12/15] hyperv: move VMBus connection ids to uapi

2016-12-20 Thread Roman Kagan
Userspace will need them too.

Signed-off-by: Roman Kagan 
---
 arch/x86/include/uapi/asm/hyperv.h |  9 +
 drivers/hv/hyperv_vmbus.h  | 10 --
 2 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/arch/x86/include/uapi/asm/hyperv.h 
b/arch/x86/include/uapi/asm/hyperv.h
index e081615..5d6e525 100644
--- a/arch/x86/include/uapi/asm/hyperv.h
+++ b/arch/x86/include/uapi/asm/hyperv.h
@@ -419,4 +419,13 @@ struct hv_monitor_page {
__u8 rsvdz4[1984];
 };
 
+/* VMBus expects pre-established communication with the following IDs */
+#define VMBUS_MESSAGE_CONNECTION_ID1
+#define VMBUS_MESSAGE_PORT_ID  1
+#define VMBUS_EVENT_CONNECTION_ID  2
+#define VMBUS_EVENT_PORT_ID2
+#define VMBUS_MONITOR_CONNECTION_ID3
+#define VMBUS_MONITOR_PORT_ID  3
+#define VMBUS_MESSAGE_SINT 2
+
 #endif
diff --git a/drivers/hv/hyperv_vmbus.h b/drivers/hv/hyperv_vmbus.h
index 7f247f2..c0a65f7 100644
--- a/drivers/hv/hyperv_vmbus.h
+++ b/drivers/hv/hyperv_vmbus.h
@@ -114,16 +114,6 @@ enum hv_guest_os_microsoft_ids {
 };
 
 
-enum {
-   VMBUS_MESSAGE_CONNECTION_ID = 1,
-   VMBUS_MESSAGE_PORT_ID   = 1,
-   VMBUS_EVENT_CONNECTION_ID   = 2,
-   VMBUS_EVENT_PORT_ID = 2,
-   VMBUS_MONITOR_CONNECTION_ID = 3,
-   VMBUS_MONITOR_PORT_ID   = 3,
-   VMBUS_MESSAGE_SINT  = 2,
-};
-
 /* #defines */
 
 #define HV_PRESENT_BIT 0x8000
-- 
2.9.3

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


[PATCH 15/15] hyperv: redefine hv_message without bitfields

2016-12-20 Thread Roman Kagan
This brings more symmetry in the API.

The downside is that this changes the userspace-visible structure.
Hopefully no userspace code had a chance to use it yet.

Signed-off-by: Roman Kagan 
---
 arch/x86/include/uapi/asm/hyperv.h | 32 +---
 drivers/hv/hyperv_vmbus.h  |  2 +-
 arch/x86/kvm/hyperv.c  | 10 +-
 drivers/hv/channel_mgmt.c  |  6 +++---
 drivers/hv/vmbus_drv.c |  2 +-
 5 files changed, 15 insertions(+), 37 deletions(-)

diff --git a/arch/x86/include/uapi/asm/hyperv.h 
b/arch/x86/include/uapi/asm/hyperv.h
index 5d6e525..89ef9c2 100644
--- a/arch/x86/include/uapi/asm/hyperv.h
+++ b/arch/x86/include/uapi/asm/hyperv.h
@@ -276,7 +276,8 @@ struct hv_ref_tsc_page {
 /* Define synthetic interrupt controller message constants. */
 #define HV_MESSAGE_SIZE(256)
 #define HV_MESSAGE_PAYLOAD_BYTE_COUNT  (240)
-#define HV_MESSAGE_PAYLOAD_QWORD_COUNT (30)
+
+#define HV_MESSAGE_FLAG_PENDING(1)
 
 /* Define hypervisor message types. */
 enum hv_message_type {
@@ -308,42 +309,19 @@ enum hv_message_type {
HVMSG_X64_LEGACY_FP_ERROR   = 0x80010005
 };
 
-/* Define synthetic interrupt controller message flags. */
-union hv_message_flags {
-   __u8 asu8;
-   struct {
-   __u8 msg_pending:1;
-   __u8 reserved:7;
-   };
-};
-
-/* Define port identifier type. */
-union hv_port_id {
-   __u32 asu32;
-   struct {
-   __u32 id:24;
-   __u32 reserved:8;
-   } u;
-};
-
 /* Define synthetic interrupt controller message header. */
 struct hv_message_header {
__u32 message_type;
__u8 payload_size;
-   union hv_message_flags message_flags;
+   __u8 message_flags;
__u8 reserved[2];
-   union {
-   __u64 sender;
-   union hv_port_id port;
-   };
+   __u64 origination_id;
 };
 
 /* Define synthetic interrupt controller message format. */
 struct hv_message {
struct hv_message_header header;
-   union {
-   __u64 payload[HV_MESSAGE_PAYLOAD_QWORD_COUNT];
-   } u;
+   __u64 payload[HV_MESSAGE_PAYLOAD_BYTE_COUNT / 8];
 };
 
 /* Define the synthetic interrupt message page layout. */
diff --git a/drivers/hv/hyperv_vmbus.h b/drivers/hv/hyperv_vmbus.h
index 8ce6d64..87713cc 100644
--- a/drivers/hv/hyperv_vmbus.h
+++ b/drivers/hv/hyperv_vmbus.h
@@ -260,7 +260,7 @@ static inline void vmbus_signal_eom(struct hv_message *msg, 
u32 old_msg_type)
 */
mb();
 
-   if (msg->header.message_flags.msg_pending) {
+   if (msg->header.message_flags & HV_MESSAGE_FLAG_PENDING) {
/*
 * This will cause message queue rescan to
 * possibly deliver another msg from the
diff --git a/arch/x86/kvm/hyperv.c b/arch/x86/kvm/hyperv.c
index c7db112..546dddc 100644
--- a/arch/x86/kvm/hyperv.c
+++ b/arch/x86/kvm/hyperv.c
@@ -137,7 +137,7 @@ static void synic_clear_sint_msg_pending(struct 
kvm_vcpu_hv_synic *synic,
msg_page = kmap_atomic(page);
 
msg = &msg_page->sint_message[sint];
-   msg->header.message_flags.msg_pending = 0;
+   msg->header.message_flags &= ~HV_MESSAGE_FLAG_PENDING;
 
kunmap_atomic(msg_page);
kvm_release_page_dirty(page);
@@ -564,10 +564,10 @@ static int synic_deliver_msg(struct kvm_vcpu_hv_synic 
*synic, u32 sint,
dst_msg = &msg_page->sint_message[sint];
if (sync_cmpxchg(&dst_msg->header.message_type, HVMSG_NONE,
 src_msg->header.message_type) != HVMSG_NONE) {
-   dst_msg->header.message_flags.msg_pending = 1;
+   dst_msg->header.message_flags |= HV_MESSAGE_FLAG_PENDING;
r = -EAGAIN;
} else {
-   memcpy(&dst_msg->u.payload, &src_msg->u.payload,
+   memcpy(&dst_msg->payload, &src_msg->payload,
   src_msg->header.payload_size);
dst_msg->header.message_type = src_msg->header.message_type;
dst_msg->header.payload_size = src_msg->header.payload_size;
@@ -588,7 +588,7 @@ static int stimer_send_msg(struct kvm_vcpu_hv_stimer 
*stimer)
struct kvm_vcpu *vcpu = stimer_to_vcpu(stimer);
struct hv_message *msg = &stimer->msg;
struct hv_timer_message_payload *payload =
-   (struct hv_timer_message_payload *)&msg->u.payload;
+   (struct hv_timer_message_payload *)&msg->payload;
 
payload->expiration_time = stimer->exp_time;
payload->delivery_time = get_time_ref_counter(vcpu->kvm);
@@ -653,7 +653,7 @@ static void stimer_prepare_msg(struct kvm_vcpu_hv_stimer 
*stimer)
 {
struct hv_message *msg = &stimer->msg;
struct hv_timer_message_payload *payload =
-   (struct hv_timer_message_payload *)&msg->u.payload;
+   (struct hv_timer_message_payload *)&msg->payload;
 
   

Re: [PATCH 02/15] hyperv: uapi-fy synic event flags definitions

2016-12-20 Thread Stephen Hemminger
On Tue, 20 Dec 2016 18:55:49 +0300
Roman Kagan  wrote:

> Move definitions related to the Hyper-V SynIC event flags to a header
> where they can be consumed by userspace.
> 
> While doing so, also clean up their use by switching to standard bitops
> and struct-based dereferencing.  The latter is also done for message
> pages.
> 
> Signed-off-by: Roman Kagan 
> ---
>  arch/x86/include/uapi/asm/hyperv.h | 13 +
>  drivers/hv/hyperv_vmbus.h  | 24 ++--
>  drivers/hv/channel_mgmt.c  | 10 +++
>  drivers/hv/connection.c| 47 ++-
>  drivers/hv/vmbus_drv.c | 57 
> ++
>  5 files changed, 54 insertions(+), 97 deletions(-)
> 
> diff --git a/arch/x86/include/uapi/asm/hyperv.h 
> b/arch/x86/include/uapi/asm/hyperv.h
> index 6098ab5..af542a3 100644
> --- a/arch/x86/include/uapi/asm/hyperv.h
> +++ b/arch/x86/include/uapi/asm/hyperv.h
> @@ -363,4 +363,17 @@ struct hv_timer_message_payload {
>  #define HV_STIMER_AUTOENABLE (1ULL << 3)
>  #define HV_STIMER_SINT(config)   (__u8)(((config) >> 16) & 0x0F)
>  
> +/* Define synthetic interrupt controller flag constants. */
> +#define HV_EVENT_FLAGS_COUNT (256 * 8)
> +
> +/* Define the synthetic interrupt controller event flags format. */
> +struct hv_synic_event_flags {
> + __u64 flags[HV_EVENT_FLAGS_COUNT / 64];
> +};
> +
> +/* Define the synthetic interrupt flags page layout. */
> +struct hv_synic_event_flags_page {
> + struct hv_synic_event_flags sintevent_flags[HV_SYNIC_SINT_COUNT];
> +};
> +
>  #endif

How are these going to be exposed to user space?

They should really be unsigned long since there is no guarantee of atomic 
operation
on 64 bit values on 32 bit architectures.
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 12/15] hyperv: move VMBus connection ids to uapi

2016-12-20 Thread Stephen Hemminger
On Tue, 20 Dec 2016 18:55:59 +0300
Roman Kagan  wrote:

> Userspace will need them too.
> 
> Signed-off-by: Roman Kagan 

What userspace? I am worried about creating more stable API's that can't change.
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 07/15] hyperv: dedup cpuid definitions

2016-12-20 Thread Roman Kagan
Use the definitions already present in the uapi header throughout the
guest driver, too.

Signed-off-by: Roman Kagan 
---
 drivers/hv/hyperv_vmbus.h | 19 ---
 drivers/hv/hv.c   |  6 +++---
 2 files changed, 3 insertions(+), 22 deletions(-)

diff --git a/drivers/hv/hyperv_vmbus.h b/drivers/hv/hyperv_vmbus.h
index 4fab154..9b0f1c9 100644
--- a/drivers/hv/hyperv_vmbus.h
+++ b/drivers/hv/hyperv_vmbus.h
@@ -39,25 +39,6 @@
  */
 #define HV_UTIL_NEGO_TIMEOUT 55
 
-/*
- * The below CPUID leaves are present if VersionAndFeatures.HypervisorPresent
- * is set by CPUID(HVCPUID_VERSION_FEATURES).
- */
-enum hv_cpuid_function {
-   HVCPUID_VERSION_FEATURES= 0x0001,
-   HVCPUID_VENDOR_MAXFUNCTION  = 0x4000,
-   HVCPUID_INTERFACE   = 0x4001,
-
-   /*
-* The remaining functions depend on the value of
-* HVCPUID_INTERFACE
-*/
-   HVCPUID_VERSION = 0x4002,
-   HVCPUID_FEATURES= 0x4003,
-   HVCPUID_ENLIGHTENMENT_INFO  = 0x4004,
-   HVCPUID_IMPLEMENTATION_LIMITS   = 0x4005,
-};
-
 #define  HV_FEATURE_GUEST_CRASH_MSR_AVAILABLE   0x400
 
 #define HV_X64_MSR_CRASH_P0   0x4100
diff --git a/drivers/hv/hv.c b/drivers/hv/hv.c
index b40c7d9..dddba07 100644
--- a/drivers/hv/hv.c
+++ b/drivers/hv/hv.c
@@ -69,17 +69,17 @@ static int query_hypervisor_info(void)
ebx = 0;
ecx = 0;
edx = 0;
-   op = HVCPUID_VENDOR_MAXFUNCTION;
+   op = HYPERV_CPUID_VENDOR_AND_MAX_FUNCTIONS;
cpuid(op, &eax, &ebx, &ecx, &edx);
 
max_leaf = eax;
 
-   if (max_leaf >= HVCPUID_VERSION) {
+   if (max_leaf >= HYPERV_CPUID_VERSION) {
eax = 0;
ebx = 0;
ecx = 0;
edx = 0;
-   op = HVCPUID_VERSION;
+   op = HYPERV_CPUID_VERSION;
cpuid(op, &eax, &ebx, &ecx, &edx);
host_info_eax = eax;
host_info_ebx = ebx;
-- 
2.9.3

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


[PATCH 04/15] hyperv: define VMBus message type

2016-12-20 Thread Roman Kagan
Give a name to the constant (1) already used in the code.

Signed-off-by: Roman Kagan 
---
 arch/x86/include/uapi/asm/hyperv.h | 2 ++
 drivers/hv/connection.c| 2 +-
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/arch/x86/include/uapi/asm/hyperv.h 
b/arch/x86/include/uapi/asm/hyperv.h
index af542a3..749fbb25 100644
--- a/arch/x86/include/uapi/asm/hyperv.h
+++ b/arch/x86/include/uapi/asm/hyperv.h
@@ -282,6 +282,8 @@ struct hv_ref_tsc_page {
 enum hv_message_type {
HVMSG_NONE  = 0x,
 
+   HVMSG_VMBUS = 0x0001,
+
/* Memory access messages. */
HVMSG_UNMAPPED_GPA  = 0x8000,
HVMSG_GPA_INTERCEPT = 0x8001,
diff --git a/drivers/hv/connection.c b/drivers/hv/connection.c
index 139b33e..d38b27f 100644
--- a/drivers/hv/connection.c
+++ b/drivers/hv/connection.c
@@ -432,7 +432,7 @@ int vmbus_post_msg(void *buffer, size_t buflen)
 * times before giving up.
 */
while (retries < 20) {
-   ret = hv_post_message(conn_id, 1, buffer, buflen);
+   ret = hv_post_message(conn_id, HVMSG_VMBUS, buffer, buflen);
 
switch (ret) {
case HV_STATUS_INVALID_CONNECTION_ID:
-- 
2.9.3

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


[PATCH 09/15] hyperv: unify Hyper-V msr definitions

2016-12-20 Thread Roman Kagan
Use the definitions already present in the uapi header.  Besides, drop
all bitfields for the msr values and use bitwise operations instead.

Signed-off-by: Roman Kagan 
---
 drivers/hv/hyperv_vmbus.h |  88 ---
 drivers/hv/hv.c   | 150 ++
 2 files changed, 59 insertions(+), 179 deletions(-)

diff --git a/drivers/hv/hyperv_vmbus.h b/drivers/hv/hyperv_vmbus.h
index 7bf1b10..ac73832 100644
--- a/drivers/hv/hyperv_vmbus.h
+++ b/drivers/hv/hyperv_vmbus.h
@@ -94,63 +94,6 @@ struct hv_connection_info {
};
 };
 
-/*
- * Timer configuration register.
- */
-union hv_timer_config {
-   u64 as_uint64;
-   struct {
-   u64 enable:1;
-   u64 periodic:1;
-   u64 lazy:1;
-   u64 auto_enable:1;
-   u64 reserved_z0:12;
-   u64 sintx:4;
-   u64 reserved_z1:44;
-   };
-};
-
-/* Define SynIC control register. */
-union hv_synic_scontrol {
-   u64 as_uint64;
-   struct {
-   u64 enable:1;
-   u64 reserved:63;
-   };
-};
-
-/* Define synthetic interrupt source. */
-union hv_synic_sint {
-   u64 as_uint64;
-   struct {
-   u64 vector:8;
-   u64 reserved1:8;
-   u64 masked:1;
-   u64 auto_eoi:1;
-   u64 reserved2:46;
-   };
-};
-
-/* Define the format of the SIMP register */
-union hv_synic_simp {
-   u64 as_uint64;
-   struct {
-   u64 simp_enabled:1;
-   u64 preserved:11;
-   u64 base_simp_gpa:52;
-   };
-};
-
-/* Define the format of the SIEFP register */
-union hv_synic_siefp {
-   u64 as_uint64;
-   struct {
-   u64 siefp_enabled:1;
-   u64 preserved:11;
-   u64 base_siefp_gpa:52;
-   };
-};
-
 /* Definitions for the monitored notification facility */
 union hv_monitor_trigger_group {
u64 as_uint64;
@@ -239,37 +182,6 @@ enum hv_guest_os_microsoft_ids {
HVGUESTOS_MICROSOFT_WINDOWSCE   = 0x05
 };
 
-/*
- * Declare the MSR used to identify the guest OS.
- */
-#define HV_X64_MSR_GUEST_OS_ID 0x4000
-
-union hv_x64_msr_guest_os_id_contents {
-   u64 as_uint64;
-   struct {
-   u64 build_number:16;
-   u64 service_version:8; /* Service Pack, etc. */
-   u64 minor_version:8;
-   u64 major_version:8;
-   u64 os_id:8; /* enum hv_guest_os_microsoft_ids (if Vendor=MS) */
-   u64 vendor_id:16; /* enum hv_guest_os_vendor */
-   };
-};
-
-/*
- * Declare the MSR used to setup pages used to communicate with the hypervisor.
- */
-#define HV_X64_MSR_HYPERCALL   0x4001
-
-union hv_x64_msr_hypercall_contents {
-   u64 as_uint64;
-   struct {
-   u64 enable:1;
-   u64 reserved:11;
-   u64 guest_physical_address:52;
-   };
-};
-
 
 enum {
VMBUS_MESSAGE_CONNECTION_ID = 1,
diff --git a/drivers/hv/hv.c b/drivers/hv/hv.c
index dddba07..7d2a3d1 100644
--- a/drivers/hv/hv.c
+++ b/drivers/hv/hv.c
@@ -181,7 +181,7 @@ static struct clocksource hyperv_cs_tsc = {
 int hv_init(void)
 {
int max_leaf;
-   union hv_x64_msr_hypercall_contents hypercall_msr;
+   u64 hypercall_msr = 0;
void *virtaddr = NULL;
 
memset(hv_context.synic_event_page, 0, sizeof(void *) * NR_CPUS);
@@ -206,30 +206,24 @@ int hv_init(void)
hv_context.guestid = generate_guest_id(0, LINUX_VERSION_CODE, 0);
wrmsrl(HV_X64_MSR_GUEST_OS_ID, hv_context.guestid);
 
-   /* See if the hypercall page is already set */
-   rdmsrl(HV_X64_MSR_HYPERCALL, hypercall_msr.as_uint64);
-
virtaddr = (void *)get_zeroed_page(GFP_KERNEL);
if (!virtaddr || set_memory_x((unsigned long)virtaddr, 1))
goto cleanup;
hv_context.hypercall_page = virtaddr;
 
-   hypercall_msr.enable = 1;
-
-   hypercall_msr.guest_physical_address =
-   virt_to_phys(virtaddr) >> PAGE_SHIFT;
-   wrmsrl(HV_X64_MSR_HYPERCALL, hypercall_msr.as_uint64);
+   rdmsrl(HV_X64_MSR_HYPERCALL, hypercall_msr);
+   hypercall_msr &= PAGE_MASK;
+   hypercall_msr = HV_X64_MSR_HYPERCALL_ENABLE | virt_to_phys(virtaddr);
+   wrmsrl(HV_X64_MSR_HYPERCALL, hypercall_msr);
 
/* Confirm that hypercall page did get setup. */
-   hypercall_msr.as_uint64 = 0;
-   rdmsrl(HV_X64_MSR_HYPERCALL, hypercall_msr.as_uint64);
-
-   if (!hypercall_msr.enable)
+   rdmsrl(HV_X64_MSR_HYPERCALL, hypercall_msr);
+   if (!(hypercall_msr & HV_X64_MSR_HYPERCALL_ENABLE))
goto cleanup;
 
 #ifdef CONFIG_X86_64
if (ms_hyperv.features & HV_X64_MSR_REFERENCE_TSC_AVAILABLE) {
-   union hv_x64_msr_hypercall_contents tsc_msr;
+   u64 tsc_msr;
void *va_tsc;
 
va_tsc = (void *)get_zeroed_page(GFP_KERNEL)

[PATCH 08/15] hyperv: dedup crash msr related definitions

2016-12-20 Thread Roman Kagan
Use the definitions already present in the uapi header throughout the
guest driver, too.

Signed-off-by: Roman Kagan 
---
 drivers/hv/hyperv_vmbus.h | 11 ---
 drivers/hv/vmbus_drv.c|  6 +++---
 2 files changed, 3 insertions(+), 14 deletions(-)

diff --git a/drivers/hv/hyperv_vmbus.h b/drivers/hv/hyperv_vmbus.h
index 9b0f1c9..7bf1b10 100644
--- a/drivers/hv/hyperv_vmbus.h
+++ b/drivers/hv/hyperv_vmbus.h
@@ -39,17 +39,6 @@
  */
 #define HV_UTIL_NEGO_TIMEOUT 55
 
-#define  HV_FEATURE_GUEST_CRASH_MSR_AVAILABLE   0x400
-
-#define HV_X64_MSR_CRASH_P0   0x4100
-#define HV_X64_MSR_CRASH_P1   0x4101
-#define HV_X64_MSR_CRASH_P2   0x4102
-#define HV_X64_MSR_CRASH_P3   0x4103
-#define HV_X64_MSR_CRASH_P4   0x4104
-#define HV_X64_MSR_CRASH_CTL  0x4105
-
-#define HV_CRASH_CTL_CRASH_NOTIFY (1ULL << 63)
-
 /* Define version of the synthetic interrupt controller. */
 #define HV_SYNIC_VERSION   (1)
 
diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
index 13dd210..7564a7b 100644
--- a/drivers/hv/vmbus_drv.c
+++ b/drivers/hv/vmbus_drv.c
@@ -77,7 +77,7 @@ static void hyperv_report_panic(struct pt_regs *regs)
/*
 * Let Hyper-V know there is crash data available
 */
-   wrmsrl(HV_X64_MSR_CRASH_CTL, HV_CRASH_CTL_CRASH_NOTIFY);
+   wrmsrl(HV_X64_MSR_CRASH_CTL, HV_X64_MSR_CRASH_CTL_NOTIFY);
 }
 
 static int hyperv_panic_event(struct notifier_block *nb, unsigned long val,
@@ -993,7 +993,7 @@ static int vmbus_bus_init(void)
/*
 * Only register if the crash MSRs are available
 */
-   if (ms_hyperv.misc_features & HV_FEATURE_GUEST_CRASH_MSR_AVAILABLE) {
+   if (ms_hyperv.misc_features & HV_X64_GUEST_CRASH_MSR_AVAILABLE) {
register_die_notifier(&hyperv_die_block);
atomic_notifier_chain_register(&panic_notifier_list,
   &hyperv_panic_block);
@@ -1535,7 +1535,7 @@ static void __exit vmbus_exit(void)
for_each_online_cpu(cpu)
tasklet_kill(hv_context.msg_dpc[cpu]);
vmbus_free_channels();
-   if (ms_hyperv.misc_features & HV_FEATURE_GUEST_CRASH_MSR_AVAILABLE) {
+   if (ms_hyperv.misc_features & HV_X64_GUEST_CRASH_MSR_AVAILABLE) {
unregister_die_notifier(&hyperv_die_block);
atomic_notifier_chain_unregister(&panic_notifier_list,
 &hyperv_panic_block);
-- 
2.9.3

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


[PATCH 03/15] hyperv: use standard bitops

2016-12-20 Thread Roman Kagan
Signed-off-by: Roman Kagan 
---
 drivers/hv/channel.c| 8 +++-
 drivers/hv/connection.c | 9 +++--
 2 files changed, 6 insertions(+), 11 deletions(-)

diff --git a/drivers/hv/channel.c b/drivers/hv/channel.c
index 5fb4c6d..f9df275 100644
--- a/drivers/hv/channel.c
+++ b/drivers/hv/channel.c
@@ -49,15 +49,13 @@ void vmbus_setevent(struct vmbus_channel *channel)
 */
if ((channel->offermsg.monitor_allocated) &&
(!channel->low_latency)) {
-   /* Each u32 represents 32 channels */
-   sync_set_bit(channel->offermsg.child_relid & 31,
-   (unsigned long *) vmbus_connection.send_int_page +
-   (channel->offermsg.child_relid >> 5));
+   set_bit(channel->offermsg.child_relid,
+   (unsigned long *)vmbus_connection.send_int_page);
 
/* Get the child to parent monitor page */
monitorpage = vmbus_connection.monitor_pages[1];
 
-   sync_set_bit(channel->monitor_bit,
+   set_bit(channel->monitor_bit,
(unsigned long *)&monitorpage->trigger_group
[channel->monitor_grp].pending);
 
diff --git a/drivers/hv/connection.c b/drivers/hv/connection.c
index aaa2103..139b33e 100644
--- a/drivers/hv/connection.c
+++ b/drivers/hv/connection.c
@@ -468,12 +468,9 @@ void vmbus_set_event(struct vmbus_channel *channel)
 {
u32 child_relid = channel->offermsg.child_relid;
 
-   if (!channel->is_dedicated_interrupt) {
-   /* Each u32 represents 32 channels */
-   sync_set_bit(child_relid & 31,
-   (unsigned long *)vmbus_connection.send_int_page +
-   (child_relid >> 5));
-   }
+   if (!channel->is_dedicated_interrupt)
+   set_bit(child_relid,
+   (unsigned long *)vmbus_connection.send_int_page);
 
hv_do_hypercall(HVCALL_SIGNAL_EVENT, channel->sig_event, NULL);
 }
-- 
2.9.3

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


[PATCH 01/15] hyperv: consolidate TSC ref page definitions

2016-12-20 Thread Roman Kagan
Consolidate the guest-side and kvm-side definitions for Hyper-V TSC
reference page.

While at this, rewrite read_hv_clock_tsc using the existing helpers.

Signed-off-by: Roman Kagan 
---
 arch/x86/include/asm/kvm_host.h|  2 +-
 arch/x86/include/uapi/asm/hyperv.h |  4 +--
 drivers/hv/hyperv_vmbus.h  |  8 --
 arch/x86/kvm/hyperv.c  |  4 +--
 drivers/hv/hv.c| 54 +++---
 5 files changed, 26 insertions(+), 46 deletions(-)

diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h
index 2e25038..2b85f49 100644
--- a/arch/x86/include/asm/kvm_host.h
+++ b/arch/x86/include/asm/kvm_host.h
@@ -713,7 +713,7 @@ struct kvm_hv {
u64 hv_crash_param[HV_X64_MSR_CRASH_PARAMS];
u64 hv_crash_ctl;
 
-   HV_REFERENCE_TSC_PAGE tsc_ref;
+   struct hv_ref_tsc_page tsc_ref;
 };
 
 struct kvm_arch {
diff --git a/arch/x86/include/uapi/asm/hyperv.h 
b/arch/x86/include/uapi/asm/hyperv.h
index 9b1a918..6098ab5 100644
--- a/arch/x86/include/uapi/asm/hyperv.h
+++ b/arch/x86/include/uapi/asm/hyperv.h
@@ -252,12 +252,12 @@
 #define HV_STATUS_INVALID_CONNECTION_ID18
 #define HV_STATUS_INSUFFICIENT_BUFFERS 19
 
-typedef struct _HV_REFERENCE_TSC_PAGE {
+struct hv_ref_tsc_page {
__u32 tsc_sequence;
__u32 res1;
__u64 tsc_scale;
__s64 tsc_offset;
-} HV_REFERENCE_TSC_PAGE, *PHV_REFERENCE_TSC_PAGE;
+};
 
 /* Define the number of synthetic interrupt sources. */
 #define HV_SYNIC_SINT_COUNT(16)
diff --git a/drivers/hv/hyperv_vmbus.h b/drivers/hv/hyperv_vmbus.h
index 0675b39..4516498 100644
--- a/drivers/hv/hyperv_vmbus.h
+++ b/drivers/hv/hyperv_vmbus.h
@@ -475,14 +475,6 @@ struct hv_context {
 
 extern struct hv_context hv_context;
 
-struct ms_hyperv_tsc_page {
-   volatile u32 tsc_sequence;
-   u32 reserved1;
-   volatile u64 tsc_scale;
-   volatile s64 tsc_offset;
-   u64 reserved2[509];
-};
-
 struct hv_ring_buffer_debug_info {
u32 current_interrupt_mask;
u32 current_read_index;
diff --git a/arch/x86/kvm/hyperv.c b/arch/x86/kvm/hyperv.c
index 1572c35..c7db112 100644
--- a/arch/x86/kvm/hyperv.c
+++ b/arch/x86/kvm/hyperv.c
@@ -806,7 +806,7 @@ static int kvm_hv_msr_set_crash_data(struct kvm_vcpu *vcpu,
  * These two equivalencies are implemented in this function.
  */
 static bool compute_tsc_page_parameters(struct pvclock_vcpu_time_info 
*hv_clock,
-   HV_REFERENCE_TSC_PAGE *tsc_ref)
+   struct hv_ref_tsc_page *tsc_ref)
 {
u64 max_mul;
 
@@ -847,7 +847,7 @@ void kvm_hv_setup_tsc_page(struct kvm *kvm,
u64 gfn;
 
BUILD_BUG_ON(sizeof(tsc_seq) != sizeof(hv->tsc_ref.tsc_sequence));
-   BUILD_BUG_ON(offsetof(HV_REFERENCE_TSC_PAGE, tsc_sequence) != 0);
+   BUILD_BUG_ON(offsetof(struct hv_ref_tsc_page, tsc_sequence) != 0);
 
if (!(hv->hv_tsc_page & HV_X64_MSR_TSC_REFERENCE_ENABLE))
return;
diff --git a/drivers/hv/hv.c b/drivers/hv/hv.c
index 446802a..a7256ec 100644
--- a/drivers/hv/hv.c
+++ b/drivers/hv/hv.c
@@ -137,41 +137,29 @@ EXPORT_SYMBOL_GPL(hv_do_hypercall);
 #ifdef CONFIG_X86_64
 static cycle_t read_hv_clock_tsc(struct clocksource *arg)
 {
-   cycle_t current_tick;
-   struct ms_hyperv_tsc_page *tsc_pg = hv_context.tsc_page;
+   struct hv_ref_tsc_page *tsc_pg = hv_context.tsc_page;
+   u32 sequence;
+   u64 scale;
+   s64 offset;
+
+   do {
+   sequence = tsc_pg->tsc_sequence;
+   virt_rmb();
+
+   if (!sequence) {
+   /* fallback to MSR */
+   cycle_t current_tick;
+   rdmsrl(HV_X64_MSR_TIME_REF_COUNT, current_tick);
+   return current_tick;
+   }
 
-   if (tsc_pg->tsc_sequence != 0) {
-   /*
-* Use the tsc page to compute the value.
-*/
+   scale = tsc_pg->tsc_scale;
+   offset = tsc_pg->tsc_offset;
 
-   while (1) {
-   cycle_t tmp;
-   u32 sequence = tsc_pg->tsc_sequence;
-   u64 cur_tsc;
-   u64 scale = tsc_pg->tsc_scale;
-   s64 offset = tsc_pg->tsc_offset;
-
-   rdtscll(cur_tsc);
-   /* current_tick = ((cur_tsc *scale) >> 64) + offset */
-   asm("mulq %3"
-   : "=d" (current_tick), "=a" (tmp)
-   : "a" (cur_tsc), "r" (scale));
-
-   current_tick += offset;
-   if (tsc_pg->tsc_sequence == sequence)
-   return current_tick;
-
-   if (tsc_pg->tsc_sequence != 0)
-   continue;
-   /*
-* Fallba

[PATCH 05/15] hyperv: GFP_ATOMIC -> GFP_KERNEL

2016-12-20 Thread Roman Kagan
There's no need in GFP_ATOMIC when initializing the driver state.

While at this, also rely on free_page() to take null argument.

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

diff --git a/drivers/hv/hv.c b/drivers/hv/hv.c
index a7256ec..6bbc0b09 100644
--- a/drivers/hv/hv.c
+++ b/drivers/hv/hv.c
@@ -393,28 +393,28 @@ int hv_synic_alloc(void)
int cpu;
 
hv_context.hv_numa_map = kzalloc(sizeof(struct cpumask) * nr_node_ids,
-GFP_ATOMIC);
+GFP_KERNEL);
if (hv_context.hv_numa_map == NULL) {
pr_err("Unable to allocate NUMA map\n");
goto err;
}
 
for_each_online_cpu(cpu) {
-   hv_context.event_dpc[cpu] = kmalloc(size, GFP_ATOMIC);
+   hv_context.event_dpc[cpu] = kmalloc(size, GFP_KERNEL);
if (hv_context.event_dpc[cpu] == NULL) {
pr_err("Unable to allocate event dpc\n");
goto err;
}
tasklet_init(hv_context.event_dpc[cpu], vmbus_on_event, cpu);
 
-   hv_context.msg_dpc[cpu] = kmalloc(size, GFP_ATOMIC);
+   hv_context.msg_dpc[cpu] = kmalloc(size, GFP_KERNEL);
if (hv_context.msg_dpc[cpu] == NULL) {
pr_err("Unable to allocate event dpc\n");
goto err;
}
tasklet_init(hv_context.msg_dpc[cpu], vmbus_on_msg_dpc, cpu);
 
-   hv_context.clk_evt[cpu] = kzalloc(ced_size, GFP_ATOMIC);
+   hv_context.clk_evt[cpu] = kzalloc(ced_size, GFP_KERNEL);
if (hv_context.clk_evt[cpu] == NULL) {
pr_err("Unable to allocate clock event device\n");
goto err;
@@ -423,7 +423,7 @@ int hv_synic_alloc(void)
hv_init_clockevent_device(hv_context.clk_evt[cpu], cpu);
 
hv_context.synic_message_page[cpu] =
-   (void *)get_zeroed_page(GFP_ATOMIC);
+   (void *)get_zeroed_page(GFP_KERNEL);
 
if (hv_context.synic_message_page[cpu] == NULL) {
pr_err("Unable to allocate SYNIC message page\n");
@@ -431,7 +431,7 @@ int hv_synic_alloc(void)
}
 
hv_context.synic_event_page[cpu] =
-   (void *)get_zeroed_page(GFP_ATOMIC);
+   (void *)get_zeroed_page(GFP_KERNEL);
 
if (hv_context.synic_event_page[cpu] == NULL) {
pr_err("Unable to allocate SYNIC event page\n");
@@ -439,7 +439,7 @@ int hv_synic_alloc(void)
}
 
hv_context.post_msg_page[cpu] =
-   (void *)get_zeroed_page(GFP_ATOMIC);
+   (void *)get_zeroed_page(GFP_KERNEL);
 
if (hv_context.post_msg_page[cpu] == NULL) {
pr_err("Unable to allocate post msg page\n");
@@ -457,12 +457,9 @@ static void hv_synic_free_cpu(int cpu)
kfree(hv_context.event_dpc[cpu]);
kfree(hv_context.msg_dpc[cpu]);
kfree(hv_context.clk_evt[cpu]);
-   if (hv_context.synic_event_page[cpu])
-   free_page((unsigned long)hv_context.synic_event_page[cpu]);
-   if (hv_context.synic_message_page[cpu])
-   free_page((unsigned long)hv_context.synic_message_page[cpu]);
-   if (hv_context.post_msg_page[cpu])
-   free_page((unsigned long)hv_context.post_msg_page[cpu]);
+   free_page((unsigned long)hv_context.synic_event_page[cpu]);
+   free_page((unsigned long)hv_context.synic_message_page[cpu]);
+   free_page((unsigned long)hv_context.post_msg_page[cpu]);
 }
 
 void hv_synic_free(void)
-- 
2.9.3

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


[PATCH 11/15] hyperv: uapi-fy monitored notification structures

2016-12-20 Thread Roman Kagan
Move structures for monitored notifications to the uapi header for
userspace to be able to consume.  Also observe that hv_monitor_parameter
is by definition the same as hv_input_signal_event so use the latter and
nuke the former.

Signed-off-by: Roman Kagan 
---
 arch/x86/include/uapi/asm/hyperv.h | 23 +++
 drivers/hv/hyperv_vmbus.h  | 60 --
 2 files changed, 23 insertions(+), 60 deletions(-)

diff --git a/arch/x86/include/uapi/asm/hyperv.h 
b/arch/x86/include/uapi/asm/hyperv.h
index eb8d42a..e081615 100644
--- a/arch/x86/include/uapi/asm/hyperv.h
+++ b/arch/x86/include/uapi/asm/hyperv.h
@@ -396,4 +396,27 @@ struct hv_input_signal_event {
__u16 rsvdz;
 } __attribute__((aligned(HV_HYPERCALL_PARAM_ALIGN)));
 
+/* Definitions for the monitored notification facility */
+struct hv_monitor_trigger_group {
+   __u32 pending;
+   __u32 armed;
+};
+
+struct hv_monitor_page {
+   __u32 trigger_state;
+   __u32 rsvdz1;
+
+   struct hv_monitor_trigger_group trigger_group[4];
+   __u64 rsvdz2[3];
+
+   __s32 next_checktime[4][32];
+
+   __u16 latency[4][32];
+   __u64 rsvdz3[32];
+
+   struct hv_input_signal_event parameter[4][32];
+
+   __u8 rsvdz4[1984];
+};
+
 #endif
diff --git a/drivers/hv/hyperv_vmbus.h b/drivers/hv/hyperv_vmbus.h
index a96f021..7f247f2 100644
--- a/drivers/hv/hyperv_vmbus.h
+++ b/drivers/hv/hyperv_vmbus.h
@@ -94,66 +94,6 @@ struct hv_connection_info {
};
 };
 
-/* Definitions for the monitored notification facility */
-union hv_monitor_trigger_group {
-   u64 as_uint64;
-   struct {
-   u32 pending;
-   u32 armed;
-   };
-};
-
-struct hv_monitor_parameter {
-   u32 connectionid;
-   u16 flagnumber;
-   u16 rsvdz;
-};
-
-union hv_monitor_trigger_state {
-   u32 asu32;
-
-   struct {
-   u32 group_enable:4;
-   u32 rsvdz:28;
-   };
-};
-
-/* struct hv_monitor_page Layout */
-/* -- */
-/* | 0   | TriggerState (4 bytes) | Rsvd1 (4 bytes) | */
-/* | 8   | TriggerGroup[0]  | */
-/* | 10  | TriggerGroup[1]  | */
-/* | 18  | TriggerGroup[2]  | */
-/* | 20  | TriggerGroup[3]  | */
-/* | 28  | Rsvd2[0] | */
-/* | 30  | Rsvd2[1] | */
-/* | 38  | Rsvd2[2] | */
-/* | 40  | NextCheckTime[0][0]| NextCheckTime[0][1] | */
-/* | ...| */
-/* | 240 | Latency[0][0..3] | */
-/* | 340 | Rsvz3[0] | */
-/* | 440 | Parameter[0][0]  | */
-/* | 448 | Parameter[0][1]  | */
-/* | ...| */
-/* | 840 | Rsvd4[0] | */
-/* -- */
-struct hv_monitor_page {
-   union hv_monitor_trigger_state trigger_state;
-   u32 rsvdz1;
-
-   union hv_monitor_trigger_group trigger_group[4];
-   u64 rsvdz2[3];
-
-   s32 next_checktime[4][32];
-
-   u16 latency[4][32];
-   u64 rsvdz3[32];
-
-   struct hv_monitor_parameter parameter[4][32];
-
-   u8 rsvdz4[1984];
-};
-
 /*
  * Versioning definitions used for guests reporting themselves to the
  * hypervisor, and visa versa.
-- 
2.9.3

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


Designated initializers, struct randomization and addressing?

2016-12-20 Thread Joe Perches
On Fri, 2016-12-16 at 17:00 -0800, Kees Cook wrote:
> Prepare to mark sensitive kernel structures for randomization by making
sure they're using designated initializers.

About the designated initializer patches,
which by themselves are fine of course,
and the fundamental randomization plugin,
c guarantees that struct member ordering
is as specified.

how is the code to be verified so that
any use of things like offsetof and any
address/indexing is not impacted?

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


[PATCH 00/13] staging: rtl8712: Fixed sparse warnings

2016-12-20 Thread Jannik Becher
In this set of patches I fixed most sparse endian warnings for the rtl8712 
driver.

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


[PATCH 01/13] staging: rtl8712: changed struct members to __le32

2016-12-20 Thread Jannik Becher
Fixed sparse warning "cast to restricted __le32".
struct sitesurvey_parm uses little endian members.

Signed-off-by: Jannik Becher 
Tested-by: Larry Finger 
---
 drivers/staging/rtl8712/rtl871x_cmd.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/rtl8712/rtl871x_cmd.h 
b/drivers/staging/rtl8712/rtl871x_cmd.h
index 3284dcf..4734ca8 100644
--- a/drivers/staging/rtl8712/rtl871x_cmd.h
+++ b/drivers/staging/rtl8712/rtl871x_cmd.h
@@ -156,9 +156,9 @@ struct  setopmode_parm {
  * Command-Event Mode
  */
 struct sitesurvey_parm {
-   sint passive_mode;  /*active: 1, passive: 0 */
-   sint bsslimit;  /* 1 ~ 48 */
-   sintss_ssidlen;
+   __le32  passive_mode;   /*active: 1, passive: 0 */
+   __le32  bsslimit;   /* 1 ~ 48 */
+   __le32  ss_ssidlen;
u8  ss_ssid[IW_ESSID_MAX_SIZE + 1];
 };
 
-- 
2.7.4

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


[PATCH 02/13] staging: rtl8712: changed variables to __le32

2016-12-20 Thread Jannik Becher
Fixed sparse warning "cast to restricted __le32".
Changed struct tx_desc members to __le32 and pcmdbuf to __le32.

Signed-off-by: Jannik Becher 
Tested-by: Larry Finger 
---
 drivers/staging/rtl8712/rtl8712_cmd.c  |  5 +++--
 drivers/staging/rtl8712/rtl8712_xmit.h | 16 
 2 files changed, 11 insertions(+), 10 deletions(-)

diff --git a/drivers/staging/rtl8712/rtl8712_cmd.c 
b/drivers/staging/rtl8712/rtl8712_cmd.c
index 9f61583..6e5e177 100644
--- a/drivers/staging/rtl8712/rtl8712_cmd.c
+++ b/drivers/staging/rtl8712/rtl8712_cmd.c
@@ -314,7 +314,8 @@ void r8712_fw_cmd_data(struct _adapter *pAdapter, u32 
*value, u8 flag)
 int r8712_cmd_thread(void *context)
 {
struct cmd_obj *pcmd;
-   unsigned int cmdsz, wr_sz, *pcmdbuf;
+   unsigned int cmdsz, wr_sz;
+   __le32 *pcmdbuf;
struct tx_desc *pdesc;
void (*pcmd_callback)(struct _adapter *dev, struct cmd_obj *pcmd);
struct _adapter *padapter = context;
@@ -334,7 +335,7 @@ int r8712_cmd_thread(void *context)
r8712_unregister_cmd_alive(padapter);
continue;
}
-   pcmdbuf = (unsigned int *)pcmdpriv->cmd_buf;
+   pcmdbuf = (__le32 *)pcmdpriv->cmd_buf;
pdesc = (struct tx_desc *)pcmdbuf;
memset(pdesc, 0, TXDESC_SIZE);
pcmd = cmd_hdl_filter(padapter, pcmd);
diff --git a/drivers/staging/rtl8712/rtl8712_xmit.h 
b/drivers/staging/rtl8712/rtl8712_xmit.h
index b50e7a1..02b1593 100644
--- a/drivers/staging/rtl8712/rtl8712_xmit.h
+++ b/drivers/staging/rtl8712/rtl8712_xmit.h
@@ -91,14 +91,14 @@
 
 struct tx_desc {
/*DWORD 0*/
-   unsigned int txdw0;
-   unsigned int txdw1;
-   unsigned int txdw2;
-   unsigned int txdw3;
-   unsigned int txdw4;
-   unsigned int txdw5;
-   unsigned int txdw6;
-   unsigned int txdw7;
+   __le32 txdw0;
+   __le32 txdw1;
+   __le32 txdw2;
+   __le32 txdw3;
+   __le32 txdw4;
+   __le32 txdw5;
+   __le32 txdw6;
+   __le32 txdw7;
 };
 
 
-- 
2.7.4

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


[PATCH 04/13] staging: rtl8712: casted variables to __le32

2016-12-20 Thread Jannik Becher
Fixed a sparse warning.
Casting __le32 variables to the right type.

Signed-off-by: Jannik Becher 
Tested-by: Larry Finger 
---
 drivers/staging/rtl8712/rtl871x_security.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/rtl8712/rtl871x_security.c 
b/drivers/staging/rtl8712/rtl871x_security.c
index a7f04a4..3400e49 100644
--- a/drivers/staging/rtl8712/rtl871x_security.c
+++ b/drivers/staging/rtl8712/rtl871x_security.c
@@ -192,7 +192,7 @@ void r8712_wep_encrypt(struct _adapter *padapter, u8 
*pxmitframe)
length = pattrib->last_txcmdsz - pattrib->
 hdrlen - pattrib->iv_len -
 pattrib->icv_len;
-   *((u32 *)crc) = cpu_to_le32(getcrc32(
+   *((__le32 *)crc) = cpu_to_le32(getcrc32(
payload, length));
arcfour_init(&mycontext, wepkey, 3 + keylength);
arcfour_encrypt(&mycontext, payload, payload,
@@ -203,7 +203,7 @@ void r8712_wep_encrypt(struct _adapter *padapter, u8 
*pxmitframe)
length = pxmitpriv->frag_len -
 pattrib->hdrlen - pattrib->iv_len -
 pattrib->icv_len;
-   *((u32 *)crc) = cpu_to_le32(getcrc32(
+   *((__le32 *)crc) = cpu_to_le32(getcrc32(
payload, length));
arcfour_init(&mycontext, wepkey, 3 + keylength);
arcfour_encrypt(&mycontext, payload, payload,
@@ -248,7 +248,7 @@ void r8712_wep_decrypt(struct _adapter  *padapter, u8 
*precvframe)
arcfour_init(&mycontext, wepkey, 3 + keylength);
arcfour_encrypt(&mycontext, payload, payload,  length);
/* calculate icv and compare the icv */
-   *((u32 *)crc) = cpu_to_le32(getcrc32(payload, length - 4));
+   *((__le32 *)crc) = cpu_to_le32(getcrc32(payload, length - 4));
}
 }
 
@@ -616,7 +616,7 @@ u32 r8712_tkip_encrypt(struct _adapter *padapter, u8 
*pxmitframe)
 pattrib->hdrlen -
 pattrib->iv_len -
 pattrib->icv_len;
-   *((u32 *)crc) = cpu_to_le32(
+   *((__le32 *)crc) = cpu_to_le32(
getcrc32(payload, length));
arcfour_init(&mycontext, rc4key, 16);
arcfour_encrypt(&mycontext, payload,
@@ -628,7 +628,7 @@ u32 r8712_tkip_encrypt(struct _adapter *padapter, u8 
*pxmitframe)
 pattrib->hdrlen -
 pattrib->iv_len -
 pattrib->icv_len;
-   *((u32 *)crc) = cpu_to_le32(getcrc32(
+   *((__le32 *)crc) = cpu_to_le32(getcrc32(
payload, length));
arcfour_init(&mycontext, rc4key, 16);
arcfour_encrypt(&mycontext, payload,
@@ -696,7 +696,7 @@ u32 r8712_tkip_decrypt(struct _adapter *padapter, u8 
*precvframe)
/* 4 decrypt payload include icv */
arcfour_init(&mycontext, rc4key, 16);
arcfour_encrypt(&mycontext, payload, payload, length);
-   *((u32 *)crc) = cpu_to_le32(getcrc32(payload,
+   *((__le32 *)crc) = cpu_to_le32(getcrc32(payload,
length - 4));
if (crc[3] != payload[length - 1] ||
crc[2] != payload[length - 2] ||
-- 
2.7.4

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


[PATCH 03/13] staging: rtl8712: changed function argument to __le32

2016-12-20 Thread Jannik Becher
Fixed a sparse warning "cast to restricted __le32".
Function argument is of type __le32.

Signed-off-by: Jannik Becher 
Tested-by: Larry Finger 
---
 drivers/staging/rtl8712/rtl8712_cmd.c   | 2 +-
 drivers/staging/rtl8712/rtl8712_event.h | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/rtl8712/rtl8712_cmd.c 
b/drivers/staging/rtl8712/rtl8712_cmd.c
index 6e5e177..f19b6b2 100644
--- a/drivers/staging/rtl8712/rtl8712_cmd.c
+++ b/drivers/staging/rtl8712/rtl8712_cmd.c
@@ -425,7 +425,7 @@ int r8712_cmd_thread(void *context)
thread_exit();
 }
 
-void r8712_event_handle(struct _adapter *padapter, uint *peventbuf)
+void r8712_event_handle(struct _adapter *padapter, __le32 *peventbuf)
 {
u8 evt_code, evt_seq;
u16 evt_sz;
diff --git a/drivers/staging/rtl8712/rtl8712_event.h 
b/drivers/staging/rtl8712/rtl8712_event.h
index 29a4c23..b383740 100644
--- a/drivers/staging/rtl8712/rtl8712_event.h
+++ b/drivers/staging/rtl8712/rtl8712_event.h
@@ -26,7 +26,7 @@
 #ifndef _RTL8712_EVENT_H_
 #define _RTL8712_EVENT_H_
 
-void r8712_event_handle(struct _adapter *padapter, uint *peventbuf);
+void r8712_event_handle(struct _adapter *padapter, __le32 *peventbuf);
 void r8712_got_addbareq_event_callback(struct _adapter *adapter, u8 *pbuf);
 
 enum rtl8712_c2h_event {
-- 
2.7.4

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


[PATCH 07/13] staging: rtl8712: changed u32 to __le32

2016-12-20 Thread Jannik Becher
Fixed sparse warning.
Just changed u32 to __le32.

Signed-off-by: Jannik Becher 
Tested-by: Larry Finger 
---
 drivers/staging/rtl8712/usb_ops.c | 18 --
 1 file changed, 8 insertions(+), 10 deletions(-)

diff --git a/drivers/staging/rtl8712/usb_ops.c 
b/drivers/staging/rtl8712/usb_ops.c
index 9172400..332e2e5 100644
--- a/drivers/staging/rtl8712/usb_ops.c
+++ b/drivers/staging/rtl8712/usb_ops.c
@@ -41,7 +41,7 @@ static u8 usb_read8(struct intf_hdl *pintfhdl, u32 addr)
u16 wvalue;
u16 index;
u16 len;
-   u32 data;
+   __le32 data;
struct intf_priv *pintfpriv = pintfhdl->pintfpriv;
 
request = 0x05;
@@ -61,7 +61,7 @@ static u16 usb_read16(struct intf_hdl *pintfhdl, u32 addr)
u16 wvalue;
u16 index;
u16 len;
-   u32 data;
+   __le32 data;
struct intf_priv *pintfpriv = pintfhdl->pintfpriv;
 
request = 0x05;
@@ -81,7 +81,7 @@ static u32 usb_read32(struct intf_hdl *pintfhdl, u32 addr)
u16 wvalue;
u16 index;
u16 len;
-   u32 data;
+   __le32 data;
struct intf_priv *pintfpriv = pintfhdl->pintfpriv;
 
request = 0x05;
@@ -101,7 +101,7 @@ static void usb_write8(struct intf_hdl *pintfhdl, u32 addr, 
u8 val)
u16 wvalue;
u16 index;
u16 len;
-   u32 data;
+   __le32 data;
struct intf_priv *pintfpriv = pintfhdl->pintfpriv;
 
request = 0x05;
@@ -109,8 +109,7 @@ static void usb_write8(struct intf_hdl *pintfhdl, u32 addr, 
u8 val)
index = 0;
wvalue = (u16)(addr & 0x);
len = 1;
-   data = val;
-   data = cpu_to_le32(data & 0x00ff);
+   data = cpu_to_le32((u32)val & 0x00ff);
r8712_usbctrl_vendorreq(pintfpriv, request, wvalue, index, &data, len,
  requesttype);
 }
@@ -122,7 +121,7 @@ static void usb_write16(struct intf_hdl *pintfhdl, u32 
addr, u16 val)
u16 wvalue;
u16 index;
u16 len;
-   u32 data;
+   __le32 data;
struct intf_priv *pintfpriv = pintfhdl->pintfpriv;
 
request = 0x05;
@@ -130,8 +129,7 @@ static void usb_write16(struct intf_hdl *pintfhdl, u32 
addr, u16 val)
index = 0;
wvalue = (u16)(addr & 0x);
len = 2;
-   data = val;
-   data = cpu_to_le32(data & 0x);
+   data = cpu_to_le32((u32)val & 0x);
r8712_usbctrl_vendorreq(pintfpriv, request, wvalue, index, &data, len,
  requesttype);
 }
@@ -143,7 +141,7 @@ static void usb_write32(struct intf_hdl *pintfhdl, u32 
addr, u32 val)
u16 wvalue;
u16 index;
u16 len;
-   u32 data;
+   __le32 data;
struct intf_priv *pintfpriv = pintfhdl->pintfpriv;
 
request = 0x05;
-- 
2.7.4

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


[PATCH 12/13] staging: rtl8712: changed u16 to __be16

2016-12-20 Thread Jannik Becher
Fixed sparse warning.
Just changed u16 to __be16 and typecasts.

Signed-off-by: Jannik Becher 
Tested-by: Larry Finger 
---
 drivers/staging/rtl8712/rtl8712_recv.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/rtl8712/rtl8712_recv.c 
b/drivers/staging/rtl8712/rtl8712_recv.c
index 66f0e0a..1332b46 100644
--- a/drivers/staging/rtl8712/rtl8712_recv.c
+++ b/drivers/staging/rtl8712/rtl8712_recv.c
@@ -408,7 +408,7 @@ static int amsdu_to_msdu(struct _adapter *padapter, union 
recv_frame *prframe)
memcpy(skb_push(sub_skb, ETH_ALEN), pattrib->dst,
ETH_ALEN);
} else {
-   u16 len;
+   __be16 len;
/* Leave Ethernet header part of hdr and full payload */
len = htons(sub_skb->len);
memcpy(skb_push(sub_skb, 2), &len, 2);
@@ -439,21 +439,21 @@ static int amsdu_to_msdu(struct _adapter *padapter, union 
recv_frame *prframe)
 
 void r8712_rxcmd_event_hdl(struct _adapter *padapter, void *prxcmdbuf)
 {
-   uint voffset;
+   __le32 voffset;
u8 *poffset;
u16 cmd_len, drvinfo_sz;
struct recv_stat *prxstat;
 
poffset = (u8 *)prxcmdbuf;
-   voffset = *(uint *)poffset;
+   voffset = *(__le32 *)poffset;
prxstat = (struct recv_stat *)prxcmdbuf;
drvinfo_sz = (le32_to_cpu(prxstat->rxdw0) & 0x000f) >> 16;
drvinfo_sz <<= 3;
poffset += RXDESC_SIZE + drvinfo_sz;
do {
-   voffset  = *(uint *)poffset;
+   voffset  = *(__le32 *)poffset;
cmd_len = (u16)(le32_to_cpu(voffset) & 0x);
-   r8712_event_handle(padapter, (uint *)poffset);
+   r8712_event_handle(padapter, (__le32 *)poffset);
poffset += (cmd_len + 8);/*8 bytes alignment*/
} while (le32_to_cpu(voffset) & BIT(31));
 
-- 
2.7.4

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


[PATCH 05/13] staging: rtl8712: changed GetFrameSubType macro

2016-12-20 Thread Jannik Becher
Fixed a sparse warning.
GetFrameSubType and GetFrameType should cast to __le16. Furthermore
GetFramSubType should use le16_to_cpu instead of cpu_to_le16.

Signed-off-by: Jannik Becher 
Tested-by: Larry Finger 
---
 drivers/staging/rtl8712/rtl871x_security.c | 4 ++--
 drivers/staging/rtl8712/wifi.h | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/rtl8712/rtl871x_security.c 
b/drivers/staging/rtl8712/rtl871x_security.c
index 3400e49..62d5694 100644
--- a/drivers/staging/rtl8712/rtl871x_security.c
+++ b/drivers/staging/rtl8712/rtl871x_security.c
@@ -1047,8 +1047,8 @@ static sint aes_cipher(u8 *key, uint  hdrlen,
u8 aes_out[16];
u8 padded_buffer[16];
u8 mic[8];
-   uintfrtype  = GetFrameType(pframe);
-   uintfrsubtype  = GetFrameSubType(pframe);
+   u16 frtype  = GetFrameType(pframe);
+   u16 frsubtype  = GetFrameSubType(pframe);
 
frsubtype >>= 4;
memset((void *)mic_iv, 0, 16);
diff --git a/drivers/staging/rtl8712/wifi.h b/drivers/staging/rtl8712/wifi.h
index b8af965..7ebf247 100644
--- a/drivers/staging/rtl8712/wifi.h
+++ b/drivers/staging/rtl8712/wifi.h
@@ -229,7 +229,7 @@ enum WIFI_REG_DOMAIN {
 #define GetOrder(pbuf) (((*(unsigned short *)(pbuf)) & \
le16_to_cpu(_ORDER_)) != 0)
 
-#define GetFrameType(pbuf) (le16_to_cpu(*(unsigned short *)(pbuf)) & \
+#define GetFrameType(pbuf) (le16_to_cpu(*(__le16 *)(pbuf)) & \
(BIT(3) | BIT(2)))
 
 #define SetFrameType(pbuf, type)   \
@@ -239,7 +239,7 @@ enum WIFI_REG_DOMAIN {
*(unsigned short *)(pbuf) |= cpu_to_le16(type); \
} while (0)
 
-#define GetFrameSubType(pbuf)  (cpu_to_le16(*(unsigned short *)(pbuf)) & \
+#define GetFrameSubType(pbuf)  (le16_to_cpu(*(__le16 *)(pbuf)) & \
(BIT(7) | BIT(6) | BIT(5) | BIT(4) | BIT(3) | \
BIT(2)))
 
-- 
2.7.4

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


[PATCH 08/13] staging: rtl8712: changed uint to __le32

2016-12-20 Thread Jannik Becher
Fixed a sparse warning.
Just changed uint to __le32.

Signed-off-by: Jannik Becher 
Tested-by: Larry Finger 
---
 drivers/staging/rtl8712/usb_ops_linux.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/rtl8712/usb_ops_linux.c 
b/drivers/staging/rtl8712/usb_ops_linux.c
index fc6bb0b..441e76b 100644
--- a/drivers/staging/rtl8712/usb_ops_linux.c
+++ b/drivers/staging/rtl8712/usb_ops_linux.c
@@ -192,7 +192,8 @@ void r8712_usb_write_mem(struct intf_hdl *pintfhdl, u32 
addr, u32 cnt, u8 *wmem)
 
 static void r8712_usb_read_port_complete(struct urb *purb)
 {
-   uint isevt, *pbuf;
+   uint isevt;
+   __le32 *pbuf;
struct recv_buf *precvbuf = (struct recv_buf *)purb->context;
struct _adapter *padapter = (struct _adapter *)precvbuf->adapter;
struct recv_priv *precvpriv = &padapter->recvpriv;
@@ -208,7 +209,7 @@ static void r8712_usb_read_port_complete(struct urb *purb)
_pkt *pskb = precvbuf->pskb;
 
precvbuf->transfer_len = purb->actual_length;
-   pbuf = (uint *)precvbuf->pbuf;
+   pbuf = (__le32 *)precvbuf->pbuf;
isevt = le32_to_cpu(*(pbuf + 1)) & 0x1ff;
if ((isevt & 0x1ff) == 0x1ff) {
r8712_rxcmd_event_hdl(padapter, pbuf);
-- 
2.7.4

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


[PATCH 06/13] staging: rtl8712: changed typecast to __le

2016-12-20 Thread Jannik Becher
Fixed sparse warning.
Changed uint to __le16 and __le32.

Signed-off-by: Jannik Becher 
Tested-by: Larry Finger 
---
 drivers/staging/rtl8712/hal_init.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/rtl8712/hal_init.c 
b/drivers/staging/rtl8712/hal_init.c
index 0dd458d..c83d7eb 100644
--- a/drivers/staging/rtl8712/hal_init.c
+++ b/drivers/staging/rtl8712/hal_init.c
@@ -117,16 +117,16 @@ static void fill_fwpriv(struct _adapter *padapter, struct 
fw_priv *pfwpriv)
 
 static void update_fwhdr(struct fw_hdr *pfwhdr, const u8 *pmappedfw)
 {
-   pfwhdr->signature = le16_to_cpu(*(u16 *)pmappedfw);
-   pfwhdr->version = le16_to_cpu(*(u16 *)(pmappedfw + 2));
+   pfwhdr->signature = le16_to_cpu(*(__le16 *)pmappedfw);
+   pfwhdr->version = le16_to_cpu(*(__le16 *)(pmappedfw + 2));
/* define the size of boot loader */
-   pfwhdr->dmem_size = le32_to_cpu(*(uint *)(pmappedfw + 4));
+   pfwhdr->dmem_size = le32_to_cpu(*(__le32 *)(pmappedfw + 4));
/* define the size of FW in IMEM */
-   pfwhdr->img_IMEM_size = le32_to_cpu(*(uint *)(pmappedfw + 8));
+   pfwhdr->img_IMEM_size = le32_to_cpu(*(__le32 *)(pmappedfw + 8));
/* define the size of FW in SRAM */
-   pfwhdr->img_SRAM_size = le32_to_cpu(*(uint *)(pmappedfw + 12));
+   pfwhdr->img_SRAM_size = le32_to_cpu(*(__le32 *)(pmappedfw + 12));
/* define the size of DMEM variable */
-   pfwhdr->fw_priv_sz = le32_to_cpu(*(uint *)(pmappedfw + 16));
+   pfwhdr->fw_priv_sz = le32_to_cpu(*(__le32 *)(pmappedfw + 16));
 }
 
 static u8 chk_fwhdr(struct fw_hdr *pfwhdr, u32 ulfilelength)
-- 
2.7.4

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


[PATCH 09/13] staging: rtl8712: fixed little endian problem

2016-12-20 Thread Jannik Becher
Fixed a sparse warning.
Using function le16_to_cpus() to avoid double assignment.

Signed-off-by: Jannik Becher 
Tested-by: Larry Finger 
---
 drivers/staging/rtl8712/rtl871x_ioctl_linux.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/rtl8712/rtl871x_ioctl_linux.c 
b/drivers/staging/rtl8712/rtl871x_ioctl_linux.c
index 590acb5..3518f1f 100644
--- a/drivers/staging/rtl8712/rtl871x_ioctl_linux.c
+++ b/drivers/staging/rtl8712/rtl871x_ioctl_linux.c
@@ -199,7 +199,7 @@ static noinline_for_stack char *translate_scan(struct 
_adapter *padapter,
iwe.cmd = SIOCGIWMODE;
memcpy((u8 *)&cap, r8712_get_capability_from_ie(pnetwork->network.IEs),
2);
-   cap = le16_to_cpu(cap);
+   le16_to_cpus(&cap);
if (cap & (WLAN_CAPABILITY_IBSS | WLAN_CAPABILITY_BSS)) {
if (cap & WLAN_CAPABILITY_BSS)
iwe.u.mode = (u32)IW_MODE_MASTER;
-- 
2.7.4

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


[PATCH 13/13] staging: rtl8712: used a better macro

2016-12-20 Thread Jannik Becher
Fixed a sparse warning.
Using be16_to_cpus() to avoid double assignment.

Signed-off-by: Jannik Becher 
Tested-by: Larry Finger 
---
 drivers/staging/rtl8712/rtl871x_recv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/rtl8712/rtl871x_recv.c 
b/drivers/staging/rtl8712/rtl871x_recv.c
index 35c721a..4388ddf 100644
--- a/drivers/staging/rtl8712/rtl871x_recv.c
+++ b/drivers/staging/rtl8712/rtl871x_recv.c
@@ -258,7 +258,7 @@ union recv_frame *r8712_portctrl(struct _adapter *adapter,
/* get ether_type */
ptr = ptr + pfhdr->attrib.hdrlen + LLC_HEADER_SIZE;
memcpy(ðer_type, ptr, 2);
-   ether_type = ntohs((unsigned short)ether_type);
+   be16_to_cpus(ðer_type);
 
if ((psta != NULL) && (psta->ieee8021x_blocked)) {
/* blocked
-- 
2.7.4

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


[PATCH 11/13] staging: rtl8712: changed cast to __le16

2016-12-20 Thread Jannik Becher
Fixed sparse warning.
Changed u16 to __le16

Signed-off-by: Jannik Becher 
Tested-by: Larry Finger 
---
 drivers/staging/rtl8712/ieee80211.c | 14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/rtl8712/ieee80211.c 
b/drivers/staging/rtl8712/ieee80211.c
index 5dc3b5b..ccf8ba6 100644
--- a/drivers/staging/rtl8712/ieee80211.c
+++ b/drivers/staging/rtl8712/ieee80211.c
@@ -174,16 +174,16 @@ int r8712_generate_ie(struct registry_priv *pregistrypriv)
sz += 8;
ie += sz;
/*beacon interval : 2bytes*/
-   *(u16 *)ie = cpu_to_le16((u16)pdev_network->Configuration.BeaconPeriod);
+   *(__le16 *)ie = 
cpu_to_le16((u16)pdev_network->Configuration.BeaconPeriod);
sz += 2;
ie += 2;
/*capability info*/
*(u16 *)ie = 0;
-   *(u16 *)ie |= cpu_to_le16(cap_IBSS);
+   *(__le16 *)ie |= cpu_to_le16(cap_IBSS);
if (pregistrypriv->preamble == PREAMBLE_SHORT)
-   *(u16 *)ie |= cpu_to_le16(cap_ShortPremble);
+   *(__le16 *)ie |= cpu_to_le16(cap_ShortPremble);
if (pdev_network->Privacy)
-   *(u16 *)ie |= cpu_to_le16(cap_Privacy);
+   *(__le16 *)ie |= cpu_to_le16(cap_Privacy);
sz += 2;
ie += 2;
/*SSID*/
@@ -224,7 +224,7 @@ unsigned char *r8712_get_wpa_ie(unsigned char *pie, int 
*wpa_ie_len, int limit)
goto check_next_ie;
/*check version...*/
memcpy((u8 *)&val16, (pbuf + 6), sizeof(val16));
-   val16 = le16_to_cpu(val16);
+   le16_to_cpus(&val16);
if (val16 != 0x0001)
goto check_next_ie;
*wpa_ie_len = *(pbuf + 1);
@@ -304,7 +304,7 @@ int r8712_parse_wpa_ie(u8 *wpa_ie, int wpa_ie_len, int 
*group_cipher,
}
/*pairwise_cipher*/
if (left >= 2) {
-   count = le16_to_cpu(*(u16 *)pos);
+   count = le16_to_cpu(*(__le16 *)pos);
pos += 2;
left -= 2;
if (count == 0 || left < count * WPA_SELECTOR_LEN)
@@ -347,7 +347,7 @@ int r8712_parse_wpa2_ie(u8 *rsn_ie, int rsn_ie_len, int 
*group_cipher,
}
/*pairwise_cipher*/
if (left >= 2) {
-   count = le16_to_cpu(*(u16 *)pos);
+   count = le16_to_cpu(*(__le16 *)pos);
pos += 2;
left -= 2;
if (count == 0 || left < count * RSN_SELECTOR_LEN)
-- 
2.7.4

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


[PATCH 10/13] staging: rtl8712: changed u32 to __le32

2016-12-20 Thread Jannik Becher
Fixed sparse warnings.
Deleted cpu_to_le32() for enum. I'm not sure why it was there.

Signed-off-by: Jannik Becher 
Tested-by: Larry Finger 
---
 drivers/staging/rtl8712/rtl871x_event.h |  2 +-
 drivers/staging/rtl8712/rtl871x_mlme.c  | 15 +++
 drivers/staging/rtl8712/wlan_bssdef.h   |  2 +-
 3 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/drivers/staging/rtl8712/rtl871x_event.h 
b/drivers/staging/rtl8712/rtl871x_event.h
index 697c8d7..5db8620 100644
--- a/drivers/staging/rtl8712/rtl871x_event.h
+++ b/drivers/staging/rtl8712/rtl871x_event.h
@@ -66,7 +66,7 @@ struct joinbss_event {
 struct stassoc_event {
unsigned char macaddr[6];
unsigned char rsvd[2];
-   intcam_id;
+   __le32cam_id;
 };
 
 struct stadel_event {
diff --git a/drivers/staging/rtl8712/rtl871x_mlme.c 
b/drivers/staging/rtl8712/rtl871x_mlme.c
index 35cbdc7..fd8d96d 100644
--- a/drivers/staging/rtl8712/rtl871x_mlme.c
+++ b/drivers/staging/rtl8712/rtl871x_mlme.c
@@ -257,10 +257,10 @@ int r8712_is_same_ibss(struct _adapter *adapter, struct 
wlan_network *pnetwork)
struct security_priv *psecuritypriv = &adapter->securitypriv;
 
if ((psecuritypriv->PrivacyAlgrthm != _NO_PRIVACY_) &&
-   (pnetwork->network.Privacy == 0))
+   (pnetwork->network.Privacy == cpu_to_le32(0)))
ret = false;
else if ((psecuritypriv->PrivacyAlgrthm == _NO_PRIVACY_) &&
-(pnetwork->network.Privacy == 1))
+(pnetwork->network.Privacy == cpu_to_le32(1)))
ret = false;
else
ret = true;
@@ -933,7 +933,7 @@ void r8712_stassoc_event_callback(struct _adapter *adapter, 
u8 *pbuf)
return;
/* to do : init sta_info variable */
psta->qos_option = 0;
-   psta->mac_id = le32_to_cpu((uint)pstassoc->cam_id);
+   psta->mac_id = le32_to_cpu(pstassoc->cam_id);
/* psta->aid = (uint)pstassoc->cam_id; */
 
if (adapter->securitypriv.AuthAlgrthm == 2)
@@ -1637,14 +1637,14 @@ void r8712_update_registrypriv_dev_network(struct 
_adapter *adapter)
pdev_network->Rssi = 0;
switch (pregistrypriv->wireless_mode) {
case WIRELESS_11B:
-   pdev_network->NetworkTypeInUse = cpu_to_le32(Ndis802_11DS);
+   pdev_network->NetworkTypeInUse = Ndis802_11DS;
break;
case WIRELESS_11G:
case WIRELESS_11BG:
-   pdev_network->NetworkTypeInUse = cpu_to_le32(Ndis802_11OFDM24);
+   pdev_network->NetworkTypeInUse = Ndis802_11OFDM24;
break;
case WIRELESS_11A:
-   pdev_network->NetworkTypeInUse = cpu_to_le32(Ndis802_11OFDM5);
+   pdev_network->NetworkTypeInUse = Ndis802_11OFDM5;
break;
default:
/* TODO */
@@ -1654,8 +1654,7 @@ void r8712_update_registrypriv_dev_network(struct 
_adapter *adapter)
   pregistrypriv->channel);
if (cur_network->network.InfrastructureMode == Ndis802_11IBSS)
pdev_network->Configuration.ATIMWindow = cpu_to_le32(3);
-   pdev_network->InfrastructureMode = cpu_to_le32(
-   cur_network->network.InfrastructureMode);
+   pdev_network->InfrastructureMode = 
cur_network->network.InfrastructureMode;
/* 1. Supported rates
 * 2. IE
 */
diff --git a/drivers/staging/rtl8712/wlan_bssdef.h 
b/drivers/staging/rtl8712/wlan_bssdef.h
index 86a88b4..c0654ae 100644
--- a/drivers/staging/rtl8712/wlan_bssdef.h
+++ b/drivers/staging/rtl8712/wlan_bssdef.h
@@ -83,7 +83,7 @@ struct wlan_bssid_ex {
unsigned char  MacAddress[6];
u8  Reserved[2];
struct ndis_802_11_ssid  Ssid;
-   u32 Privacy;
+   __le32 Privacy;
s32 Rssi;
enum NDIS_802_11_NETWORK_TYPE  NetworkTypeInUse;
struct NDIS_802_11_CONFIGURATION  Configuration;
-- 
2.7.4

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


Re: [PATCH] staging: lustre: ldlm: use designated initializers

2016-12-20 Thread Dan Carpenter
On Tue, Dec 20, 2016 at 08:47:51AM -0800, Bruce Korb wrote:
> >
> > "{ NULL }" is valid ISO C, but unfortunately "{}" is not.
> 
> Just make the thing "static const" and don't use an initializer.

That also works, of course.

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


Re: [PATCH] staging: lustre: ldlm: use designated initializers

2016-12-20 Thread Dan Carpenter
On Tue, Dec 20, 2016 at 02:57:17PM +, Hammond, John wrote:
> "{ NULL }" is valid ISO C, but unfortunately "{}" is not.

In the kernel we don't care.  We use lots of GCC extensions.

regards,
dan carpenter

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


Re: [PATCH] staging: lustre: ldlm: use designated initializers

2016-12-20 Thread Kees Cook
On Tue, Dec 20, 2016 at 11:07 AM, Dan Carpenter
 wrote:
> On Tue, Dec 20, 2016 at 02:57:17PM +, Hammond, John wrote:
>> "{ NULL }" is valid ISO C, but unfortunately "{}" is not.
>
> In the kernel we don't care.  We use lots of GCC extensions.

We depend on the compiler to do "incomplete zero-initialization" of
structures that are not mentioned in an initializer. The reason { NULL
} works is because the first field in the structure can take a NULL
value, and then the rest are zero-initialized by the compiler. { } is
the same thing, but doesn't use ordered initialization. If this style
is truly unacceptable to you, then { .somefield = NULL } can work, or
as you point out, if it's being initialized later, the static
initializer can be dropped entirely.

-Kees

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


[PATCH] staging: greybus: add host device function pointer checks

2016-12-20 Thread Jason Hrycay
Add sanity checks for cport_quiesce and cport_clear before invoking the
callbacks as these function pointers are not required during the host
device registration. This follows the logic implemented elsewhere for
various other function pointers.

Signed-off-by: Jason Hrycay 
---
 drivers/staging/greybus/connection.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/drivers/staging/greybus/connection.c 
b/drivers/staging/greybus/connection.c
index 833f83b..aa040b1 100644
--- a/drivers/staging/greybus/connection.c
+++ b/drivers/staging/greybus/connection.c
@@ -358,6 +358,9 @@ static int gb_connection_hd_cport_quiesce(struct 
gb_connection *connection)
size_t peer_space;
int ret;
 
+   if (!hd->driver->cport_quiesce)
+   return 0;
+
peer_space = sizeof(struct gb_operation_msg_hdr) +
sizeof(struct gb_cport_shutdown_request);
 
@@ -381,6 +384,9 @@ static int gb_connection_hd_cport_clear(struct 
gb_connection *connection)
struct gb_host_device *hd = connection->hd;
int ret;
 
+   if (!hd->driver->cport_clear)
+   return 0;
+
ret = hd->driver->cport_clear(hd, connection->hd_cport_id);
if (ret) {
dev_err(&hd->dev, "%s: failed to clear host cport: %d\n",
-- 
2.10.0

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


RE: [PATCH 01/15] hyperv: consolidate TSC ref page definitions

2016-12-20 Thread KY Srinivasan


> -Original Message-
> From: Roman Kagan [mailto:rka...@virtuozzo.com]
> Sent: Tuesday, December 20, 2016 7:56 AM
> To: Paolo Bonzini ; Radim Krčmář
> ; KY Srinivasan ; Vitaly
> Kuznetsov 
> Cc: Thomas Gleixner ; Ingo Molnar
> ; H. Peter Anvin ; x...@kernel.org;
> Haiyang Zhang ; k...@vger.kernel.org; linux-
> ker...@vger.kernel.org; de...@linuxdriverproject.org; Denis V . Lunev
> ; Roman Kagan 
> Subject: [PATCH 01/15] hyperv: consolidate TSC ref page definitions
> 
> Consolidate the guest-side and kvm-side definitions for Hyper-V TSC
> reference page.
> 
> While at this, rewrite read_hv_clock_tsc using the existing helpers.

Why not beak this into separate patches.
> 
> Signed-off-by: Roman Kagan 
> ---
>  arch/x86/include/asm/kvm_host.h|  2 +-
>  arch/x86/include/uapi/asm/hyperv.h |  4 +--
>  drivers/hv/hyperv_vmbus.h  |  8 --
>  arch/x86/kvm/hyperv.c  |  4 +--
>  drivers/hv/hv.c| 54 
> +++---
>  5 files changed, 26 insertions(+), 46 deletions(-)
> 
> diff --git a/arch/x86/include/asm/kvm_host.h
> b/arch/x86/include/asm/kvm_host.h
> index 2e25038..2b85f49 100644
> --- a/arch/x86/include/asm/kvm_host.h
> +++ b/arch/x86/include/asm/kvm_host.h
> @@ -713,7 +713,7 @@ struct kvm_hv {
>   u64 hv_crash_param[HV_X64_MSR_CRASH_PARAMS];
>   u64 hv_crash_ctl;
> 
> - HV_REFERENCE_TSC_PAGE tsc_ref;
> + struct hv_ref_tsc_page tsc_ref;
>  };
> 
>  struct kvm_arch {
> diff --git a/arch/x86/include/uapi/asm/hyperv.h
> b/arch/x86/include/uapi/asm/hyperv.h
> index 9b1a918..6098ab5 100644
> --- a/arch/x86/include/uapi/asm/hyperv.h
> +++ b/arch/x86/include/uapi/asm/hyperv.h
> @@ -252,12 +252,12 @@
>  #define HV_STATUS_INVALID_CONNECTION_ID  18
>  #define HV_STATUS_INSUFFICIENT_BUFFERS   19
> 
> -typedef struct _HV_REFERENCE_TSC_PAGE {
> +struct hv_ref_tsc_page {
>   __u32 tsc_sequence;
>   __u32 res1;
>   __u64 tsc_scale;
>   __s64 tsc_offset;
> -} HV_REFERENCE_TSC_PAGE, *PHV_REFERENCE_TSC_PAGE;
> +};
> 
>  /* Define the number of synthetic interrupt sources. */
>  #define HV_SYNIC_SINT_COUNT  (16)
> diff --git a/drivers/hv/hyperv_vmbus.h b/drivers/hv/hyperv_vmbus.h
> index 0675b39..4516498 100644
> --- a/drivers/hv/hyperv_vmbus.h
> +++ b/drivers/hv/hyperv_vmbus.h
> @@ -475,14 +475,6 @@ struct hv_context {
> 
>  extern struct hv_context hv_context;
> 
> -struct ms_hyperv_tsc_page {
> - volatile u32 tsc_sequence;
> - u32 reserved1;
> - volatile u64 tsc_scale;
> - volatile s64 tsc_offset;
> - u64 reserved2[509];
> -};
> -
>  struct hv_ring_buffer_debug_info {
>   u32 current_interrupt_mask;
>   u32 current_read_index;
> diff --git a/arch/x86/kvm/hyperv.c b/arch/x86/kvm/hyperv.c
> index 1572c35..c7db112 100644
> --- a/arch/x86/kvm/hyperv.c
> +++ b/arch/x86/kvm/hyperv.c
> @@ -806,7 +806,7 @@ static int kvm_hv_msr_set_crash_data(struct
> kvm_vcpu *vcpu,
>   * These two equivalencies are implemented in this function.
>   */
>  static bool compute_tsc_page_parameters(struct pvclock_vcpu_time_info
> *hv_clock,
> - HV_REFERENCE_TSC_PAGE *tsc_ref)
> + struct hv_ref_tsc_page *tsc_ref)
>  {
>   u64 max_mul;
> 
> @@ -847,7 +847,7 @@ void kvm_hv_setup_tsc_page(struct kvm *kvm,
>   u64 gfn;
> 
>   BUILD_BUG_ON(sizeof(tsc_seq) != sizeof(hv-
> >tsc_ref.tsc_sequence));
> - BUILD_BUG_ON(offsetof(HV_REFERENCE_TSC_PAGE,
> tsc_sequence) != 0);
> + BUILD_BUG_ON(offsetof(struct hv_ref_tsc_page, tsc_sequence) !=
> 0);
> 
>   if (!(hv->hv_tsc_page & HV_X64_MSR_TSC_REFERENCE_ENABLE))
>   return;
> diff --git a/drivers/hv/hv.c b/drivers/hv/hv.c
> index 446802a..a7256ec 100644
> --- a/drivers/hv/hv.c
> +++ b/drivers/hv/hv.c
> @@ -137,41 +137,29 @@ EXPORT_SYMBOL_GPL(hv_do_hypercall);
>  #ifdef CONFIG_X86_64
>  static cycle_t read_hv_clock_tsc(struct clocksource *arg)
>  {
> - cycle_t current_tick;
> - struct ms_hyperv_tsc_page *tsc_pg = hv_context.tsc_page;
> + struct hv_ref_tsc_page *tsc_pg = hv_context.tsc_page;
> + u32 sequence;
> + u64 scale;
> + s64 offset;
> +
> + do {
> + sequence = tsc_pg->tsc_sequence;
> + virt_rmb();
> +
> + if (!sequence) {
> + /* fallback to MSR */
> + cycle_t current_tick;
> + rdmsrl(HV_X64_MSR_TIME_REF_COUNT,
> current_tick);
> + return current_tick;
> + }
> 
> - if (tsc_pg->tsc_sequence != 0) {
> - /*
> -  * Use the tsc page to compute the value.
> -  */
> + scale = tsc_pg->tsc_scale;
> + offset = tsc_pg->tsc_offset;
> 
> - while (1) {
> - cycle_t tmp;
> - u32 sequence = tsc_pg->tsc_sequence;
> - u64 cur_tsc;
> - u64 scale = tsc_pg-

Re: [PATCH 0/6] storvsc: Miscellaneous fixes and enhancements

2016-12-20 Thread Martin K. Petersen
> "kys" == kys   writes:

kys> From: K. Y. Srinivasan  Miscellaneous fixes and
kys> enhancements.

Applied to 4.11/scsi-queue.

-- 
Martin K. Petersen  Oracle Linux Engineering
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: octeon: Call SET_NETDEV_DEV()

2016-12-20 Thread Florian Fainelli
On 12/14/2016 05:13 PM, Florian Fainelli wrote:
> The Octeon driver calls into PHYLIB which now checks for
> net_device->dev.parent, so make sure we do set it before calling into
> any MDIO/PHYLIB related function.
> 
> Fixes: ec988ad78ed6 ("phy: Don't increment MDIO bus refcount unless it's a 
> different owner")
> Reported-by: Aaro Koskinen 
> Signed-off-by: Florian Fainelli 

Greg, David, since this is a fix for a regression introduced in the net
tree, it may make sense that David take it via his tree.

Thanks

> ---
>  drivers/staging/octeon/ethernet.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/staging/octeon/ethernet.c 
> b/drivers/staging/octeon/ethernet.c
> index 8130dfe89745..4971aa54756a 100644
> --- a/drivers/staging/octeon/ethernet.c
> +++ b/drivers/staging/octeon/ethernet.c
> @@ -770,6 +770,7 @@ static int cvm_oct_probe(struct platform_device *pdev)
>   /* Initialize the device private structure. */
>   struct octeon_ethernet *priv = netdev_priv(dev);
>  
> + SET_NETDEV_DEV(dev, &pdev->dev);
>   dev->netdev_ops = &cvm_oct_pow_netdev_ops;
>   priv->imode = CVMX_HELPER_INTERFACE_MODE_DISABLED;
>   priv->port = CVMX_PIP_NUM_INPUT_PORTS;
> @@ -816,6 +817,7 @@ static int cvm_oct_probe(struct platform_device *pdev)
>   }
>  
>   /* Initialize the device private structure. */
> + SET_NETDEV_DEV(dev, &pdev->dev);
>   priv = netdev_priv(dev);
>   priv->netdev = dev;
>   priv->of_node = cvm_oct_node_for_port(pip, interface,
> 


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


[PATCH v3] fix code alignment with open parenthesis

2016-12-20 Thread Scott Matheina
These changes where identified by checkpatch.pl as needed changes to
align the code with the linux development coding style. The several
lines of text where aligned with the precending parenthesis.

Signed-off-by: Scott Matheina 
---
 drivers/staging/fbtft/fb_agm1264k-fl.c | 18 ++
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/drivers/staging/fbtft/fb_agm1264k-fl.c 
b/drivers/staging/fbtft/fb_agm1264k-fl.c
index a6e3af7..4ee76db 100644
--- a/drivers/staging/fbtft/fb_agm1264k-fl.c
+++ b/drivers/staging/fbtft/fb_agm1264k-fl.c
@@ -185,9 +185,9 @@ static void write_reg8_bus8(struct fbtft_par *par, int len, 
...)
buf[i] = (u8)va_arg(args, unsigned int);

va_end(args);
-   fbtft_par_dbg_hex(DEBUG_WRITE_REGISTER, par,
-   par->info->device, u8, buf, len, "%s: ", __func__);
-   }
+   fbtft_par_dbg_hex(DEBUG_WRITE_REGISTER, par, par->info->device,
+ u8, buf, len, "%s: ", __func__);
+}

va_start(args, len);

@@ -246,7 +246,7 @@ static void set_addr_win(struct fbtft_par *par, int xs, int 
ys, int xe, int ye)

 static void
 construct_line_bitmap(struct fbtft_par *par, u8 *dest, signed short *src,
-   int xs, int xe, int y)
+ int xs, int xe, int y)
 {
int x, i;

@@ -361,7 +361,8 @@ static int write_vmem(struct fbtft_par *par, size_t offset, 
size_t len)
/* left half of display */
if (addr_win.xs < par->info->var.xres / 2) {
construct_line_bitmap(par, buf, convert_buf,
-   addr_win.xs, par->info->var.xres / 2, y);
+ addr_win.xs,
+ par->info->var.xres / 2, y);

len = par->info->var.xres / 2 - addr_win.xs;

@@ -382,8 +383,9 @@ static int write_vmem(struct fbtft_par *par, size_t offset, 
size_t len)
/* right half of display */
if (addr_win.xe >= par->info->var.xres / 2) {
construct_line_bitmap(par, buf,
-   convert_buf, par->info->var.xres / 2,
-   addr_win.xe + 1, y);
+ convert_buf,
+ par->info->var.xres / 2,
+ addr_win.xe + 1, y);

len = addr_win.xe + 1 - par->info->var.xres / 2;

@@ -413,7 +415,7 @@ static int write_vmem(struct fbtft_par *par, size_t offset, 
size_t len)
 static int write(struct fbtft_par *par, void *buf, size_t len)
 {
fbtft_par_dbg_hex(DEBUG_WRITE, par, par->info->device, u8, buf, len,
-   "%s(len=%d): ", __func__, len);
+ "%s(len=%d): ", __func__, len);

gpio_set_value(par->RW, 0); /* set write mode */

--
2.7.4

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


[PATCH] indention and space fixes to align with linux style

2016-12-20 Thread Scott Matheina
Fixed indention and space issues to align the code with the linux style guide.

Signed-off-by: Scott Matheina 
---
 drivers/staging/iio/addac/adt7316.c | 603 
 1 file changed, 266 insertions(+), 337 deletions(-)

diff --git a/drivers/staging/iio/addac/adt7316.c 
b/drivers/staging/iio/addac/adt7316.c
index a7d90c8..6ba8d35 100644
--- a/drivers/staging/iio/addac/adt7316.c
+++ b/drivers/staging/iio/addac/adt7316.c
@@ -176,16 +176,16 @@
  */

 struct adt7316_chip_info {
-   struct adt7316_bus  bus;
-   u16 ldac_pin;
-   u16 int_mask;   /* 0x2f */
-   u8  config1;
-   u8  config2;
-   u8  config3;
-   u8  dac_config; /* DAC config */
-   u8  ldac_config;/* LDAC config */
-   u8  dac_bits;   /* 8, 10, 12 */
-   u8  id; /* chip id */
+   struct adt7316_bus bus;
+   u16 ldac_pin;
+   u16 int_mask;   /* 0x2f */
+   u8 config1;
+   u8 config2;
+   u8 config3;
+   u8 dac_config;  /* DAC config */
+   u8 ldac_config; /* LDAC config */
+   u8 dac_bits;/* 8, 10, 12 */
+   u8 id;  /* chip id */
 };

 /*
@@ -212,13 +212,12 @@ struct adt7316_chip_info {
  */

 struct adt7316_limit_regs {
-   u16 data_high;
-   u16 data_low;
+   u16 data_high;
+   u16 data_low;
 };

 static ssize_t adt7316_show_enabled(struct device *dev,
-   struct device_attribute *attr,
-   char *buf)
+   struct device_attribute *attr, char *buf)
 {
struct iio_dev *dev_info = dev_to_iio_dev(dev);
struct adt7316_chip_info *chip = iio_priv(dev_info);
@@ -227,7 +226,7 @@ static ssize_t adt7316_show_enabled(struct device *dev,
 }

 static ssize_t _adt7316_store_enabled(struct adt7316_chip_info *chip,
-   int enable)
+ int enable)
 {
u8 config1;
int ret;
@@ -248,9 +247,8 @@ static ssize_t _adt7316_store_enabled(struct 
adt7316_chip_info *chip,
 }

 static ssize_t adt7316_store_enabled(struct device *dev,
-   struct device_attribute *attr,
-   const char *buf,
-   size_t len)
+struct device_attribute *attr,
+const char *buf, size_t len)
 {
struct iio_dev *dev_info = dev_to_iio_dev(dev);
struct adt7316_chip_info *chip = iio_priv(dev_info);
@@ -268,13 +266,11 @@ static ssize_t adt7316_store_enabled(struct device *dev,
 }

 static IIO_DEVICE_ATTR(enabled, S_IRUGO | S_IWUSR,
-   adt7316_show_enabled,
-   adt7316_store_enabled,
-   0);
+  adt7316_show_enabled, adt7316_store_enabled, 0);

 static ssize_t adt7316_show_select_ex_temp(struct device *dev,
-   struct device_attribute *attr,
-   char *buf)
+  struct device_attribute *attr,
+  char *buf)
 {
struct iio_dev *dev_info = dev_to_iio_dev(dev);
struct adt7316_chip_info *chip = iio_priv(dev_info);
@@ -286,9 +282,8 @@ static ssize_t adt7316_show_select_ex_temp(struct device 
*dev,
 }

 static ssize_t adt7316_store_select_ex_temp(struct device *dev,
-   struct device_attribute *attr,
-   const char *buf,
-   size_t len)
+   struct device_attribute *attr,
+   const char *buf, size_t len)
 {
struct iio_dev *dev_info = dev_to_iio_dev(dev);
struct adt7316_chip_info *chip = iio_priv(dev_info);
@@ -312,13 +307,11 @@ static ssize_t adt7316_store_select_ex_temp(struct device 
*dev,
 }

 static IIO_DEVICE_ATTR(select_ex_temp, S_IRUGO | S_IWUSR,
-   adt7316_show_select_ex_temp,
-   adt7316_store_select_ex_temp,
-   0);
+  adt7316_show_select_ex_temp,
+  adt7316_store_select_ex_temp, 0);

 static ssize_t adt7316_show_mode(struct device *dev,
-   struct device_attribute *attr,
-   char *buf)
+struct device_attribute *attr, char *buf)
 {
struct iio_dev *dev_info = dev_to_iio_dev(dev);
struct adt7316_chip_info *chip = iio_priv(dev_info);
@@ -330,9 +323,8 @@ static ssize_t adt7316_show_mode(struct device *dev,
 }

 static ssize_t adt7316_store_mode(struct device *dev,
-   struct device_attribute *attr,
-   const char *buf,
-   size_t len)
+ struct device_attribute *attr,
+ const char *buf, size_t len)
 {
struct iio_dev *dev_in

Re: [PATCH] staging: octeon: Call SET_NETDEV_DEV()

2016-12-20 Thread David Miller
From: Florian Fainelli 
Date: Tue, 20 Dec 2016 17:02:37 -0800

> On 12/14/2016 05:13 PM, Florian Fainelli wrote:
>> The Octeon driver calls into PHYLIB which now checks for
>> net_device->dev.parent, so make sure we do set it before calling into
>> any MDIO/PHYLIB related function.
>> 
>> Fixes: ec988ad78ed6 ("phy: Don't increment MDIO bus refcount unless it's a 
>> different owner")
>> Reported-by: Aaro Koskinen 
>> Signed-off-by: Florian Fainelli 
> 
> Greg, David, since this is a fix for a regression introduced in the net
> tree, it may make sense that David take it via his tree.

Since the change in question is in Linus's tree, it's equally valid
for Greg to take it as well.
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] indention and space fixes to align with linux style

2016-12-20 Thread Joe Perches
On Tue, 2016-12-20 at 20:58 -0600, Scott Matheina wrote:
> Fixed indention and space issues to align the code with the linux style guide.
[]
> diff --git a/drivers/staging/iio/addac/adt7316.c 
> b/drivers/staging/iio/addac/adt7316.c
[]
> @@ -176,16 +176,16 @@
>   */
> 
>  struct adt7316_chip_info {
> - struct adt7316_bus  bus;
> - u16 ldac_pin;
> - u16 int_mask;   /* 0x2f */
> - u8  config1;
> - u8  config2;
> - u8  config3;
> - u8  dac_config; /* DAC config */
> - u8  ldac_config;/* LDAC config */
> - u8  dac_bits;   /* 8, 10, 12 */
> - u8  id; /* chip id */
> + struct adt7316_bus bus;
> + u16 ldac_pin;
> + u16 int_mask;   /* 0x2f */
> + u8 config1;
> + u8 config2;
> + u8 config3;
> + u8 dac_config;  /* DAC config */
> + u8 ldac_config; /* LDAC config */
> + u8 dac_bits;/* 8, 10, 12 */
> + u8 id;  /* chip id */
>  };

Hello Scott.

I believe you're relatively new at this
patch submission stuff.

The style above is fine and doesn't need
to be changed.  It is not in CodingStyle
as preferred one way or the other.

>  /*
> @@ -212,13 +212,12 @@ struct adt7316_chip_info {
>   */
> 
>  struct adt7316_limit_regs {
> - u16 data_high;
> - u16 data_low;
> + u16 data_high;
> + u16 data_low;
>  };
> 
>  static ssize_t adt7316_show_enabled(struct device *dev,
> - struct device_attribute *attr,
> - char *buf)
> + struct device_attribute *attr, char *buf)

This one isn't either but it is a very common
style in net/, drivers/net, and drivers/staging
though.

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


Re: [PATCH] indention and space fixes to align with linux style

2016-12-20 Thread Scott Matheina


> On Dec 20, 2016, at 9:23 PM, Joe Perches  wrote:
> 
>> On Tue, 2016-12-20 at 20:58 -0600, Scott Matheina wrote:
>> Fixed indention and space issues to align the code with the linux style 
>> guide.
> []
>> diff --git a/drivers/staging/iio/addac/adt7316.c 
>> b/drivers/staging/iio/addac/adt7316.c
> []
>> @@ -176,16 +176,16 @@
>>  */
>> 
>> struct adt7316_chip_info {
>> -struct adt7316_busbus;
>> -u16ldac_pin;
>> -u16int_mask;/* 0x2f */
>> -u8config1;
>> -u8config2;
>> -u8config3;
>> -u8dac_config;/* DAC config */
>> -u8ldac_config;/* LDAC config */
>> -u8dac_bits;/* 8, 10, 12 */
>> -u8id;/* chip id */
>> +struct adt7316_bus bus;
>> +u16 ldac_pin;
>> +u16 int_mask;/* 0x2f */
>> +u8 config1;
>> +u8 config2;
>> +u8 config3;
>> +u8 dac_config;/* DAC config */
>> +u8 ldac_config;/* LDAC config */
>> +u8 dac_bits;/* 8, 10, 12 */
>> +u8 id;/* chip id */
>> };
> 
> Hello Scott.
> 
> I believe you're relatively new at this
> patch submission stuff.
> 
> The style above is fine and doesn't need
> to be changed.  It is not in CodingStyle
> as preferred one way or the other.

I would say very very new just a couple submissions so any advice would be 
great, drivers/staging is, so I'm told a good place to make mistakes

>> /*
>> @@ -212,13 +212,12 @@ struct adt7316_chip_info {
>>  */
>> 
>> struct adt7316_limit_regs {
>> -u16data_high;
>> -u16data_low;
>> +u16 data_high;
>> +u16 data_low;
>> };
>> 
>> static ssize_t adt7316_show_enabled(struct device *dev,
>> -struct device_attribute *attr,
>> -char *buf)
>> +struct device_attribute *attr, char *buf)
> 
> This one isn't either but it is a very common
> style in net/, drivers/net, and drivers/staging
> though.
> 
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 01/15] hyperv: consolidate TSC ref page definitions

2016-12-20 Thread Roman Kagan
On Tue, Dec 20, 2016 at 08:57:28PM +, KY Srinivasan wrote:
> 
> 
> > -Original Message-
> > From: Roman Kagan [mailto:rka...@virtuozzo.com]
> > Sent: Tuesday, December 20, 2016 7:56 AM
> > To: Paolo Bonzini ; Radim Krčmář
> > ; KY Srinivasan ; Vitaly
> > Kuznetsov 
> > Cc: Thomas Gleixner ; Ingo Molnar
> > ; H. Peter Anvin ; x...@kernel.org;
> > Haiyang Zhang ; k...@vger.kernel.org; linux-
> > ker...@vger.kernel.org; de...@linuxdriverproject.org; Denis V . Lunev
> > ; Roman Kagan 
> > Subject: [PATCH 01/15] hyperv: consolidate TSC ref page definitions
> > 
> > Consolidate the guest-side and kvm-side definitions for Hyper-V TSC
> > reference page.
> > 
> > While at this, rewrite read_hv_clock_tsc using the existing helpers.
> 
> Why not beak this into separate patches.

Agreed, I'll do it in the next iteration.

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


Re: [PATCH 12/15] hyperv: move VMBus connection ids to uapi

2016-12-20 Thread Roman Kagan
On Tue, Dec 20, 2016 at 09:25:43AM -0800, Stephen Hemminger wrote:
> On Tue, 20 Dec 2016 18:55:59 +0300
> Roman Kagan  wrote:
> 
> > Userspace will need them too.
> > 
> > Signed-off-by: Roman Kagan 
> 
> What userspace? I am worried about creating more stable API's that can't 
> change.

QEMU in particular.  We're planning to implement VMBus devices in QEMU
and would like to have the definitions shared with the Linux guest
drivers for Hyper-V.

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


Re: [PATCH 02/15] hyperv: uapi-fy synic event flags definitions

2016-12-20 Thread Roman Kagan
On Tue, Dec 20, 2016 at 09:24:53AM -0800, Stephen Hemminger wrote:
> On Tue, 20 Dec 2016 18:55:49 +0300
> Roman Kagan  wrote:
> 
> > Move definitions related to the Hyper-V SynIC event flags to a header
> > where they can be consumed by userspace.
> > 
> > While doing so, also clean up their use by switching to standard bitops
> > and struct-based dereferencing.  The latter is also done for message
> > pages.
> > 
> > Signed-off-by: Roman Kagan 
> > ---
> >  arch/x86/include/uapi/asm/hyperv.h | 13 +
> >  drivers/hv/hyperv_vmbus.h  | 24 ++--
> >  drivers/hv/channel_mgmt.c  | 10 +++
> >  drivers/hv/connection.c| 47 ++-
> >  drivers/hv/vmbus_drv.c | 57 
> > ++
> >  5 files changed, 54 insertions(+), 97 deletions(-)
> > 
> > diff --git a/arch/x86/include/uapi/asm/hyperv.h 
> > b/arch/x86/include/uapi/asm/hyperv.h
> > index 6098ab5..af542a3 100644
> > --- a/arch/x86/include/uapi/asm/hyperv.h
> > +++ b/arch/x86/include/uapi/asm/hyperv.h
> > @@ -363,4 +363,17 @@ struct hv_timer_message_payload {
> >  #define HV_STIMER_AUTOENABLE   (1ULL << 3)
> >  #define HV_STIMER_SINT(config) (__u8)(((config) >> 16) & 0x0F)
> >  
> > +/* Define synthetic interrupt controller flag constants. */
> > +#define HV_EVENT_FLAGS_COUNT   (256 * 8)
> > +
> > +/* Define the synthetic interrupt controller event flags format. */
> > +struct hv_synic_event_flags {
> > +   __u64 flags[HV_EVENT_FLAGS_COUNT / 64];
> > +};
> > +
> > +/* Define the synthetic interrupt flags page layout. */
> > +struct hv_synic_event_flags_page {
> > +   struct hv_synic_event_flags sintevent_flags[HV_SYNIC_SINT_COUNT];
> > +};
> > +
> >  #endif
> 
> How are these going to be exposed to user space?
> 
> They should really be unsigned long since there is no guarantee of atomic 
> operation
> on 64 bit values on 32 bit architectures.

Indeed, absolutely.  These are bitmaps and should be unsigned long[], of
course.  I'll fix it in the next iteration.

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