Page MenuHomeFreeBSD

apuled(4): add support for LEDs on PC Engines APU boards
Needs ReviewPublic

Authored by olivier on Mar 3 2017, 12:41 PM.

Details

Reviewers
avg
Summary

PR 189772 includes a cool drivers for PC Engines APU 1 and 2.
Here is a phab review for adding more reviewer to this PR.

Diff Detail

Repository
rS FreeBSD src repository
Lint
Lint OK
Unit
No Unit Test Coverage
Build Status
Buildable 7871
Build 8011: arc lint + arc unit

Event Timeline

olivier updated this revision to Diff 25932.Mar 3 2017, 12:41 PM
olivier retitled this revision from to apuled(4): add support for LEDs on PC Engines APU boards.
olivier updated this object.
olivier edited the test plan for this revision. (Show Details)
avg added a subscriber: avg.EditedMar 3 2017, 1:31 PM

Besides the style issues I have another concern.
Now we would have at least two drivers that can concurrently access AMD PMIO registers. Given that the access is through in an index-data pair of registers, there is a possibility of a conflict. We need to think how to protect those registers from conflicting accesses.

sys/modules/apuled/apuled.c
58

You can include that header file here if that helps to avoid duplicate definitions.
See intpm.c for an example.

127

What purpose does this character device serve?
I thought that hooking into led(4) infrastructure would be sufficient.

154

General suggestion: if you move these module and driver definitions to the end of file, then everything wouldcome in its natural order and you wouldn't have to declare prototypes for the methods.

156

It's possible to use bool here if that would make the code clearer.

165

The return value of a function call can not be assigned to, so the usual argument of using this weird order of comparison operands does not apply here :-)

253

New line after break feels redundant.
There are a few more instances of this elsewhere.

433

Redundant spaces within "[]".
There are several more cases like this.

517

redundant blank line

528

redundant blank line

533

redundant blank line

539

redundant blank line

avg added a reviewer: avg.Mar 3 2017, 1:32 PM
olivier updated this revision to Diff 28156.May 8 2017, 7:17 PM

Author update his patch and addressed most of the phabricator comments and update it for supporting APU1,2 and 3 boards.

olivier marked 8 inline comments as done.May 9 2017, 5:31 AM

The updated code should answer to all remarks.
About the sys/modules/Makefile diff: I've synced my FreeBSD src tree to the last revision which updated this file, and when I've updated this review it had included by mistake the change.

sys/modules/apuled/apuled.c
58

It was not an header file, but a .c : typo fixed on the comment.

lab_gta.com added inline comments.
sys/modules/apuled/apuled.c
58

Header file no longer exists. It was combined with associated c module.

127

The APU boards also support a mode switch on the front of the case. This device can be used to get current status of switch.

156

This needs to be an int. Return value is used to determine what type of APU board was found.

253

Removed extra line breaks.

433

Removed redundant spaces around all "[]".

517

Removed redundant blank line.

528

Removed redundant blank line.

539

Removed redundant blank line.

avg edited edge metadata.Jun 1 2017, 4:10 PM

Please address a few minor style comments. Please consider using amd_chipset.h.
I am still somewhat concerned about possible clashes on concurrent accesses to the PMIO space.

sys/modules/apuled/apuled.c
58

What I meant was sys/dev/amdsbwd/amd_chipset.h which is alive and well.

154

In the FreeBSD style we do not place a space after an opening parenthesis or before a closing one.
Please remove the extra spaces here and in other function signatures.

156

okay

185

Too many empty lines in this function's body and in those of the next few functions. I do not see any code that really has to be emphasized by new lines.
E.g.

x = f();
if (x) {
  ...
}

is easier to read and takes less visual space than

x = f();

if (x) {
  ...
}
avg added a comment.Dec 7 2017, 10:56 AM

Is there still an interest in getting this moving forward?
I think that it should be relatively easy to address my comments and get this into a committable shape.

In D9876#280057, @avg wrote:

Is there still an interest in getting this moving forward?
I think that it should be relatively easy to address my comments and get this into a committable shape.

As APU2 user, I'm very interested by getting this moving forward… but I'm not a C developer then I can't address your comments: Peraphs original author (@lab_gta.com) can do it ?

In D9876#280057, @avg wrote:

Is there still an interest in getting this moving forward?
I think that it should be relatively easy to address my comments and get this into a committable shape.

We're using this code in production., it would be helpful to have it committed.

Tested this on an APU3 Board. Works great;
but i wonder if it would be smarte to write a gpiobus(4) driver instead and support the other remaining GPIO pins as well.

Addition: the APU2/3 GPIOs are on an other IO controller, and would probably require a different driver, independent of this one.