From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from smtp3.osuosl.org (smtp3.osuosl.org [140.211.166.136]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 2F11AC6FD1F for ; Tue, 14 Mar 2023 19:19:52 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id B2D5860B50; Tue, 14 Mar 2023 19:19:51 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org B2D5860B50 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=osuosl.org; s=default; t=1678821591; bh=gqU7jMyHwwC6tWCndb9xE8BjeK1zJdAfoPUgkpEZUjI=; h=From:To:In-Reply-To:References:Date:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: Cc:From; b=R49vb1yGbZP2pCOql5nWrweXdhQ1p7uE6fljeaH63WBjsSBV9BR3rugMuQBMUMX9h 7y1US6vXIMTV7kw39PqBKjJvj48XG2UKpBjnBFH2Y5z6odLyYK1uDtt/r93KNG+Me+ TDkwiwc8bFbHmJ0u0trcIrrmyCByCq1Vvr6sVDu2ta1aU6xArNuueiLiSFUe1QGvFR Pajce0kwa78sNjxSw3oZgUSEzxjW3dH5KxVp7rxM3njhimqHPLiI3Z0/3SkITTO2Kt IHuw91M4lmrkMXLoSNRJ2NYzz8WiO8I6L/YARimDFRynjD4oDrvwokzXPYKlFJxhXF gJ2H3cf3D+eeQ== X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id blh0r_Vqu7Z0; Tue, 14 Mar 2023 19:19:51 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by smtp3.osuosl.org (Postfix) with ESMTP id ABFB060B88; Tue, 14 Mar 2023 19:19:50 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org ABFB060B88 Received: from smtp2.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by ash.osuosl.org (Postfix) with ESMTP id 230DE1BF5E9 for ; Tue, 14 Mar 2023 19:19:49 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id EF34440328 for ; Tue, 14 Mar 2023 19:19:48 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org EF34440328 X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id JeFhfL4wOMWp for ; Tue, 14 Mar 2023 19:19:48 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org AFF144011D Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by smtp2.osuosl.org (Postfix) with ESMTPS id AFF144011D for ; Tue, 14 Mar 2023 19:19:47 +0000 (UTC) X-IronPort-AV: E=McAfee;i="6500,9779,10649"; a="400103543" X-IronPort-AV: E=Sophos;i="5.98,260,1673942400"; d="scan'208";a="400103543" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Mar 2023 12:19:38 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10649"; a="711633247" X-IronPort-AV: E=Sophos;i="5.98,260,1673942400"; d="scan'208";a="711633247" Received: from ktpate-mobl2.amr.corp.intel.com (HELO vcostago-mobl3) ([10.212.171.228]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Mar 2023 12:19:38 -0700 From: Vinicius Costa Gomes To: Marc Kleine-Budde In-Reply-To: <20230313095648.czf4so6qpkcotqq4@pengutronix.de> References: <20230228054534.1093483-1-vinicius.gomes@intel.com> <20230228054534.1093483-2-vinicius.gomes@intel.com> <20230313095648.czf4so6qpkcotqq4@pengutronix.de> Date: Tue, 14 Mar 2023 12:19:38 -0700 Message-ID: <875yb3i1it.fsf@intel.com> MIME-Version: 1.0 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1678821587; x=1710357587; h=from:to:cc:subject:in-reply-to:references:date: message-id:mime-version; bh=GWUsmUajL5jOHval1J6ppe6EK9fbnQlJmNBgES93TXY=; b=Qap39RsEox20MVKMMc5DqwGrr6JHsO4edO7IVFOhnv6XzFuB8IVWZwg/ NB9xxaebLVaozAKWT63asWsyKfbigBFJjI/hkdWMOQ67YKKaji/kAFhwX ZYjlBanN/IS1NBSBtPwsakaRvDeCNkebSNyOlVc7n5unWUtLiaX77I/Yq s3jWpy/BWMMbtqsfbts8KSNG7w1nqdDIRgyeSyIpr/LCIzCkAFeAtbGr5 n/Js99WqyqLVBtorsZioFEXuDunyxJCalT/O/vJJZ+X/BIWPG2YtynYWm UiWBu7kLkTT7W4RlmNvLbG54z8IVf9xPKRbSbDkLxxdMbhGsqoBDOlcHU Q==; X-Mailman-Original-Authentication-Results: smtp2.osuosl.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=Qap39RsE Subject: Re: [Intel-wired-lan] [PATCH next-queue v1 1/3] igc: Fix race condition in PTP tx code X-BeenThere: intel-wired-lan@osuosl.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel Wired Ethernet Linux Kernel Driver Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Andre Guedes , vladimir.oltean@nxp.com, kurt@linutronix.de, anthony.l.nguyen@intel.com, kernel@pengutronix.de, intel-wired-lan@lists.osuosl.org, jzi@pengutronix.de Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: intel-wired-lan-bounces@osuosl.org Sender: "Intel-wired-lan" Marc Kleine-Budde writes: > On 27.02.2023 21:45:32, Vinicius Costa Gomes wrote: >> From: Andre Guedes >> >> Currently, the igc driver supports timestamping only one tx packet at a >> time. During the transmission flow, the skb that requires hardware >> timestamping is saved in adapter->ptp_tx_skb. Once hardware has the >> timestamp, an interrupt is delivered, and adapter->ptp_tx_work is >> scheduled. In igc_ptp_tx_work(), we read the timestamp register, update >> adapter->ptp_tx_skb, and notify the network stack. >> >> While the thread executing the transmission flow (the user process >> running in kernel mode) and the thread executing ptp_tx_work don't >> access adapter->ptp_tx_skb concurrently, there are two other places >> where adapter->ptp_tx_skb is accessed: igc_ptp_tx_hang() and >> igc_ptp_suspend(). >> >> igc_ptp_tx_hang() is executed by the adapter->watchdog_task worker >> thread which runs periodically so it is possible we have two threads >> accessing ptp_tx_skb at the same time. Consider the following scenario: >> right after __IGC_PTP_TX_IN_PROGRESS is set in igc_xmit_frame_ring(), >> igc_ptp_tx_hang() is executed. Since adapter->ptp_tx_start hasn't been >> written yet, this is considered a timeout and adapter->ptp_tx_skb is >> cleaned up. >> >> This patch fixes the issue described above by adding the ptp_tx_lock to >> protect access to ptp_tx_skb and ptp_tx_start fields from igc_adapter. >> Since igc_xmit_frame_ring() called in atomic context by the networking >> stack, ptp_tx_lock is defined as a spinlock. >> >> With the introduction of the ptp_tx_lock, the __IGC_PTP_TX_IN_PROGRESS >> flag doesn't provide much of a use anymore so this patch gets rid of it. > > Since the igc PTP code is derived from igb, do we need this patch to be > ported to the igb driver, too? Yes, that would be good. Will add this to my todo, but I will be glad if anyone beats me to it. > > regards, > Marc > > -- > Pengutronix e.K. | Marc Kleine-Budde | > Embedded Linux | https://www.pengutronix.de | > Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | Cheers, -- Vinicius _______________________________________________ Intel-wired-lan mailing list Intel-wired-lan@osuosl.org https://lists.osuosl.org/mailman/listinfo/intel-wired-lan