[PATCH] x86/Hyper-V: Fix definition HV_MAX_FLUSH_REP_COUNT

2019-02-22 Thread lantianyu1986
From: Lan Tianyu 

The max flush rep count of HvFlushGuestPhysicalAddressList hypercall
is equal with how many entries of union hv_gpa_page_range can be populated
into the input parameter page. The origin code lacks parenthesis around
PAGE_SIZE - 2 * sizeof(u64). This patch is to fix it.

Cc: 
Fixs: cc4edae4b9(x86/hyper-v: Add HvFlushGuestAddressList hypercall support)
Signed-off-by: Lan Tianyu 
---
 arch/x86/include/asm/hyperv-tlfs.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/include/asm/hyperv-tlfs.h 
b/arch/x86/include/asm/hyperv-tlfs.h
index 705dafc2d11a..2bdbbbcfa393 100644
--- a/arch/x86/include/asm/hyperv-tlfs.h
+++ b/arch/x86/include/asm/hyperv-tlfs.h
@@ -841,7 +841,7 @@ union hv_gpa_page_range {
  * count is equal with how many entries of union hv_gpa_page_range can
  * be populated into the input parameter page.
  */
-#define HV_MAX_FLUSH_REP_COUNT (PAGE_SIZE - 2 * sizeof(u64) /  \
+#define HV_MAX_FLUSH_REP_COUNT ((PAGE_SIZE - 2 * sizeof(u64)) /\
sizeof(union hv_gpa_page_range))
 
 struct hv_guest_mapping_flush_list {
-- 
2.14.4

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


[PATCH] staging: android: ashmem: Avoid range_alloc() allocation with ashmem_mutex held.

2019-02-22 Thread Tetsuo Handa
ashmem_pin() is calling range_shrink() without checking whether
range_alloc() succeeded. Also, doing memory allocation with ashmem_mutex
held should be avoided because ashmem_shrink_scan() tries to hold it.

Therefore, move memory allocation for range_alloc() to ashmem_pin_unpin()
and make range_alloc() not to fail.

This patch is mostly meant for backporting purpose for fuzz testing on
stable/distributor kernels, for there is a plan to remove this code in
near future.

Signed-off-by: Tetsuo Handa 
Cc: sta...@vger.kernel.org
---
 drivers/staging/android/ashmem.c | 42 +++-
 1 file changed, 24 insertions(+), 18 deletions(-)

diff --git a/drivers/staging/android/ashmem.c b/drivers/staging/android/ashmem.c
index 5d5b091..74d497d 100644
--- a/drivers/staging/android/ashmem.c
+++ b/drivers/staging/android/ashmem.c
@@ -172,19 +172,15 @@ static inline void lru_del(struct ashmem_range *range)
  * @end:  The ending page (inclusive)
  *
  * This function is protected by ashmem_mutex.
- *
- * Return: 0 if successful, or -ENOMEM if there is an error
  */
-static int range_alloc(struct ashmem_area *asma,
-  struct ashmem_range *prev_range, unsigned int purged,
-  size_t start, size_t end)
+static void range_alloc(struct ashmem_area *asma,
+   struct ashmem_range *prev_range, unsigned int purged,
+   size_t start, size_t end,
+   struct ashmem_range **new_range)
 {
-   struct ashmem_range *range;
-
-   range = kmem_cache_zalloc(ashmem_range_cachep, GFP_KERNEL);
-   if (!range)
-   return -ENOMEM;
+   struct ashmem_range *range = *new_range;
 
+   *new_range = NULL;
range->asma = asma;
range->pgstart = start;
range->pgend = end;
@@ -194,8 +190,6 @@ static int range_alloc(struct ashmem_area *asma,
 
if (range_on_lru(range))
lru_add(range);
-
-   return 0;
 }
 
 /**
@@ -597,7 +591,8 @@ static int get_name(struct ashmem_area *asma, void __user 
*name)
  *
  * Caller must hold ashmem_mutex.
  */
-static int ashmem_pin(struct ashmem_area *asma, size_t pgstart, size_t pgend)
+static int ashmem_pin(struct ashmem_area *asma, size_t pgstart, size_t pgend,
+ struct ashmem_range **new_range)
 {
struct ashmem_range *range, *next;
int ret = ASHMEM_NOT_PURGED;
@@ -650,7 +645,7 @@ static int ashmem_pin(struct ashmem_area *asma, size_t 
pgstart, size_t pgend)
 * second half and adjust the first chunk's endpoint.
 */
range_alloc(asma, range, range->purged,
-   pgend + 1, range->pgend);
+   pgend + 1, range->pgend, new_range);
range_shrink(range, range->pgstart, pgstart - 1);
break;
}
@@ -664,7 +659,8 @@ static int ashmem_pin(struct ashmem_area *asma, size_t 
pgstart, size_t pgend)
  *
  * Caller must hold ashmem_mutex.
  */
-static int ashmem_unpin(struct ashmem_area *asma, size_t pgstart, size_t pgend)
+static int ashmem_unpin(struct ashmem_area *asma, size_t pgstart, size_t pgend,
+   struct ashmem_range **new_range)
 {
struct ashmem_range *range, *next;
unsigned int purged = ASHMEM_NOT_PURGED;
@@ -690,7 +686,8 @@ static int ashmem_unpin(struct ashmem_area *asma, size_t 
pgstart, size_t pgend)
}
}
 
