Skip to contentSkip to conversation

leds/powernv: Add driver for PowerNV platform

PATCH Jacek Anaszewski 5 participants 17 messages Apr 22, 2015 – Apr 28, 2015 LED

lore
Share & tools
lore
#0 lore raw

Hi Vasant,

Quoted 138 lines · Vasant Hegde
Quoted 108 lines · Jacek Anaszewski
Quoted 107 lines · Vasant Hegde
Quoted 41 lines · Jacek Anaszewski

Hi Vasant,

I'd like to clarify some details regarding your explanation.

On 04/15/2015 12:15 PM, Vasant Hegde wrote:
[...]

Quoted 30 lines
Quoted 6 lines
Quoted 5 lines

In Power Systems LEDs are overloaded (meaning same LED is used for identify and
fault depending on their state --- blinking = identify and solid = fault). Hence here append LED type info.

Quoted 8 lines

The label could be composed of segments and an ordinal number as labels have to be unique, e.g. attn_ident_0, attn_ident_1. The segments would have to be parsed by the driver to discover all the LED's available modes.

nitpicking: identify is a verb and is not a proper name for the LED. Could you describe the purpose of this mode, so that we could come up with a better name?

Each component (Field Replacement Unit) will have service indicator (LEDS) which
can have below states :
- OFF : no action
- Identify: blinking state (user can use this state to
identify particular component).
In Power Systems world we call it as "identify"
indicator.. Hence I retained same name here.
How about just "ident" ?
- fault : solid state (when component goes bad, LED goes to
solid state) Note that our FW is capable of isolating some of the issues and it can turn
on LEDs without OS
interference.

Quoted 4 lines

We have one more System level LED (System Attention Indicator).. This LED has two states:
- OFF : Everything is fine
- ON : Some component has issues and needs attention.

Quoted 7 lines

We have three modes:
- identify - blinking
- fault - solid
- attention indicator - solid

How does LED operation differ for fault and attention modes? Does a LED have different intensity?

Jacek,

System Attention LED is special LED and its single LED available/system. where as identify and fault is applicable to all field replaceable units in the system..

So Typical server will have
1 System Attention LED
N Identify/fault LED (N = Field Replaceable Unit).

Apart from above two, we do have two more LEDs/Enclosure (external visible LEDs)
- Enclosure Identify
- Enclosure fault
These LEDs reflects state of all Field Replaceable Units
(FRU) inside this enclosure
If any of FRU state is ON, this will become ON Also we can independently enable this LED!!

But from kernel side implementation point of view, I just
treat this as another LED.. as our platform code (OPAL firmware) takes care of roll up etc.

Now our LED can operate in two mode (Depending on our service model, typically one/two socket servers are Light Path mode, whereas high end servers are Guiding Light Mode).

1. Guiding Light
Only Identify indicator is support.. Fault is not supported System attention indicator is used to point there is some
problem in system and need attention
2. Light Path mode
Both identify and fault indicator is supported .. Fault is ON whenever some component is faulty System attention indicator is used to point that FW/OS is not
able to isolate the problem and needs user to look into serviceable event (like syslog/ our agents like ESA which analyzes and reports events)

Handling LED states :
- Though physically single LED is overloaded for identify and
fault, logically (FW/OS level) we treat them as separate LED.
- We can enable both fault and identify simultaneously.
- Hardware decides physical LED state (rule : identify has
priority over fault).
ex: Say location code 'X',
Identify = ON, fault = ON , state of 'X' = identify
(blinking) Identify = OFF, fault = ON, state of 'X' = fault
(solid) Identify = OFF, fault = ON, state of 'X' = identify
(blinking) Identify = OFF, fault = OFF , state of 'X' = OFF

Since we have various above combinations, I thought its best to have separate class dev for each individual LEDs. That way we keep everything simple and let firmware handle all complexities.

Quoted 6 lines
Quoted 6 lines

Hope this clarifies.

I just posted v3 where I addressed your comments.

     https://lists.ozlabs.org/pipermail/linuxppc-dev/2015-April/127702.html

Please let me know if you have any comments/suggestions.

Jacek,

Quoted 12 lines

From what I can see from the driver code the LEDs are set with:

opal_leds_set_ind(token, loc_code, led_mask, led_value, &max_led_type);

and their state can be read with:

opal_leds_get_ind(loc_code, &led_mask, &led_value, &max_led_type)

From the kernel point of view these are very simple operations.

Quoted 7 lines

All the logic you described should be handled by user space. If you need to be able to specify the LED mode you want to set/read, then additional 'mode' sysfs attribute should be added by the driver. There would have to be also additional sysfs attribute 'available_modes" provided. The ABI documentation should inform how the mode identifiers map to the modes. I already explained how to add it, when we were discussing about retaining led state on remove.

Quoted 1 line

Sorry..My fault.. I should have elaborated mode operation...

What I was thinking about here was actually LED type, not mode in terms of Guiding Light/Light Path. However, please look at the newest approach in the end of this message.

Quoted 7 lines

I forgot to mention that LED mode is static... meaning platform provides this information, but we cannot change during runtime..

Presently we have this information in Device Tree. Since this is static one (and also LED Mode is system wide.. nothing to do individual LED), I didn't add it in LED driver code.. .Do you think we should add that property ?

The property shouldn't be documented at all if it isn't to be used.

Quoted 29 lines
Quoted 6 lines

I'd see following use cases.

(let's assume that modes are defined as follows:
0: ident, 1: attn, 2: fault)

Modes are : Guiding Light / Light Path ... which is static and platform provides this information.

LED types : IDENT, FAULT and ATTN .... which can be get/set/reset by OS (kernel/userspace)

Also only 1 LED can be ATTN ...

Quoted 14 lines

#cat available_modes
#0 1 2
#echo 0 > mode //set ident mode
#echo 1 > brightness //set ident state
#echo 2 > mode //set fault mode
#cat brightness //read fault state
#0
#echo 1 > attn //set attn mode
#echo 1 > brightness

This would set the LED in blinking mode, so I am wondering if we shouldn't employ timer trigger for this to keep the LED API consistent.

Quoted 6 lines
Quoted 3 lines

Can a single LED support other mode than 'attention'? I'd like to know if a LED in attention mode (blinking), can be set to some solid mode?

No.. Its always single attention LED/system ... which can be Set (Solid) / reset state.

I confused it with ident.

Quoted 7 lines
Quoted 4 lines

Please let me know if such an approach would still not fit for your requirements.

Given above conditions, I think current approach (my v3 patchset) is simple and works better. What you say?

Yes, but we still have naming and blinking issues to solve.

Please look at this draft design of device tree node:

opal-leds {
        compatible = "ibm,opal-v3-led";

        U78C9.001.RST0027-P1-C1:attn {
        };

        U78C9.001.RST0027-P2-C1:identify:fault 
        };

        U78C9.001.RST0027-P3-C2:identify:fault {
        };
    };
};

The LED nodes could be empty as the name would convey all the required information. The implications would be as follows:

1. Each LED would have one corresponding LED class device.

2. Operations on attn and fault LED types:
turn on:
echo 255 > brightness
turn off:
echo 0 > brightness
get status
cat brightness

3. Operations on identify LED:
turn on:
echo "timer" > trigger
(blink_set op would have to be implemented in the driver)
turn off:
echo 0 > brightness
get status:
support for this would have to be added to the LED subsystem core

4. Since 'identify' is the platform specific name it could be preserved

Does it work for you?

Signature · 2 lines
Best Regards,
Jacek Anaszewski
#1 lore raw
Quoted 2 lines · Jacek Anaszewski

Hi Vasant,

Hi Jacek,

.../...

Quoted 21 lines
Quoted 21 lines
Quoted 20 lines

From what I can see from the driver code the LEDs are set with:

opal_leds_set_ind(token, loc_code, led_mask, led_value, &max_led_type);

and their state can be read with:

opal_leds_get_ind(loc_code, &led_mask, &led_value, &max_led_type)

From the kernel point of view these are very simple operations.

All the logic you described should be handled by user space. If you need to be able to specify the LED mode you want to set/read, then additional 'mode' sysfs attribute should be added by the driver. There would have to be also additional sysfs attribute 'available_modes" provided. The ABI documentation should inform how the mode identifiers map to the modes. I already explained how to add it, when we were discussing about retaining led state on remove.

Quoted 6 lines
Quoted 1 line

Sorry..My fault.. I should have elaborated mode operation...

What I was thinking about here was actually LED type, not mode in terms of Guiding Light/Light Path. However, please look at the newest approach in the end of this message.

No problem.

Quoted 9 lines
Quoted 7 lines

I forgot to mention that LED mode is static... meaning platform provides this information, but we cannot change during runtime..

Presently we have this information in Device Tree. Since this is static one (and also LED Mode is system wide.. nothing to do individual LED), I didn't add it in LED driver code.. .Do you think we should add that property ?

The property shouldn't be documented at all if it isn't to be used.

Ok . I will remove this.

Quoted 30 lines
Quoted 30 lines
Quoted 7 lines

I'd see following use cases.

(let's assume that modes are defined as follows:
0: ident, 1: attn, 2: fault)

Modes are : Guiding Light / Light Path ... which is static and platform provides this information.

LED types : IDENT, FAULT and ATTN .... which can be get/set/reset by OS (kernel/userspace)

Also only 1 LED can be ATTN ...

Quoted 14 lines

#cat available_modes
#0 1 2
#echo 0 > mode //set ident mode
#echo 1 > brightness //set ident state
#echo 2 > mode //set fault mode
#cat brightness //read fault state
#0
#echo 1 > attn //set attn mode
#echo 1 > brightness

This would set the LED in blinking mode, so I am wondering if we shouldn't employ timer trigger for this to keep the LED API consistent.

Quoted 8 lines
Quoted 6 lines
Quoted 3 lines

Can a single LED support other mode than 'attention'? I'd like to know if a LED in attention mode (blinking), can be set to some solid mode?

No.. Its always single attention LED/system ... which can be Set (Solid) / reset state.

