<div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><span style="color:rgb(0,0,0);font-family:-webkit-standard;font-size:medium">There is already an sdbusplus loop running, it's in Mainloop::run().</span><br></div><div><span style="color:rgb(0,0,0);font-family:-webkit-standard;font-size:medium">[Thu] I think phosphor-hwmon is using the timer for </span><span style="color:rgb(0,0,0);font-family:-webkit-standard;font-size:medium">Mainloop::run() which triggers each 1 seconds.</span></div><div><span style="color:rgb(0,0,0);font-family:-webkit-standard;font-size:medium">Is this right?</span></div><div><span style="color:rgb(0,0,0);font-family:-webkit-standard;font-size:medium">To support signal the changing in dbus property, we need a service which listens the dbus signal, right?</span></div><div><span style="color:rgb(0,0,0);font-family:-webkit-standard;font-size:medium">I'm still fresh in C++ and dbus code. So please correct me if I'm wrong.</span></div><div><span style="color:rgb(0,0,0);font-family:-webkit-standard;font-size:medium"><br></span></div><div><span style="color:rgb(0,0,0);font-family:-webkit-standard;font-size:medium">Thanks.</span></div><div><span style="color:rgb(0,0,0);font-family:-webkit-standard;font-size:medium">Thu Nguyen.</span></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Nov 6, 2020 at 3:52 AM Matt Spinler <<a href="mailto:mspinler@linux.ibm.com">mspinler@linux.ibm.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><br>
<br>
On 11/4/2020 4:18 PM, Thu Ba Nguyen wrote:<br>
> Please see my comments below. Thanks. Thu Nguyen. On Wed, Nov 4, 2020 <br>
> at 11:31 PM...<br>
> This Message Is From an External Sender<br>
> This message came from outside your organization.<br>
><br>
> Please see my comments below.<br>
><br>
> Thanks.<br>
> Thu Nguyen.<br>
><br>
> On Wed, Nov 4, 2020 at 11:31 PM Matt Spinler <<a href="mailto:mspinler@linux.ibm.com" target="_blank">mspinler@linux.ibm.com</a> <br>
> <mailto:<a href="mailto:mspinler@linux.ibm.com" target="_blank">mspinler@linux.ibm.com</a>>> wrote:<br>
><br>
><br>
><br>
> On 11/4/2020 3:15 AM, Thu Ba Nguyen wrote:<br>
> > Hi Matt, I implemented "Inactive the host sensors" in<br>
> phosphor-hwmon<br>
> > use below...<br>
> > This Message Is From an External Sender<br>
> > This message came from outside your organization.<br>
> ><br>
> > Hi Matt,<br>
> ><br>
> > I implemented "Inactive the host sensors" in phosphor-hwmon use<br>
> below<br>
> > approaching:<br>
> > 1. Add one option in Sensors configuration, phosphor-hwmon will<br>
> parse<br>
> > this option and add host sensors to _hostSensors list.<br>
> > 2. In mainloop::read() before going to loop to read the sensors<br>
> in the<br>
> > reading list. Query dbus to get CurrentHostState property.<br>
> > This property belongs to service "xyz.openbmc_project.State.Host".<br>
> > Based on the status of this property, identify host status.<br>
> > If the host is off, remove the host sensors from _state list and<br>
> dbus.<br>
> > I expected the users wouldn't see the host sensors on the BMC<br>
> Web when<br>
> > the host is off.<br>
> > If the host is on, add the host sensors back to _state list and<br>
> also dbus.<br>
> ><br>
> > The code is working. But I have two issues with this approaching:<br>
> ><br>
> > 1. Too many transactions to get dbus property CurrentHostState.<br>
> > In my case, I have 6 services to monitor the sensors which<br>
> concern the<br>
> > host.<br>
> > With the current interval 1 second of phosphor-hwmon, I have 6<br>
> > transactions to get CurrentHostState per seconds.<br>
><br>
> The better way to implement this would be to read CurrentHostState<br>
> once<br>
> on startup, and then register for<br>
> propertiesChanged signals for it and provide a callback to update an<br>
> internal host state variable.<br>
><br>
> [Thu] Yes, This is what I'm planning to do. But don't know how to add <br>
> a propertiesChanged signals<br>
> to the current phosphor-hwmon framework.<br>
><br>
> I usually use below code to add a signal to dbus.<br>
> boost::asio::io_service io;<br>
> ampere::host::conn =<br>
> std::make_shared<sdbusplus::asio::connection>(ampere::host::io);<br>
><br>
> std::vector<std::unique_ptr<sdbusplus::bus::match::match>> matches;<br>
> //Start tracking power state<br>
> std::unique_ptr<sdbusplus::bus::match::match> hostMonitor =<br>
> ampere::host::startHostStateMonitor();<br>
> matches.emplace_back(std::move(hostMonitor));<br>
><br>
> /* wait for the signal */<br>
> ampere::host::io.run();<br>
> But when start io.run(), phosphor-hwmon will stop reading sensors.<br>
<br>
There is already an sdbusplus loop running, it's in Mainloop::run().<br>
<br>
><br>
> > 2. When I call "ipmitool power off" the host, there is a gap<br>
> between<br>
> > the time I trigger GPIO to power off the chassis and the time Dbus<br>
> > property CurrentHostState is updated.<br>
> > In this gap, the phosphor-hwmon is still reading sensors. And this<br>
> > causes the threshold warnings or errors. I want to avoid this.<br>
> ><br>
> > Do you have any suggestions to avoid these issues?<br>
> ><br>
><br>
> I can't think of anything at the moment. Maybe someone else has<br>
> an idea<br>
> here.<br>
><br>
> > Others question:<br>
> > I saw that phosphor-hwmon is registering an event to smbus and<br>
> trigger<br>
> > the event after each 1 second to read sensors.<br>
> > Can I change the phosphor-hwmon code to integrate one dbus<br>
> signal event?<br>
> > Which will be triggered when there is changing in dbus property.<br>
><br>
> I'm not sure I understand what you're asking for here. Right now it<br>
> will do 1 second reads (the period is<br>
> configurable) and send a properties changed signal for each sensor on<br>
> D-Bus only when the value changes.<br>
><br>
> [Thu] I'm asking for how to add a signal to current phosphor-hwmon <br>
> framework as comment 1.<br>
><br>
> ><br>
> > I knew how to create a service which adds the call back function<br>
> when<br>
> > there is change in dbus property.<br>
> > But don't know how to intergrace it to hwmon.<br>
> ><br>
> > Regards.<br>
> > Thu Nguyen.<br>
> ><br>
> ><br>
> ><br>
> > On Fri, Oct 23, 2020 at 5:45 AM Thu Ba Nguyen<br>
> <<a href="mailto:tbnguyen1985@gmail.com" target="_blank">tbnguyen1985@gmail.com</a> <mailto:<a href="mailto:tbnguyen1985@gmail.com" target="_blank">tbnguyen1985@gmail.com</a>><br>
> > <mailto:<a href="mailto:tbnguyen1985@gmail.com" target="_blank">tbnguyen1985@gmail.com</a> <mailto:<a href="mailto:tbnguyen1985@gmail.com" target="_blank">tbnguyen1985@gmail.com</a>>>><br>
> wrote:<br>
> ><br>
> > Just remove all of added code, rebase the phosphor-hwmon<br>
> source to<br>
> > commit<br>
> > "5906173 (12 months ago) Brad Bishop: build: add support for<br>
> > building with meson"<br>
> ><br>
> > Add the include:<br>
> > #include<sdbusplus/asio/connection.hpp><br>
> > I can see the error<br>
> > |<br>
> ><br>
> /openbmc/jade_build/tmp/work/arm1176jzs-openbmc-linux-gnueabi/phosphor-hwmon/1.0+gitAUTOINC+5906173aec-r1/recipe-sysroot-native/usr/bin/arm-openbmc-linux-gnueabi/../../libexec/arm-openbmc-linux-gnueabi/gcc/arm-openbmc-linux-gnueabi/10.1.0/ld:<br>
> > phosphor_hwmon_readd-readd.o: undefined reference to symbol<br>
> > 'pthread_key_delete@@GLIBC_2.4'<br>
> > |<br>
> ><br>
> /openbmc/jade_build/tmp/work/arm1176jzs-openbmc-linux-gnueabi/phosphor-hwmon/1.0+gitAUTOINC+5906173aec-r1/recipe-sysroot-native/usr/bin/arm-openbmc-linux-gnueabi/../../libexec/arm-openbmc-linux-gnueabi/gcc/arm-openbmc-linux-gnueabi/10.1.0/ld:<br>
> ><br>
> /openbmc/jade_build/tmp/work/arm1176jzs-openbmc-linux-gnueabi/phosphor-hwmon/1.0+gitAUTOINC+5906173aec-r1/recipe-sysroot/lib/libpthread.so.0:<br>
> > error adding symbols: DSO missing from command line<br>
> > | collect2: error: ld returned 1 exit status<br>
> > | make[2]: *** [Makefile:643: phosphor-hwmon-readd] Error 1<br>
> > | make[2]: Leaving directory<br>
> ><br>
> '/openbmc/jade_build/tmp/work/arm1176jzs-openbmc-linux-gnueabi/phosphor-hwmon/1.0+gitAUTOINC+5906173aec-r1/build'<br>
> > | make[1]: *** [Makefile:801: all-recursive] Error 1<br>
> > | make[1]: Leaving directory<br>
> ><br>
> '/openbmc/jade_build/tmp/work/arm1176jzs-openbmc-linux-gnueabi/phosphor-hwmon/1.0+gitAUTOINC+5906173aec-r1/build'<br>
> > | make: *** [Makefile:524: all] Error 2<br>
> > | ERROR: oe_runmake failed<br>
> > | WARNING: exit code 1 from a shell command.<br>
> > | ERROR: Execution of<br>
> ><br>
> '/openbmc/jade_build/tmp/work/arm1176jzs-openbmc-linux-gnueabi/phosphor-hwmon/1.0+gitAUTOINC+5906173aec-r1/temp/run.do_compile.2045'<br>
> > failed with exit code 1:<br>
> > | Makefile:800: target 'check-valgrind-recursive' given more<br>
> than<br>
> > once in the same rule<br>
> > | Makefile:800: target 'check-valgrind-memcheck-recursive' given<br>
> > more than once in the same rule<br>
> > | Makefile:800: target 'check-valgrind-helgrind-recursive' given<br>
> > more than once in the same rule<br>
> > | Makefile:800: target 'check-valgrind-drd-recursive' given more<br>
> > than once in the same rule<br>
> > | Makefile:800: target 'check-valgrind-sgcheck-recursive' given<br>
> > more than once in the same rule<br>
> > | make all-recursive<br>
> ><br>
> > I think we should add thread lib.<br>
> ><br>
> > Regards.<br>
> > Thu Nguyen.<br>
> ><br>
> > On Thu, Oct 22, 2020 at 10:51 PM Matt Spinler<br>
> > <<a href="mailto:mspinler@linux.ibm.com" target="_blank">mspinler@linux.ibm.com</a> <mailto:<a href="mailto:mspinler@linux.ibm.com" target="_blank">mspinler@linux.ibm.com</a>><br>
> <mailto:<a href="mailto:mspinler@linux.ibm.com" target="_blank">mspinler@linux.ibm.com</a> <mailto:<a href="mailto:mspinler@linux.ibm.com" target="_blank">mspinler@linux.ibm.com</a>>>><br>
> wrote:<br>
> ><br>
> ><br>
> ><br>
> > On 10/22/2020 9:49 AM, Thu Ba Nguyen wrote:<br>
> > > I started on supporting enable/disable host sensors.<br>
> > Everythings is<br>
> > > fine until I...<br>
> > > This Message Is From an External Sender<br>
> > > This message came from outside your organization.<br>
> > ><br>
> > > I started on supporting enable/disable host sensors.<br>
> > > Everythings is fine until I add code to monitor host<br>
> status<br>
> > as below.<br>
> > > bool MainLoop::isHostOn(void)<br>
> > > {<br>
> > > char buff[128];<br>
> > > if (!powerMatch)<br>
> > > {<br>
> > > log<level::ERR>("Power Match Not Created");<br>
> > > }<br>
> > > sprintf(buff, "isHostOn powerStatusOn:<br>
> %d\n",powerStatusOn);<br>
> > > log<level::INFO>(buff);<br>
> > > return powerStatusOn;<br>
> > > }<br>
> > > std::shared_ptr<sdbusplus::bus::match::match><br>
> > > MainLoop::startHostStateMonitor(void) {<br>
> > > return std::make_shared<sdbusplus::bus::match::match>(<br>
> > > *conn,<br>
> > ><br>
> "type='signal',interface='org.freedesktop.DBus.Properties',"<br>
> > ><br>
> > "member='PropertiesChanged',arg0='xyz.openbmc_project.State.Host'",<br>
> > > [](sdbusplus::message::message &msg) {<br>
> > > std::string interfaceName;<br>
> > > boost::container::flat_map<std::string,<br>
> > std::variant<std::string>><br>
> > > propertiesChanged;<br>
> > > try {<br>
> > > msg.read(interfaceName, propertiesChanged);<br>
> > > } catch (std::exception &e) {<br>
> > > log<level::ERR>("Unable to read host state\n");<br>
> > > return;<br>
> > > }<br>
> > > // We only want to check for CurrentHostState<br>
> > > if (propertiesChanged.begin()->first !=<br>
> "CurrentHostState") {<br>
> > > return;<br>
> > > }<br>
> > > auto findState = propertiesChanged.find(powProperty);<br>
> > > if (findState != propertiesChanged.end())<br>
> > > {<br>
> > > powerStatusOn = boost::ends_with(<br>
> > > std::get<std::string>(findState->second), "Running");<br>
> > > }<br>
> > > powerMatch = true;<br>
> > > });<br>
> > > }<br>
> > > void MainLoop::read()<br>
> > > {<br>
> > > // TODO: Issue#3 - Need to make calls to the dbus sensor<br>
> > cache here to<br>
> > > // ensure the objects all exist?<br>
> > > /* Host changed state from On to Off */<br>
> > > if (!isHostOn() && (lastPowerState == HOST_ON ||<br>
> > > lastPowerState == HOST_NA)) {<br>
> > > removeHostSensors();<br>
> > > lastPowerState = HOST_OFF;<br>
> > > }<br>
> > > /* Host changed state from Off to On */<br>
> > > if (isHostOn() && lastPowerState == HOST_OFF) {<br>
> > > addDroppedHostSensors();<br>
> > > lastPowerState = HOST_ON;<br>
> > > }<br>
> > > When build openBMC I got error:<br>
> > ><br>
> ><br>
> tmp/work/arm1176jzs-openbmc-linux-gnueabi/phosphor-hwmon/1.0+gitAUTOINC+5906173aec-r1/recipe-sysroot/lib/libpthread.so.0:<br>
> ><br>
> > > error adding symbols: DSO missing from command line<br>
> > > | collect2: error: ld returned 1 exit status<br>
> > > | make[2]: *** [Makefile:643: phosphor-hwmon-readd]<br>
> Error 1<br>
> > ><br>
> > > It seems I need adding the threads lib to defend lib.<br>
> > > Any suggestion to add threads lib to build configuration?<br>
> > ><br>
> ><br>
> > That must be because you're using that single boost<br>
> function?<br>
> > While you<br>
> > could add the dependency,<br>
> > the ideal thing to do since this repo already uses<br>
> > phosphor-dbus-interfaces is to use the function:<br>
> ><br>
> > /** @brief Convert a string to an appropriate<br>
> enum value.<br>
> > * @param[in] s - The string to convert in the<br>
> form of<br>
> > * "xyz.openbmc_project.State.Host.<value name>"<br>
> > * @return - The enum value.<br>
> > */<br>
> > static HostState convertHostStateFromString(const<br>
> > std::string& s);<br>
> ><br>
> > to convert it to the actual HostState enum to check against:<br>
> ><br>
> > enum class HostState<br>
> > {<br>
> > Off,<br>
> > Running,<br>
> > Quiesced,<br>
> > DiagnosticMode,<br>
> > };<br>
> ><br>
> > This is all in xyz/openbmc_project/State/Host/server.hpp<br>
> > provided by<br>
> > phosphor-dbus-interfaces.<br>
> ><br>
> > > Thanks.<br>
> > > Thu.<br>
> > ><br>
> > > On Wed, Oct 21, 2020 at 11:54 PM Thu Ba Nguyen<br>
> > <<a href="mailto:tbnguyen1985@gmail.com" target="_blank">tbnguyen1985@gmail.com</a> <mailto:<a href="mailto:tbnguyen1985@gmail.com" target="_blank">tbnguyen1985@gmail.com</a>><br>
> <mailto:<a href="mailto:tbnguyen1985@gmail.com" target="_blank">tbnguyen1985@gmail.com</a> <mailto:<a href="mailto:tbnguyen1985@gmail.com" target="_blank">tbnguyen1985@gmail.com</a>>><br>
> > > <mailto:<a href="mailto:tbnguyen1985@gmail.com" target="_blank">tbnguyen1985@gmail.com</a><br>
> <mailto:<a href="mailto:tbnguyen1985@gmail.com" target="_blank">tbnguyen1985@gmail.com</a>><br>
> > <mailto:<a href="mailto:tbnguyen1985@gmail.com" target="_blank">tbnguyen1985@gmail.com</a><br>
> <mailto:<a href="mailto:tbnguyen1985@gmail.com" target="_blank">tbnguyen1985@gmail.com</a>>>>> wrote:<br>
> > ><br>
> > > Hi Vijay,<br>
> > ><br>
> > > I took a look on entity-manager and openbmc source.<br>
> > > Don't have many companies using entity-manager<br>
> model to<br>
> > support<br>
> > > sensors.<br>
> > ><br>
> > > Regards<br>
> > > Thu Nguyen.<br>
> > ><br>
> > ><br>
> > > On Wed, Oct 21, 2020 at 7:15 AM Vijay Khemka<br>
> > <<a href="mailto:vijaykhemka@fb.com" target="_blank">vijaykhemka@fb.com</a> <mailto:<a href="mailto:vijaykhemka@fb.com" target="_blank">vijaykhemka@fb.com</a>><br>
> <mailto:<a href="mailto:vijaykhemka@fb.com" target="_blank">vijaykhemka@fb.com</a> <mailto:<a href="mailto:vijaykhemka@fb.com" target="_blank">vijaykhemka@fb.com</a>>><br>
> > > <mailto:<a href="mailto:vijaykhemka@fb.com" target="_blank">vijaykhemka@fb.com</a><br>
> <mailto:<a href="mailto:vijaykhemka@fb.com" target="_blank">vijaykhemka@fb.com</a>> <mailto:<a href="mailto:vijaykhemka@fb.com" target="_blank">vijaykhemka@fb.com</a><br>
> <mailto:<a href="mailto:vijaykhemka@fb.com" target="_blank">vijaykhemka@fb.com</a>>>>><br>
> > wrote:<br>
> > ><br>
> > > *From: *openbmc<br>
> > > <br>
> <openbmc-bounces+vijaykhemka=<a href="mailto:fb.com@lists.ozlabs.org" target="_blank">fb.com@lists.ozlabs.org</a><br>
> <mailto:<a href="mailto:fb.com@lists.ozlabs.org" target="_blank">fb.com@lists.ozlabs.org</a>><br>
> > <mailto:<a href="mailto:fb.com@lists.ozlabs.org" target="_blank">fb.com@lists.ozlabs.org</a><br>
> <mailto:<a href="mailto:fb.com@lists.ozlabs.org" target="_blank">fb.com@lists.ozlabs.org</a>>><br>
> > > <mailto:<a href="mailto:fb.com@lists.ozlabs.org" target="_blank">fb.com@lists.ozlabs.org</a><br>
> <mailto:<a href="mailto:fb.com@lists.ozlabs.org" target="_blank">fb.com@lists.ozlabs.org</a>><br>
> > <mailto:<a href="mailto:fb.com@lists.ozlabs.org" target="_blank">fb.com@lists.ozlabs.org</a><br>
> <mailto:<a href="mailto:fb.com@lists.ozlabs.org" target="_blank">fb.com@lists.ozlabs.org</a>>>>> on behalf of Thu Ba Nguyen<br>
> > > <<a href="mailto:tbnguyen1985@gmail.com" target="_blank">tbnguyen1985@gmail.com</a><br>
> <mailto:<a href="mailto:tbnguyen1985@gmail.com" target="_blank">tbnguyen1985@gmail.com</a>><br>
> > <mailto:<a href="mailto:tbnguyen1985@gmail.com" target="_blank">tbnguyen1985@gmail.com</a><br>
> <mailto:<a href="mailto:tbnguyen1985@gmail.com" target="_blank">tbnguyen1985@gmail.com</a>>> <mailto:<a href="mailto:tbnguyen1985@gmail.com" target="_blank">tbnguyen1985@gmail.com</a><br>
> <mailto:<a href="mailto:tbnguyen1985@gmail.com" target="_blank">tbnguyen1985@gmail.com</a>><br>
> > <mailto:<a href="mailto:tbnguyen1985@gmail.com" target="_blank">tbnguyen1985@gmail.com</a><br>
> <mailto:<a href="mailto:tbnguyen1985@gmail.com" target="_blank">tbnguyen1985@gmail.com</a>>>>><br>
> > > *Date: *Monday, October 19, 2020 at 11:23 AM<br>
> > > *To: *Ed Tanous <<a href="mailto:ed@tanous.net" target="_blank">ed@tanous.net</a><br>
> <mailto:<a href="mailto:ed@tanous.net" target="_blank">ed@tanous.net</a>><br>
> > <mailto:<a href="mailto:ed@tanous.net" target="_blank">ed@tanous.net</a> <mailto:<a href="mailto:ed@tanous.net" target="_blank">ed@tanous.net</a>>><br>
> <mailto:<a href="mailto:ed@tanous.net" target="_blank">ed@tanous.net</a> <mailto:<a href="mailto:ed@tanous.net" target="_blank">ed@tanous.net</a>><br>
> > <mailto:<a href="mailto:ed@tanous.net" target="_blank">ed@tanous.net</a> <mailto:<a href="mailto:ed@tanous.net" target="_blank">ed@tanous.net</a>>>>><br>
> > > *Cc: *OpenBMC Maillist<br>
> <<a href="mailto:openbmc@lists.ozlabs.org" target="_blank">openbmc@lists.ozlabs.org</a> <mailto:<a href="mailto:openbmc@lists.ozlabs.org" target="_blank">openbmc@lists.ozlabs.org</a>><br>
> > <mailto:<a href="mailto:openbmc@lists.ozlabs.org" target="_blank">openbmc@lists.ozlabs.org</a><br>
> <mailto:<a href="mailto:openbmc@lists.ozlabs.org" target="_blank">openbmc@lists.ozlabs.org</a>>><br>
> > > <mailto:<a href="mailto:openbmc@lists.ozlabs.org" target="_blank">openbmc@lists.ozlabs.org</a><br>
> <mailto:<a href="mailto:openbmc@lists.ozlabs.org" target="_blank">openbmc@lists.ozlabs.org</a>><br>
> > <mailto:<a href="mailto:openbmc@lists.ozlabs.org" target="_blank">openbmc@lists.ozlabs.org</a><br>
> <mailto:<a href="mailto:openbmc@lists.ozlabs.org" target="_blank">openbmc@lists.ozlabs.org</a>>>>><br>
> > > *Subject: *Re: Enable/Disable some sensors<br>
> when Host<br>
> > On/Off<br>
> > ><br>
> > > Hi Ed Tanous,<br>
> > ><br>
> > > > Thanks for your info,<br>
> > ><br>
> > > > But in your platform we are using phosphor-hwmon<br>
> > to manage<br>
> > > sensors.<br>
> > ><br>
> > > > We don't use entity-manager.<br>
> > ><br>
> > > > As I knew we can't use both entity-manager and<br>
> > > phosphor-hwmon for one project.<br>
> > ><br>
> > > You can use both but for different sensors.<br>
> You can<br>
> > decide<br>
> > > what sensors to configure<br>
> > ><br>
> > > via EM/dbus-sensors and which one for<br>
> phosphor-hwmon.<br>
> > ><br>
> > > Regards<br>
> > ><br>
> > > Thu Nguyen.<br>
> > ><br>
> ><br>
><br>
<br>
</blockquote></div></div></div></div>