Re: [PATCH v3 net-next 1/2] net: ethernet: slicoss: add slicoss gigabit ethernet driver

2016-11-28 Thread Lino Sanfilippo
Hi Florian,

On 28.11.2016 05:56, Florian Fainelli wrote:
> On 11/26/2016 04:20 AM, Lino Sanfilippo wrote:
>> Add driver for Alacritech gigabit ethernet cards with SLIC (session-layer
>> interface control) technology. The driver provides basic support without
>> SLIC for the following devices:
>> 
>> - Mojave cards (single port PCI Gigabit) both copper and fiber
>> - Oasis cards (single and dual port PCI-x Gigabit) copper and fiber
>> - Kalahari cards (dual and quad port PCI-e Gigabit) copper and fiber
> 
> This looks great, a few nits below:
> 
> 
>> +#define SLIC_MAX_TX_COMPLETIONS 100
> 
> You usually don't want to limit the number of TX completion, if the
> entire TX ring needs to be cleaned, you would want to allow that.
> 

The problem is that the HW does not provide a tx completion index. Instead we 
have to 
iterate the status descriptors until we get an invalid idx which indicates that 
there 
are no further tx descriptors done for now. I am afraid that if we do not limit 
the 
number of descriptors processed in the tx completion handler, a continuous 
transmission 
of frames could keep the loop in xmit_complete() run endlessly. I dont know if 
this 
can actually happen but I wanted to make sure that this is avoided.

