openbmc.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* The common solution to support bind/unbind the hwmon driver base on the host state.
@ 2021-03-31  2:14 Thu Nguyen OS
  2021-03-31 16:14 ` Joseph Reynolds
  2021-04-05 16:32 ` Ed Tanous
  0 siblings, 2 replies; 10+ messages in thread
From: Thu Nguyen OS @ 2021-03-31  2:14 UTC (permalink / raw)
  To: openbmc

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

Hi All,

Currently, In Mtjade platform of Ampere, we have SMPro mdf drivers (SMPro hwmon, SMPro errmon, SMPro misc driver).
The drivers will be loaded by kernel when the BMC boot up. But they are only binded when the host is already On.
They are also unbinded when the host is Off.
To support binding/unbinding the SMPro drivesr, we have one service name driver-binder.

  1.  When the Dbus property CurrentHostState of service xyz.openbmc_project.State.Host changes to “not Off”, we will bind the drivers.
  2.  When the Dbus property RequestedHostTransition of service xyz.openbmc_project.State.Host OR Dbus property RequestedPowerTransition of xyz.openbmc_project.State.Chassis

change to Off, we will unbind the drivers.

The driver-binder is working as expected, it have the configuration file to configure which drivers will be binded/unbinded.
But that is our solution.

Do we have any common solution to do that job?

Regards.
Thu Nguyen.



