public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Andrey Borzenkov <arvidjaar@mail.ru>
To: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	linux-pm@lists.linux-foundation.org
Cc: Dave <kilroyd@googlemail.com>
Subject: [PATCH RFC] provide information whether requested firmware is bult-in
Date: Sun, 12 Oct 2008 16:18:46 +0400	[thread overview]
Message-ID: <200810121618.48830.arvidjaar@mail.ru> (raw)

[-- Attachment #1: Type: text/plain, Size: 1850 bytes --]

As indicated by several threads on lkml, currently the only safe way
to reload external firmware in resume method is to cache it in memory.
In this case if firmware was already built in, we just create useless
copy. The patch suggests framework which can be used to return information
whether firmware was loaded dynamically or already available in memory.
Requestor can check it to decide whether local copy is required.

Alternative would be request_cached_firwmare() function to manage
cache in one place.  

Comments? Is there any other reliable way to ensure firmware can be
loaded on resume?

-andrey

diff --git a/drivers/base/firmware_class.c b/drivers/base/firmware_class.c
index c9c92b0..525561a 100644
--- a/drivers/base/firmware_class.c
+++ b/drivers/base/firmware_class.c
@@ -415,6 +415,7 @@ _request_firmware(const struct firmware **firmware_p, const char *name,
 		       name);
 		firmware->size = builtin->size;
 		firmware->data = builtin->data;
+		firmware->flags |= FW_FL_BUILTIN;
 		return 0;
 	}
 
@@ -491,13 +492,8 @@ release_firmware(const struct firmware *fw)
 	struct builtin_fw *builtin;
 
 	if (fw) {
-		for (builtin = __start_builtin_fw; builtin != __end_builtin_fw;
-		     builtin++) {
-			if (fw->data == builtin->data)
-				goto free_fw;
-		}
-		vfree(fw->data);
-	free_fw:
+		if (!(fw->flags&FW_FL_BUILTIN))
+			vfree(fw->data);
 		kfree(fw);
 	}
 }
diff --git a/include/linux/firmware.h b/include/linux/firmware.h
index c8ecf5b..0c6c232 100644
--- a/include/linux/firmware.h
+++ b/include/linux/firmware.h
@@ -9,9 +9,12 @@
 #define FW_ACTION_NOHOTPLUG 0
 #define FW_ACTION_HOTPLUG 1
 
+#define FW_FL_BUILTIN	(1<<0) /* Firmware image is built in kernel */
+
 struct firmware {
 	size_t size;
 	const u8 *data;
+	unsigned short flags;
 };
 
 struct device;

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 197 bytes --]

                 reply	other threads:[~2008-10-12 12:19 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=200810121618.48830.arvidjaar@mail.ru \
    --to=arvidjaar@mail.ru \
    --cc=kilroyd@googlemail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@lists.linux-foundation.org \
    /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