All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ajay Singh <ajay.kathat@microchip.com>
To: Claudiu Beznea <Claudiu.Beznea@microchip.com>
Cc: <linux-wireless@vger.kernel.org>, <devel@driverdev.osuosl.org>,
	<gregkh@linuxfoundation.org>, <ganesh.krishna@microchip.com>,
	<venkateswara.kaja@microchip.com>, <aditya.shankar@microchip.com>,
	<adham.abozaeid@microchip.com>
Subject: Re: [PATCH 10/24] staging: wilc1000: move wilc_multicast_mac_addr_list to 'wilc_vif' struct
Date: Thu, 23 Aug 2018 15:30:21 +0530	[thread overview]
Message-ID: <20180823153021.3ad58351@ajaysk-VirtualBox> (raw)
In-Reply-To: <92faa952-6722-cc9f-cccf-2275c4158a37@microchip.com>

On Thu, 23 Aug 2018 11:10:48 +0300
Claudiu Beznea <Claudiu.Beznea@microchip.com> wrote:

> On 14.08.2018 09:50, Ajay Singh wrote:
> > Instead of using 'wilc_multicast_mac_addr_list' as global variable
> > move it part of wilc_vif struct. Rename
> > 'wilc_multicast_mac_addr_list' variable to 'mc_mac_addr_list' as
> > its now part of 'wilc_vif' struct.
> > 
> > Signed-off-by: Ajay Singh <ajay.kathat@microchip.com>
> > ---
> >  drivers/staging/wilc1000/host_interface.c     |  4 +---
> >  drivers/staging/wilc1000/host_interface.h     |  1 -
> >  drivers/staging/wilc1000/linux_wlan.c         | 14 +++++++-------
> >  drivers/staging/wilc1000/wilc_wfi_netdevice.h |  1 +
> >  4 files changed, 9 insertions(+), 11 deletions(-)
> > 
> > diff --git a/drivers/staging/wilc1000/host_interface.c
> > b/drivers/staging/wilc1000/host_interface.c index d930f06..642c314
> > 100644 --- a/drivers/staging/wilc1000/host_interface.c
> > +++ b/drivers/staging/wilc1000/host_interface.c
> > @@ -193,8 +193,6 @@ static struct mutex hif_deinit_lock;
> >  static struct timer_list periodic_rssi;
> >  static struct wilc_vif *periodic_rssi_vif;
> >  
> > -u8
> > wilc_multicast_mac_addr_list[WILC_MULTICAST_TABLE_SIZE][ETH_ALEN]; -
> >  static u8 rcv_assoc_resp[MAX_ASSOC_RESP_FRAME_SIZE];
> >  
> >  static u8 set_ip[2][4];
> > @@ -2588,7 +2586,7 @@ static void handle_set_mcast_filter(struct
> > work_struct *work) *cur_byte++ = ((hif_set_mc->cnt >> 24) & 0xFF);
> >  
> >  	if (hif_set_mc->cnt > 0)
> > -		memcpy(cur_byte, wilc_multicast_mac_addr_list,
> > +		memcpy(cur_byte, vif->mc_mac_addr_list,  
> 
> A locking mechanism should be used for vif->mc_mac_addr_list. It is
> read here.

Below is my understanding. 

wilc_set_multicast_list() is called from 'ndo_set_rx_mode' callback.
 
wilc_set_multicast_list() calls wilc_setup_multicast_filter() which
only read the value from the array and don't write to it when below
if conditions pass.

if (dev->flags &
IFF_ALLMULTI || dev->mc.count > WILC_MULTICAST_TABLE_SIZE) 

if (dev->mc.count == 0)
 
For the scenario when above 'if' conditions fails then value will be
write to array first followed by read operation which will happen
in different context(worker thread).

Unless ndo_set_rx_mode() gets called quickly I don't think there is any
issue here. 

If required instead of adding the lock how about making
handle_set_mcast_filter() a sync call in further patches, so that it can
complete handle_set_mcast_filter() operation before coming out of
ndo_set_rx_mode() callback.

Actually, I am also worried if its right to add 'lock' at this
point without reproducing the issue and only based on the code
observation.

Regards,
Ajay

> 
> >  		       ((hif_set_mc->cnt) * ETH_ALEN));
> >  
> >  	result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1,
> > diff --git a/drivers/staging/wilc1000/host_interface.h
> > b/drivers/staging/wilc1000/host_interface.h index d026f44..4a84dd2
> > 100644 --- a/drivers/staging/wilc1000/host_interface.h
> > +++ b/drivers/staging/wilc1000/host_interface.h
> > @@ -362,7 +362,6 @@ int wilc_set_tx_power(struct wilc_vif *vif, u8
> > tx_power); int wilc_get_tx_power(struct wilc_vif *vif, u8
> > *tx_power); 
> >  extern u8 wilc_connected_ssid[6];
> > -extern u8
> > wilc_multicast_mac_addr_list[WILC_MULTICAST_TABLE_SIZE][ETH_ALEN]; 
> >  extern int wilc_connecting;
> >  
> > diff --git a/drivers/staging/wilc1000/linux_wlan.c
> > b/drivers/staging/wilc1000/linux_wlan.c index 283bb74..bbaa653
> > 100644 --- a/drivers/staging/wilc1000/linux_wlan.c
> > +++ b/drivers/staging/wilc1000/linux_wlan.c
> > @@ -822,14 +822,14 @@ static void wilc_set_multicast_list(struct
> > net_device *dev) }
> >  
> >  	netdev_for_each_mc_addr(ha, dev) {
> > -		memcpy(wilc_multicast_mac_addr_list[i], ha->addr,
> > ETH_ALEN);
> > +		memcpy(vif->mc_mac_addr_list[i], ha->addr,
> > ETH_ALEN);  
> 
> and set here. The contexts are different. If not in this patch, then
> in a future one.
> 
> >  		netdev_dbg(dev, "Entry[%d]: %x:%x:%x:%x:%x:%x\n",
> > i,
> > -			   wilc_multicast_mac_addr_list[i][0],
> > -			   wilc_multicast_mac_addr_list[i][1],
> > -			   wilc_multicast_mac_addr_list[i][2],
> > -			   wilc_multicast_mac_addr_list[i][3],
> > -			   wilc_multicast_mac_addr_list[i][4],
> > -			   wilc_multicast_mac_addr_list[i][5]);
> > +			   vif->mc_mac_addr_list[i][0],
> > +			   vif->mc_mac_addr_list[i][1],
> > +			   vif->mc_mac_addr_list[i][2],
> > +			   vif->mc_mac_addr_list[i][3],
> > +			   vif->mc_mac_addr_list[i][4],
> > +			   vif->mc_mac_addr_list[i][5]);
> >  		i++;
> >  	}
> >  
> > diff --git a/drivers/staging/wilc1000/wilc_wfi_netdevice.h
> > b/drivers/staging/wilc1000/wilc_wfi_netdevice.h index
> > 8cccbbc..ee8eda7 100644 ---
> > a/drivers/staging/wilc1000/wilc_wfi_netdevice.h +++
> > b/drivers/staging/wilc1000/wilc_wfi_netdevice.h @@ -120,6 +120,7 @@
> > struct wilc_vif { u8 ifc_id;
> >  	struct timer_list during_ip_timer;
> >  	bool obtaining_ip;
> > +	u8 mc_mac_addr_list[WILC_MULTICAST_TABLE_SIZE][ETH_ALEN];
> >  };
> >  
> >  struct wilc {
> >   

  reply	other threads:[~2018-08-23 13:29 UTC|newest]

Thread overview: 61+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-14  6:49 [PATCH 00/24] staging: wilc1000: avoid use of static and global variable Ajay Singh
2018-08-14  6:49 ` [PATCH 01/24] staging: wilc1000: move 'wilc_enable_ps' global variable into 'wilc' struct Ajay Singh
2018-08-14  6:49 ` [PATCH 02/24] staging: wilc1000: move 'aging_timer' static variable to wilc_priv struct Ajay Singh
2018-08-14  6:49 ` [PATCH 03/24] staging: wilc1000: fix to use correct index to free scanned info in clear_shadow_scan() Ajay Singh
2018-08-14  6:49 ` [PATCH 04/24] staging: wilc1000: remove unnecessary NULL check " Ajay Singh
2018-08-14  6:49 ` [PATCH 05/24] staging: wilc1000: moved last_scanned_shadow & last_scanned_cnt to wilc_priv struct Ajay Singh
2018-08-14  6:49 ` [PATCH 06/24] staging: wilc1000: move during_ip_timer & wilc_optaining_ip to 'wilc_vif' struct Ajay Singh
2018-08-23  8:09   ` Claudiu Beznea
2018-08-23  9:43     ` Ajay Singh
2018-08-24  8:47       ` Claudiu Beznea
2018-08-14  6:49 ` [PATCH 07/24] staging: wilc1000: remove unused variable 'op_ifcs' Ajay Singh
2018-08-14  6:50 ` [PATCH 08/24] staging: wilc1000: avoid use of extra 'if' condition in wilc_init() Ajay Singh
2018-08-14  6:50 ` [PATCH 09/24] staging: wilc1000: move static variable clients_count to 'wilc' structure Ajay Singh
2018-08-23  8:09   ` Claudiu Beznea
2018-08-25  0:13     ` Adham Abozaeid
2018-08-14  6:50 ` [PATCH 10/24] staging: wilc1000: move wilc_multicast_mac_addr_list to 'wilc_vif' struct Ajay Singh
2018-08-23  8:10   ` Claudiu Beznea
2018-08-23 10:00     ` Ajay Singh [this message]
2018-08-24  8:47       ` Claudiu Beznea
2018-08-25  0:32         ` Adham Abozaeid
2018-08-27  5:40           ` Ajay Singh
2018-08-14  6:50 ` [PATCH 11/24] staging: wilc1000: move hif specific static variables to 'wilc' structure Ajay Singh
2018-08-23  8:11   ` Claudiu Beznea
2018-08-23 10:09     ` Ajay Singh
2018-08-24  8:47       ` Claudiu Beznea
2018-08-14  6:50 ` [PATCH 12/24] staging: wilc1000: move static variable 'terminated_handle' to wilc_vif struct Ajay Singh
2018-08-23  8:11   ` Claudiu Beznea
2018-08-23 14:36     ` Ajay Singh
2018-08-24  8:46       ` Claudiu Beznea
2018-08-27  5:27         ` Ajay Singh
2018-08-14  6:50 ` [PATCH 13/24] staging: wilc1000: move 'periodic_rssi' as part of 'wilc_vif' struct Ajay Singh
2018-08-14  6:50 ` [PATCH 14/24] staging: wilc1000: rename 'dummy_statistics' variable to 'periodic_stat' Ajay Singh
2018-08-14  6:50 ` [PATCH 15/24] staging: wilc1000: move 'rcv_assoc_resp' as part of hif_drv Ajay Singh
2018-08-14  6:50 ` [PATCH 16/24] staging: wilc1000: refactor tcp_process() to avoid extra leading tabs Ajay Singh
2018-08-14  6:50 ` [PATCH 17/24] staging: wilc1000: use lowercase for get_BSSID() and HIL variable Ajay Singh
2018-08-14  6:50 ` [PATCH 18/24] staging: wilc1000: move tcp_ack_filter algo related variables to 'wilc_vif' struct Ajay Singh
2018-08-14  6:50 ` [PATCH 19/24] staging: wilc1000: avoid line over 80 chars in wilc_wlan_txq_filter_dup_tcp_ack() Ajay Singh
2018-08-23  8:11   ` Claudiu Beznea
2018-08-23 12:18     ` Ajay Singh
2018-08-14  6:50 ` [PATCH 20/24] staging: wilc1000: avoid line over 80 chars in tcp_process() Ajay Singh
2018-08-23  8:12   ` Claudiu Beznea
2018-08-23 10:33     ` Ajay Singh
2018-08-24  9:31       ` Claudiu Beznea
2018-08-27  5:24         ` Ajay Singh
2018-08-27 12:00           ` Dan Carpenter
2018-08-28  4:29             ` Ajay Singh
2018-08-14  6:50 ` [PATCH 21/24] staging: wilc1000: remove unused code to set and get IP address Ajay Singh
2018-08-14  6:50 ` [PATCH 22/24] staging: wilc1000: move 'chip_ps_state' static variable as part of 'wilc' struct Ajay Singh
2018-08-14  6:50 ` [PATCH 23/24] staging: wilc1000: move 'wilc_connecting' static variable to 'wilc_vif' struct Ajay Singh
2018-08-23  8:12   ` Claudiu Beznea
2018-08-23 10:55   ` Greg KH
2018-08-23 11:27     ` Ajay Singh
2018-08-23 12:37       ` Dan Carpenter
2018-08-23 13:06         ` Ajay Singh
2018-08-14  6:50 ` [PATCH 24/24] staging: wilc1000: remove unnecessary static variable 'p2p_listen_state' Ajay Singh
2018-08-23  8:13   ` Claudiu Beznea
2018-08-23 12:07     ` Ajay Singh
2018-08-23  8:09 ` [PATCH 00/24] staging: wilc1000: avoid use of static and global variable Claudiu Beznea
2018-08-23  9:35   ` Ajay Singh
2018-08-27 17:10 ` Greg KH
2018-08-28  4:35   ` Ajay Singh

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180823153021.3ad58351@ajaysk-VirtualBox \
    --to=ajay.kathat@microchip.com \
    --cc=Claudiu.Beznea@microchip.com \
    --cc=adham.abozaeid@microchip.com \
    --cc=aditya.shankar@microchip.com \
    --cc=devel@driverdev.osuosl.org \
    --cc=ganesh.krishna@microchip.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=venkateswara.kaja@microchip.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.