Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
linux
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
linux
Commits
f4b98415
Commit
f4b98415
authored
Dec 09, 2010
by
Benjamin Herrenschmidt
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'nvram' into next
parents
46f52210
6024ede9
Changes
5
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
381 additions
and
363 deletions
+381
-363
arch/powerpc/include/asm/nvram.h
arch/powerpc/include/asm/nvram.h
+11
-41
arch/powerpc/kernel/nvram_64.c
arch/powerpc/kernel/nvram_64.c
+160
-321
arch/powerpc/mm/pgtable.c
arch/powerpc/mm/pgtable.c
+1
-1
arch/powerpc/platforms/chrp/time.c
arch/powerpc/platforms/chrp/time.c
+4
-0
arch/powerpc/platforms/pseries/nvram.c
arch/powerpc/platforms/pseries/nvram.c
+205
-0
No files found.
arch/powerpc/include/asm/nvram.h
View file @
f4b98415
...
@@ -10,31 +10,7 @@
...
@@ -10,31 +10,7 @@
#ifndef _ASM_POWERPC_NVRAM_H
#ifndef _ASM_POWERPC_NVRAM_H
#define _ASM_POWERPC_NVRAM_H
#define _ASM_POWERPC_NVRAM_H
#include <linux/errno.h>
/* Signatures for nvram partitions */
#define NVRW_CNT 0x20
#define NVRAM_HEADER_LEN 16
/* sizeof(struct nvram_header) */
#define NVRAM_BLOCK_LEN 16
#define NVRAM_MAX_REQ (2080/NVRAM_BLOCK_LEN)
#define NVRAM_MIN_REQ (1056/NVRAM_BLOCK_LEN)
#define NVRAM_AS0 0x74
#define NVRAM_AS1 0x75
#define NVRAM_DATA 0x77
/* RTC Offsets */
#define MOTO_RTC_SECONDS 0x1FF9
#define MOTO_RTC_MINUTES 0x1FFA
#define MOTO_RTC_HOURS 0x1FFB
#define MOTO_RTC_DAY_OF_WEEK 0x1FFC
#define MOTO_RTC_DAY_OF_MONTH 0x1FFD
#define MOTO_RTC_MONTH 0x1FFE
#define MOTO_RTC_YEAR 0x1FFF
#define MOTO_RTC_CONTROLA 0x1FF8
#define MOTO_RTC_CONTROLB 0x1FF9
#define NVRAM_SIG_SP 0x02
/* support processor */
#define NVRAM_SIG_SP 0x02
/* support processor */
#define NVRAM_SIG_OF 0x50
/* open firmware config */
#define NVRAM_SIG_OF 0x50
/* open firmware config */
#define NVRAM_SIG_FW 0x51
/* general firmware */
#define NVRAM_SIG_FW 0x51
/* general firmware */
...
@@ -49,32 +25,19 @@
...
@@ -49,32 +25,19 @@
#define NVRAM_SIG_OS 0xa0
/* OS defined */
#define NVRAM_SIG_OS 0xa0
/* OS defined */
#define NVRAM_SIG_PANIC 0xa1
/* Apple OSX "panic" */
#define NVRAM_SIG_PANIC 0xa1
/* Apple OSX "panic" */
/* If change this size, then change the size of NVNAME_LEN */
struct
nvram_header
{
unsigned
char
signature
;
unsigned
char
checksum
;
unsigned
short
length
;
char
name
[
12
];
};
#ifdef __KERNEL__
#ifdef __KERNEL__
#include <linux/errno.h>
#include <linux/list.h>
#include <linux/list.h>
struct
nvram_partition
{
#ifdef CONFIG_PPC_PSERIES
struct
list_head
partition
;
struct
nvram_header
header
;
unsigned
int
index
;
};
extern
int
nvram_write_error_log
(
char
*
buff
,
int
length
,
extern
int
nvram_write_error_log
(
char
*
buff
,
int
length
,
unsigned
int
err_type
,
unsigned
int
err_seq
);
unsigned
int
err_type
,
unsigned
int
err_seq
);
extern
int
nvram_read_error_log
(
char
*
buff
,
int
length
,
extern
int
nvram_read_error_log
(
char
*
buff
,
int
length
,
unsigned
int
*
err_type
,
unsigned
int
*
err_seq
);
unsigned
int
*
err_type
,
unsigned
int
*
err_seq
);
extern
int
nvram_clear_error_log
(
void
);
extern
int
nvram_clear_error_log
(
void
);
extern
int
pSeries_nvram_init
(
void
);
extern
int
pSeries_nvram_init
(
void
);
#endif
/* CONFIG_PPC_PSERIES */
#ifdef CONFIG_MMIO_NVRAM
#ifdef CONFIG_MMIO_NVRAM
extern
int
mmio_nvram_init
(
void
);
extern
int
mmio_nvram_init
(
void
);
...
@@ -85,6 +48,13 @@ static inline int mmio_nvram_init(void)
...
@@ -85,6 +48,13 @@ static inline int mmio_nvram_init(void)
}
}
#endif
#endif
extern
int
__init
nvram_scan_partitions
(
void
);
extern
loff_t
nvram_create_partition
(
const
char
*
name
,
int
sig
,
int
req_size
,
int
min_size
);
extern
int
nvram_remove_partition
(
const
char
*
name
,
int
sig
);
extern
int
nvram_get_partition_size
(
loff_t
data_index
);
extern
loff_t
nvram_find_partition
(
const
char
*
name
,
int
sig
,
int
*
out_size
);
#endif
/* __KERNEL__ */
#endif
/* __KERNEL__ */
/* PowerMac specific nvram stuffs */
/* PowerMac specific nvram stuffs */
...
...
arch/powerpc/kernel/nvram_64.c
View file @
f4b98415
This diff is collapsed.
Click to expand it.
arch/powerpc/mm/pgtable.c
View file @
f4b98415
...
@@ -92,7 +92,7 @@ static void pte_free_rcu_callback(struct rcu_head *head)
...
@@ -92,7 +92,7 @@ static void pte_free_rcu_callback(struct rcu_head *head)
static
void
pte_free_submit
(
struct
pte_freelist_batch
*
batch
)
static
void
pte_free_submit
(
struct
pte_freelist_batch
*
batch
)
{
{
call_rcu
(
&
batch
->
rcu
,
pte_free_rcu_callback
);
call_rcu
_sched
(
&
batch
->
rcu
,
pte_free_rcu_callback
);
}
}
void
pgtable_free_tlb
(
struct
mmu_gather
*
tlb
,
void
*
table
,
unsigned
shift
)
void
pgtable_free_tlb
(
struct
mmu_gather
*
tlb
,
void
*
table
,
unsigned
shift
)
...
...
arch/powerpc/platforms/chrp/time.c
View file @
f4b98415
...
@@ -29,6 +29,10 @@
...
@@ -29,6 +29,10 @@
extern
spinlock_t
rtc_lock
;
extern
spinlock_t
rtc_lock
;
#define NVRAM_AS0 0x74
#define NVRAM_AS1 0x75
#define NVRAM_DATA 0x77
static
int
nvram_as1
=
NVRAM_AS1
;
static
int
nvram_as1
=
NVRAM_AS1
;
static
int
nvram_as0
=
NVRAM_AS0
;
static
int
nvram_as0
=
NVRAM_AS0
;
static
int
nvram_data
=
NVRAM_DATA
;
static
int
nvram_data
=
NVRAM_DATA
;
...
...
arch/powerpc/platforms/pseries/nvram.c
View file @
f4b98415
...
@@ -22,11 +22,25 @@
...
@@ -22,11 +22,25 @@
#include <asm/prom.h>
#include <asm/prom.h>
#include <asm/machdep.h>
#include <asm/machdep.h>
/* Max bytes to read/write in one go */
#define NVRW_CNT 0x20
static
unsigned
int
nvram_size
;
static
unsigned
int
nvram_size
;
static
int
nvram_fetch
,
nvram_store
;
static
int
nvram_fetch
,
nvram_store
;
static
char
nvram_buf
[
NVRW_CNT
];
/* assume this is in the first 4GB */
static
char
nvram_buf
[
NVRW_CNT
];
/* assume this is in the first 4GB */
static
DEFINE_SPINLOCK
(
nvram_lock
);
static
DEFINE_SPINLOCK
(
nvram_lock
);
static
long
nvram_error_log_index
=
-
1
;
static
long
nvram_error_log_size
=
0
;
struct
err_log_info
{
int
error_type
;
unsigned
int
seq_num
;
};
#define NVRAM_MAX_REQ 2079
#define NVRAM_MIN_REQ 1055
#define NVRAM_LOG_PART_NAME "ibm,rtas-log"
static
ssize_t
pSeries_nvram_read
(
char
*
buf
,
size_t
count
,
loff_t
*
index
)
static
ssize_t
pSeries_nvram_read
(
char
*
buf
,
size_t
count
,
loff_t
*
index
)
{
{
...
@@ -119,6 +133,197 @@ static ssize_t pSeries_nvram_get_size(void)
...
@@ -119,6 +133,197 @@ static ssize_t pSeries_nvram_get_size(void)
return
nvram_size
?
nvram_size
:
-
ENODEV
;
return
nvram_size
?
nvram_size
:
-
ENODEV
;
}
}
/* nvram_write_error_log
*
* We need to buffer the error logs into nvram to ensure that we have
* the failure information to decode. If we have a severe error there
* is no way to guarantee that the OS or the machine is in a state to
* get back to user land and write the error to disk. For example if
* the SCSI device driver causes a Machine Check by writing to a bad
* IO address, there is no way of guaranteeing that the device driver
* is in any state that is would also be able to write the error data
* captured to disk, thus we buffer it in NVRAM for analysis on the
* next boot.
*
* In NVRAM the partition containing the error log buffer will looks like:
* Header (in bytes):
* +-----------+----------+--------+------------+------------------+
* | signature | checksum | length | name | data |
* |0 |1 |2 3|4 15|16 length-1|
* +-----------+----------+--------+------------+------------------+
*
* The 'data' section would look like (in bytes):
* +--------------+------------+-----------------------------------+
* | event_logged | sequence # | error log |
* |0 3|4 7|8 nvram_error_log_size-1|
* +--------------+------------+-----------------------------------+
*
* event_logged: 0 if event has not been logged to syslog, 1 if it has
* sequence #: The unique sequence # for each event. (until it wraps)
* error log: The error log from event_scan
*/
int
nvram_write_error_log
(
char
*
buff
,
int
length
,
unsigned
int
err_type
,
unsigned
int
error_log_cnt
)
{
int
rc
;
loff_t
tmp_index
;
struct
err_log_info
info
;
if
(
nvram_error_log_index
==
-
1
)
{
return
-
ESPIPE
;
}
if
(
length
>
nvram_error_log_size
)
{
length
=
nvram_error_log_size
;
}
info
.
error_type
=
err_type
;
info
.
seq_num
=
error_log_cnt
;
tmp_index
=
nvram_error_log_index
;
rc
=
ppc_md
.
nvram_write
((
char
*
)
&
info
,
sizeof
(
struct
err_log_info
),
&
tmp_index
);
if
(
rc
<=
0
)
{
printk
(
KERN_ERR
"nvram_write_error_log: Failed nvram_write (%d)
\n
"
,
rc
);
return
rc
;
}
rc
=
ppc_md
.
nvram_write
(
buff
,
length
,
&
tmp_index
);
if
(
rc
<=
0
)
{
printk
(
KERN_ERR
"nvram_write_error_log: Failed nvram_write (%d)
\n
"
,
rc
);
return
rc
;
}
return
0
;
}
/* nvram_read_error_log
*
* Reads nvram for error log for at most 'length'
*/
int
nvram_read_error_log
(
char
*
buff
,
int
length
,
unsigned
int
*
err_type
,
unsigned
int
*
error_log_cnt
)
{
int
rc
;
loff_t
tmp_index
;
struct
err_log_info
info
;
if
(
nvram_error_log_index
==
-
1
)
return
-
1
;
if
(
length
>
nvram_error_log_size
)
length
=
nvram_error_log_size
;
tmp_index
=
nvram_error_log_index
;
rc
=
ppc_md
.
nvram_read
((
char
*
)
&
info
,
sizeof
(
struct
err_log_info
),
&
tmp_index
);
if
(
rc
<=
0
)
{
printk
(
KERN_ERR
"nvram_read_error_log: Failed nvram_read (%d)
\n
"
,
rc
);
return
rc
;
}
rc
=
ppc_md
.
nvram_read
(
buff
,
length
,
&
tmp_index
);
if
(
rc
<=
0
)
{
printk
(
KERN_ERR
"nvram_read_error_log: Failed nvram_read (%d)
\n
"
,
rc
);
return
rc
;
}
*
error_log_cnt
=
info
.
seq_num
;
*
err_type
=
info
.
error_type
;
return
0
;
}
/* This doesn't actually zero anything, but it sets the event_logged
* word to tell that this event is safely in syslog.
*/
int
nvram_clear_error_log
(
void
)
{
loff_t
tmp_index
;
int
clear_word
=
ERR_FLAG_ALREADY_LOGGED
;
int
rc
;
if
(
nvram_error_log_index
==
-
1
)
return
-
1
;
tmp_index
=
nvram_error_log_index
;
rc
=
ppc_md
.
nvram_write
((
char
*
)
&
clear_word
,
sizeof
(
int
),
&
tmp_index
);
if
(
rc
<=
0
)
{
printk
(
KERN_ERR
"nvram_clear_error_log: Failed nvram_write (%d)
\n
"
,
rc
);
return
rc
;
}
return
0
;
}
/* pseries_nvram_init_log_partition
*
* This will setup the partition we need for buffering the
* error logs and cleanup partitions if needed.
*
* The general strategy is the following:
* 1.) If there is log partition large enough then use it.
* 2.) If there is none large enough, search
* for a free partition that is large enough.
* 3.) If there is not a free partition large enough remove
* _all_ OS partitions and consolidate the space.
* 4.) Will first try getting a chunk that will satisfy the maximum
* error log size (NVRAM_MAX_REQ).
* 5.) If the max chunk cannot be allocated then try finding a chunk
* that will satisfy the minum needed (NVRAM_MIN_REQ).
*/
static
int
__init
pseries_nvram_init_log_partition
(
void
)
{
loff_t
p
;
int
size
;
/* Scan nvram for partitions */
nvram_scan_partitions
();
/* Lookg for ours */
p
=
nvram_find_partition
(
NVRAM_LOG_PART_NAME
,
NVRAM_SIG_OS
,
&
size
);
/* Found one but too small, remove it */
if
(
p
&&
size
<
NVRAM_MIN_REQ
)
{
pr_info
(
"nvram: Found too small "
NVRAM_LOG_PART_NAME
" partition"
",removing it..."
);
nvram_remove_partition
(
NVRAM_LOG_PART_NAME
,
NVRAM_SIG_OS
);
p
=
0
;
}
/* Create one if we didn't find */
if
(
!
p
)
{
p
=
nvram_create_partition
(
NVRAM_LOG_PART_NAME
,
NVRAM_SIG_OS
,
NVRAM_MAX_REQ
,
NVRAM_MIN_REQ
);
/* No room for it, try to get rid of any OS partition
* and try again
*/
if
(
p
==
-
ENOSPC
)
{
pr_info
(
"nvram: No room to create "
NVRAM_LOG_PART_NAME
" partition, deleting all OS partitions..."
);
nvram_remove_partition
(
NULL
,
NVRAM_SIG_OS
);
p
=
nvram_create_partition
(
NVRAM_LOG_PART_NAME
,
NVRAM_SIG_OS
,
NVRAM_MAX_REQ
,
NVRAM_MIN_REQ
);
}
}
if
(
p
<=
0
)
{
pr_err
(
"nvram: Failed to find or create "
NVRAM_LOG_PART_NAME
" partition, err %d
\n
"
,
(
int
)
p
);
return
0
;
}
nvram_error_log_index
=
p
;
nvram_error_log_size
=
nvram_get_partition_size
(
p
)
-
sizeof
(
struct
err_log_info
);
return
0
;
}
machine_arch_initcall
(
pseries
,
pseries_nvram_init_log_partition
);
int
__init
pSeries_nvram_init
(
void
)
int
__init
pSeries_nvram_init
(
void
)
{
{
struct
device_node
*
nvram
;
struct
device_node
*
nvram
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment