From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796390151; b=GmMmFqMGgMEGK1E1ZySQPTGVs+G683e98WH88tN06YNERxJkeHgy4bZuHOy1CHewU4Uo nBveiMpI6K805LOGxnpIhA+kJqW9hhR+1OFrpp9uiKcszGO2G0dcXiAo0JT+rIqxJKhSi Ox0bsq0T2qMqrhggieuMcsJcaoApZX0I2/ewV3BoJKr3ebxSMKLyLPRJoHE/Be58ZPxiR LzYXcDjj+hBWuN1mD31aVEOb7ZSItmnjM0NjDA3y7vbFwa3DI+yGt9NmrrBvtdWpaLxOh 9wiFhwDtIv54hBxMskZs6HPQFSVhveKHIYB1Chs77rF+LGZGEew826K8C3jT3EkKsMg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796390151; h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID: In-Reply-To:References:X-sashiko-severity:Content-Type: Content-Transfer-Encoding:MIME-Version; bh=a1zkH0hUSIeVfLO5ipf0CZQntD8dPclQe083tizydo8=; b=wtaHQH5UBQK7m50yfKeTfvSsrtASmpV19XV0UuBEIbxR0+zibPlqu6MZBbTm1nvWFOcB nogWvtocMEbFCLE2oSRnIDtJN44LbGKYId+fB0zHHbPXftZoq+CfGgg0sz1UXYNScufum 7DWxeF/Amzts0UC/LO+JlNeZrQ5RT3vpfHuMQFALuKSd4W0CMJ0pMsp1zMdHnT8rEbP0D vXGcdWCFM3LHWZQlu7JmhaxvzoZZFZZxcs53DoSzrTNtKR+A5lOmMTSVQuaNyvkLfSjBf 1Kj/5FIeGc/8YpKll7+pEeF+nlRTZB4TmxzHL3nUqZ+NkAU1M/g08B9mmzDEnPKBKyA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Cawr1wtV; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8E539606A32F; Fri, 4 Dec 2026 13:15:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Cawr1wtV Received: by smtp.kernel.org (Postfix) with ESMTPSA id 45A071F000CE; Fri, 4 Dec 2026 13:15:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796390151; bh=a1zkH0hUSIeVfLO5ipf0CZQntD8dPclQe083tizydo8=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=Cawr1wtVN7tRJep7neWsFpWG/2D5uJxEEG8wWjW98oHhVIhnEE1TP+iBHbDLUsnAl w2INyoBZc1HEmMJriUlDOTtkJ8UdfCIXXQAX9+p41MTWMFm7X9c6QASEOqQ+4uMol0 nCihHBTuA/HMKfYQ4nXFBbPjsOjScaFgunEemUqXU0jSpMBC054K4/KzpKdKYEYJkv o52k4OSDn6Bzn6ZGQh0MW/Xezla0Y3eVk1oJUb6X4JuiODWd0VsYfo13Aohi+JLESj 8OKJtccK/i6NSkVQZv0EXavx+lpWOfusKfx14cA1G//VWfnPVVWPNJG2/rqqCId0zE VSGmDdfa5Q9Ew== Subject: Re: [PATCH net-next v2] ptp: ocp: add support for the ADVA TimeCard X2 From: netdev-bot+sashiko@kernel.org To: maimon.sagi@gmail.com Cc: netdev@vger.kernel.org, vadim.fedorenko@linux.dev, richardcochran@gmail.com, jiri@resnulli.us, andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com, horms@kernel.org, willemb@google.com, corbet@lwn.net, skhan@linuxfoundation.org, rdunlap@infradead.org, linux-doc@vger.kernel.org Date: Fri, 04 Dec 2026 13:15:49 +0000 Message-ID: <179639014981.3146.9403418067907555460@kernel.org> In-Reply-To: <20261203122416.425770-1-maimon.sagi@gmail.com> References: <20261203122416.425770-1-maimon.sagi@gmail.com> X-sashiko-severity: Medium Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-Mailing-List: netdev@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Thank you for your contribution! Sashiko AI review found 7 potential issue(s) to consider. Critical: 0 · High: 0 · Medium: 1 · Low: 6 If you believe none of the issues are legitimate, please reply to each issue of Medium severity or higher and explain why the AI is wrong. If any of them are legitimate and you plan to respin, please let patchwork know by including "pw-bot: cr" as a separate line at the end of your reply (one such reply per series is enough). - [Medium] The commit message says the new `!bp->spi_flash` check in ptp_ocp_devlink_flash_update() only matters for the X2: "The CPLD… - [Low] On the X2, the 0x70000 window is mapped into bp->pps_select so that adva_x1_bus_claim()/adva_x1_bus_release() can reach i2c_bus_ctrl. - [Low] The commit message justifies the new NULL-TOD guard in ptp_ocp_tod_init() with "Every board so far has a TOD block, SMA… - [Low] The X2 uses the shared static ptp_ocp_clock_info (`.n_ext_ts = 6`, `.n_per_out = 5`), so PTP_CLOCK_GETCAPS on the X2 advertises five… - [Low] Several comments still say the TAP CPLD is X1-only, although this patch sets `.has_cpld = true` for the X2: - `struct… - [Low] Documentation/ABI/testing/sysfs-timecard documents /sys/class/timecard/ocpN/cpld_status as "Only present on ADVA x1 TAP… - [Low] ptp: ocp: ADVA TimeCard X2 logs 0 baud for PORT_NMEA in ptp_ocp_info() -- ptp: ocp: add support for the ADVA TimeCard X2 This adds a resource table for the ADVA TimeCard X2 (PCI ID ad5a:0420) built on ptp_ocp_adva_board_init(). The board has no TOD block, no SMA op, no SPI flash and a reduced sysfs attribute set. The patch makes those three optional and adds the OSA image version layout. > Every board so far has a TOD block, SMA connectors and an FPGA flash, so > allow all three to be absent. ptp_ocp_tod_init() dereferenced bp->tod > unconditionally; it now returns early when there is no TOD block. [Severity: Low] Is this accurate for the Orolia ART card? ocp_art_resource[] has never mapped OCP_MEM_RESOURCE(tod). Only ocp_fb_resource[], ocp_adva_resource[] and ocp_adva_x1_resource[] do. The ART card was never affected, because ptp_ocp_art_board_init() does not call ptp_ocp_tod_init(). Its only callers are ptp_ocp_fb_board_init() and ptp_ocp_adva_board_init(). Would it be more accurate to say that the X2 is the first board whose init path calls ptp_ocp_tod_init() without a TOD block? > diff --git a/drivers/ptp/ptp_ocp.c b/drivers/ptp/ptp_ocp.c > index decc56892059b..cd81970a12fc1 100644 > --- a/drivers/ptp/ptp_ocp.c > +++ b/drivers/ptp/ptp_ocp.c [ ... ] > @@ -92,6 +93,8 @@ struct ptp_ocp_adva_info { > const struct ocp_attr_group *attr_groups; > /* x1: TAP CPLD present */ > bool has_cpld; > + /* x2: image version in the OSA software format */ > + bool osa_version; > }; [Severity: Low] This isn't a bug, but several comments still describe the TAP CPLD as X1-only, even though the X2 now sets .has_cpld = true: struct ptp_ocp_adva_info: /* x1: TAP CPLD present */ struct ptp_ocp: /* adva_x1 CPLD I2C (internal use only) */ ... /* x1 TAP CPLD present */ This patch changes the nearby gpio_reg i2c_bus_ctrl comment to adva_x1/x2. Should these comments be updated to match? [ ... ] > @@ -1319,12 +1323,91 @@ static struct ocp_resource ocp_adva_x1_resource[] = { > { } > }; > > +static struct ocp_resource ocp_adva_x2_resource[] = { [ ... ] > + { > + /* > + * The gpio_reg block. X2 has no SMA routing to configure, but > + * the window's i2c_bus_ctrl word carries the MicroBlaze I2C > + * bus-ownership handshake that CPLD access needs; see > + * adva_x1_bus_claim(). The X2 FPGA places it at 0x70000 > + * rather than at 0x130000 as on the other ADVA boards. > + */ > + OCP_MEM_RESOURCE(pps_select), > + .offset = 0x00070000, .size = 0x1000, > + }, [Severity: Low] With this window stored in bp->pps_select, ptp_ocp_summary_show() only checks that the pointer is non-NULL. It then decodes word 0 as the PPS1 source selector: ptp_ocp_summary_show() { ... if (bp->pps_select) { val = ioread32(&bp->pps_select->gpio1); src = &buf[80]; mac_src = "GNSS1"; if (val & 0x01) { gpio_input_map(src, bp, sma_val, 0, NULL); mac_src = src; } else if (val & 0x02) { src = "MAC"; } else if (val & 0x04) { src = "GNSS1"; } else { ... } Does gpio1 at offset 0 of the X2 window mean the same thing as on the boards that place this block at 0x130000? The new sma_op check in gpio_input_map() covers the SMA case. The MAC and GNSS1 cases still come from this register, though. If the layout is different on the X2, the debugfs summary would report PPS1 routing that the hardware does not have. [ ... ] > @@ -2189,6 +2278,11 @@ ptp_ocp_devlink_flash_update(struct devlink *devlink, > return err; > } > > + if (!bp->spi_flash) { > + NL_SET_ERR_MSG_MOD(extack, "FPGA image update not supported"); > + return -EOPNOTSUPP; > + } > + > dev = ptp_ocp_find_flash(bp); [Severity: Medium] The commit message says: "The CPLD component is unaffected, and all other boards have all three and are unaffected." Is that true for existing boards that get few MSI vectors? Every existing board registers spi_flash with .irq_vec = 9. ptp_ocp_allow_irq() skips that resource when bp->n_irqs <= 9: ptp_ocp_allow_irq() { bool allow = !r->irq_vec || r->irq_vec < bp->n_irqs; ... } ptp_ocp_probe() accepts as few as one vector through pci_alloc_irq_vectors(pdev, 1, 17, PCI_IRQ_MSI | PCI_IRQ_MSIX). Its comment says older FPGA firmware only returns 2 IRQs. On those boards bp->spi_flash stays NULL. Before this patch, a devlink flash without a component then did: ptp_ocp_devlink_flash_update() ptp_ocp_find_flash() dev = &bp->spi_flash->dev; device_find_any_child(dev) This dereferences a pointer near NULL. The crash itself is older than this patch. So the hunk also fixes a NULL dereference on existing boards. Should the commit message say so? Should it also carry a Fixes: tag, so that stable picks up the fix? On those boards the extack text "FPGA image update not supported" is also misleading. The update is supported there; the SPI controller was only skipped because there were not enough IRQ vectors. > @@ -3271,14 +3365,25 @@ ptp_ocp_adva_board_init(struct ptp_ocp *bp, struct ocp_resource *r) > bp->freq_in_nr = info->freq_in_nr; > > version = ioread32(&bp->image->version); [ ... ] > } > - bp->fw_tag = 3; > - bp->fw_version = version & 0xffff; > - bp->fw_cap = OCP_CAP_BASIC | OCP_CAP_SIGNAL | OCP_CAP_FREQ; > + bp->fw_cap = OCP_CAP_BASIC; > + if (info->signals_nr) > + bp->fw_cap |= OCP_CAP_SIGNAL; > + if (info->freq_in_nr) > + bp->fw_cap |= OCP_CAP_FREQ; [Severity: Low] This only changes which sysfs groups are created. The X2 still uses the shared ptp_ocp_clock_info: static const struct ptp_clock_info ptp_ocp_clock_info = { ... .n_ext_ts = 6, .n_per_out = 5, ... }; So PTP_CLOCK_GETCAPS on the X2 reports five periodic outputs and six external timestamp channels. The X2 has no generators, no ts0-ts4 and no SMA connectors. The commit message says "so the X2 advertises neither". Does that still hold for userspace that queries the PHC? In ptp_ocp_enable(), PTP_CLK_REQ_PEROUT index 0 with a 1 s period returns success but has no effect on the hardware: case 0: /* This is a request for 1PPS on an output SMA. * Allow, but assume manual configuration. */ if (on && (rq->perout.period.sec != 1 || rq->perout.period.nsec != 0)) return -EINVAL; return 0; For indices 1-4, ptp_ocp_signal_from_perout()->ptp_ocp_signal_set() stores bp->signal[gen] = *s before the request fails with -ENXIO. It fails because bp->signal_out[req] is NULL. Should the X2 advertise n_per_out and n_ext_ts values that match its hardware? [ ... ] > @@ -5180,12 +5288,37 @@ static const struct ocp_attr_group adva_timecard_x1_groups[] = { > { }, > }; > > +/* > + * X2 exposes the basic identity attributes plus the TAP CPLD status. It > + * has no user-accessible SMA connectors, signal generators or frequency > + * inputs, so none of the SMA, signal or freq groups apply. > + */ > +static struct attribute *adva_timecard_x2_attrs[] = { > + &dev_attr_serialnum.attr, > + &dev_attr_gnss_sync.attr, > + &dev_attr_cpld_status.attr, > + NULL, > +}; [Severity: Low] Documentation/ABI/testing/sysfs-timecard still describes cpld_status as: Only present on ADVA x1 TAP boards (PCI ID 0xad5a:0x0410). After this patch, cpld_status is also created on every X2 (0xad5a:0x0420). Should that file be updated the same way as Documentation/networking/devlink/ptp_ocp.rst? [ ... ] > @@ -1319,12 +1323,91 @@ static struct ocp_resource ocp_adva_x1_resource[] = { > { } > }; > > +static struct ocp_resource ocp_adva_x2_resource[] = { > + { > + OCP_MEM_RESOURCE(reg), > + .offset = 0x01000000, .size = 0x10000, > + }, > + { > + OCP_MEM_RESOURCE(pps_to_clk), > + .offset = 0x01040000, .size = 0x10000, > + }, > + { > + /* > + * PPS timestamper. X2 exposes no external timestampers, but > + * this block is what raises the per-second interrupt behind > + * PTP_ENABLE_PPS, so /dev/ppsN stays silent without it. > + */ > + OCP_EXT_RESOURCE(pps), > + .offset = 0x010C0000, .size = 0x10000, .irq_vec = 0, > + .extra = &(struct ptp_ocp_ext_info) { > + .index = 5, > + .irq_fcn = ptp_ocp_ts_irq, > + .enable = ptp_ocp_ts_enable, > + }, > + }, > + { > + OCP_MEM_RESOURCE(image), > + .offset = 0x00020000, .size = 0x1000, > + }, > + { > + /* > + * The gpio_reg block. X2 has no SMA routing to configure, but > + * the window's i2c_bus_ctrl word carries the MicroBlaze I2C > + * bus-ownership handshake that CPLD access needs; see > + * adva_x1_bus_claim(). The X2 FPGA places it at 0x70000 > + * rather than at 0x130000 as on the other ADVA boards. > + */ > + OCP_MEM_RESOURCE(pps_select), > + .offset = 0x00070000, .size = 0x1000, > + }, > + { > + OCP_SERIAL_RESOURCE(port[PORT_NMEA]), > + .offset = 0x00190000 + 0x1000, .irq_vec = 10, > + }, > + { > + OCP_I2C_RESOURCE(i2c_ctrl), > + .offset = 0x00150000, .size = 0x10000, .irq_vec = 7, > + .extra = &(struct ptp_ocp_i2c_info) { > + .name = "xiic-i2c", > + .fixed_rate = 50000000, > + .data_size = sizeof(struct xiic_i2c_platform_data), > + .data = &(struct xiic_i2c_platform_data) { > + .num_devices = 2, > + .devices = (struct i2c_board_info[]) { > + { I2C_BOARD_INFO("24c02", 0x50) }, > + { I2C_BOARD_INFO("24mac402", 0x58), > + .platform_data = "mac" }, > + }, > + }, > + }, > + }, > + { > + .setup = ptp_ocp_adva_board_init, > + .extra = &(struct ptp_ocp_adva_info) { > + .servo = { > + .servo_offset_p = 0xc000, > + .servo_offset_i = 0x1000, > + .servo_drift_p = 0, > + .servo_drift_i = 0, > + }, > + .signals_nr = 0, > + .freq_in_nr = 0, > + .attr_groups = adva_timecard_x2_groups, > + .has_cpld = true, > + .osa_version = true, > + }, > + }, > + { } > +}; > + > static const struct pci_device_id ptp_ocp_pcidev_id[] = { > { PCI_DEVICE_DATA(META, TIMECARD, &ocp_fb_resource) }, > { PCI_DEVICE_DATA(CELESTICA, TIMECARD, &ocp_fb_resource) }, > { PCI_DEVICE_DATA(OROLIA, ARTCARD, &ocp_art_resource) }, > { PCI_DEVICE_DATA(ADVA, TIMECARD, &ocp_adva_resource) }, > { PCI_DEVICE_DATA(ADVA, TIMECARD_X1, &ocp_adva_x1_resource) }, > + { PCI_DEVICE_DATA(ADVA, TIMECARD_X2, &ocp_adva_x2_resource) }, > { } > }; > MODULE_DEVICE_TABLE(pci, ptp_ocp_pcidev_id); [Severity: Low] On the X2 this NMEA port is registered without an .extra baud rate, and the table maps no nmea_out block either. ptp_ocp_register_serial() only fills in port.baud from r->extra, so bp->port[PORT_NMEA].baud stays 0. ptp_ocp_info() only replaces the NMEA baud when bp->nmea_out is non-NULL. On the X2 that lookup is skipped, so ptp_ocp_serial_info() logs the port as running at 0 baud on every probe: NMEA: /dev/ttySN @ 0 This is cosmetic. serial8250_register_8250_port() does not use port.baud, so the UART itself is fine. Still, the probe log is the first place people look when a card misbehaves, and a 0 baud rate there is misleading. What rate does the X2 NMEA UART run at? Could the resource carry it in .extra, as other serial resources in this file do? Or should ptp_ocp_serial_info() leave out the baud when it is not known? Separately, the commit message says the X2 keeps the NMEA serial port of the X1. As far as I can see, ocp_adva_x1_resource[] registers PORT_GNSS and PORT_MAC and no PORT_NMEA. Is the intent to say that the NMEA port is new on the X2? -- Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261203122416.425770-1-maimon.sagi%40gmail.com