I confused it with ident.

No problem. We have many hardware specific jargon's which is enough to confuse anyone :-)

Quoted 27 lines
Quoted 8 lines
Quoted 5 lines

Please let me know if such an approach would still not fit for your requirements.

Given above conditions, I think current approach (my v3 patchset) is simple and works better. What you say?

Yes, but we still have naming and blinking issues to solve.

Please look at this draft design of device tree node:

opal-leds {
        compatible = "ibm,opal-v3-led";

        U78C9.001.RST0027-P1-C1:attn {
        };

        U78C9.001.RST0027-P2-C1:identify:fault 
        };

        U78C9.001.RST0027-P3-C2:identify:fault {
        };
    };
};
Quoted 3 lines

The LED nodes could be empty as the name would convey all the required information. The implications would be as follows:

These device tree comes from out firmware ... which is immutable . We can use LED node name + led-type property for naming...which is what I do currently (v4.. which I haven't posted)

Quoted 10 lines

1. Each LED would have one corresponding LED class device.

2. Operations on attn and fault LED types:
turn on:
echo 255 > brightness
turn off:
echo 0 > brightness
get status
cat brightness

Quoted 10 lines

3. Operations on identify LED:
turn on:
echo "timer" > trigger
(blink_set op would have to be implemented in the driver)
turn off:
echo 0 > brightness
get status:
support for this would have to be added to the LED subsystem core

I see few issues here.
- Overloading same LED device with multiple opeartion complicates things .. as
these operations can be done independently (say user is allowed to enable both identify and fault simultaneously)
- point 3: IIUC after duration value expires identify indicator reverts.. we
don't want to revert until user asks .
- point 3: if I use brightness for both identify/fault, how to disable these
LEDs independently?
- Also how to use trigger property for each LED (if at all we want to use them
later)?

Quoted 3 lines

4. Since 'identify' is the platform specific name it could be preserved

Ok sure.

Quoted 3 lines

Does it work for you?

Thanks
Vasant

#2 lore raw
Quoted 121 lines · On Thu, 23 Apr 2015 10:55:40 +0530 Vasant Hegde…
Quoted 2 lines · Jacek Anaszewski

Hi Vasant,

Hi Jacek,

.../...

Quoted 22 lines
Quoted 22 lines
Quoted 21 lines

From what I can see from the driver code the LEDs are set with:

opal_leds_set_ind(token, loc_code, led_mask, led_value, &max_led_type);

and their state can be read with:

opal_leds_get_ind(loc_code, &led_mask, &led_value, &max_led_type)

From the kernel point of view these are very simple operations.

All the logic you described should be handled by user space. If you need to be able to specify the LED mode you want to set/read, then additional 'mode' sysfs attribute should be added by the driver. There would have to be also additional sysfs attribute 'available_modes" provided. The ABI documentation should inform how the mode identifiers map to the modes. I already explained how to add it, when we were discussing about retaining led state on remove.

Quoted 6 lines
Quoted 1 line

Sorry..My fault.. I should have elaborated mode operation...

What I was thinking about here was actually LED type, not mode in terms of Guiding Light/Light Path. However, please look at the newest approach in the end of this message.

No problem.

Quoted 9 lines
Quoted 7 lines

I forgot to mention that LED mode is static... meaning platform provides this information, but we cannot change during runtime..

Presently we have this information in Device Tree. Since this is static one (and also LED Mode is system wide.. nothing to do individual LED), I didn't add it in LED driver code.. .Do you think we should add that property ?

The property shouldn't be documented at all if it isn't to be used.

Ok . I will remove this.

Quoted 30 lines
Quoted 30 lines
Quoted 7 lines

I'd see following use cases.

(let's assume that modes are defined as follows:
0: ident, 1: attn, 2: fault)

Modes are : Guiding Light / Light Path ... which is static and platform provides this information.

LED types : IDENT, FAULT and ATTN .... which can be get/set/reset by OS (kernel/userspace)

Also only 1 LED can be ATTN ...

Quoted 14 lines

#cat available_modes
#0 1 2
#echo 0 > mode //set ident mode
#echo 1 > brightness //set ident state
#echo 2 > mode //set fault mode
#cat brightness //read fault state
#0
#echo 1 > attn //set attn mode
#echo 1 > brightness

This would set the LED in blinking mode, so I am wondering if we shouldn't employ timer trigger for this to keep the LED API consistent.

Quoted 8 lines
Quoted 6 lines
Quoted 3 lines

Can a single LED support other mode than 'attention'? I'd like to know if a LED in attention mode (blinking), can be set to some solid mode?

No.. Its always single attention LED/system ... which can be Set (Solid) / reset state.

I confused it with ident.

No problem. We have many hardware specific jargon's which is enough to confuse anyone :-)

Quoted 27 lines
Quoted 8 lines
Quoted 5 lines

Please let me know if such an approach would still not fit for your requirements.

Given above conditions, I think current approach (my v3 patchset) is simple and works better. What you say?

Yes, but we still have naming and blinking issues to solve.

Please look at this draft design of device tree node:

opal-leds {
        compatible = "ibm,opal-v3-led";

        U78C9.001.RST0027-P1-C1:attn {
        };

        U78C9.001.RST0027-P2-C1:identify:fault 
        };

        U78C9.001.RST0027-P3-C2:identify:fault {
        };
    };
};
Quoted 5 lines
Quoted 3 lines

