 Tervetuloa, kaikille! Ja kiitos, että minun pitää tulla. Täällä on minua suoraan kommentteja. Tämä on minun ensimmäinen kohdattelun. Ja... Kiitos. En ole niin aivan kokemusta, että täällä on täällä. Minulla on kertokaa. Jos minulla oli yksi tykkäyksiä, jotka kävelee, olisi halusin Suomessa. Mutta olen toivottavasti, että voitko vielä tästä, ja saa jotain tästä. Tässä agenda. Olen saanut sanoa... Tämä on kuitenkin yksi. Ensimmäinen paikka on todella generiikko, ja olen saanut sanoa jotain, mitä Power Management on. Ja miten nämä ovat tehtyneet. Ja seuraava paikka on ryhmä ja välillä yksi on joka on yksi on tosiaan kuten on. Ja miten tehtyneet tulot tai tuntuu koko ajan. Ja miten tehtyneet tulot tai koko ajan voittamuuttamuutin ja miten heet tulot tai oot tai koko ajan. Ja miten heet tulot tai ajan. Ja miten heet tulot tai Mä oon kerrallaan Pimikvento, ja me olemme Pimiks, ja tiedän, että Pimiks-laajalla on asioita, mutta en tiedä, joilla asioita on käyttänyt niin hyvin. Joten kun voin sanoa, miten voitaisiin ottaa näitä notifikaatioita johon hirveän puolesta, voin sanoa, mitä pitäisi tehdä näitä notifikaatioita. Ja sen jälkeen olen huomattu, että minkälaajat voivat ottaa näitä notifikaatioita, joilla tämä voi olla käyttänyt, ja miten tämä voi olla käyttänyt, jolloin ne ovat käyttäneet ja jolloin ne ovat käyttäneet. Joten, että minä olen puolestaan Pimikvento, joten Pimiks-laajalla on tullut myös minkälaajalle. Mä olen tullut tullut vahvistajalle, ja en ole tullut Pimiks-laajalle näitä tosiaan näin, mutta näin, että olen tullut pahvistajalle, joten kun oon pahvistajalle, jolloin olen tullut Pimiks-laajalle, ja nyt olen tullut tullut tullut pahvistajalle ja Ja sitten, kun sanoin, että ihmisiä, jotka olen tehdä puheenjohtajien ja ympäristöjärjestelmiä, ihmisiä on tärkeää, että mitä? Miten pitäisi puheenjohtajien ja ympäristöjärjestelmiä? Puhumme vain koreen ja asioita. Tämä on vähän ympäristössä, koska todella verta, jota nähdään jotain tästä. Se on yksi kokemuksena, jotka on tarpeeksi, joilla on eri kokemppuja ja eri kontrolalaiset. Ja ne on tietysti tuntuvat, joilla on tuntuvat, kun alkaa-mukkua ja sattavuus-sattavuus on kokemppuja. Se on tuntuvat, joka on yksi pimeä. Ei tuntuvat, vaan teemme, että teillä on tuntuvat, koko tuntuvat, joilla on kokemppuja. On top of these timings and power requirements which are kind of critical. There are also functional requirements for powering up and shutting down devices. People tend to do, pretend to want for example power savings. My wife tells me that we need to do power saving. She is the one who is paying the electricity bill. Silloin se on jotain, että se ei ole. Onneksi on hieman lukunut. Onneksi on hieman lukunut. Onneksi on hieman lukunut, kun joku on otettu. Onneksi on hieman lukunut, kun joku on ottanut. Onneksi on tarjottavasti vuodesta, moniasedun ja muodossa, ja jonteen. Tämä on tarpeeksi, että mitä on tullut pimiksille. Jos olemme tehneet kaikki nämä asioihin, se olisi hieman pispääräistä, jotka voivat olla tarpeeksi. Pimikset ovat basically ICs, ICs, jotka ovat korboituneet kaikki nämä asioihin. Tämä on... Tällä kertaa, että nämä ovat asioihin, ja artisiklokset ja erilaisia. Okei. Tällä asioihin, joilla meillä on monta eri funktioita, voisi olla tarpeeksi. Ja olen tullut... Olen tullut tullut tarpeeksi mukaan mfd, ja sitten olen tarpeeksi tullut erilaiset asioihin. Olen tullut tullut tullut erilaiset asioihin. Joten, kun meillä on monta erilaiset funktioita, ICs on tullut tullut erilaiset asioihin. Olemme tullut mfd korboituneita, joka ei ole tullut tullut erilaisia, mutta se ei ole erilaisia, mutta se on jotain, joka on valmis kaikki nämä asioihin, ja ehkä tullut erilaiset kontrol- ja korboituneet, ja ehkä hänet generaattorivaihtojen asioihin. Olen tullut tullut mfd-asioihin, ja olen tullut tullut mfd-asioihin. On ehkä tullut tullut mene, mutta minulla on tullut tullut mukaan, ja hänet hatturivaihtojen asioihin on tosiaan erilaisia. Joten kun hänet nimenomaan terveysen, theirien asioihin, ovat tullut erilaisia asioihin, näitä asioihin, ja kun olemme meneet mfd-asioihin, ja tehittävät nämä tullut meneet erilaisia asioihin, joita voimme sieltä käyttää, koko MFD koronan ja tehdä only new drivers for really changed parts. Then the regulator subsystem. Regulator subsystem is basically two-folded, or business of two, or actually more than two devices, so on the one hand there is the provider device, the regulator device and then there are the consumers. The regulator framework is something that is sitting between these, actually a regulator device which is controlling the regulator hardware and then the devices that are consuming the power from the regulator. So that the consumer drivers can be asking or requesting, for example enabling the power or disabling the power or changing the voltage. The framework is sitting there between the regulator driver and the consumer driver for a reason. There might be multiple devices connected to one regulator, and it means that you need some kind of bookkeeping that who needs these regulators enabled and who wants them to disabled, so that you want disabled power from the devices that are still being used. And this is actually a nice slide, I'm proud of this. I don't know if this needs any explanations. So in self-contained slide but in any case regulator subsystem as many other subsystems in general are operated by these callback functions so that the regulator driver is giving out the functions which are doing the specific operations by writing the hardware registers, for example enabling and disabling and so on. This regulator operation structure is embedded or pointer to pointer that is put in the regulator description and this is registered via regulator register function. After that your regulator will be known by the core and the core start to give the control to users or whoever is requesting this control. There are usually multiple regulators in one power management IC so you will see probably multiple regulator register calls in the probe function of the PIMIC IC driver. This is something that Mark, I was asking Mark if he would be nice enough to check that I don't speak any nonsense here and Mark told me, I suppose you know Mark, Mark is maintaining the regulator subsystem. He told me that there is not so much nonsense but please add something about the constraints. This is why this slide is here. Regulators can have constraints. You can give kind of boundaries, limits within which those regulators must operate for quite obvious safety reasons for example. You don't want to fry your devices. You can give these kinds of constraints from the device tree or from the initialization data and core is passing the device tree and getting the initialization data and it is not forwarding requests that are not within the constraints to the regulator driver so the core is already stopping these bad things from happening. Okay, then the second part which is kind of considering this abnormal conditions and first thing is that we want to detect the unexpected things and in Linux we are dividing these unexpected things to three severity categories. There are protection error and warning and the protection is something that when we are getting over the protection limit the hardware is shutting down the regulator automatically. Software has no kind of interaction there. Error level is something where system is of the specs so that it's assumed that the hardware is no longer working correctly but the hardware is not shutting down the regulator so software should be doing some kind of operation to mitigate the errors or to at least try to save the hardware. And finally there is this warning which is I wrote that this is new wish because it's no longer new I think it has been added in maybe 5.14 but this is the idea of the warning is that it will be informing that something is of the spec but the hardware is still not properly broken but some use case where you might be willing to use warning is for example if you have some reference voltage to some measurement device and you get the warning that this reference voltage has not been good enough so you want to drop maybe some measurements if the voltage reference voltage has been changing too much or something like that. Setting these limits can be done via device tree and there is this format of the property which is the regulator event and then the severity and then the unit and the event itself can be one of those three sorry one of those three over voltage, under voltage or temperature and over current is of course a software I can count and of course we give a value for these properties and zero and one are special values zero meaning disable one meaning enable all the rest are the actual limit value to be configured in the hardware then the question what should we do if the hardware is not supporting the requested limits if the user wants that we will have the protection enabled for 5 volts for example but the hardware cannot support that so device tree says that we want to do that but hardware is not supporting it that's a good question I don't have a good answer device tree options one is of course to abort things and return error not good idea in the regulator probe because the system might not come up and other option is ignore it silently not good option because then the user might expect that things are not getting wrong or there is some protection in place if things get wrong and currently we are just printing an error and proceeding or warning and proceeding from the driver side these limits need to be of course written in the hardware and we have these callback functions in the same place where the rest of the regulator operations are and these callbacks will be then used to write these configurations values in the hardware when core is reading the device tree and then calling these callbacks and there is actually some ongoing work by Benjamin to do do some runtime stuff enabling and disabling these monitoring features by the core when the voltages are changed for example or regulators are enabled or disabled because some of the hardware is such that if you have these protections enabled when you are changing voltages the hardware might be getting errors and shutting down the system for example so Benjamin is doing some upstreaming work for this and then of course this as mentioned earlier these operations are embedded in the regulator description and then we are calling this regulator register and we have the constraints in place when the regulator has been probed I have an example here about how this limits might be set but I think that I will skip it then there is basically two types or two ways to inform these abnormal situations there are errors and there are notifications Errors are basically just state information in the regulator core and it must be polled by consumers there is no way that the core will be informing that hey now I have errors there but this must be polled this is of course clever because sometimes the hardware does not have interrupts for example the signal that there is error so we need some kind of other mechanism to do that but polling is not always preferred we might want to save the cycles so we have the notifications also and this is typically used when the hardware can provide interrupts about these error conditions for shots in many cases the power management ICs are done in such a way that the hardware is not actually releasing the interrupt until the error condition has been cleared so if you don't be careful that your processor will be sitting in the interrupt loop and not doing any mitigations at least for the problem so you need to have some mechanism to prevent that typically by keeping the interrupts masked and so on here we have just a list of the errors you can go and read them from code but they are basically the undervoltage our overcurrent, overvoltage and temperature errors and we also have the similar list for the notifications but there are also other notifications in the kernel not only these notifications but what we are giving when something is wrong so not all the notifications are error notifications we are also providing this kind of helper function to send out the notifications or filter the error flags and this is done because the not all the drivers should be reinventing for example the wheel to prevent this IRQ storm when the hardware is not releasing the interrupt and I think this is quite typical case so we are providing this kind of helper which is offloading some of the work from the drivers I will explain the parameters later but let's first see that what this helper is actually doing so blue box here is the helper code and green box is what your drivers would be still doing in order to use this helper so what happens when we get the some abnormal situation in the hardware is that we get the interrupt there and the interrupt service rotine is run from the helper code the helper will be asking from this driver code that what happened because it does not notice the driver code should be reading out the power management IC registers to determine which regulator was generating the interrupt and what was the reason for this interrupt and this information is returned then to the helper function and in addition it's possible to configure some of the errors so that they are fatal and if the error was fatal then there is two options there is either this kind of die callback which is populated by the driver it's optional, drivers do not need to implement it but it might be implemented and if it is implemented then the die callback will be code and it should be saving the hardware by doing some whatever specific action it is and if the driver is telling that hey we have fatal error and if the die callback is not populated then the helper will be initiating emergency power of your system will be going down so you should be pretty careful when you are using fatal errors or declaring some errors fatal because users won't be happy when the devices go down this is really the last result if it was not fatal then we are sending out the notifications to the consumers and then we are calling this re-enabled callback if it has been implemented to see whether the error is still ongoing or not and if the error is ongoing then we will not be able to interrupt until the condition is okay and we will just if it was not yet clear then we will schedule the re-enabled to be code again later to see if things have been changing I think this is quite clear how this helper is configured there is this kind of struct regulator IRQ desk you will have name and fatal count and so on basic things to be interested in is probably this fatal count which if it is zero it means that this interrupt is never fatal the die won't be called and the emergency power won't be done and this is basically 99% of the cases I think that should be done how it should be done but there is still this one percent then there is the re-read millisecond which means that we wait if the reading of the BIMIC registers has been failing then we will try reading those after this amount of time this is actually something that was done in I think it was one of the Qualcomm drivers before this helper was done and I just wanted to make this helper compatible with this Qualcomm driver so that Qualcomm could be using for example this with the drivers as well then there is the time how long the interrupts will be disabled there is a possibility to keep the handling of the errors which are informing or ignore the errors that are informing problems in the disabled regulators and finally the high prior is just some legacy stuff to do decide whether we are using the high prior to work or not this is also something that was done in this Qualcomm driver maybe it was Qualcomm don't kill me if it wasn't it's a bit difficult dangerous to be mentioning company names here what else we have here is the data pointer which is usually the driver data this driver data is passed to those callback functions when the helper is calling those callbacks and usually it is used so that the regma pointer and things like that can be given to those callbacks and then there are those callbacks this description for the helper is then given for the regulator IRQ helper function which will be kind of enabling this it will be requesting the interrupts and then making it so that if the interrupt is coming this helper function will be which I was breaking down in the picture earlier it will be executed after this regulator IRQ helper function has been called this safety mechanism is in place other things that there needs to be is the IRQ information we want to know what IRQ is informing for what IRQ we are now using this helper and array of regulators because as I mentioned some pimiks have multiple regulators or most of the pimiks have multiple regulators and one IRQ might be used to inform errors in the many of those and then of course the errors that this interrupt can be informing so this map event callback is as I mentioned earlier this is done so that the interrupt reason can be found out and when this is called these parameters will be the pointer to this regulator IRQ data structure and then there will be this device mask and device mask is informing that which of the regulators have fault or enabled and the regulator IRQ data will be containing information like the regulator's status is this is array of the status function and then the number of statuses and again the data pointer and this opaq pointer opaq sorry opaq is not pointer it's long this opaq is used basically only by the driver it's not touched by the regulator core of this helper function and it's intended use case is that the regulator status registers can be stored there so that the re-enabled function can be checking the statuses if they have been changed and this error state we have this array of error states and this error state is having the regulator device and then the active errors and active notifications there or notifications to be sent there so the map event function when code from the pi core should be filling out this information which is in this structure to return the information to the helper that these are the problems we have here then we have this re-enable which test is basically just to check if the state has changed if it is now safe to enable interrupts again or not okay and finally if there is a simple one-to-one mapping from the interrupt to the regulator and the error then this regulator IRQ map event simple can be used as the map event function we have provided also this kind of helper here we have also an example about the mapping function so this map event function I hope you can still be awake it has been a long week I know I can feel it myself but let's try so what the map event is doing it is reading out the status registers for this PD6576 and if the reading is failing it will be returning this regulator failed read fry value which will be then used to determine whether this was successful or not and the helper if this interrupt would be marked as fatal to have the fatal criticality and if we are returning this regulator failed read fry this failed count times then the emergency power would be done but in this case we are not setting this interrupt ever as a fatal then we are checking which of the regulators where they are flagging the errors and setting this device mask based on that actually we are just checking if there was any of those and setting these status in this OPAQ as I mentioned earlier so this OPAQ can be used by the re-enable and here we are populating the device mask which is telling which of the regulators had problems there and finally we are setting this array and all this notification error information in this array of the error statuses in this case we have a bit more complex we don't directly assign the error values here to these notives and errors members because in our case we do decision whether these interrupts are warnings or errors at the probe time based on the device values and at the probe we are then populating this R data information with the correct notification to send and with the correct error status to advertise what we then do we fill out this helper configuration struct we set the time to keep the interrupt disabled for one second and we are giving some name for this that is shown in the interrupt names and then we are populating those callbacks I mentioned earlier then in a loop where we are registering the regulators we are adding information about those regulators that can be sending out these overvolted problems and we are populating this array of those regulators so that we can give this to helper configuration later and then we are setting the information about the errors that this interrupt can be potentially informing about and this is used because otherwise the regulator call or the helper function would not know which status is to clear when the renewable is telling that there is no more problems present there might be, because of course there might be multiple interrupts which are all telling that there are different problems and if we did not populate this information then all the problems would be cleared and maybe that's not the correct kind of thing to do it seems that I am ahead of time so we have more time to discuss and questions but to wrap this up basically as you know powering of a modern SOC is not simple anymore it's not just looking in the power cord the power management IC is something that is trying to integrate the features on chip to save the PCB area and to make it so that we don't need to design whole powering stuff again for each SOC that we are using because quite many power management ICs can also change the start-up and shutdown sequences and some can even be extended so that you can change multiple power management ICs together to get more of those outputs so this and many PMICs have functional safety features and there is some exiting support in Linux kernel to notify about these events I hope you have some questions and if there is no questions I at least hope that there are some ideas where these events and notifications are used because I assume that they exist in the kernel for a reason I just don't know this reason so I would be very interested in hearing if you have been ever using this and where these have been used you've been using that SOC for what if I may ask, can you tell it? Yeah, for that Polkom regulator driver that you were mentioning Do you know how the consumers are using those events? I wrote the driver, so yes So you wrote also the consumer drivers? Yes Great, so can you tell where these are used? I actually don't really remember That happened like 5 years ago or something? That happened like 5 years ago or something? Yeah, it's a bit shady Yeah, no problem There is at least one question This is more of a design question Can you go to slide 22 please? Okay, 22 Yeah, this one So I was looking at this reread milliseconds I was wondering this would also be useful for example for touch controllers because they are also on I2C and sometimes the I2C is also flaky Would it be possible to move this closer to the core? This kind of functionality because it's not isolated to regulators Good question I probably need something like a few hours of sleep first and then I can take a look at the code and tell you if I can move it or if I can plan it but yeah I at least won't say that this is not something that should be investigated Yeah So the I2C core supports that you add you can quantify the number of rereads it should try but this is not a good measure usually but you can define a time frame how long it should try to retry if that makes sense for touch screen controllers but that is already in there So basically this reread this is the time that we are waiting for before rereading and I think that for this Qualcomm driver that was mentioned there was this kind of thinking that if for example the I2C is overheating quite badly then the reading out the registers might be failing and that was basically why the rereading if the rereading was failing enough of times then we will be doing this shut down to try to save at least some of the hardware So this information is passed to the I2C core already This is not in the I2C core but you said that something is there I think the difference is what you can tell the I2C core is for how long it should retry and what you specify here is Is a discrete delay between the retries So this is I think driver specific and that should not be in the I2C core because only the driver know what a reasonable delay between the reads is, right? Yeah I think but on the other hand I guess we will introduce new callbacks which have all an additional parameter like but this would be like Well yeah but maybe then you can de-ruplicate this functionality in the I2C core, right? I can't remember So I have one more question which is unrelated to this and it's on slide 26 Marek, you are quite amazing on that So I was curious about this one you have RekmaBread here and it probably returns some sort of an error, right? So how do you do error propagation here because you obviously cannot do like return rat, you have to do like return regulator something here Is the error just discarded from the RekmaBread? If RekmaBread is failing Yeah, so then we are sending or returning this regulator failed retry Yeah but can we also propagate the error from the help code? I think that it silently ignored unless the where I had this this configuration here unless this fatal count is populated and if this fatal count is populated and you are failing to read more than the fatal count times in a row then we will be doing this emergency either the callback or the shutdown but otherwise we are not for example printing anything from the interrupt I think Thanks Yeah, thanks for the presentation really cool stuff and about the error on that slide 26 Is there a reason? Is it a global variable? It's not like the local to the function Maybe someone else uses it Which? Yeah I think that this example might not be complete Okay Actually I had more text on this slide first and then I was really reading the instructions how to build this slide set and there was this different kind of scale for the papers that I had been expecting so I had to squeeze it even more so there might be even less information in this function I thought just maybe there is something like get Erno after that that you can use to retrieve it but it's fine So my question is how regulator subsystem is connected to clock subsystem I think because if we go to DVFS example it's both simultaneous like it's clock and regulator is it done on a higher level? I think it's done in the higher level and I think that you might have answered it there also So the DVFS driver or the DVFS core handles both regulators and clocks so if you're raising the frequency it will first boost the voltage then raise the clock and if you're lowering the frequency then it does it in the opposite order so it's handled at the DVFS core or CPU Freak core level and not the individual subsystems Thank you and also one comment on the regulator constraints the constraints are supposed to describe the constraints of the regulator consumer so if you're just copying the values from your PMIC datasheet then you're doing it wrong So then you are not constrainin anything to hardware wouldn't be already constrainin So yeah, correct You have asked at the beginning about some examples for your abnormal events which can be used in some real case scenarios and I know that in automotive we are using usually undervoltage events like in the car there are a lot of undervoltage events and in this case you should just execute as less as possible of preparation for this kind of power loss so for example prepare AMMC that it will be disabled soon just to avoid damage of AMMC for example Thank you This makes sense because when I was first implementing this safety stuff in a PMIC this was a PMIC that was intended to be used in the automotive side and I think that we had a customer request for these safety features there but I have never heard why and what was used so this makes kind of sense Thank you Exactly the information I was hoping to hear Last question then because we're at time So yeah, after previous question I just realized that in automotive they also lock all these undervoltage overvoltage errors in the diagnostics information so you can see that this block was undervoltaged or overvoltage I mean at least in some cars Yeah, makes sense So thank you for joining