[-- Attachment #2: Type: text/html, Size: 5232 bytes --]

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

* Re: The common solution to support bind/unbind the hwmon driver base on the host state.
  2021-03-31  2:14 The common solution to support bind/unbind the hwmon driver base on the host state Thu Nguyen OS
@ 2021-03-31 16:14 ` Joseph Reynolds
  2021-04-02  7:52   ` Thu Nguyen OS
  2021-04-05 16:32 ` Ed Tanous
  1 sibling, 1 reply; 10+ messages in thread
From: Joseph Reynolds @ 2021-03-31 16:14 UTC (permalink / raw)
  To: Thu Nguyen OS, openbmc

On 3/30/21 9:14 PM, Thu Nguyen OS wrote:
> Hi All, Currently, In Mtjade platform of Ampere, we have SMPro mdf 
> drivers (SMPro hwmon, SMPro errmon, SMPro misc driver). The drivers 
> will be loaded by kernel when the BMC boot up. But they are only 
> binded when the host is already On. ‍ ‍ ‍ ‍ 
>
> Hi All,
>
> Currently, In Mtjade platform of Ampere, we have SMPro mdf drivers 
> (SMPro hwmon, SMPro errmon, SMPro misc driver).
>
> The drivers will be loaded by kernel when the BMC boot up. But they 
> are only binded when the host is already On.
>
> They are also unbinded when the host is Off.
>
> To support binding/unbinding the SMPro drivesr, we have one service 
> name driver-binder.
>
>  1. When the Dbus property CurrentHostState of service
>     xyz.openbmc_project.State.Host changes to “not Off”, we will bind
>     the drivers.
>  2. When the Dbus property RequestedHostTransition of service
>     xyz.openbmc_project.State.Host OR Dbus property
>     RequestedPowerTransition of xyz.openbmc_project.State.Chassis
>
> change to Off, we will unbind the drivers.
>
> The driver-binder is working as expected, it have the configuration 
> file to configure which drivers will be binded/unbinded.
>
> But that is our solution.
>
> Do we have any common solution to do that job?
>

Thu,

I don't have a solution.  But I do want to be able to bind and unbind 
drivers for the BMC-attached USB ports (as the underlying mechanism when 
the BMC admin disables the ports), so I think it would be good to have a 
common solution or understand the best practices.

Joseph

> Regards.
>
> Thu Nguyen.
>


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

* Re: The common solution to support bind/unbind the hwmon driver base on the host state.
  2021-03-31 16:14 ` Joseph Reynolds
@ 2021-04-02  7:52   ` Thu Nguyen OS
  2021-04-05 15:06     ` Matt Spinler
  0 siblings, 1 reply; 10+ messages in thread
From: Thu Nguyen OS @ 2021-04-02  7:52 UTC (permalink / raw)
  To: Joseph Reynolds, openbmc

I thought that OpenBmc community have to have the solution for this.
I can propose my solution but I don't think it is common enough.

Regards,
Thu Nguyen.

On 31/03/2021, 23:14, "Joseph Reynolds" <jrey@linux.ibm.com> wrote:

    On 3/30/21 9:14 PM, Thu Nguyen OS wrote:
    > Hi All, Currently, In Mtjade platform of Ampere, we have SMPro mdf 
    > drivers (SMPro hwmon, SMPro errmon, SMPro misc driver). The drivers 
    > will be loaded by kernel when the BMC boot up. But they are only 
    > binded when the host is already On. ‍ ‍ ‍ ‍ 
    >
    > Hi All,
    >
    > Currently, In Mtjade platform of Ampere, we have SMPro mdf drivers 
    > (SMPro hwmon, SMPro errmon, SMPro misc driver).
    >
    > The drivers will be loaded by kernel when the BMC boot up. But they 
    > are only binded when the host is already On.
    >
    > They are also unbinded when the host is Off.
    >
    > To support binding/unbinding the SMPro drivesr, we have one service 
    > name driver-binder.
    >
    >  1. When the Dbus property CurrentHostState of service
    >     xyz.openbmc_project.State.Host changes to “not Off”, we will bind
    >     the drivers.
    >  2. When the Dbus property RequestedHostTransition of service
    >     xyz.openbmc_project.State.Host OR Dbus property
    >     RequestedPowerTransition of xyz.openbmc_project.State.Chassis
    >
    > change to Off, we will unbind the drivers.
    >
    > The driver-binder is working as expected, it have the configuration 
    > file to configure which drivers will be binded/unbinded.
    >
    > But that is our solution.
    >
    > Do we have any common solution to do that job?
    >

    Thu,

    I don't have a solution.  But I do want to be able to bind and unbind 
    drivers for the BMC-attached USB ports (as the underlying mechanism when 
    the BMC admin disables the ports), so I think it would be good to have a 
    common solution or understand the best practices.

    Joseph

    > Regards.
    >
    > Thu Nguyen.
    >



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

* Re: The common solution to support bind/unbind the hwmon driver base on the host state.
  2021-04-02  7:52   ` Thu Nguyen OS
@ 2021-04-05 15:06     ` Matt Spinler
  2021-04-05 15:17       ` Thu Nguyen OS
  0 siblings, 1 reply; 10+ messages in thread
From: Matt Spinler @ 2021-04-05 15:06 UTC (permalink / raw)
  To: Thu Nguyen OS, Joseph Reynolds, openbmc



On 4/2/2021 2:52 AM, Thu Nguyen OS wrote:
> I thought that OpenBmc community have to have the solution for this.
> I can propose my solution but I don't think it is common enough.

I haven't seen any code that does a bind/unbind on power on, so I would 
welcome your solution being upstreamed.  We put similar functionality 
into phosphor-gpio-presence that can bind/unbind around presence 
detection where the drivers are also listed in a config file.


>
> Regards,
> Thu Nguyen.
>
> On 31/03/2021, 23:14, "Joseph Reynolds" <jrey@linux.ibm.com> wrote:
>
>      On 3/30/21 9:14 PM, Thu Nguyen OS wrote:
>      > Hi All, Currently, In Mtjade platform of Ampere, we have SMPro mdf
>      > drivers (SMPro hwmon, SMPro errmon, SMPro misc driver). The drivers
>      > will be loaded by kernel when the BMC boot up. But they are only
>      > binded when the host is already On. ‍ ‍ ‍ ‍
>      >
>      > Hi All,
>      >
>      > Currently, In Mtjade platform of Ampere, we have SMPro mdf drivers
>      > (SMPro hwmon, SMPro errmon, SMPro misc driver).
>      >
>      > The drivers will be loaded by kernel when the BMC boot up. But they
>      > are only binded when the host is already On.
>      >
>      > They are also unbinded when the host is Off.
>      >
>      > To support binding/unbinding the SMPro drivesr, we have one service
>      > name driver-binder.
>      >
>      >  1. When the Dbus property CurrentHostState of service
>      >     xyz.openbmc_project.State.Host changes to “not Off”, we will bind
>      >     the drivers.
>      >  2. When the Dbus property RequestedHostTransition of service
>      >     xyz.openbmc_project.State.Host OR Dbus property
>      >     RequestedPowerTransition of xyz.openbmc_project.State.Chassis
>      >
>      > change to Off, we will unbind the drivers.
>      >
>      > The driver-binder is working as expected, it have the configuration
>      > file to configure which drivers will be binded/unbinded.
>      >
>      > But that is our solution.
>      >
>      > Do we have any common solution to do that job?
>      >
>
>      Thu,
>
>      I don't have a solution.  But I do want to be able to bind and unbind
>      drivers for the BMC-attached USB ports (as the underlying mechanism when
>      the BMC admin disables the ports), so I think it would be good to have a
>      common solution or understand the best practices.
>
>      Joseph
>
>      > Regards.
>      >
>      > Thu Nguyen.
>      >
>
>


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

* Re: The common solution to support bind/unbind the hwmon driver base on the host state.
  2021-04-05 15:06     ` Matt Spinler
@ 2021-04-05 15:17       ` Thu Nguyen OS
  2021-04-05 16:20         ` Matt Spinler
  0 siblings, 1 reply; 10+ messages in thread
From: Thu Nguyen OS @ 2021-04-05 15:17 UTC (permalink / raw)
  To: Matt Spinler, Joseph Reynolds, openbmc

Sure, I will prepare the code.

1. Do you suggest the name of repo? I though we can use phosphor-driver-binder.
2. Below is format of the configuration file which I'm using.
{
       "hostDrivers" :
       {
              "bindDelay" : 0,
              "unbindDelay" : 0,
              "drivers" :
              [
                     {
                            "name" : "",
                            "path" : ""
                     },
                     {
                            "name" : "",
                            "path" : ""
                     }
              ]
       },
       "powerDrivers" :
       {
              "bindDelay" : 0,
              "unbindDelay" : 0,
              "drivers" :
              [
                     {
                            "name" : "",
                            "path" : ""
                     },
                     {
                            "name" : "",
                            "path" : ""
                     }
              ]
        }
}
Where:
* hostDrivers: Json entry to define the drivers which bind/unbind when the host change state.
* bindDelay: The delay will be applied before start binding the drivers in the list.
* unbindDelay: The delay will be applied before start unbinding the drivers in the list.
* drivers: Define the list of drivers in one driver type.
* name: define driver name.
* path: is the path of that driver which have bind and unbind binary.

* powerDrivers: Json entry to define the drivers which bind/unbind when the power change state.

Do you think the json format is ok?

Regards.
Thu Nguyen.

On 05/04/2021, 22:06, "Matt Spinler" <mspinler@linux.ibm.com> wrote:



    On 4/2/2021 2:52 AM, Thu Nguyen OS wrote:
    > I thought that OpenBmc community have to have the solution for this.
    > I can propose my solution but I don't think it is common enough.

    I haven't seen any code that does a bind/unbind on power on, so I would 
    welcome your solution being upstreamed.  We put similar functionality 
    into phosphor-gpio-presence that can bind/unbind around presence 
    detection where the drivers are also listed in a config file.


    >
    > Regards,
    > Thu Nguyen.
    >
    > On 31/03/2021, 23:14, "Joseph Reynolds" <jrey@linux.ibm.com> wrote:
    >
    >      On 3/30/21 9:14 PM, Thu Nguyen OS wrote:
    >      > Hi All, Currently, In Mtjade platform of Ampere, we have SMPro mdf
    >      > drivers (SMPro hwmon, SMPro errmon, SMPro misc driver). The drivers
    >      > will be loaded by kernel when the BMC boot up. But they are only
    >      > binded when the host is already On. ‍ ‍ ‍ ‍
    >      >
    >      > Hi All,
    >      >
    >      > Currently, In Mtjade platform of Ampere, we have SMPro mdf drivers
    >      > (SMPro hwmon, SMPro errmon, SMPro misc driver).
    >      >
    >      > The drivers will be loaded by kernel when the BMC boot up. But they
    >      > are only binded when the host is already On.
    >      >
    >      > They are also unbinded when the host is Off.
    >      >
    >      > To support binding/unbinding the SMPro drivesr, we have one service
    >      > name driver-binder.
    >      >
    >      >  1. When the Dbus property CurrentHostState of service
    >      >     xyz.openbmc_project.State.Host changes to “not Off”, we will bind
    >      >     the drivers.
    >      >  2. When the Dbus property RequestedHostTransition of service
    >      >     xyz.openbmc_project.State.Host OR Dbus property
    >      >     RequestedPowerTransition of xyz.openbmc_project.State.Chassis
    >      >
    >      > change to Off, we will unbind the drivers.
    >      >
    >      > The driver-binder is working as expected, it have the configuration
    >      > file to configure which drivers will be binded/unbinded.
    >      >
    >      > But that is our solution.
    >      >
    >      > Do we have any common solution to do that job?
    >      >
    >
    >      Thu,
    >
    >      I don't have a solution.  But I do want to be able to bind and unbind
    >      drivers for the BMC-attached USB ports (as the underlying mechanism when
    >      the BMC admin disables the ports), so I think it would be good to have a
    >      common solution or understand the best practices.
    >
    >      Joseph
    >
    >      > Regards.
    >      >
    >      > Thu Nguyen.
    >      >
    >
    >



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

* Re: The common solution to support bind/unbind the hwmon driver base on the host state.
  2021-04-05 15:17       ` Thu Nguyen OS
@ 2021-04-05 16:20         ` Matt Spinler
  2021-04-06 15:23           ` Thu Nguyen OS
  0 siblings, 1 reply; 10+ messages in thread
From: Matt Spinler @ 2021-04-05 16:20 UTC (permalink / raw)
  To: Thu Nguyen OS, Joseph Reynolds, openbmc, Brad Bishop



On 4/5/2021 10:17 AM, Thu Nguyen OS wrote:
> Sure, I will prepare the code.
>
> 1. Do you suggest the name of repo? I though we can use phosphor-driver-binder.

At one point, there was going to be an official way to ask where new 
functionality should go - 
https://lore.kernel.org/openbmc/20210111220919.zwc727vbwc4itm7h@thinkpad.fuzziesquirrel.com/. 
I can't remember seeing a way to make these requests though.  Maybe Brad 
can chime in.

How about just put it into the the phosphor-hwmon repo?

> 2. Below is format of the configuration file which I'm using.
> {
>         "hostDrivers" :
>         {
>                "bindDelay" : 0,
>                "unbindDelay" : 0,
>                "drivers" :
>                [
>                       {
>                              "name" : "",
>                              "path" : ""
>                       },
>                       {
>                              "name" : "",
>                              "path" : ""
>                       }
>                ]
>         },
>         "powerDrivers" :
>         {
>                "bindDelay" : 0,
>                "unbindDelay" : 0,
>                "drivers" :
>                [
>                       {
>                              "name" : "",
>                              "path" : ""
>                       },
>                       {
>                              "name" : "",
>                              "path" : ""
>                       }
>                ]
>          }
> }
> Where:
> * hostDrivers: Json entry to define the drivers which bind/unbind when the host change state.
> * bindDelay: The delay will be applied before start binding the drivers in the list.
> * unbindDelay: The delay will be applied before start unbinding the drivers in the list.
> * drivers: Define the list of drivers in one driver type.
> * name: define driver name.
> * path: is the path of that driver which have bind and unbind binary.
>
> * powerDrivers: Json entry to define the drivers which bind/unbind when the power change state.
>
> Do you think the json format is ok?

Looks pretty good to me.

> Regards.
> Thu Nguyen.
>
> On 05/04/2021, 22:06, "Matt Spinler" <mspinler@linux.ibm.com> wrote:
>
>
>
>      On 4/2/2021 2:52 AM, Thu Nguyen OS wrote:
>      > I thought that OpenBmc community have to have the solution for this.
>      > I can propose my solution but I don't think it is common enough.
>
>      I haven't seen any code that does a bind/unbind on power on, so I would
>      welcome your solution being upstreamed.  We put similar functionality
>      into phosphor-gpio-presence that can bind/unbind around presence
>      detection where the drivers are also listed in a config file.
>
>
>      >
>      > Regards,
>      > Thu Nguyen.
>      >
>      > On 31/03/2021, 23:14, "Joseph Reynolds" <jrey@linux.ibm.com> wrote:
>      >
>      >      On 3/30/21 9:14 PM, Thu Nguyen OS wrote:
>      >      > Hi All, Currently, In Mtjade platform of Ampere, we have SMPro mdf
>      >      > drivers (SMPro hwmon, SMPro errmon, SMPro misc driver). The drivers
>      >      > will be loaded by kernel when the BMC boot up. But they are only
>      >      > binded when the host is already On. ‍ ‍ ‍ ‍
>      >      >
>      >      > Hi All,
>      >      >
>      >      > Currently, In Mtjade platform of Ampere, we have SMPro mdf drivers
>      >      > (SMPro hwmon, SMPro errmon, SMPro misc driver).
>      >      >
>      >      > The drivers will be loaded by kernel when the BMC boot up. But they
>      >      > are only binded when the host is already On.
>      >      >
>      >      > They are also unbinded when the host is Off.
>      >      >
>      >      > To support binding/unbinding the SMPro drivesr, we have one service
>      >      > name driver-binder.
>      >      >
>      >      >  1. When the Dbus property CurrentHostState of service
>      >      >     xyz.openbmc_project.State.Host changes to “not Off”, we will bind
>      >      >     the drivers.
>      >      >  2. When the Dbus property RequestedHostTransition of service
>      >      >     xyz.openbmc_project.State.Host OR Dbus property
>      >      >     RequestedPowerTransition of xyz.openbmc_project.State.Chassis
>      >      >
>      >      > change to Off, we will unbind the drivers.
>      >      >
>      >      > The driver-binder is working as expected, it have the configuration
>      >      > file to configure which drivers will be binded/unbinded.
>      >      >
>      >      > But that is our solution.
>      >      >
>      >      > Do we have any common solution to do that job?
>      >      >
>      >
>      >      Thu,
>      >
>      >      I don't have a solution.  But I do want to be able to bind and unbind
>      >      drivers for the BMC-attached USB ports (as the underlying mechanism when
>      >      the BMC admin disables the ports), so I think it would be good to have a
>      >      common solution or understand the best practices.
>      >
>      >      Joseph
>      >
>      >      > Regards.
>      >      >
>      >      > Thu Nguyen.
>      >      >
>      >
>      >
>
>


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

* Re: The common solution to support bind/unbind the hwmon driver base on the host state.
  2021-03-31  2:14 The common solution to support bind/unbind the hwmon driver base on the host state Thu Nguyen OS
  2021-03-31 16:14 ` Joseph Reynolds
@ 2021-04-05 16:32 ` Ed Tanous
  2021-04-06 15:15   ` Thu Nguyen OS
  1 sibling, 1 reply; 10+ messages in thread
From: Ed Tanous @ 2021-04-05 16:32 UTC (permalink / raw)
  To: Thu Nguyen OS; +Cc: openbmc

On Tue, Mar 30, 2021 at 7:14 PM Thu Nguyen OS
<thu@os.amperecomputing.com> wrote:
>
> Hi All,
>
>
>
> Currently, In Mtjade platform of Ampere, we have SMPro mdf drivers (SMPro hwmon, SMPro errmon, SMPro misc driver).
>
> The drivers will be loaded by kernel when the BMC boot up. But they are only binded when the host is already On.

Assuming you're using dbus-sensors, you'd normally just write an app
that's capable of unloading the modules and watching the power states.
Experience seems to show that very few true "rules" exist with regards
to this kind of enabling/disabling, and as hardware gets used more,
more odd error handling seems to pop up, so as a matter of design we
pushed this into the individual sensor daemons early on to try to keep
it somewhat sane to manage.  dbus-sensors somewhat takes the position
that once all hardware is debugged, there is no "common" solution to
reset, and we've proven that on several occasions with other simple
sensors.

Overall, I'd recommend just writing an AMDCpuSensor application, as I
suspect this is the first of many special cases that the processor
will need.

>
> They are also unbinded when the host is Off.
>
> To support binding/unbinding the SMPro drivesr, we have one service name driver-binder.
>
> When the Dbus property CurrentHostState of service xyz.openbmc_project.State.Host changes to “not Off”, we will bind the drivers.
> When the Dbus property RequestedHostTransition of service xyz.openbmc_project.State.Host OR Dbus property RequestedPowerTransition of xyz.openbmc_project.State.Chassis
>
> change to Off, we will unbind the drivers.
>
>
>
> The driver-binder is working as expected, it have the configuration file to configure which drivers will be binded/unbinded.
>
> But that is our solution.
>
>
>
> Do we have any common solution to do that job?
>
>
>
> Regards.
>
> Thu Nguyen.
>
>
>
>

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

* Re: The common solution to support bind/unbind the hwmon driver base on the host state.
  2021-04-05 16:32 ` Ed Tanous
@ 2021-04-06 15:15   ` Thu Nguyen OS
  0 siblings, 0 replies; 10+ messages in thread
From: Thu Nguyen OS @ 2021-04-06 15:15 UTC (permalink / raw)
  To: Ed Tanous; +Cc: openbmc



On 05/04/2021, 23:33, "Ed Tanous" <edtanous@google.com> wrote:

    On Tue, Mar 30, 2021 at 7:14 PM Thu Nguyen OS
    <thu@os.amperecomputing.com> wrote:
    >
    > Hi All,
    >
    >
    >
    > Currently, In Mtjade platform of Ampere, we have SMPro mdf drivers (SMPro hwmon, SMPro errmon, SMPro misc driver).
    >
    > The drivers will be loaded by kernel when the BMC boot up. But they are only binded when the host is already On.

    Assuming you're using dbus-sensors, you'd normally just write an app
    that's capable of unloading the modules and watching the power states.
    Experience seems to show that very few true "rules" exist with regards
    to this kind of enabling/disabling, and as hardware gets used more,
    more odd error handling seems to pop up, so as a matter of design we
    pushed this into the individual sensor daemons early on to try to keep
    it somewhat sane to manage.  dbus-sensors somewhat takes the position
    that once all hardware is debugged, there is no "common" solution to
    reset, and we've proven that on several occasions with other simple
    sensors.

[Thu] I'm using the phosphor-hwmon, to create the sensor dbus object.
I don't use entity-manager and also dbus-sensor.
With phosphor-hwmon, when the driver is binded, all of the configured sensors will be read and update the value to dbus by phosphor-hwmon.
It seem the phosphor-hwmon is working as expected.
The problem is currently kernel don't support auto bind/unbind mechanism, so I have to do that manually. As my opinion, We can add binding/unbinding the driver as separated daemons or integrate it to phosphor-hwmon.

    Overall, I'd recommend just writing an AMDCpuSensor application, as I
    suspect this is the first of many special cases that the processor
    will need.

    >
    > They are also unbinded when the host is Off.
    >
    > To support binding/unbinding the SMPro drivesr, we have one service name driver-binder.
    >
    > When the Dbus property CurrentHostState of service xyz.openbmc_project.State.Host changes to “not Off”, we will bind the drivers.
    > When the Dbus property RequestedHostTransition of service xyz.openbmc_project.State.Host OR Dbus property RequestedPowerTransition of xyz.openbmc_project.State.Chassis
    >
    > change to Off, we will unbind the drivers.
    >
    >
    >
    > The driver-binder is working as expected, it have the configuration file to configure which drivers will be binded/unbinded.
    >
    > But that is our solution.
    >
    >
    >
    > Do we have any common solution to do that job?
    >
    >
    >
    > Regards.
    >
    > Thu Nguyen.
    >
    >
    >
    >


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

* Re: The common solution to support bind/unbind the hwmon driver base on the host state.
  2021-04-05 16:20         ` Matt Spinler
@ 2021-04-06 15:23           ` Thu Nguyen OS
  2021-04-06 15:27             ` Matt Spinler
  0 siblings, 1 reply; 10+ messages in thread
From: Thu Nguyen OS @ 2021-04-06 15:23 UTC (permalink / raw)
  To: Matt Spinler, Joseph Reynolds, openbmc, Brad Bishop

Let me think about "putting it into phosphor-hwmon".
There are two problem with this:
1. Currently phosphor-hwmon start before phosphor-state-manager create CurrentHostState dbus property. So there is the short time which we can't access this property to know the host state.
2. We need add one or some options in sensor configuration file to difference the binded/unbinded  drivers with the normal one.

Regards.
Thu Nguyen. 

On 05/04/2021, 23:20, "Matt Spinler" <mspinler@linux.ibm.com> wrote:



    On 4/5/2021 10:17 AM, Thu Nguyen OS wrote:
    > Sure, I will prepare the code.
    >
    > 1. Do you suggest the name of repo? I though we can use phosphor-driver-binder.

    At one point, there was going to be an official way to ask where new 
    functionality should go - 
    https://lore.kernel.org/openbmc/20210111220919.zwc727vbwc4itm7h@thinkpad.fuzziesquirrel.com/. 
    I can't remember seeing a way to make these requests though.  Maybe Brad 
    can chime in.

    How about just put it into the the phosphor-hwmon repo?

    > 2. Below is format of the configuration file which I'm using.
    > {
    >         "hostDrivers" :
    >         {
    >                "bindDelay" : 0,
    >                "unbindDelay" : 0,
    >                "drivers" :
    >                [
    >                       {
    >                              "name" : "",
    >                              "path" : ""
    >                       },
    >                       {
    >                              "name" : "",
    >                              "path" : ""
    >                       }
    >                ]
    >         },
    >         "powerDrivers" :
    >         {
    >                "bindDelay" : 0,
    >                "unbindDelay" : 0,
    >                "drivers" :
    >                [
    >                       {
    >                              "name" : "",
    >                              "path" : ""
    >                       },
    >                       {
    >                              "name" : "",
    >                              "path" : ""
    >                       }
    >                ]
    >          }
    > }
    > Where:
    > * hostDrivers: Json entry to define the drivers which bind/unbind when the host change state.
    > * bindDelay: The delay will be applied before start binding the drivers in the list.
    > * unbindDelay: The delay will be applied before start unbinding the drivers in the list.
    > * drivers: Define the list of drivers in one driver type.
    > * name: define driver name.
    > * path: is the path of that driver which have bind and unbind binary.
    >
    > * powerDrivers: Json entry to define the drivers which bind/unbind when the power change state.
    >
    > Do you think the json format is ok?

    Looks pretty good to me.

    > Regards.
    > Thu Nguyen.
    >
    > On 05/04/2021, 22:06, "Matt Spinler" <mspinler@linux.ibm.com> wrote:
    >
    >
    >
    >      On 4/2/2021 2:52 AM, Thu Nguyen OS wrote:
    >      > I thought that OpenBmc community have to have the solution for this.
    >      > I can propose my solution but I don't think it is common enough.
    >
    >      I haven't seen any code that does a bind/unbind on power on, so I would
    >      welcome your solution being upstreamed.  We put similar functionality
    >      into phosphor-gpio-presence that can bind/unbind around presence
    >      detection where the drivers are also listed in a config file.
    >
    >
    >      >
    >      > Regards,
    >      > Thu Nguyen.
    >      >
    >      > On 31/03/2021, 23:14, "Joseph Reynolds" <jrey@linux.ibm.com> wrote:
    >      >
    >      >      On 3/30/21 9:14 PM, Thu Nguyen OS wrote:
    >      >      > Hi All, Currently, In Mtjade platform of Ampere, we have SMPro mdf
    >      >      > drivers (SMPro hwmon, SMPro errmon, SMPro misc driver). The drivers
    >      >      > will be loaded by kernel when the BMC boot up. But they are only
    >      >      > binded when the host is already On. ‍ ‍ ‍ ‍
    >      >      >
    >      >      > Hi All,
    >      >      >
    >      >      > Currently, In Mtjade platform of Ampere, we have SMPro mdf drivers
    >      >      > (SMPro hwmon, SMPro errmon, SMPro misc driver).
    >      >      >
    >      >      > The drivers will be loaded by kernel when the BMC boot up. But they
    >      >      > are only binded when the host is already On.
    >      >      >
    >      >      > They are also unbinded when the host is Off.
    >      >      >
    >      >      > To support binding/unbinding the SMPro drivesr, we have one service
    >      >      > name driver-binder.
    >      >      >
    >      >      >  1. When the Dbus property CurrentHostState of service
    >      >      >     xyz.openbmc_project.State.Host changes to “not Off”, we will bind
    >      >      >     the drivers.
    >      >      >  2. When the Dbus property RequestedHostTransition of service
    >      >      >     xyz.openbmc_project.State.Host OR Dbus property
    >      >      >     RequestedPowerTransition of xyz.openbmc_project.State.Chassis
    >      >      >
    >      >      > change to Off, we will unbind the drivers.
    >      >      >
    >      >      > The driver-binder is working as expected, it have the configuration
    >      >      > file to configure which drivers will be binded/unbinded.
    >      >      >
    >      >      > But that is our solution.
    >      >      >
    >      >      > Do we have any common solution to do that job?
    >      >      >
    >      >
    >      >      Thu,
    >      >
    >      >      I don't have a solution.  But I do want to be able to bind and unbind
    >      >      drivers for the BMC-attached USB ports (as the underlying mechanism when
    >      >      the BMC admin disables the ports), so I think it would be good to have a
    >      >      common solution or understand the best practices.
    >      >
    >      >      Joseph
    >      >
    >      >      > Regards.
    >      >      >
    >      >      > Thu Nguyen.
    >      >      >
    >      >
    >      >
    >
    >



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

* Re: The common solution to support bind/unbind the hwmon driver base on the host state.
  2021-04-06 15:23           ` Thu Nguyen OS
@ 2021-04-06 15:27             ` Matt Spinler
  0 siblings, 0 replies; 10+ messages in thread
From: Matt Spinler @ 2021-04-06 15:27 UTC (permalink / raw)
  To: Thu Nguyen OS, Joseph Reynolds, openbmc, Brad Bishop



On 4/6/2021 10:23 AM, Thu Nguyen OS wrote:
> Let me think about "putting it into phosphor-hwmon".
> There are two problem with this:
> 1. Currently phosphor-hwmon start before phosphor-state-manager create CurrentHostState dbus property. So there is the short time which we can't access this property to know the host state.
> 2. We need add one or some options in sensor configuration file to difference the binded/unbinded  drivers with the normal one.

Oh, what I meant here was still having a new daemon, but just putting it 
in the same phosphor-hwmon git repository that phosphor-hwmon-readd 
lives in.


> Regards.
> Thu Nguyen.
>
> On 05/04/2021, 23:20, "Matt Spinler" <mspinler@linux.ibm.com> wrote:
>
>
>
>      On 4/5/2021 10:17 AM, Thu Nguyen OS wrote:
>      > Sure, I will prepare the code.
>      >
>      > 1. Do you suggest the name of repo? I though we can use phosphor-driver-binder.
>
>      At one point, there was going to be an official way to ask where new
>      functionality should go -
>      https://lore.kernel.org/openbmc/20210111220919.zwc727vbwc4itm7h@thinkpad.fuzziesquirrel.com/.
>      I can't remember seeing a way to make these requests though.  Maybe Brad
>      can chime in.
>
>      How about just put it into the the phosphor-hwmon repo?
>
>      > 2. Below is format of the configuration file which I'm using.
>      > {
>      >         "hostDrivers" :
>      >         {
>      >                "bindDelay" : 0,
>      >                "unbindDelay" : 0,
>      >                "drivers" :
>      >                [
>      >                       {
>      >                              "name" : "",
>      >                              "path" : ""
>      >                       },
>      >                       {
>      >                              "name" : "",
>      >                              "path" : ""
>      >                       }
>      >                ]
>      >         },
>      >         "powerDrivers" :
>      >         {
>      >                "bindDelay" : 0,
>      >                "unbindDelay" : 0,
>      >                "drivers" :
>      >                [
>      >                       {
>      >                              "name" : "",
>      >                              "path" : ""
>      >                       },
>      >                       {
>      >                              "name" : "",
>      >                              "path" : ""
>      >                       }
>      >                ]
>      >          }
>      > }
>      > Where:
>      > * hostDrivers: Json entry to define the drivers which bind/unbind when the host change state.
>      > * bindDelay: The delay will be applied before start binding the drivers in the list.
>      > * unbindDelay: The delay will be applied before start unbinding the drivers in the list.
>      > * drivers: Define the list of drivers in one driver type.
>      > * name: define driver name.
>      > * path: is the path of that driver which have bind and unbind binary.
>      >
>      > * powerDrivers: Json entry to define the drivers which bind/unbind when the power change state.
>      >
>      > Do you think the json format is ok?
>
>      Looks pretty good to me.
>
>      > Regards.
>      > Thu Nguyen.
>      >
>      > On 05/04/2021, 22:06, "Matt Spinler" <mspinler@linux.ibm.com> wrote:
>      >
>      >
>      >
>      >      On 4/2/2021 2:52 AM, Thu Nguyen OS wrote:
>      >      > I thought that OpenBmc community have to have the solution for this.
>      >      > I can propose my solution but I don't think it is common enough.
>      >
>      >      I haven't seen any code that does a bind/unbind on power on, so I would
>      >      welcome your solution being upstreamed.  We put similar functionality
>      >      into phosphor-gpio-presence that can bind/unbind around presence
>      >      detection where the drivers are also listed in a config file.
>      >
>      >
>      >      >
>      >      > Regards,
>      >      > Thu Nguyen.
>      >      >
>      >      > On 31/03/2021, 23:14, "Joseph Reynolds" <jrey@linux.ibm.com> wrote:
>      >      >
>      >      >      On 3/30/21 9:14 PM, Thu Nguyen OS wrote:
>      >      >      > Hi All, Currently, In Mtjade platform of Ampere, we have SMPro mdf
>      >      >      > drivers (SMPro hwmon, SMPro errmon, SMPro misc driver). The drivers
>      >      >      > will be loaded by kernel when the BMC boot up. But they are only
>      >      >      > binded when the host is already On. ‍ ‍ ‍ ‍
>      >      >      >
>      >      >      > Hi All,
>      >      >      >
>      >      >      > Currently, In Mtjade platform of Ampere, we have SMPro mdf drivers
>      >      >      > (SMPro hwmon, SMPro errmon, SMPro misc driver).
>      >      >      >
>      >      >      > The drivers will be loaded by kernel when the BMC boot up. But they
>      >      >      > are only binded when the host is already On.
>      >      >      >
>      >      >      > They are also unbinded when the host is Off.
>      >      >      >
>      >      >      > To support binding/unbinding the SMPro drivesr, we have one service
>      >      >      > name driver-binder.
>      >      >      >
>      >      >      >  1. When the Dbus property CurrentHostState of service
>      >      >      >     xyz.openbmc_project.State.Host changes to “not Off”, we will bind
>      >      >      >     the drivers.
>      >      >      >  2. When the Dbus property RequestedHostTransition of service
>      >      >      >     xyz.openbmc_project.State.Host OR Dbus property
>      >      >      >     RequestedPowerTransition of xyz.openbmc_project.State.Chassis
>      >      >      >
>      >      >      > change to Off, we will unbind the drivers.
>      >      >      >
>      >      >      > The driver-binder is working as expected, it have the configuration
>      >      >      > file to configure which drivers will be binded/unbinded.
>      >      >      >
>      >      >      > But that is our solution.
>      >      >      >
>      >      >      > Do we have any common solution to do that job?
>      >      >      >
>      >      >
>      >      >      Thu,
>      >      >
>      >      >      I don't have a solution.  But I do want to be able to bind and unbind
>      >      >      drivers for the BMC-attached USB ports (as the underlying mechanism when
>      >      >      the BMC admin disables the ports), so I think it would be good to have a
>      >      >      common solution or understand the best practices.
>      >      >
>      >      >      Joseph
>      >      >
>      >      >      > Regards.
>      >      >      >
>      >      >      > Thu Nguyen.
>      >      >      >
>      >      >
>      >      >
>      >
>      >
>
>


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

end of thread, other threads:[~2021-04-06 15:28 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-31  2:14 The common solution to support bind/unbind the hwmon driver base on the host state Thu Nguyen OS
2021-03-31 16:14 ` Joseph Reynolds
2021-04-02  7:52   ` Thu Nguyen OS
2021-04-05 15:06     ` Matt Spinler
2021-04-05 15:17       ` Thu Nguyen OS
2021-04-05 16:20         ` Matt Spinler
2021-04-06 15:23           ` Thu Nguyen OS
2021-04-06 15:27             ` Matt Spinler
2021-04-05 16:32 ` Ed Tanous
2021-04-06 15:15   ` Thu Nguyen OS

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 NNTP newsgroup(s).