The LED nodes could be empty as the name would convey all the required information. The implications would be as follows:

These device tree comes from out firmware ... which is immutable .

How the firmware is related to kernel? These bindings are for kernel, not for the firmware.

DT bindings are compiled to *.dtb file which is concatenated with zImage. During system boot device drivers are matched with DT bindings through 'compatible' property. A driver should have single matching DT node, i.e. no other driver can probe with the same DT node. This implies that the node should contain only the properties required for configuring the related device.

Quoted 25 lines

We can use LED node name + led-type property for naming...which is what I do currently (v4.. which I haven't posted)

Quoted 10 lines

1. Each LED would have one corresponding LED class device.

2. Operations on attn and fault LED types:
turn on:
echo 255 > brightness
turn off:
echo 0 > brightness
get status
cat brightness

Quoted 10 lines

3. Operations on identify LED:
turn on:
echo "timer" > trigger
(blink_set op would have to be implemented in the driver)
turn off:
echo 0 > brightness
get status:
support for this would have to be added to the LED subsystem core

Quoted 4 lines

I see few issues here.
- Overloading same LED device with multiple opeartion complicates
things .. as these operations can be done independently (say user is allowed to enable both identify and fault simultaneously)

I agree, it would be hard to distinguish whether by executing echo 0 > brightness we want to turn off identify or fault function.

Quoted 4 lines

- point 3: IIUC after duration value expires identify indicator
reverts.. we don't want to revert until user asks .

From what you shared, blinking has hardware acceleration on OPAL side.

At first timer trigger tries to use HW accelerated blinking by calling blink_set op and resorts to using software fallback only if the op fails or is not defined.

BTW timer trigger re-sets blink after timer expires, unless LED_BLINK_ONESHOT flag is set by LED class device.

Quoted 2 lines

- point 3: if I use brightness for both identify/fault, how to
disable these LEDs independently?

Another sysfs attribute would be required, but it would be ugly.

Quoted 3 lines

- Also how to use trigger property for each LED (if at all we want
to use them later)?

After analyzing pros and cons I think that separate LED class devices for each LED type would be most suitable solution in this case.

For 'identify' LED the operation would be:

#echo "timer" > trigger //set 'identify' (blinking)
#cat trigger //check "identify" state
#none [timer] //'identify' is ON
#echo 0 > brightness //unset 'identify
#cat trigger
#[none] timer //'identify' is OFF

You would have to implement blink_set op
(see Documentation/leds/leds-class.txt and other LED class drivers for reference).

For attention and fault LEDs only brightness attribute would matter.

DT bindings would look as follows:

opal-leds {
        compatible = "ibm,opal-leds";

        U78C9.001.RST0027-P1-C1:fault {
        };

        U78C9.001.RST0027-P1-C1:indent {
        };

        U78C9.001.RST0027-P2-C1:attn
        };
    }
}
Signature · 2 lines
Best Regards,
Jacek Anaszewski
#3 lore raw
Quoted 11 lines · Jacek Anaszewski
Quoted 1 line

These device tree comes from out firmware ... which is immutable .

How the firmware is related to kernel? These bindings are for kernel, not for the firmware.

DT bindings are compiled to *.dtb file which is concatenated with zImage. During system boot device drivers are matched with DT bindings through 'compatible' property. A driver should have single matching DT node, i.e. no other driver can probe with the same DT node. This implies that the node should contain only the properties required for configuring the related device.

For OPAL firmware on POWER, firmware hands kernel a flattened device tree of the machine it's booting on. It's not added to kernel as the kernels aren't board specific - they're generic.

https://github.com/open-power/skiboot/ is the firmware that generates the device tree for booting under OPAL.

#4 lore raw
Quoted 13 lines · On Fri, 24 Apr 2015 14:18:30 +1000 Stewart Smith <[email protected]>…
Quoted 11 lines · Jacek Anaszewski
Quoted 1 line

These device tree comes from out firmware ... which is immutable .

How the firmware is related to kernel? These bindings are for kernel, not for the firmware.

DT bindings are compiled to *.dtb file which is concatenated with zImage. During system boot device drivers are matched with DT bindings through 'compatible' property. A driver should have single matching DT node, i.e. no other driver can probe with the same DT node. This implies that the node should contain only the properties required for configuring the related device.

Quoted 3 lines

For OPAL firmware on POWER, firmware hands kernel a flattened device tree of the machine it's booting on. It's not added to kernel as the kernels aren't board specific - they're generic.

Is the DT node we are discussing used by some other drivers than the LED class driver? Or is it required in this form by other components of your platform?

Quoted 3 lines

https://github.com/open-power/skiboot/ is the firmware that generates the device tree for booting under OPAL.

Signature · 2 lines
Best Regards,
Jacek Anaszewski
#5 lore raw
Quoted 3 lines · Jacek Anaszewski

