From: "Luis R. Rodriguez" <mcgrof@kernel.org>
To: gregkh@linuxfoundation.org
Cc: wagi@monom.org, dwmw2@infradead.org, rafal@milecki.pl,
arend.vanspriel@broadcom.com, rjw@rjwysocki.net,
yi1.li@linux.intel.com, atull@opensource.altera.com,
moritz.fischer@ettus.com, pmladek@suse.com,
johannes.berg@intel.com, emmanuel.grumbach@intel.com,
luciano.coelho@intel.com, kvalo@codeaurora.org, luto@kernel.org,
torvalds@linux-foundation.org, keescook@chromium.org,
takahiro.akashi@linaro.org, dhowells@redhat.com,
pjones@redhat.com, hdegoede@redhat.com,
linux-kernel@vger.kernel.org,
"Luis R. Rodriguez" <mcgrof@kernel.org>
Subject: [PATCH v7 4/5] firmware: document the extensible driver data API
Date: Tue, 2 May 2017 01:49:13 -0700 [thread overview]
Message-ID: <20170502084914.23588-5-mcgrof@kernel.org> (raw)
In-Reply-To: <20170502084914.23588-1-mcgrof@kernel.org>
This documents the driver data API.
Signed-off-by: Luis R. Rodriguez <mcgrof@kernel.org>
---
Documentation/driver-api/firmware/driver_data.rst | 167 +++++++++++++++++++++
Documentation/driver-api/firmware/index.rst | 1 +
Documentation/driver-api/firmware/introduction.rst | 16 ++
.../driver-api/firmware/request_firmware.rst | 2 +
4 files changed, 186 insertions(+)
create mode 100644 Documentation/driver-api/firmware/driver_data.rst
diff --git a/Documentation/driver-api/firmware/driver_data.rst b/Documentation/driver-api/firmware/driver_data.rst
new file mode 100644
index 000000000000..be7c7ff99151
--- /dev/null
+++ b/Documentation/driver-api/firmware/driver_data.rst
@@ -0,0 +1,167 @@
+.. _driver_data:
+
+===============
+driver_data API
+===============
+
+The driver data APIs provides a flexible API for general driver data file
+lookups. Its flexibility aims at mitigating collateral evolutions on the kernel
+as new functionality is introduced.
+
+Driver data modes of operation
+==============================
+
+There are two types of modes of operation for driver data requests:
+
+ * synchronous - driver_data_request_sync()
+ * asynchronous - driver_data_request_async()
+
+Synchronous requests expect requests to be done immediately, asynchronous
+requests enable requests to be scheduled for a later time.
+
+Driver data request parameters
+==============================
+
+Variations of types of driver data requests are specified by a driver data
+request parameter data structure. The flexibility of the API is provided by
+expanding the request parameters as new functionality is needed, without
+loosely modifying or adding new exported APIs.
+
+driver_data_sync_cbs
+--------------------
+.. kernel-doc:: include/linux/driver_data.h
+ :functions: driver_data_sync_cbs
+
+driver_data_async_cbs
+---------------------
+.. kernel-doc:: include/linux/driver_data.h
+ :functions: driver_data_async_cbs
+
+driver_data_cbs
+---------------
+.. kernel-doc:: include/linux/driver_data.h
+ :functions: driver_data_cbs
+
+driver_data_reqs
+----------------
+.. kernel-doc:: include/linux/driver_data.h
+ :functions: driver_data_reqs
+
+driver_data_req_params
+----------------------
+.. kernel-doc:: include/linux/driver_data.h
+ :functions: driver_data_req_params
+
+Synchronous driver data requests
+================================
+
+Synchronous driver data requests will wait until the driver data is found or
+until an error is returned.
+
+driver_data_request_sync
+------------------------
+.. kernel-doc:: drivers/base/firmware_class.c
+ :functions: driver_data_request_sync
+
+Asynchronous driver data requests
+=================================
+
+Asynchronous driver data requests allow driver code to not have to wait
+until the driver data or an error is returned. Function callbacks are
+required so that when the firmware or an error is found the driver is
+informed through the callbacks. Asynchronous driver data requests cannot
+be called from atomic contexts.
+
+driver_data_request_async
+-------------------------
+.. kernel-doc:: drivers/base/firmware_class.c
+ :functions: driver_data_request_async
+
+Reference counting and releasing the driver data file
+=====================================================
+
+The device and module are bumped with reference counts during the driver data
+requests. This prevents removal of the device and module making the driver data
+request call until the driver data request callbacks have completed, either
+synchronously or asynchronously. When synchronous requests are made the
+firmware_class is refcounted. When asynchronous requests are made the caller's
+module is refcounted. Asynchronous requests do not refcount the firmware_class
+module.
+
+The driver data request API enables callers to provide a callback for both
+synchronous and asynchronous requests and since consumption can be expected
+in these callbacks it frees it for you by default after callback handlers
+are issued. If you wish to keep the driver data around after your callbacks
+you must specify this through the driver data request parameter data structure.
+
+Driver data private internal functionality
+==========================================
+
+This section documents functionality not exposed to users, but important in
+understanding how the driver data internals work.
+
+driver_data_mode
+----------------
+.. kernel-doc:: drivers/base/firmware_class.c
+ :functions: driver_data_mode
+
+driver_data_priv_reqs
+---------------------
+.. kernel-doc:: drivers/base/firmware_class.c
+ :functions: driver_data_priv_reqs
+
+driver_data_priv_params
+-----------------------
+.. kernel-doc:: drivers/base/firmware_class.c
+ :functions: driver_data_priv_params
+
+driver_data_params
+------------------
+.. kernel-doc:: drivers/base/firmware_class.c
+ :functions: driver_data_params
+
+Testing the driver_data API
+===========================
+
+The driver data API has a selftest driver: lib/test_driver_data.c. The
+test_driver_data enables you to build your tests in userspace by exposing knobs
+of the exported API in userspace and enabling userspace to configure and
+trigger a kernel call. This lets us build most possible test cases of
+the kernel APIs from userspace.
+
+The test_driver_data also enables multiple test triggers to be created
+enabling testing to be done in parallel, one test interface per test case.
+
+To test an async call one could do::
+
+ echo anything > /lib/firmware/test-driver_data.bin
+ echo -n 1 > /sys/devices/virtual/misc/test_driver_data0/config_async
+ echo -n 1 > /sys/devices/virtual/misc/test_driver_data0/trigger_config
+
+A series of tests have been written to test the driver data API thoroughly.
+A respective test case is expected to bet written as new features get added.
+For details of existing tests run::
+
+ tools/testing/selftests/firmware/driver_data.sh -l
+
+To see all available options::
+
+ tools/testing/selftests/firmware/driver_data.sh --help
+
+To run a test 0010 case 40 times::
+
+ tools/testing/selftests/firmware/driver_data.sh -c 0010 40
+
+Note that driver_data.sh uses its own temporary custom path for creating and
+looking for driver data files, it does this to not overwrite any production
+files you might have which may share the same names used by the test shell
+script driver_data.sh. If you are not using the driver_data.sh script your
+default path will be used.
+
+Tracking development enhancements and ideas
+===========================================
+
+To help track ongoing development for firmware_class and related items to
+firmware_class refer to the kernel newbies wiki page [0].
+
+[0] http://kernelnewbies.org/KernelProjects/firmware-class-enhancements
diff --git a/Documentation/driver-api/firmware/index.rst b/Documentation/driver-api/firmware/index.rst
index 29da39ec4b8a..70a3dea0c5de 100644
--- a/Documentation/driver-api/firmware/index.rst
+++ b/Documentation/driver-api/firmware/index.rst
@@ -8,6 +8,7 @@ Linux Firmware API
core
request_firmware
other_interfaces
+ driver_data
.. only:: subproject and html
diff --git a/Documentation/driver-api/firmware/introduction.rst b/Documentation/driver-api/firmware/introduction.rst
index 211cb44eb972..c1173bac0dbb 100644
--- a/Documentation/driver-api/firmware/introduction.rst
+++ b/Documentation/driver-api/firmware/introduction.rst
@@ -25,3 +25,19 @@ are already using asynchronous initialization mechanisms which will not
stall or delay boot. Even if loading firmware does not take a lot of time
processing firmware might, and this can still delay boot or initialization,
as such mechanisms such as asynchronous probe can help supplement drivers.
+
+Two APIs
+========
+
+Two APIs are provided for firmware:
+
+* Old firmware API - :ref:`request_firmware`
+* Flexible driver data API - :ref:`driver_data`
+
+We have historically extended the firmware API by adding new routines or at
+times extending existing routines with more or less arguments. This doesn't
+scale well, when new arguments are added to existing routines it means we need
+to traverse the kernel with a slew of collateral evolutions to adjust old
+driver users. The driver data API is an extensible API enabling extensions to
+be added by avoiding unnecessary collateral evolutions as features get added.
+New features and development should be added through the driver_data API.
diff --git a/Documentation/driver-api/firmware/request_firmware.rst b/Documentation/driver-api/firmware/request_firmware.rst
index 1c2c4967cd43..b31938244b7f 100644
--- a/Documentation/driver-api/firmware/request_firmware.rst
+++ b/Documentation/driver-api/firmware/request_firmware.rst
@@ -1,3 +1,5 @@
+.. _request_firmware:
+
====================
request_firmware API
====================
--
2.11.0
next prev parent reply other threads:[~2017-05-02 8:49 UTC|newest]
Thread overview: 98+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-30 3:25 [PATCH v6 0/5] firmware: add driver data API Luis R. Rodriguez
2017-03-30 3:25 ` [PATCH v6 1/5] firmware: add extensible driver data params Luis R. Rodriguez
2017-04-06 7:26 ` Luca Coelho
2017-04-27 2:05 ` Luis R. Rodriguez
2017-03-30 3:25 ` [PATCH v6 2/5] firmware: add extensible driver data API Luis R. Rodriguez
2017-04-10 12:42 ` Coelho, Luciano
2017-04-11 8:01 ` takahiro.akashi
2017-04-27 3:23 ` Luis R. Rodriguez
2017-04-27 3:16 ` Luis R. Rodriguez
2017-04-27 5:44 ` Luca Coelho
2017-04-27 8:04 ` Luis R. Rodriguez
2017-04-27 6:09 ` Luca Coelho
2017-04-27 10:31 ` Luis R. Rodriguez
2017-04-13 9:36 ` AKASHI Takahiro
2017-04-28 0:51 ` Luis R. Rodriguez
2017-04-28 3:19 ` AKASHI Takahiro
2017-04-29 4:36 ` Luis R. Rodriguez
2017-03-30 3:25 ` [PATCH v6 3/5] test: add new driver_data load tester Luis R. Rodriguez
2017-04-11 8:32 ` AKASHI Takahiro
2017-04-28 1:45 ` Luis R. Rodriguez
2017-05-11 10:46 ` AKASHI Takahiro
2017-05-11 17:11 ` Luis R. Rodriguez
2017-05-17 22:45 ` Li, Yi
2017-05-19 18:31 ` Luis R. Rodriguez
2017-05-11 18:12 ` Luis R. Rodriguez
2017-05-11 18:26 ` Luis R. Rodriguez
2017-05-11 18:32 ` Luis R. Rodriguez
2017-05-12 0:28 ` AKASHI Takahiro
2017-05-12 15:59 ` Luis R. Rodriguez
2017-05-17 9:08 ` AKASHI Takahiro
2017-05-17 15:38 ` Luis R. Rodriguez
2017-05-12 0:20 ` AKASHI Takahiro
2017-05-12 15:52 ` Luis R. Rodriguez
2017-05-13 18:46 ` Luis R. Rodriguez
2017-03-30 3:25 ` [PATCH v6 4/5] iwlwifi: convert to use driver data API Luis R. Rodriguez
2017-04-10 13:19 ` Luca Coelho
2017-04-28 0:56 ` Luis R. Rodriguez
2017-04-28 12:17 ` Luca Coelho
2017-03-30 3:25 ` [PATCH v6 5/5] brcmfmac: don't warn user if requested nvram fails Luis R. Rodriguez
2017-04-27 0:49 ` Luis R. Rodriguez
2017-05-02 8:49 ` [PATCH v7 0/5] firmware: add driver data API Luis R. Rodriguez
2017-05-02 8:49 ` [PATCH v7 1/5] firmware: add extensible driver data params Luis R. Rodriguez
2017-05-11 18:17 ` Li, Yi
2017-05-11 18:28 ` Luis R. Rodriguez
2017-05-02 8:49 ` [PATCH v7 2/5] firmware: add extensible driver data API Luis R. Rodriguez
2017-05-02 8:49 ` [PATCH v7 3/5] test: add new driver_data load tester Luis R. Rodriguez
2017-05-11 10:10 ` AKASHI Takahiro
2017-05-11 17:00 ` Luis R. Rodriguez
2017-05-15 18:23 ` [PATCH v8] " Luis R. Rodriguez
2017-05-02 8:49 ` Luis R. Rodriguez [this message]
2017-05-02 8:49 ` [PATCH v7 5/5] iwlwifi: convert to use driver data API Luis R. Rodriguez
2017-05-19 19:10 ` [PATCH v8 0/5] firmware: add " Luis R. Rodriguez
2017-05-19 19:10 ` [PATCH v8 1/5] firmware: add extensible driver data params Luis R. Rodriguez
2017-05-19 19:10 ` [PATCH v8 2/5] firmware: add extensible driver data API Luis R. Rodriguez
2017-05-19 19:10 ` [PATCH v8 3/5] test: add new driver_data load tester Luis R. Rodriguez
2017-05-19 19:10 ` [PATCH v8 4/5] firmware: document the extensible driver data API Luis R. Rodriguez
2017-05-19 19:10 ` [PATCH v8 5/5] iwlwifi: convert to use " Luis R. Rodriguez
2017-06-05 21:33 ` [PATCH v8 0/5] firmware: add " Luis R. Rodriguez
2017-06-05 21:39 ` [PATCH v9 " Luis R. Rodriguez
2017-06-05 21:39 ` [PATCH v9 1/5] firmware: add extensible driver data params Luis R. Rodriguez
2017-06-13 9:05 ` Greg KH
2017-06-13 10:31 ` Rafał Miłecki
2017-06-13 13:17 ` Greg KH
2017-06-13 14:12 ` Rafał Miłecki
2017-06-13 15:32 ` Luis R. Rodriguez
2017-06-13 15:50 ` Greg KH
2017-06-13 19:40 ` Luis R. Rodriguez
2017-06-14 15:57 ` Li, Yi
2017-06-17 19:38 ` Greg KH
2017-06-19 7:33 ` Johannes Berg
2017-06-19 19:41 ` Luis R. Rodriguez
2017-06-20 1:26 ` AKASHI Takahiro
2017-06-19 19:35 ` Luis R. Rodriguez
2017-06-23 15:51 ` Greg KH
2017-06-23 22:43 ` Luis R. Rodriguez
2017-06-23 23:09 ` Linus Torvalds
2017-06-24 0:48 ` Luis R. Rodriguez
2017-06-24 12:39 ` Greg KH
2017-06-26 17:33 ` Luis R. Rodriguez
2017-06-26 18:19 ` Rafał Miłecki
2017-06-26 21:29 ` Luis R. Rodriguez
2017-06-27 2:28 ` Vikram Mulukutla
2017-06-27 17:25 ` Luis R. Rodriguez
2017-06-24 12:40 ` Greg KH
2017-06-26 15:50 ` Luis R. Rodriguez
2017-06-23 15:59 ` Greg KH
2017-06-23 22:47 ` Luis R. Rodriguez
2017-06-19 22:51 ` Li, Yi
2017-06-20 1:48 ` AKASHI Takahiro
2017-06-20 15:20 ` Li, Yi
2017-06-20 16:27 ` Vikram Mulukutla
2017-06-20 17:22 ` Luis R. Rodriguez
2017-06-21 0:49 ` AKASHI Takahiro
2017-06-23 16:33 ` Luis R. Rodriguez
2017-06-05 21:39 ` [PATCH v9 2/5] firmware: add extensible driver data API Luis R. Rodriguez
2017-06-05 21:39 ` [PATCH v9 3/5] test: add new driver_data load tester Luis R. Rodriguez
2017-06-05 21:39 ` [PATCH v9 4/5] firmware: document the extensible driver data API Luis R. Rodriguez
2017-06-05 21:39 ` [PATCH v9 5/5] iwlwifi: convert to use " Luis R. Rodriguez
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170502084914.23588-5-mcgrof@kernel.org \
--to=mcgrof@kernel.org \
--cc=arend.vanspriel@broadcom.com \
--cc=atull@opensource.altera.com \
--cc=dhowells@redhat.com \
--cc=dwmw2@infradead.org \
--cc=emmanuel.grumbach@intel.com \
--cc=gregkh@linuxfoundation.org \
--cc=hdegoede@redhat.com \
--cc=johannes.berg@intel.com \
--cc=keescook@chromium.org \
--cc=kvalo@codeaurora.org \
--cc=linux-kernel@vger.kernel.org \
--cc=luciano.coelho@intel.com \
--cc=luto@kernel.org \
--cc=moritz.fischer@ettus.com \
--cc=pjones@redhat.com \
--cc=pmladek@suse.com \
--cc=rafal@milecki.pl \
--cc=rjw@rjwysocki.net \
--cc=takahiro.akashi@linaro.org \
--cc=torvalds@linux-foundation.org \
--cc=wagi@monom.org \
--cc=yi1.li@linux.intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox