From: Jakub Kicinski <kuba@kernel.org>
To: Moritz Fischer <moritzf@google.com>
Cc: netdev@vger.kernel.org, pabeni@redhat.com, edumazet@google.com,
davem@davemloft.net, bryan.whitehead@microchip.com,
UNGLinuxDriver@microchip.com, mdf@kernel.org
Subject: Re: [PATCH net-next v2] net: lan743x: Don't sleep in atomic context
Date: Mon, 26 Jun 2023 13:10:34 -0700 [thread overview]
Message-ID: <20230626131034.1766bdbf@kernel.org> (raw)
In-Reply-To: <20230625182327.984115-1-moritzf@google.com>
On Sun, 25 Jun 2023 18:23:27 +0000 Moritz Fischer wrote:
> dev_set_rx_mode() grabs a spin_lock, and the lan743x implementation
> proceeds subsequently to go to sleep using readx_poll_timeout().
>
> Introduce a helper wrapping the readx_poll_timeout_atomic() function
> and use it to replace the calls to readx_polL_timeout().
>
> Signed-off-by: Moritz Fischer <moritzf@google.com>
> ---
>
> Changes from v1:
> - Added line-breaks
> - Changed subject to target net-next
> - Removed Tested-by: tag
Sleeping in atomic context is a bug, this is a bug fix.
You should add a Fixes tag (probably 23f0703c125be AFAICT)
and target the patch at net rather than net-next.
Make sure you CC the authors of the patch under fixes (get_maintainer
will point them out if run on a patch file with a Fixes tag)
One more nit below...
> drivers/net/ethernet/microchip/lan743x_main.c | 22 +++++++++++++++----
> 1 file changed, 18 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/net/ethernet/microchip/lan743x_main.c b/drivers/net/ethernet/microchip/lan743x_main.c
> index f1bded993edc..4f277ffff1dc 100644
> --- a/drivers/net/ethernet/microchip/lan743x_main.c
> +++ b/drivers/net/ethernet/microchip/lan743x_main.c
> @@ -144,6 +144,19 @@ static int lan743x_csr_light_reset(struct lan743x_adapter *adapter)
> !(data & HW_CFG_LRST_), 100000, 10000000);
> }
>
> +static int lan743x_csr_wait_for_bit_atomic(struct lan743x_adapter *adapter,
> + int offset, u32 bit_mask,
> + int target_value, int udelay_min,
> + int udelay_max, int count)
> +{
> + u32 data;
> +
> + return readx_poll_timeout_atomic(LAN743X_CSR_READ_OP, offset, data,
> + target_value == ((data & bit_mask) ?
> + 1 : 0), udelay_max,
You can save the awkward wrapping by using a double negation:
target_value == !!(data & bit_mask)
this is a fairly common form in the kernel.
--
pw-bot: cr
prev parent reply other threads:[~2023-06-26 20:10 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-25 18:23 [PATCH net-next v2] net: lan743x: Don't sleep in atomic context Moritz Fischer
2023-06-26 20:10 ` Jakub Kicinski [this message]
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=20230626131034.1766bdbf@kernel.org \
--to=kuba@kernel.org \
--cc=UNGLinuxDriver@microchip.com \
--cc=bryan.whitehead@microchip.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=mdf@kernel.org \
--cc=moritzf@google.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.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).