diff options
| author | Seiji Aguchi <seiji.aguchi@hds.com> | 2012-11-26 19:07:44 -0500 |
|---|---|---|
| committer | Tony Luck <tony.luck@intel.com> | 2012-11-26 19:07:44 -0500 |
| commit | 755d4fe46529018ae45bc7c86df682de45ace764 (patch) | |
| tree | 470788ad3e9fa704ef41fa62ac9e770193010853 /drivers/firmware | |
| parent | a9efd39cd547223597cfe7c53acec44c099b9264 (diff) | |
efi_pstore: Add a sequence counter to a variable name
[Issue]
Currently, a variable name, which identifies each entry, consists of type, id and ctime.
But if multiple events happens in a short time, a second/third event may fail to log because
efi_pstore can't distinguish each event with current variable name.
[Solution]
A reasonable way to identify all events precisely is introducing a sequence counter to
the variable name.
The sequence counter has already supported in a pstore layer with "oopscount".
So, this patch adds it to a variable name.
Also, it is passed to read/erase callbacks of platform drivers in accordance with
the modification of the variable name.
<before applying this patch>
a variable name of first event: dump-type0-1-12345678
a variable name of second event: dump-type0-1-12345678
type:0
id:1
ctime:12345678
If multiple events happen in a short time, efi_pstore can't distinguish them because
variable names are same among them.
<after applying this patch>
it can be distinguishable by adding a sequence counter as follows.
a variable name of first event: dump-type0-1-1-12345678
a variable name of Second event: dump-type0-1-2-12345678
type:0
id:1
sequence counter: 1(first event), 2(second event)
ctime:12345678
In case of a write callback executed in pstore_console_write(), "0" is added to
an argument of the write callback because it just logs all kernel messages and
doesn't need to care about multiple events.
Signed-off-by: Seiji Aguchi <seiji.aguchi@hds.com>
Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Acked-by: Mike Waychison <mikew@google.com>
Signed-off-by: Tony Luck <tony.luck@intel.com>
Diffstat (limited to 'drivers/firmware')
| -rw-r--r-- | drivers/firmware/efivars.c | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/drivers/firmware/efivars.c b/drivers/firmware/efivars.c index 3803621c0d4..7ad3aae6e08 100644 --- a/drivers/firmware/efivars.c +++ b/drivers/firmware/efivars.c | |||
| @@ -658,13 +658,14 @@ static int efi_pstore_close(struct pstore_info *psi) | |||
| 658 | } | 658 | } |
| 659 | 659 | ||
| 660 | static ssize_t efi_pstore_read(u64 *id, enum pstore_type_id *type, | 660 | static ssize_t efi_pstore_read(u64 *id, enum pstore_type_id *type, |
| 661 | struct timespec *timespec, | 661 | int *count, struct timespec *timespec, |
| 662 | char **buf, struct pstore_info *psi) | 662 | char **buf, struct pstore_info *psi) |
| 663 | { | 663 | { |
| 664 | efi_guid_t vendor = LINUX_EFI_CRASH_GUID; | 664 | efi_guid_t vendor = LINUX_EFI_CRASH_GUID; |
| 665 | struct efivars *efivars = psi->data; | 665 | struct efivars *efivars = psi->data; |
| 666 | char name[DUMP_NAME_LEN]; | 666 | char name[DUMP_NAME_LEN]; |
| 667 | int i; | 667 | int i; |
| 668 | int cnt; | ||
| 668 | unsigned int part, size; | 669 | unsigned int part, size; |
| 669 | unsigned long time; | 670 | unsigned long time; |
| 670 | 671 | ||
| @@ -674,8 +675,10 @@ static ssize_t efi_pstore_read(u64 *id, enum pstore_type_id *type, | |||
| 674 | for (i = 0; i < DUMP_NAME_LEN; i++) { | 675 | for (i = 0; i < DUMP_NAME_LEN; i++) { |
| 675 | name[i] = efivars->walk_entry->var.VariableName[i]; | 676 | name[i] = efivars->walk_entry->var.VariableName[i]; |
| 676 | } | 677 | } |
| 677 | if (sscanf(name, "dump-type%u-%u-%lu", type, &part, &time) == 3) { | 678 | if (sscanf(name, "dump-type%u-%u-%d-%lu", |
| 679 | type, &part, &cnt, &time) == 4) { | ||
| 678 | *id = part; | 680 | *id = part; |
| 681 | *count = cnt; | ||
| 679 | timespec->tv_sec = time; | 682 | timespec->tv_sec = time; |
| 680 | timespec->tv_nsec = 0; | 683 | timespec->tv_nsec = 0; |
| 681 | get_var_data_locked(efivars, &efivars->walk_entry->var); | 684 | get_var_data_locked(efivars, &efivars->walk_entry->var); |
| @@ -698,7 +701,8 @@ static ssize_t efi_pstore_read(u64 *id, enum pstore_type_id *type, | |||
| 698 | 701 | ||
| 699 | static int efi_pstore_write(enum pstore_type_id type, | 702 | static int efi_pstore_write(enum pstore_type_id type, |
| 700 | enum kmsg_dump_reason reason, u64 *id, | 703 | enum kmsg_dump_reason reason, u64 *id, |
| 701 | unsigned int part, size_t size, struct pstore_info *psi) | 704 | unsigned int part, int count, size_t size, |
| 705 | struct pstore_info *psi) | ||
| 702 | { | 706 | { |
| 703 | char name[DUMP_NAME_LEN]; | 707 | char name[DUMP_NAME_LEN]; |
| 704 | efi_char16_t efi_name[DUMP_NAME_LEN]; | 708 | efi_char16_t efi_name[DUMP_NAME_LEN]; |
| @@ -725,7 +729,7 @@ static int efi_pstore_write(enum pstore_type_id type, | |||
| 725 | return -ENOSPC; | 729 | return -ENOSPC; |
| 726 | } | 730 | } |
| 727 | 731 | ||
| 728 | sprintf(name, "dump-type%u-%u-%lu", type, part, | 732 | sprintf(name, "dump-type%u-%u-%d-%lu", type, part, count, |
| 729 | get_seconds()); | 733 | get_seconds()); |
| 730 | 734 | ||
| 731 | for (i = 0; i < DUMP_NAME_LEN; i++) | 735 | for (i = 0; i < DUMP_NAME_LEN; i++) |
| @@ -746,7 +750,7 @@ static int efi_pstore_write(enum pstore_type_id type, | |||
| 746 | return ret; | 750 | return ret; |
| 747 | }; | 751 | }; |
| 748 | 752 | ||
| 749 | static int efi_pstore_erase(enum pstore_type_id type, u64 id, | 753 | static int efi_pstore_erase(enum pstore_type_id type, u64 id, int count, |
| 750 | struct timespec time, struct pstore_info *psi) | 754 | struct timespec time, struct pstore_info *psi) |
| 751 | { | 755 | { |
| 752 | char name[DUMP_NAME_LEN]; | 756 | char name[DUMP_NAME_LEN]; |
| @@ -756,7 +760,7 @@ static int efi_pstore_erase(enum pstore_type_id type, u64 id, | |||
| 756 | struct efivar_entry *entry, *found = NULL; | 760 | struct efivar_entry *entry, *found = NULL; |
| 757 | int i; | 761 | int i; |
| 758 | 762 | ||
| 759 | sprintf(name, "dump-type%u-%u-%lu", type, (unsigned int)id, | 763 | sprintf(name, "dump-type%u-%u-%d-%lu", type, (unsigned int)id, count, |
| 760 | time.tv_sec); | 764 | time.tv_sec); |
| 761 | 765 | ||
| 762 | spin_lock(&efivars->lock); | 766 | spin_lock(&efivars->lock); |
| @@ -807,7 +811,7 @@ static int efi_pstore_close(struct pstore_info *psi) | |||
| 807 | return 0; | 811 | return 0; |
| 808 | } | 812 | } |
| 809 | 813 | ||
| 810 | static ssize_t efi_pstore_read(u64 *id, enum pstore_type_id *type, | 814 | static ssize_t efi_pstore_read(u64 *id, enum pstore_type_id *type, int *count, |
| 811 | struct timespec *timespec, | 815 | struct timespec *timespec, |
| 812 | char **buf, struct pstore_info *psi) | 816 | char **buf, struct pstore_info *psi) |
| 813 | { | 817 | { |
| @@ -816,12 +820,13 @@ static ssize_t efi_pstore_read(u64 *id, enum pstore_type_id *type, | |||
| 816 | 820 | ||
| 817 | static int efi_pstore_write(enum pstore_type_id type, | 821 | static int efi_pstore_write(enum pstore_type_id type, |
| 818 | enum kmsg_dump_reason reason, u64 *id, | 822 | enum kmsg_dump_reason reason, u64 *id, |
| 819 | unsigned int part, size_t size, struct pstore_info *psi) | 823 | unsigned int part, int count, size_t size, |
| 824 | struct pstore_info *psi) | ||
| 820 | { | 825 | { |
| 821 | return 0; | 826 | return 0; |
| 822 | } | 827 | } |
| 823 | 828 | ||
| 824 | static int efi_pstore_erase(enum pstore_type_id type, u64 id, | 829 | static int efi_pstore_erase(enum pstore_type_id type, u64 id, int count, |
| 825 | struct timespec time, struct pstore_info *psi) | 830 | struct timespec time, struct pstore_info *psi) |
| 826 | { | 831 | { |
| 827 | return 0; | 832 | return 0; |
