Message ID | 20230630071826.105501-2-giometti@enneenne.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp10167096vqr; Fri, 30 Jun 2023 00:27:55 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6Q82yvr9IkXRUvrWo835Lmro/2bnwFYRyOT2FBpcb7n2B6oTDUFIjJAJdqb2fe3UmlQjNQ X-Received: by 2002:a05:6602:1612:b0:783:6e76:6bc7 with SMTP id x18-20020a056602161200b007836e766bc7mr3347640iow.2.1688110075586; Fri, 30 Jun 2023 00:27:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688110075; cv=none; d=google.com; s=arc-20160816; b=TQYElVysX2aM1PHfk6tS0v8N37wBD8J65AwotzTDTKqep+0kkIpdXu0rHAEcwYkCIS dWo+FwikdvYJWTbSQaU6zmuNQd1WMC9nJ51hVwLgOaJcROpVgKcA/ucSsQ1G121cdqZQ LX/blWfFZZqbjJQRm/nZjCap8rLso2bZuJ7AyOo54LmWYEyZmyZzI4s+Vmqf+rYYC0u5 ivuloscfqpRmoynGCdna6eq//6r5fcmzFual/TTalNQClesQnP7wbU8XAxdY/fW7bCTb 7o0YMBIdGV8ZzRG2/Ebh0UKMwpFAlOL1LaCkJSwgC68q8ZnGPP3TyLBEf7vGiz4gGjl5 Mj4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=lcksmT+j3dvrGVE0znQsMXKzAYoy6l9c+LDbLT3F9C0=; fh=EMuwq4M6OvdxCYN7uXvrk5VMMSOj47BLh5bHSiK9ceA=; b=m8p7ljQjFuvGLYLw4bdb6BrFACBnmewLdicT3O56GMRFcl3rJ2xTQp+Fi6Acu0sfP/ YGi/yiSAX4HL7ChWbcDVfuLdntO8KHLEYrzzInhNG5NwFUacMDTkizGjbYkE8a7KvV/D X5sXdyiOwlgx+9+4zTHhht9842TRO+9hDb5OadoFz//FbZ5zS0UKJb754GPHdZZ4u8dr LQG9kJ5sOsQtzjts7feGZTRTK2SxfUFOG9O+mLlxfGXC4zy670dER0emQCURSbvu2esw uiLXrNXwAWuxonMxUqmGweP7conGCo4ts9stNQJZhxoN+ehSIy0eSYKUkXra17oV1UPr bPLQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@aruba.it header.s=a1 header.b=UN5RMAXk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x5-20020a654145000000b005533aa71fabsi11163736pgp.572.2023.06.30.00.27.42; Fri, 30 Jun 2023 00:27:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@aruba.it header.s=a1 header.b=UN5RMAXk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232288AbjF3HTX (ORCPT <rfc822;ivan.orlov0322@gmail.com> + 99 others); Fri, 30 Jun 2023 03:19:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47386 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229945AbjF3HS6 (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Fri, 30 Jun 2023 03:18:58 -0400 Received: from smtpcmd12131.aruba.it (smtpcmd12131.aruba.it [62.149.156.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 013F01BDB for <linux-kernel@vger.kernel.org>; Fri, 30 Jun 2023 00:18:56 -0700 (PDT) Received: from polimar.homenet.telecomitalia.it ([79.0.204.227]) by Aruba Outgoing Smtp with ESMTPSA id F8P2qe5pmwtegF8PAqinFy; Fri, 30 Jun 2023 09:18:56 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=aruba.it; s=a1; t=1688109536; bh=QcsExrNJ6u1tiwlvDyvY9CDAytYAHUcGn+MfPz/pR+M=; h=From:To:Subject:Date:MIME-Version; b=UN5RMAXkMviYnp4jYmmiMtNiGPPtedCJdjUMe2Ej4XT4YDqTxeseIAB1U4IeM41fK MvDwYgL+2+9eYCWALRY4Xy8sTL4fdhgtinJSVIZ9eIJ1INOwpQb6d1U2uuC/nsm0u6 qhIH6w6fkMO/PZBUAcgIoEfjeMU5fMNxPTWVhNIa8IOgj8XSuhsD6YHVWaB/80lwX+ th5Rmm9bWhS+dvQh18yrgxergV5MNowvQNxbDLNasVjDi3fbjkCcmtvusq4Ac3u2G0 d4H8zr8EzObwBsOshfwbMvUaVbIx4oFNDe2HsRzK5O4bS0odj3IwFl1oEjXiNIg1xV GephMKN94FF6A== From: Rodolfo Giometti <giometti@enneenne.com> To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>, Rodolfo Giometti <giometti@enneenne.com> Subject: [PATCH 2/2] include/uapi pps.h: drop not needed PPS_MAX_SOURCES define Date: Fri, 30 Jun 2023 09:18:26 +0200 Message-Id: <20230630071826.105501-2-giometti@enneenne.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230630071826.105501-1-giometti@enneenne.com> References: <20230630071826.105501-1-giometti@enneenne.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CMAE-Envelope: MS4xfEKXjkKELrLkuV21oCJBEGONFsFIcn/35iHv7RHB6PVXRFxSfWMKWwHLolc88Ky7whnKEmwZVxVcyv2EZ3vOt7ciRgBmxCA2yGmnURGFEKrbSKOyjkxp GLyV6wTzwvj+L85OKaqiosjgUVD9TID+V9Ea9WLYbOO1nlTxfZ0UQ+hfZ9diJ0yIRSQ10aKT/gHX/LWUIHoddVIPPK2GNTJKeU1MbFSkWRvX8yN9ZjASp3bq 4Ks3PdGZiwGlUdYteuQz8m/SDOswsWVbCO83Tg+4y8UzvLmdUK0QorZnl+6lSbDy X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1770111710717949590?= X-GMAIL-MSGID: =?utf-8?q?1770111710717949590?= |
Series |
[1/2] include/uapi pps.h: increase PPS_MAX_SOURCES value
|
|
Commit Message
Rodolfo Giometti
June 30, 2023, 7:18 a.m. UTC
Userspace PPS clients should not known about how many PPS sources can
be defined within the system (nor the rfc2783 say so), so we can
safely drop this define since is not used anymore in the kernel too.
Signed-off-by: Rodolfo Giometti <giometti@enneenne.com>
---
drivers/pps/pps.c | 6 +++---
include/uapi/linux/pps.h | 1 -
2 files changed, 3 insertions(+), 4 deletions(-)
Comments
On Fri, Jun 30, 2023 at 09:18:26AM +0200, Rodolfo Giometti wrote: > Userspace PPS clients should not known about how many PPS sources can > be defined within the system (nor the rfc2783 say so), so we can > safely drop this define since is not used anymore in the kernel too. > > Signed-off-by: Rodolfo Giometti <giometti@enneenne.com> > --- > drivers/pps/pps.c | 6 +++--- > include/uapi/linux/pps.h | 1 - > 2 files changed, 3 insertions(+), 4 deletions(-) > > diff --git a/drivers/pps/pps.c b/drivers/pps/pps.c > index 5d19baae6a38..1a6131608036 100644 > --- a/drivers/pps/pps.c > +++ b/drivers/pps/pps.c > @@ -354,7 +354,7 @@ int pps_register_cdev(struct pps_device *pps) > * Get new ID for the new PPS source. After idr_alloc() calling > * the new source will be freely available into the kernel. > */ > - err = idr_alloc(&pps_idr, pps, 0, PPS_MAX_SOURCES, GFP_KERNEL); > + err = idr_alloc(&pps_idr, pps, 0, MINORMASK, GFP_KERNEL); > if (err < 0) { > if (err == -ENOSPC) { > pr_err("%s: too many PPS sources in the system\n", > @@ -449,7 +449,7 @@ EXPORT_SYMBOL(pps_lookup_dev); > static void __exit pps_exit(void) > { > class_destroy(pps_class); > - unregister_chrdev_region(pps_devt, PPS_MAX_SOURCES); > + unregister_chrdev_region(pps_devt, MINORMASK); > } > > static int __init pps_init(void) > @@ -463,7 +463,7 @@ static int __init pps_init(void) > } > pps_class->dev_groups = pps_groups; > > - err = alloc_chrdev_region(&pps_devt, 0, PPS_MAX_SOURCES, "pps"); > + err = alloc_chrdev_region(&pps_devt, 0, MINORMASK, "pps"); > if (err < 0) { > pr_err("failed to allocate char device region\n"); > goto remove_class; > diff --git a/include/uapi/linux/pps.h b/include/uapi/linux/pps.h > index 90f2e86020ba..8a4096f18af1 100644 > --- a/include/uapi/linux/pps.h > +++ b/include/uapi/linux/pps.h > @@ -26,7 +26,6 @@ > #include <linux/types.h> > > #define PPS_VERSION "5.3.6" > -#define PPS_MAX_SOURCES MINORMASK Why change this in patch 1, and then delete this here? That makes no sense. And if this is exported to userspace, removing it should break things, right? If not, why was it there in the first place? thanks, greg k-h
On 30/06/23 09:31, Greg Kroah-Hartman wrote: > On Fri, Jun 30, 2023 at 09:18:26AM +0200, Rodolfo Giometti wrote: >> Userspace PPS clients should not known about how many PPS sources can >> be defined within the system (nor the rfc2783 say so), so we can >> safely drop this define since is not used anymore in the kernel too. >> >> Signed-off-by: Rodolfo Giometti <giometti@enneenne.com> >> --- >> drivers/pps/pps.c | 6 +++--- >> include/uapi/linux/pps.h | 1 - >> 2 files changed, 3 insertions(+), 4 deletions(-) >> >> diff --git a/drivers/pps/pps.c b/drivers/pps/pps.c >> index 5d19baae6a38..1a6131608036 100644 >> --- a/drivers/pps/pps.c >> +++ b/drivers/pps/pps.c >> @@ -354,7 +354,7 @@ int pps_register_cdev(struct pps_device *pps) >> * Get new ID for the new PPS source. After idr_alloc() calling >> * the new source will be freely available into the kernel. >> */ >> - err = idr_alloc(&pps_idr, pps, 0, PPS_MAX_SOURCES, GFP_KERNEL); >> + err = idr_alloc(&pps_idr, pps, 0, MINORMASK, GFP_KERNEL); >> if (err < 0) { >> if (err == -ENOSPC) { >> pr_err("%s: too many PPS sources in the system\n", >> @@ -449,7 +449,7 @@ EXPORT_SYMBOL(pps_lookup_dev); >> static void __exit pps_exit(void) >> { >> class_destroy(pps_class); >> - unregister_chrdev_region(pps_devt, PPS_MAX_SOURCES); >> + unregister_chrdev_region(pps_devt, MINORMASK); >> } >> >> static int __init pps_init(void) >> @@ -463,7 +463,7 @@ static int __init pps_init(void) >> } >> pps_class->dev_groups = pps_groups; >> >> - err = alloc_chrdev_region(&pps_devt, 0, PPS_MAX_SOURCES, "pps"); >> + err = alloc_chrdev_region(&pps_devt, 0, MINORMASK, "pps"); >> if (err < 0) { >> pr_err("failed to allocate char device region\n"); >> goto remove_class; >> diff --git a/include/uapi/linux/pps.h b/include/uapi/linux/pps.h >> index 90f2e86020ba..8a4096f18af1 100644 >> --- a/include/uapi/linux/pps.h >> +++ b/include/uapi/linux/pps.h >> @@ -26,7 +26,6 @@ >> #include <linux/types.h> >> >> #define PPS_VERSION "5.3.6" >> -#define PPS_MAX_SOURCES MINORMASK > > Why change this in patch 1, and then delete this here? > > That makes no sense. I did it in two steps to be clear that the first step is about a better redefinition of the PPS_MAX_SOURCES define, while the second step is about the fact it's now that define is useless. > And if this is exported to userspace, removing it should break things, > right? If not, why was it there in the first place? In reality such define is not stated within the PPS RFC2783, so userspace programs whose relies on such define are broken. Ciao, Rodolfo
On Fri, Jun 30, 2023 at 09:50:33AM +0200, Rodolfo Giometti wrote: > On 30/06/23 09:31, Greg Kroah-Hartman wrote: > > On Fri, Jun 30, 2023 at 09:18:26AM +0200, Rodolfo Giometti wrote: > > > Userspace PPS clients should not known about how many PPS sources can > > > be defined within the system (nor the rfc2783 say so), so we can > > > safely drop this define since is not used anymore in the kernel too. > > > > > > Signed-off-by: Rodolfo Giometti <giometti@enneenne.com> > > > --- > > > drivers/pps/pps.c | 6 +++--- > > > include/uapi/linux/pps.h | 1 - > > > 2 files changed, 3 insertions(+), 4 deletions(-) > > > > > > diff --git a/drivers/pps/pps.c b/drivers/pps/pps.c > > > index 5d19baae6a38..1a6131608036 100644 > > > --- a/drivers/pps/pps.c > > > +++ b/drivers/pps/pps.c > > > @@ -354,7 +354,7 @@ int pps_register_cdev(struct pps_device *pps) > > > * Get new ID for the new PPS source. After idr_alloc() calling > > > * the new source will be freely available into the kernel. > > > */ > > > - err = idr_alloc(&pps_idr, pps, 0, PPS_MAX_SOURCES, GFP_KERNEL); > > > + err = idr_alloc(&pps_idr, pps, 0, MINORMASK, GFP_KERNEL); > > > if (err < 0) { > > > if (err == -ENOSPC) { > > > pr_err("%s: too many PPS sources in the system\n", > > > @@ -449,7 +449,7 @@ EXPORT_SYMBOL(pps_lookup_dev); > > > static void __exit pps_exit(void) > > > { > > > class_destroy(pps_class); > > > - unregister_chrdev_region(pps_devt, PPS_MAX_SOURCES); > > > + unregister_chrdev_region(pps_devt, MINORMASK); > > > } > > > static int __init pps_init(void) > > > @@ -463,7 +463,7 @@ static int __init pps_init(void) > > > } > > > pps_class->dev_groups = pps_groups; > > > - err = alloc_chrdev_region(&pps_devt, 0, PPS_MAX_SOURCES, "pps"); > > > + err = alloc_chrdev_region(&pps_devt, 0, MINORMASK, "pps"); > > > if (err < 0) { > > > pr_err("failed to allocate char device region\n"); > > > goto remove_class; > > > diff --git a/include/uapi/linux/pps.h b/include/uapi/linux/pps.h > > > index 90f2e86020ba..8a4096f18af1 100644 > > > --- a/include/uapi/linux/pps.h > > > +++ b/include/uapi/linux/pps.h > > > @@ -26,7 +26,6 @@ > > > #include <linux/types.h> > > > #define PPS_VERSION "5.3.6" > > > -#define PPS_MAX_SOURCES MINORMASK > > > > Why change this in patch 1, and then delete this here? > > > > That makes no sense. > > I did it in two steps to be clear that the first step is about a better > redefinition of the PPS_MAX_SOURCES define, while the second step is about > the fact it's now that define is useless. Better to just convert everything in patch one, and then in patch 2 delete the .h #define. That way, when userspace breaks, you can revert just the last patch :) > > And if this is exported to userspace, removing it should break things, > > right? If not, why was it there in the first place? > > In reality such define is not stated within the PPS RFC2783, so userspace > programs whose relies on such define are broken. RFC's do not document Linux kernel apis. So if any userspace code breaks, you have to put this back, sorry. thanks, greg k-h
On 30/06/23 14:53, Greg Kroah-Hartman wrote: > On Fri, Jun 30, 2023 at 09:50:33AM +0200, Rodolfo Giometti wrote: >> On 30/06/23 09:31, Greg Kroah-Hartman wrote: >>> On Fri, Jun 30, 2023 at 09:18:26AM +0200, Rodolfo Giometti wrote: >>>> Userspace PPS clients should not known about how many PPS sources can >>>> be defined within the system (nor the rfc2783 say so), so we can >>>> safely drop this define since is not used anymore in the kernel too. >>>> >>>> Signed-off-by: Rodolfo Giometti <giometti@enneenne.com> >>>> --- >>>> drivers/pps/pps.c | 6 +++--- >>>> include/uapi/linux/pps.h | 1 - >>>> 2 files changed, 3 insertions(+), 4 deletions(-) >>>> >>>> diff --git a/drivers/pps/pps.c b/drivers/pps/pps.c >>>> index 5d19baae6a38..1a6131608036 100644 >>>> --- a/drivers/pps/pps.c >>>> +++ b/drivers/pps/pps.c >>>> @@ -354,7 +354,7 @@ int pps_register_cdev(struct pps_device *pps) >>>> * Get new ID for the new PPS source. After idr_alloc() calling >>>> * the new source will be freely available into the kernel. >>>> */ >>>> - err = idr_alloc(&pps_idr, pps, 0, PPS_MAX_SOURCES, GFP_KERNEL); >>>> + err = idr_alloc(&pps_idr, pps, 0, MINORMASK, GFP_KERNEL); >>>> if (err < 0) { >>>> if (err == -ENOSPC) { >>>> pr_err("%s: too many PPS sources in the system\n", >>>> @@ -449,7 +449,7 @@ EXPORT_SYMBOL(pps_lookup_dev); >>>> static void __exit pps_exit(void) >>>> { >>>> class_destroy(pps_class); >>>> - unregister_chrdev_region(pps_devt, PPS_MAX_SOURCES); >>>> + unregister_chrdev_region(pps_devt, MINORMASK); >>>> } >>>> static int __init pps_init(void) >>>> @@ -463,7 +463,7 @@ static int __init pps_init(void) >>>> } >>>> pps_class->dev_groups = pps_groups; >>>> - err = alloc_chrdev_region(&pps_devt, 0, PPS_MAX_SOURCES, "pps"); >>>> + err = alloc_chrdev_region(&pps_devt, 0, MINORMASK, "pps"); >>>> if (err < 0) { >>>> pr_err("failed to allocate char device region\n"); >>>> goto remove_class; >>>> diff --git a/include/uapi/linux/pps.h b/include/uapi/linux/pps.h >>>> index 90f2e86020ba..8a4096f18af1 100644 >>>> --- a/include/uapi/linux/pps.h >>>> +++ b/include/uapi/linux/pps.h >>>> @@ -26,7 +26,6 @@ >>>> #include <linux/types.h> >>>> #define PPS_VERSION "5.3.6" >>>> -#define PPS_MAX_SOURCES MINORMASK >>> >>> Why change this in patch 1, and then delete this here? >>> >>> That makes no sense. >> >> I did it in two steps to be clear that the first step is about a better >> redefinition of the PPS_MAX_SOURCES define, while the second step is about >> the fact it's now that define is useless. > > Better to just convert everything in patch one, and then in patch 2 > delete the .h #define. That way, when userspace breaks, you can revert > just the last patch :) I'm puzzled since I did as you say... patch 1/2 increases PPS_MAX_SOURCES value while patch 2/2 drops PPS_MAX_SOURCES define. >>> And if this is exported to userspace, removing it should break things, >>> right? If not, why was it there in the first place? >> >> In reality such define is not stated within the PPS RFC2783, so userspace >> programs whose relies on such define are broken. > > RFC's do not document Linux kernel apis. It's true, but well written PPS clients should relay only on PPS API which in turn doesn't states that define. :P > So if any userspace code breaks, you have to put this back, sorry. If you think that patch 2 is not good, no problem, just drop it, but please just consider applying patch 1, since increasing PPS_MAX_SOURCES value is good. Ciao, Rodolfo
On Fri, Jun 30, 2023 at 03:29:50PM +0200, Rodolfo Giometti wrote: > On 30/06/23 14:53, Greg Kroah-Hartman wrote: > > On Fri, Jun 30, 2023 at 09:50:33AM +0200, Rodolfo Giometti wrote: > > > On 30/06/23 09:31, Greg Kroah-Hartman wrote: > > > > On Fri, Jun 30, 2023 at 09:18:26AM +0200, Rodolfo Giometti wrote: > > > > > Userspace PPS clients should not known about how many PPS sources can > > > > > be defined within the system (nor the rfc2783 say so), so we can > > > > > safely drop this define since is not used anymore in the kernel too. > > > > > > > > > > Signed-off-by: Rodolfo Giometti <giometti@enneenne.com> > > > > > --- > > > > > drivers/pps/pps.c | 6 +++--- > > > > > include/uapi/linux/pps.h | 1 - > > > > > 2 files changed, 3 insertions(+), 4 deletions(-) > > > > > > > > > > diff --git a/drivers/pps/pps.c b/drivers/pps/pps.c > > > > > index 5d19baae6a38..1a6131608036 100644 > > > > > --- a/drivers/pps/pps.c > > > > > +++ b/drivers/pps/pps.c > > > > > @@ -354,7 +354,7 @@ int pps_register_cdev(struct pps_device *pps) > > > > > * Get new ID for the new PPS source. After idr_alloc() calling > > > > > * the new source will be freely available into the kernel. > > > > > */ > > > > > - err = idr_alloc(&pps_idr, pps, 0, PPS_MAX_SOURCES, GFP_KERNEL); > > > > > + err = idr_alloc(&pps_idr, pps, 0, MINORMASK, GFP_KERNEL); > > > > > if (err < 0) { > > > > > if (err == -ENOSPC) { > > > > > pr_err("%s: too many PPS sources in the system\n", > > > > > @@ -449,7 +449,7 @@ EXPORT_SYMBOL(pps_lookup_dev); > > > > > static void __exit pps_exit(void) > > > > > { > > > > > class_destroy(pps_class); > > > > > - unregister_chrdev_region(pps_devt, PPS_MAX_SOURCES); > > > > > + unregister_chrdev_region(pps_devt, MINORMASK); > > > > > } > > > > > static int __init pps_init(void) > > > > > @@ -463,7 +463,7 @@ static int __init pps_init(void) > > > > > } > > > > > pps_class->dev_groups = pps_groups; > > > > > - err = alloc_chrdev_region(&pps_devt, 0, PPS_MAX_SOURCES, "pps"); > > > > > + err = alloc_chrdev_region(&pps_devt, 0, MINORMASK, "pps"); > > > > > if (err < 0) { > > > > > pr_err("failed to allocate char device region\n"); > > > > > goto remove_class; > > > > > diff --git a/include/uapi/linux/pps.h b/include/uapi/linux/pps.h > > > > > index 90f2e86020ba..8a4096f18af1 100644 > > > > > --- a/include/uapi/linux/pps.h > > > > > +++ b/include/uapi/linux/pps.h > > > > > @@ -26,7 +26,6 @@ > > > > > #include <linux/types.h> > > > > > #define PPS_VERSION "5.3.6" > > > > > -#define PPS_MAX_SOURCES MINORMASK > > > > > > > > Why change this in patch 1, and then delete this here? > > > > > > > > That makes no sense. > > > > > > I did it in two steps to be clear that the first step is about a better > > > redefinition of the PPS_MAX_SOURCES define, while the second step is about > > > the fact it's now that define is useless. > > > > Better to just convert everything in patch one, and then in patch 2 > > delete the .h #define. That way, when userspace breaks, you can revert > > just the last patch :) > > I'm puzzled since I did as you say... patch 1/2 increases PPS_MAX_SOURCES > value while patch 2/2 drops PPS_MAX_SOURCES define. Ah, I thought patch 1/2 renamed it. But why increase it if you are removing it? > > > > And if this is exported to userspace, removing it should break things, > > > > right? If not, why was it there in the first place? > > > > > > In reality such define is not stated within the PPS RFC2783, so userspace > > > programs whose relies on such define are broken. > > > > RFC's do not document Linux kernel apis. > > It's true, but well written PPS clients should relay only on PPS API which > in turn doesn't states that define. :P Are you sure? Have you audited the clients? if so, please document that in the changelog text. > > So if any userspace code breaks, you have to put this back, sorry. > > If you think that patch 2 is not good, no problem, just drop it, but please > just consider applying patch 1, since increasing PPS_MAX_SOURCES value is > good. You can't change a uapi value either without breaking things :( thanks, greg k-h
On 03/07/23 15:38, Greg Kroah-Hartman wrote: > On Fri, Jun 30, 2023 at 03:29:50PM +0200, Rodolfo Giometti wrote: >> On 30/06/23 14:53, Greg Kroah-Hartman wrote: >>> On Fri, Jun 30, 2023 at 09:50:33AM +0200, Rodolfo Giometti wrote: >>>> On 30/06/23 09:31, Greg Kroah-Hartman wrote: >>>>> On Fri, Jun 30, 2023 at 09:18:26AM +0200, Rodolfo Giometti wrote: >>>>>> Userspace PPS clients should not known about how many PPS sources can >>>>>> be defined within the system (nor the rfc2783 say so), so we can >>>>>> safely drop this define since is not used anymore in the kernel too. >>>>>> >>>>>> Signed-off-by: Rodolfo Giometti <giometti@enneenne.com> >>>>>> --- >>>>>> drivers/pps/pps.c | 6 +++--- >>>>>> include/uapi/linux/pps.h | 1 - >>>>>> 2 files changed, 3 insertions(+), 4 deletions(-) >>>>>> >>>>>> diff --git a/drivers/pps/pps.c b/drivers/pps/pps.c >>>>>> index 5d19baae6a38..1a6131608036 100644 >>>>>> --- a/drivers/pps/pps.c >>>>>> +++ b/drivers/pps/pps.c >>>>>> @@ -354,7 +354,7 @@ int pps_register_cdev(struct pps_device *pps) >>>>>> * Get new ID for the new PPS source. After idr_alloc() calling >>>>>> * the new source will be freely available into the kernel. >>>>>> */ >>>>>> - err = idr_alloc(&pps_idr, pps, 0, PPS_MAX_SOURCES, GFP_KERNEL); >>>>>> + err = idr_alloc(&pps_idr, pps, 0, MINORMASK, GFP_KERNEL); >>>>>> if (err < 0) { >>>>>> if (err == -ENOSPC) { >>>>>> pr_err("%s: too many PPS sources in the system\n", >>>>>> @@ -449,7 +449,7 @@ EXPORT_SYMBOL(pps_lookup_dev); >>>>>> static void __exit pps_exit(void) >>>>>> { >>>>>> class_destroy(pps_class); >>>>>> - unregister_chrdev_region(pps_devt, PPS_MAX_SOURCES); >>>>>> + unregister_chrdev_region(pps_devt, MINORMASK); >>>>>> } >>>>>> static int __init pps_init(void) >>>>>> @@ -463,7 +463,7 @@ static int __init pps_init(void) >>>>>> } >>>>>> pps_class->dev_groups = pps_groups; >>>>>> - err = alloc_chrdev_region(&pps_devt, 0, PPS_MAX_SOURCES, "pps"); >>>>>> + err = alloc_chrdev_region(&pps_devt, 0, MINORMASK, "pps"); >>>>>> if (err < 0) { >>>>>> pr_err("failed to allocate char device region\n"); >>>>>> goto remove_class; >>>>>> diff --git a/include/uapi/linux/pps.h b/include/uapi/linux/pps.h >>>>>> index 90f2e86020ba..8a4096f18af1 100644 >>>>>> --- a/include/uapi/linux/pps.h >>>>>> +++ b/include/uapi/linux/pps.h >>>>>> @@ -26,7 +26,6 @@ >>>>>> #include <linux/types.h> >>>>>> #define PPS_VERSION "5.3.6" >>>>>> -#define PPS_MAX_SOURCES MINORMASK >>>>> >>>>> Why change this in patch 1, and then delete this here? >>>>> >>>>> That makes no sense. >>>> >>>> I did it in two steps to be clear that the first step is about a better >>>> redefinition of the PPS_MAX_SOURCES define, while the second step is about >>>> the fact it's now that define is useless. >>> >>> Better to just convert everything in patch one, and then in patch 2 >>> delete the .h #define. That way, when userspace breaks, you can revert >>> just the last patch :) >> >> I'm puzzled since I did as you say... patch 1/2 increases PPS_MAX_SOURCES >> value while patch 2/2 drops PPS_MAX_SOURCES define. > > Ah, I thought patch 1/2 renamed it. No, patch 1/2 just safely increases PPS_MAX_SOURCES value as other drivers does. > But why increase it if you are removing it? As I said I splitted the modification in two steps just to highlight that the first step is a better redefinition of PPS_MAX_SOURCES, while the second step drops it since it's useless for userspace. As you noticed this last step is not trivial since it may breaks some userspace programs, but it's also true that RFC2783 doesn't define it, so well written userspace programs should not use that define and then they should not break at all. :) >>>>> And if this is exported to userspace, removing it should break things, >>>>> right? If not, why was it there in the first place? >>>> >>>> In reality such define is not stated within the PPS RFC2783, so userspace >>>> programs whose relies on such define are broken. >>> >>> RFC's do not document Linux kernel apis. >> >> It's true, but well written PPS clients should relay only on PPS API which >> in turn doesn't states that define. :P > > Are you sure? Have you audited the clients? if so, please document > that in the changelog text. OK, I'm going to re-write the changelog text adding this information. >>> So if any userspace code breaks, you have to put this back, sorry. >> >> If you think that patch 2 is not good, no problem, just drop it, but please >> just consider applying patch 1, since increasing PPS_MAX_SOURCES value is >> good. > > You can't change a uapi value either without breaking things :( I see, but in this case what do you suggest to do? Keeping 1/2 and dropping 2/2? Ciao, Rodolfo
On 7/3/23 09:47, Rodolfo Giometti wrote: > On 03/07/23 15:38, Greg Kroah-Hartman wrote: >> On Fri, Jun 30, 2023 at 03:29:50PM +0200, Rodolfo Giometti wrote: >>> On 30/06/23 14:53, Greg Kroah-Hartman wrote: >>>> On Fri, Jun 30, 2023 at 09:50:33AM +0200, Rodolfo Giometti wrote: >>>>> On 30/06/23 09:31, Greg Kroah-Hartman wrote: >>>>>> On Fri, Jun 30, 2023 at 09:18:26AM +0200, Rodolfo Giometti wrote: >>>>>>> Userspace PPS clients should not known about how many PPS sources can >>>>>>> be defined within the system (nor the rfc2783 say so), so we can >>>>>>> safely drop this define since is not used anymore in the kernel too. >>>>>>> >>>>>>> Signed-off-by: Rodolfo Giometti <giometti@enneenne.com> >>>>>>> --- >>>>>>> drivers/pps/pps.c | 6 +++--- >>>>>>> include/uapi/linux/pps.h | 1 - >>>>>>> 2 files changed, 3 insertions(+), 4 deletions(-) >>>>>>> >>>>>>> diff --git a/drivers/pps/pps.c b/drivers/pps/pps.c >>>>>>> index 5d19baae6a38..1a6131608036 100644 >>>>>>> --- a/drivers/pps/pps.c >>>>>>> +++ b/drivers/pps/pps.c >>>>>>> @@ -354,7 +354,7 @@ int pps_register_cdev(struct pps_device *pps) >>>>>>> * Get new ID for the new PPS source. After idr_alloc() calling >>>>>>> * the new source will be freely available into the kernel. >>>>>>> */ >>>>>>> - err = idr_alloc(&pps_idr, pps, 0, PPS_MAX_SOURCES, GFP_KERNEL); >>>>>>> + err = idr_alloc(&pps_idr, pps, 0, MINORMASK, GFP_KERNEL); >>>>>>> if (err < 0) { >>>>>>> if (err == -ENOSPC) { >>>>>>> pr_err("%s: too many PPS sources in the system\n", >>>>>>> @@ -449,7 +449,7 @@ EXPORT_SYMBOL(pps_lookup_dev); >>>>>>> static void __exit pps_exit(void) >>>>>>> { >>>>>>> class_destroy(pps_class); >>>>>>> - unregister_chrdev_region(pps_devt, PPS_MAX_SOURCES); >>>>>>> + unregister_chrdev_region(pps_devt, MINORMASK); >>>>>>> } >>>>>>> static int __init pps_init(void) >>>>>>> @@ -463,7 +463,7 @@ static int __init pps_init(void) >>>>>>> } >>>>>>> pps_class->dev_groups = pps_groups; >>>>>>> - err = alloc_chrdev_region(&pps_devt, 0, PPS_MAX_SOURCES, "pps"); >>>>>>> + err = alloc_chrdev_region(&pps_devt, 0, MINORMASK, "pps"); >>>>>>> if (err < 0) { >>>>>>> pr_err("failed to allocate char device region\n"); >>>>>>> goto remove_class; >>>>>>> diff --git a/include/uapi/linux/pps.h b/include/uapi/linux/pps.h >>>>>>> index 90f2e86020ba..8a4096f18af1 100644 >>>>>>> --- a/include/uapi/linux/pps.h >>>>>>> +++ b/include/uapi/linux/pps.h >>>>>>> @@ -26,7 +26,6 @@ >>>>>>> #include <linux/types.h> >>>>>>> #define PPS_VERSION "5.3.6" >>>>>>> -#define PPS_MAX_SOURCES MINORMASK >>>>>> >>>>>> Why change this in patch 1, and then delete this here? >>>>>> >>>>>> That makes no sense. >>>>> >>>>> I did it in two steps to be clear that the first step is about a better >>>>> redefinition of the PPS_MAX_SOURCES define, while the second step is about >>>>> the fact it's now that define is useless. >>>> >>>> Better to just convert everything in patch one, and then in patch 2 >>>> delete the .h #define. That way, when userspace breaks, you can revert >>>> just the last patch :) >>> >>> I'm puzzled since I did as you say... patch 1/2 increases PPS_MAX_SOURCES >>> value while patch 2/2 drops PPS_MAX_SOURCES define. >> >> Ah, I thought patch 1/2 renamed it. > > No, patch 1/2 just safely increases PPS_MAX_SOURCES value as other drivers does. > >> But why increase it if you are removing it? > > As I said I splitted the modification in two steps just to highlight that the first step is a better redefinition of PPS_MAX_SOURCES, while the second step drops it since it's useless for userspace. As you noticed this last step is not trivial since it may breaks some userspace programs, but it's also true that RFC2783 doesn't define it, so well written userspace programs should not use that define and then they should not break at all. :) > >>>>>> And if this is exported to userspace, removing it should break things, >>>>>> right? If not, why was it there in the first place? >>>>> >>>>> In reality such define is not stated within the PPS RFC2783, so userspace >>>>> programs whose relies on such define are broken. >>>> >>>> RFC's do not document Linux kernel apis. >>> >>> It's true, but well written PPS clients should relay only on PPS API which >>> in turn doesn't states that define. :P >> >> Are you sure? Have you audited the clients? if so, please document >> that in the changelog text. > > OK, I'm going to re-write the changelog text adding this information. > >>>> So if any userspace code breaks, you have to put this back, sorry. >>> >>> If you think that patch 2 is not good, no problem, just drop it, but please >>> just consider applying patch 1, since increasing PPS_MAX_SOURCES value is >>> good. >> >> You can't change a uapi value either without breaking things :( > > I see, but in this case what do you suggest to do? Keeping 1/2 and dropping 2/2? I'm confused here. Is the problem just that the uapi value cannot be dropped (since it is part of uapi) and only patch 1 can be applied? Or is it that the uapi value cannot be dropped OR changed so neither patch can be applied? If the latter, how would one go about raising a value like this to allow a higher limit without causing issues for existing uapi users? Regards, Charlie Johnston
On 17/07/23 17:52, Charlie Johnston wrote: > On 7/3/23 09:47, Rodolfo Giometti wrote: >> On 03/07/23 15:38, Greg Kroah-Hartman wrote: >>> On Fri, Jun 30, 2023 at 03:29:50PM +0200, Rodolfo Giometti wrote: >>>> On 30/06/23 14:53, Greg Kroah-Hartman wrote: >>>>> On Fri, Jun 30, 2023 at 09:50:33AM +0200, Rodolfo Giometti wrote: >>>>>> On 30/06/23 09:31, Greg Kroah-Hartman wrote: >>>>>>> On Fri, Jun 30, 2023 at 09:18:26AM +0200, Rodolfo Giometti wrote: >>>>>>>> Userspace PPS clients should not known about how many PPS sources can >>>>>>>> be defined within the system (nor the rfc2783 say so), so we can >>>>>>>> safely drop this define since is not used anymore in the kernel too. >>>>>>>> >>>>>>>> Signed-off-by: Rodolfo Giometti <giometti@enneenne.com> >>>>>>>> --- >>>>>>>> drivers/pps/pps.c | 6 +++--- >>>>>>>> include/uapi/linux/pps.h | 1 - >>>>>>>> 2 files changed, 3 insertions(+), 4 deletions(-) >>>>>>>> >>>>>>>> diff --git a/drivers/pps/pps.c b/drivers/pps/pps.c >>>>>>>> index 5d19baae6a38..1a6131608036 100644 >>>>>>>> --- a/drivers/pps/pps.c >>>>>>>> +++ b/drivers/pps/pps.c >>>>>>>> @@ -354,7 +354,7 @@ int pps_register_cdev(struct pps_device *pps) >>>>>>>> * Get new ID for the new PPS source. After idr_alloc() calling >>>>>>>> * the new source will be freely available into the kernel. >>>>>>>> */ >>>>>>>> - err = idr_alloc(&pps_idr, pps, 0, PPS_MAX_SOURCES, GFP_KERNEL); >>>>>>>> + err = idr_alloc(&pps_idr, pps, 0, MINORMASK, GFP_KERNEL); >>>>>>>> if (err < 0) { >>>>>>>> if (err == -ENOSPC) { >>>>>>>> pr_err("%s: too many PPS sources in the system\n", >>>>>>>> @@ -449,7 +449,7 @@ EXPORT_SYMBOL(pps_lookup_dev); >>>>>>>> static void __exit pps_exit(void) >>>>>>>> { >>>>>>>> class_destroy(pps_class); >>>>>>>> - unregister_chrdev_region(pps_devt, PPS_MAX_SOURCES); >>>>>>>> + unregister_chrdev_region(pps_devt, MINORMASK); >>>>>>>> } >>>>>>>> static int __init pps_init(void) >>>>>>>> @@ -463,7 +463,7 @@ static int __init pps_init(void) >>>>>>>> } >>>>>>>> pps_class->dev_groups = pps_groups; >>>>>>>> - err = alloc_chrdev_region(&pps_devt, 0, PPS_MAX_SOURCES, "pps"); >>>>>>>> + err = alloc_chrdev_region(&pps_devt, 0, MINORMASK, "pps"); >>>>>>>> if (err < 0) { >>>>>>>> pr_err("failed to allocate char device region\n"); >>>>>>>> goto remove_class; >>>>>>>> diff --git a/include/uapi/linux/pps.h b/include/uapi/linux/pps.h >>>>>>>> index 90f2e86020ba..8a4096f18af1 100644 >>>>>>>> --- a/include/uapi/linux/pps.h >>>>>>>> +++ b/include/uapi/linux/pps.h >>>>>>>> @@ -26,7 +26,6 @@ >>>>>>>> #include <linux/types.h> >>>>>>>> #define PPS_VERSION "5.3.6" >>>>>>>> -#define PPS_MAX_SOURCES MINORMASK >>>>>>> >>>>>>> Why change this in patch 1, and then delete this here? >>>>>>> >>>>>>> That makes no sense. >>>>>> >>>>>> I did it in two steps to be clear that the first step is about a better >>>>>> redefinition of the PPS_MAX_SOURCES define, while the second step is about >>>>>> the fact it's now that define is useless. >>>>> >>>>> Better to just convert everything in patch one, and then in patch 2 >>>>> delete the .h #define. That way, when userspace breaks, you can revert >>>>> just the last patch :) >>>> >>>> I'm puzzled since I did as you say... patch 1/2 increases PPS_MAX_SOURCES >>>> value while patch 2/2 drops PPS_MAX_SOURCES define. >>> >>> Ah, I thought patch 1/2 renamed it. >> >> No, patch 1/2 just safely increases PPS_MAX_SOURCES value as other drivers does. >> >>> But why increase it if you are removing it? >> >> As I said I splitted the modification in two steps just to highlight that the first step is a better redefinition of PPS_MAX_SOURCES, while the second step drops it since it's useless for userspace. As you noticed this last step is not trivial since it may breaks some userspace programs, but it's also true that RFC2783 doesn't define it, so well written userspace programs should not use that define and then they should not break at all. :) >> >>>>>>> And if this is exported to userspace, removing it should break things, >>>>>>> right? If not, why was it there in the first place? >>>>>> >>>>>> In reality such define is not stated within the PPS RFC2783, so userspace >>>>>> programs whose relies on such define are broken. >>>>> >>>>> RFC's do not document Linux kernel apis. >>>> >>>> It's true, but well written PPS clients should relay only on PPS API which >>>> in turn doesn't states that define. :P >>> >>> Are you sure? Have you audited the clients? if so, please document >>> that in the changelog text. >> >> OK, I'm going to re-write the changelog text adding this information. >> >>>>> So if any userspace code breaks, you have to put this back, sorry. >>>> >>>> If you think that patch 2 is not good, no problem, just drop it, but please >>>> just consider applying patch 1, since increasing PPS_MAX_SOURCES value is >>>> good. >>> >>> You can't change a uapi value either without breaking things :( >> >> I see, but in this case what do you suggest to do? Keeping 1/2 and dropping 2/2? > > I'm confused here. Is the problem just that the uapi value cannot be dropped (since it is part of uapi) and only patch 1 can be applied? Yes. > Or is it that the uapi value cannot be dropped OR changed so neither patch can be applied? No. > If the latter, how would one go about raising a value like this to allow a higher limit without causing issues for existing uapi users? My opinion is that both patches should be applied since, the first one just increases the value of possible PPS sources, while the second just drops a define that userspace tools should NOT use since RFC 2783 - Pulse-Per-Second API for UNIX-like Operating Systems doesn't define it. Is some userspace tool breaks, it should be fixed. Ciao, Rodolfo
On 7/18/23 02:47, Rodolfo Giometti wrote: > On 17/07/23 17:52, Charlie Johnston wrote: >> On 7/3/23 09:47, Rodolfo Giometti wrote: >>> On 03/07/23 15:38, Greg Kroah-Hartman wrote: >>>> On Fri, Jun 30, 2023 at 03:29:50PM +0200, Rodolfo Giometti wrote: >>>>> On 30/06/23 14:53, Greg Kroah-Hartman wrote: >>>>>> On Fri, Jun 30, 2023 at 09:50:33AM +0200, Rodolfo Giometti wrote: >>>>>>> On 30/06/23 09:31, Greg Kroah-Hartman wrote: >>>>>>>> On Fri, Jun 30, 2023 at 09:18:26AM +0200, Rodolfo Giometti wrote: >>>>>>>>> Userspace PPS clients should not known about how many PPS sources can >>>>>>>>> be defined within the system (nor the rfc2783 say so), so we can >>>>>>>>> safely drop this define since is not used anymore in the kernel too. >>>>>>>>> >>>>>>>>> Signed-off-by: Rodolfo Giometti <giometti@enneenne.com> >>>>>>>>> --- >>>>>>>>> drivers/pps/pps.c | 6 +++--- >>>>>>>>> include/uapi/linux/pps.h | 1 - >>>>>>>>> 2 files changed, 3 insertions(+), 4 deletions(-) >>>>>>>>> >>>>>>>>> diff --git a/drivers/pps/pps.c b/drivers/pps/pps.c >>>>>>>>> index 5d19baae6a38..1a6131608036 100644 >>>>>>>>> --- a/drivers/pps/pps.c >>>>>>>>> +++ b/drivers/pps/pps.c >>>>>>>>> @@ -354,7 +354,7 @@ int pps_register_cdev(struct pps_device *pps) >>>>>>>>> * Get new ID for the new PPS source. After idr_alloc() calling >>>>>>>>> * the new source will be freely available into the kernel. >>>>>>>>> */ >>>>>>>>> - err = idr_alloc(&pps_idr, pps, 0, PPS_MAX_SOURCES, GFP_KERNEL); >>>>>>>>> + err = idr_alloc(&pps_idr, pps, 0, MINORMASK, GFP_KERNEL); >>>>>>>>> if (err < 0) { >>>>>>>>> if (err == -ENOSPC) { >>>>>>>>> pr_err("%s: too many PPS sources in the system\n", >>>>>>>>> @@ -449,7 +449,7 @@ EXPORT_SYMBOL(pps_lookup_dev); >>>>>>>>> static void __exit pps_exit(void) >>>>>>>>> { >>>>>>>>> class_destroy(pps_class); >>>>>>>>> - unregister_chrdev_region(pps_devt, PPS_MAX_SOURCES); >>>>>>>>> + unregister_chrdev_region(pps_devt, MINORMASK); >>>>>>>>> } >>>>>>>>> static int __init pps_init(void) >>>>>>>>> @@ -463,7 +463,7 @@ static int __init pps_init(void) >>>>>>>>> } >>>>>>>>> pps_class->dev_groups = pps_groups; >>>>>>>>> - err = alloc_chrdev_region(&pps_devt, 0, PPS_MAX_SOURCES, "pps"); >>>>>>>>> + err = alloc_chrdev_region(&pps_devt, 0, MINORMASK, "pps"); >>>>>>>>> if (err < 0) { >>>>>>>>> pr_err("failed to allocate char device region\n"); >>>>>>>>> goto remove_class; >>>>>>>>> diff --git a/include/uapi/linux/pps.h b/include/uapi/linux/pps.h >>>>>>>>> index 90f2e86020ba..8a4096f18af1 100644 >>>>>>>>> --- a/include/uapi/linux/pps.h >>>>>>>>> +++ b/include/uapi/linux/pps.h >>>>>>>>> @@ -26,7 +26,6 @@ >>>>>>>>> #include <linux/types.h> >>>>>>>>> #define PPS_VERSION "5.3.6" >>>>>>>>> -#define PPS_MAX_SOURCES MINORMASK >>>>>>>> >>>>>>>> Why change this in patch 1, and then delete this here? >>>>>>>> >>>>>>>> That makes no sense. >>>>>>> >>>>>>> I did it in two steps to be clear that the first step is about a better >>>>>>> redefinition of the PPS_MAX_SOURCES define, while the second step is about >>>>>>> the fact it's now that define is useless. >>>>>> >>>>>> Better to just convert everything in patch one, and then in patch 2 >>>>>> delete the .h #define. That way, when userspace breaks, you can revert >>>>>> just the last patch :) >>>>> >>>>> I'm puzzled since I did as you say... patch 1/2 increases PPS_MAX_SOURCES >>>>> value while patch 2/2 drops PPS_MAX_SOURCES define. >>>> >>>> Ah, I thought patch 1/2 renamed it. >>> >>> No, patch 1/2 just safely increases PPS_MAX_SOURCES value as other drivers does. >>> >>>> But why increase it if you are removing it? >>> >>> As I said I splitted the modification in two steps just to highlight that the first step is a better redefinition of PPS_MAX_SOURCES, while the second step drops it since it's useless for userspace. As you noticed this last step is not trivial since it may breaks some userspace programs, but it's also true that RFC2783 doesn't define it, so well written userspace programs should not use that define and then they should not break at all. :) >>> >>>>>>>> And if this is exported to userspace, removing it should break things, >>>>>>>> right? If not, why was it there in the first place? >>>>>>> >>>>>>> In reality such define is not stated within the PPS RFC2783, so userspace >>>>>>> programs whose relies on such define are broken. >>>>>> >>>>>> RFC's do not document Linux kernel apis. >>>>> >>>>> It's true, but well written PPS clients should relay only on PPS API which >>>>> in turn doesn't states that define. :P >>>> >>>> Are you sure? Have you audited the clients? if so, please document >>>> that in the changelog text. >>> >>> OK, I'm going to re-write the changelog text adding this information. >>> >>>>>> So if any userspace code breaks, you have to put this back, sorry. >>>>> >>>>> If you think that patch 2 is not good, no problem, just drop it, but please >>>>> just consider applying patch 1, since increasing PPS_MAX_SOURCES value is >>>>> good. >>>> >>>> You can't change a uapi value either without breaking things :( >>> >>> I see, but in this case what do you suggest to do? Keeping 1/2 and dropping 2/2? >> >> I'm confused here. Is the problem just that the uapi value cannot be dropped (since it is part of uapi) and only patch 1 can be applied? > > Yes. > >> Or is it that the uapi value cannot be dropped OR changed so neither patch can be applied? > > No. > >> If the latter, how would one go about raising a value like this to allow a higher limit without causing issues for existing uapi users? > > My opinion is that both patches should be applied since, the first one just increases the value of possible PPS sources, while the second just drops a define that userspace tools should NOT use since RFC 2783 - Pulse-Per-Second API for UNIX-like Operating Systems doesn't define it. > > Is some userspace tool breaks, it should be fixed. > > Ciao, > > Rodolfo > Hi Rodolfo, Is there any other testing or help I can provide for this patch set? Thanks! Charlie Johnston
On 08/08/23 19:58, Charlie Johnston wrote: > On 7/18/23 02:47, Rodolfo Giometti wrote: >> On 17/07/23 17:52, Charlie Johnston wrote: >>> On 7/3/23 09:47, Rodolfo Giometti wrote: >>>> On 03/07/23 15:38, Greg Kroah-Hartman wrote: >>>>> On Fri, Jun 30, 2023 at 03:29:50PM +0200, Rodolfo Giometti wrote: >>>>>> On 30/06/23 14:53, Greg Kroah-Hartman wrote: >>>>>>> On Fri, Jun 30, 2023 at 09:50:33AM +0200, Rodolfo Giometti wrote: >>>>>>>> On 30/06/23 09:31, Greg Kroah-Hartman wrote: >>>>>>>>> On Fri, Jun 30, 2023 at 09:18:26AM +0200, Rodolfo Giometti wrote: >>>>>>>>>> Userspace PPS clients should not known about how many PPS sources can >>>>>>>>>> be defined within the system (nor the rfc2783 say so), so we can >>>>>>>>>> safely drop this define since is not used anymore in the kernel too. >>>>>>>>>> >>>>>>>>>> Signed-off-by: Rodolfo Giometti <giometti@enneenne.com> >>>>>>>>>> --- >>>>>>>>>> drivers/pps/pps.c | 6 +++--- >>>>>>>>>> include/uapi/linux/pps.h | 1 - >>>>>>>>>> 2 files changed, 3 insertions(+), 4 deletions(-) >>>>>>>>>> >>>>>>>>>> diff --git a/drivers/pps/pps.c b/drivers/pps/pps.c >>>>>>>>>> index 5d19baae6a38..1a6131608036 100644 >>>>>>>>>> --- a/drivers/pps/pps.c >>>>>>>>>> +++ b/drivers/pps/pps.c >>>>>>>>>> @@ -354,7 +354,7 @@ int pps_register_cdev(struct pps_device *pps) >>>>>>>>>> * Get new ID for the new PPS source. After idr_alloc() calling >>>>>>>>>> * the new source will be freely available into the kernel. >>>>>>>>>> */ >>>>>>>>>> - err = idr_alloc(&pps_idr, pps, 0, PPS_MAX_SOURCES, GFP_KERNEL); >>>>>>>>>> + err = idr_alloc(&pps_idr, pps, 0, MINORMASK, GFP_KERNEL); >>>>>>>>>> if (err < 0) { >>>>>>>>>> if (err == -ENOSPC) { >>>>>>>>>> pr_err("%s: too many PPS sources in the system\n", >>>>>>>>>> @@ -449,7 +449,7 @@ EXPORT_SYMBOL(pps_lookup_dev); >>>>>>>>>> static void __exit pps_exit(void) >>>>>>>>>> { >>>>>>>>>> class_destroy(pps_class); >>>>>>>>>> - unregister_chrdev_region(pps_devt, PPS_MAX_SOURCES); >>>>>>>>>> + unregister_chrdev_region(pps_devt, MINORMASK); >>>>>>>>>> } >>>>>>>>>> static int __init pps_init(void) >>>>>>>>>> @@ -463,7 +463,7 @@ static int __init pps_init(void) >>>>>>>>>> } >>>>>>>>>> pps_class->dev_groups = pps_groups; >>>>>>>>>> - err = alloc_chrdev_region(&pps_devt, 0, PPS_MAX_SOURCES, "pps"); >>>>>>>>>> + err = alloc_chrdev_region(&pps_devt, 0, MINORMASK, "pps"); >>>>>>>>>> if (err < 0) { >>>>>>>>>> pr_err("failed to allocate char device region\n"); >>>>>>>>>> goto remove_class; >>>>>>>>>> diff --git a/include/uapi/linux/pps.h b/include/uapi/linux/pps.h >>>>>>>>>> index 90f2e86020ba..8a4096f18af1 100644 >>>>>>>>>> --- a/include/uapi/linux/pps.h >>>>>>>>>> +++ b/include/uapi/linux/pps.h >>>>>>>>>> @@ -26,7 +26,6 @@ >>>>>>>>>> #include <linux/types.h> >>>>>>>>>> #define PPS_VERSION "5.3.6" >>>>>>>>>> -#define PPS_MAX_SOURCES MINORMASK >>>>>>>>> >>>>>>>>> Why change this in patch 1, and then delete this here? >>>>>>>>> >>>>>>>>> That makes no sense. >>>>>>>> >>>>>>>> I did it in two steps to be clear that the first step is about a better >>>>>>>> redefinition of the PPS_MAX_SOURCES define, while the second step is about >>>>>>>> the fact it's now that define is useless. >>>>>>> >>>>>>> Better to just convert everything in patch one, and then in patch 2 >>>>>>> delete the .h #define. That way, when userspace breaks, you can revert >>>>>>> just the last patch :) >>>>>> >>>>>> I'm puzzled since I did as you say... patch 1/2 increases PPS_MAX_SOURCES >>>>>> value while patch 2/2 drops PPS_MAX_SOURCES define. >>>>> >>>>> Ah, I thought patch 1/2 renamed it. >>>> >>>> No, patch 1/2 just safely increases PPS_MAX_SOURCES value as other drivers does. >>>> >>>>> But why increase it if you are removing it? >>>> >>>> As I said I splitted the modification in two steps just to highlight that the first step is a better redefinition of PPS_MAX_SOURCES, while the second step drops it since it's useless for userspace. As you noticed this last step is not trivial since it may breaks some userspace programs, but it's also true that RFC2783 doesn't define it, so well written userspace programs should not use that define and then they should not break at all. :) >>>> >>>>>>>>> And if this is exported to userspace, removing it should break things, >>>>>>>>> right? If not, why was it there in the first place? >>>>>>>> >>>>>>>> In reality such define is not stated within the PPS RFC2783, so userspace >>>>>>>> programs whose relies on such define are broken. >>>>>>> >>>>>>> RFC's do not document Linux kernel apis. >>>>>> >>>>>> It's true, but well written PPS clients should relay only on PPS API which >>>>>> in turn doesn't states that define. :P >>>>> >>>>> Are you sure? Have you audited the clients? if so, please document >>>>> that in the changelog text. >>>> >>>> OK, I'm going to re-write the changelog text adding this information. >>>> >>>>>>> So if any userspace code breaks, you have to put this back, sorry. >>>>>> >>>>>> If you think that patch 2 is not good, no problem, just drop it, but please >>>>>> just consider applying patch 1, since increasing PPS_MAX_SOURCES value is >>>>>> good. >>>>> >>>>> You can't change a uapi value either without breaking things :( >>>> >>>> I see, but in this case what do you suggest to do? Keeping 1/2 and dropping 2/2? >>> >>> I'm confused here. Is the problem just that the uapi value cannot be dropped (since it is part of uapi) and only patch 1 can be applied? >> >> Yes. >> >>> Or is it that the uapi value cannot be dropped OR changed so neither patch can be applied? >> >> No. >> >>> If the latter, how would one go about raising a value like this to allow a higher limit without causing issues for existing uapi users? >> >> My opinion is that both patches should be applied since, the first one just increases the value of possible PPS sources, while the second just drops a define that userspace tools should NOT use since RFC 2783 - Pulse-Per-Second API for UNIX-like Operating Systems doesn't define it. >> >> Is some userspace tool breaks, it should be fixed. >> >> Ciao, >> >> Rodolfo >> > > Hi Rodolfo, > > Is there any other testing or help I can provide for this patch set? I don't think so... I'll to ask to Greg to just apply the first patch and drop the second one. Ciao, Rodolfo
diff --git a/drivers/pps/pps.c b/drivers/pps/pps.c index 5d19baae6a38..1a6131608036 100644 --- a/drivers/pps/pps.c +++ b/drivers/pps/pps.c @@ -354,7 +354,7 @@ int pps_register_cdev(struct pps_device *pps) * Get new ID for the new PPS source. After idr_alloc() calling * the new source will be freely available into the kernel. */ - err = idr_alloc(&pps_idr, pps, 0, PPS_MAX_SOURCES, GFP_KERNEL); + err = idr_alloc(&pps_idr, pps, 0, MINORMASK, GFP_KERNEL); if (err < 0) { if (err == -ENOSPC) { pr_err("%s: too many PPS sources in the system\n", @@ -449,7 +449,7 @@ EXPORT_SYMBOL(pps_lookup_dev); static void __exit pps_exit(void) { class_destroy(pps_class); - unregister_chrdev_region(pps_devt, PPS_MAX_SOURCES); + unregister_chrdev_region(pps_devt, MINORMASK); } static int __init pps_init(void) @@ -463,7 +463,7 @@ static int __init pps_init(void) } pps_class->dev_groups = pps_groups; - err = alloc_chrdev_region(&pps_devt, 0, PPS_MAX_SOURCES, "pps"); + err = alloc_chrdev_region(&pps_devt, 0, MINORMASK, "pps"); if (err < 0) { pr_err("failed to allocate char device region\n"); goto remove_class; diff --git a/include/uapi/linux/pps.h b/include/uapi/linux/pps.h index 90f2e86020ba..8a4096f18af1 100644 --- a/include/uapi/linux/pps.h +++ b/include/uapi/linux/pps.h @@ -26,7 +26,6 @@ #include <linux/types.h> #define PPS_VERSION "5.3.6" -#define PPS_MAX_SOURCES MINORMASK /* Implementation note: the logical states ``assert'' and ``clear'' * are implemented in terms of the chip register, i.e. ``assert''