-   return range_alloc(asma, range, purged, pgstart, pgend);
+   range_alloc(asma, range, purged, pgstart, pgend, new_range);
+   return 0;
 }
 
 /*
@@ -723,10 +720,17 @@ static int ashmem_pin_unpin(struct ashmem_area *asma, 
unsigned long cmd,
struct ashmem_pin pin;
size_t pgstart, pgend;
int ret = -EINVAL;
+   struct ashmem_range *range = NULL;
 
if (copy_from_user(&pin, p, sizeof(pin)))
return -EFAULT;
 
+   if (cmd == ASHMEM_PIN || cmd == ASHMEM_UNPIN) {
+   range = kmem_cache_zalloc(ashmem_range_cachep, GFP_KERNEL);
+   if (!range)
+   return -ENOMEM;
+   }
+
mutex_lock(&ashmem_mutex);
wait_event(ashmem_shrink_wait, !atomic_read(&ashmem_shrink_inflight));
 
@@ -751,10 +755,10 @@ static int ashmem_pin_unpin(struct ashmem_area *asma, 
unsigned long cmd,
 
switch (cmd) {
case ASHMEM_PIN:
-   ret = ashmem_pin(asma, pgstart, pgend);
+   ret = ashmem_pin(asma, pgstart, pgend, &range);
break;
case ASHMEM_UNPIN:
-   ret = ashmem_unpin(asma, pgstart, pgend);
+   ret = ashmem_unpin(asma, pgstart, pgend, &range);
break;
case ASHMEM_GET_PIN_STATUS:
ret = ashmem_get_pin_status(asma, pgstart, pgend);
@@ -763,6 +767,8 @@ static int ashmem_pin_unpin(struct ashmem_area *asma, 
unsigne

Re: [PATCH v2 1/2] staging: iio: frequency: ad9834: Move frequency to standard iio types

2019-02-22 Thread Bia, Beniamin
Thank you for taking some time reviewing my code.
Ad9833/ad9834 has two frequency and phase registers and only one
output. The user can select which register is selected as input with a
mux.Because I wanted to reduce as much as possible the custom
attributes, I mapped the frequency 0 from register to channel 0 and
frequency 1 to channel 1. Same rule applies for phase. 

In order to keep the same structure as before: out_altvoltage0_frequency0 and 
out_altvoltage1_frequency1, we would have to create custom attributes for every 
frequency and phase value. This is the only way as far as I know, but I don't 
have a lot of experience with iio. What is your opinion? Do you have a better 
solution?

Thanks,
Ben 
> [External]
> 
> 
> On Thu, 14 Feb 2019 18:41:29 +0200
> Beniamin Bia  wrote:
> 
> > Frequency attribute is added with a standard type from iio
> > framework
> > instead of custom attribute. This is a small step towards removing
> > any
> > unnecessary custom attribute. Ad9834 will diverge from ad9833 in
> > the
> > future, that is why we have two identical arrays for ad9834 and
> > 9833.
> > 
> > Signed-off-by: Beniamin Bia 
> 
> Hi Beniamin
> 
> When you make a change like this, please explain in detail how the
> ABI
> changes.  Here I'm not sure we can actually map it to channels like
> this.
> We are controlling the two frequencies of FSK not independent
> channels.
> 
> The ABI around this needs very careful thinking out.  I would
> document
> your proposed ABI first and share that.  Once we reach agreement on
> the
> ABI, the actual code should be more straight forward!
> 
> Thanks,
> 
> Jonathan
> 
> > ---
> > Changes in v2:
> >   -the personal email address was replaced by the work email
> >   -separate define for frequency channel
> >   -address field from channel specification was removed
> >   -frequency variables were replaced by an array
> >   -specified in comment why we have differente chan_spec for
> > ad9834 and ad9833
> >   -enum used for write_frequency function
> > 
> >  drivers/staging/iio/frequency/ad9834.c | 110 -
> > 
> >  1 file changed, 91 insertions(+), 19 deletions(-)
> > 
> > diff --git a/drivers/staging/iio/frequency/ad9834.c
> > b/drivers/staging/iio/frequency/ad9834.c
> > index f036f75d1f22..561617046c20 100644
> > --- a/drivers/staging/iio/frequency/ad9834.c
> > +++ b/drivers/staging/iio/frequency/ad9834.c
> > @@ -81,6 +81,8 @@ struct ad9834_state {
> >   struct spi_message  freq_msg;
> >   struct mutexlock;   /* protect sensor
> > state */
> > 
> > + unsigned long   frequency[2];
> > +
> >   /*
> >* DMA (thus cache coherency maintenance) requires the
> >* transfer buffers to live in their own cache lines.
> > @@ -89,6 +91,11 @@ struct ad9834_state {
> >   __be16  freq_data[2];
> >  };
> > 
> > +enum ad9834_ch_addr {
> > + AD9834_CHANNEL_ADDRESS0,
> > + AD9834_CHANNEL_ADDRESS1,
> > +};
> > +
> >  /**
> >   * ad9834_supported_device_ids:
> >   */
> > @@ -100,6 +107,24 @@ enum ad9834_supported_device_ids {
> >   ID_AD9838,
> >  };
> > 
> > +#define AD9833_CHANNEL(chan)
> > {   \
> > + .type =
> > IIO_ALTVOLTAGE, \
> > + .indexed =
> > 1,   \
> > + .output =
> > 1,\
> > + .channel =
> > (chan),  \
> > + .info_mask_separate =
> > BIT(IIO_CHAN_INFO_FREQUENCY)  \
> > +}
> > +
> > +static const struct iio_chan_spec ad9833_channels[] = {
> > + AD9833_CHANNEL(0),
> > + AD9833_CHANNEL(1),
> > +};
> > +
> > +static const struct iio_chan_spec ad9834_channels[] = {
> > + AD9833_CHANNEL(0),
> > + AD9833_CHANNEL(1),
> > +};
> > +
> >  static unsigned int ad9834_calc_freqreg(unsigned long mclk,
> > unsigned long fout)
> >  {
> >   unsigned long long freqreg = (u64)fout *
> > (u64)BIT(AD9834_FREQ_BITS);
> > @@ -109,10 +134,12 @@ static unsigned int
> > ad9834_calc_freqreg(unsigned long mclk, unsigned long fout)
> >  }
> > 
> >  static int ad9834_write_frequency(struct ad9834_state *st,
> > -   unsigned long addr, unsigned long
> > fout)
> > +   enum ad9834_ch_addr addr,
> > +   unsigned long fout)
> >  {
> >   unsigned long clk_freq;
> >   unsigned long regval;
> > + int ret;
> > 
> >   clk_freq = clk_get_rate(st->mclk);
> > 
> > @@ -121,13 +148,27 @@ static int ad9834_write_frequency(struct
> > ad9834_state *st,
> > 
> >   regval = ad9834_calc_freqreg(clk_freq, fout);
> > 
> > - st->freq_data[0] = cpu_to_be16(addr | (regval &
> > -RES_MASK(AD9834_FREQ_BITS /
> > 2)));
> > - st->freq_data[1] = cpu_to_be1

Re: [PATCH] x86/Hyper-V: Fix definition HV_MAX_FLUSH_REP_COUNT

2019-02-22 Thread Greg KH
On Fri, Feb 22, 2019 at 06:48:44PM +0800, lantianyu1...@gmail.com wrote:
> From: Lan Tianyu 
> 
> The max flush rep count of HvFlushGuestPhysicalAddressList hypercall
> is equal with how many entries of union hv_gpa_page_range can be populated
> into the input parameter page. The origin code lacks parenthesis around
> PAGE_SIZE - 2 * sizeof(u64). This patch is to fix it.
> 
> Cc: 
> Fixs: cc4edae4b9(x86/hyper-v: Add HvFlushGuestAddressList hypercall support)

Please use this format instead:

Fixes: cc4edae4b924 ("x86/hyper-v: Add HvFlushGuestAddressList hypercall 
support")

And don't type it by hand, use a git alias for it:
git show -s --abbrev-commit --abbrev=12 --pretty=format:"%h (\"%s\")%n"

You also messed up your To: line, keeping anyone from being able to
respond to this message who do not know how to hand-edit the response
line :(

thanks,

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


[PATCH V3 1/10] X86/Hyper-V: Add parameter offset for hyperv_fill_flush_guest_mapping_list()

2019-02-22 Thread lantianyu1986
From: Lan Tianyu 

Add parameter offset to specify start position to add flush ranges in
guest address list of struct hv_guest_mapping_flush_list.

Signed-off-by: Lan Tianyu 
---
 arch/x86/hyperv/nested.c| 4 ++--
 arch/x86/include/asm/mshyperv.h | 2 +-
 arch/x86/kvm/vmx/vmx.c  | 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/x86/hyperv/nested.c b/arch/x86/hyperv/nested.c
index dd0a843f766d..96f8bac7476d 100644
--- a/arch/x86/hyperv/nested.c
+++ b/arch/x86/hyperv/nested.c
@@ -58,11 +58,11 @@ EXPORT_SYMBOL_GPL(hyperv_flush_guest_mapping);
 
 int hyperv_fill_flush_guest_mapping_list(
struct hv_guest_mapping_flush_list *flush,
-   u64 start_gfn, u64 pages)
+   int offset, u64 start_gfn, u64 pages)
 {
u64 cur = start_gfn;
u64 additional_pages;
-   int gpa_n = 0;
+   int gpa_n = offset;
 
do {
/*
diff --git a/arch/x86/include/asm/mshyperv.h b/arch/x86/include/asm/mshyperv.h
index cc60e617931c..d6be685ab6b0 100644
--- a/arch/x86/include/asm/mshyperv.h
+++ b/arch/x86/include/asm/mshyperv.h
@@ -357,7 +357,7 @@ int hyperv_flush_guest_mapping_range(u64 as,
hyperv_fill_flush_list_func fill_func, void *data);
 int hyperv_fill_flush_guest_mapping_list(
struct hv_guest_mapping_flush_list *flush,
-   u64 start_gfn, u64 end_gfn);
+   int offset, u64 start_gfn, u64 end_gfn);
 
 #ifdef CONFIG_X86_64
 void hv_apic_init(void);
diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c
index 4950bb20e06a..77b5379e3655 100644
--- a/arch/x86/kvm/vmx/vmx.c
+++ b/arch/x86/kvm/vmx/vmx.c
@@ -433,7 +433,7 @@ static int kvm_fill_hv_flush_list_func(struct 
hv_guest_mapping_flush_list *flush
 {
struct kvm_tlb_range *range = data;
 
-   return hyperv_fill_flush_guest_mapping_list(flush, range->start_gfn,
+   return hyperv_fill_flush_guest_mapping_list(flush, 0, range->start_gfn,
range->pages);
 }
 
-- 
2.14.4

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


[PATCH V3 00/10] X86/KVM/Hyper-V: Add HV ept tlb range list flush support in KVM

2019-02-22 Thread lantianyu1986
From: Lan Tianyu 

This patchset is to introduce hv ept tlb range list flush function
support in the KVM MMU component. Flushing ept tlbs of several address
range can be done via single hypercall and new list flush function is
used in the kvm_mmu_commit_zap_page() and FNAME(sync_page). This patchset
also adds more hv ept tlb range flush support in more KVM MMU function.

This patchset is based on the fix patch "x86/Hyper-V: Fix definition 
HV_MAX_FLUSH_REP_COUNT".
(https://www.mail-archive.com/linux-kernel@vger.kernel.org/msg1939455.html)

Change since v2:
1) Fix calculation of flush pages in the kvm_fill_hv_flush_list_func()
2) Change the logic of setting/clearing last_level flag

Change since v1:
1) Make flush list as a hlist instead of list in order to 
keep struct kvm_mmu_page size.
2) Add last_level flag in the struct kvm_mmu_page instead
of spte pointer
3) Move tlb flush from kvm_mmu_notifier_clear_flush_young() to 
kvm_age_hva()
4) Use range flush in the kvm_vm_ioctl_get/clear_dirty_log()


Lan Tianyu (10):
  X86/Hyper-V: Add parameter offset for
hyperv_fill_flush_guest_mapping_list()
  KVM/VMX: Fill range list in kvm_fill_hv_flush_list_func()
  KVM/MMU: Introduce tlb flush with range list
  KVM/MMU: Use range flush in sync_page()
  KVM/MMU: Flush tlb directly in the kvm_mmu_slot_gfn_write_protect()
  KVM: Add kvm_get_memslot() to get memslot via slot id
  KVM: Use tlb range flush in the kvm_vm_ioctl_get/clear_dirty_log()
  KVM: Add flush parameter for kvm_age_hva()
  KVM/MMU: Use tlb range flush in the kvm_age_hva()
  KVM/MMU: Add last_level flag in the struct mmu_spte_page

 arch/arm/include/asm/kvm_host.h |  3 +-
 arch/arm64/include/asm/kvm_host.h   |  3 +-
 arch/mips/include/asm/kvm_host.h|  3 +-
 arch/mips/kvm/mmu.c | 11 ++--
 arch/powerpc/include/asm/kvm_host.h |  3 +-
 arch/powerpc/kvm/book3s.c   | 10 +--
 arch/powerpc/kvm/e500_mmu_host.c|  3 +-
 arch/x86/hyperv/nested.c|  4 +--
 arch/x86/include/asm/kvm_host.h | 11 +++-
 arch/x86/include/asm/mshyperv.h |  2 +-
 arch/x86/kvm/mmu.c  | 55 ++---
 arch/x86/kvm/mmu.h  |  7 +
 arch/x86/kvm/paging_tmpl.h  |  5 ++--
 arch/x86/kvm/vmx/vmx.c  | 18 ++--
 arch/x86/kvm/x86.c  | 16 ---
 include/linux/kvm_host.h|  1 +
 virt/kvm/arm/mmu.c  | 13 +++--
 virt/kvm/kvm_main.c | 51 ++
 18 files changed, 156 insertions(+), 63 deletions(-)

-- 
2.14.4

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


RE: [PATCH V3 1/10] X86/Hyper-V: Add parameter offset for hyperv_fill_flush_guest_mapping_list()

2019-02-22 Thread Stephen Hemminger
int hyperv_fill_flush_guest_mapping_list(
struct hv_guest_mapping_flush_list *flush,
-   u64 start_gfn, u64 pages)
+   int offset, u64 start_gfn, u64 pages)
 {
u64 cur = start_gfn;
u64 additional_pages;
-   int gpa_n = 0;
+   int gpa_n = offset;
 
do {
/*

Do you mean to support negative offsets here? Maybe unsigned would be better?
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH V3 00/10] X86/KVM/Hyper-V: Add HV ept tlb range list flush support in KVM

2019-02-22 Thread Paolo Bonzini
On 22/02/19 16:06, lantianyu1...@gmail.com wrote:
> From: Lan Tianyu 
> 
> This patchset is to introduce hv ept tlb range list flush function
> support in the KVM MMU component. Flushing ept tlbs of several address
> range can be done via single hypercall and new list flush function is
> used in the kvm_mmu_commit_zap_page() and FNAME(sync_page). This patchset
> also adds more hv ept tlb range flush support in more KVM MMU function.
> 
> This patchset is based on the fix patch "x86/Hyper-V: Fix definition 
> HV_MAX_FLUSH_REP_COUNT".
> (https://www.mail-archive.com/linux-kernel@vger.kernel.org/msg1939455.html)

Note that this won't make it in 5.1 unless Linus releases an -rc8.
Otherwise, I'll get to it next week.

Thanks,

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


Re: [PATCH v4] staging: nrf24: add new driver for 2.4GHz radio transceiver

2019-02-22 Thread Marcin Ciupak
On Tue, Feb 19, 2019 at 11:20:10AM +0100, Greg Kroah-Hartman wrote:
> On Wed, Feb 13, 2019 at 08:40:35PM +0100, Marcin Ciupak wrote:
> > This patch adds driver for Nordic Semiconductor nRF24L01+ radio
> > transceiver.
> > 
> > Signed-off-by: Marcin Ciupak 
> > ---
> > Changes in v2:
> >   - add terminating newlines to all logging formats
> > Changes in v3:
> >   - patch subject
> >   - comments cleanup
> >   - goto labels cleanup
> >   - scnprintf bugfix
> >   - ida_simple_remove bugfix
> > Changes in v4:
> >   - fix smatch warnings
> 
> What is preventing this from being merged today with the normal
> subsystem for this type of drivers?  Why does this have to go into
> staging?
> 
> thanks,
> 
> greg k-h

As per TODO file:
+Todo:
+- opening and closing pipes via sysfs
+- improve switching in between RX and TX
+- improve handling of MAX_RT interrupt
+- find and fix bugs
+- code cleanup

Additionally, I would like to add ioctl (or any similar) interface
as configuration via sysfs is not very efficent in here.

My beliefes are that this driver needs some time in staging, but I might
be wrong and if you believe otherwise just let me know and I will try to
push it ti regular sybsystem.

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


[PATCH net] staging: fsl-dpaa2: ethsw: Add missing netdevice check

2019-02-22 Thread Florian Fainelli
port_switchdev_event() does not check that the target network device is
actually backed by the ethsw driver, this could be problematic in a
stacked environment case.

Fixes: 44baaa43d7cc ("staging: fsl-dpaa2/ethsw: Add Freescale DPAA2 Ethernet 
Switch driver")
Signed-off-by: Florian Fainelli 
---
 drivers/staging/fsl-dpaa2/ethsw/ethsw.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/staging/fsl-dpaa2/ethsw/ethsw.c 
b/drivers/staging/fsl-dpaa2/ethsw/ethsw.c
index daabaceeea52..2edd82f5229a 100644
--- a/drivers/staging/fsl-dpaa2/ethsw/ethsw.c
+++ b/drivers/staging/fsl-dpaa2/ethsw/ethsw.c
@@ -1047,6 +1047,9 @@ static int port_switchdev_event(struct notifier_block 
*unused,
struct ethsw_switchdev_event_work *switchdev_work;
struct switchdev_notifier_fdb_info *fdb_info = ptr;
 
+   if (!ethsw_port_dev_check(dev))
+   return NOTIFY_DONE;
+
switchdev_work = kzalloc(sizeof(*switchdev_work), GFP_ATOMIC);
if (!switchdev_work)
return NOTIFY_BAD;
-- 
2.17.1

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


[PATCH net-next 0/8] net: Remove switchdev_ops

2019-02-22 Thread Florian Fainelli
Hi all,

This patch series completes the removal of the switchdev_ops by
converting switchdev_port_attr_set() to use either the blocking
(process) or non-blocking (atomic) notifier since we typically need to
deal with both depending on where in the bridge code we get called from.

This was tested with the forwarding selftests and DSA hardware.

Ido, Jiri, please review :)

Florian Fainelli (8):
  switchdev: Add SWITCHDEV_PORT_ATTR_SET
  rocker: Handle SWITCHDEV_PORT_ATTR_SET
  net: dsa: Handle SWITCHDEV_PORT_ATTR_SET
  mlxsw: spectrum_switchdev: Handle SWITCHDEV_PORT_ATTR_SET
  net: mscc: ocelot: Handle SWITCHDEV_PORT_ATTR_SET
  staging: fsl-dpaa2: ethsw: Handle SWITCHDEV_PORT_ATTR_SET
  net: switchdev: Replace port attr set SDO with a notification
  net: Remove switchdev_ops

 .../net/ethernet/mellanox/mlxsw/spectrum.c|  12 --
 .../net/ethernet/mellanox/mlxsw/spectrum.h|   2 -
 .../mellanox/mlxsw/spectrum_switchdev.c   |  24 +--
 drivers/net/ethernet/mscc/ocelot.c|  32 +++-
 drivers/net/ethernet/mscc/ocelot.h|   1 +
 drivers/net/ethernet/mscc/ocelot_board.c  |   2 +
 drivers/net/ethernet/rocker/rocker_main.c |  23 ++-
 drivers/staging/fsl-dpaa2/ethsw/ethsw.c   |  26 +++-
 include/linux/netdevice.h |   3 -
 include/net/switchdev.h   |  42 ++---
 net/dsa/slave.c   |  23 ++-
 net/switchdev/switchdev.c | 147 +-
 12 files changed, 200 insertions(+), 137 deletions(-)

-- 
2.17.1

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


[PATCH net-next 3/8] net: dsa: Handle SWITCHDEV_PORT_ATTR_SET

2019-02-22 Thread Florian Fainelli
Following patches will change the way we communicate setting a port's
attribute and use notifiers towards that goal.

Prepare DSA to support receiving notifier events targeting
SWITCHDEV_PORT_ATTR_SET from both atomic and process context and use a
small helper to translate the event notifier into something that
dsa_slave_port_attr_set() can process.

Signed-off-by: Florian Fainelli 
---
 net/dsa/slave.c | 18 ++
 1 file changed, 18 insertions(+)

diff --git a/net/dsa/slave.c b/net/dsa/slave.c
index a78b2bba0332..49a5b29fe884 100644
--- a/net/dsa/slave.c
+++ b/net/dsa/slave.c
@@ -1422,6 +1422,19 @@ static int dsa_slave_netdevice_event(struct 
notifier_block *nb,
return NOTIFY_DONE;
 }
 
+static int
+dsa_slave_switchdev_port_attr_set_event(struct net_device *netdev,
+   struct switchdev_notifier_port_attr_info *port_attr_info)
+{
+   int err;
+
+   err = dsa_slave_port_attr_set(netdev, port_attr_info->attr,
+ port_attr_info->trans);
+
+   port_attr_info->handled = true;
+   return notifier_from_errno(err);
+}
+
 struct dsa_switchdev_event_work {
struct work_struct work;
struct switchdev_notifier_fdb_info fdb_info;
@@ -1500,6 +1513,9 @@ static int dsa_slave_switchdev_event(struct 
notifier_block *unused,
if (!dsa_slave_dev_check(dev))
return NOTIFY_DONE;
 
+   if (event == SWITCHDEV_PORT_ATTR_SET)
+   return dsa_slave_switchdev_port_attr_set_event(dev, ptr);
+
switchdev_work = kzalloc(sizeof(*switchdev_work), GFP_ATOMIC);
if (!switchdev_work)
return NOTIFY_BAD;
@@ -1562,6 +1578,8 @@ static int dsa_slave_switchdev_blocking_event(struct 
notifier_block *unused,
case SWITCHDEV_PORT_OBJ_ADD: /* fall through */
case SWITCHDEV_PORT_OBJ_DEL:
return dsa_slave_switchdev_port_obj_event(event, dev, ptr);
+   case SWITCHDEV_PORT_ATTR_SET:
+   return dsa_slave_switchdev_port_attr_set_event(dev, ptr);
}
 
return NOTIFY_DONE;
-- 
2.17.1

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


[PATCH net-next 8/8] net: Remove switchdev_ops

2019-02-22 Thread Florian Fainelli
Now that we have converted all possible callers to using a switchdev
notifier for attributes we do not have a need for implementing
switchdev_ops anymore, and this can be removed from all drivers the
net_device structure.

Signed-off-by: Florian Fainelli 
---
 .../net/ethernet/mellanox/mlxsw/spectrum.c| 12 ---
 .../net/ethernet/mellanox/mlxsw/spectrum.h|  2 --
 .../mellanox/mlxsw/spectrum_switchdev.c   | 12 ---
 drivers/net/ethernet/mscc/ocelot.c|  5 -
 drivers/net/ethernet/rocker/rocker_main.c |  5 -
 drivers/staging/fsl-dpaa2/ethsw/ethsw.c   |  5 -
 include/linux/netdevice.h |  3 ---
 include/net/switchdev.h   | 21 ---
 net/dsa/slave.c   |  5 -
 9 files changed, 70 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c 
b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
index f018b0607dac..5d998517653a 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
@@ -3215,7 +3215,6 @@ static int mlxsw_sp_port_create(struct mlxsw_sp 
*mlxsw_sp, u8 local_port,
}
mlxsw_sp_port->default_vlan = mlxsw_sp_port_vlan;
 
-   mlxsw_sp_port_switchdev_init(mlxsw_sp_port);
mlxsw_sp->ports[local_port] = mlxsw_sp_port;
err = register_netdev(dev);
if (err) {
@@ -3232,7 +3231,6 @@ static int mlxsw_sp_port_create(struct mlxsw_sp 
*mlxsw_sp, u8 local_port,
 
 err_register_netdev:
mlxsw_sp->ports[local_port] = NULL;
-   mlxsw_sp_port_switchdev_fini(mlxsw_sp_port);
mlxsw_sp_port_vlan_destroy(mlxsw_sp_port_vlan);
 err_port_vlan_create:
 err_port_pvid_set:
@@ -3275,7 +3273,6 @@ static void mlxsw_sp_port_remove(struct mlxsw_sp 
*mlxsw_sp, u8 local_port)
mlxsw_core_port_clear(mlxsw_sp->core, local_port, mlxsw_sp);
unregister_netdev(mlxsw_sp_port->dev); /* This calls ndo_stop */
mlxsw_sp->ports[local_port] = NULL;
-   mlxsw_sp_port_switchdev_fini(mlxsw_sp_port);
mlxsw_sp_port_vlan_flush(mlxsw_sp_port, true);
mlxsw_sp_port_nve_fini(mlxsw_sp_port);
mlxsw_sp_tc_qdisc_fini(mlxsw_sp_port);
@@ -3996,12 +3993,6 @@ static int mlxsw_sp_init(struct mlxsw_core *mlxsw_core,
goto err_span_init;
}
 
-   err = mlxsw_sp_switchdev_init(mlxsw_sp);
-   if (err) {
-   dev_err(mlxsw_sp->bus_info->dev, "Failed to initialize 
switchdev\n");
-   goto err_switchdev_init;
-   }
-
err = mlxsw_sp_counter_pool_init(mlxsw_sp);
if (err) {
dev_err(mlxsw_sp->bus_info->dev, "Failed to init counter 
pool\n");
@@ -4072,8 +4063,6 @@ static int mlxsw_sp_init(struct mlxsw_core *mlxsw_core,
 err_afa_init:
mlxsw_sp_counter_pool_fini(mlxsw_sp);
 err_counter_pool_init:
-   mlxsw_sp_switchdev_fini(mlxsw_sp);
-err_switchdev_init:
mlxsw_sp_span_fini(mlxsw_sp);
 err_span_init:
mlxsw_sp_lag_fini(mlxsw_sp);
@@ -4138,7 +4127,6 @@ static void mlxsw_sp_fini(struct mlxsw_core *mlxsw_core)
mlxsw_sp_nve_fini(mlxsw_sp);
mlxsw_sp_afa_fini(mlxsw_sp);
mlxsw_sp_counter_pool_fini(mlxsw_sp);
-   mlxsw_sp_switchdev_fini(mlxsw_sp);
mlxsw_sp_span_fini(mlxsw_sp);
mlxsw_sp_lag_fini(mlxsw_sp);
mlxsw_sp_buffers_fini(mlxsw_sp);
diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum.h 
b/drivers/net/ethernet/mellanox/mlxsw/spectrum.h
index 8bb83d0facc2..b1342fe9ca48 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum.h
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum.h
@@ -381,8 +381,6 @@ extern const struct mlxsw_sp_sb_vals mlxsw_sp2_sb_vals;
 /* spectrum_switchdev.c */
 int mlxsw_sp_switchdev_init(struct mlxsw_sp *mlxsw_sp);
 void mlxsw_sp_switchdev_fini(struct mlxsw_sp *mlxsw_sp);
-void mlxsw_sp_port_switchdev_init(struct mlxsw_sp_port *mlxsw_sp_port);
-void mlxsw_sp_port_switchdev_fini(struct mlxsw_sp_port *mlxsw_sp_port);
 int mlxsw_sp_rif_fdb_op(struct mlxsw_sp *mlxsw_sp, const char *mac, u16 fid,
bool adding);
 void
diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c 
b/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c
index c1aedfea3a31..f6ce386c3036 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c
@@ -1938,10 +1938,6 @@ static struct mlxsw_sp_port 
*mlxsw_sp_lag_rep_port(struct mlxsw_sp *mlxsw_sp,
return NULL;
 }
 
-static const struct switchdev_ops mlxsw_sp_port_switchdev_ops = {
-   .switchdev_port_attr_set= mlxsw_sp_port_attr_set,
-};
-
 static int
 mlxsw_sp_bridge_8021q_port_join(struct mlxsw_sp_bridge_device *bridge_device,
struct mlxsw_sp_bridge_port *bridge_port,
@@ -3545,11 +3541,3 @@ void mlxsw_sp_switchdev_fini(struct mlxsw_sp *mlxsw_sp)
kfree(mlxsw_sp->bridge);
 }
 
-void mlxsw_sp_port_

[PATCH net-next 6/8] staging: fsl-dpaa2: ethsw: Handle SWITCHDEV_PORT_ATTR_SET

2019-02-22 Thread Florian Fainelli
Following patches will change the way we communicate setting a port's
attribute and use a blocking notifier to perform those tasks.

Prepare ethsw to support receiving notifier events targeting
SWITCHDEV_PORT_ATTR_SET and simply translate that into the existing
swdev_port_attr_set() call.

Signed-off-by: Florian Fainelli 
---
 drivers/staging/fsl-dpaa2/ethsw/ethsw.c | 21 +
 1 file changed, 21 insertions(+)

diff --git a/drivers/staging/fsl-dpaa2/ethsw/ethsw.c 
b/drivers/staging/fsl-dpaa2/ethsw/ethsw.c
index 018399ee8731..73efc2a5fd91 100644
--- a/drivers/staging/fsl-dpaa2/ethsw/ethsw.c
+++ b/drivers/staging/fsl-dpaa2/ethsw/ethsw.c
@@ -1047,6 +1047,12 @@ static int port_switchdev_event(struct notifier_block 
*unused,
struct ethsw_switchdev_event_work *switchdev_work;
struct switchdev_notifier_fdb_info *fdb_info = ptr;
 
+   if (!ethsw_port_dev_check(dev))
+   return NOTIFY_DONE;
+
+   if (event == SWITCHDEV_PORT_ATTR_SET)
+   return ethsw_switchdev_port_attr_set_event(dev, ptr);
+
switchdev_work = kzalloc(sizeof(*switchdev_work), GFP_ATOMIC);
if (!switchdev_work)
return NOTIFY_BAD;
@@ -1103,6 +1109,19 @@ ethsw_switchdev_port_obj_event(unsigned long event, 
struct net_device *netdev,
return notifier_from_errno(err);
 }
 
+static int
+ethsw_switchdev_port_attr_set_event(struct net_device *netdev,
+   struct switchdev_notifier_port_attr_info *port_attr_info)
+{
+   int err;
+
+   err = swdev_port_attr_set(netdev, port_attr_info->attr,
+ port_attr_info->trans);
+
+   port_attr_info->handled = true;
+   return notifier_from_errno(err);
+}
+
 static int port_switchdev_blocking_event(struct notifier_block *unused,
 unsigned long event, void *ptr)
 {
@@ -1115,6 +1134,8 @@ static int port_switchdev_blocking_event(struct 
notifier_block *unused,
case SWITCHDEV_PORT_OBJ_ADD: /* fall through */
case SWITCHDEV_PORT_OBJ_DEL:
return ethsw_switchdev_port_obj_event(event, dev, ptr);
+   case SWITCHDEV_PORT_ATTR_SET:
+   return ethsw_switchdev_port_attr_set_event(dev, ptr);
}
 
return NOTIFY_DONE;
-- 
2.17.1

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


[PATCH net-next 5/8] net: mscc: ocelot: Handle SWITCHDEV_PORT_ATTR_SET

2019-02-22 Thread Florian Fainelli
Following patches will change the way we communicate setting a port's
attribute and use notifiers to perform those tasks.

Ocelot does not currently have an atomic notifier registered for
switchdev events, so we need to register one in order to deal with
atomic context SWITCHDEV_PORT_ATTR_SET events.

Signed-off-by: Florian Fainelli 
---
 drivers/net/ethernet/mscc/ocelot.c   | 27 
 drivers/net/ethernet/mscc/ocelot.h   |  1 +
 drivers/net/ethernet/mscc/ocelot_board.c |  2 ++
 3 files changed, 30 insertions(+)

diff --git a/drivers/net/ethernet/mscc/ocelot.c 
b/drivers/net/ethernet/mscc/ocelot.c
index 195306d05bcd..83a678b11757 100644
--- a/drivers/net/ethernet/mscc/ocelot.c
+++ b/drivers/net/ethernet/mscc/ocelot.c
@@ -1582,6 +1582,28 @@ struct notifier_block ocelot_netdevice_nb __read_mostly 
= {
 };
 EXPORT_SYMBOL(ocelot_netdevice_nb);
 
+static int ocelot_switchdev_event(struct notifier_block *unused,
+ unsigned long event, void *ptr)
+{
+   struct net_device *dev = switchdev_notifier_info_to_dev(ptr);
+   int err;
+
+   switch (event) {
+   case SWITCHDEV_PORT_ATTR_SET:
+   err = switchdev_handle_port_attr_set(dev, ptr,
+ocelot_netdevice_dev_check,
+ocelot_port_attr_set);
+   return notifier_from_errno(err);
+   }
+
+   return NOTIFY_DONE;
+}
+
+struct notifier_block ocelot_switchdev_nb __read_mostly = {
+   .notifier_call = ocelot_switchdev_event,
+};
+EXPORT_SYMBOL(ocelot_switchdev_nb);
+
 static int ocelot_switchdev_blocking_event(struct notifier_block *unused,
   unsigned long event, void *ptr)
 {
@@ -1600,6 +1622,11 @@ static int ocelot_switchdev_blocking_event(struct 
notifier_block *unused,
ocelot_netdevice_dev_check,
ocelot_port_obj_del);
return notifier_from_errno(err);
+   case SWITCHDEV_PORT_ATTR_SET:
+   err = switchdev_handle_port_attr_set(dev, ptr,
+ocelot_netdevice_dev_check,
+ocelot_port_attr_set);
+   return notifier_from_errno(err);
}
 
return NOTIFY_DONE;
diff --git a/drivers/net/ethernet/mscc/ocelot.h 
b/drivers/net/ethernet/mscc/ocelot.h
index 086775f7b52f..ba3b3380b4d0 100644
--- a/drivers/net/ethernet/mscc/ocelot.h
+++ b/drivers/net/ethernet/mscc/ocelot.h
@@ -499,6 +499,7 @@ int ocelot_probe_port(struct ocelot *ocelot, u8 port,
  struct phy_device *phy);
 
 extern struct notifier_block ocelot_netdevice_nb;
+extern struct notifier_block ocelot_switchdev_nb;
 extern struct notifier_block ocelot_switchdev_blocking_nb;
 
 #endif
diff --git a/drivers/net/ethernet/mscc/ocelot_board.c 
b/drivers/net/ethernet/mscc/ocelot_board.c
index ca3ea2fbfcd0..2c1121d86edf 100644
--- a/drivers/net/ethernet/mscc/ocelot_board.c
+++ b/drivers/net/ethernet/mscc/ocelot_board.c
@@ -329,6 +329,7 @@ static int mscc_ocelot_probe(struct platform_device *pdev)
}
 
register_netdevice_notifier(&ocelot_netdevice_nb);
+   register_switchdev_notifier(&ocelot_switchdev_nb);
register_switchdev_blocking_notifier(&ocelot_switchdev_blocking_nb);
 
dev_info(&pdev->dev, "Ocelot switch probed\n");
@@ -345,6 +346,7 @@ static int mscc_ocelot_remove(struct platform_device *pdev)
 
ocelot_deinit(ocelot);
unregister_switchdev_blocking_notifier(&ocelot_switchdev_blocking_nb);
+   unregister_switchdev_notifier(&ocelot_switchdev_nb);
unregister_netdevice_notifier(&ocelot_netdevice_nb);
 
return 0;
-- 
2.17.1

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


[PATCH net-next 1/8] switchdev: Add SWITCHDEV_PORT_ATTR_SET

2019-02-22 Thread Florian Fainelli
In preparation for allowing switchdev enabled drivers to veto specific
attribute settings from within the context of the caller, introduce a
new switchdev notifier type for port attributes.

Suggested-by: Ido Schimmel 
Signed-off-by: Florian Fainelli 
---
 include/net/switchdev.h   | 27 +
 net/switchdev/switchdev.c | 51 +++
 2 files changed, 78 insertions(+)

diff --git a/include/net/switchdev.h b/include/net/switchdev.h
index 45310ddf2d7e..ca56b7487540 100644
--- a/include/net/switchdev.h
+++ b/include/net/switchdev.h
@@ -136,6 +136,7 @@ enum switchdev_notifier_type {
 
SWITCHDEV_PORT_OBJ_ADD, /* Blocking. */
SWITCHDEV_PORT_OBJ_DEL, /* Blocking. */
+   SWITCHDEV_PORT_ATTR_SET, /* May be blocking . */
 
SWITCHDEV_VXLAN_FDB_ADD_TO_BRIDGE,
SWITCHDEV_VXLAN_FDB_DEL_TO_BRIDGE,
@@ -164,6 +165,13 @@ struct switchdev_notifier_port_obj_info {
bool handled;
 };
 
+struct switchdev_notifier_port_attr_info {
+   struct switchdev_notifier_info info; /* must be first */
+   const struct switchdev_attr *attr;
+   struct switchdev_trans *trans;
+   bool handled;
+};
+
 static inline struct net_device *
 switchdev_notifier_info_to_dev(const struct switchdev_notifier_info *info)
 {
@@ -216,7 +224,15 @@ int switchdev_handle_port_obj_del(struct net_device *dev,
int (*del_cb)(struct net_device *dev,
  const struct switchdev_obj *obj));
 
+int switchdev_handle_port_attr_set(struct net_device *dev,
+   struct switchdev_notifier_port_attr_info 
*port_attr_info,
+   bool (*check_cb)(const struct net_device *dev),
+   int (*set_cb)(struct net_device *dev,
+ const struct switchdev_attr *attr,
+ struct switchdev_trans *trans));
+
 #define SWITCHDEV_SET_OPS(netdev, ops) ((netdev)->switchdev_ops = (ops))
+
 #else
 
 static inline void switchdev_deferred_process(void)
@@ -303,6 +319,17 @@ switchdev_handle_port_obj_del(struct net_device *dev,
return 0;
 }
 
+static inline int
+switchdev_handle_port_attr_set(struct net_device *dev,
+   struct switchdev_notifier_port_attr_info 
*port_attr_info,
+   bool (*check_cb)(const struct net_device *dev),
+   int (*set_cb)(struct net_device *dev,
+ const struct switchdev_attr *attr,
+ struct switchdev_trans *trans))
+{
+   return 0;
+}
+
 #define SWITCHDEV_SET_OPS(netdev, ops) do {} while (0)
 
 #endif
diff --git a/net/switchdev/switchdev.c b/net/switchdev/switchdev.c
index 7e1357db33d7..94400f5b8e07 100644
--- a/net/switchdev/switchdev.c
+++ b/net/switchdev/switchdev.c
@@ -697,3 +697,54 @@ int switchdev_handle_port_obj_del(struct net_device *dev,
return err;
 }
 EXPORT_SYMBOL_GPL(switchdev_handle_port_obj_del);
+
+static int __switchdev_handle_port_attr_set(struct net_device *dev,
+   struct switchdev_notifier_port_attr_info 
*port_attr_info,
+   bool (*check_cb)(const struct net_device *dev),
+   int (*set_cb)(struct net_device *dev,
+ const struct switchdev_attr *attr,
+ struct switchdev_trans *trans))
+{
+   struct net_device *lower_dev;
+   struct list_head *iter;
+   int err = -EOPNOTSUPP;
+
+   if (check_cb(dev)) {
+   port_attr_info->handled = true;
+   return set_cb(dev, port_attr_info->attr,
+ port_attr_info->trans);
+   }
+
+   /* Switch ports might be stacked under e.g. a LAG. Ignore the
+* unsupported devices, another driver might be able to handle them. But
+* propagate to the callers any hard errors.
+*
+* If the driver does its own bookkeeping of stacked ports, it's not
+* necessary to go through this helper.
+*/
+   netdev_for_each_lower_dev(dev, lower_dev, iter) {
+   err = __switchdev_handle_port_attr_set(lower_dev, 
port_attr_info,
+  check_cb, set_cb);
+   if (err && err != -EOPNOTSUPP)
+   return err;
+   }
+
+   return err;
+}
+
+int switchdev_handle_port_attr_set(struct net_device *dev,
+   struct switchdev_notifier_port_attr_info 
*port_attr_info,
+   bool (*check_cb)(const struct net_device *dev),
+   int (*set_cb)(struct net_device *dev,
+ const struct switchdev_attr *attr,
+ struct switchdev_trans *trans))
+{
+   int err;
+
+   err = __switchdev_handle_port_attr_set(dev, port_attr_info, check_cb,
+ 

[PATCH net-next 7/8] net: switchdev: Replace port attr set SDO with a notification

2019-02-22 Thread Florian Fainelli
Drop switchdev_ops.switchdev_port_attr_set. Drop the uses of this field
from all clients, which were migrated to use switchdev notification in
the previous patches.

Add a new function switchdev_port_attr_notify() that sends the switchdev
notifications SWITCHDEV_PORT_ATTR_SET and takes care, depending on
SWITCHDEV_F_DEFER to call the blocking (process) or non-blocking
(atomic) notifier chain accordingly.

Drop __switchdev_port_attr_set() and update switchdev_port_attr_set()
likewise.

Signed-off-by: Florian Fainelli 
---
 net/switchdev/switchdev.c | 96 +++
 1 file changed, 26 insertions(+), 70 deletions(-)

diff --git a/net/switchdev/switchdev.c b/net/switchdev/switchdev.c
index 94400f5b8e07..a1f16836ef89 100644
--- a/net/switchdev/switchdev.c
+++ b/net/switchdev/switchdev.c
@@ -174,81 +174,35 @@ static int switchdev_deferred_enqueue(struct net_device 
*dev,
return 0;
 }
 
-/**
- * switchdev_port_attr_get - Get port attribute
- *
- * @dev: port device
- * @attr: attribute to get
- */
-int switchdev_port_attr_get(struct net_device *dev, struct switchdev_attr 
*attr)
+static int switchdev_port_attr_notify(enum switchdev_notifier_type nt,
+ struct net_device *dev,
+ const struct switchdev_attr *attr,
+ struct switchdev_trans *trans)
 {
-   const struct switchdev_ops *ops = dev->switchdev_ops;
-   struct net_device *lower_dev;
-   struct list_head *iter;
-   struct switchdev_attr first = {
-   .id = SWITCHDEV_ATTR_ID_UNDEFINED
-   };
-   int err = -EOPNOTSUPP;
+   int err;
+   int rc;
 
-   if (ops && ops->switchdev_port_attr_get)
-   return ops->switchdev_port_attr_get(dev, attr);
+   struct switchdev_notifier_port_attr_info attr_info = {
+   .attr = attr,
+   .trans = trans,
+   .handled = false,
+   };
 
-   if (attr->flags & SWITCHDEV_F_NO_RECURSE)
+   if (attr & SWITCHDEV_F_DEFER)
+   rc = call_switchdev_blocking_notifiers(nt, dev,
+  &attr_info.info, NULL);
+   else
+   rc = call_switchdev_notifiers(nt, dev, &attr_info.info, NULL);
+   err = notifier_to_errno(rc);
+   if (err) {
+   WARN_ON(!attr_info.handled);
return err;
-
-   /* Switch device port(s) may be stacked under
-* bond/team/vlan dev, so recurse down to get attr on
-* each port.  Return -ENODATA if attr values don't
-* compare across ports.
-*/
-
-   netdev_for_each_lower_dev(dev, lower_dev, iter) {
-   err = switchdev_port_attr_get(lower_dev, attr);
-   if (err)
-   break;
-   if (first.id == SWITCHDEV_ATTR_ID_UNDEFINED)
-   first = *attr;
-   else if (memcmp(&first, attr, sizeof(*attr)))
-   return -ENODATA;
}
 
-   return err;
-}
-EXPORT_SYMBOL_GPL(switchdev_port_attr_get);
-
-static int __switchdev_port_attr_set(struct net_device *dev,
-const struct switchdev_attr *attr,
-struct switchdev_trans *trans)
-{
-   const struct switchdev_ops *ops = dev->switchdev_ops;
-   struct net_device *lower_dev;
-   struct list_head *iter;
-   int err = -EOPNOTSUPP;
-
-   if (ops && ops->switchdev_port_attr_set) {
-   err = ops->switchdev_port_attr_set(dev, attr, trans);
-   goto done;
-   }
-
-   if (attr->flags & SWITCHDEV_F_NO_RECURSE)
-   goto done;
-
-   /* Switch device port(s) may be stacked under
-* bond/team/vlan dev, so recurse down to set attr on
-* each port.
-*/
-
-   netdev_for_each_lower_dev(dev, lower_dev, iter) {
-   err = __switchdev_port_attr_set(lower_dev, attr, trans);
-   if (err)
-   break;
-   }
-
-done:
-   if (err == -EOPNOTSUPP && attr->flags & SWITCHDEV_F_SKIP_EOPNOTSUPP)
-   err = 0;
+   if (!attr_info.handled)
+   return -EOPNOTSUPP;
 
-   return err;
+   return 0;
 }
 
 static int switchdev_port_attr_set_now(struct net_device *dev,
@@ -267,7 +221,8 @@ static int switchdev_port_attr_set_now(struct net_device 
*dev,
 */
 
trans.ph_prepare = true;
-   err = __switchdev_port_attr_set(dev, attr, &trans);
+   err = switchdev_port_attr_notify(SWITCHDEV_PORT_ATTR_SET, dev, attr,
+&trans);
if (err) {
/* Prepare phase failed: abort the transaction.  Any
 * resources reserved in the prepare phase are
@@ -286,7 +241,8 @@ static int switchdev_port_attr_set_now(struct net_device 
*dev,
 */
 
trans.ph_prepare = false;
-   err

[PATCH net-next 4/8] mlxsw: spectrum_switchdev: Handle SWITCHDEV_PORT_ATTR_SET

2019-02-22 Thread Florian Fainelli
Following patches will change the way we communicate setting a port's
attribute and use a notifier to perform those tasks.

Prepare mlxsw to support receiving notifier events targeting
SWITCHDEV_PORT_ATTR_SET and utilize the switchdev_handle_port_attr_set()
to handle stacking of devices.

Signed-off-by: Florian Fainelli 
---
 .../net/ethernet/mellanox/mlxsw/spectrum_switchdev.c | 12 
 1 file changed, 12 insertions(+)

diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c 
b/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c
index 766f5b5f1cf5..c1aedfea3a31 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c
@@ -3123,6 +3123,13 @@ static int mlxsw_sp_switchdev_event(struct 
notifier_block *unused,
struct net_device *br_dev;
int err;
 
+   if (event == SWITCHDEV_PORT_ATTR_SET) {
+   err = switchdev_handle_port_attr_set(dev, ptr,
+mlxsw_sp_port_dev_check,
+mlxsw_sp_port_attr_set);
+   return notifier_from_errno(err);
+   }
+
/* Tunnel devices are not our uppers, so check their master instead */
br_dev = netdev_master_upper_dev_get_rcu(dev);
if (!br_dev)
@@ -3446,6 +3453,11 @@ static int mlxsw_sp_switchdev_blocking_event(struct 
notifier_block *unused,
mlxsw_sp_port_dev_check,
mlxsw_sp_port_obj_del);
return notifier_from_errno(err);
+   case SWITCHDEV_PORT_ATTR_SET:
+   err = switchdev_handle_port_attr_set(dev, ptr,
+mlxsw_sp_port_dev_check,
+mlxsw_sp_port_attr_set);
+   return notifier_from_errno(err);
}
 
return NOTIFY_DONE;
-- 
2.17.1

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


[PATCH net-next 2/8] rocker: Handle SWITCHDEV_PORT_ATTR_SET

2019-02-22 Thread Florian Fainelli
Following patches will change the way we communicate setting a port's
attribute and use notifiers towards that goal.

Prepare rocker to support receiving notifier events targeting
SWITCHDEV_PORT_ATTR_SET from both atomic and process context and use a
small helper to translate the event notifier into something that
rocker_port_attr_set() can process.

Signed-off-by: Florian Fainelli 
---
 drivers/net/ethernet/rocker/rocker_main.c | 18 ++
 1 file changed, 18 insertions(+)

diff --git a/drivers/net/ethernet/rocker/rocker_main.c 
b/drivers/net/ethernet/rocker/rocker_main.c
index 309a6bf9130c..fc772cf079cc 100644
--- a/drivers/net/ethernet/rocker/rocker_main.c
+++ b/drivers/net/ethernet/rocker/rocker_main.c
@@ -2710,6 +2710,19 @@ static bool rocker_port_dev_check(const struct 
net_device *dev)
return dev->netdev_ops == &rocker_port_netdev_ops;
 }
 
+static int
+rocker_switchdev_port_attr_set_event(struct net_device *netdev,
+   struct switchdev_notifier_port_attr_info *port_attr_info)
+{
+   int err;
+
+   err = rocker_port_attr_set(netdev, port_attr_info->attr,
+  port_attr_info->trans);
+
+   port_attr_info->handled = true;
+   return notifier_from_errno(err);
+}
+
 struct rocker_switchdev_event_work {
struct work_struct work;
struct switchdev_notifier_fdb_info fdb_info;
@@ -2779,6 +2792,9 @@ static int rocker_switchdev_event(struct notifier_block 
*unused,
if (!rocker_port_dev_check(dev))
return NOTIFY_DONE;
 
+   if (event == SWITCHDEV_PORT_ATTR_SET)
+   return rocker_switchdev_port_attr_set_event(dev, ptr);
+
rocker_port = netdev_priv(dev);
switchdev_work = kzalloc(sizeof(*switchdev_work), GFP_ATOMIC);
if (WARN_ON(!switchdev_work))
@@ -2841,6 +2857,8 @@ static int rocker_switchdev_blocking_event(struct 
notifier_block *unused,
case SWITCHDEV_PORT_OBJ_ADD:
case SWITCHDEV_PORT_OBJ_DEL:
return rocker_switchdev_port_obj_event(event, dev, ptr);
+   case SWITCHDEV_PORT_ATTR_SET:
+   return rocker_switchdev_port_attr_set_event(dev, ptr);
}
 
return NOTIFY_DONE;
-- 
2.17.1

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


[PATCH 1/8] switchdev: Add SWITCHDEV_PORT_ATTR_SET

2019-02-22 Thread Florian Fainelli
In preparation for allowing switchdev enabled drivers to veto specific
attribute settings from within the context of the caller, introduce a
new switchdev notifier type for port attributes.

Suggested-by: Ido Schimmel 
Signed-off-by: Florian Fainelli 
---
 include/net/switchdev.h   | 27 +
 net/switchdev/switchdev.c | 51 +++
 2 files changed, 78 insertions(+)

diff --git a/include/net/switchdev.h b/include/net/switchdev.h
index 45310ddf2d7e..ca56b7487540 100644
--- a/include/net/switchdev.h
+++ b/include/net/switchdev.h
@@ -136,6 +136,7 @@ enum switchdev_notifier_type {
 
SWITCHDEV_PORT_OBJ_ADD, /* Blocking. */
SWITCHDEV_PORT_OBJ_DEL, /* Blocking. */
+   SWITCHDEV_PORT_ATTR_SET, /* May be blocking . */
 
SWITCHDEV_VXLAN_FDB_ADD_TO_BRIDGE,
SWITCHDEV_VXLAN_FDB_DEL_TO_BRIDGE,
@@ -164,6 +165,13 @@ struct switchdev_notifier_port_obj_info {
bool handled;
 };
 
+struct switchdev_notifier_port_attr_info {
+   struct switchdev_notifier_info info; /* must be first */
+   const struct switchdev_attr *attr;
+   struct switchdev_trans *trans;
+   bool handled;
+};
+
 static inline struct net_device *
 switchdev_notifier_info_to_dev(const struct switchdev_notifier_info *info)
 {
@@ -216,7 +224,15 @@ int switchdev_handle_port_obj_del(struct net_device *dev,
int (*del_cb)(struct net_device *dev,
  const struct switchdev_obj *obj));
 
+int switchdev_handle_port_attr_set(struct net_device *dev,
+   struct switchdev_notifier_port_attr_info 
*port_attr_info,
+   bool (*check_cb)(const struct net_device *dev),
+   int (*set_cb)(struct net_device *dev,
+ const struct switchdev_attr *attr,
+ struct switchdev_trans *trans));
+
 #define SWITCHDEV_SET_OPS(netdev, ops) ((netdev)->switchdev_ops = (ops))
+
 #else
 
 static inline void switchdev_deferred_process(void)
@@ -303,6 +319,17 @@ switchdev_handle_port_obj_del(struct net_device *dev,
return 0;
 }
 
+static inline int
+switchdev_handle_port_attr_set(struct net_device *dev,
+   struct switchdev_notifier_port_attr_info 
*port_attr_info,
+   bool (*check_cb)(const struct net_device *dev),
+   int (*set_cb)(struct net_device *dev,
+ const struct switchdev_attr *attr,
+ struct switchdev_trans *trans))
+{
+   return 0;
+}
+
 #define SWITCHDEV_SET_OPS(netdev, ops) do {} while (0)
 
 #endif
diff --git a/net/switchdev/switchdev.c b/net/switchdev/switchdev.c
index 7e1357db33d7..94400f5b8e07 100644
--- a/net/switchdev/switchdev.c
+++ b/net/switchdev/switchdev.c
@@ -697,3 +697,54 @@ int switchdev_handle_port_obj_del(struct net_device *dev,
return err;
 }
 EXPORT_SYMBOL_GPL(switchdev_handle_port_obj_del);
+
+static int __switchdev_handle_port_attr_set(struct net_device *dev,
+   struct switchdev_notifier_port_attr_info 
*port_attr_info,
+   bool (*check_cb)(const struct net_device *dev),
+   int (*set_cb)(struct net_device *dev,
+ const struct switchdev_attr *attr,
+ struct switchdev_trans *trans))
+{
+   struct net_device *lower_dev;
+   struct list_head *iter;
+   int err = -EOPNOTSUPP;
+
+   if (check_cb(dev)) {
+   port_attr_info->handled = true;
+   return set_cb(dev, port_attr_info->attr,
+ port_attr_info->trans);
+   }
+
+   /* Switch ports might be stacked under e.g. a LAG. Ignore the
+* unsupported devices, another driver might be able to handle them. But
+* propagate to the callers any hard errors.
+*
+* If the driver does its own bookkeeping of stacked ports, it's not
+* necessary to go through this helper.
+*/
+   netdev_for_each_lower_dev(dev, lower_dev, iter) {
+   err = __switchdev_handle_port_attr_set(lower_dev, 
port_attr_info,
+  check_cb, set_cb);
+   if (err && err != -EOPNOTSUPP)
+   return err;
+   }
+
+   return err;
+}
+
+int switchdev_handle_port_attr_set(struct net_device *dev,
+   struct switchdev_notifier_port_attr_info 
*port_attr_info,
+   bool (*check_cb)(const struct net_device *dev),
+   int (*set_cb)(struct net_device *dev,
+ const struct switchdev_attr *attr,
+ struct switchdev_trans *trans))
+{
+   int err;
+
+   err = __switchdev_handle_port_attr_set(dev, port_attr_info, check_cb,
+ 

[PATCH] staging/ks7070: Removed unused varibale

2019-02-22 Thread Bo YU
From: Bo Yu 

Compiling the kernel with W=1 results in the following warning:

drivers/staging/ks7010/ks_hostif.c:465:6: warning: variable ‘mib_val_type’
set but not used [-Wunused-but-set-variable]
  u16 mib_val_type;

drivers/staging/ks7010/ks_hostif.c:464:6: warning: variable ‘mib_val_size’
set but not used [-Wunused-but-set-variable]
u16 mib_val_size;

drivers/staging/ks7010/ks_hostif.c:786:6: warning: variable ‘result_code’
set but not used [-Wunused-but-set-variable]
  u16 result_code;

Remove these variables.

Rebase on next-20190222

Cc: Greg Kroah-Hartman 
Cc: Sergio Paracuellos 
Cc: Quytelda Kahja 

Signed-off-by: Bo Yu 
---
 drivers/staging/ks7010/ks_hostif.c | 6 --
 1 file changed, 6 deletions(-)

diff --git a/drivers/staging/ks7010/ks_hostif.c 
b/drivers/staging/ks7010/ks_hostif.c
index d938b0997a53..913d8996437a 100644
--- a/drivers/staging/ks7010/ks_hostif.c
+++ b/drivers/staging/ks7010/ks_hostif.c
@@ -461,13 +461,9 @@ void hostif_mib_get_confirm(struct ks_wlan_private *priv)
struct net_device *dev = priv->net_dev;
u32 mib_status;
u32 mib_attribute;
-   u16 mib_val_size;
-   u16 mib_val_type;
 
mib_status = get_dword(priv);
mib_attribute = get_dword(priv);
-   mib_val_size = get_word(priv);
-   mib_val_type = get_word(priv);
 
if (mib_status) {
netdev_err(priv->net_dev, "attribute=%08X, status=%08X\n",
@@ -783,9 +779,7 @@ void hostif_ps_adhoc_set_confirm(struct ks_wlan_private 
*priv)
 static
 void hostif_infrastructure_set_confirm(struct ks_wlan_private *priv)
 {
-   u16 result_code;
 
-   result_code = get_word(priv);
priv->infra_status = 1; /* infrastructure mode set */
hostif_sme_enqueue(priv, SME_MODE_SET_CONFIRM);
 }
-- 
2.11.0

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


Re: [PATCH] staging/ks7070: Removed unused varibale

2019-02-22 Thread Sergio Paracuellos
Hi Bo,

On Sat, Feb 23, 2019 at 7:39 AM Bo YU  wrote:
>
> From: Bo Yu 
>
> Compiling the kernel with W=1 results in the following warning:
>
> drivers/staging/ks7010/ks_hostif.c:465:6: warning: variable ‘mib_val_type’
> set but not used [-Wunused-but-set-variable]
>   u16 mib_val_type;
>
> drivers/staging/ks7010/ks_hostif.c:464:6: warning: variable ‘mib_val_size’
> set but not used [-Wunused-but-set-variable]
> u16 mib_val_size;
>
> drivers/staging/ks7010/ks_hostif.c:786:6: warning: variable ‘result_code’
> set but not used [-Wunused-but-set-variable]
>   u16 result_code;
>
> Remove these variables.
>
> Rebase on next-20190222
>
> Cc: Greg Kroah-Hartman 
> Cc: Sergio Paracuellos 
> Cc: Quytelda Kahja 
>
> Signed-off-by: Bo Yu 
> ---
>  drivers/staging/ks7010/ks_hostif.c | 6 --
>  1 file changed, 6 deletions(-)
>
> diff --git a/drivers/staging/ks7010/ks_hostif.c 
> b/drivers/staging/ks7010/ks_hostif.c
> index d938b0997a53..913d8996437a 100644
> --- a/drivers/staging/ks7010/ks_hostif.c
> +++ b/drivers/staging/ks7010/ks_hostif.c
> @@ -461,13 +461,9 @@ void hostif_mib_get_confirm(struct ks_wlan_private *priv)
> struct net_device *dev = priv->net_dev;
> u32 mib_status;
> u32 mib_attribute;
> -   u16 mib_val_size;
> -   u16 mib_val_type;
>
> mib_status = get_dword(priv);
> mib_attribute = get_dword(priv);
> -   mib_val_size = get_word(priv);
> -   mib_val_type = get_word(priv);
>
> if (mib_status) {
> netdev_err(priv->net_dev, "attribute=%08X, status=%08X\n",
> @@ -783,9 +779,7 @@ void hostif_ps_adhoc_set_confirm(struct ks_wlan_private 
> *priv)
>  static
>  void hostif_infrastructure_set_confirm(struct ks_wlan_private *priv)
>  {
> -   u16 result_code;
>
> -   result_code = get_word(priv);
> priv->infra_status = 1; /* infrastructure mode set */
> hostif_sme_enqueue(priv, SME_MODE_SET_CONFIRM);
>  }
> --
> 2.11.0
>

PATCH commit message is wrong: format, typos and driver name:

[PATCH] staging/ks7070: Removed unused varibale

Should be "staging: ks7010: removed unused variables"

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


Re: [PATCH] staging/ks7070: Removed unused varibale

2019-02-22 Thread Dan Carpenter
On Sat, Feb 23, 2019 at 01:39:39AM -0500, Bo YU wrote:
> From: Bo Yu 
> 
> Compiling the kernel with W=1 results in the following warning:
> 
> drivers/staging/ks7010/ks_hostif.c:465:6: warning: variable ‘mib_val_type’
> set but not used [-Wunused-but-set-variable]
>   u16 mib_val_type;
> 
> drivers/staging/ks7010/ks_hostif.c:464:6: warning: variable ‘mib_val_size’
> set but not used [-Wunused-but-set-variable]
> u16 mib_val_size;
> 
> drivers/staging/ks7010/ks_hostif.c:786:6: warning: variable ‘result_code’
> set but not used [-Wunused-but-set-variable]
>   u16 result_code;
> 
> Remove these variables.
> 
> Rebase on next-20190222
  ^^^
Is this a v2 patch or something?  Don't include this in the changelog.
Put it under the --- cut off line.

> 
> Cc: Greg Kroah-Hartman 
> Cc: Sergio Paracuellos 
> Cc: Quytelda Kahja 
> 
> Signed-off-by: Bo Yu 
> ---
  ^^^

>  drivers/staging/ks7010/ks_hostif.c | 6 --
>  1 file changed, 6 deletions(-)
> 

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


[PATCH V2] staging: ks7070: removed unused varibales

2019-02-22 Thread Bo YU
From: Bo Yu 

Compiling the kernel with W=1 results in the following warning:

drivers/staging/ks7010/ks_hostif.c:465:6: warning: variable ‘mib_val_type’
set but not used [-Wunused-but-set-variable]
  u16 mib_val_type;

drivers/staging/ks7010/ks_hostif.c:464:6: warning: variable ‘mib_val_size’
set but not used [-Wunused-but-set-variable]
u16 mib_val_size;

drivers/staging/ks7010/ks_hostif.c:786:6: warning: variable ‘result_code’
set but not used [-Wunused-but-set-variable]
  u16 result_code;

Remove these variables.

Rebase on next-20190222

V2: fix patch format

Cc: Greg Kroah-Hartman 
Cc: Sergio Paracuellos 
Cc: Quytelda Kahja 

Signed-off-by: Bo Yu 
---
 drivers/staging/ks7010/ks_hostif.c | 6 --
 1 file changed, 6 deletions(-)

diff --git a/drivers/staging/ks7010/ks_hostif.c 
b/drivers/staging/ks7010/ks_hostif.c
index d938b0997a53..913d8996437a 100644
--- a/drivers/staging/ks7010/ks_hostif.c
+++ b/drivers/staging/ks7010/ks_hostif.c
@@ -461,13 +461,9 @@ void hostif_mib_get_confirm(struct ks_wlan_private *priv)
struct net_device *dev = priv->net_dev;
u32 mib_status;
u32 mib_attribute;
-   u16 mib_val_size;
-   u16 mib_val_type;
 
mib_status = get_dword(priv);
mib_attribute = get_dword(priv);
-   mib_val_size = get_word(priv);
-   mib_val_type = get_word(priv);
 
if (mib_status) {
netdev_err(priv->net_dev, "attribute=%08X, status=%08X\n",
@@ -783,9 +779,7 @@ void hostif_ps_adhoc_set_confirm(struct ks_wlan_private 
*priv)
 static
 void hostif_infrastructure_set_confirm(struct ks_wlan_private *priv)
 {
-   u16 result_code;
 
-   result_code = get_word(priv);
priv->infra_status = 1; /* infrastructure mode set */
hostif_sme_enqueue(priv, SME_MODE_SET_CONFIRM);
 }
-- 
2.11.0

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


Re: [PATCH V2] staging: ks7070: removed unused varibales

2019-02-22 Thread YU Bo

On Sat, Feb 23, 2019 at 02:27:12AM -0500, Bo YU wrote:

From: Bo Yu 

Compiling the kernel with W=1 results in the following warning:

drivers/staging/ks7010/ks_hostif.c:465:6: warning: variable ‘mib_val_type’
set but not used [-Wunused-but-set-variable]
 u16 mib_val_type;

drivers/staging/ks7010/ks_hostif.c:464:6: warning: variable ‘mib_val_size’
set but not used [-Wunused-but-set-variable]
   u16 mib_val_size;

drivers/staging/ks7010/ks_hostif.c:786:6: warning: variable ‘result_code’
set but not used [-Wunused-but-set-variable]
 u16 result_code;

Remove these variables.

Rebase on next-20190222

V2: fix patch format

Please drop it, will send V3
Thanks


Cc: Greg Kroah-Hartman 
Cc: Sergio Paracuellos 
Cc: Quytelda Kahja 

Signed-off-by: Bo Yu 
---
drivers/staging/ks7010/ks_hostif.c | 6 --
1 file changed, 6 deletions(-)

diff --git a/drivers/staging/ks7010/ks_hostif.c 
b/drivers/staging/ks7010/ks_hostif.c
index d938b0997a53..913d8996437a 100644
--- a/drivers/staging/ks7010/ks_hostif.c
+++ b/drivers/staging/ks7010/ks_hostif.c
@@ -461,13 +461,9 @@ void hostif_mib_get_confirm(struct ks_wlan_private *priv)
struct net_device *dev = priv->net_dev;
u32 mib_status;
u32 mib_attribute;
-   u16 mib_val_size;
-   u16 mib_val_type;

mib_status = get_dword(priv);
mib_attribute = get_dword(priv);
-   mib_val_size = get_word(priv);
-   mib_val_type = get_word(priv);

if (mib_status) {
netdev_err(priv->net_dev, "attribute=%08X, status=%08X\n",
@@ -783,9 +779,7 @@ void hostif_ps_adhoc_set_confirm(struct ks_wlan_private 
*priv)
static
void hostif_infrastructure_set_confirm(struct ks_wlan_private *priv)
{
-   u16 result_code;

-   result_code = get_word(priv);
priv->infra_status = 1;  /* infrastructure mode set */
hostif_sme_enqueue(priv, SME_MODE_SET_CONFIRM);
}
--
2.11.0


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


Re: [PATCH V2] staging: ks7070: removed unused varibales

2019-02-22 Thread Sergio Paracuellos
Hi Bo,

On Sat, Feb 23, 2019 at 8:27 AM Bo YU  wrote:
>
> From: Bo Yu 
>
> Compiling the kernel with W=1 results in the following warning:
>
> drivers/staging/ks7010/ks_hostif.c:465:6: warning: variable ‘mib_val_type’
> set but not used [-Wunused-but-set-variable]
>   u16 mib_val_type;
>
> drivers/staging/ks7010/ks_hostif.c:464:6: warning: variable ‘mib_val_size’
> set but not used [-Wunused-but-set-variable]
> u16 mib_val_size;
>
> drivers/staging/ks7010/ks_hostif.c:786:6: warning: variable ‘result_code’
> set but not used [-Wunused-but-set-variable]
>   u16 result_code;
>
> Remove these variables.
>
> Rebase on next-20190222
> V2: fix patch format

As Dan has just said, this two rebase and v2 stuff is not needed in
the changelog.
Please, put it under the --- cut off line.

>
> Cc: Greg Kroah-Hartman 
> Cc: Sergio Paracuellos 
> Cc: Quytelda Kahja 
>
> Signed-off-by: Bo Yu 
> ---
>  drivers/staging/ks7010/ks_hostif.c | 6 --
>  1 file changed, 6 deletions(-)
>
> diff --git a/drivers/staging/ks7010/ks_hostif.c 
> b/drivers/staging/ks7010/ks_hostif.c
> index d938b0997a53..913d8996437a 100644
> --- a/drivers/staging/ks7010/ks_hostif.c
> +++ b/drivers/staging/ks7010/ks_hostif.c
> @@ -461,13 +461,9 @@ void hostif_mib_get_confirm(struct ks_wlan_private *priv)
> struct net_device *dev = priv->net_dev;
> u32 mib_status;
> u32 mib_attribute;
> -   u16 mib_val_size;
> -   u16 mib_val_type;
>
> mib_status = get_dword(priv);
> mib_attribute = get_dword(priv);
> -   mib_val_size = get_word(priv);
> -   mib_val_type = get_word(priv);
>
> if (mib_status) {
> netdev_err(priv->net_dev, "attribute=%08X, status=%08X\n",
> @@ -783,9 +779,7 @@ void hostif_ps_adhoc_set_confirm(struct ks_wlan_private 
> *priv)
>  static
>  void hostif_infrastructure_set_confirm(struct ks_wlan_private *priv)
>  {
> -   u16 result_code;
>
> -   result_code = get_word(priv);
> priv->infra_status = 1; /* infrastructure mode set */
> hostif_sme_enqueue(priv, SME_MODE_SET_CONFIRM);
>  }
> --
> 2.11.0
>

The commit message is still wrong. The driver name is not called
ks7070 is called ks7010, right? and
also the typo with "varibales" is still wrong... Let's do all changes
right at once, please :)

Best regards,
Sergio Paracuellos
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging/ks7070: Removed unused varibale

2019-02-22 Thread Greg KH
On Sat, Feb 23, 2019 at 01:39:39AM -0500, Bo YU wrote:
> From: Bo Yu 
> 
> Compiling the kernel with W=1 results in the following warning:
> 
> drivers/staging/ks7010/ks_hostif.c:465:6: warning: variable ‘mib_val_type’
> set but not used [-Wunused-but-set-variable]
>   u16 mib_val_type;
> 
> drivers/staging/ks7010/ks_hostif.c:464:6: warning: variable ‘mib_val_size’
> set but not used [-Wunused-but-set-variable]
> u16 mib_val_size;
> 
> drivers/staging/ks7010/ks_hostif.c:786:6: warning: variable ‘result_code’
> set but not used [-Wunused-but-set-variable]
>   u16 result_code;
> 
> Remove these variables.
> 
> Rebase on next-20190222
> 
> Cc: Greg Kroah-Hartman 
> Cc: Sergio Paracuellos 
> Cc: Quytelda Kahja 
> 
> Signed-off-by: Bo Yu 
> ---
>  drivers/staging/ks7010/ks_hostif.c | 6 --
>  1 file changed, 6 deletions(-)
> 
> diff --git a/drivers/staging/ks7010/ks_hostif.c 
> b/drivers/staging/ks7010/ks_hostif.c
> index d938b0997a53..913d8996437a 100644
> --- a/drivers/staging/ks7010/ks_hostif.c
> +++ b/drivers/staging/ks7010/ks_hostif.c
> @@ -461,13 +461,9 @@ void hostif_mib_get_confirm(struct ks_wlan_private *priv)
>   struct net_device *dev = priv->net_dev;
>   u32 mib_status;
>   u32 mib_attribute;
> - u16 mib_val_size;
> - u16 mib_val_type;
>  
>   mib_status = get_dword(priv);
>   mib_attribute = get_dword(priv);
> - mib_val_size = get_word(priv);
> - mib_val_type = get_word(priv);

The function get_word() actually does something to the priv structure,
so you just broke the driver :(

>  
>   if (mib_status) {
>   netdev_err(priv->net_dev, "attribute=%08X, status=%08X\n",
> @@ -783,9 +779,7 @@ void hostif_ps_adhoc_set_confirm(struct ks_wlan_private 
> *priv)
>  static
>  void hostif_infrastructure_set_confirm(struct ks_wlan_private *priv)
>  {
> - u16 result_code;
>  
> - result_code = get_word(priv);
>   priv->infra_status = 1; /* infrastructure mode set */
>   hostif_sme_enqueue(priv, SME_MODE_SET_CONFIRM);

Same here, odds are you just broke things :(

Please be more careful.

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


[PATCH V3] staging: ks7010: removed unused variables

2019-02-22 Thread Bo YU
From: Bo Yu 

Compiling the kernel with W=1 results in the following warning:

drivers/staging/ks7010/ks_hostif.c:465:6: warning: variable ‘mib_val_type’
set but not used [-Wunused-but-set-variable]
  u16 mib_val_type;

drivers/staging/ks7010/ks_hostif.c:464:6: warning: variable ‘mib_val_size’
set but not used [-Wunused-but-set-variable]
u16 mib_val_size;

drivers/staging/ks7010/ks_hostif.c:786:6: warning: variable ‘result_code’
set but not used [-Wunused-but-set-variable]
  u16 result_code;

Remove these variables.

Cc: Greg Kroah-Hartman 
Cc: Sergio Paracuellos 
Cc: Quytelda Kahja 

Signed-off-by: Bo Yu 
---
Changelog:
V3: fix spell issue in subject line
V2: fix patch format
---
 drivers/staging/ks7010/ks_hostif.c | 6 --
 1 file changed, 6 deletions(-)

diff --git a/drivers/staging/ks7010/ks_hostif.c 
b/drivers/staging/ks7010/ks_hostif.c
index d938b0997a53..913d8996437a 100644
--- a/drivers/staging/ks7010/ks_hostif.c
+++ b/drivers/staging/ks7010/ks_hostif.c
@@ -461,13 +461,9 @@ void hostif_mib_get_confirm(struct ks_wlan_private *priv)
struct net_device *dev = priv->net_dev;
u32 mib_status;
u32 mib_attribute;
-   u16 mib_val_size;
-   u16 mib_val_type;
 
mib_status = get_dword(priv);
mib_attribute = get_dword(priv);
-   mib_val_size = get_word(priv);
-   mib_val_type = get_word(priv);
 
if (mib_status) {
netdev_err(priv->net_dev, "attribute=%08X, status=%08X\n",
@@ -783,9 +779,7 @@ void hostif_ps_adhoc_set_confirm(struct ks_wlan_private 
*priv)
 static
 void hostif_infrastructure_set_confirm(struct ks_wlan_private *priv)
 {
-   u16 result_code;
 
-   result_code = get_word(priv);
priv->infra_status = 1; /* infrastructure mode set */
hostif_sme_enqueue(priv, SME_MODE_SET_CONFIRM);
 }
-- 
2.11.0

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