All of lore.kernel.org
 help / color / mirror / Atom feed
* Recommended method for changing clk params dynamically from user space?
@ 2021-04-23  7:38 Pavel Hofman
  2021-04-24  8:00 ` Pavel Hofman
  0 siblings, 1 reply; 5+ messages in thread
From: Pavel Hofman @ 2021-04-23  7:38 UTC (permalink / raw)
  To: linux-clk

Hi, I would like to add some missing features to clk-si5341.c that I
need for my project. From user-space I need to tune delays at each
output (the driver does not control corresponding registers yet) and
fine-tune frequency while the clock is running (likely the nom/denom
values).

IIUC all driver parameters are currently configured via DT. Please what
is the recommended method/best practice for changing clk params
dynamically from user space? SysFS, configFS? I would like to have the
patches accepted upstream eventually.

Thank you very much.

Best regards,

Pavel.


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

* Re: Recommended method for changing clk params dynamically from user space?
  2021-04-23  7:38 Recommended method for changing clk params dynamically from user space? Pavel Hofman
@ 2021-04-24  8:00 ` Pavel Hofman
       [not found]   ` <161956915591.177949.3064618109796640887@swboyd.mtv.corp.google.com>
  0 siblings, 1 reply; 5+ messages in thread
From: Pavel Hofman @ 2021-04-24  8:00 UTC (permalink / raw)
  To: linux-clk

Dne 23. 04. 21 v 9:38 Pavel Hofman napsal(a):
> Hi, I would like to add some missing features to clk-si5341.c that I
> need for my project. From user-space I need to tune delays at each
> output (the driver does not control corresponding registers yet) and
> fine-tune frequency while the clock is running (likely the nom/denom
> values).
> 
> IIUC all driver parameters are currently configured via DT. Please what
> is the recommended method/best practice for changing clk params
> dynamically from user space? SysFS, configFS? I would like to have the
> patches accepted upstream eventually.
> 

From what I have read sysfs seems the most suitable option. But I am
surprised I could not find any driver-specific sysfs code in the clk
drivers. Theoretically I could fine-tune the device via I2C directly
from userspace but that feels wrong. Plus others could potentially
benefit from the features added to the clk driver. Please any suggestions?

Thanks a lot,

Pavel.

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

* Re: Recommended method for changing clk params dynamically from user space?
       [not found]   ` <161956915591.177949.3064618109796640887@swboyd.mtv.corp.google.com>
@ 2021-04-28  7:08     ` Pavel Hofman
  2021-04-30  1:48       ` Stephen Boyd
  0 siblings, 1 reply; 5+ messages in thread
From: Pavel Hofman @ 2021-04-28  7:08 UTC (permalink / raw)
  To: Stephen Boyd, linux-clk

Dne 28. 04. 21 v 2:19 Stephen Boyd napsal(a):
> Quoting Pavel Hofman (2021-04-24 01:00:47)
>> Dne 23. 04. 21 v 9:38 Pavel Hofman napsal(a):
>>> Hi, I would like to add some missing features to clk-si5341.c that I
>>> need for my project. From user-space I need to tune delays at each
>>> output (the driver does not control corresponding registers yet) and
>>> fine-tune frequency while the clock is running (likely the nom/denom
>>> values).
>>>
>>> IIUC all driver parameters are currently configured via DT. Please what
>>> is the recommended method/best practice for changing clk params
>>> dynamically from user space? SysFS, configFS? I would like to have the
>>> patches accepted upstream eventually.
>>>
>>
>> From what I have read sysfs seems the most suitable option. But I am
>> surprised I could not find any driver-specific sysfs code in the clk
>> drivers. Theoretically I could fine-tune the device via I2C directly
>> from userspace but that feels wrong. Plus others could potentially
>> benefit from the features added to the clk driver. Please any suggestions?
>>
> 
> So far there isn't a userspace clk interface. Clk control is fairly low
> level so I think nobody has implemented it so far. This topic comes up
> every year or two, so you can probably search the mailing list archives
> if you're interested in previous discussions.
> 
> Can you avoid implementing a userspace API? Are you implementing
> userspace drivers?
> 

Hi Stephen, thanks a lot for your info. I searched a bit and found
https://www.spinics.net/lists/linux-clk/msg06704.html .

