Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1470027 > unrolled thread
| Started by | Daniel Wagner <wagi@monom.org> |
|---|---|
| First post | 2016-08-25 12:00 +0200 |
| Last post | 2016-08-25 12:00 +0200 |
| Articles | 2 — 1 participant |
Back to article view | Back to linux.kernel
[PATCH v3 0/3] firmware_class: encapsulate firmware loading status Daniel Wagner <wagi@monom.org> - 2016-08-25 12:00 +0200
[PATCH v3 2/3] firmware_class: Drop bit ops in favor of simple state machine Daniel Wagner <wagi@monom.org> - 2016-08-25 12:00 +0200
| From | Daniel Wagner <wagi@monom.org> |
|---|---|
| Date | 2016-08-25 12:00 +0200 |
| Subject | [PATCH v3 0/3] firmware_class: encapsulate firmware loading status |
| Message-ID | <s9ZC1-7Km-3@gated-at.bofh.it> |
From: Daniel Wagner <daniel.wagner@bmw-carit.de>
This version should address all comments from Luis. In the last patch
the fw_lock dependency is dropped. This only works if we garantee not
to race between the reader and the writer side in combination in going
to sleep and waking up. So here that should now be a good argument for
swait :)
cheers,
daniel
changes since v2:
- more splitting out
- first patch factors out all the bit ops into fw_status
- second patch gets rid of the bit ops
- third get rid of fw_lock by using swait
changes since v1:
- moved swait change into its own patch
- added ifdef section for FW_LOADER_USER_HELPER_FALLBACK
- updated commit message highlighting the mutex usage drop a bit
https://lkml.org/lkml/2016/8/4/239
Cc: Ming Lei <ming.lei@canonical.com>
Cc: Luis R. Rodriguez <mcgrof@kernel.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Daniel Wagner (3):
firmware_class: encapsulate firmware loading status
firmware_class: Drop bit ops in favor of simple state machine
firmware_class: Do not use fw_lock for fw_status protection
drivers/base/firmware_class.c | 153 ++++++++++++++++++++++++++----------------
1 file changed, 94 insertions(+), 59 deletions(-)
--
2.7.4
[toc] | [next] | [standalone]
| From | Daniel Wagner <wagi@monom.org> |
|---|---|
| Date | 2016-08-25 12:00 +0200 |
| Subject | [PATCH v3 2/3] firmware_class: Drop bit ops in favor of simple state machine |
| Message-ID | <s9ZC1-7Km-25@gated-at.bofh.it> |
| In reply to | #1470027 |
From: Daniel Wagner <daniel.wagner@bmw-carit.de>
We track the state of the loading with bit ops. Since the state machine
has only a couple of states and there are only a few simple state
transition we can model this simplify.
UNKNOWN -> LOADING -> DONE | ABORTED
Signed-off-by: Daniel Wagner <daniel.wagner@bmw-carit.de>
Cc: Ming Lei <ming.lei@canonical.com>
Cc: Luis R. Rodriguez <mcgrof@kernel.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/base/firmware_class.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/drivers/base/firmware_class.c b/drivers/base/firmware_class.c
index f397026..d6cb33a 100644
--- a/drivers/base/firmware_class.c
+++ b/drivers/base/firmware_class.c
@@ -120,16 +120,18 @@ static void fw_status_init(struct fw_status *fw_st)
static int __fw_status_check(struct fw_status *fw_st, unsigned long status)
{
- return test_bit(status, &fw_st->status);
+ return fw_st->status == status;
}
static int fw_status_wait_timeout(struct fw_status *fw_st, long timeout)
{
+ unsigned long status;
int ret;
ret = wait_for_completion_interruptible_timeout(&fw_st->completion,
timeout);
- if (ret == 0 && test_bit(FW_STATUS_ABORTED, &fw_st->status))
+ status = READ_ONCE(fw_st->status);
+ if (ret == 0 && status == FW_STATUS_ABORTED)
return -ENOENT;
return ret;
@@ -138,13 +140,11 @@ static int fw_status_wait_timeout(struct fw_status *fw_st, long timeout)
static void __fw_status_set(struct fw_status *fw_st,
unsigned long status)
{
- set_bit(status, &fw_st->status);
+ WRITE_ONCE(fw_st->status, status);
if (status == FW_STATUS_DONE ||
- status == FW_STATUS_ABORTED) {
- clear_bit(FW_STATUS_LOADING, &fw_st->status);
+ status == FW_STATUS_ABORTED)
complete_all(&fw_st->completion);
- }
}
#define fw_status_start(fw_st) \
--
2.7.4
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web