LKML Archive mirror
 help / color / mirror / Atom feed
* [RFC PATCH] pps: Increase PPS_MAX_SOURCES value.
@ 2023-06-05 20:31 Charlie Johnston
  2023-06-07  7:33 ` Rodolfo Giometti
  0 siblings, 1 reply; 9+ messages in thread
From: Charlie Johnston @ 2023-06-05 20:31 UTC (permalink / raw)
  To: giometti; +Cc: linux-kernel, brenda.streiff, Charlie Johnston

For consistency with what ptp uses for minors, this
change sets PPS_MAX_SOURCES to MINORMASK + 1.

The PPS_MAX_SOURCES value is currently set to 16. In
some cases this was not sufficient for a system. For
example, a system with multiple (4+) PCIe cards each
with 4 PTP-capable ethernet interfaces could run out
of the available PPS major:minors if each interface
registers a PPS source.

Signed-off-by: Charlie Johnston <charlie.johnston@ni.com>
---
 include/uapi/linux/pps.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/uapi/linux/pps.h b/include/uapi/linux/pps.h
index 009ebcd8ced5..85f472330da8 100644
--- a/include/uapi/linux/pps.h
+++ b/include/uapi/linux/pps.h
@@ -26,7 +26,7 @@
 #include <linux/types.h>
 
 #define PPS_VERSION		"5.3.6"
-#define PPS_MAX_SOURCES		16		/* should be enough... */
+#define PPS_MAX_SOURCES		(MINORMASK + 1)
 
 /* Implementation note: the logical states ``assert'' and ``clear''
  * are implemented in terms of the chip register, i.e. ``assert''
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [RFC PATCH] pps: Increase PPS_MAX_SOURCES value.
  2023-06-05 20:31 [RFC PATCH] pps: Increase PPS_MAX_SOURCES value Charlie Johnston
@ 2023-06-07  7:33 ` Rodolfo Giometti
  2023-06-07 22:07   ` Charlie Johnston
  0 siblings, 1 reply; 9+ messages in thread
From: Rodolfo Giometti @ 2023-06-07  7:33 UTC (permalink / raw)
  To: Charlie Johnston; +Cc: linux-kernel, brenda.streiff

On 05/06/23 22:31, Charlie Johnston wrote:
> For consistency with what ptp uses for minors, this
> change sets PPS_MAX_SOURCES to MINORMASK + 1.
> 
> The PPS_MAX_SOURCES value is currently set to 16. In
> some cases this was not sufficient for a system. For
> example, a system with multiple (4+) PCIe cards each
> with 4 PTP-capable ethernet interfaces could run out
> of the available PPS major:minors if each interface
> registers a PPS source.
> 
> Signed-off-by: Charlie Johnston <charlie.johnston@ni.com>
> ---
>   include/uapi/linux/pps.h | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/include/uapi/linux/pps.h b/include/uapi/linux/pps.h
> index 009ebcd8ced5..85f472330da8 100644
> --- a/include/uapi/linux/pps.h
> +++ b/include/uapi/linux/pps.h
> @@ -26,7 +26,7 @@
>   #include <linux/types.h>
>   
>   #define PPS_VERSION		"5.3.6"
> -#define PPS_MAX_SOURCES		16		/* should be enough... */
> +#define PPS_MAX_SOURCES		(MINORMASK + 1)
>   
>   /* Implementation note: the logical states ``assert'' and ``clear''
>    * are implemented in terms of the chip register, i.e. ``assert''

I have just one question: are you sure that it's safe to call idr_alloc(..., 0, 
(MINORMASK + 1), ...)?

Ciao,

Rodolfo

-- 
GNU/Linux Solutions                  e-mail: giometti@enneenne.com
Linux Device Driver                          giometti@linux.it
Embedded Systems                     phone:  +39 349 2432127
UNIX programming                     skype:  rodolfo.giometti


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [RFC PATCH] pps: Increase PPS_MAX_SOURCES value.
  2023-06-07  7:33 ` Rodolfo Giometti
