public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* How to pass software configuration to driver built as module in boot up phase
@ 2023-10-30 11:21 Tingwei Zhang
  2023-10-30 11:30 ` Greg Kroah-Hartman
  2023-10-30 23:35 ` Masami Hiramatsu
  0 siblings, 2 replies; 8+ messages in thread
From: Tingwei Zhang @ 2023-10-30 11:21 UTC (permalink / raw)
  To: Masami Hiramatsu, Greg Kroah-Hartman, Rafael J. Wysocki
  Cc: linux-kernel, Trilok Soni, Jinlong Mao

Hi Masami, Greg and Rafael,

I have one driver that needs a bunch to software configuration like 1000 
settings. These settings can be different according to the use case.

They are required in boot up phase so we can't reply on user space to 
make the configuration.

Boot config is not preferred since we'd like to build that driver as 
dynamic load Kernel module.

Could you let me know if there's any mechanism in Kernel to do that?

-- 
Thanks,
Tingwei

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

* Re: How to pass software configuration to driver built as module in boot up phase
  2023-10-30 11:21 How to pass software configuration to driver built as module in boot up phase Tingwei Zhang
@ 2023-10-30 11:30 ` Greg Kroah-Hartman
  2023-10-31  2:56   ` Tingwei Zhang
  2023-10-30 23:35 ` Masami Hiramatsu
  1 sibling, 1 reply; 8+ messages in thread
From: Greg Kroah-Hartman @ 2023-10-30 11:30 UTC (permalink / raw)
  To: Tingwei Zhang
  Cc: Masami Hiramatsu, Rafael J. Wysocki, linux-kernel, Trilok Soni,
	Jinlong Mao

On Mon, Oct 30, 2023 at 07:21:48PM +0800, Tingwei Zhang wrote:
> Hi Masami, Greg and Rafael,
> 
> I have one driver that needs a bunch to software configuration like 1000
> settings. These settings can be different according to the use case.

That seems very odd, what type of driver is this?

> They are required in boot up phase so we can't reply on user space to make
> the configuration.
> 
> Boot config is not preferred since we'd like to build that driver as dynamic
> load Kernel module.
> 
> Could you let me know if there's any mechanism in Kernel to do that?

What is wrong with the existing ways of doing this that all other
drivers use?

thanks,

greg k-h

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

* Re: How to pass software configuration to driver built as module in boot up phase
  2023-10-30 11:21 How to pass software configuration to driver built as module in boot up phase Tingwei Zhang
  2023-10-30 11:30 ` Greg Kroah-Hartman
@ 2023-10-30 23:35 ` Masami Hiramatsu
  2023-10-31  3:00   ` Tingwei Zhang
  1 sibling, 1 reply; 8+ messages in thread
From: Masami Hiramatsu @ 2023-10-30 23:35 UTC (permalink / raw)
  To: Tingwei Zhang
  Cc: Greg Kroah-Hartman, Rafael J. Wysocki, linux-kernel, Trilok Soni,
	Jinlong Mao

On Mon, 30 Oct 2023 19:21:48 +0800
Tingwei Zhang <quic_tingweiz@quicinc.com> wrote:

> Hi Masami, Greg and Rafael,
> 
> I have one driver that needs a bunch to software configuration like 1000 
> settings. These settings can be different according to the use case.

Is it an out-of-tree driver which can not be embedded?

> 
> They are required in boot up phase so we can't reply on user space to 
> make the configuration.
> 
> Boot config is not preferred since we'd like to build that driver as 
> dynamic load Kernel module.
> 
> Could you let me know if there's any mechanism in Kernel to do that?

Hm, it is interesting situation. So I made the bootconfig API and data
released after boot (only keep it in /proc/bootconfig). So I thought
module loader script can parse it and pass params to the modules.
But I did not expected that the number of params is about 1000.

Thank you,

-- 
Masami Hiramatsu (Google) <mhiramat@kernel.org>

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

* Re: How to pass software configuration to driver built as module in boot up phase
  2023-10-30 11:30 ` Greg Kroah-Hartman
@ 2023-10-31  2:56   ` Tingwei Zhang
  2023-10-31  6:58     ` Greg Kroah-Hartman
  0 siblings, 1 reply; 8+ messages in thread
From: Tingwei Zhang @ 2023-10-31  2:56 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Masami Hiramatsu, Rafael J. Wysocki, linux-kernel, Trilok Soni,
	Jinlong Mao

On 10/30/2023 7:30 PM, Greg Kroah-Hartman wrote:
> On Mon, Oct 30, 2023 at 07:21:48PM +0800, Tingwei Zhang wrote:
>> Hi Masami, Greg and Rafael,
>>
>> I have one driver that needs a bunch to software configuration like 1000
>> settings. These settings can be different according to the use case.
> 
> That seems very odd, what type of driver is this?
The example use case is below DCC driver which is a DMA engine. It can 
be configured to read/write registers while whose registers need to be 
configured by software. It's mainly used to debug device crash issue.
https://lore.kernel.org/lkml/cover.1691496290.git.quic_schowdhu@quicinc.com/T/
> 
>> They are required in boot up phase so we can't reply on user space to make
>> the configuration.
>>
>> Boot config is not preferred since we'd like to build that driver as dynamic
>> load Kernel module.
>>
>> Could you let me know if there's any mechanism in Kernel to do that?
> 
> What is wrong with the existing ways of doing this that all other
> drivers use?
I'm not aware of all the existing ways. Below ways are what I know and 
they may not be suitable for some reason.
1. Let user space to configure with sysfs/debugfs/ioctl interface. Since 
we need this configuration to be done in early stage before user space 
is up. This doesn't work.
2. Use device tree to pass the configuration to driver. Since the 
configuration is software configuration instead of hardware descirption. 
It doesn't fit in device tree.
3. Boot config or commandline parameter. If the driver is built in, it 
can work. But it doesn't work for dynamically loadable Kernel module.

I started this thread to look for suitable way in Kernel for driver to use.

> 
> thanks,
> 
> greg k-h

-- 
Thanks,
Tingwei


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

* Re: How to pass software configuration to driver built as module in boot up phase
  2023-10-30 23:35 ` Masami Hiramatsu
@ 2023-10-31  3:00   ` Tingwei Zhang
  0 siblings, 0 replies; 8+ messages in thread
From: Tingwei Zhang @ 2023-10-31  3:00 UTC (permalink / raw)
  To: Masami Hiramatsu (Google)
  Cc: Greg Kroah-Hartman, Rafael J. Wysocki, linux-kernel, Trilok Soni,
	Jinlong Mao

On 10/31/2023 7:35 AM, Masami Hiramatsu (Google) wrote:
> On Mon, 30 Oct 2023 19:21:48 +0800
> Tingwei Zhang <quic_tingweiz@quicinc.com> wrote:
> 
>> Hi Masami, Greg and Rafael,
>>
>> I have one driver that needs a bunch to software configuration like 1000
>> settings. These settings can be different according to the use case.
> 
> Is it an out-of-tree driver which can not be embedded?
Current it's out-of-tree and we are trying to get it accepted.
> 
>>
>> They are required in boot up phase so we can't reply on user space to
>> make the configuration.
>>
>> Boot config is not preferred since we'd like to build that driver as
>> dynamic load Kernel module.
>>
>> Could you let me know if there's any mechanism in Kernel to do that?
> 
> Hm, it is interesting situation. So I made the bootconfig API and data
> released after boot (only keep it in /proc/bootconfig). So I thought
> module loader script can parse it and pass params to the modules.
If we use bootconfig API in driver, it can't be built as module. 
Compilation won't pass.
> But I did not expected that the number of params is about 1000.
> 
> Thank you,
> 

-- 
Thanks,
Tingwei


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

* Re: How to pass software configuration to driver built as module in boot up phase
  2023-10-31  2:56   ` Tingwei Zhang