Is the DT node we are discussing used by some other drivers than the LED class driver? Or is it required in this form by other components of your platform?

OS kernels are the chief consumers, Linux being the overwhelmingly major one here.

But this is what firmware currently produces.

Changing the DT representation at this stage is perhaps *possible* without creating a bunch of pain (I'd have to audit a bunch of things to see if we have GA shipping systems with this functionality for instance, and then evaluate the impact to partners and our various labs) which is a lot of work I don't particularly want to do and is well below urgent item 248 on my TODO list, especially for what seems to be largely a cosmetic suggestion?

That being said, more and better review of things we're putting in the device tree in firmware is probably a good thing. After all, once we release we do kind of have to live with it essentially forever. If people are able to aid in that kind of code review, I'd be most welcome to hear it.

#6 lore raw
Quoted 24 lines · Stewart Smith
Quoted 3 lines · Jacek Anaszewski

Is the DT node we are discussing used by some other drivers than the LED class driver? Or is it required in this form by other components of your platform?

OS kernels are the chief consumers, Linux being the overwhelmingly major one here.

But this is what firmware currently produces.

Changing the DT representation at this stage is perhaps *possible* without creating a bunch of pain (I'd have to audit a bunch of things to see if we have GA shipping systems with this functionality for instance, and then evaluate the impact to partners and our various labs) which is a lot of work I don't particularly want to do and is well below urgent item 248 on my TODO list, especially for what seems to be largely a cosmetic suggestion?

That being said, more and better review of things we're putting in the device tree in firmware is probably a good thing. After all, once we release we do kind of have to live with it essentially forever. If people are able to aid in that kind of code review, I'd be most welcome to hear it.

Quoted 5 lines

--
To unsubscribe from this list: send the line "unsubscribe linux-leds" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

As we agreed with Ben - DT bindings are platform specific and they will have to be acked by powerpc maintainers. I have only DT related experience from ARM based platforms, but it seems not to be applicable to powerpc.

Signature · 2 lines
Best Regards,
Jacek Anaszewski
#7 lore raw
In reply to Jacek Anaszewski
Quoted 3 lines · Jacek Anaszewski

On Thu, 23 Apr 2015 10:55:40 +0530
Vasant Hegde <[email protected]> wrote:

Hi Jacek,

.../...

Quoted 6 lines
Quoted 2 lines

These device tree comes from out firmware ... which is immutable .

How the firmware is related to kernel? These bindings are for kernel, not for the firmware.

Quoted 7 lines

DT bindings are compiled to *.dtb file which is concatenated with zImage. During system boot device drivers are matched with DT bindings through 'compatible' property. A driver should have single matching DT node, i.e. no other driver can probe with the same DT node. This implies that the node should contain only the properties required for configuring the related device.

As Stewart mentioned, its not .dtb file in our case.. we pass flattened device tree .. which is built by OPAL.

Quoted 33 lines
Quoted 25 lines

We can use LED node name + led-type property for naming...which is what I do currently (v4.. which I haven't posted)

Quoted 10 lines

1. Each LED would have one corresponding LED class device.

2. Operations on attn and fault LED types:
turn on:
echo 255 > brightness
turn off:
echo 0 > brightness
get status
cat brightness

Quoted 10 lines

3. Operations on identify LED:
turn on:
echo "timer" > trigger
(blink_set op would have to be implemented in the driver)
turn off:
echo 0 > brightness
get status:
support for this would have to be added to the LED subsystem core

Quoted 4 lines

I see few issues here.
- Overloading same LED device with multiple opeartion complicates
things .. as these operations can be done independently (say user is allowed to enable both identify and fault simultaneously)

I agree, it would be hard to distinguish whether by executing echo 0 > brightness we want to turn off identify or fault function.

Quoted 7 lines
Quoted 2 lines

- point 3: IIUC after duration value expires identify indicator
reverts.. we don't want to revert until user asks .

From what you shared, blinking has hardware acceleration on OPAL side. At first timer trigger tries to use HW accelerated blinking by calling blink_set op and resorts to using software fallback only if the op fails or is not defined.

Blinking is the physical state of LED to represent "identify" state. which is taken care by hardware. and OS doesn't have control on this ..

Quoted 5 lines

From software point of view its just another LED with two state (ON and OFF).

BTW timer trigger re-sets blink after timer expires, unless LED_BLINK_ONESHOT flag is set by LED class device.

In my case, I want to retain the state.'

Quoted 5 lines
Quoted 3 lines

- point 3: if I use brightness for both identify/fault, how to
disable these LEDs independently?

Another sysfs attribute would be required, but it would be ugly.

yeah.

Quoted 6 lines
Quoted 3 lines

- Also how to use trigger property for each LED (if at all we want
to use them later)?

After analyzing pros and cons I think that separate LED class devices for each LED type would be most suitable solution in this case.

Agree.

Quoted 10 lines

For 'identify' LED the operation would be:

#echo "timer" > trigger //set 'identify' (blinking)
#cat trigger //check "identify" state
#none [timer] //'identify' is ON
#echo 0 > brightness //unset 'identify
#cat trigger
#[none] timer //'identify' is OFF

Quoted 3 lines

You would have to implement blink_set op
(see Documentation/leds/leds-class.txt and other LED class drivers for reference).

Implementing another op should be fine.. I can try to implement it.

But from user perspective identify is just another LED. Hence can we just use "brightness" property itself?

Quoted 3 lines

For attention and fault LEDs only brightness attribute would matter.

Sure.

Quoted 16 lines

DT bindings would look as follows:

opal-leds {
        compatible = "ibm,opal-leds";

        U78C9.001.RST0027-P1-C1:fault {
        };

        U78C9.001.RST0027-P1-C1:indent {
        };

        U78C9.001.RST0027-P2-C1:attn
        };
    }
}

As mentioned earlier DT is coming from our firmware. For now I will respin another round of patches by using led-types property and run it through DT experts (DT mailing list). If they insist this method is better than what I already have , then will work with my firmware folks to see what we can do better.

Thanks
Vasant

#8 lore raw

On Fri, 24 Apr 2015 11:00:41 +0530
Hi Vasant,

Quoted 23 lines · Vasant Hegde
Quoted 3 lines · Jacek Anaszewski

On Thu, 23 Apr 2015 10:55:40 +0530
Vasant Hegde <[email protected]> wrote:

Hi Jacek,

.../...

Quoted 6 lines
Quoted 2 lines

These device tree comes from out firmware ... which is immutable .

How the firmware is related to kernel? These bindings are for kernel, not for the firmware.

Quoted 7 lines

DT bindings are compiled to *.dtb file which is concatenated with zImage. During system boot device drivers are matched with DT bindings through 'compatible' property. A driver should have single matching DT node, i.e. no other driver can probe with the same DT node. This implies that the node should contain only the properties required for configuring the related device.

Quoted 2 lines

As Stewart mentioned, its not .dtb file in our case.. we pass flattened device tree .. which is built by OPAL.

No matter what format of device tree OPAL produces, I assume that it must compile it from some sources.

dtb file is a compiled form of human readable dts file containing Flattened Device Tree - a data structure for describing the hardware in the system.

Please refer to: http://elinux.org/Device_Tree

Quoted 37 lines
Quoted 37 lines
Quoted 25 lines

We can use LED node name + led-type property for naming...which is what I do currently (v4.. which I haven't posted)

Quoted 10 lines

1. Each LED would have one corresponding LED class device.

2. Operations on attn and fault LED types:
turn on:
echo 255 > brightness
turn off:
echo 0 > brightness
get status
cat brightness

Quoted 10 lines

3. Operations on identify LED:
turn on:
echo "timer" > trigger
(blink_set op would have to be implemented in the driver)
turn off:
echo 0 > brightness
get status:
support for this would have to be added to the LED subsystem core

Quoted 4 lines

I see few issues here.
- Overloading same LED device with multiple opeartion complicates
things .. as these operations can be done independently (say user is allowed to enable both identify and fault simultaneously)

I agree, it would be hard to distinguish whether by executing echo 0 > brightness we want to turn off identify or fault function.

Quoted 2 lines

- point 3: IIUC after duration value expires identify indicator
reverts.. we don't want to revert until user asks .

Quoted 8 lines
Quoted 4 lines

From what you shared, blinking has hardware acceleration on OPAL side. At first timer trigger tries to use HW accelerated blinking by calling blink_set op and resorts to using software fallback only if the op fails or is not defined.

Blinking is the physical state of LED to represent "identify" state. which is taken care by hardware. and OS doesn't have control on this ..

I am aware of it. Therefore we would probably need to add a flag LED_BLINK_HW_ONLY to the LED subsystem core and modify led_blink_set function to log an error and avoid setting software fallback in case blink_set op fails and the flag is set.

Nevertheless, I am leaning towards using brightness_set op for this.

Quoted 38 lines

From software point of view its just another LED with two state (ON and OFF).

Quoted 3 lines

BTW timer trigger re-sets blink after timer expires, unless LED_BLINK_ONESHOT flag is set by LED class device.

In my case, I want to retain the state.'

Quoted 5 lines
Quoted 3 lines

- point 3: if I use brightness for both identify/fault, how to
disable these LEDs independently?

Another sysfs attribute would be required, but it would be ugly.

yeah.

Quoted 7 lines
Quoted 3 lines

- Also how to use trigger property for each LED (if at all we
want to use them later)?

After analyzing pros and cons I think that separate LED class devices for each LED type would be most suitable solution in this case.

Agree.

Quoted 10 lines

For 'identify' LED the operation would be:

#echo "timer" > trigger //set 'identify' (blinking)
#cat trigger //check "identify" state
#none [timer] //'identify' is ON
#echo 0 > brightness //unset 'identify
#cat trigger
#[none] timer //'identify' is OFF

Quoted 8 lines
Quoted 3 lines

You would have to implement blink_set op
(see Documentation/leds/leds-class.txt and other LED class drivers for reference).

Implementing another op should be fine.. I can try to implement it.

But from user perspective identify is just another LED. Hence can we just use "brightness" property itself?

OK, let's use only brightness. Usage of blinking API would impose turning on led-triggers, which would be used only for exposing trigger sysfs attribute. Triggers however would not be used, as the intention is using only HW accelerated blinking.

Please add comment to the driver, describing the reasons for abusing API semantics.

Quoted 24 lines
Quoted 4 lines

For attention and fault LEDs only brightness attribute would matter.

Sure.

Quoted 16 lines

DT bindings would look as follows:

opal-leds {
        compatible = "ibm,opal-leds";

        U78C9.001.RST0027-P1-C1:fault {
        };

        U78C9.001.RST0027-P1-C1:indent {
        };

        U78C9.001.RST0027-P2-C1:attn
        };
    }
}
Quoted 5 lines

