Skip to contentSkip to conversation

Fix two issues in ptp_s390 driver

PATCH In review Sven Schnelle 3 participants 5 messages Jul 14 – Jul 15

Subsystems (5)
lore
Share & tools
lore

Sven Schnelle

author maintainer
#0 lore raw

cover Fix two issues in ptp_s390 driver

This patchset fixes two issues in the ptp_s390 driver:

a) Missing check of condition code in qpt query function. When PTFF QPT is not supported ptp_s390_qpt_gettime() would just return without storing the physical time.

b) Missing test for presence of facility 28 during driver registration.

Sven Schnelle (2):
ptp: ptp_s390: Add missing CC check for ptff()
ptp: ptp_s390: Add missing facility check

 drivers/ptp/ptp_s390.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
Signature · 1 line
2.53.0
author maintainer
#1 lore raw

PATCH 1/2 ptp: ptp_s390: Add missing CC check for ptff()

The code doesn't honor the returned condition code when issuing the PTFF_QPT call. Fix this by checking the return code and returning EIO if it is not zero.

Fixes 2d7de7a3010d ("s390/time: Add PtP driver")
---
 drivers/ptp/ptp_s390.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/ptp/ptp_s390.c +2 -1
index 29618eb9bf44..7299c3aae65f 100644
@@ -48,7 +48,8 @@ static int ptp_s390_qpt_gettime(struct ptp_clock_info *ptp,
 {
 	unsigned long tod;
 
-	ptff(&tod, sizeof(tod), PTFF_QPT);
+	if (ptff(&tod, sizeof(tod), PTFF_QPT) != 0)
+		return -EOPNOTSUPP;
 	*ts = tod_to_timespec64(tod);
 	return 0;
 }
Signature · 1 line
2.53.0
#2 lore raw

Re: [PATCH 1/2] ptp: ptp_s390: Add missing CC check for ptff()

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Medium] The commit message explicitly states "returning EIO if it is not zero", but the implementation…

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] The commit message explicitly states "returning EIO if it is not zero", but the implementation actually returns -EOPNOTSUPP. --

--- Patch [1]: [PATCH 1/2] ptp: ptp_s390: Add missing CC check for ptff() --- commit 1da4a31377dcdb1f0789c86ae0f57516f6c5caf1
Author: Sven Schnelle <[email protected]>

ptp: ptp_s390: Add missing CC check for ptff()

This commit updates ptp_s390_qpt_gettime to check the condition code returned by ptff. It adds an error path to handle non-zero returns from the hardware call.

Quoted 3 lines

The code doesn't honor the returned condition code when issuing the PTFF_QPT call. Fix this by checking the return code and returning EIO if it is not zero.

[Severity: Medium]
Is the description in the commit message accurate? The message states the code returns EIO, but the implementation actually returns -EOPNOTSUPP:

Quoted 14 lines
drivers/ptp/ptp_s390.c +2 -1
index 29618eb9bf442..7299c3aae65f6 100644
@@ -48,7 +48,8 @@ static int ptp_s390_qpt_gettime(struct ptp_clock_info *ptp,
 {
 	unsigned long tod;
 
-	ptff(&tod, sizeof(tod), PTFF_QPT);
+	if (ptff(&tod, sizeof(tod), PTFF_QPT) != 0)
+		return -EOPNOTSUPP;
 	*ts = tod_to_timespec64(tod);
 	return 0;
 }
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
author maintainer
#3 lore raw

PATCH 2/2 ptp: ptp_s390: Add missing facility check

In reply to Sven Schnelle

Only register the physical clock when facility 28 is installed.

Fixes 2d7de7a3010d ("s390/time: Add PtP driver")
---
 drivers/ptp/ptp_s390.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/ptp/ptp_s390.c +5 -1
index 7299c3aae65f..3ea94648cdde 100644
@@ -108,6 +108,9 @@ static __init int ptp_s390_init(void)
 	if (IS_ERR(ptp_stcke_clock))
 		return PTR_ERR(ptp_stcke_clock);
 
+	if (!test_facility(28))
+		return 0;
+
 	ptp_qpt_clock = ptp_clock_register(&ptp_s390_qpt_info, NULL);
 	if (IS_ERR(ptp_qpt_clock)) {
 		ptp_clock_unregister(ptp_stcke_clock);
@@ -118,7 +121,8 @@ static __init int ptp_s390_init(void)
 
 static __exit void ptp_s390_exit(void)
 {
-	ptp_clock_unregister(ptp_qpt_clock);
+	if (ptp_qpt_clock)
+		ptp_clock_unregister(ptp_qpt_clock);
 	ptp_clock_unregister(ptp_stcke_clock);
 }
 
Signature · 1 line
2.53.0
maintainer
#4 lore raw

Re: [PATCH 2/2] ptp: ptp_s390: Add missing facility check

Quoted 14 lines · Sven Schnelle

Only register the physical clock when facility 28 is installed.

Fixes 2d7de7a3010d ("s390/time: Add PtP driver")
---
 drivers/ptp/ptp_s390.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/ptp/ptp_s390.c +0 -0
index 7299c3aae65f..3ea94648cdde 100644

drivers/ptp/ptp_s390.c static __init int ptp_s390_init(void) · line 116

Quoted 9 lines
drivers/ptp/ptp_s390.c +3 -0
@@ -108,6 +108,9 @@ static __init int ptp_s390_init(void)
 	if (IS_ERR(ptp_stcke_clock))
 		return PTR_ERR(ptp_stcke_clock);
 
+	if (!test_facility(28))
+		return 0;
+
 	ptp_qpt_clock = ptp_clock_register(&ptp_s390_qpt_info, NULL);
 	if (IS_ERR(ptp_qpt_clock)) {
 		ptp_clock_unregister(ptp_stcke_clock);

Wouldn't it make more sense to check if PTFF-QPT is available via PTFF-QAF before registering the clock? This would also avoid the need of the first patch - since then it is guaranteed that PTFF-QPT will always return with condition code zero.

And... we wouldn't have the potential oddity to have a clock registered which doesn't work.