Re: [PATCH v8 0/4] gpiolib: speed up GPIO array processing

2018-09-13 Thread Linus Walleij
On Wed, Sep 5, 2018 at 11:49 PM Janusz Krzysztofik  wrote:

> The goal is to boost performance of get/set array functions while
> processing GPIO arrays which represent pins of a signle chip in
> hardware order.  If resulting performance is close to PIO, GPIO API
> can be used for data I/O without much loss of speed.

I applied the v8 to an immutable branch and pushed to kernelorg
so the build servers can churn it a bit, and if it works fine
then we can merge this into the devel branch and also set up
that as something other subsystems can pull in if they need it.

I'm really excited to merge this!

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


Re: [PATCH v4] staging: erofs: use explicit unsigned int type

2018-09-13 Thread Gao Xiang
Hi Thomas,

ping...

On 2018/9/12 14:21, Gao Xiang wrote:
> Hi Thomas,
> 
> On 2018/9/11 3:41, Thomas Weißschuh wrote:
>> Hi Chao,
>>
>> On Mon, 2018-09-10T23:59+0800, Chao Yu wrote:
>>> [...]
> I was not aware of this tree and worked off of staging / next.
> A patch is attached to this message that adds the tree to the MAINTAINERS 
> file.
 Hi Chao,

 I think this tree has some PREVIEW patches which preview in linux-erofs 
 mailing list only and
 doesn't send to staging mailing list and LKML,

 https://git.kernel.org/pub/scm/linux/kernel/git/chao/linux.git/log/?h=erofs

 so erofs tree is actually Greg's staging tree.
>>> Thomas,
>>>
>>> I confirmed that erofs git repository for linux upstream is Greg's staging 
>>> tree.
>>>
>>> Let me explain, in order to avoid sending buggy or preview patch, Xiang and 
>>> me
>>> plan to review patches in erofs mailing list first, and then cache reviewed
>>> patches in my git tree before sending them to Greg and staging mailing list.
>>>
>>> Based on that, I'm trying to serialize all erofs patches, expecting that can
>>> help those patches sent to staging mailing list can be merged by Greg with
>>> lesser conflict. But I made a mistake that my erofs branch has merged some
>>> pending patches, result in failing to merge yours, that mislead me to ask 
>>> you to
>>> rebase the code, sorry about that.
>> Thank you for clearing this up! And I am sorry for causing you all this work
>> for what is essentially a very small style cleanup.
>>
>>> Now I can confirm that your v2 patch can apply on Greg's staging-next, so 
>>> fixing
>>> warning reported by checkpatch.pl on your v2 patch is enough. :)
>> The patch follows.
>>
>> Thomas
> 
> Could you please resend your patch seperately? Because it will be easier for 
> Greg to merge.
> 
>>
>>
>> Changes since v1:
>>
>> * Removed changes that conflicted with
>>   [PATCH 1/6] staging: erofs: formatting fix in unzip_vle_lz4.c
>> * Added patch description
>>
>> Changes since v2:
>>
>> * Fixed conflicts with other patchsets
>> * Don't introduce new style issues
>>
>> Changes since v3:
>>
>> * Fixed conflicts with other patchsets
>>
>> Note: This patchset should be applied with the "git am --scissors", to
>> remove the historic information and this note.
>>
>> -- >8 --
> 
> I personally think that is not the correct kernel patch style.
> 
> Just as Greg's said,
>> These changes belong below the --- line, not above it.
> 
> LINK: https://lists.ozlabs.org/pipermail/linux-erofs/2018-August/000367.html
> 
> For reference, it will help the patch quickly get merged. ;)
> 
> and you could add,
> Reviewed-by: Gao Xiang 
> 
> Thanks,
> Gao Xiang
> 

and HUAWEI email server cannot send my all emails to your mailbox successfully.
Since you change a lot of files,I need to rebase my rest preview patches one by 
one right now.

Could you please resend a acceptable independent final patch for Greg? :)

Thanks,
Gao Xiang

>>
>> Fix coding style issue "Prefer 'unsigned int' to bare use of 'unsigned'"
>> detected by checkpatch.pl.
>>
>> Signed-off-by: Thomas Weißschuh 
> ___
> 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


[PATCH] staging: rtl8188eu: remove code that is valid only for 5 GHz

2018-09-13 Thread Robert Węcławski
Remove code that is used only for 5 GHz.
This addresses the below TODO item:

- find and remove remaining code valid only for 5 GHz. Most of the obvious
  ones have been removed, but things like channel > 14 still exist.

Signed-off-by: Robert Węcławski 
---
 drivers/staging/rtl8188eu/core/rtw_ap.c   | 23 ++---
 drivers/staging/rtl8188eu/core/rtw_debug.c| 25 +--
 drivers/staging/rtl8188eu/core/rtw_mlme.c | 10 
 drivers/staging/rtl8188eu/core/rtw_mlme_ext.c | 13 +-
 4 files changed, 9 insertions(+), 62 deletions(-)

