From patchwork Mon Aug 5 22:04:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vadim Fedorenko X-Patchwork-Id: 13754204 X-Patchwork-Delegate: kuba@kernel.org Received: from mx0a-00082601.pphosted.com (mx0a-00082601.pphosted.com [67.231.145.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BA6F378C8D for ; Mon, 5 Aug 2024 22:05:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=67.231.145.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722895525; cv=none; b=DZVuhXI57MrMxna5lPAtpz27DQLRhYiR4sq3BU6dYWBg8rh9cT4wPbeyTENEgX4hrIXyVTCKDonLt0MXHfRZNYgwDY6JrCWlTlBktdd4xsQ05BceZKgv7kP7CzT3Ce9Czp9hgYxZz+k8DoztmHsMYKJx33PZL0KYqCTVoq+uFok= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722895525; c=relaxed/simple; bh=t2HjtLxFi3bjEuKM47st+9yURjolrUCAlfMjCDY7l7c=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=I5f85cDHwY9U7n6TGwOADSxoe7buiJxlTPByl237WVTmj7xUOU/KCX4YWj4sB1SfIqfwhu+KyuJMJTIY7R/kvTEO9P06C1CQkW3E0Ig0Z77iEV2cm7yy9PDs4rud25WZIt3zGCTg9ykv+kM1oPq9GD9phL6mBA4EZwxQ6rzuZiU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=meta.com; spf=pass smtp.mailfrom=meta.com; dkim=pass (2048-bit key) header.d=meta.com header.i=@meta.com header.b=isbdx4sT; arc=none smtp.client-ip=67.231.145.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=meta.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=meta.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=meta.com header.i=@meta.com header.b="isbdx4sT" Received: from pps.filterd (m0044012.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 475LvAQQ014602; Mon, 5 Aug 2024 15:05:11 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=meta.com; h=from :to:cc:subject:date:message-id:mime-version :content-transfer-encoding:content-type; s=s2048-2021-q4; bh=RKt SzBiC66mZ0Z9nl12/9f1OoX4wKignoi1TCwSYi94=; b=isbdx4sTq0g0wCxIMD9 Mau6H9yu9+v6IrhnRwAalAy3Qe0S9J3tz4w6s0auGu+Jo0PF8ULyqGxLPd4Q6kYI noK45v4JLB7ql281ttjfqzrMzdnO+a8G2zdNU5XDJVSf8JS9Ih1fLMx4E613Qit+ tivF5P641/Hk+YeH3NkOHrnKiYDKt/o/c4ZM5yr0BaqNZBQQsNgIzwzNZmbvS3My +VqJTVehCouP6ceaiz5T8ZDMwwkYCNcxOOREWVE3DnFYw+HaENQEZyeIzvJZiunh aQsM21dJjRs/vdbtds/E8jMPGHIWdXFDf6q3mGsCIvZAlzUi7d74eUvtOfgx3py+ 0Ag== Received: from maileast.thefacebook.com ([163.114.130.16]) by mx0a-00082601.pphosted.com (PPS) with ESMTPS id 40u3yys990-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT); Mon, 05 Aug 2024 15:05:11 -0700 (PDT) Received: from devvm4158.cln0.facebook.com (2620:10d:c0a8:fe::f072) by mail.thefacebook.com (2620:10d:c0a9:6f::8fd4) with Microsoft SMTP Server id 15.2.1544.11; Mon, 5 Aug 2024 22:05:09 +0000 From: Vadim Fedorenko To: Vadim Fedorenko , Jakub Kicinski , Jonathan Lemon , Jiri Slaby , Greg Kroah-Hartman CC: Vadim Fedorenko , Subject: [PATCH net v2 1/2] ptp: ocp: adjust sysfs entries to expose tty information Date: Mon, 5 Aug 2024 15:04:59 -0700 Message-ID: <20240805220500.1808797-1-vadfed@meta.com> X-Mailer: git-send-email 2.43.5 Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Proofpoint-GUID: KOhZl4Honh8TY2cFygp45DyMn9X-6Tq8 X-Proofpoint-ORIG-GUID: KOhZl4Honh8TY2cFygp45DyMn9X-6Tq8 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-08-05_10,2024-08-02_01,2024-05-17_01 X-Patchwork-Delegate: kuba@kernel.org Starting v6.8 the serial port subsystem changed the hierarchy of devices and symlinks are not working anymore. Previous discussion made it clear that the idea of symlinks for tty devices was wrong by design. Implement additional attributes to expose the information. Fixes tag points to the commit which introduced the change. Fixes: b286f4e87e32 ("serial: core: Move tty and serdev to be children of serial core port device") Signed-off-by: Vadim Fedorenko --- drivers/ptp/ptp_ocp.c | 68 +++++++++++++++++++++++++++++++++---------- 1 file changed, 52 insertions(+), 16 deletions(-) diff --git a/drivers/ptp/ptp_ocp.c b/drivers/ptp/ptp_ocp.c index ee2ced88ab34..7a5026656452 100644 --- a/drivers/ptp/ptp_ocp.c +++ b/drivers/ptp/ptp_ocp.c @@ -3346,6 +3346,55 @@ static EXT_ATTR_RO(freq, frequency, 1); static EXT_ATTR_RO(freq, frequency, 2); static EXT_ATTR_RO(freq, frequency, 3); +static ssize_t +ptp_ocp_tty_show(struct device *dev, struct device_attribute *attr, char *buf) +{ + struct dev_ext_attribute *ea = to_ext_attr(attr); + struct ptp_ocp *bp = dev_get_drvdata(dev); + struct ptp_ocp_serial_port *port; + + port = (void *)((uintptr_t)bp + (uintptr_t)ea->var); + return sysfs_emit(buf, "ttyS%d", port->line); +} + +static umode_t +ptp_ocp_timecard_tty_is_visible(struct kobject *kobj, struct attribute *attr, int n) +{ + struct ptp_ocp *bp = dev_get_drvdata(kobj_to_dev(kobj)); + struct ptp_ocp_serial_port *port; + struct device_attribute *dattr; + struct dev_ext_attribute *ea; + + if (strncmp(attr->name, "tty", 3)) + return attr->mode; + + dattr = container_of(attr, struct device_attribute, attr); + ea = container_of(dattr, struct dev_ext_attribute, attr); + port = (void *)((uintptr_t)bp + (uintptr_t)ea->var); + return port->line == -1 ? 0 : 0444; +} +#define EXT_TTY_ATTR_RO(_name, _val) \ + struct dev_ext_attribute dev_attr_tty##_name = \ + { __ATTR(tty##_name, 0444, ptp_ocp_tty_show, NULL), (void *)_val } + +static EXT_TTY_ATTR_RO(GNSS, offsetof(struct ptp_ocp, gnss_port)); +static EXT_TTY_ATTR_RO(GNSS2, offsetof(struct ptp_ocp, gnss2_port)); +static EXT_TTY_ATTR_RO(MAC, offsetof(struct ptp_ocp, mac_port)); +static EXT_TTY_ATTR_RO(NMEA, offsetof(struct ptp_ocp, nmea_port)); +static struct attribute *ptp_ocp_timecard_tty_attrs[] = { + &dev_attr_ttyGNSS.attr.attr, + &dev_attr_ttyGNSS2.attr.attr, + &dev_attr_ttyMAC.attr.attr, + &dev_attr_ttyNMEA.attr.attr, + NULL, +}; + +static const struct attribute_group ptp_ocp_timecard_tty_group = { + .name = "tty", + .attrs = ptp_ocp_timecard_tty_attrs, + .is_visible = ptp_ocp_timecard_tty_is_visible, +}; + static ssize_t serialnum_show(struct device *dev, struct device_attribute *attr, char *buf) { @@ -3775,6 +3824,7 @@ static const struct attribute_group fb_timecard_group = { static const struct ocp_attr_group fb_timecard_groups[] = { { .cap = OCP_CAP_BASIC, .group = &fb_timecard_group }, + { .cap = OCP_CAP_BASIC, .group = &ptp_ocp_timecard_tty_group }, { .cap = OCP_CAP_SIGNAL, .group = &fb_timecard_signal0_group }, { .cap = OCP_CAP_SIGNAL, .group = &fb_timecard_signal1_group }, { .cap = OCP_CAP_SIGNAL, .group = &fb_timecard_signal2_group }, @@ -3814,6 +3864,7 @@ static const struct attribute_group art_timecard_group = { static const struct ocp_attr_group art_timecard_groups[] = { { .cap = OCP_CAP_BASIC, .group = &art_timecard_group }, + { .cap = OCP_CAP_BASIC, .group = &ptp_ocp_timecard_tty_group }, { }, }; @@ -3841,6 +3892,7 @@ static const struct attribute_group adva_timecard_group = { static const struct ocp_attr_group adva_timecard_groups[] = { { .cap = OCP_CAP_BASIC, .group = &adva_timecard_group }, + { .cap = OCP_CAP_BASIC, .group = &ptp_ocp_timecard_tty_group }, { .cap = OCP_CAP_SIGNAL, .group = &fb_timecard_signal0_group }, { .cap = OCP_CAP_SIGNAL, .group = &fb_timecard_signal1_group }, { .cap = OCP_CAP_FREQ, .group = &fb_timecard_freq0_group }, @@ -4352,22 +4404,6 @@ ptp_ocp_complete(struct ptp_ocp *bp) struct pps_device *pps; char buf[32]; - if (bp->gnss_port.line != -1) { - sprintf(buf, "ttyS%d", bp->gnss_port.line); - ptp_ocp_link_child(bp, buf, "ttyGNSS"); - } - if (bp->gnss2_port.line != -1) { - sprintf(buf, "ttyS%d", bp->gnss2_port.line); - ptp_ocp_link_child(bp, buf, "ttyGNSS2"); - } - if (bp->mac_port.line != -1) { - sprintf(buf, "ttyS%d", bp->mac_port.line); - ptp_ocp_link_child(bp, buf, "ttyMAC"); - } - if (bp->nmea_port.line != -1) { - sprintf(buf, "ttyS%d", bp->nmea_port.line); - ptp_ocp_link_child(bp, buf, "ttyNMEA"); - } sprintf(buf, "ptp%d", ptp_clock_index(bp->ptp)); ptp_ocp_link_child(bp, buf, "ptp"); From patchwork Mon Aug 5 22:05:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vadim Fedorenko X-Patchwork-Id: 13754205 X-Patchwork-Delegate: kuba@kernel.org Received: from mx0a-00082601.pphosted.com (mx0a-00082601.pphosted.com [67.231.145.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8116214C5A1 for ; Mon, 5 Aug 2024 22:05:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=67.231.145.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722895529; cv=none; b=dY0sU0lxzjol2/VvrFT3mHJMcqJzc/z0q3ACzoq1tOHMF7IooYq2CYL2xVW2Nn81szj3ptSrzOdGG8nHHyl6PZKfHnEPHHrtZYafXb6tSJcv6i2CmR3nPooM+m7ERa9HDjlw2hnHXu1UPbFva6PpJVQkrr0+4Lk1lGLnjLOLRV0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722895529; c=relaxed/simple; bh=OutB4SmwTuXnpzwnAeVCeLrkDUKImL5Zn0dp+2n7REs=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=oxhPECiA9FPs0tFPGo3eQXUc9TNGHEGtdOcHujjKSgRJwAiSVM72toUeBWHqZoRQ9Yf6M18QtLOhZjolVVzZJSgVnF4W5pp64EcwzR0y9gwC6kXXUk8FRmkk9CzaL+l7UHOaJiU+U+TfXJ11hD6Hjvz/fW+0UgyY9gjQ3F5TWro= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=meta.com; spf=pass smtp.mailfrom=meta.com; dkim=pass (2048-bit key) header.d=meta.com header.i=@meta.com header.b=IC3Ri1Q8; arc=none smtp.client-ip=67.231.145.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=meta.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=meta.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=meta.com header.i=@meta.com header.b="IC3Ri1Q8" Received: from pps.filterd (m0044012.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 475LvAQR014602; Mon, 5 Aug 2024 15:05:12 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=meta.com; h=from :to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding:content-type; s= s2048-2021-q4; bh=M7SecbCtkGqGmalNbhYVkl6y9qy5wCiRCj4gU1HdodI=; b= IC3Ri1Q8tyRBeVRILPORf4CsWTh5fsHzB9rKTGwmLtkqZiB3+itujXxmElRfnjG/ tg2y4GS1lvPwkbdM1FCi0+dptnckrtZQ2bONAVxwvTLIojv7ae3wdi0Sx1if2Ra0 IMaXdrX0SMAoMZX8JwPzaCeS9u34cGRksmK/Js3H/GVvARdqRjSGpbD5CZYU02wa n7x+Kg5oGVQDdUlbTJhg1HJhHnpYvSe0LN0wgvxNT0UnfyqILMfZmBic87GOC8UD CsEaz+o9QNC0y0KEPh3Z5mmgOEBP1bvTWJEMvig3E5nBlvoKg9gAyI4SEYLbjCT5 /ArVqNByUWd0rvDqdAPcPQ== Received: from maileast.thefacebook.com ([163.114.130.16]) by mx0a-00082601.pphosted.com (PPS) with ESMTPS id 40u3yys990-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT); Mon, 05 Aug 2024 15:05:12 -0700 (PDT) Received: from devvm4158.cln0.facebook.com (2620:10d:c0a8:fe::f072) by mail.thefacebook.com (2620:10d:c0a9:6f::8fd4) with Microsoft SMTP Server id 15.2.1544.11; Mon, 5 Aug 2024 22:05:10 +0000 From: Vadim Fedorenko To: Vadim Fedorenko , Jakub Kicinski , Jonathan Lemon , Jiri Slaby , Greg Kroah-Hartman CC: Vadim Fedorenko , Subject: [PATCH net v2 2/2] docs: ABI: update OCP TimeCard sysfs entries Date: Mon, 5 Aug 2024 15:05:00 -0700 Message-ID: <20240805220500.1808797-2-vadfed@meta.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20240805220500.1808797-1-vadfed@meta.com> References: <20240805220500.1808797-1-vadfed@meta.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Proofpoint-GUID: 04hNv_JNORObIoCoqy0TnFl4eE4cZgMn X-Proofpoint-ORIG-GUID: 04hNv_JNORObIoCoqy0TnFl4eE4cZgMn X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-08-05_10,2024-08-02_01,2024-05-17_01 X-Patchwork-Delegate: kuba@kernel.org Update documentation according to the changes in the driver. New attributes group tty is exposed and ttyGNSS, ttyGNSS2, ttyMAC and ttyNMEA are moved to this gruop. Also, these attributes are no more links to the devices but rather simple text files containing names of tty devices. Signed-off-by: Vadim Fedorenko --- Documentation/ABI/testing/sysfs-timecard | 31 ++++++++++++++---------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/Documentation/ABI/testing/sysfs-timecard b/Documentation/ABI/testing/sysfs-timecard index 220478156297..3ae41b7634ac 100644 --- a/Documentation/ABI/testing/sysfs-timecard +++ b/Documentation/ABI/testing/sysfs-timecard @@ -258,24 +258,29 @@ Description: (RW) When retrieving the PHC with the PTP SYS_OFFSET_EXTENDED the estimated point where the FPGA latches the PHC time. This value may be changed by writing an unsigned integer. -What: /sys/class/timecard/ocpN/ttyGNSS -What: /sys/class/timecard/ocpN/ttyGNSS2 -Date: September 2021 +What: /sys/class/timecard/ocpN/tty +Date: August 2024 +Contact: Vadim Fedorenko +Description: (RO) Directory containing the sysfs nodes for TTY attributes + +What: /sys/class/timecard/ocpN/tty/ttyGNSS +What: /sys/class/timecard/ocpN/tty/ttyGNSS2 +Date: August 2024 Contact: Jonathan Lemon -Description: These optional attributes link to the TTY serial ports - associated with the GNSS devices. +Description: (RO) These optional attributes contain names of the TTY serial + ports associated with the GNSS devices. -What: /sys/class/timecard/ocpN/ttyMAC -Date: September 2021 +What: /sys/class/timecard/ocpN/tty/ttyMAC +Date: August 2024 Contact: Jonathan Lemon -Description: This optional attribute links to the TTY serial port - associated with the Miniature Atomic Clock. +Description: (RO) This optional attribute contains name of the TTY serial + port associated with the Miniature Atomic Clock. -What: /sys/class/timecard/ocpN/ttyNMEA -Date: September 2021 +What: /sys/class/timecard/ocpN/tty/ttyNMEA +Date: August 2024 Contact: Jonathan Lemon -Description: This optional attribute links to the TTY serial port - which outputs the PHC time in NMEA ZDA format. +Description: (RO) This optional attribute contains name of the TTY serial + port which outputs the PHC time in NMEA ZDA format. What: /sys/class/timecard/ocpN/utc_tai_offset Date: September 2021