> [snip]
> 
>> +while (slic_get_free_rx_descs(rxq) > SLIC_MAX_REQ_RX_DESCS) {
>> +skb = alloc_skb(maplen + ALIGN_MASK, gfp);
>> +if (!skb)
>> +break;
>> +
>> +paddr = dma_map_single(&sdev->pdev->dev, skb->data, maplen,
>> +   DMA_FROM_DEVICE);
>> +if (dma_mapping_error(&sdev->pdev->dev, paddr)) {
>> +netdev_err(dev, "mapping rx packet failed\n");
>> +/* drop skb */
>> +dev_kfree_skb_any(skb);
>> +break;
>> +}
>> +/* ensure head buffer descriptors are 256 byte aligned */
>> +offset = 0;
>> +misalign = paddr & ALIGN_MASK;
>> +if (misalign) {
>> +offset = SLIC_RX_BUFF_ALIGN - misalign;
>> +skb_reserve(skb, offset);
>> +}
>> +/* the HW expects dma chunks for descriptor + frame data */
>> +desc = (struct slic_rx_desc *)skb->data;
>> +memset(desc, 0, sizeof(*desc));
> 
> Do you really need to zero-out the prepending RX descriptor? Are not you
> missing a write barrier here?

Indeed, it should be sufficient to make sure that the bit SLIC_IRHDDR_SVALID is 
not set.
I will adjust it. 
Concerning the write barrier: You mean a wmb() before slic_write() to ensure 
that the zeroing
 of the status desc is done before the descriptor is passed to the HW, right?


> [snip]
> 
>> +
>> +dma_sync_single_for_cpu(&sdev->pdev->dev,
>> +dma_unmap_addr(buff, map_addr),
>> +buff->addr_offset + sizeof(*desc),
>> +DMA_FROM_DEVICE);
>> +
>> +status = le32_to_cpu(desc->status);
>> +if (!(status & SLIC_IRHDDR_SVALID))
>> +break;
>> +
>> +buff->skb = NULL;
>> +
>> +dma_unmap_single(&sdev->pdev->dev,
>> + dma_unmap_addr(buff, map_addr),
>> + dma_unmap_len(buff, map_len),
>> + DMA_FROM_DEVICE);
> 
> This is potentially inefficient, you already did a cache invalidation
> for the RX descriptor here, you could be more efficient with just
> invalidating the packet length, minus the descriptor length.
> 

I am not sure I understand: We have to unmap the complete dma area, no matter 
if we synced
part of it before, dont we? AFAIK a dma sync is different from unmapping dma, 
or do I miss
something?


>> +
>> +/* skip rx descriptor that is placed before the frame data */
>> +skb_reserve(skb, SLIC_RX_BUFF_HDR_SIZE);
>> +
>> +if (unlikely(status & SLIC_IRHDDR_ERR)) {
>> +slic_handle_frame_error(sdev, skb);
>> +dev_kfree_skb_any(skb);
>> +} else {
>> +struct ethhdr *eh = (struct ethhdr *)skb->data;
>> +
>> +if (is_multicast_ether_addr(eh->h_dest))
>> +SLIC_INC_STATS_COUNTER(&sdev->stats, rx_mcasts);
>> +
>> +len = le32_to_cpu(desc->length) & SLIC_IRHDDR_FLEN_MSK;
>> +skb_put(skb, len);
>> +skb->protocol = eth_type_trans(skb, dev);
>> +skb->ip_summed = CHECKSUM_UNNECESSARY;
>> +skb->dev = dev;
> 
> eth_type_trans() already assigns skb->dev = dev;
> 

Right, this is unnecessary, I will fix it.

>> +static int slic_poll(struct napi_struct *napi, int todo)
>> +{
>> +struct slic_device *sdev = container_of(napi, struct slic_device, napi);
>> +struct slic_shmem *sm = &sd

Re: [PATCH v3 net-next 1/2] net: ethernet: slicoss: add slicoss gigabit ethernet driver

2016-11-28 Thread Lino Sanfilippo
Hi Markus,

On 27.11.2016 18:59, Markus Böhme wrote:
> Hello Lino,
> 
> just some things barely worth mentioning:
> 

> 
> I found a bunch of unused #defines in slic.h. I cannot judge if they are
> worth keeping:
> 
>   SLIC_VRHSTATB_LONGE
>   SLIC_VRHSTATB_PREA
>   SLIC_ISR_IO
>   SLIC_ISR_PING_MASK
>   SLIC_GIG_SPEED_MASK
>   SLIC_GMCR_RESET
>   SLIC_XCR_RESET
>   SLIC_XCR_XMTEN
>   SLIC_XCR_PAUSEEN
>   SLIC_XCR_LOADRNG
>   SLIC_REG_DBAR
>   SLIC_REG_PING
>   SLIC_REG_DUMP_CMD
>   SLIC_REG_DUMP_DATA
>   SLIC_REG_WRHOSTID
>   SLIC_REG_LOW_POWER
>   SLIC_REG_RESET_IFACE
>   SLIC_REG_ADDR_UPPER
>   SLIC_REG_HBAR64
>   SLIC_REG_DBAR64
>   SLIC_REG_CBAR64
>   SLIC_REG_RBAR64
>   SLIC_REG_WRVLANID
>   SLIC_REG_READ_XF_INFO
>   SLIC_REG_WRITE_XF_INFO
>   SLIC_REG_TICKS_PER_SEC
> 
> These device IDs are not used, either, but maybe it's good to keep them
> for documentation purposes:
> 
>   PCI_SUBDEVICE_ID_ALACRITECH_1000X1_2
>   PCI_SUBDEVICE_ID_ALACRITECH_SES1001T
>   PCI_SUBDEVICE_ID_ALACRITECH_SEN2002XT
>   PCI_SUBDEVICE_ID_ALACRITECH_SEN2001XT
>   PCI_SUBDEVICE_ID_ALACRITECH_SEN2104ET
>   PCI_SUBDEVICE_ID_ALACRITECH_SEN2102ET
> 

I left these defines in for both documentation and to avoid gaps in
register ranges. I would like to keep this as it is.

>> +
>> +/* SLIC EEPROM structure for Oasis */
>> +struct slic_mojave_eeprom {
> 
> Comment: "for Mojave".

Will fix, thanks,

> 
> [...]
> 
>> +struct slic_device {
>> +struct pci_dev *pdev;
>> +struct net_device *netdev;
>> +void __iomem *regs;
>> +/* upper address setting lock */
>> +spinlock_t upper_lock;
>> +struct slic_shmem shmem;
>> +struct napi_struct napi;
>> +struct slic_rx_queue rxq;
>> +struct slic_tx_queue txq;
>> +struct slic_stat_queue stq;
>> +struct slic_stats stats;
>> +struct slic_upr_list upr_list;
>> +/* link configuration lock */
>> +spinlock_t link_lock;
>> +bool promisc;
>> +bool autoneg;
>> +int speed;
>> +int duplex;
> 
> Maybe make speed and duplex unsigned? They are assigned and compared
> against unsigned values in slicoss.c, so this would get rid of some
> (benign, because of the range of the values) -Wsign-compare warnings in
> slic_configure_link_locked. However, in a comparison there SPEED_UNKNOWN
> would need to be casted to unsigned to prevent another one popping up.
> 

There is indeed a bunch of warnings concerning signedness. Will have a look
at all of them. However I think I will keep "speed" as an int, because casting
SPEED_UNKNOWN to an unsigned int is IMHO an ugly thing to do.

> [...]
> 
>> +#endif /* _SLIC_H */
>> diff --git a/drivers/net/ethernet/alacritech/slicoss.c 
>> b/drivers/net/ethernet/alacritech/slicoss.c
>> new file mode 100644
>> index 000..8cd862a
>> --- /dev/null
>> +++ b/drivers/net/ethernet/alacritech/slicoss.c
>> @@ -0,0 +1,1867 @@
> 
> [...]
> 
>> +
>> +static const struct pci_device_id slic_id_tbl[] = {
>> +{ PCI_DEVICE(PCI_VENDOR_ID_ALACRITECH,
>> + PCI_DEVICE_ID_ALACRITECH_MOAVE) },
> 
> I missed this in slic.h, but is this a typo and "MOAVE" should be
> "MOJAVE"? There are a couple similar #defines in slic.h.

This should definitely be "Mojave". Will fix it. 

> 
> [...]
> 
>> +static void slic_refill_rx_queue(struct slic_device *sdev, gfp_t gfp)
>> +{
>> +const unsigned int ALIGN_MASK = SLIC_RX_BUFF_ALIGN - 1;
>> +unsigned int maplen = SLIC_RX_BUFF_SIZE;
>> +struct slic_rx_queue *rxq = &sdev->rxq;
>> +struct net_device *dev = sdev->netdev;
>> +struct slic_rx_buffer *buff;
>> +struct slic_rx_desc *desc;
>> +unsigned int misalign;
>> +unsigned int offset;
>> +struct sk_buff *skb;
>> +dma_addr_t paddr;
>> +
>> +while (slic_get_free_rx_descs(rxq) > SLIC_MAX_REQ_RX_DESCS) {
>> +skb = alloc_skb(maplen + ALIGN_MASK, gfp);
>> +if (!skb)
>> +break;
>> +
>> +paddr = dma_map_single(&sdev->pdev->dev, skb->data, maplen,
>> +   DMA_FROM_DEVICE);
>> +if (dma_mapping_error(&sdev->pdev->dev, paddr)) {
>> +netdev_err(dev, "mapping rx packet failed\n");
>> +/* drop skb */
>> +dev_kfree_skb_any(skb);
>> +break;
>> +}
>> +/* ensure head buffer descriptors are 256 byte aligned */
>> +offset = 0;
>> +misalign = paddr & ALIGN_MASK;
>> +if (misalign) {
>> +offset = SLIC_RX_BUFF_ALIGN - misalign;
>> +skb_reserve(skb, offset);
>> +}
>> +/* the HW expects dma chunks for descriptor + frame data */
>> +desc = (struct slic_rx_desc *)skb->data;
>> +memset(desc, 0, sizeof(*desc));
>> +
>> +buff = &rxq->rxbuffs[rxq->put_idx];
>> +  

[PATCH] staging: sm750fb: fix function definition argument style warning

2016-11-28 Thread Andrea Ghittino
Fixes sm750fb function definition argument style warning
found by checkpatch.pl tool

Signed-off-by: Andrea Ghittino 
---
diff --git a/drivers/staging/sm750fb/ddk750_chip.h 
b/drivers/staging/sm750fb/ddk750_chip.h
index e97e859..30653dd 100644
--- a/drivers/staging/sm750fb/ddk750_chip.h
+++ b/drivers/staging/sm750fb/ddk750_chip.h
@@ -91,6 +91,6 @@ void sm750_set_chip_type(unsigned short devId, char revId);
 unsigned int sm750_calc_pll_value(unsigned int request, struct  pll_value 
*pll);
 unsigned int sm750_format_pll_reg(struct pll_value *pPLL);
 unsigned int ddk750_get_vm_size(void);
-int ddk750_init_hw(struct initchip_param *);
+int ddk750_init_hw(struct initchip_param *p_init_param);
 
 #endif
diff --git a/drivers/staging/sm750fb/ddk750_display.h 
b/drivers/staging/sm750fb/ddk750_display.h
index 8abca88..c4a4cbf 100644
--- a/drivers/staging/sm750fb/ddk750_display.h
+++ b/drivers/staging/sm750fb/ddk750_display.h
@@ -107,6 +107,6 @@ typedef enum _disp_output_t {
 }
 disp_output_t;
 
-void ddk750_setLogicalDispOut(disp_output_t);
+void ddk750_setLogicalDispOut(disp_output_t output);
 
 #endif
diff --git a/drivers/staging/sm750fb/ddk750_mode.h 
b/drivers/staging/sm750fb/ddk750_mode.h
index e846dc2..bdcfe69 100644
--- a/drivers/staging/sm750fb/ddk750_mode.h
+++ b/drivers/staging/sm750fb/ddk750_mode.h
@@ -35,7 +35,7 @@ typedef struct _mode_parameter_t {
 }
 mode_parameter_t;
 
-int ddk750_setModeTiming(mode_parameter_t *, clock_type_t);
+int ddk750_setModeTiming(mode_parameter_t *parm, clock_type_t clock);
 
 
 #endif
diff --git a/drivers/staging/sm750fb/ddk750_power.h 
b/drivers/staging/sm750fb/ddk750_power.h
index eb088b0..6de0458 100644
--- a/drivers/staging/sm750fb/ddk750_power.h
+++ b/drivers/staging/sm750fb/ddk750_power.h
@@ -14,7 +14,7 @@ DPMS_t;
   (PEEK32(MISC_CTRL) & ~MISC_CTRL_DAC_POWER_OFF) | (off)); \
 }
 
-void ddk750_set_dpms(DPMS_t);
+void ddk750_set_dpms(DPMS_t state);
 void sm750_set_power_mode(unsigned int powerMode);
 void sm750_set_current_gate(unsigned int gate);
 
diff --git a/drivers/staging/sm750fb/sm750.h b/drivers/staging/sm750fb/sm750.h
index 28f4b9b..3b7bced 100644
--- a/drivers/staging/sm750fb/sm750.h
+++ b/drivers/staging/sm750fb/sm750.h
@@ -184,19 +184,23 @@ static inline unsigned long ps_to_hz(unsigned int psvalue)
 }
 
 int hw_sm750_map(struct sm750_dev *sm750_dev, struct pci_dev *pdev);
-int hw_sm750_inithw(struct sm750_dev*, struct pci_dev *);
-void hw_sm750_initAccel(struct sm750_dev *);
+int hw_sm750_inithw(struct sm750_dev *sm750_dev, struct pci_dev *pdev);
+void hw_sm750_initAccel(struct sm750_dev *sm750_dev);
 int hw_sm750_deWait(void);
 int hw_sm750le_deWait(void);
 
-int hw_sm750_output_setMode(struct lynxfb_output*, struct fb_var_screeninfo*,
-   struct fb_fix_screeninfo*);
-int hw_sm750_crtc_checkMode(struct lynxfb_crtc*, struct fb_var_screeninfo*);
-int hw_sm750_crtc_setMode(struct lynxfb_crtc*, struct fb_var_screeninfo*,
- struct fb_fix_screeninfo*);
-int hw_sm750_setColReg(struct lynxfb_crtc*, ushort, ushort, ushort, ushort);
-int hw_sm750_setBLANK(struct lynxfb_output*, int);
-int hw_sm750le_setBLANK(struct lynxfb_output*, int);
+int hw_sm750_output_setMode(struct lynxfb_output *output,
+   struct fb_var_screeninfo *var,
+   struct fb_fix_screeninfo *fix);
+int hw_sm750_crtc_checkMode(struct lynxfb_crtc *crtc,
+   struct fb_var_screeninfo *var);
+int hw_sm750_crtc_setMode(struct lynxfb_crtc *crtc,
+   struct fb_var_screeninfo *var,
+   struct fb_fix_screeninfo *fix);
+int hw_sm750_setColReg(struct lynxfb_crtc *crtc, ushort index,
+   ushort red, ushort green, ushort blue);
+int hw_sm750_setBLANK(struct lynxfb_output *output, int blank);
+int hw_sm750le_setBLANK(struct lynxfb_output *output, int blank);
 int hw_sm750_pan_display(struct lynxfb_crtc *crtc,
 const struct fb_var_screeninfo *var,
 const struct fb_info *info);
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: sm750fb: fix function definition argument style warning

2016-11-28 Thread Andrea Ghittino
On Mon, Nov 28, 2016 at 12:48 AM, Randy Dunlap  wrote:
> On 11/27/16 13:11, Andrea Ghittino wrote:
>> Fixes sm750fb function definition argument style warning
>> found by checkpatch.pl tool
>>
>> Signed-off-by: Andrea Ghittino 
>> ---
>
> Does checkpatch not complain about the camelcase variable names and
> function names?
>
>
> --
> ~Randy

No, it doesn't. But I correct some errors and changed one name for a variable

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


[PATCH] staging: greybus: fix line over 80 characters style warnings

2016-11-28 Thread Andrea Ghittino
Fixes greybus "line over 80 characters" style warnings 
found by checkpatch.pl tool

Signed-off-by: Andrea Ghittino 
---
diff --git a/drivers/staging/greybus/arche-apb-ctrl.c 
b/drivers/staging/greybus/arche-apb-ctrl.c
index 3fda0cd..755120a 100644
--- a/drivers/staging/greybus/arche-apb-ctrl.c
+++ b/drivers/staging/greybus/arche-apb-ctrl.c
@@ -168,7 +168,10 @@ static int standby_boot_seq(struct platform_device *pdev)
if (apb->init_disabled)
return 0;
 
-   /* Even if it is in OFF state, then we do not want to change the state 
*/
+   /*
+* Even if it is in OFF state,
+* then we do not want to change the state
+*/
if (apb->state == ARCHE_PLATFORM_STATE_STANDBY ||
apb->state == ARCHE_PLATFORM_STATE_OFF)
return 0;
diff --git a/drivers/staging/greybus/arche-platform.c 
b/drivers/staging/greybus/arche-platform.c
index 338c2d3..18ab2b4 100644
--- a/drivers/staging/greybus/arche-platform.c
+++ b/drivers/staging/greybus/arche-platform.c
@@ -295,7 +295,10 @@ static irqreturn_t arche_platform_wd_irq(int irq, void 
*devid)

arche_platform_set_wake_detect_state(arche_pdata,
 
WD_STATE_IDLE);
} else {
-   /* Check we are not in middle of irq thread 
already */
+   /*
+* Check we are not in middle
+* of irq thread already
+*/
if (arche_pdata->wake_detect_state !=
WD_STATE_COLDBOOT_START) {

arche_platform_set_wake_detect_state(arche_pdata,
@@ -312,12 +315,14 @@ static irqreturn_t arche_platform_wd_irq(int irq, void 
*devid)
if (arche_pdata->wake_detect_state == WD_STATE_IDLE) {
arche_pdata->wake_detect_start = jiffies;
/*
-* In the begining, when wake/detect goes low (first 
time), we assume
-* it is meant for coldboot and set the flag. If 
wake/detect line stays low
-* beyond 30msec, then it is coldboot else fallback to 
standby boot.
+* In the begining, when wake/detect goes low
+* (first time), we assume it is meant for coldboot
+* and set the flag. If wake/detect line stays low
+* beyond 30msec, then it is coldboot else
+* fallback to standby boot.
 */
arche_platform_set_wake_detect_state(arche_pdata,
-
WD_STATE_BOOT_INIT);
+
WD_STATE_BOOT_INIT);
}
}
 
@@ -561,7 +566,9 @@ static int arche_platform_probe(struct platform_device 
*pdev)
struct device_node *np = dev->of_node;
int ret;
 
-   arche_pdata = devm_kzalloc(&pdev->dev, sizeof(*arche_pdata), 
GFP_KERNEL);
+   arche_pdata = devm_kzalloc(&pdev->dev,
+  sizeof(*arche_pdata),
+  GFP_KERNEL);
if (!arche_pdata)
return -ENOMEM;
 
@@ -780,12 +787,18 @@ static SIMPLE_DEV_PM_OPS(arche_platform_pm_ops,
arche_platform_resume);
 
 static const struct of_device_id arche_platform_of_match[] = {
-   { .compatible = "google,arche-platform", }, /* Use PID/VID of SVC 
device */
+   {
+   /* Use PID/VID of SVC device */
+   .compatible = "google,arche-platform",
+   },
{ },
 };
 
 static const struct of_device_id arche_combined_id[] = {
-   { .compatible = "google,arche-platform", }, /* Use PID/VID of SVC 
device */
+   {
+   /* Use PID/VID of SVC device */
+   .compatible = "google,arche-platform",
+   },
{ .compatible = "usb,2", },
{ },
 };
diff --git a/drivers/staging/greybus/audio_codec.c 
b/drivers/staging/greybus/audio_codec.c
index f8862c6..e8010c8 100644
--- a/drivers/staging/greybus/audio_codec.c
+++ b/drivers/staging/greybus/audio_codec.c
@@ -831,7 +831,10 @@ int gbaudio_register_module(struct gbaudio_module_info 
*module)
snd_soc_dapm_link_component_dai_widgets(codec->card,
&codec->dapm);
 #ifdef CONFIG_SND_JACK
-   /* register jack devices for this module from codec->jack_list 
*/
+   /*
+* register jack devices for this module from
+* codec->jack_list
+*/
list_for_each_entry(jack, &codec->jack_list, list) {
if ((jack == &modu

Re: [PATCH] staging: greybus: fix line over 80 characters style warnings

2016-11-28 Thread Greg KH
On Mon, Nov 28, 2016 at 07:42:49PM +0100, Andrea Ghittino wrote:
> Fixes greybus "line over 80 characters" style warnings 
> found by checkpatch.pl tool
> 
> Signed-off-by: Andrea Ghittino 

You need a "real" email address here, please don't try to mask it.

thanks,

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


[PATCH] staging: greybus: fix line over 80 characters style warnings

2016-11-28 Thread Andrea Ghittino
Fixes greybus "line over 80 characters" style warnings 
found by checkpatch.pl tool

Signed-off-by: Andrea Ghittino 
---
diff --git a/drivers/staging/greybus/arche-apb-ctrl.c 
b/drivers/staging/greybus/arche-apb-ctrl.c
index 3fda0cd..755120a 100644
--- a/drivers/staging/greybus/arche-apb-ctrl.c
+++ b/drivers/staging/greybus/arche-apb-ctrl.c
@@ -168,7 +168,10 @@ static int standby_boot_seq(struct platform_device *pdev)
if (apb->init_disabled)
return 0;
 
-   /* Even if it is in OFF state, then we do not want to change the state 
*/
+   /*
+* Even if it is in OFF state,
+* then we do not want to change the state
+*/
if (apb->state == ARCHE_PLATFORM_STATE_STANDBY ||
apb->state == ARCHE_PLATFORM_STATE_OFF)
return 0;
diff --git a/drivers/staging/greybus/arche-platform.c 
b/drivers/staging/greybus/arche-platform.c
index 338c2d3..18ab2b4 100644
--- a/drivers/staging/greybus/arche-platform.c
+++ b/drivers/staging/greybus/arche-platform.c
@@ -295,7 +295,10 @@ static irqreturn_t arche_platform_wd_irq(int irq, void 
*devid)

arche_platform_set_wake_detect_state(arche_pdata,
 
WD_STATE_IDLE);
} else {
-   /* Check we are not in middle of irq thread 
already */
+   /*
+* Check we are not in middle
+* of irq thread already
+*/
if (arche_pdata->wake_detect_state !=
WD_STATE_COLDBOOT_START) {

arche_platform_set_wake_detect_state(arche_pdata,
@@ -312,12 +315,14 @@ static irqreturn_t arche_platform_wd_irq(int irq, void 
*devid)
if (arche_pdata->wake_detect_state == WD_STATE_IDLE) {
arche_pdata->wake_detect_start = jiffies;
/*
-* In the begining, when wake/detect goes low (first 
time), we assume
-* it is meant for coldboot and set the flag. If 
wake/detect line stays low
-* beyond 30msec, then it is coldboot else fallback to 
standby boot.
+* In the begining, when wake/detect goes low
+* (first time), we assume it is meant for coldboot
+* and set the flag. If wake/detect line stays low
+* beyond 30msec, then it is coldboot else
+* fallback to standby boot.
 */
arche_platform_set_wake_detect_state(arche_pdata,
-
WD_STATE_BOOT_INIT);
+
WD_STATE_BOOT_INIT);
}
}
 
@@ -561,7 +566,9 @@ static int arche_platform_probe(struct platform_device 
*pdev)
struct device_node *np = dev->of_node;
int ret;
 
-   arche_pdata = devm_kzalloc(&pdev->dev, sizeof(*arche_pdata), 
GFP_KERNEL);
+   arche_pdata = devm_kzalloc(&pdev->dev,
+  sizeof(*arche_pdata),
+  GFP_KERNEL);
if (!arche_pdata)
return -ENOMEM;
 
@@ -780,12 +787,18 @@ static SIMPLE_DEV_PM_OPS(arche_platform_pm_ops,
arche_platform_resume);
 
 static const struct of_device_id arche_platform_of_match[] = {
-   { .compatible = "google,arche-platform", }, /* Use PID/VID of SVC 
device */
+   {
+   /* Use PID/VID of SVC device */
+   .compatible = "google,arche-platform",
+   },
{ },
 };
 
 static const struct of_device_id arche_combined_id[] = {
-   { .compatible = "google,arche-platform", }, /* Use PID/VID of SVC 
device */
+   {
+   /* Use PID/VID of SVC device */
+   .compatible = "google,arche-platform",
+   },
{ .compatible = "usb,2", },
{ },
 };
diff --git a/drivers/staging/greybus/audio_codec.c 
b/drivers/staging/greybus/audio_codec.c
index f8862c6..e8010c8 100644
--- a/drivers/staging/greybus/audio_codec.c
+++ b/drivers/staging/greybus/audio_codec.c
@@ -831,7 +831,10 @@ int gbaudio_register_module(struct gbaudio_module_info 
*module)
snd_soc_dapm_link_component_dai_widgets(codec->card,
&codec->dapm);
 #ifdef CONFIG_SND_JACK
-   /* register jack devices for this module from codec->jack_list 
*/
+   /*
+* register jack devices for this module from
+* codec->jack_list
+*/
list_for_each_entry(jack, &codec->jack_list, list) {
if ((jack == &modu

RE: [PATCH] hv: utils: properly pick TS protocol version for future hosts

2016-11-28 Thread Alex Ng (LIS)
> -Original Message-
> From: Vitaly Kuznetsov [mailto:vkuzn...@redhat.com]
> Sent: Monday, November 28, 2016 8:30 AM
> To: de...@linuxdriverproject.org
> Cc: linux-ker...@vger.kernel.org; KY Srinivasan ;
> Haiyang Zhang ; Alex Ng (LIS)
> 
> Subject: [PATCH] hv: utils: properly pick TS protocol version for future hosts
> 
> It is reasonable to expect that future Hyper-V versions will continue
> supporting TimeSync v4 protocol, we, however, only pick it for
> VERSION_WIN10. Currently this is not an issue as VERSION_WIN10 is the
> maximum protocol version we can negotiate but this may change in future.
> Instead of hoping that we won't forget to update it when time comes I
> suggest we change the default now.
> 

Vitaly, can you see if this upstream commit already fixes the issue you 
described?

https://git.kernel.org/cgit/linux/kernel/git/next/linux-next.git/commit/drivers/hv?id=3da0401b4d0e17aea7526db0235d98fa535d903e

> Signed-off-by: Vitaly Kuznetsov 
> ---
>  drivers/hv/hv_util.c | 13 +
>  1 file changed, 5 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/hv/hv_util.c b/drivers/hv/hv_util.c
> index bcd0630..a13003f 100644
> --- a/drivers/hv/hv_util.c
> +++ b/drivers/hv/hv_util.c
> @@ -382,23 +382,20 @@ static int util_probe(struct hv_device *dev,
>* Based on the host; initialize the framework and
>* service version numbers we will negotiate.
>*/
> - switch (vmbus_proto_version) {
> - case (VERSION_WS2008):
> + if (vmbus_proto_version <= VERSION_WS2008) {
>   util_fw_version = UTIL_WS2K8_FW_VERSION;
>   sd_srv_version = SD_VERSION_1;
>   ts_srv_version = TS_VERSION_1;
>   hb_srv_version = HB_VERSION_1;
> - break;
> - case(VERSION_WIN10):
> + } else if (vmbus_proto_version < VERSION_WIN10) {
>   util_fw_version = UTIL_FW_VERSION;
>   sd_srv_version = SD_VERSION;
> - ts_srv_version = TS_VERSION;
> + ts_srv_version = TS_VERSION_3;
>   hb_srv_version = HB_VERSION;
> - break;
> - default:
> + } else {
>   util_fw_version = UTIL_FW_VERSION;
>   sd_srv_version = SD_VERSION;
> - ts_srv_version = TS_VERSION_3;
> + ts_srv_version = TS_VERSION;
>   hb_srv_version = HB_VERSION;
>   }
> 
> --
> 2.9.3

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


RE: [PATCH 6/9] bus: fsl-mc: dpio: add QBMan portal APIs for DPAA2

2016-11-28 Thread Ruxandra Ioana Radulescu
> -Original Message-
> From: Stuart Yoder [mailto:stuart.yo...@nxp.com]
> Sent: Friday, October 21, 2016 9:02 AM
> To: gre...@linuxfoundation.org
> Cc: German Rivera ; de...@driverdev.osuosl.org;
> linux-ker...@vger.kernel.org; ag...@suse.de; a...@arndb.de; Leo Li
> ; Roy Pledge ; Roy Pledge
> ; Haiying Wang ; Stuart
> Yoder 
> Subject: [PATCH 6/9] bus: fsl-mc: dpio: add QBMan portal APIs for DPAA2
> 
> From: Roy Pledge 
> 
> Add QBman APIs for frame queue and buffer pool operations.
> 
> Signed-off-by: Roy Pledge 
> Signed-off-by: Haiying Wang 
> Signed-off-by: Stuart Yoder 
> ---
>  drivers/bus/fsl-mc/dpio/Makefile   |2 +-
>  drivers/bus/fsl-mc/dpio/qbman-portal.c | 1009
> 
>  drivers/bus/fsl-mc/dpio/qbman-portal.h |  464 +++
>  3 files changed, 1474 insertions(+), 1 deletion(-)
>  create mode 100644 drivers/bus/fsl-mc/dpio/qbman-portal.c
>  create mode 100644 drivers/bus/fsl-mc/dpio/qbman-portal.h
> 
> diff --git a/drivers/bus/fsl-mc/dpio/Makefile b/drivers/bus/fsl-
> mc/dpio/Makefile
> index 128befc..6588498 100644
> --- a/drivers/bus/fsl-mc/dpio/Makefile
> +++ b/drivers/bus/fsl-mc/dpio/Makefile
> @@ -6,4 +6,4 @@ subdir-ccflags-y := -Werror
> 
>  obj-$(CONFIG_FSL_MC_DPIO) += fsl-mc-dpio.o
> 
> -fsl-mc-dpio-objs := dpio.o
> +fsl-mc-dpio-objs := dpio.o qbman-portal.o
> diff --git a/drivers/bus/fsl-mc/dpio/qbman-portal.c b/drivers/bus/fsl-
> mc/dpio/qbman-portal.c
> new file mode 100644
> index 000..1eb3dd9
> --- /dev/null
> +++ b/drivers/bus/fsl-mc/dpio/qbman-portal.c

[...]

> +/**
> + * qbman_swp_pull() - Issue the pull dequeue command
> + * @s: the software portal object
> + * @d: the software portal descriptor which has been configured with
> + * the set of qbman_pull_desc_set_*() calls
> + *
> + * Return 0 for success, and -EBUSY if the software portal is not ready
> + * to do pull dequeue.
> + */
> +int qbman_swp_pull(struct qbman_swp *s, struct qbman_pull_desc *d)
> +{
> + struct qbman_pull_desc *p;
> +
> + if (!atomic_dec_and_test(&s->vdq.available)) {
> + atomic_inc(&s->vdq.available);
> + return -EBUSY;
> + }
> + s->vdq.storage = (void *)d->rsp_addr_virt;
> + d->tok = 1;
> + p = qbman_get_cmd(s, QBMAN_CENA_SWP_VDQCR);
> + *p = *d;
> + dma_wmb();
> +
> + /* Set the verb byte, have to substitute in the valid-bit */
> + p->verb |= s->vdq.valid_bit;
> + s->vdq.valid_bit ^= QB_VALID_BIT;
> +
> + return 0;
> +}
> +
[...] 
> +
> +/**
> + * qbman_result_has_new_result() - Check and get the dequeue response
> from the
> + * dq storage memory set in pull dequeue 
> command
> + * @s: the software portal object
> + * @dq: the dequeue result read from the memory
> + *
> + * Return 1 for getting a valid dequeue result, or 0 for not getting a valid
> + * dequeue result.
> + *
> + * Only used for user-provided storage of dequeue results, not DQRR. For
> + * efficiency purposes, the driver will perform any required endianness
> + * conversion to ensure that the user's dequeue result storage is in host-
> endian
> + * format. As such, once the user has called
> qbman_result_has_new_result() and
> + * been returned a valid dequeue result, they should not call it again on
> + * the same memory location (except of course if another dequeue
> command has
> + * been executed to produce a new result to that location).
> + */
> +int qbman_result_has_new_result(struct qbman_swp *s, const struct
> dpaa2_dq *dq)
> +{
> + if (!dq->dq.tok)
> + return 0;

While testing the Ethernet driver I discovered that sometimes the above
check fails.

When we check a store entry for the first time, if the hardware didn't
manage to fill it with a valid respose yet, we may find a non-null value in the
token field (because the stores have uninitialized memory). So by only
checking that token is !=0, we risk processing an uninitialized memory area
as a valid dequeue entry.

We should always compare the token field against 1, the value that is given
to the hardware on the dequeue command. It might also be a good idea
to use a define here, to make it clear 1 is a magic value.

And I think we should also zero the stores when they are first allocated,
since even with the proposed fix there's still a (much smaller) risk of finding
our exact token value in an uninitialized memory area.

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


Re: [PATCH] staging: greybuis: fix line over 80 characters style warnings

2016-11-28 Thread Andrea Ghittino
On Mon, Nov 28, 2016 at 10:14:03AM +0530, Vaibhav Hiremath wrote:
> On Sun, Nov 27, 2016 at 3:43 AM, Andrea Ghittino  wrote:
> > Fixes greybus "line over 80 characters" style warnings
> > found by checkpatch.pl tool
> >
> 
> It is always trade-off between readability vs 80 character restriction.
> I give preference and precedence to readability, so I kept it as is
> during development.
> 
> I have marked the changes with "+1", wherever I feel they should be
> accepted, and others probably not needed due to readability issue.
> 
> 
> > Signed-off-by: Andrea Ghittino 
> > ---
> >
> > diff --git a/drivers/staging/greybus/arche-apb-ctrl.c 
> > b/drivers/staging/greybus/arche-apb-ctrl.c
> > index 3fda0cd..755120a 100644
> > --- a/drivers/staging/greybus/arche-apb-ctrl.c
> > +++ b/drivers/staging/greybus/arche-apb-ctrl.c
> > @@ -168,7 +168,10 @@ static int standby_boot_seq(struct platform_device 
> > *pdev)
> > if (apb->init_disabled)
> > return 0;
> >
> > -   /* Even if it is in OFF state, then we do not want to change the 
> > state */
> > +   /*
> > +* Even if it is in OFF state,
> > +* then we do not want to change the state
> > +*/
> 
> +1
> 
> > if (apb->state == ARCHE_PLATFORM_STATE_STANDBY ||
> > apb->state == ARCHE_PLATFORM_STATE_OFF)
> > return 0;
> > diff --git a/drivers/staging/greybus/arche-platform.c 
> > b/drivers/staging/greybus/arche-platform.c
> > index 338c2d3..594fe01 100644
> > --- a/drivers/staging/greybus/arche-platform.c
> > +++ b/drivers/staging/greybus/arche-platform.c
> > @@ -291,15 +291,21 @@ static irqreturn_t arche_platform_wd_irq(int irq, 
> > void *devid)
> > if (arche_pdata->wake_detect_state == WD_STATE_BOOT_INIT) {
> > if (time_before(jiffies,
> > arche_pdata->wake_detect_start +
> > -   
> > msecs_to_jiffies(WD_COLDBOOT_PULSE_WIDTH_MS))) {
> > -   
> > arche_platform_set_wake_detect_state(arche_pdata,
> > -
> > WD_STATE_IDLE);
> > +   msecs_to_jiffies(
> > +   
> > WD_COLDBOOT_PULSE_WIDTH_MS))) {
> > +   arche_platform_set_wake_detect_state(
> > +   arche_pdata,
> > +   
> > WD_STATE_IDLE);
> 
> This I feel that, lets keep original code, as it impacts the readability.
> 
> > } else {
> > -   /* Check we are not in middle of irq thread 
> > already */
> > +   /*
> > +* Check we are not in middle
> > +* of irq thread already
> > +*/
> 
> +1
> 
> > if (arche_pdata->wake_detect_state !=
> > WD_STATE_COLDBOOT_START) {
> > -   
> > arche_platform_set_wake_detect_state(arche_pdata,
> > -   
> >  WD_STATE_COLDBOOT_TRIG);
> > +   
> > arche_platform_set_wake_detect_state(
> > +  
> > arche_pdata,
> > +  
> > WD_STATE_COLDBOOT_TRIG);
> 
> Probably keep the original code here as well.
> 
> > spin_unlock_irqrestore(
> > &arche_pdata->wake_lock,
> > flags);
> > @@ -312,12 +318,14 @@ static irqreturn_t arche_platform_wd_irq(int irq, 
> > void *devid)
> > if (arche_pdata->wake_detect_state == WD_STATE_IDLE) {
> > arche_pdata->wake_detect_start = jiffies;
> > /*
> > -* In the begining, when wake/detect goes low 
> > (first time), we assume
> > -* it is meant for coldboot and set the flag. If 
> > wake/detect line stays low
> > -* beyond 30msec, then it is coldboot else fallback 
> > to standby boot.
> > +* In the begining, when wake/detect goes low
> > +* (first time), we assume it is meant for coldboot
> > +* and set the flag. If wake/detect line stays low
> > +* beyond 30msec, then it is coldboot else
> > +* fallback to standby boot.
> >  */
> > arche_platform_set_wake_detect_state(arche_pdata,
> > -

[PATCH 2/2] uio-hv-generic: new userspace i/o driver for VMBus

2016-11-28 Thread Stephen Hemminger
This is a new driver to enable userspace networking on VMBus.
It is based largely on the similar driver that already exists
for PCI, and earlier work done by Brocade to support DPDK.

Signed-off-by: Stephen Hemminger 
---
 MAINTAINERS  |   1 +
 drivers/hv/connection.c  |   1 +
 drivers/uio/Kconfig  |   9 ++
 drivers/uio/Makefile |   1 +
 drivers/uio/uio_hv_generic.c | 216 +++
 5 files changed, 228 insertions(+)
 create mode 100644 drivers/uio/uio_hv_generic.c

diff --git a/MAINTAINERS b/MAINTAINERS
index f73e192..502166f 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -5938,6 +5938,7 @@ F:drivers/input/serio/hyperv-keyboard.c
 F: drivers/pci/host/pci-hyperv.c
 F: drivers/net/hyperv/
 F: drivers/scsi/storvsc_drv.c
+F: drivers/uio/uio_hv_generic.c
 F: drivers/video/fbdev/hyperv_fb.c
 F: include/linux/hyperv.h
 F: tools/hv/
diff --git a/drivers/hv/connection.c b/drivers/hv/connection.c
index 78e6368..6ce8b87 100644
--- a/drivers/hv/connection.c
+++ b/drivers/hv/connection.c
@@ -39,6 +39,7 @@ struct vmbus_connection vmbus_connection = {
.conn_state = DISCONNECTED,
.next_gpadl_handle  = ATOMIC_INIT(0xE1E10),
 };
+EXPORT_SYMBOL_GPL(vmbus_connection);
 
 /*
  * Negotiated protocol version with the host.
diff --git a/drivers/uio/Kconfig b/drivers/uio/Kconfig
index 52c98ce..7e8dc78 100644
--- a/drivers/uio/Kconfig
+++ b/drivers/uio/Kconfig
@@ -155,4 +155,13 @@ config UIO_MF624
 
  If you compile this as a module, it will be called uio_mf624.
 
+config UIO_HV_GENERIC
+   tristate "Generic driver for Hyper-V VMBus"
+   depends on HYPERV
+   help
+ Generic driver that you can bind, dynamically, to any
+ Hyper-V VMBus device. It is useful to provide direct access
+ to network and storage devices from userspace.
+
+ If you compile this as a module, it will be called uio_hv_generic.
 endif
diff --git a/drivers/uio/Makefile b/drivers/uio/Makefile
index 8560dad..e9663bb 100644
--- a/drivers/uio/Makefile
+++ b/drivers/uio/Makefile
@@ -9,3 +9,4 @@ obj-$(CONFIG_UIO_NETX)  += uio_netx.o
 obj-$(CONFIG_UIO_PRUSS) += uio_pruss.o
 obj-$(CONFIG_UIO_MF624) += uio_mf624.o
 obj-$(CONFIG_UIO_FSL_ELBC_GPCM)+= uio_fsl_elbc_gpcm.o
+obj-$(CONFIG_UIO_HV_GENERIC)   += uio_hv_generic.o
diff --git a/drivers/uio/uio_hv_generic.c b/drivers/uio/uio_hv_generic.c
new file mode 100644
index 000..ab5eccb
--- /dev/null
+++ b/drivers/uio/uio_hv_generic.c
@@ -0,0 +1,216 @@
+/*
+ * uio_hv_generic - generic UIO driver for VMBus
+ *
+ * Copyright (c) 2013-2016 Brocade Communications Systems, Inc.
+ * Copyright (c) 2016, Microsoft Corporation.
+ *
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2.
+ *
+ * Since the driver does not declare any device ids, you must allocate
+ * id and bind the device to the driver yourself.  For example:
+ *
+ * # echo "f8615163-df3e-46c5-913f-f2d2f965ed0e" \
+ *> /sys/bus/vmbus/drivers/uio_hv_generic
+ * # echo -n vmbus-ed963694-e847-4b2a-85af-bc9cfc11d6f3 \
+ *> /sys/bus/vmbus/drivers/hv_netvsc/unbind
+ * # echo -n vmbus-ed963694-e847-4b2a-85af-bc9cfc11d6f3 \
+ *> /sys/bus/vmbus/drivers/uio_hv_generic/bind
+ */
+
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "../hv/hyperv_vmbus.h"
+
+#define DRIVER_VERSION "0.02.0"
+#define DRIVER_AUTHOR  "Stephen Hemminger "
+#define DRIVER_DESC"Generic UIO driver for VMBus devices"
+
+/*
+ * List of resources to be mapped to user space
+ * can be extended up to MAX_UIO_MAPS(5) items
+ */
+enum hv_uio_map {
+   TXRX_RING_MAP = 0,
+   INT_PAGE_MAP,
+   MON_PAGE_MAP,
+};
+
+#define HV_RING_SIZE   512
+
+struct hv_uio_private_data {
+   struct uio_info info;
+   struct hv_device *device;
+};
+
+static int
+hv_uio_mmap(struct uio_info *info, struct vm_area_struct *vma)
+{
+   int mi;
+
+   if (vma->vm_pgoff >= MAX_UIO_MAPS)
+   return -EINVAL;
+
+   if (info->mem[vma->vm_pgoff].size == 0)
+   return -EINVAL;
+
+   mi = (int)vma->vm_pgoff;
+
+   return remap_pfn_range(vma, vma->vm_start,
+  virt_to_phys((void *)info->mem[mi].addr) >> 
PAGE_SHIFT,
+  vma->vm_end - vma->vm_start, vma->vm_page_prot);
+}
+
+/*
+ * This is the irqcontrol callback to be registered to uio_info.
+ * It can be used to disable/enable interrupt from user space processes.
+ *
+ * @param info
+ *  pointer to uio_info.
+ * @param irq_state
+ *  state value. 1 to enable interrupt, 0 to disable interrupt.
+ */
+static int
+hv_uio_irqcontrol(struct uio_info *info, s32 irq_state)
+{
+   struct hv_uio_private_data *pdata = info->priv;
+   struct hv_device *dev = pdata->device;
+
+   dev->channel->inbound.ring_buffer->interru

[PATCH 1/2] vmbus: add support for dynamic device id's

2016-11-28 Thread Stephen Hemminger
This patch adds sysfs interface to dynamically bind new UUID values
to existing VMBus device. This is useful for generic UIO driver to
act similar to uio_pci_generic.

Signed-off-by: Stephen Hemminger 
---
 drivers/hv/vmbus_drv.c | 174 ++---
 include/linux/hyperv.h |   6 ++
 2 files changed, 172 insertions(+), 8 deletions(-)

diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
index 0276d2e..85d6aba 100644
--- a/drivers/hv/vmbus_drv.c
+++ b/drivers/hv/vmbus_drv.c
@@ -45,6 +45,11 @@
 #include 
 #include "hyperv_vmbus.h"
 
+struct vmbus_dynid {
+   struct list_head node;
+   struct hv_vmbus_device_id id;
+};
+
 static struct acpi_device  *hv_acpi_dev;
 
 static struct completion probe_event;
@@ -500,7 +505,7 @@ static ssize_t device_show(struct device *dev,
 static DEVICE_ATTR_RO(device);
 
 /* Set up per device attributes in /sys/bus/vmbus/devices/ */
-static struct attribute *vmbus_attrs[] = {
+static struct attribute *vmbus_dev_attrs[] = {
&dev_attr_id.attr,
&dev_attr_state.attr,
&dev_attr_monitor_id.attr,
@@ -528,7 +533,7 @@ static struct attribute *vmbus_attrs[] = {
&dev_attr_device.attr,
NULL,
 };
-ATTRIBUTE_GROUPS(vmbus);
+ATTRIBUTE_GROUPS(vmbus_dev);
 
 /*
  * vmbus_uevent - add uevent for our device
@@ -565,10 +570,29 @@ static inline bool is_null_guid(const uuid_le *guid)
  * Return a matching hv_vmbus_device_id pointer.
  * If there is no match, return NULL.
  */
-static const struct hv_vmbus_device_id *hv_vmbus_get_id(
-   const struct hv_vmbus_device_id *id,
+static const struct hv_vmbus_device_id *hv_vmbus_get_id(struct hv_driver *drv,
const uuid_le *guid)
 {
+   const struct hv_vmbus_device_id *id = NULL;
+   struct vmbus_dynid *dynid;
+
+   /* Look at the dynamic ids first, before the static ones */
+   spin_lock(&drv->dynids.lock);
+   list_for_each_entry(dynid, &drv->dynids.list, node) {
+   if (!uuid_le_cmp(dynid->id.guid, *guid)) {
+   id = &dynid->id;
+   break;
+   }
+   }
+   spin_unlock(&drv->dynids.lock);
+
+   if (id)
+   return id;
+
+   id = drv->id_table;
+   if (id == NULL)
+   return NULL; /* empty device table */
+
for (; !is_null_guid(&id->guid); id++)
if (!uuid_le_cmp(id->guid, *guid))
return id;
@@ -576,6 +600,134 @@ static const struct hv_vmbus_device_id *hv_vmbus_get_id(
return NULL;
 }
 
+/* vmbus_add_dynid - add a new device ID to this driver and re-probe devices */
+static int vmbus_add_dynid(struct hv_driver *drv, uuid_le *guid)
+{
+   struct vmbus_dynid *dynid;
+
+   dynid = kzalloc(sizeof(*dynid), GFP_KERNEL);
+   if (!dynid)
+   return -ENOMEM;
+
+   dynid->id.guid = *guid;
+
+   spin_lock(&drv->dynids.lock);
+   list_add_tail(&dynid->node, &drv->dynids.list);
+   spin_unlock(&drv->dynids.lock);
+
+   return driver_attach(&drv->driver);
+}
+
+static void vmbus_free_dynids(struct hv_driver *drv)
+{
+   struct vmbus_dynid *dynid, *n;
+
+   spin_lock(&drv->dynids.lock);
+   list_for_each_entry_safe(dynid, n, &drv->dynids.list, node) {
+   list_del(&dynid->node);
+   kfree(dynid);
+   }
+   spin_unlock(&drv->dynids.lock);
+}
+
+/* Parse string of form: 1b4e28ba-2fa1-11d2-883f-b9a761bde3f */
+static int get_uuid_le(const char *str, uuid_le *uu)
+{
+   unsigned int b[16];
+   int i;
+
+   if (strlen(str) < 37)
+   return -1;
+
+   for (i = 0; i < 36; i++) {
+   switch (i) {
+   case 8: case 13: case 18: case 23:
+   if (str[i] != '-')
+   return -1;
+   break;
+   default:
+   if (!isxdigit(str[i]))
+   return -1;
+   }
+   }
+
+   /* unparse little endian output byte order */
+   if (sscanf(str,
+  "%2x%2x%2x%2x-%2x%2x-%2x%2x-%2x%2x-%2x%2x%2x%2x%2x%2x",
+  &b[3], &b[2], &b[1], &b[0],
+  &b[5], &b[4], &b[7], &b[6], &b[8], &b[9],
+  &b[10], &b[11], &b[12], &b[13], &b[14], &b[15]) != 16)
+   return -1;
+
+   for (i = 0; i < 16; i++)
+   uu->b[i] = b[i];
+   return 0;
+}
+
+/*
+ * store_new_id - sysfs frontend to vmbus_add_dynid()
+ *
+ * Allow GUIDs to be added to an existing driver via sysfs.
+ */
+static ssize_t store_new_id(struct device_driver *driver, const char *buf,
+   size_t count)
+{
+   struct hv_driver *drv = drv_to_hv_drv(driver);
+   uuid_le guid = NULL_UUID_LE;
+   ssize_t retval;
+
+   if (get_uuid_le(buf, &guid) != 0)
+   return -EINVAL;
+
+   if (hv_vmbus_get_id(drv

[PATCH v3 0/2] UIO support for Hyper-V

2016-11-28 Thread Stephen Hemminger
This is version 3, for some reason last version was not merged?
Documentation already merged into linux doc tree so that patch is
not included.

Stephen Hemminger (2):
  vmbus: add support for dynamic device id's
  uio-hv-generic: new userspace i/o driver for VMBus

 MAINTAINERS  |   1 +
 drivers/hv/connection.c  |   1 +
 drivers/hv/vmbus_drv.c   | 174 --
 drivers/uio/Kconfig  |   9 ++
 drivers/uio/Makefile |   1 +
 drivers/uio/uio_hv_generic.c | 216 +++
 include/linux/hyperv.h   |   6 ++
 7 files changed, 400 insertions(+), 8 deletions(-)
 create mode 100644 drivers/uio/uio_hv_generic.c

-- 
2.7.4

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


[PATCH] hv: utils: properly pick TS protocol version for future hosts

2016-11-28 Thread Vitaly Kuznetsov
It is reasonable to expect that future Hyper-V versions will continue
supporting TimeSync v4 protocol, we, however, only pick it for
VERSION_WIN10. Currently this is not an issue as VERSION_WIN10 is the
maximum protocol version we can negotiate but this may change in future.
Instead of hoping that we won't forget to update it when time comes I
suggest we change the default now.

Signed-off-by: Vitaly Kuznetsov 
---
 drivers/hv/hv_util.c | 13 +
 1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/drivers/hv/hv_util.c b/drivers/hv/hv_util.c
index bcd0630..a13003f 100644
--- a/drivers/hv/hv_util.c
+++ b/drivers/hv/hv_util.c
@@ -382,23 +382,20 @@ static int util_probe(struct hv_device *dev,
 * Based on the host; initialize the framework and
 * service version numbers we will negotiate.
 */
-   switch (vmbus_proto_version) {
-   case (VERSION_WS2008):
+   if (vmbus_proto_version <= VERSION_WS2008) {
util_fw_version = UTIL_WS2K8_FW_VERSION;
sd_srv_version = SD_VERSION_1;
ts_srv_version = TS_VERSION_1;
hb_srv_version = HB_VERSION_1;
-   break;
-   case(VERSION_WIN10):
+   } else if (vmbus_proto_version < VERSION_WIN10) {
util_fw_version = UTIL_FW_VERSION;
sd_srv_version = SD_VERSION;
-   ts_srv_version = TS_VERSION;
+   ts_srv_version = TS_VERSION_3;
hb_srv_version = HB_VERSION;
-   break;
-   default:
+   } else {
util_fw_version = UTIL_FW_VERSION;
sd_srv_version = SD_VERSION;
-   ts_srv_version = TS_VERSION_3;
+   ts_srv_version = TS_VERSION;
hb_srv_version = HB_VERSION;
}
 
-- 
2.9.3

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


Re: [PATCH 0/7] hv: CPU onlining/offlining fixes and improvements

2016-11-28 Thread Vitaly Kuznetsov
Dexuan Cui  writes:

>> From: Stephen Hemminger [mailto:step...@networkplumber.org]
>> Sent: Sunday, November 27, 2016 01:06
>> To: Vitaly Kuznetsov 
>> Cc: de...@linuxdriverproject.org; linux-ker...@vger.kernel.org; KY Srinivasan
>> ; Haiyang Zhang ; Dexuan Cui
>> 
>> Subject: Re: [PATCH 0/7] hv: CPU onlining/offlining fixes and improvements
>> 
>> On Fri, 25 Nov 2016 13:48:36 +0100
>> Vitaly Kuznetsov  wrote:
>> 
>> > Some time ago we forbade CPU offlining for Hyper-V and this was sufficient
>> > if you boot with all CPUs onlined. Turns out, people may want to limit the
>> > number online CPUs by passing 'maxcpus=' kernel parameter and we hit a
>> > crash in Hyper-V code in this case. After some thinking, I think we may not
>> > only fix the crash but also make the offlining prevention fine-grained: we
>> > need to prevent from offlining CPUs which have VMBus channels attached
>> > only. All offlined CPUs may always be onlined.
>> >
>> 
>> As a temporary solution this is ok, but long term we need to support
>> dynamic CPU online/offline.
>
> If a CPU is bound to some channels, it seems impossible to make it offline,
> unless Hyper-V supplies a mechanism to dynamically rebind  the channels (i.e.
> without closing & opening the channels) to another CPU, e.g. CPU0.
> Currently it looks there is no such mechanism.
>

Exactly. Offlining a CPU with an attached active VMBus channel means
killing the device and unless we're offereed an API to rebind it to some
other CPU there is no point in allowing that. We may, however, allow
offlining CPUs with sub-channels attached by closing these sub-channels,
not sure if we want to.

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