Skip to content

Commit 797625d

Browse files
Christophe Lombardmpe
authored andcommitted
cxl: Fixes for Coherent Accelerator Interface Architecture 2.0
A previous set of patches "cxl: Add support for Coherent Accelerator Interface Architecture 2.0" has introduced a new support for the CAPI cards. These patches have been tested on Simulation environment and quite a bit of them have been tested on real hardware. This patch brings new fixes after a series of tests carried out on new equipment: - Add POWER9 definition. - Re-enable any masked interrupts when the AFU is not activated after resetting the AFU. - Remove the api cxl_is_psl8/9 which is no longer useful. - Do not dump CAPI1 registers. - Rewrite cxl_is_page_fault() function. - Do not register slb callack on P9. Fixes: f24be42 ("cxl: Add psl9 specific code") Signed-off-by: Christophe Lombard <[email protected]> Acked-by: Frederic Barrat <[email protected]> Signed-off-by: Michael Ellerman <[email protected]>
1 parent 34f19ff commit 797625d

File tree

6 files changed

+57
-47
lines changed

6 files changed

+57
-47
lines changed

drivers/misc/cxl/context.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ int cxl_context_init(struct cxl_context *ctx, struct cxl_afu *afu, bool master)
4545
mutex_init(&ctx->mapping_lock);
4646
ctx->mapping = NULL;
4747