As mentioned earlier DT is coming from our firmware. For now I will respin another round of patches by using led-types property and run it through DT experts (DT mailing list). If they insist this method is better than what I already have , then will work with my firmware folks to see what we can do better.

Please hold on with sending the patches until we clarify all the DT related issues. Having full picture will help to adjust the bindings better to LED common bindings specification.

Signature · 2 lines
Best Regards,
Jacek Anaszewski
#9 lore raw
Quoted 2 lines · Jacek Anaszewski

No matter what format of device tree OPAL produces, I assume that it must compile it from some sources.

Nope. Well... .C code maybe qualifies as "sources" :-)

Quoted 5 lines

dtb file is a compiled form of human readable dts file containing Flattened Device Tree - a data structure for describing the hardware in the system.

Please refer to: http://elinux.org/Device_Tree

We are quite familiar with this, guess what architecture created the whole flat device-tree stuff in the first place ?

In any case, in our case, the fdt is procedurally generated by firmware.

Cheers,
Ben.

#10 lore raw
In reply to Jacek Anaszewski

Hi Vasant,

On 04/24/2015 12:15 PM, Jacek Anaszewski wrote:
[...]

Quoted 28 lines
Quoted 22 lines
Quoted 2 lines

For attention and fault LEDs only brightness attribute would matter.

