Skip to content

Commit e681041

Browse files
Jack SteinerIngo Molnar
authored andcommitted
x86, UV: Add common uv_early_read_mmr() function for reading MMRs
Early in boot, reading MMRs from the UV hub controller require calls to early_ioremap()/early_iounmap(). Rather than duplicating code, add a common function to do the map/read/unmap. Signed-off-by: Jack Steiner <[email protected]> LKML-Reference: <[email protected]> Signed-off-by: Ingo Molnar <[email protected]>
1 parent 90a8a73 commit e681041

File tree

1 file changed

+14
-16
lines changed

1 file changed

+14
-16
lines changed

arch/x86/kernel/apic/x2apic_uv_x.c

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,16 @@ unsigned int uv_apicid_hibits;
4848
EXPORT_SYMBOL_GPL(uv_apicid_hibits);
4949
static DEFINE_SPINLOCK(uv_nmi_lock);
5050

51+
static unsigned long __init uv_early_read_mmr(unsigned long addr)
52+
{
53+
unsigned long val, *mmr;
54+
55+
mmr = early_ioremap(UV_LOCAL_MMR_BASE | addr, sizeof(*mmr));
56+
val = *mmr;
57+
early_iounmap(mmr, sizeof(*mmr));
58+
return val;
59+
}
60+
5161
static inline bool is_GRU_range(u64 start, u64 end)
5262
{
5363
return start >= gru_start_paddr && end <= gru_end_paddr;
@@ -58,28 +68,20 @@ static bool uv_is_untracked_pat_range(u64 start, u64 end)
5868
return is_ISA_range(start, end) || is_GRU_range(start, end);
5969
}
6070

61-
static int early_get_nodeid(void)
71+
static int __init early_get_nodeid(void)
6272
{
6373
union uvh_node_id_u node_id;
64-
unsigned long *mmr;
65-
66-
mmr = early_ioremap(UV_LOCAL_MMR_BASE | UVH_NODE_ID, sizeof(*mmr));
67-
node_id.v = *mmr;
68-
early_iounmap(mmr, sizeof(*mmr));
6974

7075
/* Currently, all blades have same revision number */
76+
node_id.v = uv_early_read_mmr(UVH_NODE_ID);
7177
uv_min_hub_revision_id = node_id.s.revision;
7278

7379
return node_id.s.node_id;
7480
}
7581

7682
static void __init early_get_apic_pnode_shift(void)
7783
{
78-
unsigned long *mmr;
79-
80-
mmr = early_ioremap(UV_LOCAL_MMR_BASE | UVH_APICID, sizeof(*mmr));
81-
uvh_apicid.v = *mmr;
82-
early_iounmap(mmr, sizeof(*mmr));
84+
uvh_apicid.v = uv_early_read_mmr(UVH_APICID);
8385
if (!uvh_apicid.v)
8486
/*
8587
* Old bios, use default value
@@ -95,12 +97,8 @@ static void __init early_get_apic_pnode_shift(void)
9597
static void __init uv_set_apicid_hibit(void)
9698
{
9799
union uvh_lb_target_physical_apic_id_mask_u apicid_mask;
98-
unsigned long *mmr;
99100

100-
mmr = early_ioremap(UV_LOCAL_MMR_BASE |
101-
UVH_LB_TARGET_PHYSICAL_APIC_ID_MASK, sizeof(*mmr));
102-
apicid_mask.v = *mmr;
103-
early_iounmap(mmr, sizeof(*mmr));
101+
apicid_mask.v = uv_early_read_mmr(UVH_LB_TARGET_PHYSICAL_APIC_ID_MASK);
104102
uv_apicid_hibits = apicid_mask.s.bit_enables & UV_APICID_HIBIT_MASK;
105103
}
106104

0 commit comments

Comments
 (0)