@ 2023-06-07 22:07   ` Charlie Johnston
  2023-06-09  7:30     ` Rodolfo Giometti
  0 siblings, 1 reply; 9+ messages in thread
From: Charlie Johnston @ 2023-06-07 22:07 UTC (permalink / raw)
  To: Rodolfo Giometti; +Cc: linux-kernel, brenda.streiff

On 6/7/23 02:33, Rodolfo Giometti wrote:
> On 05/06/23 22:31, Charlie Johnston wrote:
>> For consistency with what ptp uses for minors, this
>> change sets PPS_MAX_SOURCES to MINORMASK + 1.
>>
>> The PPS_MAX_SOURCES value is currently set to 16. In
>> some cases this was not sufficient for a system. For
>> example, a system with multiple (4+) PCIe cards each
>> with 4 PTP-capable ethernet interfaces could run out
>> of the available PPS major:minors if each interface
>> registers a PPS source.
>>
>> Signed-off-by: Charlie Johnston <charlie.johnston@ni.com>
>> ---
>>   include/uapi/linux/pps.h | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/include/uapi/linux/pps.h b/include/uapi/linux/pps.h
>> index 009ebcd8ced5..85f472330da8 100644
>> --- a/include/uapi/linux/pps.h
>> +++ b/include/uapi/linux/pps.h
>> @@ -26,7 +26,7 @@
>>   #include <linux/types.h>
>>     #define PPS_VERSION        "5.3.6"
>> -#define PPS_MAX_SOURCES        16        /* should be enough... */
>> +#define PPS_MAX_SOURCES        (MINORMASK + 1)
>>     /* Implementation note: the logical states ``assert'' and ``clear''
>>    * are implemented in terms of the chip register, i.e. ``assert''
> 
> I have just one question: are you sure that it's safe to call idr_alloc(..., 0, (MINORMASK + 1), ...)?
> 
> Ciao,
> 
> Rodolfo
> 

Thanks for taking a look!

My understanding is that idr_alloc(..., start, end, ...) can take any end value up to INT_MAX. It also handles any values <= 0 by treating them as equal to INT_MAX + 1 since the end value is non-inclusive. I can't think of any reason using MINORMASK + 1 here would be an issue since it's much less than the maximum value idr_alloc() allows.

A number of drivers (e.g. ptp) just explicitly use a start and end value of 0, but I don't think that change would fit here.

Regards,
Charlie

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [RFC PATCH] pps: Increase PPS_MAX_SOURCES value.
  2023-06-07 22:07   ` Charlie Johnston
@ 2023-06-09  7:30     ` Rodolfo Giometti
  2023-06-09 21:00       ` Charlie Johnston
  0 siblings, 1 reply; 9+ messages in thread
From: Rodolfo Giometti @ 2023-06-09  7:30 UTC (permalink / raw)
  To: Charlie Johnston; +Cc: linux-kernel, brenda.streiff

On 08/06/23 00:07, Charlie Johnston wrote:
> On 6/7/23 02:33, Rodolfo Giometti wrote:
>> On 05/06/23 22:31, Charlie Johnston wrote:
>>> For consistency with what ptp uses for minors, this
>>> change sets PPS_MAX_SOURCES to MINORMASK + 1.
>>>
>>> The PPS_MAX_SOURCES value is currently set to 16. In
>>> some cases this was not sufficient for a system. For
>>> example, a system with multiple (4+) PCIe cards each
>>> with 4 PTP-capable ethernet interfaces could run out
>>> of the available PPS major:minors if each interface
>>> registers a PPS source.
>>>
>>> Signed-off-by: Charlie Johnston <charlie.johnston@ni.com>
>>> ---
>>>    include/uapi/linux/pps.h | 2 +-
>>>    1 file changed, 1 insertion(+), 1 deletion(-)
>>>
>>> diff --git a/include/uapi/linux/pps.h b/include/uapi/linux/pps.h
>>> index 009ebcd8ced5..85f472330da8 100644
>>> --- a/include/uapi/linux/pps.h
>>> +++ b/include/uapi/linux/pps.h
>>> @@ -26,7 +26,7 @@
>>>    #include <linux/types.h>
>>>      #define PPS_VERSION        "5.3.6"
>>> -#define PPS_MAX_SOURCES        16        /* should be enough... */
>>> +#define PPS_MAX_SOURCES        (MINORMASK + 1)
>>>      /* Implementation note: the logical states ``assert'' and ``clear''
>>>     * are implemented in terms of the chip register, i.e. ``assert''
>>
>> I have just one question: are you sure that it's safe to call idr_alloc(..., 0, (MINORMASK + 1), ...)?
>>
>> Ciao,
>>
>> Rodolfo
>>
> 
> Thanks for taking a look!
> 
> My understanding is that idr_alloc(..., start, end, ...) can take any end value up to INT_MAX. It also handles any values <= 0 by treating them as equal to INT_MAX + 1 since the end value is non-inclusive. I can't think of any reason using MINORMASK + 1 here would be an issue since it's much less than the maximum value idr_alloc() allows.
> 
> A number of drivers (e.g. ptp) just explicitly use a start and end value of 0, but I don't think that change would fit here.

I see and maybe I should replace the usage of idr_*() with ida_*() as PTP does...

However the right-thing(TM) to do here should be dropping PPS_MAX_SOURCES at all!

Let me go deeper in this issue. I'm going to produce a patch set in next days. 
Have you any chances to test it?

Ciao,

Rodolfo

-- 
GNU/Linux Solutions                  e-mail: giometti@enneenne.com
Linux Device Driver                          giometti@linux.it
Embedded Systems                     phone:  +39 349 2432127
UNIX programming                     skype:  rodolfo.giometti


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [RFC PATCH] pps: Increase PPS_MAX_SOURCES value.
  2023-06-09  7:30     ` Rodolfo Giometti
@ 2023-06-09 21:00       ` Charlie Johnston
  2023-06-12 16:07         ` Rodolfo Giometti
  0 siblings, 1 reply; 9+ messages in thread
From: Charlie Johnston @ 2023-06-09 21:00 UTC (permalink / raw)
  To: Rodolfo Giometti; +Cc: linux-kernel, brenda.streiff

On 6/9/23 02:30, Rodolfo Giometti wrote:
> On 08/06/23 00:07, Charlie Johnston wrote:
>> On 6/7/23 02:33, Rodolfo Giometti wrote:
>>> On 05/06/23 22:31, Charlie Johnston wrote:
>>>> For consistency with what ptp uses for minors, this
>>>> change sets PPS_MAX_SOURCES to MINORMASK + 1.
>>>>
>>>> The PPS_MAX_SOURCES value is currently set to 16. In
>>>> some cases this was not sufficient for a system. For
>>>> example, a system with multiple (4+) PCIe cards each
>>>> with 4 PTP-capable ethernet interfaces could run out
>>>> of the available PPS major:minors if each interface
>>>> registers a PPS source.
>>>>
>>>> Signed-off-by: Charlie Johnston <charlie.johnston@ni.com>
>>>> ---
>>>>    include/uapi/linux/pps.h | 2 +-
>>>>    1 file changed, 1 insertion(+), 1 deletion(-)
>>>>
>>>> diff --git a/include/uapi/linux/pps.h b/include/uapi/linux/pps.h
>>>> index 009ebcd8ced5..85f472330da8 100644
>>>> --- a/include/uapi/linux/pps.h
>>>> +++ b/include/uapi/linux/pps.h
>>>> @@ -26,7 +26,7 @@
>>>>    #include <linux/types.h>
>>>>      #define PPS_VERSION        "5.3.6"
>>>> -#define PPS_MAX_SOURCES        16        /* should be enough... */
>>>> +#define PPS_MAX_SOURCES        (MINORMASK + 1)
>>>>      /* Implementation note: the logical states ``assert'' and ``clear''
>>>>     * are implemented in terms of the chip register, i.e. ``assert''
>>>
>>> I have just one question: are you sure that it's safe to call idr_alloc(..., 0, (MINORMASK + 1), ...)?
>>>
>>> Ciao,
>>>
>>> Rodolfo
>>>
>>
>> Thanks for taking a look!
>>
>> My understanding is that idr_alloc(..., start, end, ...) can take any end value up to INT_MAX. It also handles any values <= 0 by treating them as equal to INT_MAX + 1 since the end value is non-inclusive. I can't think of any reason using MINORMASK + 1 here would be an issue since it's much less than the maximum value idr_alloc() allows.
>>
>> A number of drivers (e.g. ptp) just explicitly use a start and end value of 0, but I don't think that change would fit here.
> 
> I see and maybe I should replace the usage of idr_*() with ida_*() as PTP does...
> 
> However the right-thing(TM) to do here should be dropping PPS_MAX_SOURCES at all!
> 
> Let me go deeper in this issue. I'm going to produce a patch set in next days. Have you any chances to test it?
> 
> Ciao,
> 
> Rodolfo
> 

I'll have to check when the system we used for testing is available again (not easy to find a system with 20+ Ethernet ports) but I'd be happy to test a patch!

I know an increase to PPS_MAX_SOURCES was tested on that system.

Thanks,
Charlie

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [RFC PATCH] pps: Increase PPS_MAX_SOURCES value.
  2023-06-09 21:00       ` Charlie Johnston
@ 2023-06-12 16:07         ` Rodolfo Giometti
  2023-06-20 20:42           ` Charlie Johnston
  0 siblings, 1 reply; 9+ messages in thread
From: Rodolfo Giometti @ 2023-06-12 16:07 UTC (permalink / raw)
  To: Charlie Johnston; +Cc: linux-kernel, brenda.streiff

On 09/06/23 23:00, Charlie Johnston wrote:
> On 6/9/23 02:30, Rodolfo Giometti wrote:
>> On 08/06/23 00:07, Charlie Johnston wrote:
>>> On 6/7/23 02:33, Rodolfo Giometti wrote:
>>>> On 05/06/23 22:31, Charlie Johnston wrote:
>>>>> For consistency with what ptp uses for minors, this
>>>>> change sets PPS_MAX_SOURCES to MINORMASK + 1.
>>>>>
>>>>> The PPS_MAX_SOURCES value is currently set to 16. In
>>>>> some cases this was not sufficient for a system. For
>>>>> example, a system with multiple (4+) PCIe cards each
>>>>> with 4 PTP-capable ethernet interfaces could run out
>>>>> of the available PPS major:minors if each interface
>>>>> registers a PPS source.
>>>>>
>>>>> Signed-off-by: Charlie Johnston <charlie.johnston@ni.com>
>>>>> ---
>>>>>     include/uapi/linux/pps.h | 2 +-
>>>>>     1 file changed, 1 insertion(+), 1 deletion(-)
>>>>>
>>>>> diff --git a/include/uapi/linux/pps.h b/include/uapi/linux/pps.h
>>>>> index 009ebcd8ced5..85f472330da8 100644
>>>>> --- a/include/uapi/linux/pps.h
>>>>> +++ b/include/uapi/linux/pps.h
>>>>> @@ -26,7 +26,7 @@
>>>>>     #include <linux/types.h>
>>>>>       #define PPS_VERSION        "5.3.6"
>>>>> -#define PPS_MAX_SOURCES        16        /* should be enough... */
>>>>> +#define PPS_MAX_SOURCES        (MINORMASK + 1)
>>>>>       /* Implementation note: the logical states ``assert'' and ``clear''
>>>>>      * are implemented in terms of the chip register, i.e. ``assert''
>>>>
>>>> I have just one question: are you sure that it's safe to call idr_alloc(..., 0, (MINORMASK + 1), ...)?
>>>>
>>>> Ciao,
>>>>
>>>> Rodolfo
>>>>
>>>
>>> Thanks for taking a look!
>>>
>>> My understanding is that idr_alloc(..., start, end, ...) can take any end value up to INT_MAX. It also handles any values <= 0 by treating them as equal to INT_MAX + 1 since the end value is non-inclusive. I can't think of any reason using MINORMASK + 1 here would be an issue since it's much less than the maximum value idr_alloc() allows.
>>>
>>> A number of drivers (e.g. ptp) just explicitly use a start and end value of 0, but I don't think that change would fit here.
>>
>> I see and maybe I should replace the usage of idr_*() with ida_*() as PTP does...
>>
>> However the right-thing(TM) to do here should be dropping PPS_MAX_SOURCES at all!
>>
>> Let me go deeper in this issue. I'm going to produce a patch set in next days. Have you any chances to test it?
>>
>> Ciao,
>>
>> Rodolfo
>>
> MINORMASK
> I'll have to check when the system we used for testing is available again (not easy to find a system with 20+ Ethernet ports) but I'd be happy to test a patch!

Great! Please, let me know.

> I know an increase to PPS_MAX_SOURCES was tested on that system.

I see and it seems that it's safer to set PPS_MAX_SOURCES to MINORMASK... so 
please reproduce your patch with this simple modification, then I'm going to 
produce a patch to drop the PPS_MAX_SOURCES define since it's not needed anymore.

After that you should test all these modifications in order to safely add them 
to Linux.

Ciao,

Rodolfo

-- 
GNU/Linux Solutions                  e-mail: giometti@enneenne.com
Linux Device Driver                          giometti@linux.it
Embedded Systems                     phone:  +39 349 2432127
UNIX programming                     skype:  rodolfo.giometti


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [RFC PATCH] pps: Increase PPS_MAX_SOURCES value.
  2023-06-12 16:07         ` Rodolfo Giometti
@ 2023-06-20 20:42           ` Charlie Johnston
  2023-06-21 15:31             ` Rodolfo Giometti
  0 siblings, 1 reply; 9+ messages in thread
From: Charlie Johnston @ 2023-06-20 20:42 UTC (permalink / raw)
  To: Rodolfo Giometti; +Cc: linux-kernel, brenda.streiff

On 6/12/23 11:07, Rodolfo Giometti wrote:
> On 09/06/23 23:00, Charlie Johnston wrote:
>> On 6/9/23 02:30, Rodolfo Giometti wrote:
>>> On 08/06/23 00:07, Charlie Johnston wrote:
>>>> On 6/7/23 02:33, Rodolfo Giometti wrote:
>>>>> On 05/06/23 22:31, Charlie Johnston wrote:
>>>>>> For consistency with what ptp uses for minors, this
>>>>>> change sets PPS_MAX_SOURCES to MINORMASK + 1.
>>>>>>
>>>>>> The PPS_MAX_SOURCES value is currently set to 16. In
>>>>>> some cases this was not sufficient for a system. For
>>>>>> example, a system with multiple (4+) PCIe cards each
>>>>>> with 4 PTP-capable ethernet interfaces could run out
>>>>>> of the available PPS major:minors if each interface
>>>>>> registers a PPS source.
>>>>>>
>>>>>> Signed-off-by: Charlie Johnston <charlie.johnston@ni.com>
>>>>>> ---
>>>>>>     include/uapi/linux/pps.h | 2 +-
>>>>>>     1 file changed, 1 insertion(+), 1 deletion(-)
>>>>>>
>>>>>> diff --git a/include/uapi/linux/pps.h b/include/uapi/linux/pps.h
>>>>>> index 009ebcd8ced5..85f472330da8 100644
>>>>>> --- a/include/uapi/linux/pps.h
>>>>>> +++ b/include/uapi/linux/pps.h
>>>>>> @@ -26,7 +26,7 @@
>>>>>>     #include <linux/types.h>
>>>>>>       #define PPS_VERSION        "5.3.6"
>>>>>> -#define PPS_MAX_SOURCES        16        /* should be enough... */
>>>>>> +#define PPS_MAX_SOURCES        (MINORMASK + 1)
>>>>>>       /* Implementation note: the logical states ``assert'' and ``clear''
>>>>>>      * are implemented in terms of the chip register, i.e. ``assert''
>>>>>
>>>>> I have just one question: are you sure that it's safe to call idr_alloc(..., 0, (MINORMASK + 1), ...)?
>>>>>
>>>>> Ciao,
>>>>>
>>>>> Rodolfo
>>>>>
>>>>
>>>> Thanks for taking a look!
>>>>
>>>> My understanding is that idr_alloc(..., start, end, ...) can take any end value up to INT_MAX. It also handles any values <= 0 by treating them as equal to INT_MAX + 1 since the end value is non-inclusive. I can't think of any reason using MINORMASK + 1 here would be an issue since it's much less than the maximum value idr_alloc() allows.
>>>>
>>>> A number of drivers (e.g. ptp) just explicitly use a start and end value of 0, but I don't think that change would fit here.
>>>
>>> I see and maybe I should replace the usage of idr_*() with ida_*() as PTP does...
>>>
>>> However the right-thing(TM) to do here should be dropping PPS_MAX_SOURCES at all!
>>>
>>> Let me go deeper in this issue. I'm going to produce a patch set in next days. Have you any chances to test it?
>>>
>>> Ciao,
>>>
>>> Rodolfo
>>>
>> MINORMASK
>> I'll have to check when the system we used for testing is available again (not easy to find a system with 20+ Ethernet ports) but I'd be happy to test a patch!
> 
> Great! Please, let me know.
> 
>> I know an increase to PPS_MAX_SOURCES was tested on that system.
> 
> I see and it seems that it's safer to set PPS_MAX_SOURCES to MINORMASK... so please reproduce your patch with this simple modification, then I'm going to produce a patch to drop the PPS_MAX_SOURCES define since it's not needed anymore.
> 
> After that you should test all these modifications in order to safely add them to Linux.
> 
> Ciao,
> 
> Rodolfo
> 

I've resubmitted the patch with just PPS_MAX_SOURCES = MINORMASK. The system which hits the limit and causes the problem is currently available for testing. 

Is there anything you'd like me to try running? Or just confirm the limit change works?

Thanks,
Charlie

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [RFC PATCH] pps: Increase PPS_MAX_SOURCES value.
  2023-06-20 20:42           ` Charlie Johnston
@ 2023-06-21 15:31             ` Rodolfo Giometti
  2023-06-23  2:03               ` Charlie Johnston
  0 siblings, 1 reply; 9+ messages in thread
From: Rodolfo Giometti @ 2023-06-21 15:31 UTC (permalink / raw)
  To: Charlie Johnston; +Cc: linux-kernel, brenda.streiff

[-- Attachment #1: Type: text/plain, Size: 663 bytes --]

On 20/06/23 22:42, Charlie Johnston wrote:
> I've resubmitted the patch with just PPS_MAX_SOURCES = MINORMASK. The system which hits the limit and causes the problem is currently available for testing.
> 
> Is there anything you'd like me to try running? Or just confirm the limit change works?

Sorry for the delay (i was very busy in these days)! Please, test the attached 
two patches.

Ciao,

Rodolfo

-- 
GNU/Linux Solutions                  e-mail: giometti@enneenne.com
Linux Device Driver                          giometti@linux.it
Embedded Systems                     phone:  +39 349 2432127
UNIX programming                     skype:  rodolfo.giometti

[-- Attachment #2: 0001-include-uapi-pps.h-increase-PPS_MAX_SOURCES-value.patch --]
[-- Type: text/x-patch, Size: 1296 bytes --]

From 029bb28772b4751cd07beb5f366066e9333ea502 Mon Sep 17 00:00:00 2001
From: Charlie Johnston <charlie.johnston@ni.com>
Date: Mon, 12 Jun 2023 14:08:28 -0500
Subject: [PATCH 1/2] include/uapi pps.h: increase PPS_MAX_SOURCES value

For consistency with what others use for minors, this change sets
PPS_MAX_SOURCES to MINORMASK.

The PPS_MAX_SOURCES value is currently set to 16. In some cases this
was not sufficient for a system. For example, a system with multiple
(4+) PCIe cards each with 4 PTP-capable ethernet interfaces could run
out of the available PPS major:minors if each interface registers a
PPS source.

Signed-off-by: Charlie Johnston <charlie.johnston@ni.com>
Acked-by: Rodolfo Giometti <giometti@enneenne.com>
---
 include/uapi/linux/pps.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/uapi/linux/pps.h b/include/uapi/linux/pps.h
index 009ebcd8ced5..90f2e86020ba 100644
--- a/include/uapi/linux/pps.h
+++ b/include/uapi/linux/pps.h
@@ -26,7 +26,7 @@
 #include <linux/types.h>
 
 #define PPS_VERSION		"5.3.6"
-#define PPS_MAX_SOURCES		16		/* should be enough... */
+#define PPS_MAX_SOURCES		MINORMASK
 
 /* Implementation note: the logical states ``assert'' and ``clear''
  * are implemented in terms of the chip register, i.e. ``assert''
-- 
2.34.1


[-- Attachment #3: 0002-include-uapi-pps.h-drop-not-needed-PPS_MAX_SOURCES-d.patch --]
[-- Type: text/x-patch, Size: 2193 bytes --]

From 347f4b3bcfcf95039b53ca0f66586f547e9a9229 Mon Sep 17 00:00:00 2001
From: Rodolfo Giometti <giometti@enneenne.com>
Date: Wed, 21 Jun 2023 16:42:38 +0200
Subject: [PATCH 2/2] include/uapi pps.h: drop not needed PPS_MAX_SOURCES
 define

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
 
 /* Implementation note: the logical states ``assert'' and ``clear''
  * are implemented in terms of the chip register, i.e. ``assert''
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [RFC PATCH] pps: Increase PPS_MAX_SOURCES value.
  2023-06-21 15:31             ` Rodolfo Giometti
@ 2023-06-23  2:03               ` Charlie Johnston
  0 siblings, 0 replies; 9+ messages in thread
From: Charlie Johnston @ 2023-06-23  2:03 UTC (permalink / raw)
  To: Rodolfo Giometti; +Cc: linux-kernel@vger.kernel.org, Brenda Streiff

On 6/21/23 10:31, Rodolfo Giometti wrote:
> On 20/06/23 22:42, Charlie Johnston wrote:
>> I've resubmitted the patch with just PPS_MAX_SOURCES = MINORMASK. The system which hits the limit and causes the problem is currently available for testing.
>>
>> Is there anything you'd like me to try running? Or just confirm the limit change works?
> 
> Sorry for the delay (i was very busy in these days)! Please, test the attached 
> two patches.
> 
> Ciao,
> 
> Rodolfo
> 

Had some time to test today. Everything I tried appeared to work and the message log indicated sources were available for each port.

[    1.853052] pps_core: LinuxPPS API ver. 1 registered
[    2.749945] pps pps0: new PPS source ptp0
[    2.790179] pps pps1: new PPS source ptp1
[    2.818900] pps pps2: new PPS source ptp3
...
[    6.326282] pps pps26: new PPS source ptp27
[    6.354941] pps pps27: new PPS source ptp28
[    6.383575] pps pps28: new PPS source ptp29

Thanks for the quick turnaround on the patches!
Charlie

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2023-06-23  2:03 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-05 20:31 [RFC PATCH] pps: Increase PPS_MAX_SOURCES value Charlie Johnston
2023-06-07  7:33 ` Rodolfo Giometti
2023-06-07 22:07   ` Charlie Johnston
2023-06-09  7:30     ` Rodolfo Giometti
2023-06-09 21:00       ` Charlie Johnston
2023-06-12 16:07         ` Rodolfo Giometti
2023-06-20 20:42           ` Charlie Johnston
2023-06-21 15:31             ` Rodolfo Giometti
2023-06-23  2:03               ` Charlie Johnston

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).