Received: by 2002:ab2:6a05:0:b0:1f8:1780:a4ed with SMTP id w5csp1875316lqo; Mon, 13 May 2024 00:29:55 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV8iit2hC5S35rMUhRnppWKx96xHy9OE4OfmCNito0q+GArU3SGSjGMOGtJKXMJbOXdjxNBg8qes42qUB4ALA3LXhsVe8fylOy6pqnCdw== X-Google-Smtp-Source: AGHT+IHxpPBFnie3V8m+tSVyvn0pXAoZCxreARdFD+tAwolSCXruYYuQse1JkCdiQsW3Gn8ZliRO X-Received: by 2002:a17:906:2c07:b0:a5a:5bd3:9f0 with SMTP id a640c23a62f3a-a5a5bd3aea4mr213294466b.24.1715585395127; Mon, 13 May 2024 00:29:55 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715585395; cv=pass; d=google.com; s=arc-20160816; b=vz7qWHaqIILOP2LcqDD3LOvb7sL6o/R34W3aLuQ9LDrBywNemjuFzNwZ9ei/SDgsQu ybiedIm9BGoz+nvmMVwgxf9rrgWXXLx6WpM1vhEvPvtF37EUnYxU9i+cjEMQOkq/r6Wh Fpa9bv1CoXsFLHza28/x1BBiEzpNPAwYC+7dyNnRQa9VtmHvPr5f/pbahFXp7Z/KzrY4 UTh7a+eoWRgiycMlOe+OiMpY0UnTBmFW6DBmF++dx/eKJIL+f09znBev82J3IsnKn+It vp1zXi8wZDtlJQ4VCEk7bE9vpkmlE2v+uyoPP/580voxiCLCPCdQRHwGw5Z1Wx1wTv6c v7Lw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=iAY4/lorGsuZXDngCKORi6jmMI4bRdFCzdsTXkDAPOg=; fh=8QxH5puVB3vcZwCiGUGsw61GxL8HKqh77csVvYVxWBw=; b=jzAPSmlfpPHKyu09fnAhaQ9PUQ3c6jqaTaCm8ds3oaqosWQgSzOEJPui8cRfKshEtW MKvUa+JacwdFAC6Nkg7z7yxMKixt9cjyo1iO165JDOcQPB3pDOhqXEl9LmQpVfHRoA4i uthzFYvyDIGT92wDi9KOx01sfYuhj2cxQjeD/diGQ5gzfd4z7+x8vgkpiLnFwYam/Fqp eexGgjs99pbSuncY9JqECVsvqQvY9DSmDcotH8glF6jzmDy3UHAOOsvGv6i4kuV3mNq6 A91eJrWbAIFpk8T+3Z3xsB7OmszBEjri+2BWb0klWHl7CojcGsF4bJ1ta0No2aQbhBmK FkFQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b="so7U/oaT"; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-177256-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-177256-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id a640c23a62f3a-a5a1797cdd8si489687066b.263.2024.05.13.00.29.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 May 2024 00:29:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-177256-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b="so7U/oaT"; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-177256-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-177256-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id D33E31F21A21 for ; Mon, 13 May 2024 07:29:54 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 97A1B1465A7; Mon, 13 May 2024 07:29:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="so7U/oaT" Received: from mail-ed1-f51.google.com (mail-ed1-f51.google.com [209.85.208.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 42675146A77 for ; Mon, 13 May 2024 07:29:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.51 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715585385; cv=none; b=Gch8GlYtFLB+6H57C3KO8ux9m5LYQOwj5HK8sehZPL6cxoE2T0b8MeQO81M98t1/92VtufM1a567dSnWf9pLNna1unEcAi0eiyzgt6AngYs4Z/0Ta9SO0Q1xN5piw78O3X8090mdRfYDcSR+WHGxg17V/yqOUm8F5ruwQV5EOHU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715585385; c=relaxed/simple; bh=IzPgdw0K49eRhw5jtIZPmynlarK4dqQ229YsGJcycyE=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=Q2dKY1KJYPKbaSSQ7v0pNyIGVYcXs/Xakgd4616xUf0wMj4ZWGhZ2ChbK+g3B0uVwtSgxtdaLwwZ1JAQuVuoaFLvU0FerSNXiffzTuiSRs6mHPpthFNguE2SVD0hfDfNerxFwxEB+w5fmJlGDGIUVC/8+PBiupTDMV12UKFexns= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=so7U/oaT; arc=none smtp.client-ip=209.85.208.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Received: by mail-ed1-f51.google.com with SMTP id 4fb4d7f45d1cf-5724736770cso8793a12.1 for ; Mon, 13 May 2024 00:29:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1715585382; x=1716190182; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=iAY4/lorGsuZXDngCKORi6jmMI4bRdFCzdsTXkDAPOg=; b=so7U/oaTH/1My0EXDal3lNbOVdwa4Pb2lXxhCe1w/KPWh8LrWgdOyXwvyL+6gE5ZqP aVVvwQAx8YxYKuKTgG+sxq0UDSkTK3VK7iWyTIVcnlBb6fTHSLFQo1z9TMljFTZxTtgZ csIeaBVTqGwQC7Y5S7qXmNQpSUXSzFR1PZOItHZnikuHDJDJnFDKOIqNKoO2PFKi2LSD 2iLFrL40RGmDGFQ0DdUOnHyJsrIY4C9htfBT4B51/CAIY9HMiNXhx4IXfzD9cQ2A7rKq Rg51rvqr22Cj3k5Hlt2vZjFU+wuYVl1ieiJ0YxDCV7UG0AhEQK5qRb+Y2BZt8lbppfKG 5UaQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715585382; x=1716190182; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=iAY4/lorGsuZXDngCKORi6jmMI4bRdFCzdsTXkDAPOg=; b=xTibsM69oNYzcSHgqHZKQhs44VHML+/BgNvBg2yOWk/U/Lg2xJ3dP3X2ksaGTu12lr Lgy43FAHv+pkXyxy09/haSgwBIzX1jDhCBpN06WUG2rNEr9RfhZx95/RybOxe9b8+Ixp jGlIkCpKdRiEc9r25hFA22Ap0v2EjGoUNjOJoWzGyZ0flwkKPzn0NME0MKDjXp+QYjRY 8xnpdouzi/wbwaV8MD2atU+/O5A4H8lgn8ec3FCp1wvQszeaLX+g4rvHRglFgm37jaTG V1QU4ki9zN+vrCPW24xskRwMRXZE0dJb2HlpUdZN+PQy9Rn5UnUCHQaZzEMKv688fIDI UsMA== X-Forwarded-Encrypted: i=1; AJvYcCXRfRXAKSTqXjVShZJNIEFnhEpWn7Rf3fgSt9eNzx9T+cE3ZCiDeYJkclejLFI2EuibtWeAO4FcUvEE8W5wZMVm6w6HjyUQxaCWeXQO X-Gm-Message-State: AOJu0YxLmaDAq6Q9IAQSUfnbC1axQar8hGICwdfjdISY1FwCnI6GJ2GW jOjGlZ6IfjIJtHSsC8eVz+OJ9n7UsXIafnqASEmoUijB3NZjWUXABsHYWS+3DbM+5KqfwwCYVMQ 8McTjIkowhOJPDDa1zFIwId/p13X662Rxs8k7 X-Received: by 2002:a05:6402:2228:b0:572:57d8:4516 with SMTP id 4fb4d7f45d1cf-5743a09ba38mr227370a12.2.1715585382186; Mon, 13 May 2024 00:29:42 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240513015127.961360-1-wei.fang@nxp.com> In-Reply-To: <20240513015127.961360-1-wei.fang@nxp.com> From: Eric Dumazet Date: Mon, 13 May 2024 09:29:28 +0200 Message-ID: Subject: Re: [PATCH net] net: fec: avoid lock evasion when reading pps_enable To: Wei Fang Cc: davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com, shenwei.wang@nxp.com, xiaoning.wang@nxp.com, richardcochran@gmail.com, andrew@lunn.ch, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, imx@lists.linux.dev Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Mon, May 13, 2024 at 4:02=E2=80=AFAM Wei Fang wrote: > > The assignment of pps_enable is protected by tmreg_lock, but the read > operation of pps_enable is not. So the Coverity tool reports a lock > evasion warning which may cause data race to occur when running in a > multithread environment. Although this issue is almost impossible to > occur, we'd better fix it, at least it seems more logically reasonable, > and it also prevents Coverity from continuing to issue warnings. > > Fixes: 278d24047891 ("net: fec: ptp: Enable PPS output based on ptp clock= ") > Signed-off-by: Wei Fang > --- > drivers/net/ethernet/freescale/fec_ptp.c | 8 +++++--- > 1 file changed, 5 insertions(+), 3 deletions(-) > > diff --git a/drivers/net/ethernet/freescale/fec_ptp.c b/drivers/net/ether= net/freescale/fec_ptp.c > index 181d9bfbee22..8d37274a3fb0 100644 > --- a/drivers/net/ethernet/freescale/fec_ptp.c > +++ b/drivers/net/ethernet/freescale/fec_ptp.c > @@ -104,14 +104,16 @@ static int fec_ptp_enable_pps(struct fec_enet_priva= te *fep, uint enable) > struct timespec64 ts; > u64 ns; > > - if (fep->pps_enable =3D=3D enable) > - return 0; > - > fep->pps_channel =3D DEFAULT_PPS_CHANNEL; > fep->reload_period =3D PPS_OUPUT_RELOAD_PERIOD; Why are these writes left without the spinlock protection ? > > spin_lock_irqsave(&fep->tmreg_lock, flags); > > + if (fep->pps_enable =3D=3D enable) { > + spin_unlock_irqrestore(&fep->tmreg_lock, flags); > + return 0; > + } > + > if (enable) { > /* clear capture or output compare interrupt status if ha= ve. > */ > -- > 2.34.1 >