From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ot1-f41.google.com (mail-ot1-f41.google.com [209.85.210.41]) (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 72D1631716D for ; Sat, 15 Aug 2026 01:08:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.41 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786756110; cv=none; b=cqarURnOt07GmRrQGaUoanzym/klPcdG4PtMZG1ZX7CCSyHkA03Ahyi4g63Cag1M7jQpNPZkTQGixY0tMR5EeY2zWfRm5MuYIwl41cOmQf3J5SK82keoouxJN+WTdHRwoYcWlDIgMVozg/kI/iozFkY2TiOAtlKVlvt/ysF5z5c= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786756110; c=relaxed/simple; bh=Aa3x4hIztegYvcTbIqhvp4D7IHwChEh3gYm0aBgAdNQ=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=QJ8ZYiwUR1oZiP3OBefF85TrIXklIkqG85YufV5IsCbPVsDPeT6EqsH3VHuiOfavYBtNHQ30b1TGV+hem7SDHzZGGHyxeAldkTL70Q3/5avrZTkvO0mDF5B2PYxOBa8RQspD5EHXYqTAhyUWWckk0G6fkJRsMzN6EWGAjMtEhnk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=KuXqthXG; arc=none smtp.client-ip=209.85.210.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="KuXqthXG" Received: by mail-ot1-f41.google.com with SMTP id 46e09a7af769-7e6b5737bb2so2074204a34.1 for ; Fri, 14 Aug 2026 18:08:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1786756107; x=1787360907; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=2WaeFHY8Amefx+z0iRX7zRmJGE/YSFA3BET5wf4LK6c=; b=KuXqthXGWEPfbZWOWQETcI7FaVEIB02EYmxoospc8KemE9adbEEZy4YbZO1D7Vxu8q 5zXPM91QzU6VkpJxMsxAfeoxi0vpqAnHST59G1bLgoKCT7W2FyEMBxjSaduG9G2QQuYf QZ7+bC7KrD3ObFc0wK15/FgBjNFEbMyuRHUOK8WBgCuV1igpGCNzUy1ItK3vMQnJogV4 LyRQ0wH3mavqlq+dUUBc1WXjtdI0m1VERvcgTqJbyrnS6yBuieDfvGT/01ZDH/zWx+lX J63HcYH6WerZ52IN5Y2lrXSLnvf4EP4N3KYH38223UhZLcX/Hq/Zf7TeL9FnEcQxhF3P KRuQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786756107; x=1787360907; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=2WaeFHY8Amefx+z0iRX7zRmJGE/YSFA3BET5wf4LK6c=; b=ddg3H79tGkGg5yVxKB8eUMKrMMAdZ9pAjNoDdRGDdZSsp30UyEq/U3o4BRiJXL6NlE tFhhx++50tBeNX66U3RiQojcjqDMwMPNpYCOvMpk4QUJS+DECQnXExIhY1urvlRuyGl0 Bw5SEYuIKGbHetzx6A9f59HV061xpXKAlp4kdpx9aKmksM+PTudoe/i7u8kbih2G6eD4 e6oEoRWnpgrcjcWB4GiAL1MtWR9FK1rqcs8P9PIDiVdHWQRWeR92i5yegcHf+7j5CZ4h 28uWgEgGv/8S4E9ZYhthFQdqyfhkfXFEgJtjBxU6UGl9ssL3CjFT13ctlOuo4TZuus8X sNUA== X-Forwarded-Encrypted: i=1; AHgh+RqCWGmjJtEhFDdlZ6IJbC2pDnvFsEeodzxgZlo8zLVl+J0ttJswLj8kJG3X5dnmXtYnRWXm31hI+vrZm40=@vger.kernel.org X-Gm-Message-State: AOJu0YzZIxiwSo25exceGcDewAlGnt8fuVYnKnQRkHpT8H81GtXiTmZK MxSt0X3UMPzGwpQazydkJhFaTjcydeyO9tCy+WFSX2RM61u+40w0gv6g X-Gm-Gg: AR+sD13La5s6X4e1nTKs32LNXWKx1LI2ubfUXokkrUMejLcBfcP7LgzB7RFqZUEA0ri MqDV2gFkWMyyzvaXKQBvAUmFQTZB00OGTPPE1eK6GIqwBY84Wrxceqb+SlhSu437mw+8xEbyeww DmE9B8xW9CqYxNPJicIk7AneN/DR6vCTJIaq6wuCrtj36Lax+NklB3aB2ScsrcFX21z0qk7LiL7 sda0vnQclHvv/9Ie58f16mlvcPcxiO3VivcwhlF6Ku42+hnQoieMq5j9B6xn2hjHarkU/qjGSMK LMj72gQxMzC0mb6tk8UBY+Gtlcq29fycVwLwP2AQ25VGmFBSATC0JtUEgdzgDURj37MNGZg1ldh KMUQ0vYWb7h32RcHLeKglZeTTiwTFF2rIMJku0efyW1ZcSJyYTHjvkFI5EYMSTWxR0yS33tSdax J1kLnlqBL0X8rX30+p6zIf6nUAb+AoZbXUQ7K/15rjUp2Xx8hQUrDXTEszXiQlFv8sC17UNNaO6 4sickG4qge7xV1CrdKXR9Y3hHKedLI= X-Received: by 2002:a05:6830:3813:b0:7e9:d3aa:e391 with SMTP id 46e09a7af769-7f3de4ea83dmr9379236a34.6.1786756107331; Fri, 14 Aug 2026 18:08:27 -0700 (PDT) Received: from shiv-machina.. (174-16-201-18.hlrn.qwest.net. [174.16.201.18]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-7f3e869f65fsm2320947a34.26.2026.08.14.18.08.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Aug 2026 18:08:26 -0700 (PDT) From: Shivani Gupta To: intel-wired-lan@lists.osuosl.org, Tony Nguyen , Przemek Kitszel Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Richard Cochran , Simon Horman , Alessio Igor Bogani Subject: [PATCH iwl-net] igb: Reject hwtstamp requests when PTP is unavailable Date: Sat, 15 Aug 2026 01:08:15 +0000 Message-Id: <20260815010815.91898-1-shivani07g@gmail.com> X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit IGB depends on PTP_1588_CLOCK_OPTIONAL, so ptp_clock_register() can return NULL when PTP is compiled out and can fail at runtime. Commit b888c510f7b3 ("igb: Avoid starting unnecessary workqueues") moved the PTP locks, work items, timestamp configuration, and clock reset behind successful clock registration. The netdev is already registered when igb_ptp_init() runs, however, and the hwtstamp entry points were not gated on registration. On 82576 a TX timestamp request can therefore schedule a never-initialized ptp_tx_work. Initialize the passive PTP state and hardware clock before registering the PHC. INIT_WORK() and INIT_DELAYED_WORK() do not queue any work; the overflow work is started only after registration succeeds. This also ensures that PHC callbacks and the netdev timestamping paths never observe partially initialized state. Reject hwtstamp get and set requests with -EOPNOTSUPP while no PTP clock is registered, and advertise software timestamping only in that state. Successful registration retains the existing behavior on 82576, 82580, i350, i354, i210, and i211. On 82575, an OFF request that was previously accepted as a no-op now reports that hardware timestamping is unsupported. Reproduced with CONFIG_IGB=y and CONFIG_PTP_1588_CLOCK=n on the QEMU 82576 model: SIOCSHWTSTAMP(HWTSTAMP_TX_ON) followed by a hardware timestamp request warned in __queue_work() before this change and returns EOPNOTSUPP afterwards. Fixes: b888c510f7b3 ("igb: Avoid starting unnecessary workqueues") Signed-off-by: Shivani Gupta --- drivers/net/ethernet/intel/igb/igb_ethtool.c | 9 +++++ drivers/net/ethernet/intel/igb/igb_ptp.c | 40 ++++++++++++++------ 2 files changed, 38 insertions(+), 11 deletions(-) diff --git a/drivers/net/ethernet/intel/igb/igb_ethtool.c b/drivers/net/ethernet/intel/igb/igb_ethtool.c index f7938c1da835..4ebd447117cc 100644 --- a/drivers/net/ethernet/intel/igb/igb_ethtool.c +++ b/drivers/net/ethernet/intel/igb/igb_ethtool.c @@ -2396,6 +2396,15 @@ static int igb_get_ts_info(struct net_device *dev, case e1000_i354: case e1000_i210: case e1000_i211: + /* No PTP clock, no hardware timestamping. Advertise what + * igb_ptp_hwtstamp_set() will actually accept. + */ + if (!(adapter->ptp_flags & IGB_PTP_ENABLED)) { + info->so_timestamping = + SOF_TIMESTAMPING_TX_SOFTWARE; + return 0; + } + info->so_timestamping = SOF_TIMESTAMPING_TX_SOFTWARE | SOF_TIMESTAMPING_TX_HARDWARE | diff --git a/drivers/net/ethernet/intel/igb/igb_ptp.c b/drivers/net/ethernet/intel/igb/igb_ptp.c index 638d8242b66b..01992a73b37b 100644 --- a/drivers/net/ethernet/intel/igb/igb_ptp.c +++ b/drivers/net/ethernet/intel/igb/igb_ptp.c @@ -1104,6 +1104,9 @@ int igb_ptp_hwtstamp_get(struct net_device *netdev, { struct igb_adapter *adapter = netdev_priv(netdev); + if (!(adapter->ptp_flags & IGB_PTP_ENABLED)) + return -EOPNOTSUPP; + *config = adapter->tstamp_config; return 0; @@ -1285,6 +1288,9 @@ int igb_ptp_hwtstamp_set(struct net_device *netdev, struct igb_adapter *adapter = netdev_priv(netdev); int err; + if (!(adapter->ptp_flags & IGB_PTP_ENABLED)) + return -EOPNOTSUPP; + err = igb_ptp_set_timestamp_mode(adapter, config); if (err) return err; @@ -1378,6 +1384,25 @@ void igb_ptp_init(struct igb_adapter *adapter) return; } + /* Initialize all state used by the PHC and timestamping paths before + * registering either interface. INIT_WORK() only initializes the work + * item; no work is queued until timestamping is enabled. + */ + spin_lock_init(&adapter->tmreg_lock); + INIT_WORK(&adapter->ptp_tx_work, igb_ptp_tx_work); + + if (adapter->ptp_flags & IGB_PTP_OVERFLOW_CHECK) + INIT_DELAYED_WORK(&adapter->ptp_overflow_work, + igb_ptp_overflow_check); + + adapter->tstamp_config.rx_filter = HWTSTAMP_FILTER_NONE; + adapter->tstamp_config.tx_type = HWTSTAMP_TX_OFF; + + /* Initialize the hardware clock before ptp_clock_register() makes its + * callbacks visible. The overflow work is started after registration. + */ + igb_ptp_reset(adapter); + adapter->ptp_clock = ptp_clock_register(&adapter->ptp_caps, &adapter->pdev->dev); if (IS_ERR(adapter->ptp_clock)) { @@ -1388,17 +1413,9 @@ void igb_ptp_init(struct igb_adapter *adapter) adapter->netdev->name); adapter->ptp_flags |= IGB_PTP_ENABLED; - spin_lock_init(&adapter->tmreg_lock); - INIT_WORK(&adapter->ptp_tx_work, igb_ptp_tx_work); - if (adapter->ptp_flags & IGB_PTP_OVERFLOW_CHECK) - INIT_DELAYED_WORK(&adapter->ptp_overflow_work, - igb_ptp_overflow_check); - - adapter->tstamp_config.rx_filter = HWTSTAMP_FILTER_NONE; - adapter->tstamp_config.tx_type = HWTSTAMP_TX_OFF; - - igb_ptp_reset(adapter); + schedule_delayed_work(&adapter->ptp_overflow_work, + IGB_SYSTIM_OVERFLOW_PERIOD); } } @@ -1513,7 +1530,8 @@ void igb_ptp_reset(struct igb_adapter *adapter) wrfl(); - if (adapter->ptp_flags & IGB_PTP_OVERFLOW_CHECK) + if ((adapter->ptp_flags & IGB_PTP_ENABLED) && + (adapter->ptp_flags & IGB_PTP_OVERFLOW_CHECK)) schedule_delayed_work(&adapter->ptp_overflow_work, IGB_SYSTIM_OVERFLOW_PERIOD); }