LKML Archive mirror
 help / color / mirror / Atom feed
From: David Miller <davem@davemloft.net>
To: zheyuma97@gmail.com
Cc: GR-Linux-NIC-Dev@marvell.com, kuba@kernel.org,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] net/qla3xxx: fix schedule while atomic in ql_sem_spinlock
Date: Wed, 19 May 2021 12:26:05 -0700 (PDT)	[thread overview]
Message-ID: <20210519.122605.1971627339402718160.davem@davemloft.net> (raw)
In-Reply-To: <1621406954-1130-1-git-send-email-zheyuma97@gmail.com>

From: Zheyu Ma <zheyuma97@gmail.com>
Date: Wed, 19 May 2021 06:49:14 +0000

> When calling the 'ql_sem_spinlock', the driver has already acquired the
> spin lock, so the driver should not call 'ssleep' in atomic context.
> 
> This bug can be fixed by unlocking before calling 'ssleep'.
 ...
> diff --git a/drivers/net/ethernet/qlogic/qla3xxx.c b/drivers/net/ethernet/qlogic/qla3xxx.c
> index 214e347097a7..af7c142a066f 100644
> --- a/drivers/net/ethernet/qlogic/qla3xxx.c
> +++ b/drivers/net/ethernet/qlogic/qla3xxx.c
> @@ -114,7 +114,9 @@ static int ql_sem_spinlock(struct ql3_adapter *qdev,
>  		value = readl(&port_regs->CommonRegs.semaphoreReg);
>  		if ((value & (sem_mask >> 16)) == sem_bits)
>  			return 0;
> +		spin_unlock_irq(&qdev->hw_lock);
>  		ssleep(1);
> +		spin_lock_irq(&qdev->hw_lock);
>  	} while (--seconds);
>  	return -1;
>  }

Are you sure dropping the lock like this dos not introduce a race condition?

Thank you.

  reply	other threads:[~2021-05-19 19:26 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-19  6:49 [PATCH] net/qla3xxx: fix schedule while atomic in ql_sem_spinlock Zheyu Ma
2021-05-19 19:26 ` David Miller [this message]
2021-05-20 12:13   ` Zheyu Ma

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=20210519.122605.1971627339402718160.davem@davemloft.net \
    --to=davem@davemloft.net \
    --cc=GR-Linux-NIC-Dev@marvell.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=zheyuma97@gmail.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 read-only IMAP folder(s) and NNTP newsgroup(s).