diff options
author | Ian Munsie <imunsie@au1.ibm.com> | 2014-10-27 23:25:28 -0400 |
---|---|---|
committer | Michael Ellerman <mpe@ellerman.id.au> | 2014-10-28 04:52:24 -0400 |
commit | b03a7f578ac831276fe3870ebda01609d18167de (patch) | |
tree | 62d5c3c12fabcc8acfea7952e04ee61ae5b03483 | |
parent | 5100a9d6444bf205de49190431b0d08de43b86e9 (diff) |
cxl: Refactor cxl_load_segment() and find_free_sste()
This moves the segment table hash calculation from cxl_load_segment()
into find_free_sste() since that is the only place it is actually used.
Signed-off-by: Ian Munsie <imunsie@au1.ibm.com>
Reviewed-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
-rw-r--r-- | drivers/misc/cxl/fault.c | 34 |
1 files changed, 18 insertions, 16 deletions
diff --git a/drivers/misc/cxl/fault.c b/drivers/misc/cxl/fault.c index d0e97fd3d4c5..cb4f3231b451 100644 --- a/drivers/misc/cxl/fault.c +++ b/drivers/misc/cxl/fault.c | |||
@@ -21,20 +21,30 @@ | |||
21 | 21 | ||
22 | #include "cxl.h" | 22 | #include "cxl.h" |
23 | 23 | ||
24 | static struct cxl_sste* find_free_sste(struct cxl_sste *primary_group, | 24 | /* This finds a free SSTE for the given SLB */ |
25 | unsigned int *lru) | 25 | static struct cxl_sste* find_free_sste(struct cxl_context *ctx, |
26 | struct copro_slb *slb) | ||
26 | { | 27 | { |
28 | struct cxl_sste *primary, *sste; | ||
29 | unsigned int mask = (ctx->sst_size >> 7) - 1; /* SSTP0[SegTableSize] */ | ||
27 | unsigned int entry; | 30 | unsigned int entry; |
28 | struct cxl_sste *sste, *group = primary_group; | 31 | unsigned int hash; |
32 | |||
33 | if (slb->vsid & SLB_VSID_B_1T) | ||
34 | hash = (slb->esid >> SID_SHIFT_1T) & mask; | ||
35 | else /* 256M */ | ||
36 | hash = (slb->esid >> SID_SHIFT) & mask; | ||
29 | 37 | ||
30 | for (entry = 0; entry < 8; entry++) { | 38 | primary = ctx->sstp + (hash << 3); |
31 | sste = group + entry; | 39 | |
40 | for (entry = 0, sste = primary; entry < 8; entry++, sste++) { | ||
32 | if (!(be64_to_cpu(sste->esid_data) & SLB_ESID_V)) | 41 | if (!(be64_to_cpu(sste->esid_data) & SLB_ESID_V)) |
33 | return sste; | 42 | return sste; |
34 | } | 43 | } |
44 | |||
35 | /* Nothing free, select an entry to cast out */ | 45 | /* Nothing free, select an entry to cast out */ |
36 | sste = primary_group + *lru; | 46 | sste = primary + ctx->sst_lru; |
37 | *lru = (*lru + 1) & 0x7; | 47 | ctx->sst_lru = (ctx->sst_lru + 1) & 0x7; |
38 | 48 | ||
39 | return sste; | 49 | return sste; |
40 | } | 50 | } |
@@ -42,19 +52,11 @@ static struct cxl_sste* find_free_sste(struct cxl_sste *primary_group, | |||
42 | static void cxl_load_segment(struct cxl_context *ctx, struct copro_slb *slb) | 52 | static void cxl_load_segment(struct cxl_context *ctx, struct copro_slb *slb) |
43 | { | 53 | { |
44 | /* mask is the group index, we search primary and secondary here. */ | 54 | /* mask is the group index, we search primary and secondary here. */ |
45 | unsigned int mask = (ctx->sst_size >> 7)-1; /* SSTP0[SegTableSize] */ | ||
46 | struct cxl_sste *sste; | 55 | struct cxl_sste *sste; |
47 | unsigned int hash; | ||
48 | unsigned long flags; | 56 | unsigned long flags; |
49 | 57 | ||
50 | |||
51 | if (slb->vsid & SLB_VSID_B_1T) | ||
52 | hash = (slb->esid >> SID_SHIFT_1T) & mask; | ||
53 | else /* 256M */ | ||
54 | hash = (slb->esid >> SID_SHIFT) & mask; | ||
55 | |||
56 | spin_lock_irqsave(&ctx->sste_lock, flags); | 58 | spin_lock_irqsave(&ctx->sste_lock, flags); |
57 | sste = find_free_sste(ctx->sstp + (hash << 3), &ctx->sst_lru); | 59 | sste = find_free_sste(ctx, slb); |
58 | 60 | ||
59 | pr_devel("CXL Populating SST[%li]: %#llx %#llx\n", | 61 | pr_devel("CXL Populating SST[%li]: %#llx %#llx\n", |
60 | sste - ctx->sstp, slb->vsid, slb->esid); | 62 | sste - ctx->sstp, slb->vsid, slb->esid); |