@ 2023-10-31  6:58     ` Greg Kroah-Hartman
  2023-10-31 10:01       ` Tingwei Zhang
  0 siblings, 1 reply; 8+ messages in thread
From: Greg Kroah-Hartman @ 2023-10-31  6:58 UTC (permalink / raw)
  To: Tingwei Zhang
  Cc: Masami Hiramatsu, Rafael J. Wysocki, linux-kernel, Trilok Soni,
	Jinlong Mao

On Tue, Oct 31, 2023 at 10:56:23AM +0800, Tingwei Zhang wrote:
> On 10/30/2023 7:30 PM, Greg Kroah-Hartman wrote:
> > On Mon, Oct 30, 2023 at 07:21:48PM +0800, Tingwei Zhang wrote:
> > > Hi Masami, Greg and Rafael,
> > > 
> > > I have one driver that needs a bunch to software configuration like 1000
> > > settings. These settings can be different according to the use case.
> > 
> > That seems very odd, what type of driver is this?
> The example use case is below DCC driver which is a DMA engine. It can be
> configured to read/write registers while whose registers need to be
> configured by software. It's mainly used to debug device crash issue.
> https://lore.kernel.org/lkml/cover.1691496290.git.quic_schowdhu@quicinc.com/T/

Given that no one listened to my last review cycle of that driver, why
are you asking us again?

> > > They are required in boot up phase so we can't reply on user space to make
> > > the configuration.
> > > 
> > > Boot config is not preferred since we'd like to build that driver as dynamic
> > > load Kernel module.
> > > 
> > > Could you let me know if there's any mechanism in Kernel to do that?
> > 
> > What is wrong with the existing ways of doing this that all other
> > drivers use?
> I'm not aware of all the existing ways. Below ways are what I know and they
> may not be suitable for some reason.
> 1. Let user space to configure with sysfs/debugfs/ioctl interface. Since we
> need this configuration to be done in early stage before user space is up.

I really doubt that you need this before userspace starts, as that's not
what "device crash" stuff should be dealing with.  That happens after
init starts, because you have a working kernel (i.e. this is not for
hardware bringup.)

> This doesn't work.

Why do you need this before init?  Specific reasons please.

> 2. Use device tree to pass the configuration to driver. Since the
> configuration is software configuration instead of hardware descirption. It
> doesn't fit in device tree.
> 3. Boot config or commandline parameter. If the driver is built in, it can
> work. But it doesn't work for dynamically loadable Kernel module.

