RE: [PATCH v2 10/27] staging: unisys: visorinput: remove unnecessary locking
> -Original Message- > From: Thomas Gleixner [mailto:t...@linutronix.de] > Sent: Wednesday, June 01, 2016 2:41 AM > To: Kershner, David A > Cc: cor...@lwn.net; mi...@redhat.com; h...@zytor.com; > gre...@linuxfoundation.org; Arfvidson, Erik; Sell, Timothy C; > hof...@osadl.org; dzic...@redhat.com; jes.soren...@redhat.com; Curtin, > Alexander Paul; janani.rvchn...@gmail.com; > sudipm.mukher...@gmail.com; pra...@redhat.com; Binder, David Anthony; > nhor...@redhat.com; dan.j.willi...@intel.com; linux- > ker...@vger.kernel.org; linux-...@vger.kernel.org; driverdev- > de...@linuxdriverproject.org; *S-Par-Maintainer > Subject: Re: [PATCH v2 10/27] staging: unisys: visorinput: remove > unnecessary locking > > On Tue, 31 May 2016, David Kershner wrote: > > + /* > > +* If we're not paused, really enable interrupts. > > +* Regardless of whether we are paused, set a flag indicating > > +* interrupts should be enabled so when we resume, interrupts > > +* will really be enabled. > > +*/ > > + down_write(&devdata->lock_visor_dev); > > Why is this a rw_semaphore? It's only ever taken with down_write() and it's > always the same context. Should be a mutex, right? > Correct. We have a local patch that addresses this, but would like to submit this via a follow-on patchset if possible. I'll explain. Rationale: our intent for this patchset was to focus on the visorbus driver ONLY. The only reason visorinput got involved in the first place was due to the visorbus change that necessitated that we remove the locking from visorinput_channel_interrupt(), due to that now being called from atomic context. If the semaphore --> mutex change would have been as simple as it sounds, we would have had NO problem including it with the next version (v3) of this patchset. But unfortunately, this change uncovered a latent defect, which necessitated yet another patch. (I know... hard to believe that something this simple would do that, but it did.) Rather than further complicating this patchset, we thought it would be better to address the visorinput issues via a separate follow-on patchset. Is that acceptable for you? > While at it, please convert the notifier_lock to a mutex as well. Thanks. Since this is visorbus-specific, we DO plan to address this in v3 of this patchset, which will most-likely just be REMOVING notifier_lock altogether. Tim Sell > > Thanks, > > tglx ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
RE: [Linaro-mm-sig] [RFC][PATCH 1/3] staging: ion: Move away from the DMA APIs for cache flushing
Hi Laura, It seems that outer cache is needed to be handled after __cpuc_flush_dcache_area() for ARM platform. Please correct me if I am wrong. Thanks Xiaoquan -Original Message- From: Linaro-mm-sig [mailto:linaro-mm-sig-boun...@lists.linaro.org] On Behalf Of Laura Abbott Sent: 2016年5月26日 3:48 To: Sumit Semwal; John Stultz; Arve Hjønnevåg; Riley Andrews Cc: de...@driverdev.osuosl.org; Jon Medhurst; Android Kernel Team; Greg Kroah-Hartman; Will Deacon; Russell King; linux-ker...@vger.kernel.org; linaro-mm-...@lists.linaro.org; Rohit kumar; Jeremy Gebben; Eun Taik Lee; Catalin Marinas; Liviu Dudau; Laura Abbott; linux-arm-ker...@lists.infradead.org Subject: [Linaro-mm-sig] [RFC][PATCH 1/3] staging: ion: Move away from the DMA APIs for cache flushing Ion is currently using the DMA APIs in non-compliant ways for cache maintaince. The issue is Ion needs to do cache operations outside of the regular DMA model. The Ion model matches more closely with the DRM model which calls cache APIs directly. Add an appropriate abstraction layer for Ion to call cache operations outside of the DMA API. Signed-off-by: Laura Abbott --- drivers/staging/android/ion/Kconfig | 14 - drivers/staging/android/ion/Makefile| 3 + drivers/staging/android/ion/ion-arm.c | 83 + drivers/staging/android/ion/ion-arm64.c | 46 ++ drivers/staging/android/ion/ion-x86.c | 34 ++ drivers/staging/android/ion/ion.c | 59 ++ drivers/staging/android/ion/ion_carveout_heap.c | 5 +- drivers/staging/android/ion/ion_chunk_heap.c| 7 +-- drivers/staging/android/ion/ion_page_pool.c | 3 +- drivers/staging/android/ion/ion_priv.h | 14 ++--- drivers/staging/android/ion/ion_system_heap.c | 5 +- 11 files changed, 210 insertions(+), 63 deletions(-) create mode 100644 drivers/staging/android/ion/ion-arm.c create mode 100644 drivers/staging/android/ion/ion-arm64.c create mode 100644 drivers/staging/android/ion/ion-x86.c diff --git a/drivers/staging/android/ion/Kconfig b/drivers/staging/android/ion/Kconfig index 19c1572..c1b1813 100644 --- a/drivers/staging/android/ion/Kconfig +++ b/drivers/staging/android/ion/Kconfig @@ -1,6 +1,6 @@ menuconfig ION bool "Ion Memory Manager" - depends on HAVE_MEMBLOCK && HAS_DMA && MMU + depends on HAVE_MEMBLOCK && HAS_DMA && MMU && (X86 || ARM || ARM64) select GENERIC_ALLOCATOR select DMA_SHARED_BUFFER ---help--- @@ -10,6 +10,18 @@ menuconfig ION If you're not using Android its probably safe to say N here. +config ION_ARM + depends on ION && ARM + def_bool y + +config ION_ARM64 + depends on ION && ARM64 + def_bool y + +config ION_X86 + depends on ION && X86 + def_bool y + config ION_TEST tristate "Ion Test Device" depends on ION diff --git a/drivers/staging/android/ion/Makefile b/drivers/staging/android/ion/Makefile index 18cc2aa..1b82bb5 100644 --- a/drivers/staging/android/ion/Makefile +++ b/drivers/staging/android/ion/Makefile @@ -1,5 +1,8 @@ obj-$(CONFIG_ION) += ion.o ion_heap.o ion_page_pool.o ion_system_heap.o \ ion_carveout_heap.o ion_chunk_heap.o ion_cma_heap.o +obj-$(CONFIG_ION_X86) += ion-x86.o +obj-$(CONFIG_ION_ARM) += ion-arm.o +obj-$(CONFIG_ION_ARM64) += ion-arm64.o obj-$(CONFIG_ION_TEST) += ion_test.o ifdef CONFIG_COMPAT obj-$(CONFIG_ION) += compat_ion.o diff --git a/drivers/staging/android/ion/ion-arm.c b/drivers/staging/android/ion/ion-arm.c new file mode 100644 index 000..b91287f --- /dev/null +++ b/drivers/staging/android/ion/ion-arm.c @@ -0,0 +1,83 @@ +/* + * Copyright (C) 2016 Laura Abbott + * + * This software is licensed under the terms of the GNU General Public + * License version 2, as published by the Free Software Foundation, and + * may be copied, distributed, and modified under those terms. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ + +#include +#include +#include +#include + +#include + +#include "ion_priv.h" + + +void ion_clean_page(struct page *page, size_t size) +{ + unsigned long pfn; + size_t left = size; + + pfn = page_to_pfn(page); + + /* +* A single sg entry may refer to multiple physically contiguous +* pages. But we still need to process highmem pages individually. +* If highmem is not configured then the bulk of this loop gets +* optimized out. +*/ + do { + size_t len = left; + void *vaddr; + + page = pfn_to_page(pfn); + + if (PageHighMem(page)) { + if (len > PAGE_SIZE) +
[PATCH 4/6] staging: comedi: addi_apci_1564: rewrite the timer subdevice support
The support functions for the timer subdevice are broken. 1) The (*insn_write) assumes that insn->n is always 2 (data[1] is used) 2) The (*insn_read) assumes that insn->n is always 2 (data can be returned in data[0] and data[1]). 3) The (*insn_config) does not follow the API. It assumes insn->n is always 4 (data[1], data[2] and data[3] are used). It also doesn't use data[0] to determine what the config "instruction" is. Rewrite the code to follow the comedi API and add the missing comedi driver comment block. The new implementation is based on the (minimal) datasheet I have from ADDI-DATA. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Cc: Greg Kroah-Hartman --- .../comedi/drivers/addi-data/hwdrv_apci1564.c | 91 --- drivers/staging/comedi/drivers/addi_apci_1564.c| 129 + 2 files changed, 129 insertions(+), 91 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c index d6b2880..a1df66d 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c @@ -1,94 +1,3 @@ -static int apci1564_timer_insn_config(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, - unsigned int *data) -{ - struct apci1564_private *devpriv = dev->private; - unsigned int ctrl; - - /* Stop the timer */ - ctrl = inl(devpriv->timer + ADDI_TCW_CTRL_REG); - ctrl &= ~(ADDI_TCW_CTRL_GATE | ADDI_TCW_CTRL_TRIG | - ADDI_TCW_CTRL_ENA); - outl(ctrl, devpriv->timer + ADDI_TCW_CTRL_REG); - - if (data[1] == 1) { - /* Enable timer int & disable all the other int sources */ - outl(ADDI_TCW_CTRL_IRQ_ENA, -devpriv->timer + ADDI_TCW_CTRL_REG); - outl(0x0, dev->iobase + APCI1564_DI_IRQ_REG); - outl(0x0, dev->iobase + APCI1564_DO_IRQ_REG); - outl(0x0, dev->iobase + APCI1564_WDOG_IRQ_REG); - if (devpriv->counters) { - unsigned long iobase; - - iobase = devpriv->counters + ADDI_TCW_IRQ_REG; - outl(0x0, iobase + APCI1564_COUNTER(0)); - outl(0x0, iobase + APCI1564_COUNTER(1)); - outl(0x0, iobase + APCI1564_COUNTER(2)); - } - } else { - /* disable Timer interrupt */ - outl(0x0, devpriv->timer + ADDI_TCW_CTRL_REG); - } - - /* Loading Timebase */ - outl(data[2], devpriv->timer + ADDI_TCW_TIMEBASE_REG); - - /* Loading the Reload value */ - outl(data[3], devpriv->timer + ADDI_TCW_RELOAD_REG); - - ctrl = inl(devpriv->timer + ADDI_TCW_CTRL_REG); - ctrl &= ~(ADDI_TCW_CTRL_CNTR_ENA | ADDI_TCW_CTRL_MODE_MASK | - ADDI_TCW_CTRL_GATE | ADDI_TCW_CTRL_TRIG | - ADDI_TCW_CTRL_TIMER_ENA | ADDI_TCW_CTRL_RESET_ENA | - ADDI_TCW_CTRL_WARN_ENA | ADDI_TCW_CTRL_ENA); - ctrl |= ADDI_TCW_CTRL_MODE(2) | ADDI_TCW_CTRL_TIMER_ENA; - outl(ctrl, devpriv->timer + ADDI_TCW_CTRL_REG); - - return insn->n; -} - -static int apci1564_timer_insn_write(struct comedi_device *dev, -struct comedi_subdevice *s, -struct comedi_insn *insn, -unsigned int *data) -{ - struct apci1564_private *devpriv = dev->private; - unsigned int ctrl; - - ctrl = inl(devpriv->timer + ADDI_TCW_CTRL_REG); - ctrl &= ~(ADDI_TCW_CTRL_GATE | ADDI_TCW_CTRL_TRIG); - switch (data[1]) { - case 0: /* Stop The Timer */ - ctrl &= ~ADDI_TCW_CTRL_ENA; - break; - case 1: /* Enable the Timer */ - ctrl |= ADDI_TCW_CTRL_ENA; - break; - } - outl(ctrl, devpriv->timer + ADDI_TCW_CTRL_REG); - - return insn->n; -} - -static int apci1564_timer_insn_read(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, - unsigned int *data) -{ - struct apci1564_private *devpriv = dev->private; - - /* Stores the status of the Timer */ - data[0] = inl(devpriv->timer + ADDI_TCW_STATUS_REG) & - ADDI_TCW_STATUS_OVERFLOW; - - /* Stores the Actual value of the Timer */ - data[1] = inl(devpriv->timer + ADDI_TCW_VAL_REG); - - return insn->n; -} - static int apci1564_counter_insn_config(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, diff --git a/drivers/staging/comedi/drivers/addi_
[PATCH 3/6] staging: comedi: addi_apci_1564: use comedi_handle_event() for counters
The counter subdevice can generate an interrupt. Currently send_sig() is used to let the task know when the interrupt occurs. Use the dev->read_subdev and comedi_handle_events() instead. Remove the, now unused, 'tsk_current' member from the private data and the unnecessary include of . Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Cc: Greg Kroah-Hartman --- .../staging/comedi/drivers/addi-data/hwdrv_apci1564.c| 4 drivers/staging/comedi/drivers/addi_apci_1564.c | 16 ++-- 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c index f0c0d58..d6b2880 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c @@ -6,8 +6,6 @@ static int apci1564_timer_insn_config(struct comedi_device *dev, struct apci1564_private *devpriv = dev->private; unsigned int ctrl; - devpriv->tsk_current = current; - /* Stop the timer */ ctrl = inl(devpriv->timer + ADDI_TCW_CTRL_REG); ctrl &= ~(ADDI_TCW_CTRL_GATE | ADDI_TCW_CTRL_TRIG | @@ -101,8 +99,6 @@ static int apci1564_counter_insn_config(struct comedi_device *dev, unsigned long iobase = devpriv->counters + APCI1564_COUNTER(chan); unsigned int ctrl; - devpriv->tsk_current = current; - /* Stop The Timer */ ctrl = inl(iobase + ADDI_TCW_CTRL_REG); ctrl &= ~(ADDI_TCW_CTRL_GATE | ADDI_TCW_CTRL_TRIG | diff --git a/drivers/staging/comedi/drivers/addi_apci_1564.c b/drivers/staging/comedi/drivers/addi_apci_1564.c index d7b920e..259d249 100644 --- a/drivers/staging/comedi/drivers/addi_apci_1564.c +++ b/drivers/staging/comedi/drivers/addi_apci_1564.c @@ -23,7 +23,6 @@ #include #include -#include #include "../comedi_pci.h" #include "addi_tcw.h" @@ -118,6 +117,7 @@ */ #define APCI1564_EVENT_COS BIT(31) #define APCI1564_EVENT_TIMER BIT(30) +#define APCI1564_EVENT_COUNTER(x) BIT(27 + (x)) /* counter 0-2 */ #define APCI1564_EVENT_MASK0xffff /* all but [19:4] */ struct apci1564_private { @@ -127,7 +127,6 @@ struct apci1564_private { unsigned int mode1; /* riding-edge/high level channels */ unsigned int mode2; /* falling-edge/low level channels */ unsigned int ctrl; /* interrupt mode OR (edge) . AND (level) */ - struct task_struct *tsk_current; }; #include "addi-data/hwdrv_apci1564.c" @@ -198,21 +197,18 @@ static irqreturn_t apci1564_interrupt(int irq, void *d) } if (devpriv->counters) { - for (chan = 0; chan < 4; chan++) { + for (chan = 0; chan < 3; chan++) { unsigned long iobase; iobase = devpriv->counters + APCI1564_COUNTER(chan); status = inl(iobase + ADDI_TCW_IRQ_REG); - if (status & 0x01) { - /* Disable Counter Interrupt */ + if (status & ADDI_TCW_IRQ) { + s->state |= APCI1564_EVENT_COUNTER(chan); + + /* clear the interrupt */ ctrl = inl(iobase + ADDI_TCW_CTRL_REG); outl(0x0, iobase + ADDI_TCW_CTRL_REG); - - /* Send a signal to from kernel to user space */ - send_sig(SIGIO, devpriv->tsk_current, 0); - - /* Enable Counter Interrupt */ outl(ctrl, iobase + ADDI_TCW_CTRL_REG); } } -- 2.8.2 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 5/6] staging: comedi: addi_apci_1564: rewrite the counter subdevice support
Like the timer, the support functions for the counter subdevice are broken. Rewrite the code to follow the comedi API. The new implementation is based on the (minimal) datasheet I have from ADDI-DATA. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Cc: Greg Kroah-Hartman --- .../comedi/drivers/addi-data/hwdrv_apci1564.c | 92 - drivers/staging/comedi/drivers/addi_apci_1564.c| 94 +- 2 files changed, 92 insertions(+), 94 deletions(-) delete mode 100644 drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c deleted file mode 100644 index a1df66d..000 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c +++ /dev/null @@ -1,92 +0,0 @@ -static int apci1564_counter_insn_config(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, - unsigned int *data) -{ - struct apci1564_private *devpriv = dev->private; - unsigned int chan = CR_CHAN(insn->chanspec); - unsigned long iobase = devpriv->counters + APCI1564_COUNTER(chan); - unsigned int ctrl; - - /* Stop The Timer */ - ctrl = inl(iobase + ADDI_TCW_CTRL_REG); - ctrl &= ~(ADDI_TCW_CTRL_GATE | ADDI_TCW_CTRL_TRIG | - ADDI_TCW_CTRL_ENA); - outl(ctrl, iobase + ADDI_TCW_CTRL_REG); - - /* Set the reload value */ - outl(data[3], iobase + ADDI_TCW_RELOAD_REG); - - /* Set the mode */ - ctrl &= ~(ADDI_TCW_CTRL_EXT_CLK_MASK | ADDI_TCW_CTRL_MODE_MASK | - ADDI_TCW_CTRL_TIMER_ENA | ADDI_TCW_CTRL_RESET_ENA | - ADDI_TCW_CTRL_WARN_ENA); - ctrl |= ADDI_TCW_CTRL_CNTR_ENA | ADDI_TCW_CTRL_MODE(data[4]); - outl(ctrl, iobase + ADDI_TCW_CTRL_REG); - - /* Enable or Disable Interrupt */ - if (data[1]) - ctrl |= ADDI_TCW_CTRL_IRQ_ENA; - else - ctrl &= ~ADDI_TCW_CTRL_IRQ_ENA; - outl(ctrl, iobase + ADDI_TCW_CTRL_REG); - - /* Set the Up/Down selection */ - if (data[6]) - ctrl |= ADDI_TCW_CTRL_CNT_UP; - else - ctrl &= ~ADDI_TCW_CTRL_CNT_UP; - outl(ctrl, iobase + ADDI_TCW_CTRL_REG); - - return insn->n; -} - -static int apci1564_counter_insn_write(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, - unsigned int *data) -{ - struct apci1564_private *devpriv = dev->private; - unsigned int chan = CR_CHAN(insn->chanspec); - unsigned long iobase = devpriv->counters + APCI1564_COUNTER(chan); - unsigned int ctrl; - - ctrl = inl(iobase + ADDI_TCW_CTRL_REG); - ctrl &= ~(ADDI_TCW_CTRL_GATE | ADDI_TCW_CTRL_TRIG); - switch (data[1]) { - case 0: /* Stops the Counter subdevice */ - ctrl = 0; - break; - case 1: /* Start the Counter subdevice */ - ctrl |= ADDI_TCW_CTRL_ENA; - break; - case 2: /* Clears the Counter subdevice */ - ctrl |= ADDI_TCW_CTRL_GATE; - break; - } - outl(ctrl, iobase + ADDI_TCW_CTRL_REG); - - return insn->n; -} - -static int apci1564_counter_insn_read(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, - unsigned int *data) -{ - struct apci1564_private *devpriv = dev->private; - unsigned int chan = CR_CHAN(insn->chanspec); - unsigned long iobase = devpriv->counters + APCI1564_COUNTER(chan); - unsigned int status; - - /* Read the Counter Actual Value. */ - data[0] = inl(iobase + ADDI_TCW_VAL_REG); - - status = inl(iobase + ADDI_TCW_STATUS_REG); - data[1] = (status & ADDI_TCW_STATUS_SOFT_TRIG) ? 1 : 0; - data[2] = (status & ADDI_TCW_STATUS_HARDWARE_TRIG) ? 1 : 0; - data[3] = (status & ADDI_TCW_STATUS_SOFT_CLR) ? 1 : 0; - data[4] = (status & ADDI_TCW_STATUS_OVERFLOW) ? 1 : 0; - - return insn->n; -} diff --git a/drivers/staging/comedi/drivers/addi_apci_1564.c b/drivers/staging/comedi/drivers/addi_apci_1564.c index 32b2596..e59af41 100644 --- a/drivers/staging/comedi/drivers/addi_apci_1564.c +++ b/drivers/staging/comedi/drivers/addi_apci_1564.c @@ -67,6 +67,12 @@ * the raw data[1] to this register along with the raw data[2] value to the * ADDI_TCW_RELOAD_REG. If anyone tests this and can determine the actual * timebase/reload operation please let me know. + * + * The counter subdevice also does not use an async command. All control is + * handled by the (*insn_config). + * + * FIXME: The operation o
[PATCH 6/6] staging: comedi: addi_apci_1564: remove unnecessary wdog register defines
The watchdog subdevice is supported using the addi_watchdog module and it uses the register defines from addi_tcw.h. The only register define needed it the iobase offset to the register block. Remove the unnecessary defines and rename the iobase define. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Cc: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/addi_apci_1564.c | 13 +++-- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi_apci_1564.c b/drivers/staging/comedi/drivers/addi_apci_1564.c index e59af41..0f853b1 100644 --- a/drivers/staging/comedi/drivers/addi_apci_1564.c +++ b/drivers/staging/comedi/drivers/addi_apci_1564.c @@ -144,14 +144,7 @@ #define APCI1564_DO_INT_STATUS_VCC BIT(0) #define APCI1564_DO_IRQ_REG0x20 #define APCI1564_DO_IRQ_INTR BIT(0) -#define APCI1564_WDOG_REG 0x24 -#define APCI1564_WDOG_RELOAD_REG 0x28 -#define APCI1564_WDOG_TIMEBASE_REG 0x2c -#define APCI1564_WDOG_CTRL_REG 0x30 -#define APCI1564_WDOG_STATUS_REG 0x34 -#define APCI1564_WDOG_IRQ_REG 0x38 -#define APCI1564_WDOG_WARN_TIMEVAL_REG 0x3c -#define APCI1564_WDOG_WARN_TIMEBASE_REG0x40 +#define APCI1564_WDOG_IOBASE 0x24 /* * devpriv->timer Register Map (see addi_tcw.h for register/bit defines) @@ -198,7 +191,7 @@ static int apci1564_reset(struct comedi_device *dev) outl(0x0, dev->iobase + APCI1564_DO_INT_CTRL_REG); /* Reset the watchdog registers */ - addi_watchdog_reset(dev->iobase + APCI1564_WDOG_REG); + addi_watchdog_reset(dev->iobase + APCI1564_WDOG_IOBASE); /* Reset the timer registers */ outl(0x0, devpriv->timer + ADDI_TCW_CTRL_REG); @@ -771,7 +764,7 @@ static int apci1564_auto_attach(struct comedi_device *dev, /* Initialize the watchdog subdevice */ s = &dev->subdevices[5]; - ret = addi_watchdog_init(s, dev->iobase + APCI1564_WDOG_REG); + ret = addi_watchdog_init(s, dev->iobase + APCI1564_WDOG_IOBASE); if (ret) return ret; -- 2.8.2 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 1/6] staging: comedi: addi_apci_1564: clarify change-of-state interrupt support
This board supports change-of-state interrupts on digital inputs 4 to 19 not 0 to 15. The current code "works" but it could set inappropriate bits in the mode1 and mode2 registers that setup which channels are enabled. It also doesn't return the status of the upper 4 channels (19 to 16). Fix the comment and mask the mode1/mode2 values so that only the interrupt capable channels can be enabled. Add the SDF_LSAMPL flag to the subdevice so that 32-bit samples are used instead of 16-bit ones. This allows returning the upper 4 channels. Use the remaining bits in the sample to return "event" flags to the user. The timer and counter subdevices can also generate interrupts and are a bit hacked. They don't currently follow the comedi API and they use send_sig() to let the task that know that the interrupt occured. The "event" flags will be used instead when these subdevices are fixed. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Cc: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/addi_apci_1564.c | 37 + 1 file changed, 26 insertions(+), 11 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi_apci_1564.c b/drivers/staging/comedi/drivers/addi_apci_1564.c index f1ccfbd..37e18b3 100644 --- a/drivers/staging/comedi/drivers/addi_apci_1564.c +++ b/drivers/staging/comedi/drivers/addi_apci_1564.c @@ -77,6 +77,7 @@ #define APCI1564_DI_REG0x00 #define APCI1564_DI_INT_MODE1_REG 0x04 #define APCI1564_DI_INT_MODE2_REG 0x08 +#define APCI1564_DI_INT_MODE_MASK 0x0000 /* chans [19:4] */ #define APCI1564_DI_INT_STATUS_REG 0x0c #define APCI1564_DI_IRQ_REG0x10 #define APCI1564_DI_IRQ_ENABIT(2) @@ -111,6 +112,13 @@ */ #define APCI1564_COUNTER(x)((x) * 0x20) +/* + * The dev->read_subdev is used to return the interrupt events along with + * the state of the interrupt capable inputs. + */ +#define APCI1564_EVENT_COS BIT(31) +#define APCI1564_EVENT_MASK0xffff /* all but [19:4] */ + struct apci1564_private { unsigned long eeprom; /* base address of EEPROM register */ unsigned long timer;/* base address of 12-bit timer */ @@ -165,18 +173,16 @@ static irqreturn_t apci1564_interrupt(int irq, void *d) unsigned int ctrl; unsigned int chan; + s->state &= ~APCI1564_EVENT_MASK; + status = inl(dev->iobase + APCI1564_DI_IRQ_REG); if (status & APCI1564_DI_IRQ_ENA) { - /* disable the interrupt */ + s->state = inl(dev->iobase + APCI1564_DI_INT_STATUS_REG); + s->state |= APCI1564_EVENT_COS; + + /* clear the interrupt */ outl(status & ~APCI1564_DI_IRQ_ENA, dev->iobase + APCI1564_DI_IRQ_REG); - - s->state = inl(dev->iobase + APCI1564_DI_INT_STATUS_REG) & - 0x; - comedi_buf_write_samples(s, &s->state, 1); - comedi_handle_events(dev, s); - - /* enable the interrupt */ outl(status, dev->iobase + APCI1564_DI_IRQ_REG); } @@ -214,6 +220,11 @@ static irqreturn_t apci1564_interrupt(int irq, void *d) } } + if (s->state & APCI1564_EVENT_MASK) { + comedi_buf_write_samples(s, &s->state, 1); + comedi_handle_events(dev, s); + } + return IRQ_HANDLED; } @@ -255,7 +266,7 @@ static int apci1564_diag_insn_bits(struct comedi_device *dev, /* * Change-Of-State (COS) interrupt configuration * - * Channels 0 to 15 are interruptible. These channels can be configured + * Channels 4 to 19 are interruptible. These channels can be configured * to generate interrupts based on AND/OR logic for the desired channels. * * OR logic @@ -343,6 +354,10 @@ static int apci1564_cos_insn_config(struct comedi_device *dev, default: return -EINVAL; } + + /* ensure the mode bits are in-range for channels [19:4] */ + devpriv->mode1 &= APCI1564_DI_INT_MODE_MASK; + devpriv->mode2 &= APCI1564_DI_INT_MODE_MASK; break; default: return -EINVAL; @@ -409,7 +424,7 @@ static int apci1564_cos_cmd(struct comedi_device *dev, { struct apci1564_private *devpriv = dev->private; - if (!devpriv->ctrl) { + if (!devpriv->ctrl && !(devpriv->mode1 || devpriv->mode2)) { dev_warn(dev->class_dev, "Interrupts disabled due to mode configuration!\n"); return -EINVAL; @@ -501,7 +516,7 @@ static int apci1564_auto_attach(struct comedi_device *dev, if (dev->irq) { dev->read_subdev = s; s->type = COMEDI_SUBD_DI; - s->subdev_flags = SDF_READABLE | SDF_CMD_R
[PATCH 0/6] staging: comedi: addi_apci_1564: cleanup driver
This driver still uses some of old broken code in hwdrv_apci1564.c for the timer and counter subdevices. This code does not follow the comedi API and does not work without additional patches to the core. Tidy up the change-of-state support so that the dev->read_subdev can be used to handle the interrupt events from the timer and counter subdevices. Rewrite the timer and counter subdevice support so that it follows the comedi API. NOTE: The datasheet I have from ADDI-DATA just describes the registers. It does not have any functional information on the operation of the timer or counter. The new code might not work _correctly_ but it at least makes the subdevices work with the comedi API so that additional testing can be done. H Hartley Sweeten (6): staging: comedi: addi_apci_1564: clarify change-of-state interrupt support staging: comedi: addi_apci_1564: use comedi_handle_event() for timer staging: comedi: addi_apci_1564: use comedi_handle_event() for counters staging: comedi: addi_apci_1564: rewrite the timer subdevice support staging: comedi: addi_apci_1564: rewrite the counter subdevice support staging: comedi: addi_apci_1564: remove unnecessary wdog register defines .../comedi/drivers/addi-data/hwdrv_apci1564.c | 187 - drivers/staging/comedi/drivers/addi_apci_1564.c| 301 ++--- 2 files changed, 261 insertions(+), 227 deletions(-) delete mode 100644 drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c -- 2.8.2 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 2/6] staging: comedi: addi_apci_1564: use comedi_handle_event() for timer
The timer subdevice can generate an interrupt. Currently send_sig() is used to let the task know when the interrupt occurs. Use the dev->read_subdev and comedi_handle_events() instead. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Cc: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/addi_apci_1564.c | 12 +--- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi_apci_1564.c b/drivers/staging/comedi/drivers/addi_apci_1564.c index 37e18b3..d7b920e 100644 --- a/drivers/staging/comedi/drivers/addi_apci_1564.c +++ b/drivers/staging/comedi/drivers/addi_apci_1564.c @@ -117,6 +117,7 @@ * the state of the interrupt capable inputs. */ #define APCI1564_EVENT_COS BIT(31) +#define APCI1564_EVENT_TIMER BIT(30) #define APCI1564_EVENT_MASK0xffff /* all but [19:4] */ struct apci1564_private { @@ -187,15 +188,12 @@ static irqreturn_t apci1564_interrupt(int irq, void *d) } status = inl(devpriv->timer + ADDI_TCW_IRQ_REG); - if (status & 0x01) { - /* Disable Timer Interrupt */ + if (status & ADDI_TCW_IRQ) { + s->state |= APCI1564_EVENT_TIMER; + + /* clear the interrupt */ ctrl = inl(devpriv->timer + ADDI_TCW_CTRL_REG); outl(0x0, devpriv->timer + ADDI_TCW_CTRL_REG); - - /* Send a signal to from kernel to user space */ - send_sig(SIGIO, devpriv->tsk_current, 0); - - /* Enable Timer Interrupt */ outl(ctrl, devpriv->timer + ADDI_TCW_CTRL_REG); } -- 2.8.2 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH net-next] hv_netvsc: Fix VF register on vlan devices
Added a condition to avoid vlan devices with same MAC registering as VF. Signed-off-by: Haiyang Zhang Reviewed-by: K. Y. Srinivasan --- drivers/net/hyperv/netvsc_drv.c |4 1 files changed, 4 insertions(+), 0 deletions(-) diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c index 6a69b5c..5ac1267 100644 --- a/drivers/net/hyperv/netvsc_drv.c +++ b/drivers/net/hyperv/netvsc_drv.c @@ -1500,6 +1500,10 @@ static int netvsc_netdev_event(struct notifier_block *this, { struct net_device *event_dev = netdev_notifier_info_to_dev(ptr); + /* Avoid Vlan dev with same MAC registering as VF */ + if (event_dev->priv_flags & IFF_802_1Q_VLAN) + return NOTIFY_DONE; + switch (event) { case NETDEV_REGISTER: return netvsc_register_vf(event_dev); -- 1.7.4.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH v2 0/4] *** rtl8712: Replace semaphores with mutex / completions ***
On 06/02/2016 02:43 AM, Arnd Bergmann wrote: On Thursday, June 2, 2016 9:54:06 AM CEST Binoy Jayan wrote: Hi, These are a set of patches [v2] which removes semaphores from: drivers/staging/rtl8712 They build correctly (individually and as a whole). NB: I have not tested this as I do not have the following hardware: "RealTek RTL8712U (RTL8192SU) Wireless LAN NIC driver" Rework on comments w.r.t. PATCH v1: - Removed wrapper functions _wait_completion, _down_sema and _enter_pwrlock - Updated changelog to explain use of mutex_lock instead of mutex_lock_interruptible in [PATCH v2 4/4] All four look great now, Reviewed-by: Arnd Bergmann I agree. Tested-by: Larry Finger Larry ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH v2 10/27] staging: unisys: visorinput: remove unnecessary locking
On Thu, Jun 02, 2016 at 05:02:11AM +, Sell, Timothy C wrote: > > -Original Message- > > From: Neil Horman [mailto:nhor...@redhat.com] > > Sent: Wednesday, June 01, 2016 2:43 PM > > To: Sell, Timothy C > > Cc: Kershner, David A; cor...@lwn.net; t...@linutronix.de; > > mi...@redhat.com; h...@zytor.com; gre...@linuxfoundation.org; > > Arfvidson, Erik; hof...@osadl.org; dzic...@redhat.com; > > jes.soren...@redhat.com; Curtin, Alexander Paul; > > janani.rvchn...@gmail.com; sudipm.mukher...@gmail.com; > > pra...@redhat.com; Binder, David Anthony; dan.j.willi...@intel.com; > > linux-ker...@vger.kernel.org; linux-...@vger.kernel.org; driverdev- > > de...@linuxdriverproject.org; *S-Par-Maintainer > > Subject: Re: [PATCH v2 10/27] staging: unisys: visorinput: remove > > unnecessary locking > > > > On Wed, Jun 01, 2016 at 03:09:13PM +, Sell, Timothy C wrote: > > > > -Original Message- > > > > From: Neil Horman [mailto:nhor...@redhat.com] > > > > Sent: Wednesday, June 01, 2016 10:18 AM > > > > To: Kershner, David A > > > > Cc: cor...@lwn.net; t...@linutronix.de; mi...@redhat.com; > > > > h...@zytor.com; gre...@linuxfoundation.org; Arfvidson, Erik; Sell, > > Timothy > > > > C; hof...@osadl.org; dzic...@redhat.com; jes.soren...@redhat.com; > > > > Curtin, Alexander Paul; janani.rvchn...@gmail.com; > > > > sudipm.mukher...@gmail.com; pra...@redhat.com; Binder, David > > Anthony; > > > > dan.j.willi...@intel.com; linux-ker...@vger.kernel.org; linux- > > > > d...@vger.kernel.org; driverdev-devel@linuxdriverproject.org; *S-Par- > > > > Maintainer > > > > Subject: Re: [PATCH v2 10/27] staging: unisys: visorinput: remove > > > > unnecessary locking > > > > > > > > On Tue, May 31, 2016 at 10:26:36PM -0400, David Kershner wrote: > > > > > From: Tim Sell > > > > > > > > > > Locking in the _interrupt() function is NOT necessary so long as we > > ensure > > > > > that interrupts have been stopped whenever we need to pause or > > resume > > > > the > > > > > device, which we now do. > > > > > > > > > > While a device is paused, we ensure that interrupts stay disabled, > > > > > i.e. > > > > > that the _interrupt() function will NOT be called, yet remember the > > > > desired > > > > > state in devdata->interrupts_enabled if open() or close() are called > > > > > are > > > > > called while the device is paused. Then when the device is resumed, > > we > > > > > restore the actual state of interrupts (i.e., whether _interrupt() is > > > > > going > > > > > to be called or not) to the desired state in devdata- > > >interrupts_enabled. > > > > > > > > > > Signed-off-by: Tim Sell > > > > > Signed-off-by: David Kershner > > > > > --- > > > > > drivers/staging/unisys/visorinput/visorinput.c | 57 > > > > +- > > > > > 1 file changed, 47 insertions(+), 10 deletions(-) > > > > > > > > > > diff --git a/drivers/staging/unisys/visorinput/visorinput.c > > > > b/drivers/staging/unisys/visorinput/visorinput.c > > > > > index 12a3570..9c00710 100644 > > > > > --- a/drivers/staging/unisys/visorinput/visorinput.c > > > > > +++ b/drivers/staging/unisys/visorinput/visorinput.c > > > > > @@ -66,6 +66,7 @@ struct visorinput_devdata { > > > > > struct rw_semaphore lock_visor_dev; /* lock for dev */ > > > > > struct input_dev *visorinput_dev; > > > > > bool paused; > > > > > + bool interrupts_enabled; > > > > > unsigned int keycode_table_bytes; /* size of following array */ > > > > > /* for keyboard devices: visorkbd_keycode[] + > > > > visorkbd_ext_keycode[] */ > > > > > unsigned char keycode_table[0]; > > > > > @@ -228,7 +229,21 @@ static int visorinput_open(struct input_dev > > > > *visorinput_dev) > > > > > return -EINVAL; > > > > > } > > > > > dev_dbg(&visorinput_dev->dev, "%s opened\n", __func__); > > > > > + > > > > > + /* > > > > > + * If we're not paused, really enable interrupts. > > > > > + * Regardless of whether we are paused, set a flag indicating > > > > > + * interrupts should be enabled so when we resume, interrupts > > > > > + * will really be enabled. > > > > > + */ > > > > > + down_write(&devdata->lock_visor_dev); > > > > > + devdata->interrupts_enabled = true; > > > > > + if (devdata->paused) > > > > > + goto out_unlock; > > > > Don't you want to wait until you actually enable interrupts here to set > > > > interrupts_enabled to true? Otherwise, if devdata->paused is true, you > > will > > > > be > > > > out of sync. > > > > > > No. That's the intent of this code, to remember what the > > > state of interrupts SHOULD be (via devdata->interrupts_enabled), at > > > a point in time when interrupts can NOT be enabled, e.g., when > > > the device is paused (devdata->paused). After the device is resumed, > > > the real interrupt state (visorbus_enable_channel_interrupts()) > > > will be synchronized with the remembered state. > > > > > > > Ok, I'll buy that, but it
Re: [PATCH v2 0/4] *** rtl8192u: Replace semaphores with mutexes ***
On Thursday, June 2, 2016 4:22:58 PM CEST Binoy Jayan wrote: > Hi, > > These are a set of patches [v2] which removes semaphores from: > > drivers/staging/rtl8192u > > These are part of a bigger effort to eliminate all semaphores > from the linux kernel. > > They build correctly (individually and as a whole). > NB: I have not tested this as I do not have the following hardware: > > All look good now. Note about the 'Reviewed-by: ' reply I gave you. When you resend a patch, you should pick up all the 'Reviewed-by', 'Acked-by', 'Tested-by', etc lines and add them to your 'Signed-off-by' line in the patch, so that information doesn't get lost. If you don't resend the patch but it gets picked up by the maintainer, then the maintainer adds then while applying the patches. Arnd ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v2 4/4] rtl8192u: Remove unused semaphore rf_sem
The semaphore 'rf_sem' in rtl8192u has no users, hence removing it. Signed-off-by: Binoy Jayan --- This patch depends on the following patch: rtl8192u: Replace semaphore scan_sem with mutex drivers/staging/rtl8192u/r8192U.h | 1 - drivers/staging/rtl8192u/r8192U_core.c | 1 - 2 files changed, 2 deletions(-) diff --git a/drivers/staging/rtl8192u/r8192U.h b/drivers/staging/rtl8192u/r8192U.h index 2780838..f717cb3 100644 --- a/drivers/staging/rtl8192u/r8192U.h +++ b/drivers/staging/rtl8192u/r8192U.h @@ -880,7 +880,6 @@ typedef struct r8192_priv { short crcmon; struct mutex wx_mutex; - struct semaphore rf_sem;/* Used to lock rf write operation */ u8 rf_type; /* 0: 1T2R, 1: 2T4R */ RT_RF_TYPE_819xU rf_chip; diff --git a/drivers/staging/rtl8192u/r8192U_core.c b/drivers/staging/rtl8192u/r8192U_core.c index c6d3119..ccb4259 100644 --- a/drivers/staging/rtl8192u/r8192U_core.c +++ b/drivers/staging/rtl8192u/r8192U_core.c @@ -2374,7 +2374,6 @@ static void rtl8192_init_priv_lock(struct r8192_priv *priv) spin_lock_init(&priv->tx_lock); spin_lock_init(&priv->irq_lock); mutex_init(&priv->wx_mutex); - sema_init(&priv->rf_sem, 1); mutex_init(&priv->mutex); } -- The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v2 2/4] rtl8192u: ieee80211_device: Replace semaphore wx_sem with mutex
The semaphore 'wx_sem' in ieee80211_device is a simple mutex, so it should be written as one. Semaphores are going away in the future. Signed-off-by: Binoy Jayan --- This patch depends on the following patch: rtl8192u: r8192_priv: Replace semaphore wx_sem with mutex drivers/staging/rtl8192u/ieee80211/ieee80211.h | 2 +- .../staging/rtl8192u/ieee80211/ieee80211_softmac.c | 36 +++--- .../rtl8192u/ieee80211/ieee80211_softmac_wx.c | 34 ++-- drivers/staging/rtl8192u/ieee80211/ieee80211_wx.c | 6 ++-- drivers/staging/rtl8192u/r8192U_core.c | 4 +-- 5 files changed, 41 insertions(+), 41 deletions(-) diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211.h b/drivers/staging/rtl8192u/ieee80211/ieee80211.h index 68931e5..ef9ae22 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211.h +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211.h @@ -1799,7 +1799,7 @@ struct ieee80211_device { short scanning; short proto_started; - struct semaphore wx_sem; + struct mutex wx_mutex; struct semaphore scan_sem; spinlock_t mgmt_tx_lock; diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c index ae1274c..c983e49 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c @@ -621,7 +621,7 @@ static void ieee80211_start_scan(struct ieee80211_device *ieee) } -/* called with wx_sem held */ +/* called with wx_mutex held */ void ieee80211_start_scan_syncro(struct ieee80211_device *ieee) { if (IS_DOT11D_ENABLE(ieee) ) @@ -1389,7 +1389,7 @@ static void ieee80211_associate_procedure_wq(struct work_struct *work) { struct ieee80211_device *ieee = container_of(work, struct ieee80211_device, associate_procedure_wq); ieee->sync_scan_hurryup = 1; - down(&ieee->wx_sem); + mutex_lock(&ieee->wx_mutex); if (ieee->data_hard_stop) ieee->data_hard_stop(ieee->dev); @@ -1402,7 +1402,7 @@ static void ieee80211_associate_procedure_wq(struct work_struct *work) ieee->associate_seq = 1; ieee80211_associate_step1(ieee); - up(&ieee->wx_sem); + mutex_unlock(&ieee->wx_mutex); } inline void ieee80211_softmac_new_net(struct ieee80211_device *ieee, struct ieee80211_network *net) @@ -2331,7 +2331,7 @@ static void ieee80211_start_ibss_wq(struct work_struct *work) struct ieee80211_device *ieee = container_of(dwork, struct ieee80211_device, start_ibss_wq); /* iwconfig mode ad-hoc will schedule this and return * on the other hand this will block further iwconfig SET -* operations because of the wx_sem hold. +* operations because of the wx_mutex hold. * Anyway some most set operations set a flag to speed-up * (abort) this wq (when syncro scanning) before sleeping * on the semaphore @@ -2340,7 +2340,7 @@ static void ieee80211_start_ibss_wq(struct work_struct *work) printk("==oh driver down return\n"); return; } - down(&ieee->wx_sem); + mutex_lock(&ieee->wx_mutex); if (ieee->current_network.ssid_len == 0) { strcpy(ieee->current_network.ssid, IEEE80211_DEFAULT_TX_ESSID); @@ -2431,7 +2431,7 @@ static void ieee80211_start_ibss_wq(struct work_struct *work) ieee->data_hard_resume(ieee->dev); netif_carrier_on(ieee->dev); - up(&ieee->wx_sem); + mutex_unlock(&ieee->wx_mutex); } inline void ieee80211_start_ibss(struct ieee80211_device *ieee) @@ -2439,7 +2439,7 @@ inline void ieee80211_start_ibss(struct ieee80211_device *ieee) schedule_delayed_work(&ieee->start_ibss_wq, 150); } -/* this is called only in user context, with wx_sem held */ +/* this is called only in user context, with wx_mutex held */ void ieee80211_start_bss(struct ieee80211_device *ieee) { unsigned long flags; @@ -2505,7 +2505,7 @@ static void ieee80211_associate_retry_wq(struct work_struct *work) struct ieee80211_device *ieee = container_of(dwork, struct ieee80211_device, associate_retry_wq); unsigned long flags; - down(&ieee->wx_sem); + mutex_lock(&ieee->wx_mutex); if(!ieee->proto_started) goto exit; @@ -2537,7 +2537,7 @@ static void ieee80211_associate_retry_wq(struct work_struct *work) spin_unlock_irqrestore(&ieee->lock, flags); exit: - up(&ieee->wx_sem); + mutex_unlock(&ieee->wx_mutex); } struct sk_buff *ieee80211_get_beacon_(struct ieee80211_device *ieee) @@ -2583,9 +2583,9 @@ EXPORT_SYMBOL(ieee80211_get_beacon); void ieee80211_softmac_stop_protocol(struct ieee80211_device *ieee) { ieee->sync_scan_hurryup = 1; - down(&ieee->wx_sem); + mutex_lock(&ieee->wx_mutex); ieee80211_stop_protocol(ieee); - up(&ieee->wx_sem
[PATCH v2 3/4] rtl8192u: Replace semaphore scan_sem with mutex
The semaphore 'scan_sem' in rtl8192u is a simple mutex, so it should be written as one. Semaphores are going away in the future. Signed-off-by: Binoy Jayan --- This patch depends on the following patch: rtl8192u: ieee80211_device: Replace semaphore wx_sem with mutex drivers/staging/rtl8192u/ieee80211/ieee80211.h | 2 +- drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c | 18 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211.h b/drivers/staging/rtl8192u/ieee80211/ieee80211.h index ef9ae22..09e9499 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211.h +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211.h @@ -1800,7 +1800,7 @@ struct ieee80211_device { short proto_started; struct mutex wx_mutex; - struct semaphore scan_sem; + struct mutex scan_mutex; spinlock_t mgmt_tx_lock; spinlock_t beacon_lock; diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c index c983e49..e8e83f5 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c @@ -427,7 +427,7 @@ void ieee80211_softmac_scan_syncro(struct ieee80211_device *ieee) short ch = 0; u8 channel_map[MAX_CHANNEL_NUMBER+1]; memcpy(channel_map, GET_DOT11D_INFO(ieee)->channel_map, MAX_CHANNEL_NUMBER+1); - down(&ieee->scan_sem); + mutex_lock(&ieee->scan_mutex); while(1) { @@ -475,13 +475,13 @@ void ieee80211_softmac_scan_syncro(struct ieee80211_device *ieee) out: if(ieee->state < IEEE80211_LINKED){ ieee->actscanning = false; - up(&ieee->scan_sem); + mutex_unlock(&ieee->scan_mutex); } else{ ieee->sync_scan_hurryup = 0; if(IS_DOT11D_ENABLE(ieee)) DOT11D_ScanComplete(ieee); - up(&ieee->scan_sem); + mutex_unlock(&ieee->scan_mutex); } } EXPORT_SYMBOL(ieee80211_softmac_scan_syncro); @@ -495,7 +495,7 @@ static void ieee80211_softmac_scan_wq(struct work_struct *work) memcpy(channel_map, GET_DOT11D_INFO(ieee)->channel_map, MAX_CHANNEL_NUMBER+1); if(!ieee->ieee_up) return; - down(&ieee->scan_sem); + mutex_lock(&ieee->scan_mutex); do{ ieee->current_network.channel = (ieee->current_network.channel + 1) % MAX_CHANNEL_NUMBER; @@ -517,7 +517,7 @@ static void ieee80211_softmac_scan_wq(struct work_struct *work) schedule_delayed_work(&ieee->softmac_scan_wq, IEEE80211_SOFTMAC_SCAN_TIME); - up(&ieee->scan_sem); + mutex_unlock(&ieee->scan_mutex); return; out: if(IS_DOT11D_ENABLE(ieee)) @@ -525,7 +525,7 @@ out: ieee->actscanning = false; watchdog = 0; ieee->scanning = 0; - up(&ieee->scan_sem); + mutex_unlock(&ieee->scan_mutex); } @@ -579,7 +579,7 @@ static void ieee80211_softmac_stop_scan(struct ieee80211_device *ieee) //ieee->sync_scan_hurryup = 1; - down(&ieee->scan_sem); + mutex_lock(&ieee->scan_mutex); // spin_lock_irqsave(&ieee->lock, flags); if (ieee->scanning == 1) { @@ -589,7 +589,7 @@ static void ieee80211_softmac_stop_scan(struct ieee80211_device *ieee) } // spin_unlock_irqrestore(&ieee->lock, flags); - up(&ieee->scan_sem); + mutex_unlock(&ieee->scan_mutex); } void ieee80211_stop_scan(struct ieee80211_device *ieee) @@ -2729,7 +2729,7 @@ void ieee80211_softmac_init(struct ieee80211_device *ieee) mutex_init(&ieee->wx_mutex); - sema_init(&ieee->scan_sem, 1); + mutex_init(&ieee->scan_mutex); spin_lock_init(&ieee->mgmt_tx_lock); spin_lock_init(&ieee->beacon_lock); -- The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v2 1/4] rtl8192u: r8192_priv: Replace semaphore wx_sem with mutex
The semaphore 'wx_sem' in r8192_priv is a simple mutex, so it should be written as one. Semaphores are going away in the future. Signed-off-by: Binoy Jayan --- drivers/staging/rtl8192u/r8192U.h | 2 +- drivers/staging/rtl8192u/r8192U_core.c | 28 ++-- drivers/staging/rtl8192u/r8192U_wx.c | 80 +- 3 files changed, 55 insertions(+), 55 deletions(-) diff --git a/drivers/staging/rtl8192u/r8192U.h b/drivers/staging/rtl8192u/r8192U.h index ee1c722..2780838 100644 --- a/drivers/staging/rtl8192u/r8192U.h +++ b/drivers/staging/rtl8192u/r8192U.h @@ -879,7 +879,7 @@ typedef struct r8192_priv { /* If 1, allow bad crc frame, reception in monitor mode */ short crcmon; - struct semaphore wx_sem; + struct mutex wx_mutex; struct semaphore rf_sem;/* Used to lock rf write operation */ u8 rf_type; /* 0: 1T2R, 1: 2T4R */ diff --git a/drivers/staging/rtl8192u/r8192U_core.c b/drivers/staging/rtl8192u/r8192U_core.c index 849a95e..3d1b52f 100644 --- a/drivers/staging/rtl8192u/r8192U_core.c +++ b/drivers/staging/rtl8192u/r8192U_core.c @@ -2373,7 +2373,7 @@ static void rtl8192_init_priv_lock(struct r8192_priv *priv) { spin_lock_init(&priv->tx_lock); spin_lock_init(&priv->irq_lock); - sema_init(&priv->wx_sem, 1); + mutex_init(&priv->wx_mutex); sema_init(&priv->rf_sem, 1); mutex_init(&priv->mutex); } @@ -3324,12 +3324,12 @@ RESET_START: /* Set the variable for reset. */ priv->ResetProgress = RESET_TYPE_SILENT; - down(&priv->wx_sem); + mutex_lock(&priv->wx_mutex); if (priv->up == 0) { RT_TRACE(COMP_ERR, "%s():the driver is not up! return\n", __func__); - up(&priv->wx_sem); + mutex_unlock(&priv->wx_mutex); return; } priv->up = 0; @@ -3356,7 +3356,7 @@ RESET_START: netdev_dbg(dev, "ieee->state is NOT LINKED\n"); ieee80211_softmac_stop_protocol(priv->ieee80211); } - up(&priv->wx_sem); + mutex_unlock(&priv->wx_mutex); RT_TRACE(COMP_RESET, "%s():<==down process is finished\n", __func__); @@ -3556,9 +3556,9 @@ static int rtl8192_open(struct net_device *dev) struct r8192_priv *priv = ieee80211_priv(dev); int ret; - down(&priv->wx_sem); + mutex_lock(&priv->wx_mutex); ret = rtl8192_up(dev); - up(&priv->wx_sem); + mutex_unlock(&priv->wx_mutex); return ret; } @@ -3580,11 +3580,11 @@ static int rtl8192_close(struct net_device *dev) struct r8192_priv *priv = ieee80211_priv(dev); int ret; - down(&priv->wx_sem); + mutex_lock(&priv->wx_mutex); ret = rtl8192_down(dev); - up(&priv->wx_sem); + mutex_unlock(&priv->wx_mutex); return ret; @@ -3658,11 +3658,11 @@ static void rtl8192_restart(struct work_struct *work) reset_wq); struct net_device *dev = priv->ieee80211->dev; - down(&priv->wx_sem); + mutex_lock(&priv->wx_mutex); rtl8192_commit(dev); - up(&priv->wx_sem); + mutex_unlock(&priv->wx_mutex); } static void r8192_set_multicast(struct net_device *dev) @@ -3685,12 +3685,12 @@ static int r8192_set_mac_adr(struct net_device *dev, void *mac) struct r8192_priv *priv = ieee80211_priv(dev); struct sockaddr *addr = mac; - down(&priv->wx_sem); + mutex_lock(&priv->wx_mutex); ether_addr_copy(dev->dev_addr, addr->sa_data); schedule_work(&priv->reset_wq); - up(&priv->wx_sem); + mutex_unlock(&priv->wx_mutex); return 0; } @@ -3707,7 +3707,7 @@ static int rtl8192_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) struct iw_point *p = &wrq->u.data; struct ieee_param *ipw = NULL; - down(&priv->wx_sem); + mutex_lock(&priv->wx_mutex); if (p->length < sizeof(struct ieee_param) || !p->pointer) { @@ -3800,7 +3800,7 @@ static int rtl8192_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) kfree(ipw); ipw = NULL; out: - up(&priv->wx_sem); + mutex_unlock(&priv->wx_mutex); return ret; } diff --git a/drivers/staging/rtl8192u/r8192U_wx.c b/drivers/staging/rtl8192u/r8192U_wx.c index f828e64..c59f36f 100644 --- a/drivers/staging/rtl8192u/r8192U_wx.c +++ b/drivers/staging/rtl8192u/r8192U_wx.c @@ -73,11 +73,11 @@ static int r8192_wx_set_rate(struct net_device *dev, int ret; struct r8192_priv *priv = ieee80211_priv(dev); - down(&priv->wx_sem); + mutex_lock(&priv->wx_mutex
[PATCH v2 0/4] *** rtl8192u: Replace semaphores with mutexes ***
Hi, These are a set of patches [v2] which removes semaphores from: drivers/staging/rtl8192u These are part of a bigger effort to eliminate all semaphores from the linux kernel. They build correctly (individually and as a whole). NB: I have not tested this as I do not have the following hardware: "RealTek RTL8192U Wireless LAN NIC driver" Review comments w.r.t. PATCH v1: Changed the following patch (PATCH 4/4) rtl8192u: Replace semaphore rf_sem with mutex with rtl8192u: Remove unused semaphore rf_sem since 'rf_sem' has no users, removing it instead of replacing it with a mutex. Thanks, Binoy Binoy Jayan (4): rtl8192u: r8192_priv: Replace semaphore wx_sem with mutex rtl8192u: ieee80211_device: Replace semaphore wx_sem with mutex rtl8192u: Replace semaphore scan_sem with mutex rtl8192u: Remove unused semaphore rf_sem drivers/staging/rtl8192u/ieee80211/ieee80211.h | 4 +- .../staging/rtl8192u/ieee80211/ieee80211_softmac.c | 54 +++ .../rtl8192u/ieee80211/ieee80211_softmac_wx.c | 34 - drivers/staging/rtl8192u/ieee80211/ieee80211_wx.c | 6 +- drivers/staging/rtl8192u/r8192U.h | 3 +- drivers/staging/rtl8192u/r8192U_core.c | 33 + drivers/staging/rtl8192u/r8192U_wx.c | 80 +++--- 7 files changed, 106 insertions(+), 108 deletions(-) -- The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH 0/4] *** rtl8192u: Replace semaphores with mutexes ***
On Thursday, June 2, 2016 10:27:51 AM CEST Binoy Jayan wrote: > Hi, > > These are a set of patches which removes semaphores from: > > drivers/staging/rtl8192u > > They build correctly (individually and as a whole). > NB: I have not tested this as I do not have the following hardware: > > "RealTek RTL8192U Wireless LAN NIC driver" > > Patches 1-3 look good, Reviewed-by: Arnd Bergmann I commented on patch 4, which is correct but I think it should be done differently. One more thing that might be helpful to note in the cover letter above is that this is part of a bigger effort to eliminate all semaphores from the kernel. Arnd ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH 4/4] rtl8192u: Replace semaphore rf_sem with mutex
On Thursday, June 2, 2016 10:27:55 AM CEST Binoy Jayan wrote: > diff --git a/drivers/staging/rtl8192u/r8192U.h > b/drivers/staging/rtl8192u/r8192U.h > index 2780838..7b921d4 100644 > --- a/drivers/staging/rtl8192u/r8192U.h > +++ b/drivers/staging/rtl8192u/r8192U.h > @@ -880,7 +880,7 @@ typedef struct r8192_priv { > short crcmon; > > struct mutex wx_mutex; > - struct semaphore rf_sem;/* Used to lock rf write operation */ > + struct mutex rf_mutex; /* Used to lock rf write operation */ > > u8 rf_type; /* 0: 1T2R, 1: 2T4R */ > RT_RF_TYPE_819xU rf_chip; > diff --git a/drivers/staging/rtl8192u/r8192U_core.c > b/drivers/staging/rtl8192u/r8192U_core.c > index c6d3119..46d613a 100644 > --- a/drivers/staging/rtl8192u/r8192U_core.c > +++ b/drivers/staging/rtl8192u/r8192U_core.c > @@ -2374,7 +2374,7 @@ static void rtl8192_init_priv_lock(struct r8192_priv > *priv) > spin_lock_init(&priv->tx_lock); > spin_lock_init(&priv->irq_lock); > mutex_init(&priv->wx_mutex); > - sema_init(&priv->rf_sem, 1); > + mutex_init(&priv->rf_mutex); > mutex_init(&priv->mutex); > } I think this one should be done differently: as there are obviously no users of this semaphore, there is no need to replace it with a mutex, it should just be removed entirely. Arnd ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH v2 0/4] *** rtl8712: Replace semaphores with mutex / completions ***
On Thursday, June 2, 2016 9:54:06 AM CEST Binoy Jayan wrote: > Hi, > > These are a set of patches [v2] which removes semaphores from: > > drivers/staging/rtl8712 > > They build correctly (individually and as a whole). > NB: I have not tested this as I do not have the following hardware: > > "RealTek RTL8712U (RTL8192SU) Wireless LAN NIC driver" > > Rework on comments w.r.t. PATCH v1: > > - Removed wrapper functions _wait_completion, _down_sema and _enter_pwrlock > - Updated changelog to explain use of mutex_lock instead of >mutex_lock_interruptible in [PATCH v2 4/4] > All four look great now, Reviewed-by: Arnd Bergmann ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel