LKML Archive mirror
 help / color / mirror / Atom feed
From: Rodolfo Giometti <giometti@enneenne.com>
To: Charlie Johnston <charlie.johnston@ni.com>
Cc: linux-kernel@vger.kernel.org, brenda.streiff@ni.com
Subject: Re: [RFC PATCH] pps: Increase PPS_MAX_SOURCES value.
Date: Fri, 9 Jun 2023 09:30:47 +0200	[thread overview]
Message-ID: <70ce864c-ca13-4fc4-fcb5-9b7f91579a90@enneenne.com> (raw)
In-Reply-To: <b794bccc-0233-4d78-df6f-bf7c688a7d7d@ni.com>

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


  reply	other threads:[~2023-06-09  7:36 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=70ce864c-ca13-4fc4-fcb5-9b7f91579a90@enneenne.com \
    --to=giometti@enneenne.com \
    --cc=brenda.streiff@ni.com \
    --cc=charlie.johnston@ni.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).