lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1495262886-1045-2-git-send-email-yi1.li@linux.intel.com>
Date:   Sat, 20 May 2017 01:48:05 -0500
From:   yi1.li@...ux.intel.com
To:     mcgrof@...nel.org, atull@...nel.org, gregkh@...uxfoundation.org,
        wagi@...om.org, dwmw2@...radead.org, rafal@...ecki.pl,
        arend.vanspriel@...adcom.com, rjw@...ysocki.net,
        moritz.fischer@...us.com, pmladek@...e.com,
        johannes.berg@...el.com, emmanuel.grumbach@...el.com,
        luciano.coelho@...el.com, kvalo@...eaurora.org, luto@...nel.org,
        takahiro.akashi@...aro.org, dhowells@...hat.com, pjones@...hat.com
Cc:     linux-kernel@...r.kernel.org, linux-fpga@...r.kernel.org,
        Yi Li <yi1.li@...ux.intel.com>
Subject: [PATCHv2 1/2] firmware: Enable pre-allocated buffer support in driver_data

From: Yi Li <yi1.li@...ux.intel.com>

This enables the equivalent feature of the legacy request_firmware_into_buf
to driver_data, so caller can allocate and manage the firmware buffer
instead of by driver_data class internally. The caller need to setup
alloc_buf and alloc_buf_size in the @driver_data_req_params structure.

Signed-off-by: Yi Li <yi1.li@...ux.intel.com>
---
 drivers/base/firmware_class.c | 21 ++++++++-------------
 include/linux/driver_data.h   |  5 +++++
 2 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/drivers/base/firmware_class.c b/drivers/base/firmware_class.c
index 444c9a8..461c7c2 100644
--- a/drivers/base/firmware_class.c
+++ b/drivers/base/firmware_class.c
@@ -83,9 +83,6 @@ enum driver_data_priv_reqs {
  * @mode: mode of operation
  * @priv_reqs: private set of &enum driver_data_reqs, private requirements for
  * 	the driver data request
- * @alloc_buf: buffer area allocated by the caller so we can place the
- * 	respective driver data
- * @alloc_buf_size: size of the @alloc_buf
  * @old_async_cb: used only for request_firmware_nowait() since we won't change
  * 	all async callbacks to get the return value on failure
  * @api: used internally for keeping track of the currently evaluated API
@@ -98,8 +95,6 @@ enum driver_data_priv_reqs {
 struct driver_data_priv_params {
 	enum driver_data_mode mode;
 	u64 priv_reqs;
-	void *alloc_buf;
-	size_t alloc_buf_size;
 	void (*old_async_cb)(const struct firmware *driver_data, void *context);
 	u8 api;
 	bool retry_api;
@@ -149,12 +144,12 @@ struct driver_data_params {
 #define __DATA_REQ_FIRMWARE_BUF(buf, size)				\
 	.req_params = {							\
 		.reqs = DRIVER_DATA_REQ_NO_CACHE,			\
+		.alloc_buf = &buf,					\
+		.alloc_buf_size = size,					\
 	},								\
 	.priv_params = {						\
 		.priv_reqs = DRIVER_DATA_PRIV_REQ_FALLBACK |		\
 			     DRIVER_DATA_PRIV_REQ_FALLBACK_UEVENT,	\
-		.alloc_buf = buf,					\
-		.alloc_buf_size = size,					\
 	}
 
 #define __DATA_REQ_FIRMWARE_NOWAIT(module, uevent, gfp, async_cb, async_ctx) \
@@ -265,9 +260,9 @@ static bool fw_get_builtin_firmware(struct firmware *fw, const char *name,
 	void *buf;
 	size_t size;
 
-	if (data_params) {
-		buf = data_params->priv_params.alloc_buf;
-		size = data_params->priv_params.alloc_buf_size;
+	if (data_params && data_params->req_params.alloc_buf) {
+		buf = *data_params->req_params.alloc_buf;
+		size = data_params->req_params.alloc_buf_size;
 	} else {
 		buf = NULL;
 		size = 0;
@@ -507,9 +502,9 @@ static struct firmware_buf *__allocate_fw_buf(const char *fw_name,
 	void *dbuf;
 	size_t size;
 
-	if (data_params) {
-		dbuf = data_params->priv_params.alloc_buf;
-		size = data_params->priv_params.alloc_buf_size;
+	if (data_params && data_params->req_params.alloc_buf) {
+		dbuf = *data_params->req_params.alloc_buf;
+		size = data_params->req_params.alloc_buf_size;
 	} else {
 		dbuf = NULL;
 		size = 0;
diff --git a/include/linux/driver_data.h b/include/linux/driver_data.h
index b6ef5ee..a3a5fbe 100644
--- a/include/linux/driver_data.h
+++ b/include/linux/driver_data.h
@@ -144,6 +144,9 @@ enum driver_data_reqs {
  * 	highest version of API supported by the caller.
  * @api_name_postfix: optional, indicates to use this as the driver data name
  * 	postfix when %DRIVER_DATA_REQ_USE_API_VERSIONING is enabled.
+ * @alloc_buf: pointer of pointer to the buffer area allocated by the caller
+ *	so we can place the respective driver data
+ * @alloc_buf_size: size of the @alloc_buf
  *
  * This data structure is intended to carry all requirements and specifications
  * required to complete the task to get the requested driver date file to the
@@ -157,6 +160,8 @@ struct driver_data_req_params {
 	u8 api_max;
 	const char *api_name_postfix;
 	const union driver_data_cbs cbs;
+	void **alloc_buf;
+	size_t alloc_buf_size;
 };
 
 /*
-- 
2.7.4

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