From nobody Thu Sep 24 15:10:01 2026 Received: from mail-lf2-f13.google.com (mail-lf2-f13.google.com [74.125.229.205]) (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 6DFCD54EECA for ; Tue, 22 Sep 2026 14:28:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.229.205 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790087320; cv=none; b=GNI1/NX26r+RsnrmCXWJEJhMQwl7Zw3OxsGHQHPq3UBytIWGL7k5oTU1OGB5+t3PvRInC23oxj/AdlNoatU3GUL+zgFpAEihUCXLMKXhzNgBnp4JGb4lR99gQFS9cgtEdwa4KJt2uIIOAjxv/BZX9tkWxGHCOthMRTXM+J/P+Fw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790087320; c=relaxed/simple; bh=L+4quM8DIZHcLp0rpytZsLw6+jjB2bs2Afpu5C94VdI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=csY3/vDIP746GQczSJavnBxq7LYj5U1pUO7vVOXP9gG7b4Fb6tnwBpRcbZNQenhBwC+pcO83ZtEDX90qkYpDqaMIp7teYQFBOjiPDjf+Xl0jElATMDkp3C7UoKiyYwvOd7ENs2j3TzpfrRBcNJlnaNft7xLPI5gdcPzHVORV1CE= 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=kFcpiyz0; arc=none smtp.client-ip=74.125.229.205 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="kFcpiyz0" Received: by mail-lf2-f13.google.com with SMTP id 2adb3069b0e04-5b8d7263f0cso264596e87.2 for ; Tue, 22 Sep 2026 07:28:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1790087316; x=1790692116; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=e2Bt2pbnVu/ApigQk0zS6acL2EWAE6Kw3ktFWRmRY+Q=; b=kFcpiyz0iNrUZNjoH0gTE2Q6n5rOgKW+9hgvkU17NQk15+hIoDafBOpyogzbFZ8mss FzmDJyEDkRuMdI28APMKao5qQx9idrar8jOaCsf7bWFVSxPsuEzVXlqMNLn1WGF/GQ3O O5kcvzmrRvUUromuSbl2xmnxqFKpiHbE8gaeBU3oiCFoE3Pb+DXtde1L7ibo8e6rrDaP LFKdwuKswVdJ3n1uki61zMjjHKDISgC89autGFMpv+zH9n/xoLpqo+jxZ4HKzJsuRtUs Rs/6Qzf72/ZUFA4UubQ1Dbr8vLcd12EvT5p28hXGQBG/4hwndrdWBq/qG5bBrNJtDijR eaWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1790087316; x=1790692116; h=content-transfer-encoding:mime-version:references:in-reply-to :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=e2Bt2pbnVu/ApigQk0zS6acL2EWAE6Kw3ktFWRmRY+Q=; b=DBhHifmR8ORegviFDO8qFqTdDI8cJ3tfVTYNoMbpURJDEN/yUcbq1pS01n/6benzwB IT0t4MmTtzSVSvf695MXMa9nfq4MX3kEfjrmp9ZT54PON01qEAJ8beoLHtAJfTZMyihU Z4IE1piNFE02K02K1KG1OGVNhonoqpsy+acSwVGRuIoy7DzMr12lvRz9d/lnXsfHLOHS aAFqyCEJoqb8WrjVgf5wksE5VDMyiRLMI+gPukI6yaf70yqwJ/U0RIdorSLtqTh4+WN0 eZTwzdc/CK52MUNDKSJm3ttzuSOnI8u348Ze8xB+EqPLL7MTKiNhcZr8HCXSQIWO4zXI xCsQ== X-Forwarded-Encrypted: i=1; AKwUvBx5cB0K5u7c3uilk889zn6EG/m3ylij0UtxJeZLyH+ZE0yu7aoYRqjFbwEDJwJ+1jX9n8GJVEnh7vooiVY=@vger.kernel.org X-Gm-Message-State: AFuF++nhfaBCAm2+GwbXt/dhhFoFiUz68sE/+8SQ/FUknamEq357eBIY PXz5OTkWFXpJ77BQKbBoWcmnCy6B7hss0N23i/eUpHalljp1lz+tHEWh X-Gm-Gg: AYBFou1EteLfQKUHAd2dLw/PtrfvBQS2GUHRd6SIPs0EkT2OWDMJoxEAI0F9v/BPriI CGJBd4arI2m3IYn4/mz1p67LxVnI/PDxgOtlCfzTVkZF9z1yEU96T7gxujHHmTYU/DoIWEnHRmD 4HEVYGWXcobwxTyWNEJ5xJ+KCW/GmPqw/tIfIAS8/ACTUGCHMT5WMI9aNwDuLMTUR5Tr0jHXKED tsCeG39vYppkWyx5yPvBZC/TZ7jq6ACQYzL69/SkL6B17euBT7C0r+o7W7cpTodewC3w8y0dM2+ 9AjLj2t5yTEv6V++vTwBrXpEGwKoak0aKNLxpRYWyZ5cS5L9cazsGZ0VT/6PX/rjyeVb/YpRtsw 4Mu/v6gDPvvKBJVjIh8iyfY0jm2a1Y8LIVM3rCTJq7+LJniWZDIVcYZeFFamt1QKmdZHV2FcaQa ge6sebLN1AAGFAWj83qwuV29xEfezK7+zzDq1p51Q1q2orbeSrFSEqSQSL2YVNyvyZGum25xNaN B9FJNRoFQxTAnjiG1X8Wmq8OzIVyl800FEkLlP5DA== X-Received: by 2002:ac2:5681:0:b0:5b6:1a7c:30 with SMTP id 2adb3069b0e04-5b8c1859720mr5678732e87.51.1790087316034; Tue, 22 Sep 2026 07:28:36 -0700 (PDT) Received: from fedora-tap.advaoptical.com ([82.166.23.19]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-5b8d46d2064sm589691e87.24.2026.09.22.07.28.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Sep 2026 07:28:35 -0700 (PDT) From: Sagi Maimon To: Richard Cochran , Vadim Fedorenko , Jakub Kicinski , "David S. Miller" , Eric Dumazet , Paolo Abeni , Andrew Lunn , Simon Horman , Jiri Pirko , Arkadiusz Kubalewski , Jonathan Corbet , Randy Dunlap , Shuah Khan , netdev@vger.kernel.org Cc: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, Sagi Maimon Subject: [PATCH net-next 1/9] ptp: ocp: move the CPLD identification read off the sync worker Date: Tue, 22 Sep 2026 17:28:21 +0300 Message-ID: <20260922142829.57740-2-maimon.sagi@gmail.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20260922142829.57740-1-maimon.sagi@gmail.com> References: <20260922142829.57740-1-maimon.sagi@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" ptp_ocp_sync_work() samples the in-sync bit once a second and emits the dpll change notification. Since the TAP CPLD support it also resolves the i2c adapter and performs the one-shot CPLD identification read, and that read can block for seconds: adva_x1_bus_claim() waits for the MicroBlaze to grant the TMC segment for up to MBLAZE_RETRIES * MBLAZE_RETRY_US, and the hand-back polls for the grant to drop for as long again. While that runs the in-sync sampling and the dpll notification are delayed by the same amount, and because ptp_ocp_remove() - which is also the .shutdown handler - begins with cancel_delayed_work_sync(&bp->sync_work), unbind and reboot block for it too. Give the identification its own delayed work, queued from probe only on boards that have the part and rescheduled only until the one-shot read is settled, so a claim that has to wait no longer holds up anything else. Fixes: 3b815e29966f ("ptp: ocp: add TAP CPLD access for ADVA TimeCard X1") Signed-off-by: Sagi Maimon --- drivers/ptp/ptp_ocp.c | 39 ++++++++++++++++++++++++++++++--------- 1 file changed, 30 insertions(+), 9 deletions(-) diff --git a/drivers/ptp/ptp_ocp.c b/drivers/ptp/ptp_ocp.c index 2802989e8494..4a58bcc14648 100644 --- a/drivers/ptp/ptp_ocp.c +++ b/drivers/ptp/ptp_ocp.c @@ -402,6 +402,8 @@ struct ptp_ocp { bool sync; time64_t gnss_lost; struct delayed_work sync_work; + /* CPLD identification, off the 1 Hz sync poller */ + struct delayed_work cpld_work; int id; int n_irqs; struct ptp_ocp_serial_port port[__PORT_COUNT]; @@ -5935,18 +5937,32 @@ ptp_ocp_sync_work(struct work_struct *work) =20 bp->sync =3D sync; =20 - /* Resolve the adapter here rather than once in probe, where it can - * race the adapter's own registration, and read the ID as soon as it - * turns up. A claim can fail transiently - the firmware may not - * grant the segment straight after power-up - so adva_x1_cpld_read_id() - * retries a bounded number of times before giving up. - */ + queue_delayed_work(system_power_efficient_wq, &bp->sync_work, HZ); +} + +/* + * Resolve the i2c adapter and read the CPLD identification. + * + * Kept off ptp_ocp_sync_work(): a claim can block for seconds - the + * MicroBlaze handshake polls for up to MBLAZE_RETRIES * MBLAZE_RETRY_US a= nd + * the hand-back does the same - which would delay the in-sync sampling and + * the dpll change notification, and stall the cancel_delayed_work_sync() = on + * the unbind and shutdown paths for as long. + * + * Reschedules only while there is something left to do, so a board without + * the part, or one whose identification is settled, costs nothing. + */ +static void ptp_ocp_cpld_work(struct work_struct *work) +{ + struct ptp_ocp *bp =3D container_of(work, struct ptp_ocp, cpld_work.work); + adva_x1_cache_i2c_adap(bp); - if (bp->has_cpld && !READ_ONCE(bp->cpld_id_tried) && - READ_ONCE(bp->cpld_i2c_adap_nr) >=3D 0) + if (READ_ONCE(bp->cpld_i2c_adap_nr) >=3D 0) adva_x1_cpld_read_id(bp); =20 - queue_delayed_work(system_power_efficient_wq, &bp->sync_work, HZ); + if (!READ_ONCE(bp->cpld_id_tried)) + queue_delayed_work(system_power_efficient_wq, &bp->cpld_work, + HZ); } =20 static int @@ -5984,6 +6000,7 @@ ptp_ocp_probe(struct pci_dev *pdev, const struct pci_= device_id *id) bp->cpld_i2c_adap_nr =3D -1; =20 INIT_DELAYED_WORK(&bp->sync_work, ptp_ocp_sync_work); + INIT_DELAYED_WORK(&bp->cpld_work, ptp_ocp_cpld_work); =20 /* compat mode. * Older FPGA firmware only returns 2 irq's. @@ -6046,6 +6063,9 @@ ptp_ocp_probe(struct pci_dev *pdev, const struct pci_= device_id *id) } } queue_delayed_work(system_power_efficient_wq, &bp->sync_work, HZ); + if (bp->has_cpld) + queue_delayed_work(system_power_efficient_wq, &bp->cpld_work, + HZ); =20 return 0; out_dpll: @@ -6080,6 +6100,7 @@ ptp_ocp_remove(struct pci_dev *pdev) int i; =20 cancel_delayed_work_sync(&bp->sync_work); + cancel_delayed_work_sync(&bp->cpld_work); for (i =3D 0; i < OCP_SMA_NUM; i++) { if (bp->sma[i].dpll_pin) { dpll_pin_unregister(bp->dpll, bp->sma[i].dpll_pin, &dpll_pins_ops, &bp-= >sma[i]); --=20 2.47.0 From nobody Thu Sep 24 15:10:01 2026 Received: from mail-lf1-f47.google.com (mail-lf1-f47.google.com [209.85.167.47]) (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 DDF60551995 for ; Tue, 22 Sep 2026 14:28:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790087322; cv=none; b=kt6iQDhG/S99VIEkdKfYiVzYECyE8hGW9YP3yDRi2Uv5/ePuk17x7KUDYAJGguzCWNPn1tmnmvh9RSaykqYl+PwTe5R/W3eNSqYHYYaS6TDbRZ45iT7mQEVzZw9cYK4lLUcSk1bq9UU31NU0tJeApMPSvnSbrcIhd4InBtxqq3M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790087322; c=relaxed/simple; bh=3F8nzkClo9hFmLBqeL2ZwX2gzhcKOqj11Tya8k4rmUQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=mr0j9zaGX8/bLHhNGkCSuBoudxptY20GgNaUYsImLAScheStHzRA9VCOn0FDv77rd5ey7lk7y8nBoK1109k3G0DG1UqGBla52U8glT1+ANSjYZcwZOFD7tIaeiFRhRjONQ94tgjknEGxDY25LPMJTp/uvLQI0Nk/tH13UB9qHYM= 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=LOQtrtKW; arc=none smtp.client-ip=209.85.167.47 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="LOQtrtKW" Received: by mail-lf1-f47.google.com with SMTP id 2adb3069b0e04-5b5f21afe8cso1076684e87.1 for ; Tue, 22 Sep 2026 07:28:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1790087319; x=1790692119; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=1u3pLUA5u42iB7wAAx0Pnvzg/CHC2JIBmGTUfYO84VU=; b=LOQtrtKWExY/0366Fz0+GMQF0E61usIS5K2vvYbqS1Hv9I2zJF5ed84jTSnL3I7CVk EtBi/Vs3OVAr4MI9jTCnwedPBboFdGur08gdqsMx4rVslIAp2bUz5meyv1rhVdBJ55W8 Swt1fLqvAuwh3kw/Cil0ZIh/+WSydtiywbdlKtB2qjm1sdx3kEYAp4DEwrRKXjEBzajA sVkQixYACIuEN2+4F2Ptr4LCh/XbTVHo5jC3B7n1b3qTkc8l6T7hm5BkFeonw1ve1rlD EAuLoZfsfDMxAmPYenNwQFoBBQBXBnSqXcvfnun+UiTypJcJEcWwfsL/2Pa9co17xIEl UDlg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1790087319; x=1790692119; h=content-transfer-encoding:mime-version:references:in-reply-to :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=1u3pLUA5u42iB7wAAx0Pnvzg/CHC2JIBmGTUfYO84VU=; b=aKMtJqbVUMXyMbMCxF9Hhg3utd2UTPb0VgBZTkAedYcrnIHbjdv+Ct7IprqEjAdy6e c8J5lAbrKb/Br+JPZxtPiCngfa5ROpHuB2Fc2WNrdnuux7kRz2d4qyaiyA3pf0maDFAz +btdR7Y4hsJg87l017BXYNrlycGmRsu6SfHvR59Tl/z2iwzoY0nBZJYBbPCB56ko69cC YA16JVE1hatv3W5XxPTlPCngrOqDbdLN9R2KohEkKsgetGO989FToGM1mq3SXY0SjSR0 bVsXun40u849qnwl6dC3H5w2r37co9zQu2zDwYl8W/bBVoTlXh6DCwxE6okBmQ6hshj7 tmzQ== X-Forwarded-Encrypted: i=1; AKwUvBwLFy9ZD8E4cBynA169MkgIQpETfmlWEOYnL6H2O/YfEPRG3ZGmyTLwiXP4b3I2ZmRDXp8fiK2eiJpOqTg=@vger.kernel.org X-Gm-Message-State: AFuF++k+Tso1wr0Q85vIoM/W/ROAaAFrGGUVCGMX0L3lyhfpf34KDTVX 5+Z8xTEUjiTcf+CBsK9QUVbsznb45hr9OQAR+UJjN+68VJwTcey5f5CY X-Gm-Gg: AYBFou0aiAiRnizOtxyDcSXRs+QksW9Bkze+FFO73Ticv70WFdv85JBC2rA0NZfxtCH y62Y0/M/sN0IpPBG68FFDAdeBEWP9vrf6uR8DdZ5z82FRnHOA+u5pY4hi9OvD97kS+L8yA2Hm9b UyvJu0khR8NvjU/+uS3+nQW1l96vEFzUq1HYqiQXWqwFcPqanvwSami5PQdeNHnv/NlBos01I1h DiygjeTdJyx6ijjC4GugccBAL+TXhHPo24CFT4OboIgX43QuZGYhk4ug0TNvou60HQMDYHK+XVx 5CcaKFQAGVT/dZLsqmjFB7p8XCqvt05F6Skdlb6WXC4HeioCINXASl61Lm3cz/2zMePSLiNURIU 8owQ8BIPnbzIErqFmYAyi0l5NtFnngOANPHzq+vAvaaN+BrvTwsTU+MJN2QRI9Lolz5fh54MfkX xEn/lmlIUfiM7cO+md7USYpVp7nQ7pSy6/ZE2KSHJ9uFOV9K6JH20AJgXEkyc5QOwZVtkTCRRYT jrr3QGSk5PFKbmzttGy85/r3owRr28toLaLCA92AUDdUCu/s0U= X-Received: by 2002:ac2:514b:0:b0:5b6:1aee:95f7 with SMTP id 2adb3069b0e04-5b8d2961643mr658169e87.43.1790087318520; Tue, 22 Sep 2026 07:28:38 -0700 (PDT) Received: from fedora-tap.advaoptical.com ([82.166.23.19]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-5b8d46d2064sm589691e87.24.2026.09.22.07.28.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Sep 2026 07:28:38 -0700 (PDT) From: Sagi Maimon To: Richard Cochran , Vadim Fedorenko , Jakub Kicinski , "David S. Miller" , Eric Dumazet , Paolo Abeni , Andrew Lunn , Simon Horman , Jiri Pirko , Arkadiusz Kubalewski , Jonathan Corbet , Randy Dunlap , Shuah Khan , netdev@vger.kernel.org Cc: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, Sagi Maimon Subject: [PATCH net-next 2/9] ptp: ocp: do not cache EEPROM content after a failed TMC bus hand-back Date: Tue, 22 Sep 2026 17:28:22 +0300 Message-ID: <20260922142829.57740-3-maimon.sagi@gmail.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20260922142829.57740-1-maimon.sagi@gmail.com> References: <20260922142829.57740-1-maimon.sagi@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" adva_x1_bus_release() drops the i2c root adapter lock whatever adva_x1_mblaze_release() returned. That is deliberate - holding the lock after the firmware failed to take the segment back would stall every other user of the controller with no way to recover it - but it means the errno reaches only the CPLD operation that held the claim, while the next transfer on that adapter may still be routed to the TMC bus. ptp_ocp_read_eeprom() is reachable from the unprivileged DEVLINK_CMD_INFO_GET path and stores what it reads without validating it, so in that window it can latch whatever answers 0x50/0x58 on the TMC segment as bp->serial and bp->board_id and then publish them. Record that the routing is unknown when the hand-back times out and skip the EEPROM read while it is, rather than caching a value that was never read from the EEPROMs. A later claim that the firmware grants proves the handshake is working again and clears it. This does not fence the at24 and nvmem sysfs paths, which do not go through the driver; it only stops the driver publishing the result. Fixes: 3b815e29966f ("ptp: ocp: add TAP CPLD access for ADVA TimeCard X1") Signed-off-by: Sagi Maimon --- drivers/ptp/ptp_ocp.c | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/drivers/ptp/ptp_ocp.c b/drivers/ptp/ptp_ocp.c index 4a58bcc14648..510083dc750a 100644 --- a/drivers/ptp/ptp_ocp.c +++ b/drivers/ptp/ptp_ocp.c @@ -448,6 +448,8 @@ struct ptp_ocp { unsigned int cpld_id_attempts; /* x1 TAP CPLD present */ bool has_cpld; + /* the TMC segment was never handed back; routing is unknown */ + bool cpld_bus_stuck; /* EN_CFG_TP issued but not yet REFRESH'd */ bool cpld_in_config_mode; }; @@ -2022,6 +2024,18 @@ ptp_ocp_read_eeprom(struct ptp_ocp *bp) if (!bp->i2c_ctrl) return; =20 + /* A hand-back that timed out leaves the controller possibly still + * routed to the TMC segment. Reading now would latch whatever + * answers 0x50/0x58 there as the serial and board id, and those are + * published over the unprivileged devlink info path, so refuse + * rather than cache something that was never read from the EEPROMs. + */ + if (READ_ONCE(bp->cpld_bus_stuck)) { + dev_dbg(&bp->pdev->dev, + "skipping EEPROM read, TMC bus routing unknown\n"); + return; + } + tag =3D NULL; nvmem =3D NULL; =20 @@ -4537,6 +4551,8 @@ static int adva_x1_bus_release(struct ptp_ocp *bp) return 0; =20 err =3D adva_x1_mblaze_release(bp); + if (err) + WRITE_ONCE(bp->cpld_bus_stuck, true); bp->cpld_adap =3D NULL; kfree(bp->cpld_buf); bp->cpld_buf =3D NULL; @@ -4632,10 +4648,17 @@ static int adva_x1_bus_claim(struct ptp_ocp *bp) bp->cpld_adap =3D adap; =20 ret =3D adva_x1_mblaze_acquire(bp); - if (ret) + if (ret) { adva_x1_bus_release(bp); /* keeps the acquire error */ + return ret; + } =20 - return ret; + /* The firmware granted the segment, so it is answering the handshake + * again and the routing is known once more. + */ + WRITE_ONCE(bp->cpld_bus_stuck, false); + + return 0; } =20 /* Select a mux channel, or deselect all with ch < 0 - the power-on state. --=20 2.47.0 From nobody Thu Sep 24 15:10:01 2026 Received: from mail-lf2-f13.google.com (mail-lf2-f13.google.com [74.125.229.205]) (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 54BA8556B85 for ; Tue, 22 Sep 2026 14:28:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.229.205 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790087325; cv=none; b=m5JA9lCHqcLNHp7MG4w45COUcz54IjrEyj0aoQw9AJbw8OiLYnA1hznckX82xL0eP2uaAR7Rgz2twVGqfehHoK05+diq23a/vmRTBVTeJgUULkxwemNue0n4LMHR5RutwRjE1gcnDsBftAa30e/78AP5tyj1Ra1IzApxOv9va5Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790087325; c=relaxed/simple; bh=SVtzUg4Eb+h//swwQumGXMTtjoutlA+uq+ys1ApPWSc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=PZZ5aYdJEKxQB88ss86GvRpKd7TJUSaDd7Z2iEm2w+Z7KQzLagOdE5e2G4Veg6AzFzs3pMYkuzxBZqRUM7YYc10v8gyA0GzbtEawqgHoPfdbZct0Nupr42pExRA4sSEXVdztlCb6pBfnkt3gCcL6bYOmzL8MsPvEPR2bfkDhDF8= 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=bdB02Ipb; arc=none smtp.client-ip=74.125.229.205 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="bdB02Ipb" Received: by mail-lf2-f13.google.com with SMTP id 2adb3069b0e04-5b8d6489419so414124e87.3 for ; Tue, 22 Sep 2026 07:28:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1790087321; x=1790692121; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=C2cIcFD9n/tIhle0FL6VW14T8JQcamu6z/X7FWTdDmM=; b=bdB02IpbBAv4XESwKAcJhUt9dgcHa2erpxr9NqcM1HXuWC5Uzyt+Kidg3uKs4LwkYq 8IJVUfJ+7WJRtirgB7oeAQ2xn5xFPJgocGqpERQjaEGcr7cNFVGMRq1gopkUaxBr0eK/ dO2AjVfBEWrtDyo1bAX2i9x95oCspoZ2J26BcJ1eoAtfZZw4yLZP1S4jQyElMH+IwKvf 24BJhV5Xw+yCEnRYvTmIk/sWWD5Syp7aCYs0/IGYzPqPTPOpvwT4Yt14ZqT5USp6SSta AT449txM9XKTszVDeIPq8q7pKLGm6cCQ9FKo9Na2XXwtsFuyOIkcwjEoPJ2V3BNkaC8I Mj/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1790087321; x=1790692121; h=content-transfer-encoding:mime-version:references:in-reply-to :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=C2cIcFD9n/tIhle0FL6VW14T8JQcamu6z/X7FWTdDmM=; b=EVHQCJYNe5zli2m/t5NFMiR30tGEqu73f2FtBk26HOs2+Xkq9MffvFeJtUQ0p0UCvx htDoDhmv/sUgrA7+ENROLdGSkPHzFxJJKwfT/HmiAG8E+aeNaNUz1lIqPLTPRSCvE6pq 40pvdlfs/uJZwkWpJA/MgXdGjVkhBG4sJyuVPuN8qsq2iK0Z2gAXUdbpPJQ7IuJT0Dz4 +SbYlDzLUWHinFec4zzLv8NVe8/uhDDXf9fS6YbrrSqZ5c64iRGXrRcCRVF1VuFO4FbY ghnC8y+vUeROXWSTDAZumyO4NoOXY8t1cnD5gEh4qpL7nrVJ1OPnakOrXvv/4i5nr8nn oLyg== X-Forwarded-Encrypted: i=1; AKwUvBzFZIPzuGzoNuz7+z0GAtS+VkAYSnEoHDWvaPwrAdM+MuiwORdvBf30Bh3BnKJQ4Q7VVey1L/RmmwDSqbQ=@vger.kernel.org X-Gm-Message-State: AFuF++mH8ePf9uIEA64qqrmry5abb6jdp413oQgvLhNPGzdNzPicYysK vRRpB88GUJKWxW2uXTvbSubNkDisSLhlri31/7eKTlXNh6FG2nD9sN2U X-Gm-Gg: AYBFou2AEd5JZX0yFnKOk/5kfKw2mudPBnSGZvOTVQfTWjlcCpLANEaoU40D0U44IuQ C/8flG8Igau+fHUk3xSm7Kzs0ivIWjko8GEm0Y1hms6xGT3SU/BJF3DTuVE0Ei37b7LpAaT6lT/ bp2ZEEFcPg70aRXlm2QHgfpAibsAdaJX5ouMNQIN6H3YWm4w7kanrXMAh6CrUYgrlkRg2vY97/V S8XCc0j/etEmx73vjjwD6yVhCPO9E1BgbnN5iygwdk7Ebl+18Ext35sHpA1ypOE41rmpyWudvsJ qRUIIkB4R/64WzMifwRchqmypuaz8/0KqeMEjK34j2pf0Zr7rHCn5wYTG0NdMNqqpenXS3LcJOp GILOdj/bnB50a2eLc3eVrRzpTSJKKo3woemjRqB+SheBRxb/CmrdYR/0pH/vhH3CNGFY/Z4+eqm 7bxJBtex0bmM6C0Txcf4UreKoyRvzqunibi+CVblMiHMj2vqTzVAqLRXqw7v/sXt8iVzI31yMYS hvFs8sqQAjTOsHzORNofku65YafEab/bsUCf08L X-Received: by 2002:a05:6512:1329:b0:5b4:adb1:b25b with SMTP id 2adb3069b0e04-5b8c17f1feamr4505886e87.14.1790087321044; Tue, 22 Sep 2026 07:28:41 -0700 (PDT) Received: from fedora-tap.advaoptical.com ([82.166.23.19]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-5b8d46d2064sm589691e87.24.2026.09.22.07.28.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Sep 2026 07:28:40 -0700 (PDT) From: Sagi Maimon To: Richard Cochran , Vadim Fedorenko , Jakub Kicinski , "David S. Miller" , Eric Dumazet , Paolo Abeni , Andrew Lunn , Simon Horman , Jiri Pirko , Arkadiusz Kubalewski , Jonathan Corbet , Randy Dunlap , Shuah Khan , netdev@vger.kernel.org Cc: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, Sagi Maimon Subject: [PATCH net-next 3/9] ptp: ocp: hand the TMC bus back once on an acquire timeout Date: Tue, 22 Sep 2026 17:28:23 +0300 Message-ID: <20260922142829.57740-4-maimon.sagi@gmail.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20260922142829.57740-1-maimon.sagi@gmail.com> References: <20260922142829.57740-1-maimon.sagi@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" adva_x1_mblaze_acquire() ran the hand-back itself before returning -ETIMEDOUT, and adva_x1_bus_claim() then called adva_x1_bus_release() for the same error, which runs it again. Both write MBLAZE_RELEASE and poll for the grant to drop for up to MBLAZE_RETRIES * MBLAZE_RETRY_US, and both run with the i2c root adapter lock held, so a single failed claim could hold the shared controller for half as long again and log "TMC bus still granted after release" twice for one failure. Leave it to the release path, which the claim already calls. Fixes: 3b815e29966f ("ptp: ocp: add TAP CPLD access for ADVA TimeCard X1") Signed-off-by: Sagi Maimon --- drivers/ptp/ptp_ocp.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/ptp/ptp_ocp.c b/drivers/ptp/ptp_ocp.c index 510083dc750a..feb61355078a 100644 --- a/drivers/ptp/ptp_ocp.c +++ b/drivers/ptp/ptp_ocp.c @@ -4526,10 +4526,6 @@ static int adva_x1_mblaze_acquire(struct ptp_ocp *bp) return 0; } =20 - /* Drop the request we gave up on. Any error from the hand-back is - * subsumed by the -ETIMEDOUT we are already returning. - */ - adva_x1_mblaze_release(bp); return -ETIMEDOUT; } =20 @@ -4647,6 +4643,12 @@ static int adva_x1_bus_claim(struct ptp_ocp *bp) i2c_lock_bus(adap, I2C_LOCK_ROOT_ADAPTER); bp->cpld_adap =3D adap; =20 + /* adva_x1_bus_release() runs the hand-back, so the acquire path does + * not do it itself: both poll for the grant to drop for up to + * MBLAZE_RETRIES * MBLAZE_RETRY_US with the adapter lock held, and + * doing it twice only holds the shared controller for longer and + * logs the same failure twice. + */ ret =3D adva_x1_mblaze_acquire(bp); if (ret) { adva_x1_bus_release(bp); /* keeps the acquire error */ --=20 2.47.0 From nobody Thu Sep 24 15:10:01 2026 Received: from mail-lf2-f12.google.com (mail-lf2-f12.google.com [74.125.229.204]) (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 DF25A5581FC for ; Tue, 22 Sep 2026 14:28:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.229.204 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790087328; cv=none; b=TD1S2C30RzMJ1Qo/sNp8LLCl9t4EV3OFnmSfyydJGQInWt6F/RQSkGS3YY39vXKTJDdQtij1oiuubV9z8SRujuZ8xwod1/gH2qco3d5GlrHc84NL5RxkRgAi5RrYrwu539SjVz7jwPGvf5O8Yng6O2El3Mvnn9JxrDlX0HqHvtA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790087328; c=relaxed/simple; bh=xIgy530ICC4m3NkKuadi/zzirqDT04Q8w/kPC5TSRsM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=MuZ4Chm08XJ2U+yIQdmB6y0ghbNggtHS/JT3DhC/aOksrO+TDegg0zXYT0GEFNYwZmA6dKnHEuq1aFTTHzckp9yI1LlR0YUgYzujFp0A3g2L7pyZRYbCEpsBCPryzflCtg+jpMsYaClS/BQSV0ty6/2DWV0mF5c8CcHslOoP38w= 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=WAhbLqQ0; arc=none smtp.client-ip=74.125.229.204 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="WAhbLqQ0" Received: by mail-lf2-f12.google.com with SMTP id 2adb3069b0e04-5b5e4f1e023so1554590e87.0 for ; Tue, 22 Sep 2026 07:28:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1790087324; x=1790692124; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=8Qx6sfb6upNLcj5IsqKTL87bc3YDUS09h8egDr62oaQ=; b=WAhbLqQ0L0Lm2DdQD8jamZaGUYd4uJJ+iAyP6l4/XSjA7qxCRLIm4joOjNbhKRojx0 2EccsASsw8d33gwRDvxXsFj3VnPP988EOM6nGS9p5bIwZ4kdNziuv/fGZXXD+BDVFSYO 1yw7MvB1oVHdymO+dcNC0vesmJE9V3jvXMoUNvPBM4oB2ZKBdfuHjwVAlkKBgU8w6p0D zIsgIh7AUHcZE5TItwMxKMJa1AaaZmJPI0k9Ycahcgf1f4UXoVgmmBus78nJqP7fGvzB xYvYCgGrrYgaVyG4f8ydWm575BBzu9ftL0pLEl2mEc9MpmmbFvNu6JCdRJ1AbDF5lBZz Rqrw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1790087324; x=1790692124; h=content-transfer-encoding:mime-version:references:in-reply-to :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=8Qx6sfb6upNLcj5IsqKTL87bc3YDUS09h8egDr62oaQ=; b=OMHExYb1v1cKjidGjanaM0t1ut1sF4roKidGi+8QtHqY/cLSwn2BSyJehjpfpfeD+E sUjTp43LXezEfTb01rcj+0F4vuOh/egKgAUCgkIO/2Eock86idzDcDcoCmt70tWgshRQ yzLL5GysZZyj0f2ifM5FeJHtUp9ooLQ2XtlHfFPhOBfP8r+XVWpDbtOjn/yD+r0xqjVS 5kflCqreH4e83qmsz62eNB0F1CpMoau3jwkGQpyu1mxZh32xKz/ExrWmprioMivEcGOb jGU4yNlej6eRq/BYESpKTEjwpT5gDb2SKjihobENCJ+ctI13/6biNIduHoeGP8SNBatp 388A== X-Forwarded-Encrypted: i=1; AKwUvBy3Z590c3N03XyhMWLwLZkFeiqkl0Hm2z3AZUT75dyvIinzvqLxTfYOEGX7FAGvzoN6LZdfP7BJuD+0ELQ=@vger.kernel.org X-Gm-Message-State: AFuF++ntRVLwPaywM1L5/UhvwamObeoqbycpc2TcMmZ614WP9YsxGCq9 mzxxi96UJSpVbu4mf3B96CLHDz+Y5WTgjnsE64Zl7Mi/ZFnFs5ttvHn8 X-Gm-Gg: AYBFou2ijAFU80CxSjZyIYzSLEvPTBHTAKcnDjmEkktSH1yglgl94qDncx8ZcIlTHdE 5xVYz4KL0rARxnxoJSCmdlS6m2kfeiRHhIcdDC6pcGqP7/YB47vqXrkR/IHjgFHYKNVsHzqRUlV enD6amUTisKKfV39HME2lOdGKh39rxY5dFdipfRIpY4fGoNNrCleHw/C0WTQffZJAPfsQfeBp4M ZYwyw+q1lBi8gtb/SgS0t5sNdI+zg3sL3PjsfaaSfNe8GwZBFN9lLdB7ywalzBn1IOq2nGja5/B xmpOdTriQpeMw3WlFTmBo663bBuCwXrnU14rcAE6KPcBvHo86ns7l4Nklb172ItqP3HeSn4grsD /oWSEhFaJSKFrIqs9/982l36p+39Dsa92gjEVXv+etHU4qw7eovixWSV0nKnK0xYlmQzoHU+kzY tzgX4A3YBZ83Cw4iLNzkSQRCZuReAOADw9GFfdJN1mkA4X9w84mbija2x0Qivx6qI0dgIG7CgZG 4BvT0qBFZb3ziB1fvo4InOt1l/juypL7HNSn2pM5Q== X-Received: by 2002:a05:6512:23a9:b0:5b4:ac27:8f76 with SMTP id 2adb3069b0e04-5b8d28fe7e6mr1013908e87.7.1790087323448; Tue, 22 Sep 2026 07:28:43 -0700 (PDT) Received: from fedora-tap.advaoptical.com ([82.166.23.19]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-5b8d46d2064sm589691e87.24.2026.09.22.07.28.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Sep 2026 07:28:43 -0700 (PDT) From: Sagi Maimon To: Richard Cochran , Vadim Fedorenko , Jakub Kicinski , "David S. Miller" , Eric Dumazet , Paolo Abeni , Andrew Lunn , Simon Horman , Jiri Pirko , Arkadiusz Kubalewski , Jonathan Corbet , Randy Dunlap , Shuah Khan , netdev@vger.kernel.org Cc: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, Sagi Maimon Subject: [PATCH net-next 4/9] ptp: ocp: forget a CPLD i2c adapter number that no longer resolves Date: Tue, 22 Sep 2026 17:28:24 +0300 Message-ID: <20260922142829.57740-5-maimon.sagi@gmail.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20260922142829.57740-1-maimon.sagi@gmail.com> References: <20260922142829.57740-1-maimon.sagi@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" adva_x1_bus_claim() returned -ENODEV when i2c_get_adapter() found nothing for the cached number but left the number in place, so adva_x1_cache_i2c_adap() kept bailing out on its first test and never resolved the adapter again. The comment on the parent check claimed a bad number is forgotten and looked up again on the next sweep; that only held for a mismatched adapter, not for one that had gone away. Factor the invalidation out and use it on both paths. Re-arm the one-shot identification when a new adapter is cached as well: a different adapter may answer where the previous one did not, and leaving cpld_id_tried set kept cpld.id absent for the rest of the binding. Fixes: 3b815e29966f ("ptp: ocp: add TAP CPLD access for ADVA TimeCard X1") Signed-off-by: Sagi Maimon --- drivers/ptp/ptp_ocp.c | 35 ++++++++++++++++++++++++++++++----- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/drivers/ptp/ptp_ocp.c b/drivers/ptp/ptp_ocp.c index feb61355078a..45313143b6f7 100644 --- a/drivers/ptp/ptp_ocp.c +++ b/drivers/ptp/ptp_ocp.c @@ -4574,6 +4574,19 @@ static int adva_x1_i2c_adap_match(struct device *dev= , const void *data) * both the notifier and a single lookup here can miss the same adapter. * Retrying costs a short klist walk per tick until one of them succeeds. */ +/* + * Forget the cached adapter number so the next sweep resolves it again. + * @nr < 0 forgets whatever is cached; otherwise only that number, so a + * caller that raced the notifier cannot clear a newer one. + */ +static void adva_x1_forget_i2c_adap(struct ptp_ocp *bp, int nr) +{ + scoped_guard(spinlock, &bp->cpld_adap_lock) { + if (nr < 0 || bp->cpld_i2c_adap_nr =3D=3D nr) + bp->cpld_i2c_adap_nr =3D -1; + } +} + static void adva_x1_cache_i2c_adap(struct ptp_ocp *bp) { struct device *child; @@ -4598,6 +4611,15 @@ static void adva_x1_cache_i2c_adap(struct ptp_ocp *b= p) bp->cpld_i2c_adap_nr =3D i2c_verify_adapter(child)->nr; } =20 + /* A different adapter may answer differently, so let the one-shot + * identification run again rather than leaving cpld.id absent for + * the rest of the binding. + */ + scoped_guard(mutex, &bp->cpld_lock) { + bp->cpld_id_tried =3D false; + bp->cpld_id_attempts =3D 0; + } + put_device(child); } =20 @@ -4614,8 +4636,14 @@ static int adva_x1_bus_claim(struct ptp_ocp *bp) lockdep_assert_held(&bp->cpld_lock); =20 adap =3D i2c_get_adapter(READ_ONCE(bp->cpld_i2c_adap_nr)); - if (!adap) + if (!adap) { + /* The adapter behind the cached number is gone. Forget it, + * or adva_x1_cache_i2c_adap() keeps bailing out on its first + * test and never resolves the adapter again. + */ + adva_x1_forget_i2c_adap(bp, -1); return -ENODEV; + } =20 /* The number is freed before the notifier clears it, so it can * already be another adapter's. Check this is still ours, and drop @@ -4623,10 +4651,7 @@ static int adva_x1_bus_claim(struct ptp_ocp *bp) * way, where forgetting it lets the worker look the adapter up again. */ if (!bp->i2c_ctrl || adap->dev.parent !=3D &bp->i2c_ctrl->dev) { - scoped_guard(spinlock, &bp->cpld_adap_lock) { - if (bp->cpld_i2c_adap_nr =3D=3D adap->nr) - bp->cpld_i2c_adap_nr =3D -1; - } + adva_x1_forget_i2c_adap(bp, adap->nr); i2c_put_adapter(adap); return -ENODEV; } --=20 2.47.0 From nobody Thu Sep 24 15:10:01 2026 Received: from mail-lf2-f13.google.com (mail-lf2-f13.google.com [74.125.229.205]) (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 C211E559301 for ; Tue, 22 Sep 2026 14:28:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.229.205 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790087331; cv=none; b=FkcIalg3TH8ucVb3e8YNNYgmxEpMKo+Z3se4N0utNy4P1ngOMiTC3xMfUKz2qhCem+qGLJ1AvNR6tyW59XuWylzura+Fm1l1i3hDpH9HrAkXmLkgVtN7pZ5ha4AS7pWRuj9wPd0EcHnXLbs3mXxBVxfLGyY2pJgE6v29vobdCxc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790087331; c=relaxed/simple; bh=XA55q142D8aRkadxqfCagWbQvXMi9cPh2wIUiWNw0Sw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=cxiyS8nNM3LEmlDRFrTBH82V5mAQYh/8mPmmOMfTdh/8G0sNuEeM4f+LAxvbvn0rn926+x2qkLrS1v8R73wHsNkY2Tyay51TU4qg3qc27cm4dUbOMttPMVx5JpzHa5dV9F8XzeyENdCQOWA4wzksL0l9kUsXb4y5J0PUlaSOzyE= 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=FmSMFL1F; arc=none smtp.client-ip=74.125.229.205 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="FmSMFL1F" Received: by mail-lf2-f13.google.com with SMTP id 2adb3069b0e04-5b8d7263f0cso264812e87.2 for ; Tue, 22 Sep 2026 07:28:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1790087327; x=1790692127; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=Np0pzXK9nCSAZ/EqFO5RnAzXdV1OHTysVqZnz2yyn3g=; b=FmSMFL1FoGwl+TLSh8/4uDlQzap6oEjQOh1Z/XAEZDsQSbWlk3P4MDLTZ7IzKrsv02 WVRJjnj6lheSfNIYw7+xfShqspXWVdwOwj4ab1y28KccfuwxATOqRmhB5UfD5TTLw/NB d0xQJdwgFG9lQROLugG9gAxpN4DaoCsEyfSXEbx919I1J7Xhb3mAqrXoC0p8XhGuufWq 4z4EOw1t2yhKVbPx2LzXLZsbfXESCRfzISSvDlZLboo0mTHN453KAhwixPPbxCu0I8en 7ewzbdwJakEGxNTR+ItcSPHWTzQmedf/fhPih4dvwIVm5YYbfu1fqyaaI2qthxkegI5X JOOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1790087327; x=1790692127; h=content-transfer-encoding:mime-version:references:in-reply-to :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=Np0pzXK9nCSAZ/EqFO5RnAzXdV1OHTysVqZnz2yyn3g=; b=RCp3x930YXgPTyR8HIusi6ZryFqRx2PyXAG/Y4y/JQdoYaLRK/0pVFlU7Kb6ZM9vTW PKy8KMG4B3DEdwrnHp5d3jANIoKhbQjOJ89hc9qCX/MaiC1zPV7wuPNSYCAOOhjtoRP0 +sjOtr/DrMBylChd74kzf95jgRuakwxSh+2WRHdFgqCHpzxHCu4vUsW+x4S6aGFaKdT3 7bzFe0Znf9ylh7MibLZwBS2ckzU8wEpal77jNCI0i/Zd6WM3c2J7vwZjBuEfuJwYRrw0 LCClwblNFIPct1XyJtKINyk3wPG5x2L53z4QhwNDMQW3SGi+YQu1/Qw1QxUFETqoaMEZ 2sZg== X-Forwarded-Encrypted: i=1; AKwUvBwfAAMWQX3Fw7GWRxsKQtquc2tpmhnKekLd5lUG+bnKoiGlNPr8AuKHQU69iaAi8LVqQnp0pHlq1LrGcAs=@vger.kernel.org X-Gm-Message-State: AFuF++mqrxHbfnclwDiNhIapz2Z5KOoH/mG+LBE1TBjLgZokzwYxmJCP ZeAR/21u1XpFCbaR54DMTCG8E95wyjhxk159MSsa7YHrN4T+cjdR38nQ X-Gm-Gg: AYBFou1kBmYXSbARI+DlyqAlCbGc2dORbYxFBMX9YDibGiqFjinyfBUr+efowdwpHvf jbL6Ob2P5llP9QgdpsD7b4YGprK5JVEIz+pttXEzWiWawcCS29mSbVaRzFpdMdXZl/gn06tRQn9 Cd6HlE+EYIhl9efydeuBFJ8RWtp7812c3cRlJUZ9ZXGm50+s7MNndN9C1nfzjpluVbMTNJOXZEW T/DQm/8+xnotlSAhAp8rFJVLkeFhoTJLM1+VDI3fV31vQPi5WT7nf9GSCM+ckgLL5TaaCZnK1ZY IqBR2Vlohd5kQzkeKiGSSwZDYUd6vFE7PDtC+H98nYvcpe8fkQyzD6hQh+0CJcfSZLaPHbP6hjN sKeCzowaquEhSpDAaiH97ghU2NCeFi4dn04Sb+fZ0004fQau2W98xwKdjJYQRd5AF6sf2Lje14V jExOiARH4xB13b2sELFHGhzMXHwqZk47bjtFJzzjVZK9pa7V9+9AG+TG05LsaIGO1KhI4cCkGeh p+MAaR2QmQ79o0GDFixC3byDswrtR1soxGf8IxL X-Received: by 2002:a05:6512:3a8e:b0:5b2:a967:c0bf with SMTP id 2adb3069b0e04-5b8c17f5f54mr4811816e87.10.1790087325948; Tue, 22 Sep 2026 07:28:45 -0700 (PDT) Received: from fedora-tap.advaoptical.com ([82.166.23.19]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-5b8d46d2064sm589691e87.24.2026.09.22.07.28.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Sep 2026 07:28:45 -0700 (PDT) From: Sagi Maimon To: Richard Cochran , Vadim Fedorenko , Jakub Kicinski , "David S. Miller" , Eric Dumazet , Paolo Abeni , Andrew Lunn , Simon Horman , Jiri Pirko , Arkadiusz Kubalewski , Jonathan Corbet , Randy Dunlap , Shuah Khan , netdev@vger.kernel.org Cc: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, Sagi Maimon Subject: [PATCH net-next 5/9] ptp: ocp: correct the CPLD bookkeeping comments and the flash progress Date: Tue, 22 Sep 2026 17:28:25 +0300 Message-ID: <20260922142829.57740-6-maimon.sagi@gmail.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20260922142829.57740-1-maimon.sagi@gmail.com> References: <20260922142829.57740-1-maimon.sagi@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The struct ptp_ocp member comments overstate the locking. cpld_i2c_adap_nr was documented as "Under cpld_adap_lock" and cpld_id_tried as "under cpld_lock", but every reader takes neither: the design is that the writers are serialised while readers may see a stale value and re-validate it - adva_x1_bus_claim() re-checks the adapter's parent, and a stale cpld_id_tried only costs one extra attempt. Describe that instead. Pair the stores of cpld_id_tried with those unlocked readers using WRITE_ONCE() rather than plain stores. The flash progress notification reported the offset of the page that had just been written rather than the number of bytes written, so it was one page behind and never reached fw->size from inside the loop. No functional change beyond the reported progress value. Fixes: 3b815e29966f ("ptp: ocp: add TAP CPLD access for ADVA TimeCard X1") Fixes: a4b7c15aa78f ("ptp: ocp: add TAP CPLD flashing via devlink") Signed-off-by: Sagi Maimon --- drivers/ptp/ptp_ocp.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/drivers/ptp/ptp_ocp.c b/drivers/ptp/ptp_ocp.c index 45313143b6f7..e10f6b5149c9 100644 --- a/drivers/ptp/ptp_ocp.c +++ b/drivers/ptp/ptp_ocp.c @@ -428,9 +428,12 @@ struct ptp_ocp { /* adva_x1 CPLD I2C (internal use only) */ /* serialises CPLD operations */ struct mutex cpld_lock; - /* guards cpld_i2c_adap_nr against the bus notifier */ + /* serialises the cpld_i2c_adap_nr writers against each other */ spinlock_t cpld_adap_lock; - /* I2C adapter nr; -1 if absent. Under cpld_adap_lock */ + /* I2C adapter nr, -1 if absent. Writers hold cpld_adap_lock; + * readers take no lock and re-validate what they got, since the + * number can be recycled - see adva_x1_bus_claim(). + */ int cpld_i2c_adap_nr; /* claimed adapter; valid under cpld_lock */ struct i2c_adapter *cpld_adap; @@ -442,9 +445,12 @@ struct ptp_ocp { u32 cpld_usercode; /* cpld_usercode has been read since the last flash */ bool cpld_usercode_ok; - /* one-shot ID read finished, successfully or not; under cpld_lock */ + /* one-shot ID read finished, successfully or not. Written under + * cpld_lock; the worker reads it unlocked, where a stale value only + * costs one extra attempt. + */ bool cpld_id_tried; - /* failed ID read attempts so far; under cpld_lock */ + /* failed ID read attempts so far; cpld_lock */ unsigned int cpld_id_attempts; /* x1 TAP CPLD present */ bool has_cpld; @@ -4616,7 +4622,7 @@ static void adva_x1_cache_i2c_adap(struct ptp_ocp *bp) * the rest of the binding. */ scoped_guard(mutex, &bp->cpld_lock) { - bp->cpld_id_tried =3D false; + WRITE_ONCE(bp->cpld_id_tried, false); bp->cpld_id_attempts =3D 0; } =20 @@ -4900,7 +4906,7 @@ static int adva_x1_cpld_read_id(struct ptp_ocp *bp) * worker that had already finished reading. */ if (!ret || ++bp->cpld_id_attempts >=3D CPLD_ID_MAX_ATTEMPTS) - bp->cpld_id_tried =3D true; + WRITE_ONCE(bp->cpld_id_tried, true); mutex_unlock(&bp->cpld_lock); if (ret) dev_dbg(&bp->pdev->dev, @@ -5047,7 +5053,7 @@ static int adva_x1_cpld_flash(struct ptp_ocp *bp, str= uct devlink *devlink, */ WRITE_ONCE(bp->cpld_id, 0); WRITE_ONCE(bp->cpld_usercode_ok, false); - bp->cpld_id_tried =3D false; + WRITE_ONCE(bp->cpld_id_tried, false); bp->cpld_id_attempts =3D 0; =20 err =3D adva_x1_cpld_write(bp, CPLD_CMD_RESET_ADDR); @@ -5056,6 +5062,7 @@ static int adva_x1_cpld_flash(struct ptp_ocp *bp, str= uct devlink *devlink, =20 for (offset =3D 0; offset < fw->size; offset +=3D CPLD_PAGE_SIZE) { u8 args[3 + CPLD_PAGE_SIZE] =3D { 0x00, 0x00, 0x01 }; + size_t done; =20 /* The loop holds cpld_lock and the i2c root lock for the * whole image, so give a dying task a way out. The part is @@ -5075,11 +5082,12 @@ static int adva_x1_cpld_flash(struct ptp_ocp *bp, s= truct devlink *devlink, if (err) goto exit_config; =20 + done =3D offset + CPLD_PAGE_SIZE; if (!(offset % (CPLD_PAGE_SIZE * 64))) devlink_flash_update_status_notify(devlink, "Programming", ADVA_CPLD_COMPONENT, - offset, fw->size); + done, fw->size); } devlink_flash_update_status_notify(devlink, "Programming", ADVA_CPLD_COMPONENT, --=20 2.47.0 From nobody Thu Sep 24 15:10:01 2026 Received: from mail-lf2-f12.google.com (mail-lf2-f12.google.com [74.125.229.204]) (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 2C51B559C8B for ; Tue, 22 Sep 2026 14:28:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.229.204 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790087333; cv=none; b=JLg7++e6/fK1PQ+VqYVN4IwSnJVowHGt5P2Bt2ISk+RTAZZcfVukZ3H99OW+3fCd+ogIsoQSLLEMTk0bi6AZA0b821p04SzxEcKYWabpZDYIP0eUSyGZxUD6s9ltK/6ew51Kn/Hr8JG6ob7/wJIvbgOjbOHpIYy3rsn08YJyc+I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790087333; c=relaxed/simple; bh=vmXda7q3sDpJEX8AFmmpa4DPRcImaRBMRm6OQHAWGGE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=NXy2upTkd9ehlzXRbTfNjgM0yDQfLDInOmFtW39j0ShVz0zsCvM2Vj1+Ixp8To+4niPsZC1Vq8rockBufumbM8rKNmNQ4oQhdy0p2YKsrEoyIWchyWBZBQcYt/97M84fId1nzU7RB/LYtV0Ctmv5yaMa7Z5o8vo6QxwhLtjf9Lw= 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=VijQ3XL8; arc=none smtp.client-ip=74.125.229.204 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="VijQ3XL8" Received: by mail-lf2-f12.google.com with SMTP id 2adb3069b0e04-5b5e4f16c81so3625984e87.2 for ; Tue, 22 Sep 2026 07:28:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1790087330; x=1790692130; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=tCnqW3uWQK4vADqWc0y/sNw0Dm5EpPQnotxldEeM2YU=; b=VijQ3XL8mcNzlFTQCPeDqWlpAWFBrdyBLIiesM/qzOa/uiameADm5DzLR49ACYIN27 w3ysbVpjEBSUX8ZXwH3ccjFzObRtXLANTGHvVwJ4kDPGAX5+Xy3tyJ++uJ6k97PptoSW tEIAkUrg657+mfUuSxRFNAqvbOLRkw2TwOvuhBCIufALBg9LJHLdCKv8+EXY5UBQljtb RIKrj+KdfVVhmx2q1bxH0Y6sz6xF+6TvkOZNkJDhaTeKv2JITQpHkXseSYEjTa//06wh 0tODbO1HYl7B4zXwtEipB/SLDni+3RcfDrGIzYO7jozKH3kvnHtfcp1yxKWxHlHWLJ6y RikA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1790087330; x=1790692130; h=content-transfer-encoding:mime-version:references:in-reply-to :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=tCnqW3uWQK4vADqWc0y/sNw0Dm5EpPQnotxldEeM2YU=; b=RasmVJGeZRBgLFGXuNdc55L9+CSt2Gj5vEBX6vfK+dHytXfHgoC2aSL6iMCbN1znEU j657TtdFMVj2FwTjaLSdYf1nE4FLqDRiLT9BTeeANhkICa/5aOfUKouw9yXudHDq9ub+ 3tBk1upxWkzllQPhwVRE0FIqnYO93fNPOyCUjV6RNJ07UdkmUMA4xB3GxEBdSJhjva/1 736vFkS8u0LkL8Mg6JYJX7uFGLgxcD6fVHHSrxqAlN8SVKT6zF0hpMFoHUZAe2zbMntf V67byQKWPRE+VMM42eHxoCJmYJJvUuExKDv+egCui91gRr0urUWN274U9Ow5/W8YG4AA rXWA== X-Forwarded-Encrypted: i=1; AKwUvBz6WNQqMf+CzRb7khRnhgQlaHxPayFZUvJYRlwgHe/EKXAKrMlnoRksbAFo0Hs2r9Mguk/prIwtBVP+Cvk=@vger.kernel.org X-Gm-Message-State: AFuF++lOY+AWgJits8OwcrhiQGlAVjkMqSlPD81rM4DR/pgpyhxUr8EH F2oQcqAiuWi2eg/Rb0YH8kMHsR6/OsxxHRdaZ+98jLayFAL1nWOJ0eWr X-Gm-Gg: AYBFou1CSGTJLiZzspYEQhjaXeUUYPMaWypd0yB1+GfAKZ3/PX6g9w4DgcP3EvItvA2 9UgxF/zWPwnGuRBJGMHzAK9JbypOur0B4WIYwkWpPadkKRDed7+9Bz5uNiUx3LuYamGwsYRq1+P 02AZZaL+yVVVrhbIhxNgM7AxGNdwcHHdk/dQz4AhBtLryd9bO2YbwLsI026a0QJ2Z/NhpiG5857 fEtj4uuac4FiZEdIrS0bxdngFF94/EP9Pj7CjRl1zUqVJhSjwmjSrasdX7yL3h+ArAR20/l90SE FCdjsjdAKR/z0n7ZG43BYYaVECu9QpZ851yg30iV8qYhrHkzR1w6w6rx9Z5qtBILdfczc8SQsGq vrAAtXvjz2piu3ofwmzWbwJ2AzHXntCfx8mrkH3e51rRqmpmj6xjx5CmR8LwGELnEGySf0vroKH uDMrv5T1M3+aQeUzCrUBNxo51MzgNXSvIJr4hlQWJqxsvVHSXXNlntXdFucFlsw9tjYVkxR0c51 YHNCe6pr5KZzvn6zz0l6nkQuaK+Wg9p6jtvmcZd X-Received: by 2002:a05:6512:3b2a:b0:5b6:1a81:1c8d with SMTP id 2adb3069b0e04-5b8c197976cmr4302647e87.66.1790087328717; Tue, 22 Sep 2026 07:28:48 -0700 (PDT) Received: from fedora-tap.advaoptical.com ([82.166.23.19]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-5b8d46d2064sm589691e87.24.2026.09.22.07.28.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Sep 2026 07:28:48 -0700 (PDT) From: Sagi Maimon To: Richard Cochran , Vadim Fedorenko , Jakub Kicinski , "David S. Miller" , Eric Dumazet , Paolo Abeni , Andrew Lunn , Simon Horman , Jiri Pirko , Arkadiusz Kubalewski , Jonathan Corbet , Randy Dunlap , Shuah Khan , netdev@vger.kernel.org Cc: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, Sagi Maimon , netdev-bot+sashiko@kernel.org Subject: [PATCH net-next 6/9] ptp: ocp: report fw.cpld with an empty value until the USERCODE is read Date: Tue, 22 Sep 2026 17:28:26 +0300 Message-ID: <20260922142829.57740-7-maimon.sagi@gmail.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20260922142829.57740-1-maimon.sagi@gmail.com> References: <20260922142829.57740-1-maimon.sagi@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The fw.cpld running version was published as the literal string "unknown" before the USERCODE had been read, which contradicts both the changelog and the .rst entry describing it as the USERCODE formatted as 0x%08x, and is not a version anyone can use. The string was there because naming the component is what lets "devlink dev flash ... component fw.cpld" through, and a part left holding a bad image answers neither READ_ID nor READ_USERCODE - gating the component on the read would make exactly that state unrecoverable. An empty value gives both: devlink_info_version_put() invokes its version_cb, which is what devlink_flash_component_get() collects names with, before returning early on an empty value, so the component stays flashable while no version attribute is emitted. Suggested-by: netdev-bot+sashiko@kernel.org Fixes: a4b7c15aa78f ("ptp: ocp: add TAP CPLD flashing via devlink") Signed-off-by: Sagi Maimon --- drivers/ptp/ptp_ocp.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/ptp/ptp_ocp.c b/drivers/ptp/ptp_ocp.c index e10f6b5149c9..4ce86df6e196 100644 --- a/drivers/ptp/ptp_ocp.c +++ b/drivers/ptp/ptp_ocp.c @@ -2264,15 +2264,20 @@ ptp_ocp_devlink_info_get(struct devlink *devlink, s= truct devlink_info_req *req, /* The flashable component. Naming it here is what lets * "devlink dev flash ... component fw.cpld" through, as the * core matches the name against the versions reported here, - * so it is reported for every board that has the part and not + * so it is named for every board that has the part and not * only once its USERCODE has been read: a part left holding a * bad image answers neither, and gating the component on the * read would make that state unrecoverable. + * + * An empty value still registers the name with the core - + * devlink_info_version_put() runs its version_cb before the + * empty-value early-out - while emitting no version attribute, + * so nothing is published until the USERCODE has been read. */ if (smp_load_acquire(&bp->cpld_usercode_ok)) sprintf(buf, "0x%08x", READ_ONCE(bp->cpld_usercode)); else - strscpy(buf, "unknown", sizeof(buf)); + buf[0] =3D '\0'; err =3D devlink_info_version_running_put_ext(req, "fw.cpld", buf, ver_type); if (err) --=20 2.47.0 From nobody Thu Sep 24 15:10:01 2026 Received: from mail-lf2-f13.google.com (mail-lf2-f13.google.com [74.125.229.205]) (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 673D6559C9A for ; Tue, 22 Sep 2026 14:28:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.229.205 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790087336; cv=none; b=cegoO2j4/eCnfWBpAYvN6Vr9DQAdYDCE9CAdL+K3pOqJ5nKRl60Gjfai5VzDTb0grUuy556nI2Hew/j3l9AKmAmGikkTG5/mOkZaHmjFEaBGGdtus9jtJkiIb0eGskUq3eKyW0LDK2Dq0n9SqhRIsK6AdhYNaZwibBCtxLv0qaY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790087336; c=relaxed/simple; bh=tJr42xaDAVSaWnaqwzCH0FtQxeXXRL2IL2eoB7zaOd4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=LstxUj48DX4nCT3SapL6Xl9GU3Uncf/B6IA7aAYd0Vyx+fsEU2AccIER9PO3KlFFcf+g8XApIYQ/+GNHGi5GYZ/RSmZgHuaoecPP/V97xD/V1SwPkJRIKamdsfihx/ChYfeVkfPo5XH5XLH812+Pww/fJJ2xqCqxGjcqPfJGrZk= 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=QeT9iphd; arc=none smtp.client-ip=74.125.229.205 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="QeT9iphd" Received: by mail-lf2-f13.google.com with SMTP id 2adb3069b0e04-5b899413537so6351005e87.1 for ; Tue, 22 Sep 2026 07:28:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1790087331; x=1790692131; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=2Qq4F7XD5vHunZiMcFmCR76nTufbFhGNTmnh/jlQeSI=; b=QeT9iphdsGBTEjSRj6o38WonfURX+A85mBtAUf0ecaPDLPD3ZRw0mVrn/2VpCs6sRY Ag0h12weq+0t0lPb2ltP0z1xLum4L5pzK5lQhY+CnF1PS3z5yvU7gbxD46FU4hyj3D9a NP509ife4ghbv0J9BsMl6ar0v7U0TCGg8guzPXHgcau46DHeigIIEcUrbZJEDuoofQYD NIUgvy1qbrO862avQWH+a0flHl7lSd7TBjv7sk5DVEGyxOfJjrSCXjPE+X/sgaRUFCed pU7gjy9ykOlRoduhTXBFHaqFPiOm6HUCFPv6/4XArDzJ7j+Y3U2S0eebuDo/I/RPlcWc xodg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1790087331; x=1790692131; h=content-transfer-encoding:mime-version:references:in-reply-to :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=2Qq4F7XD5vHunZiMcFmCR76nTufbFhGNTmnh/jlQeSI=; b=gPuaK57o0ueg4S6TsQGPYcZ/TJPY4FjWdZBSnixkCDSHNy3Mw3V6IGHPuZTzmzobFT Ydwruu9WIMLy8oVeTI6wcNzchXVTup1FCOyQUK08p6jOGAUqPdONvHEXbNAusdlaKOqU p5sEMARfaXYvIda+CQtHanE/RfO8ybjrJeeI9QE+khpDGsGhrYZokwFEKPCEX2XVQbCk 9/QqmJwxElT3YIQWuasSXI8UARypmj/g3m40HeTG5pdBafPxHET1PlnlSbrQIaV97a+Z VvjlbetEG4EJPIqEQrs5zkciS+bb8hTtwhdS6Htvt/W446y1tpbPXfi5d/TffERPLMcB o/2w== X-Forwarded-Encrypted: i=1; AKwUvBzDfJ5n+NOm79tqx5w3tyRUZ0STmEyCESAEvOmxSlMMWeIN5qSFS3n0SI08AtgjUpN9f72uB5XeiWC1RDQ=@vger.kernel.org X-Gm-Message-State: AFuF++kG14TPBVBOzSK7PETEC5E5kmzfSFyK8NA6vsO54fDIdicAIxkx YjxnkKQ2j5y3YoQpcsl7EL51nTOr29ombNY3m/bquVmDavXQnOxYRT/c X-Gm-Gg: AYBFou0xm1EwwrB9FyTE2mkqYi2cB1K9YV/OV/kDtRhR9V20vnwZgjE89HB7BdlhoeL h0A9PFjcY5BZi3XVRvEbSYsIpbCnET7yR7I4ITddka69ullgxihm08prjkUSVK5GBiss12n5Uk3 qttELmxkRKY7i4x1Iaf25Uhv+IWYTQttraqHo+HhJz4DfjcXhy3WdtpZNUTmSWE9NLYRMJvO0Dp eCJCFQE7YQCyAQdLSUtvVOWzjojicU1LFu3oLXS3dtCYey1RKAK77CMURoQ8jSPlaE1Sqb/Vl1G kuWKi2+EWHNeFjr+yCyqotlKoDiPKNx6UCbe7+e0SxKTPG28RfFukJCIWgvIOhptdA/djcbN11w 09XCnerrIqJfV9UIse8GVP3CW47h2G6rPAnQwwQtNDYsHM9q/r7kPX8O5ZTRlyI4D8aDNuwtzfP AOPZ/IiDqQaxdoYIuEIfxrHUwDa3F8V1uqk2rabyHU8lZQvUwCZ0TE61G+Umng0fRSwi9lA3Wtp JqKXXyzl6guQnfPaCfb4qEgoRn93BciGp0OwNvfAQ== X-Received: by 2002:a05:6512:b89:b0:5b4:a836:13fd with SMTP id 2adb3069b0e04-5b8c180b471mr4899616e87.22.1790087331133; Tue, 22 Sep 2026 07:28:51 -0700 (PDT) Received: from fedora-tap.advaoptical.com ([82.166.23.19]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-5b8d46d2064sm589691e87.24.2026.09.22.07.28.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Sep 2026 07:28:50 -0700 (PDT) From: Sagi Maimon To: Richard Cochran , Vadim Fedorenko , Jakub Kicinski , "David S. Miller" , Eric Dumazet , Paolo Abeni , Andrew Lunn , Simon Horman , Jiri Pirko , Arkadiusz Kubalewski , Jonathan Corbet , Randy Dunlap , Shuah Khan , netdev@vger.kernel.org Cc: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, Sagi Maimon Subject: [PATCH net-next 7/9] ptp: ocp: drop only the USERCODE when flashing, and drop it before erasing Date: Tue, 22 Sep 2026 17:28:27 +0300 Message-ID: <20260922142829.57740-8-maimon.sagi@gmail.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20260922142829.57740-1-maimon.sagi@gmail.com> References: <20260922142829.57740-1-maimon.sagi@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Two problems with where adva_x1_cpld_flash() invalidated the cached CPLD identity. It ran after the erase *wait* returned, so an ACKed ERASE whose wait then failed skipped it: the erase is running in the part at that point, but cpld.id and the fw.cpld USERCODE kept describing the image that is being destroyed, and cpld_id_tried stayed set so nothing re-read them for the rest of the binding. Do it before the ERASE is issued instead. It also cleared cpld_id, which is the Lattice IDCODE - a property of the silicon that erasing the configuration flash cannot change. Dropping it on a failed update only hid information that was still correct, and made recovery depend on a re-read that may not succeed. Leave it alone. The documentation said the identification is read "again after a successful CPLD update", which was never what the code did; describe what is actually dropped and restored. While there, note the size check and the state the part is left in when an update fails part-way. Fixes: a4b7c15aa78f ("ptp: ocp: add TAP CPLD flashing via devlink") Signed-off-by: Sagi Maimon --- Documentation/ABI/testing/sysfs-timecard | 8 +++--- Documentation/networking/devlink/ptp_ocp.rst | 28 +++++++++++++------- drivers/ptp/ptp_ocp.c | 25 ++++++++++------- 3 files changed, 37 insertions(+), 24 deletions(-) diff --git a/Documentation/ABI/testing/sysfs-timecard b/Documentation/ABI/t= esting/sysfs-timecard index 4ba45c6ee4a3..569ab668a225 100644 --- a/Documentation/ABI/testing/sysfs-timecard +++ b/Documentation/ABI/testing/sysfs-timecard @@ -31,10 +31,10 @@ Description: (RO, root only) The flags set in the statu= s register of the =20 A read arbitrates for the shared I2C bus and reprograms the on-card mux, so it is restricted to root. The Lattice device - ID of the CPLD is read by the driver shortly after probe, - and again after a successful CPLD update, and reported from - that cached value as the fixed "cpld.id" version by - devlink dev info. + ID of the CPLD is read by the driver shortly after probe and + reported from that cached value as the fixed "cpld.id" + version by devlink dev info. It identifies the silicon, so a + CPLD update does not change it. =20 New CPLD firmware is programmed with devlink dev flash, selecting the "fw.cpld" component; see diff --git a/Documentation/networking/devlink/ptp_ocp.rst b/Documentation/n= etworking/devlink/ptp_ocp.rst index f94b759d9cd6..249ca63eebf6 100644 --- a/Documentation/networking/devlink/ptp_ocp.rst +++ b/Documentation/networking/devlink/ptp_ocp.rst @@ -32,14 +32,17 @@ The ``ptp_ocp`` driver reports the following versions carrying that CPLD. Reading it claims the shared I2C bus and reprograms the on-card mux, so the driver does that from its own worker and reports the cached value here; the version is omitted - until that read has succeeded. The read is made once per binding - and again after a successful CPLD update. + until that read has succeeded. The IDCODE identifies the silicon, + so it is not affected by a CPLD update. * - ``fw.cpld`` - running - USERCODE of the image programmed into the TAP CPLD, formatted as ``0x%08x``. Read together with ``cpld.id`` and reported the same - way. This is the component name to pass to ``devlink dev flash`` - to update the CPLD. + way; it is dropped when an update erases the part and reported + again once the new image has been read back. This is the + component name to pass to ``devlink dev flash`` to update the + CPLD, and the name is reported even while the value is not, so a + part left holding a bad image can still be reflashed. =20 Flash update =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D @@ -59,12 +62,17 @@ selected with the component name. - The configuration flash of the TAP CPLD on ADVA TimeCard X1 boards, programmed over I2C with the MachXO3 in-system programming commands and activated with a REFRESH, so the new image runs immediately. - The image is the raw configuration bitstream. The only check the - driver makes is that its length is a non-zero multiple of the - 16-byte page size, so a container such as ``.jed`` has to be - converted first rather than passed through - one whose length - happens to be a multiple of 16 would be programmed as if it were - a bitstream. + The image is the raw configuration bitstream. The driver checks + only that its length is a non-zero multiple of the 16-byte page + size and that it is not larger than the part takes, so a container + such as ``.jed`` has to be converted first rather than passed + through - one whose length happens to be a multiple of 16 would be + programmed as if it were a bitstream. + + The erase clears the configuration flash before the first page is + written, so any failure from that point on - including an abort on + a fatal signal - leaves the CPLD unconfigured until a valid image + is written. The component stays available for that. =20 Programming the CPLD claims the shared I2C bus for the whole cycle, so reads of the card's EEPROM block until it completes. Progress is reported diff --git a/drivers/ptp/ptp_ocp.c b/drivers/ptp/ptp_ocp.c index 4ce86df6e196..0d6d0c02882c 100644 --- a/drivers/ptp/ptp_ocp.c +++ b/drivers/ptp/ptp_ocp.c @@ -5043,6 +5043,21 @@ static int adva_x1_cpld_flash(struct ptp_ocp *bp, st= ruct devlink *devlink, goto exit_config; } =20 + /* Once the erase is issued the image is gone whatever happens next - + * an ACKed ERASE runs in the part even if the wait for it fails - so + * stop reporting the USERCODE before sending it rather than after + * the whole sequence has succeeded. + * + * cpld.id is left alone: it is the Lattice IDCODE, a property of the + * silicon that erasing the configuration flash cannot change, so + * dropping it on a failed update only hid information that was still + * correct. Written under cpld_lock, which adva_x1_cpld_read_id() + * also holds across its own bookkeeping. + */ + WRITE_ONCE(bp->cpld_usercode_ok, false); + WRITE_ONCE(bp->cpld_id_tried, false); + bp->cpld_id_attempts =3D 0; + devlink_flash_update_status_notify(devlink, "Erasing", ADVA_CPLD_COMPONENT, 0, 0); err =3D adva_x1_cpld_write(bp, CPLD_CMD_ERASE); @@ -5051,16 +5066,6 @@ static int adva_x1_cpld_flash(struct ptp_ocp *bp, st= ruct devlink *devlink, if (err) goto exit_config; =20 - /* The old image is gone from here on, so stop reporting its - * identity even if the rest of the sequence fails. Written under - * cpld_lock, which adva_x1_cpld_read_id() also holds across its own - * bookkeeping, so the worker cannot resurrect any of it. - */ - WRITE_ONCE(bp->cpld_id, 0); - WRITE_ONCE(bp->cpld_usercode_ok, false); - WRITE_ONCE(bp->cpld_id_tried, false); - bp->cpld_id_attempts =3D 0; - err =3D adva_x1_cpld_write(bp, CPLD_CMD_RESET_ADDR); if (err) goto exit_config; --=20 2.47.0 From nobody Thu Sep 24 15:10:01 2026 Received: from mail-lf1-f51.google.com (mail-lf1-f51.google.com [209.85.167.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 C782A55C1B9 for ; Tue, 22 Sep 2026 14:28:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790087337; cv=none; b=lFNsXkh6HlLFTl4zNREbs/cjqgvGEvG2PWGo2jn+peYkMQyKoTZmdOH0bMFDR690zTtb4RFVKQz9QDBiaMALsrejHFTcxloHcxUWeAxNY2GFL8Pg9h577pXNeN8b1WaTkD4Q7oEqdqOehYfSeTNEOWw29X/3aA8NNI0XrHx4usA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790087337; c=relaxed/simple; bh=LjFWXtBxX8T94YoQ6LqwowvWE59E53HE3eg72IgpkjE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=WDmlX3BQoHKk2gtIFrf1Aosy1rw3lLfNVzCGlTiWwdB9BzpBGEFSV1aC3noQa045JsrokdJhpsc4mjvSZsC23J5N2xyx823Pj9YkLWuibDa9OIH5EQznotNh3d+9SS5zkddFcU4R1g27KVM8v34X9KaHDoqDJqwkfM0YLX+u/Ho= 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=YsTNHPDq; arc=none smtp.client-ip=209.85.167.51 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="YsTNHPDq" Received: by mail-lf1-f51.google.com with SMTP id 2adb3069b0e04-5b8b3c8c4bbso655199e87.0 for ; Tue, 22 Sep 2026 07:28:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1790087334; x=1790692134; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=ElzIfLW9vsgs9qj3Q3n1oLfTLliMNpKpVYJ0kUF5UpQ=; b=YsTNHPDqoCOie/hcailZHkczEXqKkCCPBmdDCFHxP1J9Xj+y77g6qfYb1AMxuvoM8l ozMeihLSbDRnU2779bgyG21CkCzYU1GDWefo8al69vTQI5n0SQGlgGYFIsUlXSO7wVV/ UFZtq7hrLq6bjNYKEUzrG8qYcA5MHJ+lx9PfkYWexNbnk4LIuRQmB5dWu241lpZZDCA8 8thUOkuqsq7GjDIQudK8brofRUZ6uA6tS23Se6nyi8K+I767XyKXoEeJ9o1wUU6GObVC F2OcMUAoplR9UfaQKQnTqkfpiWR6A9YdIQOIotyLoqf7pzo/igOsBVxMBHrxejDHFV0V bLQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1790087334; x=1790692134; h=content-transfer-encoding:mime-version:references:in-reply-to :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=ElzIfLW9vsgs9qj3Q3n1oLfTLliMNpKpVYJ0kUF5UpQ=; b=Wt9tkV78Hg0F8hvrOgrBx1j8SrCJV7lQCoSFr0IelhZ7BU6OEziv+XnOCuEb3YyA0S OEtXWX2C+cFWFnYn0B0SL9Eqe2A+tBPgsDFbNLmD2Ph6sFsVUQF1kOsWCGJRSr2Y2iQb UZcqkOVwCW7CHsLdhqfX2IxvJHqOT6FtVXMcSxv2MNzNZl7ChUISmq9Guo3aL67bmGhP 9Tae9zIDRTcMMtiUl24OFslYKcc40JKqwxNlFLODjRFmAe53FWG7xVwH7dumIegyo4Qt rYvUw7+D5iBfoTlacXlYEaGzEPY1EDW/ZQtoZ39TBxpspdkj2KrQsNl+uZaGerJIMR3y DS1A== X-Forwarded-Encrypted: i=1; AKwUvBzRvUTD/9M9fnnADXuBT3qzN/9eCJ0EosYIywOTnWfh+N/EPt0zL1NObmpzd+ggxiMOjjUpp2ZrMuBSwi0=@vger.kernel.org X-Gm-Message-State: AFuF++kzGyUynl52dQO+84QlD9vz3nqLcNDYFi9bSQOzBcFCrhIQgkhr 7gTy2X5AjOLlBSo8WFsXytvQnhF1g+dZxPjsyTrOwLC5vWHeLomMdH1E X-Gm-Gg: AYBFou2Ef/Shgist9xtXGYBrDw8TGs3egfBRPtZa2FzGUinOaYA9uL0tu7o9YtK3g9K n1c1Fc9+gLmhHGSe91vo2vP6rszyIIzXqFpP2eTMdEe7zyWgBkqmbnj3JYBXmlUntlCf0sFwgQ4 cc+dfdP08FE+lSeCtDjmhKKHvSg3OTRXPDyEJVC8a5Vzr+tuF6AVQoN//Stxk6JYrUy0EKdyOQ0 mmS6MkB8OdtCxXopcNeHvCrMkMZhFHTF+6kilIHaHzgTOZlkuswaSrvsQcII93UBoiV3Kp1u1tp 5OAM4KAm7qjfls8cOR8KOo2g7V0wBCYMFt+Njhxdg2M6JFXDl6vHAxfdMMpAhUTXdoZxlMLFlJ5 hwrE7uVmf02ZMw/ElKde6daAiZ/TUDpPZTtsN88Q6nfTYrI3U2Db1CylASpqes8X4pMbxLGVXl6 KOEVolTInYjYxp3DizQ13tDQRnT6U+SP+K8AjLHo9Ienk2GLIt0oZC5RonRKoojOkVavKE270TV MdSGzDNUnqhmlS38SReo+xH0dOd9IMw8gsdG0xk X-Received: by 2002:a05:6512:1242:b0:5b8:9a95:e251 with SMTP id 2adb3069b0e04-5b8d293525bmr961353e87.25.1790087333547; Tue, 22 Sep 2026 07:28:53 -0700 (PDT) Received: from fedora-tap.advaoptical.com ([82.166.23.19]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-5b8d46d2064sm589691e87.24.2026.09.22.07.28.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Sep 2026 07:28:53 -0700 (PDT) From: Sagi Maimon To: Richard Cochran , Vadim Fedorenko , Jakub Kicinski , "David S. Miller" , Eric Dumazet , Paolo Abeni , Andrew Lunn , Simon Horman , Jiri Pirko , Arkadiusz Kubalewski , Jonathan Corbet , Randy Dunlap , Shuah Khan , netdev@vger.kernel.org Cc: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, Sagi Maimon Subject: [PATCH net-next 8/9] ptp: ocp: tolerate a latched FAILED when entering configuration mode Date: Tue, 22 Sep 2026 17:28:28 +0300 Message-ID: <20260922142829.57740-9-maimon.sagi@gmail.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20260922142829.57740-1-maimon.sagi@gmail.com> References: <20260922142829.57740-1-maimon.sagi@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The first status wait after EN_CFG_TP used adva_x1_cpld_wait_ready(), which turns a set CPLD_STATUS_FAILED into -EIO. FAILED is latched across operations and nothing in the driver clears it - the failure path only sends DIS_CFG - so once a part had failed an operation, every later "devlink dev flash ... component fw.cpld" would return -EIO at the enable step, before reaching the ERASE and REFRESH that would put the part back into a defined state. That contradicts the recovery this driver relies on elsewhere: the page loop documents an aborted update as recoverable because fw.cpld stays advertised so the image can be written again. Use adva_x1_cpld_wait_idle(), which waits the operation out whatever its outcome, and let the CPLD_STATUS_ENAB check that follows decide whether the part actually entered configuration mode. machxo2_write_init() in drivers/fpga/machxo2-spi.c tests FAIL the same way, after the enable has completed rather than as a precondition for it. Fixes: a4b7c15aa78f ("ptp: ocp: add TAP CPLD flashing via devlink") Signed-off-by: Sagi Maimon --- drivers/ptp/ptp_ocp.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/ptp/ptp_ocp.c b/drivers/ptp/ptp_ocp.c index 0d6d0c02882c..4f2bf54a23c2 100644 --- a/drivers/ptp/ptp_ocp.c +++ b/drivers/ptp/ptp_ocp.c @@ -5018,9 +5018,16 @@ static int adva_x1_cpld_flash(struct ptp_ocp *bp, st= ruct devlink *devlink, */ bp->cpld_in_config_mode =3D true; =20 + /* wait_idle(), not wait_ready(): FAILED is latched across operations + * and nothing here clears it, so treating it as fatal at the enable + * step would make every later flash of a part that has failed once + * return -EIO before reaching the ERASE and REFRESH that put it back + * into a defined state. ENAB below is what says the enable worked; + * machxo2-spi.c likewise tests FAIL only after ISC_ENABLE completes. + */ err =3D adva_x1_cpld_write(bp, CPLD_CMD_EN_CFG_TP); if (!err) - err =3D adva_x1_cpld_wait_ready(bp, 5000); + err =3D adva_x1_cpld_wait_idle(bp, 5000); if (err) goto exit_config; =20 --=20 2.47.0 From nobody Thu Sep 24 15:10:01 2026 Received: from mail-lf2-f12.google.com (mail-lf2-f12.google.com [74.125.229.204]) (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 343E755C30A for ; Tue, 22 Sep 2026 14:28:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.229.204 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790087340; cv=none; b=S5YFRKh1OjDXGcvF6VOycVoaLH/bSBwxbEFwuWrZLcHt3rypFl80Xz7br2C5bix9G3/wHEM+ehXXZfr5CQ9h/njiu5thevuTBFFYcop1YtIfU1Ofi56dD9taXCuHhNec0pu/KytQ+jKe/wA94+IAU03V+6yDICvwUYO6TtdwV70= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790087340; c=relaxed/simple; bh=tp2C5wgYQL0+H/MstzejuqB0z6Y4qPGa9hNfxih8Myc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ZYIErWEfXmnTaV9squ2+WI9MwJi9Wejj83stgv6DYZ0GaEqnE7EOWQA6zsbKGC7UQzpPEbZciDUlbUZUfC7MPiZxUPEk46MjGatH9TbF0MAbvLsARC1jLrsLj3zqH1f7Afex8GT1HWguSBLVonDAEWjk/OidHdRlP3JDbtv5PLg= 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=nxX2jk/Q; arc=none smtp.client-ip=74.125.229.204 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="nxX2jk/Q" Received: by mail-lf2-f12.google.com with SMTP id 2adb3069b0e04-5b5e4f1801fso4229964e87.2 for ; Tue, 22 Sep 2026 07:28:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1790087336; x=1790692136; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=DWnL/kcGD9BgwQHJ1ulieSSx0+mb/wdvY4wv1lor7jg=; b=nxX2jk/Q3+RMc1UIK03+z7NwXbmC4TZgNllhKUt2tbFDttnI6YUM+lagN8P6p88sc9 KNAc8a5rx3cIjbBI5u1KNZKjYc+P9Syws6QBgrLj1v3z9rCO6oklhpAp8DyailwRn8MG ugAExIj2tsdmVIBlOJageTbX7TckfGG7Fs97kH1UQf1IRwRN7B2nZ5qiqR1fDCRGmjdi 5KIXs/d1UPcmZmxfc74lyqA5FKKCeYsLmNMkTu4TEk/1KL6shSEw2FrJKrBd4pRUDoAO EZDtZrm7/j7vs5HmgbOLl6BX+g/Hqi6U1ffcfSzGPQUwsNWandKRfPQiWQOgY9H4fs2K QS6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1790087336; x=1790692136; h=content-transfer-encoding:mime-version:references:in-reply-to :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=DWnL/kcGD9BgwQHJ1ulieSSx0+mb/wdvY4wv1lor7jg=; b=Z/oHesv7JAerRZV+lgBnT9QBtZ0KCo5Iw+rAmwNgueUsS+mxLifoJeO+PJq/wl5nY6 fTwHjSDt8lPA03/hjPa+boKXzJEcInsX8gfYqHnRVegDBvbYNPeag++2lYIF4stK7oDa qANDt60r5T1YJD8Jtc4CUsVU9th9Hd5A8Qpnactd5uGORs8KU2PDaP+vjyv0JeWd4GP8 JUV46WVNTUK/+BRnhmKoRCyGAOvE9UewFC8RUFG7VMhaej7f2K/J4lFaBEelFYpgTVqu FUGHAa6KqMj6m9yqwIhoWNxucjZ6lNENrI1QXiTA3Swj5wBQJ8XNRs5W/bGir8/lnjMY J3pA== X-Forwarded-Encrypted: i=1; AKwUvBw7gB3MW/YTTdgn+bSmrrckGtKML/63O871dGriX7bXgltNJxXrA9bJekNd8/YJvXPL/WmpG8hFNJzhJgs=@vger.kernel.org X-Gm-Message-State: AFuF++nhfeEpoM0upODQkCfhXiM/xW0t+1QqGr9U0tJr6YmjEOAtyZN+ eK/ksjXUEX5DI4S/V3rjLhh6zjeHF4baqxzBkwHvfroAIMj+p3o8wxF0 X-Gm-Gg: AYBFou1x9K9e/kiru1JW8h88opRg9oCLPp1VLHS6Jio9FBgoLj7eZXqWTL6EXla1ke7 JgeuqRHtywnZEip9Grm9P+y+R9OsCLua0o2svj/GFW8zlLZ2XIYRWPhfS92wmkQwyYiBQysWmZA 6OlWWbdO//1ncGa/1QyMqVmrDo3oIo6iuskeLgPTu3gCiq6VWnlqk1ddLzLwUAewzFE23dmtnJP shMNx8ow3o4CCN2YqatG+aKi7wE8sptBfwdlcUu3fn2A9KYv8XX55ta+MsXpMUuEJ2fjUa5TchG RrOk1+i/aVaQv2KH2uXZJmmqWUh+aEk2afBDMbVNc8VarQHYYItgKgm1Jcakzyi+fhdZl9Zuvap f3Lt7kMpxJpJXf6ek/ek/ridZjBsHgc9u7CJ/NuLnsXayBC3vhFuSiQ5x3ew2d+KMlCCYaCkaJe Vh3BERuKjii6LBbePr1qqewGZzpKyLeXgUK+Fwdz6yjysHTUMTqzMEhJ9xy5S6rbvoSuB7e2xq1 CcK/pd5Wl0F6zhsBGhM0lY4OdA74Zw1aa+tPsDo X-Received: by 2002:a05:6512:3e25:b0:5b8:d078:da8e with SMTP id 2adb3069b0e04-5b8d078e2c7mr1792641e87.28.1790087335967; Tue, 22 Sep 2026 07:28:55 -0700 (PDT) Received: from fedora-tap.advaoptical.com ([82.166.23.19]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-5b8d46d2064sm589691e87.24.2026.09.22.07.28.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Sep 2026 07:28:55 -0700 (PDT) From: Sagi Maimon To: Richard Cochran , Vadim Fedorenko , Jakub Kicinski , "David S. Miller" , Eric Dumazet , Paolo Abeni , Andrew Lunn , Simon Horman , Jiri Pirko , Arkadiusz Kubalewski , Jonathan Corbet , Randy Dunlap , Shuah Khan , netdev@vger.kernel.org Cc: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, Sagi Maimon Subject: [PATCH net-next 9/9] ptp: ocp: confirm the CPLD really left configuration mode after REFRESH Date: Tue, 22 Sep 2026 17:28:29 +0300 Message-ID: <20260922142829.57740-10-maimon.sagi@gmail.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20260922142829.57740-1-maimon.sagi@gmail.com> References: <20260922142829.57740-1-maimon.sagi@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The post-REFRESH check required DONE set, BUSY clear and no error code. Those three conditions are already satisfied by the state SET_DONE leaves behind, so they cannot distinguish a REFRESH that rebooted the part from one whose frame was ACKed but never latched - and the I2C ACK alone was taken as proof, clearing cpld_in_config_mode. A part left that way stays in configuration mode running the old image while "devlink dev flash ... component fw.cpld" reports success, which is the opposite of what the documentation promises. Test CPLD_STATUS_ENAB as well: leaving configuration mode is the one thing only a REFRESH does, so it is what separates the two cases. Put cpld_in_config_mode back when ENAB is still set, so the exit path and the recovery at the start of the next flash can act on it instead of believing a mode change that never happened. Fixes: a4b7c15aa78f ("ptp: ocp: add TAP CPLD flashing via devlink") Signed-off-by: Sagi Maimon --- drivers/ptp/ptp_ocp.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/drivers/ptp/ptp_ocp.c b/drivers/ptp/ptp_ocp.c index 4f2bf54a23c2..9c2b7403bfd0 100644 --- a/drivers/ptp/ptp_ocp.c +++ b/drivers/ptp/ptp_ocp.c @@ -5135,6 +5135,9 @@ static int adva_x1_cpld_flash(struct ptp_ocp *bp, str= uct devlink *devlink, =20 /* REFRESH reboots the CPLD out of configuration mode, so the exit * path must not send DIS_CFG afterwards even if a check below fails. + * The ENAB test below confirms it really left; until then assume it + * did, because sending DIS_CFG to a part that has rebooted is what + * this flag exists to avoid. */ bp->cpld_in_config_mode =3D false; =20 @@ -5156,12 +5159,21 @@ static int adva_x1_cpld_flash(struct ptp_ocp *bp, s= truct devlink *devlink, /* Require DONE set, not busy and no error code, as machxo2-spi.c does * after a refresh: without it a CRC or preamble error reads back as a * successful update. + * + * ENAB has to be clear too. Those three conditions are already met + * by the state SET_DONE leaves behind, so on their own they cannot + * tell a REFRESH that rebooted the part from one whose frame was + * ACKed but never latched - which leaves the part in configuration + * mode still running the old image. Leaving configuration mode is + * the one thing only a REFRESH does. */ err =3D adva_x1_cpld_read_status(bp, &st); if (err) goto deselect; + if (st & CPLD_STATUS_ENAB) + bp->cpld_in_config_mode =3D true; if (!(st & CPLD_STATUS_DONE) || (st & CPLD_STATUS_BUSY) || - (st & CPLD_STATUS_ERR)) { + (st & CPLD_STATUS_ERR) || (st & CPLD_STATUS_ENAB)) { dev_err(&bp->pdev->dev, "CPLD refresh left status 0x%08x\n", st); NL_SET_ERR_MSG_MOD(extack, "CPLD did not come back configured"); --=20 2.47.0