diff --git a/drivers/staging/rtl8188eu/core/rtw_ap.c 
b/drivers/staging/rtl8188eu/core/rtw_ap.c
index e611eda11b5f..1c319c2ca86d 100644
--- a/drivers/staging/rtl8188eu/core/rtw_ap.c
+++ b/drivers/staging/rtl8188eu/core/rtw_ap.c
@@ -337,8 +337,6 @@ void add_RATid(struct adapter *padapter, struct sta_info 
*psta, u8 rssi_level)
unsigned char sta_band = 0, raid, shortGIrate = false;
unsigned int tx_ra_bitmap = 0;
struct ht_priv  *psta_ht = NULL;
-   struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
-   struct wlan_bssid_ex *pcur_network = (struct wlan_bssid_ex 
*)&pmlmepriv->cur_network.network;
 
if (psta)
psta_ht = &psta->htpriv;
@@ -363,20 +361,13 @@ void add_RATid(struct adapter *padapter, struct sta_info 
*psta, u8 rssi_level)
shortGIrate = psta_ht->sgi;
}
 
-   if (pcur_network->Configuration.DSConfig > 14) {
-   /*  5G band */
-   if (tx_ra_bitmap & 0x000)
-   sta_band |= WIRELESS_11_5N | WIRELESS_11A;
-   else
-   sta_band |= WIRELESS_11A;
-   } else {
-   if (tx_ra_bitmap & 0x000)
-   sta_band |= WIRELESS_11_24N | WIRELESS_11G | 
WIRELESS_11B;
-   else if (tx_ra_bitmap & 0xff0)
-   sta_band |= WIRELESS_11G | WIRELESS_11B;
-   else
-   sta_band |= WIRELESS_11B;
-   }
+   if (tx_ra_bitmap & 0x000)
+   sta_band |= WIRELESS_11_24N | WIRELESS_11G | WIRELESS_11B;
+   else if (tx_ra_bitmap & 0xff0)
+   sta_band |= WIRELESS_11G | WIRELESS_11B;
+   else
+   sta_band |= WIRELESS_11B;
+
 
psta->wireless_mode = sta_band;
 
diff --git a/drivers/staging/rtl8188eu/core/rtw_debug.c 
b/drivers/staging/rtl8188eu/core/rtw_debug.c
index 67461fdf315c..6c2fe1a112ac 100644
--- a/drivers/staging/rtl8188eu/core/rtw_debug.c
+++ b/drivers/staging/rtl8188eu/core/rtw_debug.c
@@ -153,13 +153,11 @@ int proc_get_best_channel(char *page, char **start,
struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
int len = 0;
-   u32 i, best_channel_24G = 1, best_channel_5G = 36, index_24G = 0, 
index_5G = 0;
+   u32 i, best_channel_24G = 1, index_24G = 0;
 
for (i = 0; pmlmeext->channel_set[i].ChannelNum != 0; i++) {
if (pmlmeext->channel_set[i].ChannelNum == 1)
index_24G = i;
-   if (pmlmeext->channel_set[i].ChannelNum == 36)
-   index_5G = i;
}
 
for (i = 0; pmlmeext->channel_set[i].ChannelNum != 0; i++) {
@@ -171,32 +169,11 @@ int proc_get_best_channel(char *page, char **start,
}
}
 
-   /*  5G */
-   if (pmlmeext->channel_set[i].ChannelNum >= 36 &&
-   pmlmeext->channel_set[i].ChannelNum < 140) {
-   /*  Find primary channel */
-   if (((pmlmeext->channel_set[i].ChannelNum - 36) % 8 == 
0) &&
-   (pmlmeext->channel_set[i].rx_count < 
pmlmeext->channel_set[index_5G].rx_count)) {
-   index_5G = i;
-   best_channel_5G = 
pmlmeext->channel_set[i].ChannelNum;
-   }
-   }
-
-   if (pmlmeext->channel_set[i].ChannelNum >= 149 &&
-   pmlmeext->channel_set[i].ChannelNum < 165) {
-   /*  find primary channel */
-   if (((pmlmeext->channel_set[i].ChannelNum - 149) % 8 == 
0) &&
-   (pmlmeext->channel_set[i].rx_count < 
pmlmeext->channel_set[index_5G].rx_count)) {
-   index_5G = i;
-   best_channel_5G = 
pmlmeext->channel_set[i].ChannelNum;
-   }
-   }
/*  debug */
len += snprintf(page + len, count - len, "The rx cnt of channel 
%3d = %d\n",
pmlmeext->channel_set[i].ChannelNum, 
pmlmeext->channel_set[i].rx_count);
}
 
