Fix two issues in ptp_s390 driver
Subsystems (5)
Sven Schnelle
maintainercover 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
Sven Schnelle
maintainerPATCH 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.
--- drivers/ptp/ptp_s390.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/ptp/ptp_s390.c +2 -1
@@ -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
[email protected]
AI reviewRe: [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_QPTcall. 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@@ -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
Sven Schnelle
maintainerPATCH 2/2 ptp: ptp_s390: Add missing facility check
In reply to Sven SchnelleOnly register the physical clock when facility 28 is installed.
--- drivers/ptp/ptp_s390.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/ptp/ptp_s390.c +5 -1
@@ -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
Heiko Carstens
maintainerRe: [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")Signed-off-by Sven Schnelle <[email protected]>--- drivers/ptp/ptp_s390.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)drivers/ptp/ptp_s390.c +0
-0
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.