48-
if (cxl_is_psl8(afu)) {
48+
if (cxl_is_power8()) {
4949
spin_lock_init(&ctx->sste_lock);
5050

5151
/*
@@ -189,7 +189,7 @@ int cxl_context_iomap(struct cxl_context *ctx, struct vm_area_struct *vma)
189189
if (start + len > ctx->afu->adapter->ps_size)
190190
return -EINVAL;
191191

192-
if (cxl_is_psl9(ctx->afu)) {
192+
if (cxl_is_power9()) {
193193
/*
194194
* Make sure there is a valid problem state
195195
* area space for this AFU.
@@ -324,7 +324,7 @@ static void reclaim_ctx(struct rcu_head *rcu)
324324
{
325325
struct cxl_context *ctx = container_of(rcu, struct cxl_context, rcu);
326326

327-
if (cxl_is_psl8(ctx->afu))
327+
if (cxl_is_power8())
328328
free_page((u64)ctx->sstp);
329329
if (ctx->ff_page)
330330
__free_page(ctx->ff_page);

drivers/misc/cxl/cxl.h

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,7 @@ static const cxl_p2n_reg_t CXL_PSL_WED_An = {0x0A0};
357357
#define CXL_PSL9_DSISR_An_PF_RGP 0x0000000000000090ULL /* PTE not found (Radix Guest (parent)) 0b10010000 */
358358
#define CXL_PSL9_DSISR_An_PF_HRH 0x0000000000000094ULL /* PTE not found (HPT/Radix Host) 0b10010100 */
359359
#define CXL_PSL9_DSISR_An_PF_STEG 0x000000000000009CULL /* PTE not found (STEG VA) 0b10011100 */
360+
#define CXL_PSL9_DSISR_An_URTCH 0x00000000000000B4ULL /* Unsupported Radix Tree Configuration 0b10110100 */
360361

361362
/****** CXL_PSL_TFC_An ******************************************************/
362363
#define CXL_PSL_TFC_An_A (1ull << (63-28)) /* Acknowledge non-translation fault */
@@ -844,24 +845,15 @@ static inline bool cxl_is_power8(void)
844845

845846
static inline bool cxl_is_power9(void)
846847
{
847-
/* intermediate solution */
848-
if (!cxl_is_power8() &&
849-
(cpu_has_feature(CPU_FTRS_POWER9) ||
850-
cpu_has_feature(CPU_FTR_POWER9_DD1)))
848+
if (pvr_version_is(PVR_POWER9))
851849
return true;
852850
return false;
853851
}
854852

855-
static inline bool cxl_is_psl8(struct cxl_afu *afu)
853+
static inline bool cxl_is_power9_dd1(void)
856854
{
857-
if (afu->adapter->caia_major == 1)
858-
return true;
859-
return false;
860-
}
861-
862-
static inline bool cxl_is_psl9(struct cxl_afu *afu)
863-
{
864-
if (afu->adapter->caia_major == 2)
855+
if ((pvr_version_is(PVR_POWER9)) &&
856+
cpu_has_feature(CPU_FTR_POWER9_DD1))
865857
return true;
866858
return false;
867859
}

drivers/misc/cxl/fault.c

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -187,24 +187,31 @@ static struct mm_struct *get_mem_context(struct cxl_context *ctx)
187187

188188
static bool cxl_is_segment_miss(struct cxl_context *ctx, u64 dsisr)
189189
{
190-
if ((cxl_is_psl8(ctx->afu)) && (dsisr & CXL_PSL_DSISR_An_DS))
190+
if ((cxl_is_power8() && (dsisr & CXL_PSL_DSISR_An_DS)))
191191
return true;
192192

193193
return false;
194194
}
195195

196196
static bool cxl_is_page_fault(struct cxl_context *ctx, u64 dsisr)
197197
{
198-
if ((cxl_is_psl8(ctx->afu)) && (dsisr & CXL_PSL_DSISR_An_DM))
199-
return true;
198+
u64 crs; /* Translation Checkout Response Status */
200199

201-
if ((cxl_is_psl9(ctx->afu)) &&
202-
((dsisr & CXL_PSL9_DSISR_An_CO_MASK) &
203-
(CXL_PSL9_DSISR_An_PF_SLR | CXL_PSL9_DSISR_An_PF_RGC |
204-
CXL_PSL9_DSISR_An_PF_RGP | CXL_PSL9_DSISR_An_PF_HRH |
205-
CXL_PSL9_DSISR_An_PF_STEG)))
200+
if ((cxl_is_power8()) && (dsisr & CXL_PSL_DSISR_An_DM))
206201
return true;
207202

203+
if (cxl_is_power9()) {
204+
crs = (dsisr & CXL_PSL9_DSISR_An_CO_MASK);
205+
if ((crs == CXL_PSL9_DSISR_An_PF_SLR) ||
206+
(crs == CXL_PSL9_DSISR_An_PF_RGC) ||
207+
(crs == CXL_PSL9_DSISR_An_PF_RGP) ||
208+
(crs == CXL_PSL9_DSISR_An_PF_HRH) ||
209+
(crs == CXL_PSL9_DSISR_An_PF_STEG) ||
210+
(crs == CXL_PSL9_DSISR_An_URTCH)) {
211+
return true;
212+
}
213+
}
214+
208215
return false;
209216
}
210217

drivers/misc/cxl/main.c

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -329,8 +329,15 @@ static int __init init_cxl(void)
329329

330330
cxl_debugfs_init();
331331

332-
if ((rc = register_cxl_calls(&cxl_calls)))
333-
goto err;
332+
/*
333+
* we don't register the callback on P9. slb callack is only
334+
* used for the PSL8 MMU and CX4.
335+
*/
336+
if (cxl_is_power8()) {
337+
rc = register_cxl_calls(&cxl_calls);
338+
if (rc)
339+
goto err;
340+
}
334341

335342
if (cpu_has_feature(CPU_FTR_HVMODE)) {
336343
cxl_ops = &cxl_native_ops;
@@ -347,7 +354,8 @@ static int __init init_cxl(void)
347354

348355
return 0;
349356
err1:
350-
unregister_cxl_calls(&cxl_calls);
357+
if (cxl_is_power8())
358+
unregister_cxl_calls(&cxl_calls);
351359
err:
352360
cxl_debugfs_exit();
353361
cxl_file_exit();
@@ -366,7 +374,8 @@ static void exit_cxl(void)
366374

367375
cxl_debugfs_exit();
368376
cxl_file_exit();
369-
unregister_cxl_calls(&cxl_calls);
377+
if (cxl_is_power8())
378+
unregister_cxl_calls(&cxl_calls);
370379
idr_destroy(&cxl_adapter_idr);
371380
}
372381

drivers/misc/cxl/native.c

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -105,11 +105,16 @@ static int native_afu_reset(struct cxl_afu *afu)
105105
CXL_AFU_Cntl_An_RS_MASK | CXL_AFU_Cntl_An_ES_MASK,
106106
false);
107107

108-
/* Re-enable any masked interrupts */
109-
serr = cxl_p1n_read(afu, CXL_PSL_SERR_An);
110-
serr &= ~CXL_PSL_SERR_An_IRQ_MASKS;
111-
cxl_p1n_write(afu, CXL_PSL_SERR_An, serr);
112-
108+
/*
109+
* Re-enable any masked interrupts when the AFU is not
110+
* activated to avoid side effects after attaching a process
111+
* in dedicated mode.
112+
*/
113+
if (afu->current_mode == 0) {
114+
serr = cxl_p1n_read(afu, CXL_PSL_SERR_An);
115+
serr &= ~CXL_PSL_SERR_An_IRQ_MASKS;
116+
cxl_p1n_write(afu, CXL_PSL_SERR_An, serr);
117+
}
113118

114119
return rc;
115120
}
@@ -139,9 +144,9 @@ int cxl_psl_purge(struct cxl_afu *afu)
139144

140145
pr_devel("PSL purge request\n");
141146

142-
if (cxl_is_psl8(afu))
147+
if (cxl_is_power8())
143148
trans_fault = CXL_PSL_DSISR_TRANS;
144-
if (cxl_is_psl9(afu))
149+
if (cxl_is_power9())
145150
trans_fault = CXL_PSL9_DSISR_An_TF;
146151

147152
if (!cxl_ops->link_ok(afu->adapter, afu)) {
@@ -603,7 +608,7 @@ static u64 calculate_sr(struct cxl_context *ctx)
603608
if (!test_tsk_thread_flag(current, TIF_32BIT))
604609
sr |= CXL_PSL_SR_An_SF;
605610
}
606-
if (cxl_is_psl9(ctx->afu)) {
611+
if (cxl_is_power9()) {
607612
if (radix_enabled())
608613
sr |= CXL_PSL_SR_An_XLAT_ror;
609614
else
@@ -1117,10 +1122,10 @@ static irqreturn_t native_handle_psl_slice_error(struct cxl_context *ctx,
11171122

11181123
static bool cxl_is_translation_fault(struct cxl_afu *afu, u64 dsisr)
11191124
{
1120-
if ((cxl_is_psl8(afu)) && (dsisr & CXL_PSL_DSISR_TRANS))
1125+
if ((cxl_is_power8()) && (dsisr & CXL_PSL_DSISR_TRANS))
11211126
return true;
11221127

1123-
if ((cxl_is_psl9(afu)) && (dsisr & CXL_PSL9_DSISR_An_TF))
1128+
if ((cxl_is_power9()) && (dsisr & CXL_PSL9_DSISR_An_TF))
11241129
return true;
11251130

11261131
return false;
@@ -1194,10 +1199,10 @@ static void native_irq_wait(struct cxl_context *ctx)
11941199
if (ph != ctx->pe)
11951200
return;
11961201
dsisr = cxl_p2n_read(ctx->afu, CXL_PSL_DSISR_An);
1197-
if (cxl_is_psl8(ctx->afu) &&
1202+
if (cxl_is_power8() &&
11981203
((dsisr & CXL_PSL_DSISR_PENDING) == 0))
11991204
return;
1200-
if (cxl_is_psl9(ctx->afu) &&
1205+
if (cxl_is_power9() &&
12011206
((dsisr & CXL_PSL9_DSISR_PENDING) == 0))
12021207
return;
12031208
/*

drivers/misc/cxl/pci.c

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,7 @@ static int init_implementation_adapter_regs_psl9(struct cxl *adapter, struct pci
436436
/* nMMU_ID Defaults to: b’000001001’*/
437437
xsl_dsnctl |= ((u64)0x09 << (63-28));
438438

439-
if (cxl_is_power9() && !cpu_has_feature(CPU_FTR_POWER9_DD1)) {
439+
if (!(cxl_is_power9_dd1())) {
440440
/*
441441
* Used to identify CAPI packets which should be sorted into
442442
* the Non-Blocking queues by the PHB. This field should match
@@ -491,7 +491,7 @@ static int init_implementation_adapter_regs_psl9(struct cxl *adapter, struct pci
491491
cxl_p1_write(adapter, CXL_PSL9_APCDEDTYPE, 0x40000003FFFF0000ULL);
492492

493493
/* Disable vc dd1 fix */
494-
if ((cxl_is_power9() && cpu_has_feature(CPU_FTR_POWER9_DD1)))
494+
if (cxl_is_power9_dd1())
495495
cxl_p1_write(adapter, CXL_PSL9_GP_CT, 0x0400000000000001ULL);
496496

497497
return 0;
@@ -1439,8 +1439,7 @@ int cxl_pci_reset(struct cxl *adapter)
14391439
* The adapter is about to be reset, so ignore errors.
14401440
* Not supported on P9 DD1
14411441
*/
1442-
if ((cxl_is_power8()) ||
1443-
((cxl_is_power9() && !cpu_has_feature(CPU_FTR_POWER9_DD1))))
1442+
if ((cxl_is_power8()) || (!(cxl_is_power9_dd1())))
14441443
cxl_data_cache_flush(adapter);
14451444

14461445
/* pcie_warm_reset requests a fundamental pci reset which includes a
@@ -1750,7 +1749,6 @@ static const struct cxl_service_layer_ops psl9_ops = {
17501749
.debugfs_add_adapter_regs = cxl_debugfs_add_adapter_regs_psl9,
17511750
.debugfs_add_afu_regs = cxl_debugfs_add_afu_regs_psl9,
17521751
.psl_irq_dump_registers = cxl_native_irq_dump_regs_psl9,
1753-
.err_irq_dump_registers = cxl_native_err_irq_dump_regs,
17541752
.debugfs_stop_trace = cxl_stop_trace_psl9,
17551753
.write_timebase_ctrl = write_timebase_ctrl_psl9,
17561754
.timebase_read = timebase_read_psl9,
@@ -1889,8 +1887,7 @@ static void cxl_pci_remove_adapter(struct cxl *adapter)
18891887
* Flush adapter datacache as its about to be removed.
18901888
* Not supported on P9 DD1.
18911889
*/
1892-
if ((cxl_is_power8()) ||
1893-
((cxl_is_power9() && !cpu_has_feature(CPU_FTR_POWER9_DD1))))
1890+
if ((cxl_is_power8()) || (!(cxl_is_power9_dd1())))
18941891
cxl_data_cache_flush(adapter);
18951892

18961893
cxl_deconfigure_adapter(adapter);

0 commit comments

Comments
 (0)