-   len += snprintf(page + len, count - len, "best_channel_5G = %d\n", 
best_channel_5G);
len += snprintf(page + len, count - len, "best_channel_24G = %d

Re: [PATCH v2] staging: Convert to using %pOFn instead of device_node.name

2018-09-13 Thread Rob Herring
On Thu, Sep 13, 2018 at 3:45 PM Joe Perches  wrote:
>
> On Wed, 2018-09-12 at 15:26 -0500, Rob Herring wrote:
> > A problem with MAINTAINERS is there is no way to tell who applies
> > patches for a given path vs. anyone else listed.
>
> try the --scm option

That kind of helps if the maintainer has listed a tree, but gives
wrong results if not. And you still have to figure out who owns which
tree. That's not hard, but it's not scriptable.

IMO, we should reserve 'M:' for maintainers with trees and use 'R:'
driver maintainers. That's redefining M as "maintainer" rather than
"mail patches to". You could still have both for a entry so you can
know who to go bug when your patch hasn't been applied.

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


[PATCH 2/6] vmbus: keep pointer to ring buffer page

2018-09-13 Thread Stephen Hemminger
Avoid going from struct page to virt address (and back) by just
keeping pointer to the allocated pages instead of virt address.

Signed-off-by: Stephen Hemminger 
---
 drivers/hv/channel.c | 20 +---
 drivers/uio/uio_hv_generic.c |  5 +++--
 include/linux/hyperv.h   |  2 +-
 3 files changed, 13 insertions(+), 14 deletions(-)

diff --git a/drivers/hv/channel.c b/drivers/hv/channel.c
index 33e6db02dbab..56ec0d96d876 100644
--- a/drivers/hv/channel.c
+++ b/drivers/hv/channel.c
@@ -91,11 +91,14 @@ int vmbus_open(struct vmbus_channel *newchannel, u32 
send_ringbuffer_size,
unsigned long flags;
int ret, err = 0;
struct page *page;
+   unsigned int order;
 
if (send_ringbuffer_size % PAGE_SIZE ||
recv_ringbuffer_size % PAGE_SIZE)
return -EINVAL;
 
+   order = get_order(send_ringbuffer_size + recv_ringbuffer_size);
+
spin_lock_irqsave(&newchannel->lock, flags);
if (newchannel->state == CHANNEL_OPEN_STATE) {
newchannel->state = CHANNEL_OPENING_STATE;
@@ -110,21 +113,17 @@ int vmbus_open(struct vmbus_channel *newchannel, u32 
send_ringbuffer_size,
 
/* Allocate the ring buffer */
page = alloc_pages_node(cpu_to_node(newchannel->target_cpu),
-   GFP_KERNEL|__GFP_ZERO,
-   get_order(send_ringbuffer_size +
-   recv_ringbuffer_size));
+   GFP_KERNEL|__GFP_ZERO, order);
 
if (!page)
-   page = alloc_pages(GFP_KERNEL|__GFP_ZERO,
-  get_order(send_ringbuffer_size +
-recv_ringbuffer_size));
+   page = alloc_pages(GFP_KERNEL|__GFP_ZERO, order);
 
if (!page) {
err = -ENOMEM;
goto error_set_chnstate;
}
 
-   newchannel->ringbuffer_pages = page_address(page);
+   newchannel->ringbuffer_page = page;
newchannel->ringbuffer_pagecount = (send_ringbuffer_size +
   recv_ringbuffer_size) >> PAGE_SHIFT;
 
@@ -239,8 +238,7 @@ int vmbus_open(struct vmbus_channel *newchannel, u32 
send_ringbuffer_size,
 error_free_pages:
hv_ringbuffer_cleanup(&newchannel->outbound);
hv_ringbuffer_cleanup(&newchannel->inbound);
-   __free_pages(page,
-get_order(send_ringbuffer_size + recv_ringbuffer_size));
+   __free_pages(page, order);
 error_set_chnstate:
newchannel->state = CHANNEL_OPEN_STATE;
return err;
@@ -658,8 +656,8 @@ static int vmbus_close_internal(struct vmbus_channel 
*channel)
hv_ringbuffer_cleanup(&channel->outbound);
hv_ringbuffer_cleanup(&channel->inbound);
 
-   free_pages((unsigned long)channel->ringbuffer_pages,
-   get_order(channel->ringbuffer_pagecount * PAGE_SIZE));
+   __free_pages(channel->ringbuffer_page,
+get_order(channel->ringbuffer_pagecount << PAGE_SHIFT));
 
 out:
return ret;
diff --git a/drivers/uio/uio_hv_generic.c b/drivers/uio/uio_hv_generic.c
index a08860260f55..ba67a5267557 100644
--- a/drivers/uio/uio_hv_generic.c
+++ b/drivers/uio/uio_hv_generic.c
@@ -130,11 +130,12 @@ static int hv_uio_ring_mmap(struct file *filp, struct 
kobject *kobj,
= container_of(kobj, struct vmbus_channel, kobj);
struct hv_device *dev = channel->primary_channel->device_obj;
u16 q_idx = channel->offermsg.offer.sub_channel_index;
+   void *ring_buffer = page_address(channel->ringbuffer_page);
 
dev_dbg(&dev->device, "mmap channel %u pages %#lx at %#lx\n",
q_idx, vma_pages(vma), vma->vm_pgoff);
 
-   return vm_iomap_memory(vma, virt_to_phys(channel->ringbuffer_pages),
+   return vm_iomap_memory(vma, virt_to_phys(ring_buffer),
   channel->ringbuffer_pagecount << PAGE_SHIFT);
 }
 
@@ -223,7 +224,7 @@ hv_uio_probe(struct hv_device *dev,
/* mem resources */
pdata->info.mem[TXRX_RING_MAP].name = "txrx_rings";
pdata->info.mem[TXRX_RING_MAP].addr
-   = (uintptr_t)dev->channel->ringbuffer_pages;
+   = (uintptr_t)page_address(dev->channel->ringbuffer_page);
pdata->info.mem[TXRX_RING_MAP].size
= dev->channel->ringbuffer_pagecount << PAGE_SHIFT;
pdata->info.mem[TXRX_RING_MAP].memtype = UIO_MEM_LOGICAL;
diff --git a/include/linux/hyperv.h b/include/linux/hyperv.h
index 6c4575c7f46b..a6c32d2d090b 100644
--- a/include/linux/hyperv.h
+++ b/include/linux/hyperv.h
@@ -739,7 +739,7 @@ struct vmbus_channel {
u32 ringbuffer_gpadlhandle;
 
/* Allocated memory for ring buffer */
-   void *ringbuffer_pages;
+   struct page *ringbuffer_page;
u32 ringbuffer_pagecount;
struct hv_ring_buffer_info outbound;/* send to parent */
struct hv_ring_buffer_info inbound; /* 

[PATCH 1/6] vmbus: pass channel to hv_process_channel_removal

2018-09-13 Thread Stephen Hemminger
Rather than passing relid and then looking up the channel.
Pass the channel directly, since caller already knows it.

Signed-off-by: Stephen Hemminger 
---
 drivers/hv/channel.c  |  3 +--
 drivers/hv/channel_mgmt.c | 17 +
 drivers/hv/vmbus_drv.c|  3 +--
 include/linux/hyperv.h|  2 +-
 4 files changed, 8 insertions(+), 17 deletions(-)

diff --git a/drivers/hv/channel.c b/drivers/hv/channel.c
index 741857d80da1..33e6db02dbab 100644
--- a/drivers/hv/channel.c
+++ b/drivers/hv/channel.c
@@ -690,8 +690,7 @@ void vmbus_close(struct vmbus_channel *channel)
wait_for_completion(&cur_channel->rescind_event);
mutex_lock(&vmbus_connection.channel_mutex);
vmbus_close_internal(cur_channel);
-   hv_process_channel_removal(
-  cur_channel->offermsg.child_relid);
+   hv_process_channel_removal(cur_channel);
} else {
mutex_lock(&vmbus_connection.channel_mutex);
vmbus_close_internal(cur_channel);
diff --git a/drivers/hv/channel_mgmt.c b/drivers/hv/channel_mgmt.c
index 0f0e091c117c..b7c48ebdf6a1 100644
--- a/drivers/hv/channel_mgmt.c
+++ b/drivers/hv/channel_mgmt.c
@@ -385,21 +385,14 @@ static void vmbus_release_relid(u32 relid)
trace_vmbus_release_relid(&msg, ret);
 }
 
-void hv_process_channel_removal(u32 relid)
+void hv_process_channel_removal(struct vmbus_channel *channel)
 {
+   struct vmbus_channel *primary_channel;
unsigned long flags;
-   struct vmbus_channel *primary_channel, *channel;
 
BUG_ON(!mutex_is_locked(&vmbus_connection.channel_mutex));
-
-   /*
-* Make sure channel is valid as we may have raced.
-*/
-   channel = relid2channel(relid);
-   if (!channel)
-   return;
-
BUG_ON(!channel->rescind);
+
if (channel->target_cpu != get_cpu()) {
put_cpu();
smp_call_function_single(channel->target_cpu,
@@ -429,7 +422,7 @@ void hv_process_channel_removal(u32 relid)
cpumask_clear_cpu(channel->target_cpu,
  &primary_channel->alloced_cpus_in_node);
 
-   vmbus_release_relid(relid);
+   vmbus_release_relid(channel->offermsg.child_relid);
 
free_channel(channel);
 }
@@ -943,7 +936,7 @@ static void vmbus_onoffer_rescind(struct 
vmbus_channel_message_header *hdr)
 * The channel is currently not open;
 * it is safe for us to cleanup the channel.
 */
-   hv_process_channel_removal(rescind->child_relid);
+   hv_process_channel_removal(channel);
} else {
complete(&channel->rescind_event);
}
diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
index e6d8fdac6d8b..007ee8e5986a 100644
--- a/drivers/hv/vmbus_drv.c
+++ b/drivers/hv/vmbus_drv.c
@@ -864,10 +864,9 @@ static void vmbus_device_release(struct device *device)
struct vmbus_channel *channel = hv_dev->channel;
 
mutex_lock(&vmbus_connection.channel_mutex);
-   hv_process_channel_removal(channel->offermsg.child_relid);
+   hv_process_channel_removal(channel);
mutex_unlock(&vmbus_connection.channel_mutex);
kfree(hv_dev);
-
 }
 
 /* The one and only one */
diff --git a/include/linux/hyperv.h b/include/linux/hyperv.h
index 2c3798bcb01c..6c4575c7f46b 100644
--- a/include/linux/hyperv.h
+++ b/include/linux/hyperv.h
@@ -1443,7 +1443,7 @@ extern bool vmbus_prep_negotiate_resp(struct icmsg_hdr 
*icmsghdrp, u8 *buf,
const int *srv_version, int srv_vercnt,
int *nego_fw_version, int *nego_srv_version);
 
-void hv_process_channel_removal(u32 relid);
+void hv_process_channel_removal(struct vmbus_channel *channel);
 
 void vmbus_setevent(struct vmbus_channel *channel);
 /*
-- 
2.18.0

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


[PATCH 5/6] hv_uio_generic: map ringbuffer phys addr

2018-09-13 Thread Stephen Hemminger
The ring buffer is contiguous IOVA and is mapped via phys addr
for sysfs file. Use same method for the UIO mapping.

Signed-off-by: Stephen Hemminger 
---
 drivers/uio/uio_hv_generic.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/uio/uio_hv_generic.c b/drivers/uio/uio_hv_generic.c
index ba67a5267557..53f5610c6065 100644
--- a/drivers/uio/uio_hv_generic.c
+++ b/drivers/uio/uio_hv_generic.c
@@ -224,10 +224,10 @@ hv_uio_probe(struct hv_device *dev,
/* mem resources */
pdata->info.mem[TXRX_RING_MAP].name = "txrx_rings";
pdata->info.mem[TXRX_RING_MAP].addr
-   = (uintptr_t)page_address(dev->channel->ringbuffer_page);
+   = 
(uintptr_t)virt_to_phys(page_address(dev->channel->ringbuffer_page));
pdata->info.mem[TXRX_RING_MAP].size
= dev->channel->ringbuffer_pagecount << PAGE_SHIFT;
-   pdata->info.mem[TXRX_RING_MAP].memtype = UIO_MEM_LOGICAL;
+   pdata->info.mem[TXRX_RING_MAP].memtype = UIO_MEM_IOVA;
 
pdata->info.mem[INT_PAGE_MAP].name = "int_page";
pdata->info.mem[INT_PAGE_MAP].addr
-- 
2.18.0

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


[PATCH 4/6] uio: introduce UIO_MEM_IOVA

2018-09-13 Thread Stephen Hemminger
Introduce the concept of mapping physical memory locations that
are normal memory. The new type UIO_MEM_IOVA are similar to
existing UIO_MEM_PHYS but the backing memory is not marked as uncached.

Also, indent related switch to the currently used style.

Signed-off-by: Stephen Hemminger 
---
 drivers/uio/uio.c  | 24 +---
 include/linux/uio_driver.h |  1 +
 2 files changed, 14 insertions(+), 11 deletions(-)

diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c
index 0ffb324aa038..e601bd3fbae1 100644
--- a/drivers/uio/uio.c
+++ b/drivers/uio/uio.c
@@ -738,7 +738,8 @@ static int uio_mmap_physical(struct vm_area_struct *vma)
return -EINVAL;
 
vma->vm_ops = &uio_physical_vm_ops;
-   vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
+   if (idev->info->mem[mi].memtype == UIO_MEM_PHYS)
+   vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
 
/*
 * We cannot use the vm_iomap_memory() helper here,
@@ -795,18 +796,19 @@ static int uio_mmap(struct file *filep, struct 
vm_area_struct *vma)
}
 
switch (idev->info->mem[mi].memtype) {
-   case UIO_MEM_PHYS:
-   ret = uio_mmap_physical(vma);
-   break;
-   case UIO_MEM_LOGICAL:
-   case UIO_MEM_VIRTUAL:
-   ret = uio_mmap_logical(vma);
-   break;
-   default:
-   ret = -EINVAL;
+   case UIO_MEM_IOVA:
+   case UIO_MEM_PHYS:
+   ret = uio_mmap_physical(vma);
+   break;
+   case UIO_MEM_LOGICAL:
+   case UIO_MEM_VIRTUAL:
+   ret = uio_mmap_logical(vma);
+   break;
+   default:
+   ret = -EINVAL;
}
 
-out:
+ out:
mutex_unlock(&idev->info_lock);
return ret;
 }
diff --git a/include/linux/uio_driver.h b/include/linux/uio_driver.h
index 6f8b68cd460f..a3cd7cb67a69 100644
--- a/include/linux/uio_driver.h
+++ b/include/linux/uio_driver.h
@@ -133,6 +133,7 @@ extern void uio_event_notify(struct uio_info *info);
 #define UIO_MEM_PHYS   1
 #define UIO_MEM_LOGICAL2
 #define UIO_MEM_VIRTUAL 3
+#define UIO_MEM_IOVA   4
 
 /* defines for uio_port->porttype */
 #define UIO_PORT_NONE  0
-- 
2.18.0

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


[PATCH 6/6] uio_hv_generic: defer opening vmbus until first use

2018-09-13 Thread Stephen Hemminger
This fixes two design flaws in hv_uio_generic.

Since hv_uio_probe is called from vmbus_probe with lock held
it potentially can cause sleep in an atomic section because
vmbus_open will wait for response from host.

The hv_uio_generic driver could not handle applications
exiting and restarting because the vmbus channel was
persistent.  Change the semantics so that the buffers are
allocated on probe, but not attached to host until
device is opened.

Signed-off-by: Stephen Hemminger 
---
 drivers/uio/uio_hv_generic.c | 102 ---
 1 file changed, 72 insertions(+), 30 deletions(-)

diff --git a/drivers/uio/uio_hv_generic.c b/drivers/uio/uio_hv_generic.c
index 53f5610c6065..9bd837accdb5 100644
--- a/drivers/uio/uio_hv_generic.c
+++ b/drivers/uio/uio_hv_generic.c
@@ -55,6 +55,7 @@ enum hv_uio_map {
 struct hv_uio_private_data {
struct uio_info info;
struct hv_device *device;
+   atomic_t refcnt;
 
void*recv_buf;
u32 recv_gpadl;
@@ -128,12 +129,10 @@ static int hv_uio_ring_mmap(struct file *filp, struct 
kobject *kobj,
 {
struct vmbus_channel *channel
= container_of(kobj, struct vmbus_channel, kobj);
-   struct hv_device *dev = channel->primary_channel->device_obj;
-   u16 q_idx = channel->offermsg.offer.sub_channel_index;
void *ring_buffer = page_address(channel->ringbuffer_page);
 
-   dev_dbg(&dev->device, "mmap channel %u pages %#lx at %#lx\n",
-   q_idx, vma_pages(vma), vma->vm_pgoff);
+   if (channel->state != CHANNEL_OPENED_STATE)
+   return -ENODEV;
 
return vm_iomap_memory(vma, virt_to_phys(ring_buffer),
   channel->ringbuffer_pagecount << PAGE_SHIFT);
@@ -176,57 +175,101 @@ hv_uio_new_channel(struct vmbus_channel *new_sc)
}
 }
 
+/* free the reserved buffers for send and receive */
 static void
 hv_uio_cleanup(struct hv_device *dev, struct hv_uio_private_data *pdata)
 {
-   if (pdata->send_gpadl)
+   if (pdata->send_gpadl) {
vmbus_teardown_gpadl(dev->channel, pdata->send_gpadl);
-   vfree(pdata->send_buf);
+   pdata->send_gpadl = 0;
+   vfree(pdata->send_buf);
+   }
 
-   if (pdata->recv_gpadl)
+   if (pdata->recv_gpadl) {
vmbus_teardown_gpadl(dev->channel, pdata->recv_gpadl);
-   vfree(pdata->recv_buf);
+   pdata->recv_gpadl = 0;
+   vfree(pdata->recv_buf);
+   }
+}
+
+/* VMBus primary channel is opened on first use */
+static int
+hv_uio_open(struct uio_info *info, struct inode *inode)
+{
+   struct hv_uio_private_data *pdata
+   = container_of(info, struct hv_uio_private_data, info);
+   struct hv_device *dev = pdata->device;
+   int ret;
+
+   if (atomic_inc_return(&pdata->refcnt) != 1)
+   return 0;
+
+   ret = vmbus_connect_ring(dev->channel,
+hv_uio_channel_cb, dev->channel);
+
+   if (ret == 0)
+   dev->channel->inbound.ring_buffer->interrupt_mask = 1;
+
+   return ret;
+}
+
+/* VMBus primary channel is closed on last close */
+static int
+hv_uio_release(struct uio_info *info, struct inode *inode)
+{
+   struct hv_uio_private_data *pdata
+   = container_of(info, struct hv_uio_private_data, info);
+   struct hv_device *dev = pdata->device;
+   int ret = 0;
+
+   if (atomic_dec_and_test(&pdata->refcnt))
+   ret = vmbus_disconnect_ring(dev->channel);
+
+   return ret;
 }
 
 static int
 hv_uio_probe(struct hv_device *dev,
 const struct hv_vmbus_device_id *dev_id)
 {
+   struct vmbus_channel *channel = dev->channel;
struct hv_uio_private_data *pdata;
+   void *ring_buffer;
int ret;
 
+   /* Communicating with host has to be via shared memory not hypercall */
+   if (!channel->offermsg.monitor_allocated) {
+   dev_err(&dev->device, "vmbus channel requires hypercall\n");
+   return -ENOTSUPP;
+   }
+
pdata = kzalloc(sizeof(*pdata), GFP_KERNEL);
if (!pdata)
return -ENOMEM;
 
-   ret = vmbus_open(dev->channel, HV_RING_SIZE * PAGE_SIZE,
-HV_RING_SIZE * PAGE_SIZE, NULL, 0,
-hv_uio_channel_cb, dev->channel);
+   ret = vmbus_alloc_ring(channel, HV_RING_SIZE * PAGE_SIZE,
+  HV_RING_SIZE * PAGE_SIZE);
if (ret)
goto fail;
 
-   /* Communicating with host has to be via shared memory not hypercall */
-   if (!dev->channel->offermsg.monitor_allocated) {
-   dev_err(&dev->device, "vmbus channel requires hypercall\n");
-   ret = -ENOTSUPP;
-   goto fail_close;
-   }
-
-   dev->channel->inbound.ring_buffer->interrupt_mask = 1;
-   set_channel_read_mode(dev->channel, HV_CALL_ISR);
+   set_channel_read_mode(channel, HV_

[PATCH 0/6] fix Hyper-V uio restart

2018-09-13 Thread Stephen Hemminger
This set of patches fixes the problem where DPDK applications
using hv_uio_generic driver can not be successfully restarted.

In order to get this working it required small change to uio
to allow for mapping without no-cache. And refactoring of how
ring buffer is setup in vmbus code.

It could be backported as a fix, to 4.19 but that is not
an LTS so probably not worth it.

Stephen Hemminger (6):
  vmbus: pass channel to hv_process_channel_removal
  vmbus: keep pointer to ring buffer page
  vmbus: split ring buffer allocation from open
  uio: introduce UIO_MEM_IOVA
  hv_uio_generic: map ringbuffer phys addr
  uio_hv_generic: defer opening vmbus until first use

 drivers/hv/channel.c | 276 ---
 drivers/hv/channel_mgmt.c|  17 +--
 drivers/hv/ring_buffer.c |   1 +
 drivers/hv/vmbus_drv.c   |   3 +-
 drivers/uio/uio.c|  24 +--
 drivers/uio/uio_hv_generic.c | 107 ++
 include/linux/hyperv.h   |  13 +-
 include/linux/uio_driver.h   |   1 +
 8 files changed, 262 insertions(+), 180 deletions(-)

-- 
2.18.0

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


[PATCH 3/6] vmbus: split ring buffer allocation from open

2018-09-13 Thread Stephen Hemminger
The UIO driver needs the ring buffer to be persistent(reused)
across open/close. Split the allocation and setup of ring buffer
out of vmbus_open. For normal usage vmbus_open/vmbus_close there
are no changes; only impacts uio_hv_generic which needs to keep
ring buffer memory and reuse when application restarts.

Signed-off-by: Stephen Hemminger 
---
 drivers/hv/channel.c | 267 ++-
 drivers/hv/ring_buffer.c |   1 +
 include/linux/hyperv.h   |   9 ++
 3 files changed, 162 insertions(+), 115 deletions(-)

diff --git a/drivers/hv/channel.c b/drivers/hv/channel.c
index 56ec0d96d876..ddadb7efd1cc 100644
--- a/drivers/hv/channel.c
+++ b/drivers/hv/channel.c
@@ -79,84 +79,96 @@ void vmbus_setevent(struct vmbus_channel *channel)
 }
 EXPORT_SYMBOL_GPL(vmbus_setevent);
 
-/*
- * vmbus_open - Open the specified channel.
- */
-int vmbus_open(struct vmbus_channel *newchannel, u32 send_ringbuffer_size,
-u32 recv_ringbuffer_size, void *userdata, u32 userdatalen,
-void (*onchannelcallback)(void *context), void *context)
+/* vmbus_free_ring - drop mapping of ring buffer */
+void vmbus_free_ring(struct vmbus_channel *channel)
 {
-   struct vmbus_channel_open_channel *open_msg;
-   struct vmbus_channel_msginfo *open_info = NULL;
-   unsigned long flags;
-   int ret, err = 0;
-   struct page *page;
-   unsigned int order;
+   hv_ringbuffer_cleanup(&channel->outbound);
+   hv_ringbuffer_cleanup(&channel->inbound);
 
-   if (send_ringbuffer_size % PAGE_SIZE ||
-   recv_ringbuffer_size % PAGE_SIZE)
-   return -EINVAL;
+   if (channel->ringbuffer_page) {
+   __free_pages(channel->ringbuffer_page,
+get_order(channel->ringbuffer_pagecount
+  << PAGE_SHIFT));
+   channel->ringbuffer_page = NULL;
+   }
+}
+EXPORT_SYMBOL_GPL(vmbus_free_ring);
 
-   order = get_order(send_ringbuffer_size + recv_ringbuffer_size);
+/* vmbus_alloc_ring - allocate and map pages for ring buffer */
+int vmbus_alloc_ring(struct vmbus_channel *newchannel,
+u32 send_size, u32 recv_size)
+{
+   struct page *page;
+   int order;
 
-   spin_lock_irqsave(&newchannel->lock, flags);
-   if (newchannel->state == CHANNEL_OPEN_STATE) {
-   newchannel->state = CHANNEL_OPENING_STATE;
-   } else {
-   spin_unlock_irqrestore(&newchannel->lock, flags);
+   if (send_size % PAGE_SIZE || recv_size % PAGE_SIZE)
return -EINVAL;
-   }
-   spin_unlock_irqrestore(&newchannel->lock, flags);
-
-   newchannel->onchannel_callback = onchannelcallback;
-   newchannel->channel_callback_context = context;
 
/* Allocate the ring buffer */
+   order = get_order(send_size + recv_size);
page = alloc_pages_node(cpu_to_node(newchannel->target_cpu),
GFP_KERNEL|__GFP_ZERO, order);
 
if (!page)
page = alloc_pages(GFP_KERNEL|__GFP_ZERO, order);
 
-   if (!page) {
-   err = -ENOMEM;
-   goto error_set_chnstate;
-   }
+   if (!page)
+   return -ENOMEM;
 
newchannel->ringbuffer_page = page;
-   newchannel->ringbuffer_pagecount = (send_ringbuffer_size +
-  recv_ringbuffer_size) >> PAGE_SHIFT;
+   newchannel->ringbuffer_pagecount = (send_size + recv_size) >> 
PAGE_SHIFT;
+   newchannel->ringbuffer_send_offset = send_size >> PAGE_SHIFT;
 
-   ret = hv_ringbuffer_init(&newchannel->outbound, page,
-send_ringbuffer_size >> PAGE_SHIFT);
+   return 0;
+}
+EXPORT_SYMBOL_GPL(vmbus_alloc_ring);
 
-   if (ret != 0) {
-   err = ret;
-   goto error_free_pages;
-   }
+static int __vmbus_open(struct vmbus_channel *newchannel,
+  void *userdata, u32 userdatalen,
+  void (*onchannelcallback)(void *context), void *context)
+{
+   struct vmbus_channel_open_channel *open_msg;
+   struct vmbus_channel_msginfo *open_info = NULL;
+   struct page *page = newchannel->ringbuffer_page;
+   u32 send_pages, recv_pages;
+   unsigned long flags;
+   int err;
 
-   ret = hv_ringbuffer_init(&newchannel->inbound,
-&page[send_ringbuffer_size >> PAGE_SHIFT],
-recv_ringbuffer_size >> PAGE_SHIFT);
-   if (ret != 0) {
-   err = ret;
-   goto error_free_pages;
+   if (userdatalen > MAX_USER_DEFINED_BYTES)
+   return -EINVAL;
+
+   send_pages = newchannel->ringbuffer_send_offset;
+   recv_pages = newchannel->ringbuffer_pagecount - send_pages;
+
+   spin_lock_irqsave(&newchannel->lock, flags);
+   if (newchannel->state != CHANNEL_OPEN_STATE) {
+   spin_unlock_irqrest

Re: [PATCH v2] staging: Convert to using %pOFn instead of device_node.name

2018-09-13 Thread Joe Perches
On Wed, 2018-09-12 at 15:26 -0500, Rob Herring wrote:
> A problem with MAINTAINERS is there is no way to tell who applies
> patches for a given path vs. anyone else listed.

try the --scm option

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


Re: [PATCH] staging: rtl8188eu: remove code that is valid only for 5 GHz

2018-09-13 Thread Dan Carpenter
On Thu, Sep 13, 2018 at 10:32:39PM +0200, Robert Węcławski wrote:
> diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme.c 
> b/drivers/staging/rtl8188eu/core/rtw_mlme.c
> index eca06f05c0c4..b610443f2ac6 100644
> --- a/drivers/staging/rtl8188eu/core/rtw_mlme.c
> +++ b/drivers/staging/rtl8188eu/core/rtw_mlme.c
> @@ -1819,16 +1819,6 @@ void rtw_update_registrypriv_dev_network(struct 
> adapter *adapter)
>   case WIRELESS_11BG_24N:
>   pdev_network->NetworkTypeInUse = Ndis802_11OFDM24;
>   break;
> - case WIRELESS_11A:
> - case WIRELESS_11A_5N:
> - pdev_network->NetworkTypeInUse = Ndis802_11OFDM5;
> - break;
> - case WIRELESS_11ABGN:
> - if (pregistrypriv->channel > 14)
> - pdev_network->NetworkTypeInUse = Ndis802_11OFDM5;
> - else
> - pdev_network->NetworkTypeInUse = Ndis802_11OFDM24;
> - break;
>   default:
>   /*  TODO */
>   break;

Are you sure about this chunk?  I would have thought that <= 14 was not
5G.  (I try to avoid rhetorical questions and I don't know the answer
here).

regards,
dan carpenter

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


Re: [PATCH 6/6] uio_hv_generic: defer opening vmbus until first use

2018-09-13 Thread Dan Carpenter
On Thu, Sep 13, 2018 at 03:25:27PM -0700, Stephen Hemminger wrote:
> +/* VMBus primary channel is opened on first use */
> +static int
> +hv_uio_open(struct uio_info *info, struct inode *inode)
> +{
> + struct hv_uio_private_data *pdata
> + = container_of(info, struct hv_uio_private_data, info);
> + struct hv_device *dev = pdata->device;
> + int ret;
> +
> + if (atomic_inc_return(&pdata->refcnt) != 1)
> + return 0;
> +
> + ret = vmbus_connect_ring(dev->channel,
> +  hv_uio_channel_cb, dev->channel);
> +
> + if (ret == 0)
> + dev->channel->inbound.ring_buffer->interrupt_mask = 1;
> +
> + return ret;

I think we should decrement pdata->refcnt if vmbus_connect_ring() fails?

> +}

regards,
dan carpenter

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