If you have a module, then you can do this after init starts, so you
are reporting conflicting "requirements" here, which make this
impossible for us to understand :(

Please work with the kernel developers at your company to come up with a
solution for this, you have the experience, do not require the community
to do your work for you.

thanks,

greg k-h

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

* Re: How to pass software configuration to driver built as module in boot up phase
  2023-10-31  6:58     ` Greg Kroah-Hartman
@ 2023-10-31 10:01       ` Tingwei Zhang
  2023-10-31 10:44         ` Greg Kroah-Hartman
  0 siblings, 1 reply; 8+ messages in thread
From: Tingwei Zhang @ 2023-10-31 10:01 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Masami Hiramatsu, Rafael J. Wysocki, linux-kernel, Trilok Soni,
	Jinlong Mao

On 10/31/2023 2:58 PM, Greg Kroah-Hartman wrote:
> On Tue, Oct 31, 2023 at 10:56:23AM +0800, Tingwei Zhang wrote:
>> On 10/30/2023 7:30 PM, Greg Kroah-Hartman wrote:
>>> On Mon, Oct 30, 2023 at 07:21:48PM +0800, Tingwei Zhang wrote:
>>>> Hi Masami, Greg and Rafael,
>>>>
>>>> I have one driver that needs a bunch to software configuration like 1000
>>>> settings. These settings can be different according to the use case.
>>>
>>> That seems very odd, what type of driver is this?
>> The example use case is below DCC driver which is a DMA engine. It can be
>> configured to read/write registers while whose registers need to be
>> configured by software. It's mainly used to debug device crash issue.
>> https://lore.kernel.org/lkml/cover.1691496290.git.quic_schowdhu@quicinc.com/T/
> 
> Given that no one listened to my last review cycle of that driver, why
> are you asking us again?
> 

There's some change on developer owner of DCC driver. We preparing and 
reviewing the driver internally.  It will be submitted once ready.

>>>> They are required in boot up phase so we can't reply on user space to make
>>>> the configuration.
>>>>
>>>> Boot config is not preferred since we'd like to build that driver as dynamic
>>>> load Kernel module.
>>>>
>>>> Could you let me know if there's any mechanism in Kernel to do that?
>>>
>>> What is wrong with the existing ways of doing this that all other
>>> drivers use?
>> I'm not aware of all the existing ways. Below ways are what I know and they
>> may not be suitable for some reason.
>> 1. Let user space to configure with sysfs/debugfs/ioctl interface. Since we
>> need this configuration to be done in early stage before user space is up.
> 
> I really doubt that you need this before userspace starts, as that's not
> what "device crash" stuff should be dealing with.  That happens after
> init starts, because you have a working kernel (i.e. this is not for
> hardware bringup.)
> 
>> This doesn't work.
> 
> Why do you need this before init?  Specific reasons please.
> 
There are some case that some driver broke Kernel in development phase 
and those bad driver could cause device crash in very early boot up phase.
>> 2. Use device tree to pass the configuration to driver. Since the
>> configuration is software configuration instead of hardware descirption. It
>> doesn't fit in device tree.
>> 3. Boot config or commandline parameter. If the driver is built in, it can
>> work. But it doesn't work for dynamically loadable Kernel module.
> 
> If you have a module, then you can do this after init starts, so you
> are reporting conflicting "requirements" here, which make this
> impossible for us to understand :(

You are correct.  I missed that part. We should already have user space 
up when install the module.

> 
> Please work with the kernel developers at your company to come up with a
> solution for this, you have the experience, do not require the community
> to do your work for you.
> 
> thanks,
> 
> greg k-h

-- 
Thanks,
Tingwei


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

* Re: How to pass software configuration to driver built as module in boot up phase
  2023-10-31 10:01       ` Tingwei Zhang
@ 2023-10-31 10:44         ` Greg Kroah-Hartman
  0 siblings, 0 replies; 8+ messages in thread
From: Greg Kroah-Hartman @ 2023-10-31 10:44 UTC (permalink / raw)
  To: Tingwei Zhang
  Cc: Masami Hiramatsu, Rafael J. Wysocki, linux-kernel, Trilok Soni,
	Jinlong Mao

On Tue, Oct 31, 2023 at 06:01:44PM +0800, Tingwei Zhang wrote:
> > Why do you need this before init?  Specific reasons please.
> > 
> There are some case that some driver broke Kernel in development phase and
> those bad driver could cause device crash in very early boot up phase.

Then work on that in the development phase of your system, don't make it
a requirement for us for this.

thanks,

greg k-h

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

end of thread, other threads:[~2023-10-31 10:44 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-30 11:21 How to pass software configuration to driver built as module in boot up phase Tingwei Zhang
2023-10-30 11:30 ` Greg Kroah-Hartman
2023-10-31  2:56   ` Tingwei Zhang
2023-10-31  6:58     ` Greg Kroah-Hartman
2023-10-31 10:01       ` Tingwei Zhang
2023-10-31 10:44         ` Greg Kroah-Hartman
2023-10-30 23:35 ` Masami Hiramatsu
2023-10-31  3:00   ` Tingwei Zhang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox