Skip to content

Commit eb01d4c

Browse files
Ian Munsiempe
authored andcommitted
cxl: Fix PSL error due to duplicate segment table entries
In certain circumstances the PSL (Power Service Layer, which provides translation services for CXL hardware) can send an interrupt for a segment miss that the kernel has already handled. This can happen if multiple translations for the same segment are queued in the PSL before the kernel has restarted the first translation. The CXL driver does not expect this situation and does not check if a segment had already been handled. This could cause a duplicate segment table entry which in turn caused a PSL error taking down the card. This patch fixes the issue by checking for existing entries in the segment table that match the segment we are trying to insert, so as to avoid inserting duplicate entries. Signed-off-by: Ian Munsie <[email protected]> Reviewed-by: Aneesh Kumar K.V <[email protected]> Signed-off-by: Michael Ellerman <[email protected]>
1 parent 03f5439 commit eb01d4c

File tree

1 file changed

+22
-6
lines changed

1 file changed

+22
-6
lines changed

drivers/misc/cxl/fault.c

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,20 @@
2121

2222
#include "cxl.h"
2323

24-
/* This finds a free SSTE for the given SLB */
24+
static bool sste_matches(struct cxl_sste *sste, struct copro_slb *slb)
25+
{
26+
return ((sste->vsid_data == cpu_to_be64(slb->vsid)) &&
27+
(sste->esid_data == cpu_to_be64(slb->esid)));
28+
}
29+
30+
/*
31+
* This finds a free SSTE for the given SLB, or returns NULL if it's already in
32+
* the segment table.
33+
*/
2534
static struct cxl_sste* find_free_sste(struct cxl_context *ctx,
2635
struct copro_slb *slb)
2736
{
28-
struct cxl_sste *primary, *sste;
37+
struct cxl_sste *primary, *sste, *ret = NULL;
2938
unsigned int mask = (ctx->sst_size >> 7) - 1; /* SSTP0[SegTableSize] */
3039
unsigned int entry;
3140
unsigned int hash;
@@ -38,15 +47,19 @@ static struct cxl_sste* find_free_sste(struct cxl_context *ctx,
3847
primary = ctx->sstp + (hash << 3);
3948

4049
for (entry = 0, sste = primary; entry < 8; entry++, sste++) {
41-
if (!(be64_to_cpu(sste->esid_data) & SLB_ESID_V))
42-
return sste;
50+
if (!ret && !(be64_to_cpu(sste->esid_data) & SLB_ESID_V))
51+
ret = sste;
52+
if (sste_matches(sste, slb))
53+
return NULL;
4354
}
55+
if (ret)
56+
return ret;
4457

4558
/* Nothing free, select an entry to cast out */
46-
sste = primary + ctx->sst_lru;
59+
ret = primary + ctx->sst_lru;
4760
ctx->sst_lru = (ctx->sst_lru + 1) & 0x7;
4861

49-
return sste;
62+
return ret;
5063
}
5164

5265
static void cxl_load_segment(struct cxl_context *ctx, struct copro_slb *slb)
@@ -57,12 +70,15 @@ static void cxl_load_segment(struct cxl_context *ctx, struct copro_slb *slb)
5770

5871
spin_lock_irqsave(&ctx->sste_lock, flags);
5972
sste = find_free_sste(ctx, slb);
73+
if (!sste)
74+
goto out_unlock;
6075

6176
pr_devel("CXL Populating SST[%li]: %#llx %#llx\n",
6277
sste - ctx->sstp, slb->vsid, slb->esid);
6378

6479
sste->vsid_data = cpu_to_be64(slb->vsid);
6580
sste->esid_data = cpu_to_be64(slb->esid);
81+
out_unlock:
6682
spin_unlock_irqrestore(&ctx->sste_lock, flags);
6783
}
6884

0 commit comments

Comments
 (0)