Re: [PATCH v2 00/11] Documentation: Add ABI to the admin guide

From: Mauro Carvalho Chehab
Date: Thu Apr 20 2017 - 19:21:54 EST


Em Thu, 20 Apr 2017 15:40:00 -0600
Jonathan Corbet <corbet@xxxxxxx> escreveu:

> On Thu, 13 Apr 2017 07:08:43 -0300
> Mauro Carvalho Chehab <mchehab@xxxxxxxxxxxxxxxx> wrote:
>
> > That's the third attempt to add support for the Kernel ABI
> > at the Documentation's admin guide.
> >
> > The first approach was based on a generic extension that
> > calls a random script. This one is based on a new Sphinx
> > extension with adds a symbol specific for parsing ABI
> > symbols.
> >
> > It adds a new script (scripts/get_abi.pl) with can either
> > search for ABI symbols that match a regular expression or
> > outputs the entire documentation found inside a directory
> > as a ReST book.
>
> So I've finally taken a quick look at this. I'm not quite ready to take
> it for 4.12 at this point, but I guess I'm running out of reasons to
> block it in general..:)

Good!

>
> One question, though: is there a reason for the split between the sphinx
> extension and the Perl script that does the work? Could it all happen in
> the extension directly instead? It seems like a lot of moving parts.

There are a couple of reasons:

- On the last feedback from you and Jani about MAINTAINERS parser,
you both suggested that, if we would be parsing MAINTAINERS, such
functionality should be at get_maintainer.pl. So, I tried to follow
the same way as get_maintainer: to have a single script that would be
in charge of handling ABI parsing;

- get_abi.pl doesn't only generate ReST documentation. It also
query the ABI database. So, with get_abi.pl, do things like:

$ ./scripts/get_abi.pl search usbip_status

/sys/devices/platform/usbip-vudc.%d/usbip_status
------------------------------------------------

Kernel version: 4.6
Date: April 2016
Contact: Krzysztof Opasiak <k.opasiak@xxxxxxxxxxx>
Defined on file: Documentation/ABI/testing/sysfs-platform-usbip-vudc

Description:

Current status of the device.
Allowed values:
1 - Device is available and can be exported
2 - Device is currently exported
3 - Fatal error occurred during communication
with peer

And even use regex, querying for multiple ABI symbols:

$ ./scripts/get_abi.pl search .*bus.*devices/.*power.*usb.*

/sys/bus/usb/devices/.../power/usb2_hardware_lpm
------------------------------------------------

Date: September 2011
Contact: Andiry Xu <andiry.xu@xxxxxxx>
Defined on file: Documentation/ABI/testing/sysfs-bus-usb

Description:

If CONFIG_PM is set and a USB 2.0 lpm-capable device is plugged
in to a xHCI host which support link PM, it will perform a LPM
test; if the test is passed and host supports USB2 hardware LPM
(xHCI 1.0 feature), USB2 hardware LPM will be enabled for the
device and the USB device directory will contain a file named
power/usb2_hardware_lpm. The file holds a string value (enable
or disable) indicating whether or not USB2 hardware LPM is
enabled for the device. Developer can write y/Y/1 or n/N/0 to
the file to enable/disable the feature.


/sys/bus/usb/devices/.../power/usb2_lpm_besl
--------------------------------------------

Date: May 2013
Contact: Mathias Nyman <mathias.nyman@xxxxxxxxxxxxxxx>
Defined on file: Documentation/ABI/testing/sysfs-bus-usb

Description:

USB 2.0 devices that support hardware link power management (LPM)
L1 sleep state now use a best effort service latency value (BESL) to
indicate the best effort to resumption of service to the device after the
initiation of the resume event.
If the device does not have a preferred besl value then the host can select
one instead. This usb2_lpm_besl attribute allows to tune the host selected besl
value in order to tune power saving and service latency.

Supported values are 0 - 15.
More information on how besl values map to microseconds can be found in
USB 2.0 ECN Errata for Link Power Management, section 4.10)

/sys/bus/usb/devices/.../power/usb2_lpm_l1_timeout
--------------------------------------------------

Date: May 2013
Contact: Mathias Nyman <mathias.nyman@xxxxxxxxxxxxxxx>
Defined on file: Documentation/ABI/testing/sysfs-bus-usb

Description:

USB 2.0 devices may support hardware link power management (LPM)
L1 sleep state. The usb2_lpm_l1_timeout attribute allows
tuning the timeout for L1 inactivity timer (LPM timer), e.g.
needed inactivity time before host requests the device to go to L1 sleep.
Useful for power management tuning.
Supported values are 0 - 65535 microseconds.


/sys/bus/usb/devices/.../power/usb3_hardware_lpm_u1
---------------------------------------------------

Date: November 2015
Contact: Kevin Strasser <kevin.strasser@xxxxxxxxxxxxxxx>
Lu Baolu <baolu.lu@xxxxxxxxxxxxxxx>
Defined on file: Documentation/ABI/testing/sysfs-bus-usb

Description:

If CONFIG_PM is set and a USB 3.0 lpm-capable device is plugged
in to a xHCI host which supports link PM, it will check if U1
and U2 exit latencies have been set in the BOS descriptor; if
the check is passed and the host supports USB3 hardware LPM,
USB3 hardware LPM will be enabled for the device and the USB
device directory will contain two files named
power/usb3_hardware_lpm_u1 and power/usb3_hardware_lpm_u2. These
files hold a string value (enable or disable) indicating whether
or not USB3 hardware LPM U1 or U2 is enabled for the device.

(the output in this mode not ReST)

- I'm not a python programmer ;-) I just took Markus "generic" kernel-cmd
code, hardcoding there a call to the script.

With (a lot of) time, I would likely be able to find a solution to add
the entire ABI logic there, but, in this case, we would lose the
capability of calling the script without Sphinx.

Thanks,
Mauro