Sure.

Quoted 16 lines

DT bindings would look as follows:

opal-leds {
         compatible = "ibm,opal-leds";

         U78C9.001.RST0027-P1-C1:fault {
         };

         U78C9.001.RST0027-P1-C1:indent {
         };

         U78C9.001.RST0027-P2-C1:attn
         };
     }
}
Quoted 5 lines

As mentioned earlier DT is coming from our firmware. For now I will respin another round of patches by using led-types property and run it through DT experts (DT mailing list). If they insist this method is better than what I already have , then will work with my firmware folks to see what we can do better.

Quoted 4 lines

Please hold on with sending the patches until we clarify all the DT related issues. Having full picture will help to adjust the bindings better to LED common bindings specification.

Please send the next version adjusted to your platform needs. Since I've found out that only powerpc maintainers will have to ack DT patch, you can avoid adding devicetree list on cc.

Signature · 2 lines
Best Regards,
Jacek Anaszewski
#11 lore raw
In reply to Jacek Anaszewski
Quoted 2 lines · Jacek Anaszewski

How the firmware is related to kernel? These bindings are for kernel, not for the firmware.

There should be no relation. DT bindings should be kernel agnostic and represent the HW layout, not be designed based on what a given kernel driver wants, but I'm digressing...

Quoted 2 lines

DT bindings are compiled to *.dtb file which is concatenated with zImage.

No. First, a "binding" isn't compiled to a dtb, a binding is a piece documentation. A flat device tree *might* be compiled from a dts to a dtb but that isn't necessarily the case.

For example, any machine with an actual implementation of Open Firmware will essentially flatten OF internal tree into a dtb at boot time, and that tree is itself generated by forth code.

In our case, the device tree is procedurally generated by two layers of firmware, there is no dts "compilation" happening. HostBoot generates a shell and OPAL extends it before flattening it and passing it to the kernel.

The "concatenated with zImage" point you make is also a very ARM centric one. ARM provides the *optional* ability to concatenate a dtb with a zImage, but that's specific to ARM zImage wrapper. For example, powerpc can do something similar (but not identical) using the "wrapper" script we have in arch/powerpc/boot where we embed the dtb. However, this too is optional, we have a longer history of having firwmares generating device-trees.

Note: We invented the whole FDT business :-)

Quoted 5 lines

During system boot device drivers are matched with DT bindings through 'compatible' property. A driver should have single matching DT node, i.e. no other driver can probe with the same DT node. This implies that the node should contain only the properties required for configuring the related device.

I don't see how you goes from A to implying B here. Yes, a device generally will have a single representing node but that doesn't mean that the node only contains what the driver needs. The DT node can contain all sort of auxilliary informations that the driver may or may not be interested in that was deemed potentially relevant or useful by the platform designer.

Cheers,
Ben.

#12 lore raw

Hi Benjamin,

Thanks for your explanation.

Quoted 41 lines · Benjamin Herrenschmidt
Quoted 2 lines · Jacek Anaszewski

How the firmware is related to kernel? These bindings are for kernel, not for the firmware.

There should be no relation. DT bindings should be kernel agnostic and represent the HW layout, not be designed based on what a given kernel driver wants, but I'm digressing...

Quoted 2 lines

DT bindings are compiled to *.dtb file which is concatenated with zImage.

No. First, a "binding" isn't compiled to a dtb, a binding is a piece documentation. A flat device tree *might* be compiled from a dts to a dtb but that isn't necessarily the case.

For example, any machine with an actual implementation of Open Firmware will essentially flatten OF internal tree into a dtb at boot time, and that tree is itself generated by forth code.

In our case, the device tree is procedurally generated by two layers of firmware, there is no dts "compilation" happening. HostBoot generates a shell and OPAL extends it before flattening it and passing it to the kernel.

The "concatenated with zImage" point you make is also a very ARM centric one. ARM provides the *optional* ability to concatenate a dtb with a zImage, but that's specific to ARM zImage wrapper. For example, powerpc can do something similar (but not identical) using the "wrapper" script we have in arch/powerpc/boot where we embed the dtb. However, this too is optional, we have a longer history of having firwmares generating device-trees.

Note: We invented the whole FDT business :-)

Quoted 5 lines

During system boot device drivers are matched with DT bindings through 'compatible' property. A driver should have single matching DT node, i.e. no other driver can probe with the same DT node. This implies that the node should contain only the properties required for configuring the related device.

Quoted 6 lines

I don't see how you goes from A to implying B here. Yes, a device generally will have a single representing node but that doesn't mean that the node only contains what the driver needs. The DT node can contain all sort of auxilliary informations that the driver may or may not be interested in that was deemed potentially relevant or useful by the platform designer.

I was not aware that some other entity than the driver could be interested in the information provided by DT node. I will no longer object, provided that we will get an ack from DT maintainer.

Signature · 2 lines
Best Regards,
Jacek Anaszewski
#13 lore raw
Quoted 3 lines · Jacek Anaszewski

I was not aware that some other entity than the driver could be interested in the information provided by DT node. I will no longer object, provided that we will get an ack from DT maintainer.

My understanding is that we no longer need bindings to be accepted by DT maintainers.

That being said, I would like to review this one before it is accepted, as I haven't had a chance to do so yet :-) (I was mostly responding to you, I haven't caught up with the full thread yet).

Please wait for an ack from myself or Michael Ellerman (the two powerpc maintainers). Either that or provide your ack and we'll merge it via our tree if we are happy with it.

Cheers,
Ben.

#14 lore raw
Quoted 7 lines · Benjamin Herrenschmidt
Quoted 3 lines · Jacek Anaszewski

I was not aware that some other entity than the driver could be interested in the information provided by DT node. I will no longer object, provided that we will get an ack from DT maintainer.

My understanding is that we no longer need bindings to be accepted by DT maintainers.

I've just skimmed through the patches in Documentation/devicetree/bindings/powerpc and they indeed don't have acks from DT maintainers.

Quoted 7 lines

That being said, I would like to review this one before it is accepted, as I haven't had a chance to do so yet :-) (I was mostly responding to you, I haven't caught up with the full thread yet).

Please wait for an ack from myself or Michael Ellerman (the two powerpc maintainers). Either that or provide your ack and we'll merge it via our tree if we are happy with it.

Since this driver is for LED subsystem it should better go via leds tree.

Signature · 2 lines
Best Regards,
Jacek Anaszewski
#15 lore raw
Quoted 6 lines · Jacek Anaszewski
Quoted 5 lines · Benjamin Herrenschmidt
Quoted 3 lines · Jacek Anaszewski

I was not aware that some other entity than the driver could be interested in the information provided by DT node. I will no longer object, provided that we will get an ack from DT maintainer.

Jacket,

Quoted 6 lines
Quoted 2 lines

My understanding is that we no longer need bindings to be accepted by DT maintainers.

I've just skimmed through the patches in Documentation/devicetree/bindings/powerpc and they indeed don't have acks from DT maintainers.

Sure.. I have addressed all other issues we discussed earlier. Will respin v4 soon.

Quoted 11 lines
Quoted 8 lines

That being said, I would like to review this one before it is accepted, as I haven't had a chance to do so yet :-) (I was mostly responding to you, I haven't caught up with the full thread yet).

Please wait for an ack from myself or Michael Ellerman (the two powerpc maintainers). Either that or provide your ack and we'll merge it via our tree if we are happy with it.

Since this driver is for LED subsystem it should better go via leds tree.

Sure.. Will send v4 and request benh/mpe to review/ack from powerpc side.

-Vasant

#16 lore raw
Quoted 9 lines · Vasant Hegde
Quoted 6 lines · Jacek Anaszewski
Quoted 5 lines · Benjamin Herrenschmidt
Quoted 3 lines · Jacek Anaszewski

I was not aware that some other entity than the driver could be interested in the information provided by DT node. I will no longer object, provided that we will get an ack from DT maintainer.

Jacket,

Oops.. Sorry.. It was a typo .. I meant Jacek..

-Vasant