[PATCH] hwmon: (ina3221) Add summation feature support

2019-10-16 Thread Nicolin Chen
voltage sum register, if all shunt resistors are equivalent. Signed-off-by: Nicolin Chen --- Hi Guenter, I know my previous questions haven't been answered yet, so nodes for enabling bits aren't decided completely. But this patch only adds voltage and its current, and we had a conclusion

Re: [PATCH] hwmon: (ina3221) Add summation feature support

2019-10-21 Thread Nicolin Chen
On Sun, Oct 20, 2019 at 09:36:28AM -0700, Guenter Roeck wrote: > On Wed, Oct 16, 2019 at 04:57:02PM -0700, Nicolin Chen wrote: > > This patch implements the summation feature of INA3221, mainly the > > SCC (enabling) and SF (warning flag) bits of MASK_ENABLE register, > &

[PATCH] hwmon (ina3221) Add single-shot mode support

2018-11-12 Thread Nicolin Chen
odes. Signed-off-by: Nicolin Chen --- Documentation/hwmon/ina3221 | 3 + drivers/hwmon/ina3221.c | 109 2 files changed, 112 insertions(+) diff --git a/Documentation/hwmon/ina3221 b/Documentation/hwmon/ina3221 index 4b82cbfb551c..b03f4ad901ee 100644 --- a

Re: [PATCH] hwmon (ina3221) Add single-shot mode support

2018-11-12 Thread Nicolin Chen
Hi Guenter, On Mon, Nov 12, 2018 at 08:32:48PM -0800, Guenter Roeck wrote: > On Mon, Nov 12, 2018 at 08:23:53PM -0800, Nicolin Chen wrote: > > INA3221 supports both continuous and single-shot modes. When > > running in the continuous mode, it keeps measuring the inputs > > a

Re: [PATCH] hwmon (ina3221) Add single-shot mode support

2018-11-13 Thread Nicolin Chen
Hi Guenter, On Tue, Nov 13, 2018 at 09:21:02AM -0800, Guenter Roeck wrote: > > > > INA3221 supports both continuous and single-shot modes. When > > > > running in the continuous mode, it keeps measuring the inputs > > > > and converting them to the data register even if there are no > > > > users

Re: [PATCH] hwmon (ina3221) Add single-shot mode support

2018-11-16 Thread Nicolin Chen
Hello Guenter, On Wed, Nov 14, 2018 at 09:23:30AM -0800, Guenter Roeck wrote: > > An alternative way (without the sysfs node), after looking at > > other hwmon code, could be to have a timed polling thread and > > read data using an update_interval value from ABI. This might > > turn out to be mor

[PATCH] Documentation: hwmon: Add descriptions for ina2xx sysfs entries

2018-11-19 Thread Nicolin Chen
There are a few sysfs entries being exposed to user space by the ina2xx hwmon driver while not getting explicitly documented. So this patch just adds a description section for them. Signed-off-by: Nicolin Chen --- Documentation/hwmon/ina2xx | 15 +++ 1 file changed, 15 insertions

Re: [PATCH] hwmon (ina3221) Add single-shot mode support

2018-11-19 Thread Nicolin Chen
On Mon, Nov 19, 2018 at 09:45:59AM -0800, Guenter Roeck wrote: > > In short, other than exposing it via a generic ABI to the user > > space, how about defining some policy to maintaining it within > > the driver? > I think that would be a bad idea. It changes timing for everyone > curently using t

[RFC][PATCH] hwmon: (ina2xx) Improve current and power reading precision

2018-11-20 Thread Nicolin Chen
mA power1_input = 62800 uW (expected 62965 uW) === Summary === - "shunt_resistor" attribute sets rshunt and "max_curr" boundaries - "max_curr" sysfs attribute decides current_lsb_uA and power_lsb_uW - ina2xx_init() still uses 4096|2048 as default calibration setting * Al

Re: [RFC][PATCH] hwmon: (ina2xx) Improve current and power reading precision

2018-11-21 Thread Nicolin Chen
(Removing "m.pur...@samsung.com" since it's not reachable any more) Hi Stefan, Thank you for the comments. On Wed, Nov 21, 2018 at 04:13:01PM +, Brüns, Stefan wrote: > > === Problem === > > Both methods simplify software routine by fixing one factor, which > > sacrifices the precision of the

Re: [RFC][PATCH] hwmon: (ina2xx) Improve current and power reading precision

2019-01-04 Thread Nicolin Chen
Hi Stefan, Sorry for a super late reply. I took a long vacation. On Wed, Nov 21, 2018 at 10:16:09PM +, Brüns, Stefan wrote: > > > Another concern may be voltage drop over the shunt, but for this case you > > > have a nominal voltage of 1.8V, so 30uV are 0.001%. > > > > > > > When measuring a

Re: [RFC][PATCH] hwmon: (ina2xx) Improve current and power reading precision

2019-01-17 Thread Nicolin Chen
On Fri, Jan 04, 2019 at 05:26:42PM -0800, Nicolin Chen wrote: > Hi Stefan, > > Sorry for a super late reply. I took a long vacation. > > On Wed, Nov 21, 2018 at 10:16:09PM +, Brüns, Stefan wrote: > > > > Another concern may be voltage drop over the shunt, but

Re: [RFC][PATCH] hwmon: (ina2xx) Improve current and power reading precision

2019-01-17 Thread Nicolin Chen
Hi Guenter, On Thu, Jan 17, 2019 at 03:13:23PM -0800, Guenter Roeck wrote: > I have one claim stating that your change won't make a difference, > and your claim that it would. That leaves me with no choice but to > spend a large amount of time with the datasheet, and possibly with > my evaluation

[PATCH v2 0/2] Add an initial DT binding doc for ina3221

2018-09-21 Thread Nicolin Chen
This series adds a initial DT binding doc for ina3221. It defines a child node to describe the input source of each ina3221 channel. Then it changes the driver to handle the information properly. Changelog v1->v2: * Redefined DT bindings (detail in PATCH-1) * Changed the driver code accordingly

[PATCH v2 1/2] dt-bindings: hwmon: Add ina3221 documentation

2018-09-21 Thread Nicolin Chen
Texas Instruments INA3221 is a triple-channel shunt and bus voltage monitor. This patch adds a DT binding doc for it. Signed-off-by: Nicolin Chen --- Changelog v1->v2: * Dropped channel name properties * Added child node definitions. * * Added shunt resistor property in the child n

[PATCH v2 2/2] hwmon: ina3221: Read channel input source info from DT

2018-09-21 Thread Nicolin Chen
From: Nicolin Chen An ina3221 chip has three input ports. Each port is used to measure the voltage and current of its input source. The DT binding now has defined bindings for their input sources, so the driver should read these information and handle accordingly. This patch adds a new

Re: [PATCH v2 1/2] dt-bindings: hwmon: Add ina3221 documentation

2018-09-21 Thread Nicolin Chen
Found two mistakes at this doc, sending v3. On Fri, Sep 21, 2018 at 1:12 PM Nicolin Chen wrote: > +++ b/Documentation/devicetree/bindings/hwmon/ina3221.txt > @@ -0,0 +1,38 @@ > +ina3221 properties > + Should be a description of the doc. > + VDD_GPU { > + s

[PATCH v3 0/2] Add an initial DT binding doc for ina3221

2018-09-21 Thread Nicolin Chen
ndings (detail in PATCH-1) * Changed the driver code accordingly (detail in PATCH-2) Nicolin Chen (2): dt-bindings: hwmon: Add ina3221 documentation hwmon: ina3221: Read channel input source info from DT .../devicetree/bindings/hwmon/ina3221.txt | 38 ++ Documentation/hwmon/i

[PATCH v3 2/2] hwmon: ina3221: Read channel input source info from DT

2018-09-21 Thread Nicolin Chen
From: Nicolin Chen An ina3221 chip has three input ports. Each port is used to measure the voltage and current of its input source. The DT binding now has defined bindings for their input sources, so the driver should read these information and handle accordingly. This patch adds a new

[PATCH v3 1/2] dt-bindings: hwmon: Add ina3221 documentation

2018-09-21 Thread Nicolin Chen
Texas Instruments INA3221 is a triple-channel shunt and bus voltage monitor. This patch adds a DT binding doc for it. Signed-off-by: Nicolin Chen --- Changelog v2->v3: * Added a simple subject in the line 1 * Fixed the shunt resistor value in the example v1->v2: * Dropped channe

Re: [PATCH v3 1/2] dt-bindings: hwmon: Add ina3221 documentation

2018-09-22 Thread Nicolin Chen
> >+2) child nodes > >+ The names of child nodes should indicate input source names > >+ > >+ Required properties: > >+ - input-id: Must be 1, 2 or 3 > >+ > >+ Optional properties: > >+ - shunt-resistor: Shunt resistor value in micro-Ohm > >+ - status: Should be "disabled" if no input source

Re: [PATCH v3 2/2] hwmon: ina3221: Read channel input source info from DT

2018-09-22 Thread Nicolin Chen
> >This patch adds a new structure of input source specific > >information including input source label, shunt resistor > >value and its connection status. It exposes these labels > >via sysfs and also disables those channels where there's > >no input source being connected. > > > > I see you have

Re: [PATCH v3 2/2] hwmon: ina3221: Read channel input source info from DT

2018-09-22 Thread Nicolin Chen
On Sat, Sep 22, 2018 at 04:59:55PM -0700, Guenter Roeck wrote: > > > > + /* Disable channels if their inputs are disconnected */ > > > > + for (i = 0, mask = 0; i < INA3221_NUM_CHANNELS; i++) { > > > > + if (ina->inputs[i].disconnected) > > > > + mas

Re: [PATCH v3 2/2] hwmon: ina3221: Read channel input source info from DT

2018-09-22 Thread Nicolin Chen
On Sat, Sep 22, 2018 at 05:38:41PM -0700, Nicolin Chen wrote: > On Sat, Sep 22, 2018 at 04:59:55PM -0700, Guenter Roeck wrote: > > > > > > + /* Disable channels if their inputs are disconnected */ > > > > > + for (i = 0, m

Re: [PATCH v3 2/2] hwmon: ina3221: Read channel input source info from DT

2018-09-22 Thread Nicolin Chen
On Sat, Sep 22, 2018 at 07:07:02PM -0700, Guenter Roeck wrote: > On 09/22/2018 05:38 PM, Nicolin Chen wrote: > >On Sat, Sep 22, 2018 at 04:59:55PM -0700, Guenter Roeck wrote: > > > >>>>>+/* Disable channels if their inputs are disconnected */ > &

Re: [PATCH v3 2/2] hwmon: ina3221: Read channel input source info from DT

2018-09-22 Thread Nicolin Chen
On Sat, Sep 22, 2018 at 08:33:00PM -0700, Nicolin Chen wrote: > On Sat, Sep 22, 2018 at 07:07:02PM -0700, Guenter Roeck wrote: > > On 09/22/2018 05:38 PM, Nicolin Chen wrote: > > >On Sat, Sep 22, 2018 at 04:59:55PM -0700, Guenter Roeck wrote: > > > > > >>

[PATCH v4 0/2] Add an initial DT binding doc for ina3221

2018-09-22 Thread Nicolin Chen
ver accordingly and added is_visible (PATCH-2) v2->v3: * Fixed two places in DT bindings (PATCH-1) v1->v2: * Redefined DT bindings (detail in PATCH-1) * Changed the driver code accordingly (detail in PATCH-2) Nicolin Chen (2): dt-bindings: hwmon: Add ina3221 documentation hwmon: ina3221: Rea

[PATCH v4 1/2] dt-bindings: hwmon: Add ina3221 documentation

2018-09-22 Thread Nicolin Chen
Texas Instruments INA3221 is a triple-channel shunt and bus voltage monitor. This patch adds a DT binding doc for it. Signed-off-by: Nicolin Chen --- Changelog v3->v4: * Removed the attempt of putting labels in the node names * Added a new optional label property in the child node * Upda

[PATCH v4 2/2] hwmon: ina3221: Read channel input source info from DT

2018-09-22 Thread Nicolin Chen
specific information including input source label, shunt resistor value and its connection status. It exposes these labels via sysfs if available and also disables those channels where there's no input source being connected. Signed-off-by: Nicolin Chen --- Changelog v3->v4: * Added is

Re: [PATCH v4 2/2] hwmon: ina3221: Read channel input source info from DT

2018-09-22 Thread Nicolin Chen
Thank you for the quick response! On Sat, Sep 22, 2018 at 10:11:26PM -0700, Guenter Roeck wrote: > >+static umode_t ina3221_attr_is_visible(struct kobject *kobj, > >+ struct attribute *attr, int n) > >+{ > >+const int max_attrs = ARRAY_SIZE(ina3221_attrs) - 1;

Re: [PATCH v4 1/2] dt-bindings: hwmon: Add ina3221 documentation

2018-09-22 Thread Nicolin Chen
On Sat, Sep 22, 2018 at 10:19:42PM -0700, Guenter Roeck wrote: > >+2) child nodes > >+ Required properties: > >+ - input-id: Must be 1, 2 or 3 > >+ > >+ Optional properties: > >+ - input-label: Name of the input source > >+ - shunt-resistor: Shunt resistor value in micro-Ohm > >+ - status: Sh

Re: [PATCH v4 1/2] dt-bindings: hwmon: Add ina3221 documentation

2018-09-22 Thread Nicolin Chen
On Sat, Sep 22, 2018 at 10:45:49PM -0700, Guenter Roeck wrote: > On 09/22/2018 10:31 PM, Nicolin Chen wrote: > > On Sat, Sep 22, 2018 at 10:19:42PM -0700, Guenter Roeck wrote: > > > > +2) child nodes > > > > + Required properties: > &g

Re: [PATCH v4 1/2] dt-bindings: hwmon: Add ina3221 documentation

2018-09-23 Thread Nicolin Chen
On Sat, Sep 22, 2018 at 11:36:22PM -0700, Guenter Roeck wrote: > >+ Optional properties: > >+ - input-label: Name of the input source > > Just noticed the "input-" here. Please just use "label". Will fix in v5. > >+ input1 { > >+ input-id = <0x1>; > > We'll h

[PATCH v5 2/2] hwmon: ina3221: Read channel input source info from DT

2018-09-25 Thread Nicolin Chen
specific information including input source label, shunt resistor value and its connection status. It exposes these labels via sysfs if available and also disables those channels where there's no input source being connected. Signed-off-by: Nicolin Chen --- Changelog v4->v5: * Replace

[PATCH v5 0/2] Add an initial DT binding doc for ina3221

2018-09-25 Thread Nicolin Chen
d the driver code accordingly (detail in PATCH-2) Nicolin Chen (2): dt-bindings: hwmon: Add ina3221 documentation hwmon: ina3221: Read channel input source info from DT .../devicetree/bindings/hwmon/ina3221.txt | 49 ++ Documentation/hwmon/ina3221 | 1 + drivers/hwm

[PATCH v5 1/2] dt-bindings: hwmon: Add ina3221 documentation

2018-09-25 Thread Nicolin Chen
Texas Instruments INA3221 is a triple-channel shunt and bus voltage monitor. This patch adds a DT binding doc for it. Signed-off-by: Nicolin Chen --- Changelog v4->v5: * Replaced "input-id" with "reg" and added address-cells and size-cells * Replaced "input-lab

Re: [PATCH v5 1/2] dt-bindings: hwmon: Add ina3221 documentation

2018-09-25 Thread Nicolin Chen
Hello Guenter, On Tue, Sep 25, 2018 at 06:52:29PM -0700, Guenter Roeck wrote: > > +2) child nodes > > + Required properties: > > + - reg: Must be 0, 1 or 2, corresponding to IN1, IN2 or IN3 port of > > INA3221 > > + > > + Optional properties: > > + - label: Name of the input source > > + -

Re: [PATCH v5 1/2] dt-bindings: hwmon: Add ina3221 documentation

2018-09-25 Thread Nicolin Chen
On Tue, Sep 25, 2018 at 08:40:59PM -0700, Guenter Roeck wrote: > >>>+2) child nodes > >>>+ Required properties: > >>>+ - reg: Must be 0, 1 or 2, corresponding to IN1, IN2 or IN3 port of > >>>INA3221 > >>>+ input@0 { > >>>+ reg = <0x0>; > >>>+ status = "disabled"; > >>saying

[PATCH 1/2] hwmon: ina3221: Add power sysfs nodes

2018-09-25 Thread Nicolin Chen
The hwmon sysfs ABI supports powerX_input and powerX_crit. This can ease user space programs who care more about power in total than voltage or current individually. So this patch adds these two sysfs nodes for INA3221 driver. Signed-off-by: Nicolin Chen --- Documentation/hwmon/ina3221 | 4

[PATCH 2/2] hwmon: ina3221: Add enable sysfs nodes

2018-09-25 Thread Nicolin Chen
ds to check if the attribute is read-only to make sure it's not reading a configuration but the sensor data. Signed-off-by: Nicolin Chen --- Documentation/hwmon/ina3221 | 1 + drivers/hwmon/ina3221.c | 85 + 2 files changed, 86 insertions(+) di

[PATCH 0/2] hwmon: ina3221: Add power and enable sysfs nodes

2018-09-25 Thread Nicolin Chen
As this patch is still under review (waiting for an ack from DT binding side), these two patches can only go through review at this point -- needs to wait for the patch above getting merged first. Nicolin Chen (2): hwmon: ina3221: Add power sysfs nodes hwmon: ina3221: Add en

Re: [PATCH 2/2] hwmon: ina3221: Add enable sysfs nodes

2018-09-26 Thread Nicolin Chen
On Wed, Sep 26, 2018 at 06:06:32AM -0700, Guenter Roeck wrote: > On 09/25/2018 11:42 PM, Nicolin Chen wrote: > > The inX_enable interface allows user space to enable or disable > > the corresponding channel. Meanwhile, according to hwmon ABI, a > > disabled channel/sensor shou

Re: [PATCH 1/2] hwmon: ina3221: Add power sysfs nodes

2018-09-26 Thread Nicolin Chen
On Wed, Sep 26, 2018 at 05:34:53AM -0700, Guenter Roeck wrote: > Hi Nicolin, > > On 09/25/2018 11:42 PM, Nicolin Chen wrote: > > The hwmon sysfs ABI supports powerX_input and powerX_crit. This > > can ease user space programs who care more about power in total > &

Re: [PATCH 1/2] hwmon: ina3221: Add power sysfs nodes

2018-09-26 Thread Nicolin Chen
Hello Guenter, On Wed, Sep 26, 2018 at 12:45:34PM -0700, Guenter Roeck wrote: > Hi Nicolin, > > On Wed, Sep 26, 2018 at 11:20:06AM -0700, Nicolin Chen wrote: > > On Wed, Sep 26, 2018 at 05:34:53AM -0700, Guenter Roeck wrote: > > > Hi Nicolin, > > > > >

Re: [PATCH 2/2] hwmon: ina3221: Add enable sysfs nodes

2018-09-26 Thread Nicolin Chen
Hello, On Wed, Sep 26, 2018 at 12:58:17PM -0700, Guenter Roeck wrote: > On Wed, Sep 26, 2018 at 11:02:44AM -0700, Nicolin Chen wrote: > > On Wed, Sep 26, 2018 at 06:06:32AM -0700, Guenter Roeck wrote: > > > On 09/25/2018 11:42 PM, Nicolin Chen wrote: > > > > The in

Re: [PATCH 2/2] hwmon: ina3221: Add enable sysfs nodes

2018-09-26 Thread Nicolin Chen
On Wed, Sep 26, 2018 at 01:44:55PM -0700, Guenter Roeck wrote: > On Wed, Sep 26, 2018 at 01:25:20PM -0700, Nicolin Chen wrote: > > Hello, > > > > On Wed, Sep 26, 2018 at 12:58:17PM -0700, Guenter Roeck wrote: > > > On Wed, Sep 26, 2018 at 11:02:44AM -0700, Nicolin C

Re: [PATCH 2/2] hwmon: ina3221: Add enable sysfs nodes

2018-09-27 Thread Nicolin Chen
Hello Guenter, On Thu, Sep 27, 2018 at 09:05:09AM -0700, Guenter Roeck wrote: > > > Point is that I don't _know_ how this is going to be used, so I'd > > > rather keep it flexible. > > > > Well, taking one step back, I am okay to follow your way if you > > are really firm about it. Just please gi

Re: [PATCH v5 1/2] dt-bindings: hwmon: Add ina3221 documentation

2018-09-27 Thread Nicolin Chen
On Thu, Sep 27, 2018 at 12:44:13PM -0500, Rob Herring wrote: > > +2) child nodes > > + Required properties: > > + - reg: Must be 0, 1 or 2, corresponding to IN1, IN2 or IN3 port of > > INA3221 > > + > > + Optional properties: > > + - label: Name of the input source > > + - shunt-resistor-micr

[PATCH v6 0/2] Add an initial DT binding doc for ina3221

2018-09-27 Thread Nicolin Chen
* Fixed two places in DT bindings (PATCH-1) v1->v2: * Redefined DT bindings (detail in PATCH-1) * Changed the driver code accordingly (detail in PATCH-2) Nicolin Chen (2): dt-bindings: hwmon: Add ina3221 documentation hwmon: ina3221: Read channel input source info from DT .../devicetree

[PATCH v6 1/2] dt-bindings: hwmon: Add ina3221 documentation

2018-09-27 Thread Nicolin Chen
Texas Instruments INA3221 is a triple-channel shunt and bus voltage monitor. This patch adds a DT binding doc for it. Signed-off-by: Nicolin Chen --- Changelog v5->v6: * Removed status property as no need to explicitly list it. * Combined all examples into a complete one. v4->v5: * Re

[PATCH v6 2/2] hwmon: ina3221: Read channel input source info from DT

2018-09-27 Thread Nicolin Chen
for users to get control of three channels, and returns -ENODATA code for any sensor read according to hwmon ABI. Signed-off-by: Nicolin Chen --- Changelog v5->v6: * Removed the code of hiding disconnected channels * Added in[123]_label sysfs nodes to control channels * Added -ENODATA ret

Re: [PATCH v6 1/2] dt-bindings: hwmon: Add ina3221 documentation

2018-09-27 Thread Nicolin Chen
On Thu, Sep 27, 2018 at 03:38:44PM -0500, Rob Herring wrote: > On Thu, Sep 27, 2018 at 2:49 PM Nicolin Chen wrote: > > > > Texas Instruments INA3221 is a triple-channel shunt and bus > > voltage monitor. This patch adds a DT binding doc for it. > > >

[PATCH v7 2/2] hwmon: ina3221: Read channel input source info from DT

2018-09-27 Thread Nicolin Chen
for users to get control of three channels, and returns -ENODATA code for any sensor read according to hwmon ABI. Signed-off-by: Nicolin Chen --- Changelog v6->v7: * N/A v5->v6: * Removed the code of hiding disconnected channels * Added in[123]_label sysfs nodes to control channels *

[PATCH v7 1/2] dt-bindings: hwmon: Add ina3221 documentation

2018-09-27 Thread Nicolin Chen
Texas Instruments INA3221 is a triple-channel shunt and bus voltage monitor. This patch adds a DT binding doc for it. Signed-off-by: Nicolin Chen --- Changelog v6->v7: * Restored three channel examples and merged them with the parent one v5->v6: * Removed status property as no n

[PATCH v7 0/2] Add an initial DT binding doc for ina3221

2018-09-27 Thread Nicolin Chen
d the driver accordingly and added is_visible (PATCH-2) v2->v3: * Fixed two places in DT bindings (PATCH-1) v1->v2: * Redefined DT bindings (detail in PATCH-1) * Changed the driver code accordingly (detail in PATCH-2) Nicolin Chen (2): dt-bindings: hwmon: Add ina3221 documentation hw

Re: [PATCH v7 2/2] hwmon: ina3221: Read channel input source info from DT

2018-09-27 Thread Nicolin Chen
On Thu, Sep 27, 2018 at 03:06:20PM -0700, Guenter Roeck wrote: > I am quite sure I asked to use kstrtobool(). Did that get lost or do you have > some reason to not use it ? > > I can understand if you don't want to change ina3221_is_enable() to > ina3221_is_enabled(), since that is POV, but I do

Re: [PATCH 2/2] hwmon: ina3221: Add enable sysfs nodes

2018-09-27 Thread Nicolin Chen
On Wed, Sep 26, 2018 at 06:06:32AM -0700, Guenter Roeck wrote: > > +static inline bool ina3221_is_enable(struct ina3221_data *ina, int channel) > > s/is_enable/is_enabled/, maybe ? Fixing. > > + return (config & INA3221_CONFIG_CHx_EN(channel)) > 0; > > The "> 0" is unnecessary. Conversion to

Re: [PATCH 2/2] hwmon: ina3221: Add enable sysfs nodes

2018-09-27 Thread Nicolin Chen
On Thu, Sep 27, 2018 at 03:52:00PM -0700, Guenter Roeck wrote: > The proper fix for this problem would be to add support for suspend / > resume to the driver. At resume time, all channels will have been > re-enabled if the chip was powered off, even if they were explicitly > disabled by devicetree

[PATCH v8 2/2] hwmon: ina3221: Read channel input source info from DT

2018-09-28 Thread Nicolin Chen
for users to get control of three channels, and returns -ENODATA code for any sensor read according to hwmon ABI. Signed-off-by: Nicolin Chen --- Changelog v7->v8: * Rebased the change after the new suspend-resume patch * * Please apply suspend-resume patch prior to this one * Rena

[PATCH v8 0/2] Add an initial DT binding doc for ina3221

2018-09-28 Thread Nicolin Chen
ed one place in child DT node bindings (PATCH-1) * Changed the driver accordingly and added is_visible (PATCH-2) v2->v3: * Fixed two places in DT bindings (PATCH-1) v1->v2: * Redefined DT bindings (detail in PATCH-1) * Changed the driver code accordingly (detail in PATCH-2) Nicolin Ch

[PATCH v8 1/2] dt-bindings: hwmon: Add ina3221 documentation

2018-09-28 Thread Nicolin Chen
Texas Instruments INA3221 is a triple-channel shunt and bus voltage monitor. This patch adds a DT binding doc for it. Signed-off-by: Nicolin Chen --- Changelog v7->v8: * N/A v6->v7: * Restored three channel examples and merged them with the parent one v5->v6: * Removed status prope

Re: [PATCH v8 2/2] hwmon: ina3221: Read channel input source info from DT

2018-09-30 Thread Nicolin Chen
On Sun, Sep 30, 2018 at 01:55:18PM -0700, Guenter Roeck wrote: > Hi Nicolin, > > On 09/28/2018 06:39 PM, Nicolin Chen wrote: > >An ina3221 chip has three input ports. Each port is used > >to measure the voltage and current of its input source. > > > >The DT bin

[PATCH v9 1/2] dt-bindings: hwmon: Add ina3221 documentation

2018-10-01 Thread Nicolin Chen
Texas Instruments INA3221 is a triple-channel shunt and bus voltage monitor. This patch adds a DT binding doc for it. Signed-off-by: Nicolin Chen --- Changelog v7->v9: * N/A v6->v7: * Restored three channel examples and merged them with the parent one v5->v6: * Removed status prope

[PATCH v9 2/2] hwmon: (ina3221) Read channel input source info from DT

2018-10-01 Thread Nicolin Chen
for users to get control of three channels, and returns -ENODATA code for any sensor read according to hwmon ABI. Signed-off-by: Nicolin Chen --- Changelog v8->v9: * Renamed the subject by following hwmon naming convention * Rebased the patch after the merged ina3221 changes * Fixed

[PATCH v9 0/2] Add an initial DT binding doc for ina3221

2018-10-01 Thread Nicolin Chen
driver code accordingly (detail in PATCH-2) Nicolin Chen (2): dt-bindings: hwmon: Add ina3221 documentation hwmon: (ina3221) Read channel input source info from DT .../devicetree/bindings/hwmon/ina3221.txt | 44 Documentation/hwmon/ina3221 | 2 +

Re: [PATCH v9 1/2] dt-bindings: hwmon: Add ina3221 documentation

2018-10-02 Thread Nicolin Chen
On Tue, Oct 02, 2018 at 10:05:18AM -0700, Guenter Roeck wrote: > Hi Nicolin, > > On Mon, Oct 01, 2018 at 06:05:22PM -0700, Nicolin Chen wrote: > > Texas Instruments INA3221 is a triple-channel shunt and bus > > voltage monitor. This patch adds a DT binding doc for it. &

[PATCH 0/2] hwmon: Add operating mode support for core and ina3221

2018-10-09 Thread Nicolin Chen
Add operating mode support in the core and ina3221. Nicolin Chen (2): hwmon: (core) Add hwmon_mode structure and mode sysfs node hwmon: (ina3221) Add operating mode support Documentation/hwmon/sysfs-interface | 15 + drivers/hwmon/hwmon.c | 87

[PATCH 2/2] hwmon: (ina3221) Add operating mode support

2018-10-09 Thread Nicolin Chen
The hwmon core now has a new optional mode interface. So this patch just implements this mode support so that user space can check and configure via sysfs node its operating modes: power-down, one-shot, and continuous modes. Signed-off-by: Nicolin Chen --- drivers/hwmon/ina3221.c | 64

[PATCH 1/2] hwmon: (core) Add hwmon_mode structure and mode sysfs node

2018-10-09 Thread Nicolin Chen
"mode" and "available_modes" for user to check and configure the operating mode. For hwmon device drivers that implemented the _with_info API, the change also adds an optional hwmon_mode structure in hwmon_chip_info structure so that those drivers can pass mode related information

Re: [PATCH 1/2] hwmon: (core) Add hwmon_mode structure and mode sysfs node

2018-10-10 Thread Nicolin Chen
Hi Guenter, On Wed, Oct 10, 2018 at 06:08:30AM -0700, Guenter Roeck wrote: > > +available_modes The available operating modes of the chip. > > + This should be short, lowercase string, not containing > > + whitespace, or the wildcard character '*'. > > + This attribut

Re: [PATCH 2/2] hwmon: (ina3221) Add operating mode support

2018-10-10 Thread Nicolin Chen
kind of support though. > I am open to help explore adding support for runtime power management > to the hwmon subsystem, but that would be less than straightforward and > require an actual use case to warrant the effort. Is there any feasible solution from your point of view? Thanks Nico

Re: [PATCH 2/2] hwmon: (ina3221) Add operating mode support

2018-10-10 Thread Nicolin Chen
Hi Guenter, On Wed, Oct 10, 2018 at 04:43:00PM -0700, Guenter Roeck wrote: > > > The effort to do all this using CPU cycles would in most if not all cases > > > outweigh any perceived power savings. As such, I just don't see the > > > practical use case. > > > > It really depends on the use case

Re: [PATCH 2/2] hwmon: (ina3221) Add operating mode support

2018-10-11 Thread Nicolin Chen
On Thu, Oct 11, 2018 at 12:31:52PM -0700, Guenter Roeck wrote: > > One more question here, and this might sound a bit abuse of using > > the existing hwmon ABI: would it sound plausible to you that the > > driver powers down the chip when all three channels get disabled > > via in[123]_enable node

Re: [PATCH 2/2] hwmon: (ina3221) Add operating mode support

2018-10-11 Thread Nicolin Chen
On Thu, Oct 11, 2018 at 12:50:25PM -0700, Guenter Roeck wrote: > Hi Nicolin, > > On Thu, Oct 11, 2018 at 12:36:59PM -0700, Nicolin Chen wrote: > > On Thu, Oct 11, 2018 at 12:31:52PM -0700, Guenter Roeck wrote: > > > > > > One more question here, and this

[PATCH v7 00/13] iommufd: Add vIOMMU infrastructure (Part-1)

2024-11-05 Thread Nicolin Chen
IOMMU_INVALIDATE uAPI; Instead, reuse the HWPT one * Reworked mock_viommu_cache_invalidate() using the new iommu helper * Reordered details of set/unset_vdev_id handlers for proper lockings v1 https://lore.kernel.org/all/cover.1723061377.git.nicol...@nvidia.com/ Thanks! Nicolin Nicolin Chen (

[PATCH v7 02/13] iommufd: Move _iommufd_object_alloc helper to a sharable file

2024-11-05 Thread Nicolin Chen
remaining to be selectable for drivers to build the existing iova_bitmap.c file. Suggested-by: Jason Gunthorpe Reviewed-by: Jason Gunthorpe Signed-off-by: Nicolin Chen --- drivers/iommu/iommufd/Kconfig | 4 +++ drivers/iommu/iommufd/Makefile | 1 + drivers/iommu/iommufd

[PATCH v7 01/13] iommufd: Move struct iommufd_object to public iommufd header

2024-11-05 Thread Nicolin Chen
; }; It has to expose struct iommufd_object and enum iommufd_object_type from the core-level private header to the public iommufd header. Reviewed-by: Jason Gunthorpe Reviewed-by: Kevin Tian Signed-off-by: Nicolin Chen --- drivers/iommu/iommufd/iommufd_private.h | 25

[PATCH v7 04/13] iommufd: Verify object in iommufd_object_finalize/abort()

2024-11-05 Thread Nicolin Chen
more robust to verify if the xarray slot indexed by the input obj->id is having an XA_ZERO_ENTRY, which is the reserved value stored by xa_alloc via iommufd_object_alloc. Suggested-by: Jason Gunthorpe Reviewed-by: Jason Gunthorpe Signed-off-by: Nicolin Chen --- drivers/iommu/iommufd/mai

[PATCH v7 05/13] iommufd/viommu: Add IOMMU_VIOMMU_ALLOC ioctl

2024-11-05 Thread Nicolin Chen
Reviewed-by: Kevin Tian Signed-off-by: Nicolin Chen --- drivers/iommu/iommufd/Makefile | 3 +- drivers/iommu/iommufd/iommufd_private.h | 3 + include/uapi/linux/iommufd.h| 40 drivers/iommu/iommufd/main.c| 6 ++ drivers/iommu/iommufd/viommu.c

[PATCH v7 03/13] iommufd: Introduce IOMMUFD_OBJ_VIOMMU and its related struct

2024-11-05 Thread Nicolin Chen
iommu_domain_ops my_driver_domain_ops = { .viommu_alloc = my_driver_viommu_alloc, }; Suggested-by: Jason Gunthorpe Reviewed-by: Kevin Tian Reviewed-by: Jason Gunthorpe Signed-off-by: Nicolin Chen --- include/linux/iommu.h | 14 ++ include/lin

[PATCH v7 07/13] iommufd: Allow pt_id to carry viommu_id for IOMMU_HWPT_ALLOC

2024-11-05 Thread Nicolin Chen
. Since a vIOMMU object holds the parent hwpt's refcount already, increase the refcount of the vIOMMU only. Reviewed-by: Kevin Tian Signed-off-by: Nicolin Chen --- drivers/iommu/iommufd/iommufd_private.h | 1 + include/uapi/linux/iommufd.h| 14 +++-- drivers/iommu/io

[PATCH v7 10/13] iommufd/selftest: Add refcount to mock_iommu_device

2024-11-05 Thread Nicolin Chen
refcount is unbalanced. The refcount inc/dec will be added in the following patch. Suggested-by: Jason Gunthorpe Reviewed-by: Kevin Tian Reviewed-by: Jason Gunthorpe Signed-off-by: Nicolin Chen --- drivers/iommu/iommufd/selftest.c | 39 +--- 1 file changed, 31 inse

[PATCH v7 06/13] iommufd: Add alloc_domain_nested op to iommufd_viommu_ops

2024-11-05 Thread Nicolin Chen
Allow IOMMU driver to use a vIOMMU object that holds a nesting parent hwpt/domain to allocate a nested domain. Suggested-by: Jason Gunthorpe Reviewed-by: Kevin Tian Reviewed-by: Jason Gunthorpe Signed-off-by: Nicolin Chen --- include/linux/iommufd.h | 9 + 1 file changed, 9

[PATCH v7 08/13] iommufd/selftest: Add container_of helpers

2024-11-05 Thread Nicolin Chen
Use these inline helpers to shorten those container_of lines. Note that one of them goes back and forth between iommu_domain and mock_iommu_domain, which isn't necessary. So drop its container_of. Reviewed-by: Kevin Tian Reviewed-by: Jason Gunthorpe Signed-off-by: Nicolin Chen --- dr

[PATCH v7 13/13] Documentation: userspace-api: iommufd: Update vIOMMU

2024-11-05 Thread Nicolin Chen
With the introduction of the new object and its infrastructure, update the doc to reflect that and add a new graph. Reviewed-by: Jason Gunthorpe Reviewed-by: Kevin Tian Signed-off-by: Nicolin Chen --- Documentation/userspace-api/iommufd.rst | 69 - 1 file changed, 68

[PATCH v7 12/13] iommufd/selftest: Add IOMMU_VIOMMU_ALLOC test coverage

2024-11-05 Thread Nicolin Chen
Add a new iommufd_viommu FIXTURE and setup it up with a vIOMMU object. Any new vIOMMU feature will be added as a TEST_F under that. Reviewed-by: Kevin Tian Signed-off-by: Nicolin Chen --- tools/testing/selftests/iommu/iommufd_utils.h | 28 tools/testing/selftests/iommu/iommufd.c

[PATCH v7 11/13] iommufd/selftest: Add IOMMU_VIOMMU_TYPE_SELFTEST

2024-11-05 Thread Nicolin Chen
Implement the viommu alloc/free functions to increase/reduce refcount of its dependent mock iommu device. User space can verify this loop via the IOMMU_VIOMMU_TYPE_SELFTEST. Reviewed-by: Kevin Tian Reviewed-by: Jason Gunthorpe Signed-off-by: Nicolin Chen --- drivers/iommu/iommufd

[PATCH v7 09/13] iommufd/selftest: Prepare for mock_viommu_alloc_domain_nested()

2024-11-05 Thread Nicolin Chen
A nested domain now can be allocated for a parent domain or for a vIOMMU object. Rework the existing allocators to prepare for the latter case. Reviewed-by: Kevin Tian Reviewed-by: Jason Gunthorpe Signed-off-by: Nicolin Chen --- drivers/iommu/iommufd/selftest.c | 89

[PATCH v7 03/10] iommu/viommu: Add cache_invalidate to iommufd_viommu_ops

2024-11-05 Thread Nicolin Chen
This per-vIOMMU cache_invalidate op is like the cache_invalidate_user op in struct iommu_domain_ops, but wider, supporting device cache (e.g. PCI ATC invaldiations). Reviewed-by: Jason Gunthorpe Reviewed-by: Kevin Tian Signed-off-by: Nicolin Chen --- include/linux/iommufd.h | 10 ++ 1

[PATCH v7 05/10] iommu: Add iommu_copy_struct_from_full_user_array helper

2024-11-05 Thread Nicolin Chen
iommu_copy_struct_from_user_array kdoc accordingly. Signed-off-by: Jason Gunthorpe Reviewed-by: Kevin Tian Reviewed-by: Jason Gunthorpe Signed-off-by: Nicolin Chen --- include/linux/iommu.h | 48 ++- 1 file changed, 47 insertions(+), 1 deletion(-) diff --git a/include

[PATCH v7 02/10] iommufd/selftest: Add IOMMU_VDEVICE_ALLOC test coverage

2024-11-05 Thread Nicolin Chen
Add a vdevice_alloc op to the viommu mock_viommu_ops for the coverage of IOMMU_VIOMMU_TYPE_SELFTEST allocations. Then, add a vdevice_alloc TEST_F to cover the IOMMU_VDEVICE_ALLOC ioctl. Reviewed-by: Kevin Tian Reviewed-by: Jason Gunthorpe Signed-off-by: Nicolin Chen --- tools/testing

[PATCH v7 00/10] iommufd: Add vIOMMU infrastructure (Part-2: vDEVICE)

2024-11-05 Thread Nicolin Chen
iommu helper * Reordered details of set/unset_vdev_id handlers for proper lockings v1 https://lore.kernel.org/all/cover.1723061377.git.nicol...@nvidia.com/ Thanks! Nicolin Jason Gunthorpe (1): iommu: Add iommu_copy_struct_from_full_user_array helper Nicolin Chen (9): iommufd/viommu: Ad

[PATCH v7 01/10] iommufd/viommu: Add IOMMUFD_OBJ_VDEVICE and IOMMU_VDEVICE_ALLOC ioctl

2024-11-05 Thread Nicolin Chen
tl handler. Signed-off-by: Nicolin Chen --- drivers/iommu/iommufd/iommufd_private.h | 18 ++ include/linux/iommufd.h | 4 ++ include/uapi/linux/iommufd.h| 22 +++ drivers/iommu/iommufd/main.c| 6 ++ drivers/iommu/iommufd/viommu.c

[PATCH v7 08/10] iommufd/selftest: Add IOMMU_TEST_OP_DEV_CHECK_CACHE test command

2024-11-05 Thread Nicolin Chen
Similar to IOMMU_TEST_OP_MD_CHECK_IOTLB verifying a mock_domain's iotlb, IOMMU_TEST_OP_DEV_CHECK_CACHE will be used to verify a mock_dev's cache. Reviewed-by: Kevin Tian Reviewed-by: Jason Gunthorpe Signed-off-by: Nicolin Chen --- drivers/iommu/iommufd/iommufd_test.h | 5 +

[PATCH v7 07/10] iommufd/selftest: Add mock_viommu_cache_invalidate

2024-11-05 Thread Nicolin Chen
Similar to the coverage of cache_invalidate_user for iotlb invalidation, add a device cache and a viommu_cache_invalidate function to test it out. Reviewed-by: Kevin Tian Signed-off-by: Nicolin Chen --- drivers/iommu/iommufd/iommufd_test.h | 25 + drivers/iommu/iommufd/selftest.c

[PATCH v7 06/10] iommufd/viommu: Add iommufd_viommu_find_dev helper

2024-11-05 Thread Nicolin Chen
This avoids a bigger trouble of exposing struct iommufd_device and struct iommufd_vdevice in the public header. Reviewed-by: Kevin Tian Reviewed-by: Jason Gunthorpe Signed-off-by: Nicolin Chen --- include/linux/iommufd.h| 8 drivers/iommu/iommufd/driver.c | 13

[PATCH v7 04/10] iommufd: Allow hwpt_id to carry viommu_id for IOMMU_HWPT_INVALIDATE

2024-11-05 Thread Nicolin Chen
. Update the uAPI, kdoc, and selftest case accordingly. Reviewed-by: Jason Gunthorpe Reviewed-by: Kevin Tian Signed-off-by: Nicolin Chen --- include/uapi/linux/iommufd.h| 9 -- drivers/iommu/iommufd/hw_pagetable.c| 40 +++-- tools/testing/selftests/iommu

[PATCH v7 09/10] iommufd/selftest: Add vIOMMU coverage for IOMMU_HWPT_INVALIDATE ioctl

2024-11-05 Thread Nicolin Chen
Add a viommu_cache test function to cover vIOMMU invalidations using the updated IOMMU_HWPT_INVALIDATE ioctl, which now allows passing in a vIOMMU via its hwpt_id field. Reviewed-by: Kevin Tian Reviewed-by: Jason Gunthorpe Signed-off-by: Nicolin Chen --- tools/testing/selftests/iommu

[PATCH v7 10/10] Documentation: userspace-api: iommufd: Update vDEVICE

2024-11-05 Thread Nicolin Chen
With the introduction of the new object and its infrastructure, update the doc and the vIOMMU graph to reflect that. Reviewed-by: Jason Gunthorpe Reviewed-by: Kevin Tian Signed-off-by: Nicolin Chen --- Documentation/userspace-api/iommufd.rst | 41 +++-- 1 file changed, 32

Re: [PATCH v6 12/13] iommufd/selftest: Add IOMMU_VIOMMU_ALLOC test coverage

2024-10-31 Thread Nicolin Chen
On Thu, Oct 31, 2024 at 09:38:17AM -0700, Nicolin Chen wrote: > On Thu, Oct 31, 2024 at 10:16:37AM -0300, Jason Gunthorpe wrote: > > On Wed, Oct 30, 2024 at 02:34:38PM -0700, Nicolin Chen wrote: > > > +FIXTURE_SETUP(iommufd_viommu) ... > > > +

  1   2   3   4   >