Re: staging: ks7010: Replace three printk() calls by pr_err()
On Wed, Aug 10, 2016 at 09:41:37PM +0200, SF Markus Elfring wrote: > >> Please and and use pr_fmt > > > > Can't we use dev_* on the SDIO device? > > How should a connection be constructed from the data structure > "sdio_device_id" > to the corresponding device information for such an use case? What did you try so far? signature.asc Description: PGP signature ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH 0/2] Drivers: hv: vmbus: make bus ids in sysfs persistent
KY Srinivasan writes: >> -Original Message- >> From: Vitaly Kuznetsov [mailto:vkuzn...@redhat.com] >> Sent: Tuesday, August 9, 2016 1:46 AM >> To: de...@linuxdriverproject.org >> Cc: linux-ker...@vger.kernel.org; Haiyang Zhang ; >> KY Srinivasan >> Subject: [PATCH 0/2] Drivers: hv: vmbus: make bus ids in sysfs persistent >> >> Bus ids for VMBus devices in /sys/bus/vmbus/devices/ are not guaranteed >> to be persistent across reboot or kernel restart and this causes problems >> for some tools. E.g. kexec tools use these ids to identify NIC on kdump. >> Fix the issue by using relid from channel offer as the unique id instead >> of an auto incremented counter. > > Relids are not persistent. It is only valid between a channel offer > message and a relid released message (or an unload or initiate contact > message, which invalidates all channels). This is an opaque number > that the root generates and uses to track channels. There is no > guarantee that the same type of channel (networking, storage, etc) > will get the same relid on each reboot. > Thanks for the info, can we use device_id (offermsg.offer.if_instance.b) instead? -- Vitaly ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH 3/4] Drivers: hv: balloon: get rid on ol_waitevent
"Alex Ng (LIS)" writes: >> -Original Message- >> From: Vitaly Kuznetsov [mailto:vkuzn...@redhat.com] >> Sent: Friday, August 5, 2016 3:49 AM >> To: de...@linuxdriverproject.org >> Cc: linux-ker...@vger.kernel.org; Haiyang Zhang ; KY >> Srinivasan ; Alex Ng (LIS) >> Subject: [PATCH 3/4] Drivers: hv: balloon: get rid on ol_waitevent >> >> With the recently introduced in-kernel memory onlining >> (MEMORY_HOTPLUG_DEFAULT_ONLINE) these it no point in waiting for pages >> to come online in the driver and in case the feature is disabled the 5 >> second wait won't help. Get rid of the waiting. >> > > Continuing our internal discussion here. Here's the context. > >> > Is it necessary to remove the ol_waitevent in "Drivers: hv: balloon: get >> > rid >> > on ol_waitevent"? If we respond to the host too quickly, then the next >> > hot-add request may not see the new pages come online and could fail to >> > alloc memory as seen in the call trace. >> > >> > Thoughts? >> >> This should not be an issue with CONFIG_MEMORY_HOTPLUG_DEFAULT_ONLINE: we >> online pages when we add them (add_memory()) so when we reply to the host >> these pages are already online. But in case the onlining is done by an >> external tool (e.g. udev) this wait helps (not always, as if someone eats >> all memory before the next add_memory call we're still in trouble). > > MEMORY_HOTPLUG_DEFAULT_ONLINE is disabled in Kconfig by default. > Would it make sense to keep the wait and only #ifdef it out when > CONFIG_MEMORY_HOTPLUG_DEFAULT_ONLINE is set? I have a better idea. We can check 'memhp_auto_online' value to see the current status and don't wait if it is 'true'. Will do v2. -- Vitaly ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH v2 0/6] de-stage SW_SYNC validation frawework
On Mon, Aug 08, 2016 at 06:24:16PM -0300, Gustavo Padovan wrote: > From: Gustavo Padovan > > Hi Greg, > > This is the last step in the Sync Framwork de-stage task. It de-stage > the SW_SYNC validation framework and the sync_debug info debugfs file. > > The first 2 patches are clean up and improvements and the rest is preparation > to de-stage and then finally the actual de-stage. > > v2: > - add documentation about the SW_SYNC ioctl API (comments from Pavel Machek) > - remove for now patch to add sync_pt name to debugfs > > Please review, > > Gustavo > > --- > Gustavo Padovan (6): > staging/android: remove doc from sw_sync > staging/android: do not let userspace trigger WARN_ON > staging/android: move trace/sync.h to sync_trace.h > staging/android: prepare sw_sync files for de-staging > staging/android: add Doc for SW_SYNC ioctl interface > dma-buf/sw_sync: de-stage SW_SYNC > > drivers/dma-buf/Kconfig | 13 ++ > drivers/dma-buf/Makefile | 1 + > drivers/dma-buf/sw_sync.c| 349 > +++ > drivers/dma-buf/sync_debug.c | 230 +++ > drivers/dma-buf/sync_debug.h | 69 +++ > drivers/dma-buf/sync_trace.h | 32 > drivers/staging/android/Kconfig | 13 -- > drivers/staging/android/Makefile | 1 - > drivers/staging/android/sw_sync.c| 344 -- > drivers/staging/android/sync_debug.c | 230 --- > drivers/staging/android/sync_debug.h | 84 - > drivers/staging/android/trace/sync.h | 32 > 12 files changed, 694 insertions(+), 704 deletions(-) > create mode 100644 drivers/dma-buf/sw_sync.c > create mode 100644 drivers/dma-buf/sync_debug.c > create mode 100644 drivers/dma-buf/sync_debug.h > create mode 100644 drivers/dma-buf/sync_trace.h > delete mode 100644 drivers/staging/android/sw_sync.c > delete mode 100644 drivers/staging/android/sync_debug.c > delete mode 100644 drivers/staging/android/sync_debug.h > delete mode 100644 drivers/staging/android/trace/sync.h When you send your next revision, could you use `git format-patch -M`? A good 95% of the lines in these patches aren't actually modified, just moved around, which makes it much harder to spot the actual changes :) Cheers, Eric > > -- > 2.5.5 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH v2 3/6] staging/android: move trace/sync.h to sync_trace.h
On Mon, Aug 08, 2016 at 06:24:19PM -0300, Gustavo Padovan wrote: > From: Gustavo Padovan > > The common behaviour for trace headers is to have them in the same folder > they are used, instead of creating a special trace/ directory. > > Signed-off-by: Gustavo Padovan Reviewed-by: Eric Engestrom > --- > drivers/staging/android/sw_sync.c| 2 +- > drivers/staging/android/sync_trace.h | 32 > drivers/staging/android/trace/sync.h | 32 > 3 files changed, 33 insertions(+), 33 deletions(-) > create mode 100644 drivers/staging/android/sync_trace.h > delete mode 100644 drivers/staging/android/trace/sync.h > > diff --git a/drivers/staging/android/sw_sync.c > b/drivers/staging/android/sw_sync.c > index ad0bb1a..745597b 100644 > --- a/drivers/staging/android/sw_sync.c > +++ b/drivers/staging/android/sw_sync.c > @@ -23,7 +23,7 @@ > #include "sync_debug.h" > > #define CREATE_TRACE_POINTS > -#include "trace/sync.h" > +#include "sync_trace.h" > > struct sw_sync_create_fence_data { > __u32 value; > diff --git a/drivers/staging/android/sync_trace.h > b/drivers/staging/android/sync_trace.h > new file mode 100644 > index 000..ea485f7 > --- /dev/null > +++ b/drivers/staging/android/sync_trace.h > @@ -0,0 +1,32 @@ > +#undef TRACE_SYSTEM > +#define TRACE_INCLUDE_PATH ../../drivers/staging/android > +#define TRACE_SYSTEM sync_trace > + > +#if !defined(_TRACE_SYNC_H) || defined(TRACE_HEADER_MULTI_READ) > +#define _TRACE_SYNC_H > + > +#include "sync_debug.h" > +#include > + > +TRACE_EVENT(sync_timeline, > + TP_PROTO(struct sync_timeline *timeline), > + > + TP_ARGS(timeline), > + > + TP_STRUCT__entry( > + __string(name, timeline->name) > + __field(u32, value) > + ), > + > + TP_fast_assign( > + __assign_str(name, timeline->name); > + __entry->value = timeline->value; > + ), > + > + TP_printk("name=%s value=%d", __get_str(name), __entry->value) > +); > + > +#endif /* if !defined(_TRACE_SYNC_H) || defined(TRACE_HEADER_MULTI_READ) */ > + > +/* This part must be outside protection */ > +#include > diff --git a/drivers/staging/android/trace/sync.h > b/drivers/staging/android/trace/sync.h > deleted file mode 100644 > index 6b5ce96..000 > --- a/drivers/staging/android/trace/sync.h > +++ /dev/null > @@ -1,32 +0,0 @@ > -#undef TRACE_SYSTEM > -#define TRACE_INCLUDE_PATH ../../drivers/staging/android/trace > -#define TRACE_SYSTEM sync > - > -#if !defined(_TRACE_SYNC_H) || defined(TRACE_HEADER_MULTI_READ) > -#define _TRACE_SYNC_H > - > -#include "../sync_debug.h" > -#include > - > -TRACE_EVENT(sync_timeline, > - TP_PROTO(struct sync_timeline *timeline), > - > - TP_ARGS(timeline), > - > - TP_STRUCT__entry( > - __string(name, timeline->name) > - __field(u32, value) > - ), > - > - TP_fast_assign( > - __assign_str(name, timeline->name); > - __entry->value = timeline->value; > - ), > - > - TP_printk("name=%s value=%d", __get_str(name), __entry->value) > -); > - > -#endif /* if !defined(_TRACE_SYNC_H) || defined(TRACE_HEADER_MULTI_READ) */ > - > -/* This part must be outside protection */ > -#include > -- > 2.5.5 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH v2 4/6] staging/android: prepare sw_sync files for de-staging
On Mon, Aug 08, 2016 at 06:24:20PM -0300, Gustavo Padovan wrote: > From: Gustavo Padovan > > remove file paths in the comments and add short description about each > file. > > v2: remove file paths instead of just change them. > > Signed-off-by: Gustavo Padovan > --- > drivers/staging/android/sw_sync.c| 2 +- > drivers/staging/android/sync_debug.c | 2 +- > drivers/staging/android/sync_debug.h | 2 +- > 3 files changed, 3 insertions(+), 3 deletions(-) > > diff --git a/drivers/staging/android/sw_sync.c > b/drivers/staging/android/sw_sync.c > index 745597b..43491b6 100644 > --- a/drivers/staging/android/sw_sync.c > +++ b/drivers/staging/android/sw_sync.c > @@ -1,5 +1,5 @@ > /* > - * drivers/dma-buf/sw_sync.c > + * Sync File validation framework > * > * Copyright (C) 2012 Google, Inc. > * > diff --git a/drivers/staging/android/sync_debug.c > b/drivers/staging/android/sync_debug.c > index 4c5a855..fab9520 100644 > --- a/drivers/staging/android/sync_debug.c > +++ b/drivers/staging/android/sync_debug.c > @@ -1,5 +1,5 @@ > /* > - * drivers/base/sync.c > + * Sync File validation framework and debug information > * > * Copyright (C) 2012 Google, Inc. > * > diff --git a/drivers/staging/android/sync_debug.h > b/drivers/staging/android/sync_debug.h > index 5b82cf8..ee3c27b 100644 > --- a/drivers/staging/android/sync_debug.h > +++ b/drivers/staging/android/sync_debug.h > @@ -1,5 +1,5 @@ > /* > - * include/linux/sync.h > + * Sync File validation framework "and debug information" With that added, Reviewed-by: Eric Engestrom > * > * Copyright (C) 2012 Google, Inc. > * > -- > 2.5.5 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH v2 5/6] staging/android: add Doc for SW_SYNC ioctl interface
On Mon, Aug 08, 2016 at 06:24:21PM -0300, Gustavo Padovan wrote: > From: Gustavo Padovan > > This interface is hidden from kernel headers and it is intended for use > only for testing. So testers would have to add the ioctl information > internally. This is to prevent misuse of this feature. > > Signed-off-by: Gustavo Padovan > --- > drivers/staging/android/sw_sync.c | 31 +++ > 1 file changed, 31 insertions(+) > > diff --git a/drivers/staging/android/sw_sync.c > b/drivers/staging/android/sw_sync.c > index 43491b6..2ac5608 100644 > --- a/drivers/staging/android/sw_sync.c > +++ b/drivers/staging/android/sw_sync.c > @@ -25,6 +25,36 @@ > #define CREATE_TRACE_POINTS > #include "sync_trace.h" > > +/* > + * SW SYNC validation framework > + * > + * A sync object driver that uses a 32bit counter to coordinate > + * synchronization. Useful when there is no hardware primitive backing > + * the synchronization. > + * > + * To start the framework just open: > + * > + * /sync/sw_sync > + * > + * That will create a sync timeline, all fences created under this timeline > + * file descriptor will belong to the this timeline. > + * > + * The 'sw_sync' file can be opened many times as to create different > + * timelines. > + * > + * Fences can be created with SW_SYNC_IOC_CREATE_FENCE ioctl with struct > + * sw_sync_ioctl_create_fence as parameter. > + * > + * To increment the timeline counter SW_SYNC_IOC_INC ioctl should be used > + * with the increment as u32. This will update the last signaled value > + * from the timeline and signal any fence that has seqno, smaller of equal > + * it. This last paragraph could use some love: comma before "SW_SYNC_IOC_INC", "that has seqno smaller or equal to it." > + * > + * struct sw_sync_ioctl_create_fence > + * @value: the seqno to initiate the fence with s/initiate/initialise/ With these fixed, Reviewed-by: Eric Engestrom > + * @name:the name of the new sync point > + * @fence: return the fd of the new sync_file with the created fence > + */ > struct sw_sync_create_fence_data { > __u32 value; > charname[32]; > @@ -35,6 +65,7 @@ struct sw_sync_create_fence_data { > > #define SW_SYNC_IOC_CREATE_FENCE _IOWR(SW_SYNC_IOC_MAGIC, 0,\ > struct sw_sync_create_fence_data) > + > #define SW_SYNC_IOC_INC _IOW(SW_SYNC_IOC_MAGIC, 1, > __u32) > > static const struct fence_ops timeline_fence_ops; > -- > 2.5.5 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH v2 6/6] dma-buf/sw_sync: de-stage SW_SYNC
On Mon, Aug 08, 2016 at 06:24:22PM -0300, Gustavo Padovan wrote: > From: Gustavo Padovan > > SW_SYNC allows to run tests on the sync_file framework via debugfs on > > /sync/sw_sync > > Opening and closing the file triggers creation and release of a sync > timeline. To create fences on this timeline the SW_SYNC_IOC_CREATE_FENCE > ioctl should be used. To increment the timeline value use SW_SYNC_IOC_INC. > > Also it exports Sync information on > > /sync/info > > Signed-off-by: Gustavo Padovan Reviewed-by: Eric Engestrom > --- > drivers/dma-buf/Kconfig | 13 ++ > drivers/dma-buf/Makefile | 1 + > drivers/dma-buf/sw_sync.c| 349 > +++ > drivers/dma-buf/sync_debug.c | 230 +++ > drivers/dma-buf/sync_debug.h | 69 +++ > drivers/dma-buf/sync_trace.h | 32 > drivers/staging/android/Kconfig | 13 -- > drivers/staging/android/Makefile | 1 - > drivers/staging/android/sw_sync.c| 349 > --- > drivers/staging/android/sync_debug.c | 230 --- > drivers/staging/android/sync_debug.h | 69 --- > drivers/staging/android/sync_trace.h | 32 > 12 files changed, 694 insertions(+), 694 deletions(-) > create mode 100644 drivers/dma-buf/sw_sync.c > create mode 100644 drivers/dma-buf/sync_debug.c > create mode 100644 drivers/dma-buf/sync_debug.h > create mode 100644 drivers/dma-buf/sync_trace.h > delete mode 100644 drivers/staging/android/sw_sync.c > delete mode 100644 drivers/staging/android/sync_debug.c > delete mode 100644 drivers/staging/android/sync_debug.h > delete mode 100644 drivers/staging/android/sync_trace.h > [snip] ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH net 1/4] hv_netvsc: don't lose VF information
struct netvsc_device is not suitable for storing VF information as this structure is being destroyed on MTU change / set channel operation (see rndis_filter_device_remove()). Move all VF related stuff to struct net_device_context which is persistent. Signed-off-by: Vitaly Kuznetsov --- drivers/net/hyperv/hyperv_net.h | 19 drivers/net/hyperv/netvsc.c | 19 +++- drivers/net/hyperv/netvsc_drv.c | 49 +++-- 3 files changed, 45 insertions(+), 42 deletions(-) diff --git a/drivers/net/hyperv/hyperv_net.h b/drivers/net/hyperv/hyperv_net.h index 467fb8b..3b3ecf2 100644 --- a/drivers/net/hyperv/hyperv_net.h +++ b/drivers/net/hyperv/hyperv_net.h @@ -647,7 +647,7 @@ struct netvsc_reconfig { struct garp_wrk { struct work_struct dwrk; struct net_device *netdev; - struct netvsc_device *netvsc_dev; + struct net_device_context *net_device_ctx; }; /* The context of the netvsc device */ @@ -678,6 +678,15 @@ struct net_device_context { /* the device is going away */ bool start_remove; + + /* State to manage the associated VF interface. */ + struct net_device *vf_netdev; + bool vf_inject; + atomic_t vf_use_cnt; + /* 1: allocated, serial number is valid. 0: not allocated */ + u32 vf_alloc; + /* Serial number of the VF to team with */ + u32 vf_serial; }; /* Per netvsc device */ @@ -733,15 +742,7 @@ struct netvsc_device { u32 max_pkt; /* max number of pkt in one send, e.g. 8 */ u32 pkt_align; /* alignment bytes, e.g. 8 */ - /* 1: allocated, serial number is valid. 0: not allocated */ - u32 vf_alloc; - /* Serial number of the VF to team with */ - u32 vf_serial; atomic_t open_cnt; - /* State to manage the associated VF interface. */ - bool vf_inject; - struct net_device *vf_netdev; - atomic_t vf_use_cnt; }; static inline struct netvsc_device * diff --git a/drivers/net/hyperv/netvsc.c b/drivers/net/hyperv/netvsc.c index 20e0917..410fb8e8 100644 --- a/drivers/net/hyperv/netvsc.c +++ b/drivers/net/hyperv/netvsc.c @@ -77,13 +77,9 @@ static struct netvsc_device *alloc_net_device(void) init_waitqueue_head(&net_device->wait_drain); net_device->destroy = false; atomic_set(&net_device->open_cnt, 0); - atomic_set(&net_device->vf_use_cnt, 0); net_device->max_pkt = RNDIS_MAX_PKT_DEFAULT; net_device->pkt_align = RNDIS_PKT_ALIGN_DEFAULT; - net_device->vf_netdev = NULL; - net_device->vf_inject = false; - return net_device; } @@ -1106,16 +1102,16 @@ static void netvsc_send_table(struct hv_device *hdev, nvscdev->send_table[i] = tab[i]; } -static void netvsc_send_vf(struct netvsc_device *nvdev, +static void netvsc_send_vf(struct net_device_context *net_device_ctx, struct nvsp_message *nvmsg) { - nvdev->vf_alloc = nvmsg->msg.v4_msg.vf_assoc.allocated; - nvdev->vf_serial = nvmsg->msg.v4_msg.vf_assoc.serial; + net_device_ctx->vf_alloc = nvmsg->msg.v4_msg.vf_assoc.allocated; + net_device_ctx->vf_serial = nvmsg->msg.v4_msg.vf_assoc.serial; } static inline void netvsc_receive_inband(struct hv_device *hdev, -struct netvsc_device *nvdev, -struct nvsp_message *nvmsg) +struct net_device_context *net_device_ctx, +struct nvsp_message *nvmsg) { switch (nvmsg->hdr.msg_type) { case NVSP_MSG5_TYPE_SEND_INDIRECTION_TABLE: @@ -1123,7 +1119,7 @@ static inline void netvsc_receive_inband(struct hv_device *hdev, break; case NVSP_MSG4_TYPE_SEND_VF_ASSOCIATION: - netvsc_send_vf(nvdev, nvmsg); + netvsc_send_vf(net_device_ctx, nvmsg); break; } } @@ -1136,6 +1132,7 @@ static void netvsc_process_raw_pkt(struct hv_device *device, struct vmpacket_descriptor *desc) { struct nvsp_message *nvmsg; + struct net_device_context *net_device_ctx = netdev_priv(ndev); nvmsg = (struct nvsp_message *)((unsigned long) desc + (desc->offset8 << 3)); @@ -1150,7 +1147,7 @@ static void netvsc_process_raw_pkt(struct hv_device *device, break; case VM_PKT_DATA_INBAND: - netvsc_receive_inband(device, net_device, nvmsg); + netvsc_receive_inband(device, net_device_ctx, nvmsg); break; default: diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c index 41bd952..794139b 100644 --- a/drivers/net/hyperv/netvsc_drv.c +++ b/drivers/net/hyperv/netvsc_drv.c @@ -658,20 +658,19 @@ int netvsc_recv_callback(struct hv_device *device_obj, struct sk_buff *skb; struct sk_buff *vf_skb;
[PATCH net 0/4] hv_netvsc: fixes for VF removal path
Kernel crash is reported after VF is removed and detached from netvsc device. My investigation led me to PATCH2 of this series but PATCH1 is required to support the change. I also noticed a couple of other issues while debugging and I fix them with PATCH3 and PATCH4. Please review. Vitaly Kuznetsov (4): hv_netvsc: don't lose VF information hv_netvsc: reset vf_inject on VF removal hv_netvsc: protect module refcount by checking net_device_ctx->vf_netdev hv_netvsc: avoid deadlocks between rtnl lock and netvsc_inject_disable() drivers/net/hyperv/hyperv_net.h | 24 --- drivers/net/hyperv/netvsc.c | 19 drivers/net/hyperv/netvsc_drv.c | 96 ++--- 3 files changed, 59 insertions(+), 80 deletions(-) -- 2.7.4 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH net 3/4] hv_netvsc: protect module refcount by checking net_device_ctx->vf_netdev
We're not guaranteed to see NETDEV_REGISTER/NETDEV_UNREGISTER notifications only once per VF but we increase/decrease module refcount unconditionally. Check vf_netdev to make sure we don't take/release it twice. We presume that only one VF per netvsc device may exist. Signed-off-by: Vitaly Kuznetsov --- drivers/net/hyperv/netvsc_drv.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c index b3c31e3..874829a 100644 --- a/drivers/net/hyperv/netvsc_drv.c +++ b/drivers/net/hyperv/netvsc_drv.c @@ -1204,7 +1204,7 @@ static int netvsc_register_vf(struct net_device *vf_netdev) net_device_ctx = netdev_priv(ndev); netvsc_dev = net_device_ctx->nvdev; - if (netvsc_dev == NULL) + if (!netvsc_dev || net_device_ctx->vf_netdev) return NOTIFY_DONE; netdev_info(ndev, "VF registering: %s\n", vf_netdev->name); @@ -1334,7 +1334,7 @@ static int netvsc_unregister_vf(struct net_device *vf_netdev) net_device_ctx = netdev_priv(ndev); netvsc_dev = net_device_ctx->nvdev; - if (netvsc_dev == NULL) + if (!netvsc_dev || !net_device_ctx->vf_netdev) return NOTIFY_DONE; netdev_info(ndev, "VF unregistering: %s\n", vf_netdev->name); netvsc_inject_disable(net_device_ctx); -- 2.7.4 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH net 2/4] hv_netvsc: reset vf_inject on VF removal
We reset vf_inject on VF going down (netvsc_vf_down()) but we don't on VF removal (netvsc_unregister_vf()) so vf_inject stays 'true' while vf_netdev is already NULL and we're trying to inject packets into NULL net device in netvsc_recv_callback() causing kernel to crash. Signed-off-by: Vitaly Kuznetsov --- drivers/net/hyperv/netvsc_drv.c | 26 -- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c index 794139b..b3c31e3 100644 --- a/drivers/net/hyperv/netvsc_drv.c +++ b/drivers/net/hyperv/netvsc_drv.c @@ -1216,6 +1216,19 @@ static int netvsc_register_vf(struct net_device *vf_netdev) return NOTIFY_OK; } +static void netvsc_inject_enable(struct net_device_context *net_device_ctx) +{ + net_device_ctx->vf_inject = true; +} + +static void netvsc_inject_disable(struct net_device_context *net_device_ctx) +{ + net_device_ctx->vf_inject = false; + + /* Wait for currently active users to drain out. */ + while (atomic_read(&net_device_ctx->vf_use_cnt) != 0) + udelay(50); +} static int netvsc_vf_up(struct net_device *vf_netdev) { @@ -1238,7 +1251,7 @@ static int netvsc_vf_up(struct net_device *vf_netdev) return NOTIFY_DONE; netdev_info(ndev, "VF up: %s\n", vf_netdev->name); - net_device_ctx->vf_inject = true; + netvsc_inject_enable(net_device_ctx); /* * Open the device before switching data path. @@ -1288,14 +1301,7 @@ static int netvsc_vf_down(struct net_device *vf_netdev) return NOTIFY_DONE; netdev_info(ndev, "VF down: %s\n", vf_netdev->name); - net_device_ctx->vf_inject = false; - /* -* Wait for currently active users to -* drain out. -*/ - - while (atomic_read(&net_device_ctx->vf_use_cnt) != 0) - udelay(50); + netvsc_inject_disable(net_device_ctx); netvsc_switch_datapath(ndev, false); netdev_info(ndev, "Data path switched from VF: %s\n", vf_netdev->name); rndis_filter_close(netvsc_dev); @@ -1331,7 +1337,7 @@ static int netvsc_unregister_vf(struct net_device *vf_netdev) if (netvsc_dev == NULL) return NOTIFY_DONE; netdev_info(ndev, "VF unregistering: %s\n", vf_netdev->name); - + netvsc_inject_disable(net_device_ctx); net_device_ctx->vf_netdev = NULL; module_put(THIS_MODULE); return NOTIFY_OK; -- 2.7.4 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH net 4/4] hv_netvsc: avoid deadlocks between rtnl lock and netvsc_inject_disable()
Here is a deadlock scenario: - netvsc_vf_up() schedules netvsc_notify_peers() work and quits. - netvsc_vf_down() runs before netvsc_notify_peers() gets executed. As it is being executed from netdev notifier chain we hold rtnl lock when we get here. - we enter netvsc_inject_disable() and loop and wait till netvsc_notify_peers() drops vf_use_cnt. - netvsc_notify_peers() starts on some other CPU but netdev_notify_peers() will hang on rtnl_lock(). - deadlock! Similar deadlocks are possible between netvsc_vf_{up,down}() and netvsc_unregister_vf() as it also waits till vf_use_cnt drops to zero. Instead of introducing additional synchronization I suggest we drop gwrk.dwrk completely and call NETDEV_NOTIFY_PEERS directly. As we're acting under rtnl lock this is legitimate. Signed-off-by: Vitaly Kuznetsov --- drivers/net/hyperv/hyperv_net.h | 7 --- drivers/net/hyperv/netvsc_drv.c | 33 + 2 files changed, 5 insertions(+), 35 deletions(-) diff --git a/drivers/net/hyperv/hyperv_net.h b/drivers/net/hyperv/hyperv_net.h index 3b3ecf2..591af71 100644 --- a/drivers/net/hyperv/hyperv_net.h +++ b/drivers/net/hyperv/hyperv_net.h @@ -644,12 +644,6 @@ struct netvsc_reconfig { u32 event; }; -struct garp_wrk { - struct work_struct dwrk; - struct net_device *netdev; - struct net_device_context *net_device_ctx; -}; - /* The context of the netvsc device */ struct net_device_context { /* point back to our device context */ @@ -667,7 +661,6 @@ struct net_device_context { struct work_struct work; u32 msg_enable; /* debug level */ - struct garp_wrk gwrk; struct netvsc_stats __percpu *tx_stats; struct netvsc_stats __percpu *rx_stats; diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c index 874829a..62a4e6e 100644 --- a/drivers/net/hyperv/netvsc_drv.c +++ b/drivers/net/hyperv/netvsc_drv.c @@ -1151,17 +1151,6 @@ static void netvsc_free_netdev(struct net_device *netdev) free_netdev(netdev); } -static void netvsc_notify_peers(struct work_struct *wrk) -{ - struct garp_wrk *gwrk; - - gwrk = container_of(wrk, struct garp_wrk, dwrk); - - netdev_notify_peers(gwrk->netdev); - - atomic_dec(&gwrk->net_device_ctx->vf_use_cnt); -} - static struct net_device *get_netvsc_net_device(char *mac) { struct net_device *dev, *found = NULL; @@ -1266,15 +1255,8 @@ static int netvsc_vf_up(struct net_device *vf_netdev) netif_carrier_off(ndev); - /* -* Now notify peers. We are scheduling work to -* notify peers; take a reference to prevent -* the VF interface from vanishing. -*/ - atomic_inc(&net_device_ctx->vf_use_cnt); - net_device_ctx->gwrk.netdev = vf_netdev; - net_device_ctx->gwrk.net_device_ctx = net_device_ctx; - schedule_work(&net_device_ctx->gwrk.dwrk); + /* Now notify peers through VF device. */ + call_netdevice_notifiers(NETDEV_NOTIFY_PEERS, vf_netdev); return NOTIFY_OK; } @@ -1306,13 +1288,9 @@ static int netvsc_vf_down(struct net_device *vf_netdev) netdev_info(ndev, "Data path switched from VF: %s\n", vf_netdev->name); rndis_filter_close(netvsc_dev); netif_carrier_on(ndev); - /* -* Notify peers. -*/ - atomic_inc(&net_device_ctx->vf_use_cnt); - net_device_ctx->gwrk.netdev = ndev; - net_device_ctx->gwrk.net_device_ctx = net_device_ctx; - schedule_work(&net_device_ctx->gwrk.dwrk); + + /* Now notify peers through netvsc device. */ + call_netdevice_notifiers(NETDEV_NOTIFY_PEERS, ndev); return NOTIFY_OK; } @@ -1384,7 +1362,6 @@ static int netvsc_probe(struct hv_device *dev, INIT_DELAYED_WORK(&net_device_ctx->dwork, netvsc_link_change); INIT_WORK(&net_device_ctx->work, do_set_multicast); - INIT_WORK(&net_device_ctx->gwrk.dwrk, netvsc_notify_peers); spin_lock_init(&net_device_ctx->lock); INIT_LIST_HEAD(&net_device_ctx->reconfig_events); -- 2.7.4 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH net 2/4] hv_netvsc: reset vf_inject on VF removal
Yuval Mintz writes: >> +static void netvsc_inject_enable(struct net_device_context >> +*net_device_ctx) { >> +net_device_ctx->vf_inject = true; >> +} >> + >> +static void netvsc_inject_disable(struct net_device_context >> +*net_device_ctx) { >> +net_device_ctx->vf_inject = false; >> + >> +/* Wait for currently active users to drain out. */ >> +while (atomic_read(&net_device_ctx->vf_use_cnt) != 0) >> +udelay(50); >> +} > > That was already the behavior before, but are you certain you > want to unconditionally block without any possible timeout? Yes, this is OK. After PATCH4 of this series there is only one place which takes the vf_use_cnt (netvsc_recv_callback()) and it is an interrupt handler, there are no sleepable operations there. -- Vitaly ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v2 0/4] Drivers: hv: balloon: fix WS2012 memory hotplug issues and do some cleanup
Changes since v1: - Keep ol_waitevent and wait when kernel memory onlining is disabled [Alex Ng] Crashes with Hyper-V balloon driver are reported with WS2012 (non-R2), hosts I was able to identify two issues which I fix with first two patches of this series. Patches 3 removes wait on ol_waitevent when we have in in-kernel memory onlining, patch 4 gets rid of ha_region_mutex by doing the locking fine-grained with a spinlock. Vitaly Kuznetsov (4): Drivers: hv: balloon: keep track of where ha_region starts Drivers: hv: balloon: account for gaps in hot add regions Drivers: hv: balloon: don't wait for ol_waitevent when memhp_auto_online is enabled Drivers: hv: balloon: replace ha_region_mutex with spinlock drivers/hv/hv_balloon.c | 216 1 file changed, 144 insertions(+), 72 deletions(-) -- 2.7.4 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v2 1/4] Drivers: hv: balloon: keep track of where ha_region starts
Windows 2012 (non-R2) does not specify hot add region in hot add requests and the logic in hot_add_req() is trying to find a 128Mb-aligned region covering the request. It may also happen that host's requests are not 128Mb aligned and the created ha_region will start before the first specified PFN. We can't online these non-present pages but we don't remember the real start of the region. This is a regression introduced by the commit 5a75d733 ("Drivers: hv: hv_balloon: don't lose memory when onlining order is not natural"). While the idea of keeping the 'moving window' was wrong (as there is no guarantee that hot add requests come ordered) we should still keep track of covered_start_pfn. This is not a revert, the logic is different. Signed-off-by: Vitaly Kuznetsov --- drivers/hv/hv_balloon.c | 7 +-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/hv/hv_balloon.c b/drivers/hv/hv_balloon.c index df35fb7..4ae26d6 100644 --- a/drivers/hv/hv_balloon.c +++ b/drivers/hv/hv_balloon.c @@ -430,13 +430,14 @@ struct dm_info_msg { * currently hot added. We hot add in multiples of 128M * chunks; it is possible that we may not be able to bring * online all the pages in the region. The range - * covered_end_pfn defines the pages that can + * covered_start_pfn:covered_end_pfn defines the pages that can * be brough online. */ struct hv_hotadd_state { struct list_head list; unsigned long start_pfn; + unsigned long covered_start_pfn; unsigned long covered_end_pfn; unsigned long ha_end_pfn; unsigned long end_pfn; @@ -682,7 +683,8 @@ static void hv_online_page(struct page *pg) list_for_each(cur, &dm_device.ha_region_list) { has = list_entry(cur, struct hv_hotadd_state, list); - cur_start_pgp = (unsigned long)pfn_to_page(has->start_pfn); + cur_start_pgp = (unsigned long) + pfn_to_page(has->covered_start_pfn); cur_end_pgp = (unsigned long)pfn_to_page(has->covered_end_pfn); if (((unsigned long)pg >= cur_start_pgp) && @@ -854,6 +856,7 @@ static unsigned long process_hot_add(unsigned long pg_start, list_add_tail(&ha_region->list, &dm_device.ha_region_list); ha_region->start_pfn = rg_start; ha_region->ha_end_pfn = rg_start; + ha_region->covered_start_pfn = pg_start; ha_region->covered_end_pfn = pg_start; ha_region->end_pfn = rg_start + rg_size; } -- 2.7.4 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v2 3/4] Drivers: hv: balloon: don't wait for ol_waitevent when memhp_auto_online is enabled
With the recently introduced in-kernel memory onlining (MEMORY_HOTPLUG_DEFAULT_ONLINE) these is no point in waiting for pages to come online in the driver and we can get rid of the waiting. Signed-off-by: Vitaly Kuznetsov --- drivers/hv/hv_balloon.c | 14 -- 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/drivers/hv/hv_balloon.c b/drivers/hv/hv_balloon.c index 064ef3d..a8b8b9a 100644 --- a/drivers/hv/hv_balloon.c +++ b/drivers/hv/hv_balloon.c @@ -645,7 +645,7 @@ static void hv_mem_hot_add(unsigned long start, unsigned long size, has->covered_end_pfn += processed_pfn; init_completion(&dm_device.ol_waitevent); - dm_device.ha_waiting = true; + dm_device.ha_waiting = !memhp_auto_online; mutex_unlock(&dm_device.ha_region_mutex); nid = memory_add_physaddr_to_nid(PFN_PHYS(start_pfn)); @@ -671,12 +671,14 @@ static void hv_mem_hot_add(unsigned long start, unsigned long size, } /* -* Wait for the memory block to be onlined. -* Since the hot add has succeeded, it is ok to -* proceed even if the pages in the hot added region -* have not been "onlined" within the allowed time. +* Wait for the memory block to be onlined when memory onlining +* is done outside of kernel (memhp_auto_online). Since the hot +* add has succeeded, it is ok to proceed even if the pages in +* the hot added region have not been "onlined" within the +* allowed time. */ - wait_for_completion_timeout(&dm_device.ol_waitevent, 5*HZ); + if (dm_device.ha_waiting) + wait_for_completion_timeout(&dm_device.ol_waitevent, 5*HZ); mutex_lock(&dm_device.ha_region_mutex); post_status(&dm_device); } -- 2.7.4 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v2 2/4] Drivers: hv: balloon: account for gaps in hot add regions
I'm observing the following hot add requests from the WS2012 host: hot_add_req: start_pfn = 0x108200 count = 330752 hot_add_req: start_pfn = 0x158e00 count = 193536 hot_add_req: start_pfn = 0x188400 count = 239616 As the host doesn't specify hot add regions we're trying to create 128Mb-aligned region covering the first request, we create the 0x108000 - 0x16 region and we add 0x108000 - 0x158e00 memory. The second request passes the pfn_covered() check, we enlarge the region to 0x108000 - 0x19 and add 0x158e00 - 0x188200 memory. The problem emerges with the third request as it starts at 0x188400 so there is a 0x200 gap which is not covered. As the end of our region is 0x19 now it again passes the pfn_covered() check were we just adjust the covered_end_pfn and make it 0x188400 instead of 0x188200 which means that we'll try to online 0x188200-0x188400 pages but these pages were never assigned to us and we crash. We can't react to such requests by creating new hot add regions as it may happen that the whole suggested range falls into the previously identified 128Mb-aligned area so we'll end up adding nothing or create intersecting regions and our current logic doesn't allow that. Instead, create a list of such 'gaps' and check for them in the page online callback. Signed-off-by: Vitaly Kuznetsov --- drivers/hv/hv_balloon.c | 107 +--- 1 file changed, 83 insertions(+), 24 deletions(-) diff --git a/drivers/hv/hv_balloon.c b/drivers/hv/hv_balloon.c index 4ae26d6..064ef3d 100644 --- a/drivers/hv/hv_balloon.c +++ b/drivers/hv/hv_balloon.c @@ -441,6 +441,16 @@ struct hv_hotadd_state { unsigned long covered_end_pfn; unsigned long ha_end_pfn; unsigned long end_pfn; + /* +* A list of gaps. +*/ + struct list_head gap_list; +}; + +struct hv_hotadd_gap { + struct list_head list; + unsigned long start_pfn; + unsigned long end_pfn; }; struct balloon_state { @@ -676,35 +686,63 @@ static void hv_mem_hot_add(unsigned long start, unsigned long size, static void hv_online_page(struct page *pg) { - struct list_head *cur; struct hv_hotadd_state *has; + struct hv_hotadd_gap *gap; unsigned long cur_start_pgp; unsigned long cur_end_pgp; + bool is_gap = false; list_for_each(cur, &dm_device.ha_region_list) { has = list_entry(cur, struct hv_hotadd_state, list); cur_start_pgp = (unsigned long) + pfn_to_page(has->start_pfn); + cur_end_pgp = (unsigned long)pfn_to_page(has->end_pfn); + + /* The page belongs to a different HAS. */ + if (((unsigned long)pg < cur_start_pgp) || + ((unsigned long)pg >= cur_end_pgp)) + continue; + + cur_start_pgp = (unsigned long) pfn_to_page(has->covered_start_pfn); cur_end_pgp = (unsigned long)pfn_to_page(has->covered_end_pfn); - if (((unsigned long)pg >= cur_start_pgp) && - ((unsigned long)pg < cur_end_pgp)) { - /* -* This frame is currently backed; online the -* page. -*/ - __online_page_set_limits(pg); - __online_page_increment_counters(pg); - __online_page_free(pg); + /* The page is not backed. */ + if (((unsigned long)pg < cur_start_pgp) || + ((unsigned long)pg >= cur_end_pgp)) + continue; + + /* Check for gaps. */ + list_for_each_entry(gap, &has->gap_list, list) { + cur_start_pgp = (unsigned long) + pfn_to_page(gap->start_pfn); + cur_end_pgp = (unsigned long) + pfn_to_page(gap->end_pfn); + if (((unsigned long)pg >= cur_start_pgp) && + ((unsigned long)pg < cur_end_pgp)) { + is_gap = true; + break; + } } + + if (is_gap) + break; + + /* This frame is currently backed; online the page. */ + __online_page_set_limits(pg); + __online_page_increment_counters(pg); + __online_page_free(pg); + break; } } -static bool pfn_covered(unsigned long start_pfn, unsigned long pfn_cnt) +static int pfn_covered(unsigned long start_pfn, unsigned long pfn_cnt) { struct list_head *cur; struct hv_hotadd_state *has; + struct hv_hotadd_gap *gap; unsigned long residual, new_inc; + int ret = 0; if (list_empty(&dm_device.ha_region_list)) return false
[PATCH v2 4/4] Drivers: hv: balloon: replace ha_region_mutex with spinlock
lockdep reports possible circular locking dependency when udev is used for memory onlining: systemd-udevd/3996 is trying to acquire lock: ((memory_chain).rwsem){.+}, at: [] __blocking_notifier_call_chain+0x4e/0xc0 but task is already holding lock: (&dm_device.ha_region_mutex){+.+.+.}, at: [] hv_memory_notifier+0x5e/0xc0 [hv_balloon] ... which is probably a false positive because we take and release ha_region_mutex from memory notifier chain depending on the arg. No real deadlocks were reported so far (though I'm not really sure about preemptible kernels...) but we don't really need to hold the mutex for so long. We use it to protect ha_region_list (and its members) and the num_pages_onlined counter. None of these operations require us to sleep and nothing is slow, switch to using spinlock with interrupts disabled. While on it, replace list_for_each -> list_for_each_entry as we actually need entries in all these cases, drop meaningless list_empty() checks. Signed-off-by: Vitaly Kuznetsov --- drivers/hv/hv_balloon.c | 96 ++--- 1 file changed, 52 insertions(+), 44 deletions(-) diff --git a/drivers/hv/hv_balloon.c b/drivers/hv/hv_balloon.c index a8b8b9a..19498f4 100644 --- a/drivers/hv/hv_balloon.c +++ b/drivers/hv/hv_balloon.c @@ -547,7 +547,11 @@ struct hv_dynmem_device { */ struct task_struct *thread; - struct mutex ha_region_mutex; + /* +* Protects ha_region_list, num_pages_onlined counter and individual +* regions from ha_region_list. +*/ + spinlock_t ha_lock; /* * A list of hot-add regions. @@ -571,18 +575,14 @@ static int hv_memory_notifier(struct notifier_block *nb, unsigned long val, void *v) { struct memory_notify *mem = (struct memory_notify *)v; + unsigned long flags; switch (val) { - case MEM_GOING_ONLINE: - mutex_lock(&dm_device.ha_region_mutex); - break; - case MEM_ONLINE: + spin_lock_irqsave(&dm_device.ha_lock, flags); dm_device.num_pages_onlined += mem->nr_pages; + spin_unlock_irqrestore(&dm_device.ha_lock, flags); case MEM_CANCEL_ONLINE: - if (val == MEM_ONLINE || - mutex_is_locked(&dm_device.ha_region_mutex)) - mutex_unlock(&dm_device.ha_region_mutex); if (dm_device.ha_waiting) { dm_device.ha_waiting = false; complete(&dm_device.ol_waitevent); @@ -590,10 +590,11 @@ static int hv_memory_notifier(struct notifier_block *nb, unsigned long val, break; case MEM_OFFLINE: - mutex_lock(&dm_device.ha_region_mutex); + spin_lock_irqsave(&dm_device.ha_lock, flags); dm_device.num_pages_onlined -= mem->nr_pages; - mutex_unlock(&dm_device.ha_region_mutex); + spin_unlock_irqrestore(&dm_device.ha_lock, flags); break; + case MEM_GOING_ONLINE: case MEM_GOING_OFFLINE: case MEM_CANCEL_OFFLINE: break; @@ -629,9 +630,12 @@ static void hv_mem_hot_add(unsigned long start, unsigned long size, unsigned long start_pfn; unsigned long processed_pfn; unsigned long total_pfn = pfn_count; + unsigned long flags; for (i = 0; i < (size/HA_CHUNK); i++) { start_pfn = start + (i * HA_CHUNK); + + spin_lock_irqsave(&dm_device.ha_lock, flags); has->ha_end_pfn += HA_CHUNK; if (total_pfn > HA_CHUNK) { @@ -643,11 +647,11 @@ static void hv_mem_hot_add(unsigned long start, unsigned long size, } has->covered_end_pfn += processed_pfn; + spin_unlock_irqrestore(&dm_device.ha_lock, flags); init_completion(&dm_device.ol_waitevent); dm_device.ha_waiting = !memhp_auto_online; - mutex_unlock(&dm_device.ha_region_mutex); nid = memory_add_physaddr_to_nid(PFN_PHYS(start_pfn)); ret = add_memory(nid, PFN_PHYS((start_pfn)), (HA_CHUNK << PAGE_SHIFT)); @@ -664,9 +668,10 @@ static void hv_mem_hot_add(unsigned long start, unsigned long size, */ do_hot_add = false; } + spin_lock_irqsave(&dm_device.ha_lock, flags); has->ha_end_pfn -= HA_CHUNK; has->covered_end_pfn -= processed_pfn; - mutex_lock(&dm_device.ha_region_mutex); + spin_unlock_irqrestore(&dm_device.ha_lock, flags); break; } @@ -679,7 +684,6 @@ static void hv_mem_hot_add(unsigned long start, unsigned long size, */
[PATCH v2 RESEND 3/4] Drivers: hv: balloon: don't wait for ol_waitevent when memhp_auto_online is enabled
With the recently introduced in-kernel memory onlining (MEMORY_HOTPLUG_DEFAULT_ONLINE) these is no point in waiting for pages to come online in the driver and we can get rid of the waiting. Signed-off-by: Vitaly Kuznetsov --- drivers/hv/hv_balloon.c | 14 -- 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/drivers/hv/hv_balloon.c b/drivers/hv/hv_balloon.c index 064ef3d..a8b8b9a 100644 --- a/drivers/hv/hv_balloon.c +++ b/drivers/hv/hv_balloon.c @@ -645,7 +645,7 @@ static void hv_mem_hot_add(unsigned long start, unsigned long size, has->covered_end_pfn += processed_pfn; init_completion(&dm_device.ol_waitevent); - dm_device.ha_waiting = true; + dm_device.ha_waiting = !memhp_auto_online; mutex_unlock(&dm_device.ha_region_mutex); nid = memory_add_physaddr_to_nid(PFN_PHYS(start_pfn)); @@ -671,12 +671,14 @@ static void hv_mem_hot_add(unsigned long start, unsigned long size, } /* -* Wait for the memory block to be onlined. -* Since the hot add has succeeded, it is ok to -* proceed even if the pages in the hot added region -* have not been "onlined" within the allowed time. +* Wait for the memory block to be onlined when memory onlining +* is done outside of kernel (memhp_auto_online). Since the hot +* add has succeeded, it is ok to proceed even if the pages in +* the hot added region have not been "onlined" within the +* allowed time. */ - wait_for_completion_timeout(&dm_device.ol_waitevent, 5*HZ); + if (dm_device.ha_waiting) + wait_for_completion_timeout(&dm_device.ol_waitevent, 5*HZ); mutex_lock(&dm_device.ha_region_mutex); post_status(&dm_device); } -- 2.7.4 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v2 RESEND 4/4] Drivers: hv: balloon: replace ha_region_mutex with spinlock
lockdep reports possible circular locking dependency when udev is used for memory onlining: systemd-udevd/3996 is trying to acquire lock: ((memory_chain).rwsem){.+}, at: [] __blocking_notifier_call_chain+0x4e/0xc0 but task is already holding lock: (&dm_device.ha_region_mutex){+.+.+.}, at: [] hv_memory_notifier+0x5e/0xc0 [hv_balloon] ... which is probably a false positive because we take and release ha_region_mutex from memory notifier chain depending on the arg. No real deadlocks were reported so far (though I'm not really sure about preemptible kernels...) but we don't really need to hold the mutex for so long. We use it to protect ha_region_list (and its members) and the num_pages_onlined counter. None of these operations require us to sleep and nothing is slow, switch to using spinlock with interrupts disabled. While on it, replace list_for_each -> list_for_each_entry as we actually need entries in all these cases, drop meaningless list_empty() checks. Signed-off-by: Vitaly Kuznetsov --- drivers/hv/hv_balloon.c | 96 ++--- 1 file changed, 52 insertions(+), 44 deletions(-) diff --git a/drivers/hv/hv_balloon.c b/drivers/hv/hv_balloon.c index a8b8b9a..19498f4 100644 --- a/drivers/hv/hv_balloon.c +++ b/drivers/hv/hv_balloon.c @@ -547,7 +547,11 @@ struct hv_dynmem_device { */ struct task_struct *thread; - struct mutex ha_region_mutex; + /* +* Protects ha_region_list, num_pages_onlined counter and individual +* regions from ha_region_list. +*/ + spinlock_t ha_lock; /* * A list of hot-add regions. @@ -571,18 +575,14 @@ static int hv_memory_notifier(struct notifier_block *nb, unsigned long val, void *v) { struct memory_notify *mem = (struct memory_notify *)v; + unsigned long flags; switch (val) { - case MEM_GOING_ONLINE: - mutex_lock(&dm_device.ha_region_mutex); - break; - case MEM_ONLINE: + spin_lock_irqsave(&dm_device.ha_lock, flags); dm_device.num_pages_onlined += mem->nr_pages; + spin_unlock_irqrestore(&dm_device.ha_lock, flags); case MEM_CANCEL_ONLINE: - if (val == MEM_ONLINE || - mutex_is_locked(&dm_device.ha_region_mutex)) - mutex_unlock(&dm_device.ha_region_mutex); if (dm_device.ha_waiting) { dm_device.ha_waiting = false; complete(&dm_device.ol_waitevent); @@ -590,10 +590,11 @@ static int hv_memory_notifier(struct notifier_block *nb, unsigned long val, break; case MEM_OFFLINE: - mutex_lock(&dm_device.ha_region_mutex); + spin_lock_irqsave(&dm_device.ha_lock, flags); dm_device.num_pages_onlined -= mem->nr_pages; - mutex_unlock(&dm_device.ha_region_mutex); + spin_unlock_irqrestore(&dm_device.ha_lock, flags); break; + case MEM_GOING_ONLINE: case MEM_GOING_OFFLINE: case MEM_CANCEL_OFFLINE: break; @@ -629,9 +630,12 @@ static void hv_mem_hot_add(unsigned long start, unsigned long size, unsigned long start_pfn; unsigned long processed_pfn; unsigned long total_pfn = pfn_count; + unsigned long flags; for (i = 0; i < (size/HA_CHUNK); i++) { start_pfn = start + (i * HA_CHUNK); + + spin_lock_irqsave(&dm_device.ha_lock, flags); has->ha_end_pfn += HA_CHUNK; if (total_pfn > HA_CHUNK) { @@ -643,11 +647,11 @@ static void hv_mem_hot_add(unsigned long start, unsigned long size, } has->covered_end_pfn += processed_pfn; + spin_unlock_irqrestore(&dm_device.ha_lock, flags); init_completion(&dm_device.ol_waitevent); dm_device.ha_waiting = !memhp_auto_online; - mutex_unlock(&dm_device.ha_region_mutex); nid = memory_add_physaddr_to_nid(PFN_PHYS(start_pfn)); ret = add_memory(nid, PFN_PHYS((start_pfn)), (HA_CHUNK << PAGE_SHIFT)); @@ -664,9 +668,10 @@ static void hv_mem_hot_add(unsigned long start, unsigned long size, */ do_hot_add = false; } + spin_lock_irqsave(&dm_device.ha_lock, flags); has->ha_end_pfn -= HA_CHUNK; has->covered_end_pfn -= processed_pfn; - mutex_lock(&dm_device.ha_region_mutex); + spin_unlock_irqrestore(&dm_device.ha_lock, flags); break; } @@ -679,7 +684,6 @@ static void hv_mem_hot_add(unsigned long start, unsigned long size, */
[PATCH v2 RESEND 2/4] Drivers: hv: balloon: account for gaps in hot add regions
I'm observing the following hot add requests from the WS2012 host: hot_add_req: start_pfn = 0x108200 count = 330752 hot_add_req: start_pfn = 0x158e00 count = 193536 hot_add_req: start_pfn = 0x188400 count = 239616 As the host doesn't specify hot add regions we're trying to create 128Mb-aligned region covering the first request, we create the 0x108000 - 0x16 region and we add 0x108000 - 0x158e00 memory. The second request passes the pfn_covered() check, we enlarge the region to 0x108000 - 0x19 and add 0x158e00 - 0x188200 memory. The problem emerges with the third request as it starts at 0x188400 so there is a 0x200 gap which is not covered. As the end of our region is 0x19 now it again passes the pfn_covered() check were we just adjust the covered_end_pfn and make it 0x188400 instead of 0x188200 which means that we'll try to online 0x188200-0x188400 pages but these pages were never assigned to us and we crash. We can't react to such requests by creating new hot add regions as it may happen that the whole suggested range falls into the previously identified 128Mb-aligned area so we'll end up adding nothing or create intersecting regions and our current logic doesn't allow that. Instead, create a list of such 'gaps' and check for them in the page online callback. Signed-off-by: Vitaly Kuznetsov --- drivers/hv/hv_balloon.c | 107 +--- 1 file changed, 83 insertions(+), 24 deletions(-) diff --git a/drivers/hv/hv_balloon.c b/drivers/hv/hv_balloon.c index 4ae26d6..064ef3d 100644 --- a/drivers/hv/hv_balloon.c +++ b/drivers/hv/hv_balloon.c @@ -441,6 +441,16 @@ struct hv_hotadd_state { unsigned long covered_end_pfn; unsigned long ha_end_pfn; unsigned long end_pfn; + /* +* A list of gaps. +*/ + struct list_head gap_list; +}; + +struct hv_hotadd_gap { + struct list_head list; + unsigned long start_pfn; + unsigned long end_pfn; }; struct balloon_state { @@ -676,35 +686,63 @@ static void hv_mem_hot_add(unsigned long start, unsigned long size, static void hv_online_page(struct page *pg) { - struct list_head *cur; struct hv_hotadd_state *has; + struct hv_hotadd_gap *gap; unsigned long cur_start_pgp; unsigned long cur_end_pgp; + bool is_gap = false; list_for_each(cur, &dm_device.ha_region_list) { has = list_entry(cur, struct hv_hotadd_state, list); cur_start_pgp = (unsigned long) + pfn_to_page(has->start_pfn); + cur_end_pgp = (unsigned long)pfn_to_page(has->end_pfn); + + /* The page belongs to a different HAS. */ + if (((unsigned long)pg < cur_start_pgp) || + ((unsigned long)pg >= cur_end_pgp)) + continue; + + cur_start_pgp = (unsigned long) pfn_to_page(has->covered_start_pfn); cur_end_pgp = (unsigned long)pfn_to_page(has->covered_end_pfn); - if (((unsigned long)pg >= cur_start_pgp) && - ((unsigned long)pg < cur_end_pgp)) { - /* -* This frame is currently backed; online the -* page. -*/ - __online_page_set_limits(pg); - __online_page_increment_counters(pg); - __online_page_free(pg); + /* The page is not backed. */ + if (((unsigned long)pg < cur_start_pgp) || + ((unsigned long)pg >= cur_end_pgp)) + continue; + + /* Check for gaps. */ + list_for_each_entry(gap, &has->gap_list, list) { + cur_start_pgp = (unsigned long) + pfn_to_page(gap->start_pfn); + cur_end_pgp = (unsigned long) + pfn_to_page(gap->end_pfn); + if (((unsigned long)pg >= cur_start_pgp) && + ((unsigned long)pg < cur_end_pgp)) { + is_gap = true; + break; + } } + + if (is_gap) + break; + + /* This frame is currently backed; online the page. */ + __online_page_set_limits(pg); + __online_page_increment_counters(pg); + __online_page_free(pg); + break; } } -static bool pfn_covered(unsigned long start_pfn, unsigned long pfn_cnt) +static int pfn_covered(unsigned long start_pfn, unsigned long pfn_cnt) { struct list_head *cur; struct hv_hotadd_state *has; + struct hv_hotadd_gap *gap; unsigned long residual, new_inc; + int ret = 0; if (list_empty(&dm_device.ha_region_list)) return false
[PATCH v2 RESEND 0/4] Drivers: hv: balloon: fix WS2012 memory hotplug issues and do some cleanup
Changes since v2: - I'm sorry, I screwed up Alex's address, this is just a resend. Changes since v1: - Keep ol_waitevent and wait when kernel memory onlining is disabled [Alex Ng] Crashes with Hyper-V balloon driver are reported with WS2012 (non-R2), hosts I was able to identify two issues which I fix with first two patches of this series. Patches 3 removes wait on ol_waitevent when we have in in-kernel memory onlining, patch 4 gets rid of ha_region_mutex by doing the locking fine-grained with a spinlock. Vitaly Kuznetsov (4): Drivers: hv: balloon: keep track of where ha_region starts Drivers: hv: balloon: account for gaps in hot add regions Drivers: hv: balloon: don't wait for ol_waitevent when memhp_auto_online is enabled Drivers: hv: balloon: replace ha_region_mutex with spinlock drivers/hv/hv_balloon.c | 216 1 file changed, 144 insertions(+), 72 deletions(-) -- 2.7.4 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v2 RESEND 1/4] Drivers: hv: balloon: keep track of where ha_region starts
Windows 2012 (non-R2) does not specify hot add region in hot add requests and the logic in hot_add_req() is trying to find a 128Mb-aligned region covering the request. It may also happen that host's requests are not 128Mb aligned and the created ha_region will start before the first specified PFN. We can't online these non-present pages but we don't remember the real start of the region. This is a regression introduced by the commit 5a75d733 ("Drivers: hv: hv_balloon: don't lose memory when onlining order is not natural"). While the idea of keeping the 'moving window' was wrong (as there is no guarantee that hot add requests come ordered) we should still keep track of covered_start_pfn. This is not a revert, the logic is different. Signed-off-by: Vitaly Kuznetsov --- drivers/hv/hv_balloon.c | 7 +-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/hv/hv_balloon.c b/drivers/hv/hv_balloon.c index df35fb7..4ae26d6 100644 --- a/drivers/hv/hv_balloon.c +++ b/drivers/hv/hv_balloon.c @@ -430,13 +430,14 @@ struct dm_info_msg { * currently hot added. We hot add in multiples of 128M * chunks; it is possible that we may not be able to bring * online all the pages in the region. The range - * covered_end_pfn defines the pages that can + * covered_start_pfn:covered_end_pfn defines the pages that can * be brough online. */ struct hv_hotadd_state { struct list_head list; unsigned long start_pfn; + unsigned long covered_start_pfn; unsigned long covered_end_pfn; unsigned long ha_end_pfn; unsigned long end_pfn; @@ -682,7 +683,8 @@ static void hv_online_page(struct page *pg) list_for_each(cur, &dm_device.ha_region_list) { has = list_entry(cur, struct hv_hotadd_state, list); - cur_start_pgp = (unsigned long)pfn_to_page(has->start_pfn); + cur_start_pgp = (unsigned long) + pfn_to_page(has->covered_start_pfn); cur_end_pgp = (unsigned long)pfn_to_page(has->covered_end_pfn); if (((unsigned long)pg >= cur_start_pgp) && @@ -854,6 +856,7 @@ static unsigned long process_hot_add(unsigned long pg_start, list_add_tail(&ha_region->list, &dm_device.ha_region_list); ha_region->start_pfn = rg_start; ha_region->ha_end_pfn = rg_start; + ha_region->covered_start_pfn = pg_start; ha_region->covered_end_pfn = pg_start; ha_region->end_pfn = rg_start + rg_size; } -- 2.7.4 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH] Staging: rtl8723au: os_intfs: fixed case statement is variable issue
Fixed sparse parse error: Expected constant expression in case statement. Signed-off-by: Bing Sun --- drivers/staging/rtl8723au/os_dep/os_intfs.c | 11 +-- 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/drivers/staging/rtl8723au/os_dep/os_intfs.c b/drivers/staging/rtl8723au/os_dep/os_intfs.c index b8848c2..f30d5d2 100644 --- a/drivers/staging/rtl8723au/os_dep/os_intfs.c +++ b/drivers/staging/rtl8723au/os_dep/os_intfs.c @@ -283,14 +283,13 @@ static u32 rtw_classify8021d(struct sk_buff *skb) */ if (skb->priority >= 256 && skb->priority <= 263) return skb->priority - 256; - switch (skb->protocol) { - case htons(ETH_P_IP): + + if (skb->protocol == htons(ETH_P_IP)) { dscp = ip_hdr(skb)->tos & 0xfc; - break; - default: - return 0; + return dscp >> 5; } - return dscp >> 5; + + return 0; } static u16 rtw_select_queue(struct net_device *dev, struct sk_buff *skb, -- 2.1.0 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH v2 1/6] staging/android: remove doc from sw_sync
Hi Pavel, 2016-08-09 Pavel Machek : > On Mon 2016-08-08 18:24:17, Gustavo Padovan wrote: > > From: Gustavo Padovan > > > > SW_SYNC should never be used by other pieces of the kernel apart from > > sync_debug as it is only a Sync File Validation Framework, so hide any > > info to avoid confuse this with a standard kernel internal API. > > > Signed-off-by: Gustavo Padovan > > NAK. > > It is unclear for what the code does, removing the docs is not going to help. > > If it should not be used, document that it should not be used.. but not remove > the docs. Okay, I'll skip this patch. ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH v2 0/6] de-stage SW_SYNC validation frawework
Hi Eric, 2016-08-11 Eric Engestrom : > On Mon, Aug 08, 2016 at 06:24:16PM -0300, Gustavo Padovan wrote: > > From: Gustavo Padovan > > > > Hi Greg, > > > > This is the last step in the Sync Framwork de-stage task. It de-stage > > the SW_SYNC validation framework and the sync_debug info debugfs file. > > > > The first 2 patches are clean up and improvements and the rest is > > preparation > > to de-stage and then finally the actual de-stage. > > > > v2: > > - add documentation about the SW_SYNC ioctl API (comments from Pavel > > Machek) > > - remove for now patch to add sync_pt name to debugfs > > > > Please review, > > > > Gustavo > > > > --- > > Gustavo Padovan (6): > > staging/android: remove doc from sw_sync > > staging/android: do not let userspace trigger WARN_ON > > staging/android: move trace/sync.h to sync_trace.h > > staging/android: prepare sw_sync files for de-staging > > staging/android: add Doc for SW_SYNC ioctl interface > > dma-buf/sw_sync: de-stage SW_SYNC > > > > drivers/dma-buf/Kconfig | 13 ++ > > drivers/dma-buf/Makefile | 1 + > > drivers/dma-buf/sw_sync.c| 349 > > +++ > > drivers/dma-buf/sync_debug.c | 230 +++ > > drivers/dma-buf/sync_debug.h | 69 +++ > > drivers/dma-buf/sync_trace.h | 32 > > drivers/staging/android/Kconfig | 13 -- > > drivers/staging/android/Makefile | 1 - > > drivers/staging/android/sw_sync.c| 344 > > -- > > drivers/staging/android/sync_debug.c | 230 --- > > drivers/staging/android/sync_debug.h | 84 - > > drivers/staging/android/trace/sync.h | 32 > > 12 files changed, 694 insertions(+), 704 deletions(-) > > > create mode 100644 drivers/dma-buf/sw_sync.c > > create mode 100644 drivers/dma-buf/sync_debug.c > > create mode 100644 drivers/dma-buf/sync_debug.h > > create mode 100644 drivers/dma-buf/sync_trace.h > > delete mode 100644 drivers/staging/android/sw_sync.c > > delete mode 100644 drivers/staging/android/sync_debug.c > > delete mode 100644 drivers/staging/android/sync_debug.h > > delete mode 100644 drivers/staging/android/trace/sync.h > > When you send your next revision, could you use `git format-patch -M`? > A good 95% of the lines in these patches aren't actually modified, just > moved around, which makes it much harder to spot the actual changes :) Sure, I was doing this for previous revisions, but forgot to do it for this one. Gustavo ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
RE: [PATCH net 2/4] hv_netvsc: reset vf_inject on VF removal
> +static void netvsc_inject_enable(struct net_device_context > +*net_device_ctx) { > + net_device_ctx->vf_inject = true; > +} > + > +static void netvsc_inject_disable(struct net_device_context > +*net_device_ctx) { > + net_device_ctx->vf_inject = false; > + > + /* Wait for currently active users to drain out. */ > + while (atomic_read(&net_device_ctx->vf_use_cnt) != 0) > + udelay(50); > +} That was already the behavior before, but are you certain you want to unconditionally block without any possible timeout? ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH] Staging: rtl8723au: os_intfs: fixed case statement is variable issue
Bing Sun writes: > Fixed sparse parse error: > Expected constant expression in case statement. > > Signed-off-by: Bing Sun > --- > drivers/staging/rtl8723au/os_dep/os_intfs.c | 11 +-- > 1 file changed, 5 insertions(+), 6 deletions(-) > > diff --git a/drivers/staging/rtl8723au/os_dep/os_intfs.c > b/drivers/staging/rtl8723au/os_dep/os_intfs.c > index b8848c2..f30d5d2 100644 > --- a/drivers/staging/rtl8723au/os_dep/os_intfs.c > +++ b/drivers/staging/rtl8723au/os_dep/os_intfs.c > @@ -283,14 +283,13 @@ static u32 rtw_classify8021d(struct sk_buff *skb) >*/ > if (skb->priority >= 256 && skb->priority <= 263) > return skb->priority - 256; > - switch (skb->protocol) { > - case htons(ETH_P_IP): > + > + if (skb->protocol == htons(ETH_P_IP)) { > dscp = ip_hdr(skb)->tos & 0xfc; > - break; > - default: > - return 0; > + return dscp >> 5; > } > - return dscp >> 5; > + > + return 0; > } Pardon me here, but I find it really hard to see how this change is an improvement over the old code in any shape or form. Jes ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v3 1/5] staging/android: do not let userspace trigger WARN_ON
From: Gustavo Padovan Closing the timeline without waiting all fences to signal is not a critical failure, it is just bad usage from userspace so avoid calling WARN_ON in this case. Signed-off-by: Gustavo Padovan --- drivers/staging/android/sw_sync.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/android/sw_sync.c b/drivers/staging/android/sw_sync.c index 115c917..bda1f6a 100644 --- a/drivers/staging/android/sw_sync.c +++ b/drivers/staging/android/sw_sync.c @@ -176,7 +176,7 @@ static void timeline_fence_release(struct fence *fence) spin_lock_irqsave(fence->lock, flags); list_del(&pt->child_list); - if (WARN_ON_ONCE(!list_empty(&pt->active_list))) + if (!list_empty(&pt->active_list)) list_del(&pt->active_list); spin_unlock_irqrestore(fence->lock, flags); -- 2.5.5 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v3 0/5] de-stage SW_SYNC validation frawework
From: Gustavo Padovan Hi Greg, This is the last step in the Sync Framwork de-stage task. It de-stage the SW_SYNC validation framework and the sync_debug info debugfs file. The first 2 patches are clean up and improvements and the rest is preparation to de-stage and then finally the actual de-stage. v2: - add documentation about the SW_SYNC ioctl API (comments from Pavel Machek) - remove for now patch to add sync_pt name to debugfs v3: - doc improvements (comments from Eric Engestrom) - remove patch that removes documentation (comments from Pavel Machek) Gustavo Padovan (5): staging/android: do not let userspace trigger WARN_ON staging/android: move trace/sync.h to sync_trace.h staging/android: prepare sw_sync files for de-staging staging/android: add Doc for SW_SYNC ioctl interface dma-buf/sw_sync: de-stage SW_SYNC drivers/dma-buf/Kconfig| 13 drivers/dma-buf/Makefile | 1 + drivers/{staging/android => dma-buf}/sw_sync.c | 37 -- drivers/{staging/android => dma-buf}/sync_debug.c | 2 +- drivers/{staging/android => dma-buf}/sync_debug.h | 2 +- .../android/trace/sync.h => dma-buf/sync_trace.h} | 6 ++-- drivers/staging/android/Kconfig| 13 drivers/staging/android/Makefile | 1 - 8 files changed, 53 insertions(+), 22 deletions(-) rename drivers/{staging/android => dma-buf}/sw_sync.c (87%) rename drivers/{staging/android => dma-buf}/sync_debug.c (99%) rename drivers/{staging/android => dma-buf}/sync_debug.h (97%) rename drivers/{staging/android/trace/sync.h => dma-buf/sync_trace.h} (84%) -- 2.5.5 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v3 5/5] dma-buf/sw_sync: de-stage SW_SYNC
From: Gustavo Padovan SW_SYNC allows to run tests on the sync_file framework via debugfs on /sync/sw_sync Opening and closing the file triggers creation and release of a sync timeline. To create fences on this timeline the SW_SYNC_IOC_CREATE_FENCE ioctl should be used. To increment the timeline value use SW_SYNC_IOC_INC. Also it exports Sync information on /sync/info Signed-off-by: Gustavo Padovan Reviewed-by: Eric Engestrom --- drivers/dma-buf/Kconfig | 13 + drivers/dma-buf/Makefile | 1 + drivers/{staging/android => dma-buf}/sw_sync.c| 0 drivers/{staging/android => dma-buf}/sync_debug.c | 0 drivers/{staging/android => dma-buf}/sync_debug.h | 0 drivers/{staging/android => dma-buf}/sync_trace.h | 2 +- drivers/staging/android/Kconfig | 13 - drivers/staging/android/Makefile | 1 - 8 files changed, 15 insertions(+), 15 deletions(-) rename drivers/{staging/android => dma-buf}/sw_sync.c (100%) rename drivers/{staging/android => dma-buf}/sync_debug.c (100%) rename drivers/{staging/android => dma-buf}/sync_debug.h (100%) rename drivers/{staging/android => dma-buf}/sync_trace.h (92%) diff --git a/drivers/dma-buf/Kconfig b/drivers/dma-buf/Kconfig index 25bcfa0..2585821 100644 --- a/drivers/dma-buf/Kconfig +++ b/drivers/dma-buf/Kconfig @@ -17,4 +17,17 @@ config SYNC_FILE Files fds, to the DRM driver for example. More details at Documentation/sync_file.txt. +config SW_SYNC + bool "Sync File Validation Framework" + default n + depends on SYNC_FILE + depends on DEBUG_FS + ---help--- + A sync object driver that uses a 32bit counter to coordinate + synchronization. Useful when there is no hardware primitive backing + the synchronization. + + WARNING: improper use of this can result in deadlocking kernel + drivers from userspace. Intended for test and debug only. + endmenu diff --git a/drivers/dma-buf/Makefile b/drivers/dma-buf/Makefile index f353db2..210a10b 100644 --- a/drivers/dma-buf/Makefile +++ b/drivers/dma-buf/Makefile @@ -1,2 +1,3 @@ obj-y := dma-buf.o fence.o reservation.o seqno-fence.o fence-array.o obj-$(CONFIG_SYNC_FILE)+= sync_file.o +obj-$(CONFIG_SW_SYNC) += sw_sync.o sync_debug.o diff --git a/drivers/staging/android/sw_sync.c b/drivers/dma-buf/sw_sync.c similarity index 100% rename from drivers/staging/android/sw_sync.c rename to drivers/dma-buf/sw_sync.c diff --git a/drivers/staging/android/sync_debug.c b/drivers/dma-buf/sync_debug.c similarity index 100% rename from drivers/staging/android/sync_debug.c rename to drivers/dma-buf/sync_debug.c diff --git a/drivers/staging/android/sync_debug.h b/drivers/dma-buf/sync_debug.h similarity index 100% rename from drivers/staging/android/sync_debug.h rename to drivers/dma-buf/sync_debug.h diff --git a/drivers/staging/android/sync_trace.h b/drivers/dma-buf/sync_trace.h similarity index 92% rename from drivers/staging/android/sync_trace.h rename to drivers/dma-buf/sync_trace.h index ea485f7..d13d59f 100644 --- a/drivers/staging/android/sync_trace.h +++ b/drivers/dma-buf/sync_trace.h @@ -1,5 +1,5 @@ #undef TRACE_SYSTEM -#define TRACE_INCLUDE_PATH ../../drivers/staging/android +#define TRACE_INCLUDE_PATH ../../drivers/dma-buf #define TRACE_SYSTEM sync_trace #if !defined(_TRACE_SYNC_H) || defined(TRACE_HEADER_MULTI_READ) diff --git a/drivers/staging/android/Kconfig b/drivers/staging/android/Kconfig index 06e41d2..6c00d6f 100644 --- a/drivers/staging/android/Kconfig +++ b/drivers/staging/android/Kconfig @@ -24,19 +24,6 @@ config ANDROID_LOW_MEMORY_KILLER scripts (/init.rc), and it defines priority values with minimum free memory size for each priority. -config SW_SYNC - bool "Software synchronization framework" - default n - depends on SYNC_FILE - depends on DEBUG_FS - ---help--- - A sync object driver that uses a 32bit counter to coordinate - synchronization. Useful when there is no hardware primitive backing - the synchronization. - - WARNING: improper use of this can result in deadlocking kernel - drivers from userspace. Intended for test and debug only. - source "drivers/staging/android/ion/Kconfig" endif # if ANDROID diff --git a/drivers/staging/android/Makefile b/drivers/staging/android/Makefile index 7ca61b7..7ed1be7 100644 --- a/drivers/staging/android/Makefile +++ b/drivers/staging/android/Makefile @@ -4,4 +4,3 @@ obj-y += ion/ obj-$(CONFIG_ASHMEM) += ashmem.o obj-$(CONFIG_ANDROID_LOW_MEMORY_KILLER)+= lowmemorykiller.o -obj-$(CONFIG_SW_SYNC) += sw_sync.o sync_debug.o -- 2.5.5 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listi
[PATCH v3 4/5] staging/android: add Doc for SW_SYNC ioctl interface
From: Gustavo Padovan This interface is hidden from kernel headers and it is intended for use only for testing. So testers would have to add the ioctl information internally. This is to prevent misuse of this feature. v2: take in Eric suggestions for the Documentation Signed-off-by: Gustavo Padovan Reviewed-by: Eric Engestrom --- drivers/staging/android/sw_sync.c | 31 +++ 1 file changed, 31 insertions(+) diff --git a/drivers/staging/android/sw_sync.c b/drivers/staging/android/sw_sync.c index 039e1f4..498ab55 100644 --- a/drivers/staging/android/sw_sync.c +++ b/drivers/staging/android/sw_sync.c @@ -25,6 +25,36 @@ #define CREATE_TRACE_POINTS #include "sync_trace.h" +/* + * SW SYNC validation framework + * + * A sync object driver that uses a 32bit counter to coordinate + * synchronization. Useful when there is no hardware primitive backing + * the synchronization. + * + * To start the framework just open: + * + * /sync/sw_sync + * + * That will create a sync timeline, all fences created under this timeline + * file descriptor will belong to the this timeline. + * + * The 'sw_sync' file can be opened many times as to create different + * timelines. + * + * Fences can be created with SW_SYNC_IOC_CREATE_FENCE ioctl with struct + * sw_sync_ioctl_create_fence as parameter. + * + * To increment the timeline counter, SW_SYNC_IOC_INC ioctl should be used + * with the increment as u32. This will update the last signaled value + * from the timeline and signal any fence that has seqno smaller of equal + * it. + * + * struct sw_sync_ioctl_create_fence + * @value: the seqno to initialise the fence with + * @name: the name of the new sync point + * @fence: return the fd of the new sync_file with the created fence + */ struct sw_sync_create_fence_data { __u32 value; charname[32]; @@ -35,6 +65,7 @@ struct sw_sync_create_fence_data { #define SW_SYNC_IOC_CREATE_FENCE _IOWR(SW_SYNC_IOC_MAGIC, 0,\ struct sw_sync_create_fence_data) + #define SW_SYNC_IOC_INC_IOW(SW_SYNC_IOC_MAGIC, 1, __u32) static const struct fence_ops timeline_fence_ops; -- 2.5.5 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v3 3/5] staging/android: prepare sw_sync files for de-staging
From: Gustavo Padovan remove file paths in the comments and add short description about each file. v2: remove file paths instead of just change them. v3: improve header description as sugggested by Eric Signed-off-by: Gustavo Padovan Reviewed-by: Eric Engestrom --- drivers/staging/android/sw_sync.c| 2 +- drivers/staging/android/sync_debug.c | 2 +- drivers/staging/android/sync_debug.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/android/sw_sync.c b/drivers/staging/android/sw_sync.c index 92c1f8b..039e1f4 100644 --- a/drivers/staging/android/sw_sync.c +++ b/drivers/staging/android/sw_sync.c @@ -1,5 +1,5 @@ /* - * drivers/dma-buf/sw_sync.c + * Sync File validation framework * * Copyright (C) 2012 Google, Inc. * diff --git a/drivers/staging/android/sync_debug.c b/drivers/staging/android/sync_debug.c index 4c5a855..fab9520 100644 --- a/drivers/staging/android/sync_debug.c +++ b/drivers/staging/android/sync_debug.c @@ -1,5 +1,5 @@ /* - * drivers/base/sync.c + * Sync File validation framework and debug information * * Copyright (C) 2012 Google, Inc. * diff --git a/drivers/staging/android/sync_debug.h b/drivers/staging/android/sync_debug.h index fab6639..d269aa6 100644 --- a/drivers/staging/android/sync_debug.h +++ b/drivers/staging/android/sync_debug.h @@ -1,5 +1,5 @@ /* - * include/linux/sync.h + * Sync File validation framework and debug infomation * * Copyright (C) 2012 Google, Inc. * -- 2.5.5 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v3 2/5] staging/android: move trace/sync.h to sync_trace.h
From: Gustavo Padovan The common behaviour for trace headers is to have them in the same folder they are used, instead of creating a special trace/ directory. Signed-off-by: Gustavo Padovan Reviewed-by: Eric Engestrom --- drivers/staging/android/sw_sync.c | 2 +- drivers/staging/android/{trace/sync.h => sync_trace.h} | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) rename drivers/staging/android/{trace/sync.h => sync_trace.h} (84%) diff --git a/drivers/staging/android/sw_sync.c b/drivers/staging/android/sw_sync.c index bda1f6a..92c1f8b 100644 --- a/drivers/staging/android/sw_sync.c +++ b/drivers/staging/android/sw_sync.c @@ -23,7 +23,7 @@ #include "sync_debug.h" #define CREATE_TRACE_POINTS -#include "trace/sync.h" +#include "sync_trace.h" struct sw_sync_create_fence_data { __u32 value; diff --git a/drivers/staging/android/trace/sync.h b/drivers/staging/android/sync_trace.h similarity index 84% rename from drivers/staging/android/trace/sync.h rename to drivers/staging/android/sync_trace.h index 6b5ce96..ea485f7 100644 --- a/drivers/staging/android/trace/sync.h +++ b/drivers/staging/android/sync_trace.h @@ -1,11 +1,11 @@ #undef TRACE_SYSTEM -#define TRACE_INCLUDE_PATH ../../drivers/staging/android/trace -#define TRACE_SYSTEM sync +#define TRACE_INCLUDE_PATH ../../drivers/staging/android +#define TRACE_SYSTEM sync_trace #if !defined(_TRACE_SYNC_H) || defined(TRACE_HEADER_MULTI_READ) #define _TRACE_SYNC_H -#include "../sync_debug.h" +#include "sync_debug.h" #include TRACE_EVENT(sync_timeline, -- 2.5.5 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
RE: [PATCH net 1/4] hv_netvsc: don't lose VF information
> -Original Message- > From: Vitaly Kuznetsov [mailto:vkuzn...@redhat.com] > Sent: Thursday, August 11, 2016 6:59 AM > To: net...@vger.kernel.org > Cc: de...@linuxdriverproject.org; linux-ker...@vger.kernel.org; Haiyang > Zhang ; KY Srinivasan > Subject: [PATCH net 1/4] hv_netvsc: don't lose VF information > > struct netvsc_device is not suitable for storing VF information as this > structure is being destroyed on MTU change / set channel operation (see > rndis_filter_device_remove()). Move all VF related stuff to struct > net_device_context which is persistent. > > Signed-off-by: Vitaly Kuznetsov Acked-by: Haiyang Zhang ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
RE: [PATCH net 2/4] hv_netvsc: reset vf_inject on VF removal
> -Original Message- > From: Vitaly Kuznetsov [mailto:vkuzn...@redhat.com] > Sent: Thursday, August 11, 2016 6:59 AM > To: net...@vger.kernel.org > Cc: de...@linuxdriverproject.org; linux-ker...@vger.kernel.org; Haiyang > Zhang ; KY Srinivasan > Subject: [PATCH net 2/4] hv_netvsc: reset vf_inject on VF removal > > We reset vf_inject on VF going down (netvsc_vf_down()) but we don't on > VF removal (netvsc_unregister_vf()) so vf_inject stays 'true' while > vf_netdev is already NULL and we're trying to inject packets into NULL > net device in netvsc_recv_callback() causing kernel to crash. > > Signed-off-by: Vitaly Kuznetsov Acked-by: Haiyang Zhang ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
RE: [PATCH net 4/4] hv_netvsc: avoid deadlocks between rtnl lock and netvsc_inject_disable()
> -Original Message- > From: Vitaly Kuznetsov [mailto:vkuzn...@redhat.com] > Sent: Thursday, August 11, 2016 6:59 AM > To: net...@vger.kernel.org > Cc: de...@linuxdriverproject.org; linux-ker...@vger.kernel.org; Haiyang > Zhang ; KY Srinivasan > Subject: [PATCH net 4/4] hv_netvsc: avoid deadlocks between rtnl lock and > netvsc_inject_disable() > > Here is a deadlock scenario: > - netvsc_vf_up() schedules netvsc_notify_peers() work and quits. > - netvsc_vf_down() runs before netvsc_notify_peers() gets executed. As it > is being executed from netdev notifier chain we hold rtnl lock when we > get here. > - we enter netvsc_inject_disable() and loop and wait till > netvsc_notify_peers() drops vf_use_cnt. > - netvsc_notify_peers() starts on some other CPU but netdev_notify_peers() > will hang on rtnl_lock(). > - deadlock! > > Similar deadlocks are possible between netvsc_vf_{up,down}() and > netvsc_unregister_vf() as it also waits till vf_use_cnt drops to zero. > Instead of introducing additional synchronization I suggest we drop > gwrk.dwrk completely and call NETDEV_NOTIFY_PEERS directly. As we're > acting under rtnl lock this is legitimate. > > Signed-off-by: Vitaly Kuznetsov Acked-by: Haiyang Zhang ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
RE: [PATCH net 3/4] hv_netvsc: protect module refcount by checking net_device_ctx->vf_netdev
> -Original Message- > From: Vitaly Kuznetsov [mailto:vkuzn...@redhat.com] > Sent: Thursday, August 11, 2016 6:59 AM > To: net...@vger.kernel.org > Cc: de...@linuxdriverproject.org; linux-ker...@vger.kernel.org; Haiyang > Zhang ; KY Srinivasan > Subject: [PATCH net 3/4] hv_netvsc: protect module refcount by checking > net_device_ctx->vf_netdev > > We're not guaranteed to see NETDEV_REGISTER/NETDEV_UNREGISTER > notifications > only once per VF but we increase/decrease module refcount unconditionally. > Check vf_netdev to make sure we don't take/release it twice. We presume > that only one VF per netvsc device may exist. > > Signed-off-by: Vitaly Kuznetsov Acked-by: Haiyang Zhang ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH v3 4/5] staging/android: add Doc for SW_SYNC ioctl interface
On Thu, Aug 11, 2016 at 12:26:43PM -0300, Gustavo Padovan wrote: > From: Gustavo Padovan > > This interface is hidden from kernel headers and it is intended for use > only for testing. So testers would have to add the ioctl information > internally. This is to prevent misuse of this feature. > > v2: take in Eric suggestions for the Documentation > > Signed-off-by: Gustavo Padovan > Reviewed-by: Eric Engestrom > --- > drivers/staging/android/sw_sync.c | 31 +++ > 1 file changed, 31 insertions(+) > > diff --git a/drivers/staging/android/sw_sync.c > b/drivers/staging/android/sw_sync.c > index 039e1f4..498ab55 100644 > --- a/drivers/staging/android/sw_sync.c > +++ b/drivers/staging/android/sw_sync.c > @@ -25,6 +25,36 @@ > #define CREATE_TRACE_POINTS > #include "sync_trace.h" > > +/* > + * SW SYNC validation framework > + * > + * A sync object driver that uses a 32bit counter to coordinate > + * synchronization. Useful when there is no hardware primitive backing > + * the synchronization. > + * > + * To start the framework just open: > + * > + * /sync/sw_sync > + * > + * That will create a sync timeline, all fences created under this timeline > + * file descriptor will belong to the this timeline. > + * > + * The 'sw_sync' file can be opened many times as to create different > + * timelines. > + * > + * Fences can be created with SW_SYNC_IOC_CREATE_FENCE ioctl with struct > + * sw_sync_ioctl_create_fence as parameter. > + * > + * To increment the timeline counter, SW_SYNC_IOC_INC ioctl should be used > + * with the increment as u32. This will update the last signaled value > + * from the timeline and signal any fence that has seqno smaller of equal > + * it. You didn't fix all of it: "that has a seqno smaller or equal to it." Missing "a" (just noticed), s/of/or/, and missing "to" :) Cheers, Eric > + * > + * struct sw_sync_ioctl_create_fence > + * @value: the seqno to initialise the fence with > + * @name:the name of the new sync point > + * @fence: return the fd of the new sync_file with the created fence > + */ > struct sw_sync_create_fence_data { > __u32 value; > charname[32]; > @@ -35,6 +65,7 @@ struct sw_sync_create_fence_data { > > #define SW_SYNC_IOC_CREATE_FENCE _IOWR(SW_SYNC_IOC_MAGIC, 0,\ > struct sw_sync_create_fence_data) > + > #define SW_SYNC_IOC_INC _IOW(SW_SYNC_IOC_MAGIC, 1, > __u32) > > static const struct fence_ops timeline_fence_ops; > -- > 2.5.5 > ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH v3 4/5] staging/android: add Doc for SW_SYNC ioctl interface
2016-08-11 Eric Engestrom : > On Thu, Aug 11, 2016 at 12:26:43PM -0300, Gustavo Padovan wrote: > > From: Gustavo Padovan > > > > This interface is hidden from kernel headers and it is intended for use > > only for testing. So testers would have to add the ioctl information > > internally. This is to prevent misuse of this feature. > > > > v2: take in Eric suggestions for the Documentation > > > > Signed-off-by: Gustavo Padovan > > Reviewed-by: Eric Engestrom > > --- > > drivers/staging/android/sw_sync.c | 31 +++ > > 1 file changed, 31 insertions(+) > > > > diff --git a/drivers/staging/android/sw_sync.c > > b/drivers/staging/android/sw_sync.c > > index 039e1f4..498ab55 100644 > > --- a/drivers/staging/android/sw_sync.c > > +++ b/drivers/staging/android/sw_sync.c > > @@ -25,6 +25,36 @@ > > #define CREATE_TRACE_POINTS > > #include "sync_trace.h" > > > > +/* > > + * SW SYNC validation framework > > + * > > + * A sync object driver that uses a 32bit counter to coordinate > > + * synchronization. Useful when there is no hardware primitive backing > > + * the synchronization. > > + * > > + * To start the framework just open: > > + * > > + * /sync/sw_sync > > + * > > + * That will create a sync timeline, all fences created under this timeline > > + * file descriptor will belong to the this timeline. > > + * > > + * The 'sw_sync' file can be opened many times as to create different > > + * timelines. > > + * > > + * Fences can be created with SW_SYNC_IOC_CREATE_FENCE ioctl with struct > > + * sw_sync_ioctl_create_fence as parameter. > > + * > > + * To increment the timeline counter, SW_SYNC_IOC_INC ioctl should be used > > + * with the increment as u32. This will update the last signaled value > > + * from the timeline and signal any fence that has seqno smaller of equal > > + * it. > > You didn't fix all of it: "that has a seqno smaller or equal to it." > Missing "a" (just noticed), s/of/or/, and missing "to" :) Oh. Right. I didn't pay attention to all your fixes in that phrase. Thanks. I'll send an updated patch. ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH] staging/android: add Doc for SW_SYNC ioctl interface
From: Gustavo Padovan This interface is hidden from kernel headers and it is intended for use only for testing. So testers would have to add the ioctl information internally. This is to prevent misuse of this feature. v2: take in Eric suggestions for the Documentation v3: really take in Eric suggestions Signed-off-by: Gustavo Padovan Reviewed-by: Eric Engestrom --- drivers/staging/android/sw_sync.c | 31 +++ 1 file changed, 31 insertions(+) diff --git a/drivers/staging/android/sw_sync.c b/drivers/staging/android/sw_sync.c index 039e1f4..62e8e6d 100644 --- a/drivers/staging/android/sw_sync.c +++ b/drivers/staging/android/sw_sync.c @@ -25,6 +25,36 @@ #define CREATE_TRACE_POINTS #include "sync_trace.h" +/* + * SW SYNC validation framework + * + * A sync object driver that uses a 32bit counter to coordinate + * synchronization. Useful when there is no hardware primitive backing + * the synchronization. + * + * To start the framework just open: + * + * /sync/sw_sync + * + * That will create a sync timeline, all fences created under this timeline + * file descriptor will belong to the this timeline. + * + * The 'sw_sync' file can be opened many times as to create different + * timelines. + * + * Fences can be created with SW_SYNC_IOC_CREATE_FENCE ioctl with struct + * sw_sync_ioctl_create_fence as parameter. + * + * To increment the timeline counter, SW_SYNC_IOC_INC ioctl should be used + * with the increment as u32. This will update the last signaled value + * from the timeline and signal any fence that has a seqno smaller or equal + * to it. + * + * struct sw_sync_ioctl_create_fence + * @value: the seqno to initialise the fence with + * @name: the name of the new sync point + * @fence: return the fd of the new sync_file with the created fence + */ struct sw_sync_create_fence_data { __u32 value; charname[32]; @@ -35,6 +65,7 @@ struct sw_sync_create_fence_data { #define SW_SYNC_IOC_CREATE_FENCE _IOWR(SW_SYNC_IOC_MAGIC, 0,\ struct sw_sync_create_fence_data) + #define SW_SYNC_IOC_INC_IOW(SW_SYNC_IOC_MAGIC, 1, __u32) static const struct fence_ops timeline_fence_ops; -- 2.5.5 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 5/6] staging: rtl8192u: r8192U_core: don't print error when allocating urb fails
kmalloc will print enough information in case of failure. Signed-off-by: Wolfram Sang --- drivers/staging/rtl8192u/r8192U_core.c | 5 + 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/staging/rtl8192u/r8192U_core.c b/drivers/staging/rtl8192u/r8192U_core.c index dd0970facdf5bd..7af1af8c6616f4 100644 --- a/drivers/staging/rtl8192u/r8192U_core.c +++ b/drivers/staging/rtl8192u/r8192U_core.c @@ -1702,11 +1702,8 @@ short rtl8192_tx(struct net_device *dev, struct sk_buff *skb) } if (bSend0Byte) { tx_urb_zero = usb_alloc_urb(0, GFP_ATOMIC); - if (!tx_urb_zero) { - RT_TRACE(COMP_ERR, -"can't alloc urb for zero byte\n"); + if (!tx_urb_zero) return -ENOMEM; - } usb_fill_bulk_urb(tx_urb_zero, udev, usb_sndbulkpipe(udev, idx_pipe), &zero, 0, tx_zero_isr, dev); -- 2.8.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 4/6] staging: most: hdm-usb: hdm_usb: don't print error when allocating urb fails
kmalloc will print enough information in case of failure. Signed-off-by: Wolfram Sang --- drivers/staging/most/hdm-usb/hdm_usb.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/staging/most/hdm-usb/hdm_usb.c b/drivers/staging/most/hdm-usb/hdm_usb.c index aeae071f282321..9ec29788c0471f 100644 --- a/drivers/staging/most/hdm-usb/hdm_usb.c +++ b/drivers/staging/most/hdm-usb/hdm_usb.c @@ -650,10 +650,8 @@ static int hdm_enqueue(struct most_interface *iface, int channel, return -ENODEV; urb = usb_alloc_urb(NO_ISOCHRONOUS_URB, GFP_ATOMIC); - if (!urb) { - dev_err(dev, "Failed to allocate URB\n"); + if (!urb) return -ENOMEM; - } anchor = kzalloc(sizeof(*anchor), GFP_ATOMIC); if (!anchor) { -- 2.8.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 1/6] staging: comedi: drivers: usbduxfast: don't print error when allocating urb fails
kmalloc will print enough information in case of failure. Signed-off-by: Wolfram Sang --- drivers/staging/comedi/drivers/usbduxfast.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/staging/comedi/drivers/usbduxfast.c b/drivers/staging/comedi/drivers/usbduxfast.c index 10f94ec3453606..608403c7586b76 100644 --- a/drivers/staging/comedi/drivers/usbduxfast.c +++ b/drivers/staging/comedi/drivers/usbduxfast.c @@ -946,10 +946,8 @@ static int usbduxfast_auto_attach(struct comedi_device *dev, } devpriv->urb = usb_alloc_urb(0, GFP_KERNEL); - if (!devpriv->urb) { - dev_err(dev->class_dev, "Could not alloc. urb\n"); + if (!devpriv->urb) return -ENOMEM; - } devpriv->inbuf = kmalloc(SIZEINBUF, GFP_KERNEL); if (!devpriv->inbuf) -- 2.8.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 6/6] staging: vt6656: main_usb: don't print error when allocating urb fails
kmalloc will print enough information in case of failure. Signed-off-by: Wolfram Sang --- drivers/staging/vt6656/main_usb.c | 12 +++- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/drivers/staging/vt6656/main_usb.c b/drivers/staging/vt6656/main_usb.c index ac4fecb30d0e9c..0594828bdabf92 100644 --- a/drivers/staging/vt6656/main_usb.c +++ b/drivers/staging/vt6656/main_usb.c @@ -440,10 +440,8 @@ static bool vnt_alloc_bufs(struct vnt_private *priv) /* allocate URBs */ tx_context->urb = usb_alloc_urb(0, GFP_KERNEL); - if (!tx_context->urb) { - dev_err(&priv->usb->dev, "alloc tx urb failed\n"); + if (!tx_context->urb) goto free_tx; - } tx_context->in_use = false; } @@ -462,10 +460,8 @@ static bool vnt_alloc_bufs(struct vnt_private *priv) /* allocate URBs */ rcb->urb = usb_alloc_urb(0, GFP_KERNEL); - if (!rcb->urb) { - dev_err(&priv->usb->dev, "Failed to alloc rx urb\n"); + if (!rcb->urb) goto free_rx_tx; - } rcb->skb = dev_alloc_skb(priv->rx_buf_sz); if (!rcb->skb) @@ -479,10 +475,8 @@ static bool vnt_alloc_bufs(struct vnt_private *priv) } priv->interrupt_urb = usb_alloc_urb(0, GFP_KERNEL); - if (!priv->interrupt_urb) { - dev_err(&priv->usb->dev, "Failed to alloc int urb\n"); + if (!priv->interrupt_urb) goto free_rx_tx; - } priv->int_buf.data_buf = kmalloc(MAX_INTERRUPT_SIZE, GFP_KERNEL); if (!priv->int_buf.data_buf) { -- 2.8.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 0/6] staging: don't print error when allocating urb fails
This per-subsystem series is part of a tree wide cleanup. usb_alloc_urb() uses kmalloc which already prints enough information on failure. So, let's simply remove those "allocation failed" messages from drivers like we did already for other -ENOMEM cases. gkh acked this approach when we talked about it at LCJ in Tokyo a few weeks ago. Wolfram Sang (6): staging: comedi: drivers: usbduxfast: don't print error when allocating urb fails staging: media: lirc: lirc_imon: don't print error when allocating urb fails staging: media: lirc: lirc_sasem: don't print error when allocating urb fails staging: most: hdm-usb: hdm_usb: don't print error when allocating urb fails staging: rtl8192u: r8192U_core: don't print error when allocating urb fails staging: vt6656: main_usb: don't print error when allocating urb fails drivers/staging/comedi/drivers/usbduxfast.c | 4 +--- drivers/staging/media/lirc/lirc_imon.c | 9 ++--- drivers/staging/media/lirc/lirc_sasem.c | 5 - drivers/staging/most/hdm-usb/hdm_usb.c | 4 +--- drivers/staging/rtl8192u/r8192U_core.c | 5 + drivers/staging/vt6656/main_usb.c | 12 +++- 6 files changed, 8 insertions(+), 31 deletions(-) -- 2.8.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 2/6] staging: media: lirc: lirc_imon: don't print error when allocating urb fails
kmalloc will print enough information in case of failure. Signed-off-by: Wolfram Sang --- drivers/staging/media/lirc/lirc_imon.c | 9 ++--- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/drivers/staging/media/lirc/lirc_imon.c b/drivers/staging/media/lirc/lirc_imon.c index ff1926ca1f96f5..a183e68ec32089 100644 --- a/drivers/staging/media/lirc/lirc_imon.c +++ b/drivers/staging/media/lirc/lirc_imon.c @@ -797,16 +797,11 @@ static int imon_probe(struct usb_interface *interface, goto free_rbuf; } rx_urb = usb_alloc_urb(0, GFP_KERNEL); - if (!rx_urb) { - dev_err(dev, "%s: usb_alloc_urb failed for IR urb\n", __func__); + if (!rx_urb) goto free_lirc_buf; - } tx_urb = usb_alloc_urb(0, GFP_KERNEL); - if (!tx_urb) { - dev_err(dev, "%s: usb_alloc_urb failed for display urb\n", - __func__); + if (!tx_urb) goto free_rx_urb; - } mutex_init(&context->ctx_lock); context->vfd_proto_6p = vfd_proto_6p; -- 2.8.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 3/6] staging: media: lirc: lirc_sasem: don't print error when allocating urb fails
kmalloc will print enough information in case of failure. Signed-off-by: Wolfram Sang --- drivers/staging/media/lirc/lirc_sasem.c | 5 - 1 file changed, 5 deletions(-) diff --git a/drivers/staging/media/lirc/lirc_sasem.c b/drivers/staging/media/lirc/lirc_sasem.c index 2218d0042030ed..b080fde6d740c9 100644 --- a/drivers/staging/media/lirc/lirc_sasem.c +++ b/drivers/staging/media/lirc/lirc_sasem.c @@ -758,17 +758,12 @@ static int sasem_probe(struct usb_interface *interface, } rx_urb = usb_alloc_urb(0, GFP_KERNEL); if (!rx_urb) { - dev_err(&interface->dev, - "%s: usb_alloc_urb failed for IR urb\n", __func__); alloc_status = 5; goto alloc_status_switch; } if (vfd_ep_found) { tx_urb = usb_alloc_urb(0, GFP_KERNEL); if (!tx_urb) { - dev_err(&interface->dev, - "%s: usb_alloc_urb failed for VFD urb", - __func__); alloc_status = 6; goto alloc_status_switch; } -- 2.8.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH] Staging: rtl8723au: os_intfs: fixed case statement is variable issue
On Aug 11, 2016, at 23:25, Jes Sorensen wrote: > Bing Sun writes: >> Fixed sparse parse error: >> Expected constant expression in case statement. >> >> Signed-off-by: Bing Sun >> --- >> drivers/staging/rtl8723au/os_dep/os_intfs.c | 11 +-- >> 1 file changed, 5 insertions(+), 6 deletions(-) >> >> diff --git a/drivers/staging/rtl8723au/os_dep/os_intfs.c >> b/drivers/staging/rtl8723au/os_dep/os_intfs.c >> index b8848c2..f30d5d2 100644 >> --- a/drivers/staging/rtl8723au/os_dep/os_intfs.c >> +++ b/drivers/staging/rtl8723au/os_dep/os_intfs.c >> @@ -283,14 +283,13 @@ static u32 rtw_classify8021d(struct sk_buff *skb) >> */ >> if (skb->priority >= 256 && skb->priority <= 263) >> return skb->priority - 256; >> -switch (skb->protocol) { >> -case htons(ETH_P_IP): >> + >> +if (skb->protocol == htons(ETH_P_IP)) { >> dscp = ip_hdr(skb)->tos & 0xfc; >> -break; >> -default: >> -return 0; >> +return dscp >> 5; >> } >> -return dscp >> 5; >> + >> +return 0; >> } > > Pardon me here, but I find it really hard to see how this change is an > improvement over the old code in any shape or form. > > Jes There is no functional improvement. But before this patch, when we do: make C=1 M=drivers/staging/rtl8723au/ An error output: drivers/staging/rtl8723au//os_dep/os_intfs.c:287:14: error: Expected constant expression in case statement To avoid sparse parse error, a case statement converts to an if statement. So we got this patch. ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel