netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Florian Fainelli <f.fainelli@gmail.com>
To: Iyappan Subramanian <isubramanian@apm.com>,
	davem@davemloft.net, netdev@vger.kernel.org
Cc: Quan Nguyen <qnguyen@apm.com>,
	patches@apm.com, linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH net-next 1/9] drivers: net: xgene: Protect indirect MAC access
Date: Wed, 26 Apr 2017 17:06:23 -0700	[thread overview]
Message-ID: <d23578a5-fedd-accd-c49b-12200440b9ca@gmail.com> (raw)
In-Reply-To: <1493249935-30759-2-git-send-email-isubramanian@apm.com>

On 04/26/2017 04:38 PM, Iyappan Subramanian wrote:
> From: Quan Nguyen <qnguyen@apm.com>
> 
> This patch adds lock to protect indirect mac access sequence.
> 
> Signed-off-by: Quan Nguyen <qnguyen@apm.com>
> Signed-off-by: Iyappan Subramanian <isubramanian@apm.com>
> ---
>  drivers/net/ethernet/apm/xgene/xgene_enet_hw.c    | 2 ++
>  drivers/net/ethernet/apm/xgene/xgene_enet_main.c  | 1 +
>  drivers/net/ethernet/apm/xgene/xgene_enet_main.h  | 1 +
>  drivers/net/ethernet/apm/xgene/xgene_enet_sgmac.c | 7 ++++++-
>  drivers/net/ethernet/apm/xgene/xgene_enet_xgmac.c | 2 ++
>  5 files changed, 12 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/ethernet/apm/xgene/xgene_enet_hw.c b/drivers/net/ethernet/apm/xgene/xgene_enet_hw.c
> index 2a835e0..3697ba7 100644
> --- a/drivers/net/ethernet/apm/xgene/xgene_enet_hw.c
> +++ b/drivers/net/ethernet/apm/xgene/xgene_enet_hw.c
> @@ -365,9 +365,11 @@ static void xgene_enet_rd_mcx_mac(struct xgene_enet_pdata *pdata,
>  	cmd = pdata->mcx_mac_addr + MAC_COMMAND_REG_OFFSET;
>  	cmd_done = pdata->mcx_mac_addr + MAC_COMMAND_DONE_REG_OFFSET;
>  
> +	spin_lock(&pdata->mac_lock);
>  	if (!xgene_enet_rd_indirect(addr, rd, cmd, cmd_done, rd_addr, rd_data))
>  		netdev_err(pdata->ndev, "MCX mac read failed, addr: %04x\n",
>  			   rd_addr);
> +	spin_unlock(&pdata->mac_lock);

Why not fold the spinlock manipulation within xgenet_enet_rd_indirect()?
That way the caller does not have to know that acquiring the spinlock is
required and you avoid potential bugs in the future where you are
missing the spinlock on indirect accesses?
-- 
Florian

  reply	other threads:[~2017-04-27  0:06 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-26 23:38 [PATCH net-next 0/9] drivers: net: xgene: Add ethtool stats and bug fixes Iyappan Subramanian
2017-04-26 23:38 ` [PATCH net-next 1/9] drivers: net: xgene: Protect indirect MAC access Iyappan Subramanian
2017-04-27  0:06   ` Florian Fainelli [this message]
2017-04-27  4:12     ` Iyappan Subramanian
2017-04-26 23:38 ` [PATCH net-next 2/9] drivers: net: xgene: Remove redundant local stats Iyappan Subramanian
2017-04-26 23:38 ` [PATCH net-next 3/9] drivers: net: xgene: Refactor statistics error parsing code Iyappan Subramanian
2017-04-26 23:38 ` [PATCH net-next 4/9] drivers: net: xgene: Remove unused macros Iyappan Subramanian
2017-04-26 23:38 ` [PATCH net-next 5/9] drivers: net: xgene: Extend ethtool statistics Iyappan Subramanian
2017-04-26 23:38 ` [PATCH net-next 6/9] drivers: net: xgene: Add rx_overrun/tx_underrun statistic Iyappan Subramanian
2017-04-26 23:38 ` [PATCH net-next 7/9] drivers: net: xgene: Workaround for HW errata 10GE_4 Iyappan Subramanian
2017-04-26 23:38 ` [PATCH net-next 8/9] drivers: net: xgene: Add frame recovered statistics counter for errata 10GE_8/ENET_11 Iyappan Subramanian
2017-04-26 23:38 ` [PATCH net-next 9/9] drivers: net: xgene: Workaround for HW errata 10GE_10/ENET_15 Iyappan Subramanian

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=d23578a5-fedd-accd-c49b-12200440b9ca@gmail.com \
    --to=f.fainelli@gmail.com \
    --cc=davem@davemloft.net \
    --cc=isubramanian@apm.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=netdev@vger.kernel.org \
    --cc=patches@apm.com \
    --cc=qnguyen@apm.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).