I do not want to implement any userspace clock API, but user-space
control of extended features of a specific chip, currently missing in
the particular driver. Clock generators Si5340/1 (and many more, but
they are not my focus) can adjust output skew/delay on each output. Also
they allow fine-tuning the frequencies while running, by tiny
incremental steps. These features need to be controlled dynamically from
user space, by the application using them. None of the features iteract
with the in-kernel clock API. The fine-tuning control would not change
the set_rate/get_rate values, but adjust the real frequency, similarly
to alsa control 'PCM Rate Shift 100000' in snd-aloop loopback. So my
question is whether sysfs is the currently preferred interface for
specific-module control like this, or what other method should be used.

Thanks a lot,

Pavel.

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

* Re: Recommended method for changing clk params dynamically from user space?
  2021-04-28  7:08     ` Pavel Hofman
@ 2021-04-30  1:48       ` Stephen Boyd
  2021-05-03  7:37         ` Pavel Hofman
  0 siblings, 1 reply; 5+ messages in thread
From: Stephen Boyd @ 2021-04-30  1:48 UTC (permalink / raw)
  To: Pavel Hofman, linux-clk

Quoting Pavel Hofman (2021-04-28 00:08:55)
> Dne 28. 04. 21 v 2:19 Stephen Boyd napsal(a):
> > Quoting Pavel Hofman (2021-04-24 01:00:47)
> >> Dne 23. 04. 21 v 9:38 Pavel Hofman napsal(a):
> >>> Hi, I would like to add some missing features to clk-si5341.c that I
> >>> need for my project. From user-space I need to tune delays at each
> >>> output (the driver does not control corresponding registers yet) and
> >>> fine-tune frequency while the clock is running (likely the nom/denom
> >>> values).
> >>>
> >>> IIUC all driver parameters are currently configured via DT. Please what
> >>> is the recommended method/best practice for changing clk params
> >>> dynamically from user space? SysFS, configFS? I would like to have the
> >>> patches accepted upstream eventually.
> >>>
> >>
> >> From what I have read sysfs seems the most suitable option. But I am
> >> surprised I could not find any driver-specific sysfs code in the clk
> >> drivers. Theoretically I could fine-tune the device via I2C directly
> >> from userspace but that feels wrong. Plus others could potentially
> >> benefit from the features added to the clk driver. Please any suggestions?
> >>
> > 
> > So far there isn't a userspace clk interface. Clk control is fairly low
> > level so I think nobody has implemented it so far. This topic comes up
> > every year or two, so you can probably search the mailing list archives
> > if you're interested in previous discussions.
> > 
> > Can you avoid implementing a userspace API? Are you implementing
> > userspace drivers?
> > 
> 
> Hi Stephen, thanks a lot for your info. I searched a bit and found
> https://www.spinics.net/lists/linux-clk/msg06704.html .
> 
> I do not want to implement any userspace clock API, but user-space
> control of extended features of a specific chip, currently missing in
> the particular driver. Clock generators Si5340/1 (and many more, but
> they are not my focus) can adjust output skew/delay on each output.

Is the output skew/delay to control clk phase?

> Also
> they allow fine-tuning the frequencies while running, by tiny
> incremental steps. These features need to be controlled dynamically from
> user space, by the application using them.

Can you share more details on the application?

> None of the features iteract
> with the in-kernel clock API. The fine-tuning control would not change
> the set_rate/get_rate values, but adjust the real frequency, similarly
> to alsa control 'PCM Rate Shift 100000' in snd-aloop loopback. So my
> question is whether sysfs is the currently preferred interface for
> specific-module control like this, or what other method should be used.
> 

Given that you're comparing to alsa control, is this for some audio
processing feature? Perhaps it needs to be controlled via alsa then and
eventually call into the clk driver to fine tune the clk that the
sound driver consumes.

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

* Re: Recommended method for changing clk params dynamically from user space?
  2021-04-30  1:48       ` Stephen Boyd
@ 2021-05-03  7:37         ` Pavel Hofman
  0 siblings, 0 replies; 5+ messages in thread
From: Pavel Hofman @ 2021-05-03  7:37 UTC (permalink / raw)
  To: Stephen Boyd, linux-clk

Dne 30. 04. 21 v 3:48 Stephen Boyd napsal(a):
> Quoting Pavel Hofman (2021-04-28 00:08:55)
>> Dne 28. 04. 21 v 2:19 Stephen Boyd napsal(a):
>>> Quoting Pavel Hofman (2021-04-24 01:00:47)
>>>> Dne 23. 04. 21 v 9:38 Pavel Hofman napsal(a):
>>>>> Hi, I would like to add some missing features to clk-si5341.c that I
>>>>> need for my project. From user-space I need to tune delays at each
>>>>> output (the driver does not control corresponding registers yet) and
>>>>> fine-tune frequency while the clock is running (likely the nom/denom
>>>>> values).
>>>>>
>>>>> IIUC all driver parameters are currently configured via DT. Please what
>>>>> is the recommended method/best practice for changing clk params
>>>>> dynamically from user space? SysFS, configFS? I would like to have the
>>>>> patches accepted upstream eventually.
>>>>>
>>>>
>>>> From what I have read sysfs seems the most suitable option. But I am
>>>> surprised I could not find any driver-specific sysfs code in the clk
>>>> drivers. Theoretically I could fine-tune the device via I2C directly
>>>> from userspace but that feels wrong. Plus others could potentially
>>>> benefit from the features added to the clk driver. Please any suggestions?
>>>>
>>>
>>> So far there isn't a userspace clk interface. Clk control is fairly low
>>> level so I think nobody has implemented it so far. This topic comes up
>>> every year or two, so you can probably search the mailing list archives
>>> if you're interested in previous discussions.
>>>
>>> Can you avoid implementing a userspace API? Are you implementing
>>> userspace drivers?
>>>
>>
>> Hi Stephen, thanks a lot for your info. I searched a bit and found
>> https://www.spinics.net/lists/linux-clk/msg06704.html .
>>
>> I do not want to implement any userspace clock API, but user-space
>> control of extended features of a specific chip, currently missing in
>> the particular driver. Clock generators Si5340/1 (and many more, but
>> they are not my focus) can adjust output skew/delay on each output.
> 
> Is the output skew/delay to control clk phase?

The skew controls delay of the clk signal for the given output. So
basically it is phase, but enumerated in fractions of the internal
oscillator.

> 
>> Also
>> they allow fine-tuning the frequencies while running, by tiny
>> incremental steps. These features need to be controlled dynamically from
>> user space, by the application using them.
> 
> Can you share more details on the application?

Audio analyzer (DAC, ADC, clock, protection, ranging, etc.). Fine-tuning
the frequency can be used e.g. for sampling an analog oscillator with
slowly drifting frequency. Clock skew is required for adjusting delays
introduced by the various HW components so that all synchronous clock
signals reaching the DAC/ADC correct delays against each other. It will
take some experimentation and hard-coding the values in the device tree
config is not practical.

> 
>> None of the features iteract
>> with the in-kernel clock API. The fine-tuning control would not change
>> the set_rate/get_rate values, but adjust the real frequency, similarly
>> to alsa control 'PCM Rate Shift 100000' in snd-aloop loopback. So my
>> question is whether sysfs is the currently preferred interface for
>> specific-module control like this, or what other method should be used.
>>
> 
> Given that you're comparing to alsa control, is this for some audio
> processing feature? Perhaps it needs to be controlled via alsa then and
> eventually call into the clk driver to fine tune the clk that the
> sound driver consumes.

The alsa controls in snd-aloop are directly used by that module. In my
case the alsa driver would have to know how to operate specific features
of the specific clk driver, yet serving just as a proxy for the
controls. The alsa driver itself needs only the standard clk API for its
operation. IMO controlling the specific clock features directly is
correct as the features are provided by the specific clock HW and do not
interact with the standard clock API.

Nevertheless, in the end I decided to control all the Si5340 features
via I2C from my userspace application (incl. clk frequency settings),
avoiding the existing kernel Si5340 driver alltogether.

Thanks a lot,

Pavel.


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

end of thread, other threads:[~2021-05-03  7:38 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-23  7:38 Recommended method for changing clk params dynamically from user space? Pavel Hofman
2021-04-24  8:00 ` Pavel Hofman
     [not found]   ` <161956915591.177949.3064618109796640887@swboyd.mtv.corp.google.com>
2021-04-28  7:08     ` Pavel Hofman
2021-04-30  1:48       ` Stephen Boyd
2021-05-03  7:37         ` Pavel Hofman

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.