Skip to content

Commit 1b46bac

Browse files
committed
Merge tag 'powerpc-4.6-4' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux
Pull powerpc fixes from Michael Ellerman: "A few more powerpc fixes for 4.6: - cxl: Keep IRQ mappings on context teardown from Michael Neuling - cxl: Poll for outstanding IRQs when detaching a context from Michael Neuling - Wire up preadv2 and pwritev2 syscalls from Rui Salvaterra" * tag 'powerpc-4.6-4' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux: powerpc: wire up preadv2 and pwritev2 syscalls cxl: Poll for outstanding IRQs when detaching a context cxl: Keep IRQ mappings on context teardown
2 parents 65c4cbe + d701cca commit 1b46bac

File tree

7 files changed

+45
-2
lines changed

7 files changed

+45
-2
lines changed

arch/powerpc/include/asm/systbl.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -384,3 +384,5 @@ SYSCALL(ni_syscall)
384384
SYSCALL(ni_syscall)
385385
SYSCALL(mlock2)
386386
SYSCALL(copy_file_range)
387+
COMPAT_SYS_SPU(preadv2)
388+
COMPAT_SYS_SPU(pwritev2)

arch/powerpc/include/asm/unistd.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
#include <uapi/asm/unistd.h>
1313

1414

15-
#define NR_syscalls 380
15+
#define NR_syscalls 382
1616

1717
#define __NR__exit __NR_exit
1818

arch/powerpc/include/uapi/asm/unistd.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,5 +390,7 @@
390390
#define __NR_membarrier 365
391391
#define __NR_mlock2 378
392392
#define __NR_copy_file_range 379
393+
#define __NR_preadv2 380
394+
#define __NR_pwritev2 381
393395

394396
#endif /* _UAPI_ASM_POWERPC_UNISTD_H_ */

drivers/misc/cxl/context.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,13 @@ int __detach_context(struct cxl_context *ctx)
223223
cxl_ops->link_ok(ctx->afu->adapter, ctx->afu));
224224
flush_work(&ctx->fault_work); /* Only needed for dedicated process */
225225

226+
/*
227+
* Wait until no further interrupts are presented by the PSL
228+
* for this context.
229+
*/
230+
if (cxl_ops->irq_wait)
231+
cxl_ops->irq_wait(ctx);
232+
226233
/* release the reference to the group leader and mm handling pid */
227234
put_pid(ctx->pid);
228235
put_pid(ctx->glpid);

drivers/misc/cxl/cxl.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,7 @@ static const cxl_p2n_reg_t CXL_PSL_WED_An = {0x0A0};
274274
#define CXL_PSL_DSISR_An_PE (1ull << (63-4)) /* PSL Error (implementation specific) */
275275
#define CXL_PSL_DSISR_An_AE (1ull << (63-5)) /* AFU Error */
276276
#define CXL_PSL_DSISR_An_OC (1ull << (63-6)) /* OS Context Warning */
277+
#define CXL_PSL_DSISR_PENDING (CXL_PSL_DSISR_TRANS | CXL_PSL_DSISR_An_PE | CXL_PSL_DSISR_An_AE | CXL_PSL_DSISR_An_OC)
277278
/* NOTE: Bits 32:63 are undefined if DSISR[DS] = 1 */
278279
#define CXL_PSL_DSISR_An_M DSISR_NOHPTE /* PTE not found */
279280
#define CXL_PSL_DSISR_An_P DSISR_PROTFAULT /* Storage protection violation */
@@ -855,6 +856,7 @@ struct cxl_backend_ops {
855856
u64 dsisr, u64 errstat);
856857
irqreturn_t (*psl_interrupt)(int irq, void *data);
857858
int (*ack_irq)(struct cxl_context *ctx, u64 tfc, u64 psl_reset_mask);
859+
void (*irq_wait)(struct cxl_context *ctx);
858860
int (*attach_process)(struct cxl_context *ctx, bool kernel,
859861
u64 wed, u64 amr);
860862
int (*detach_process)(struct cxl_context *ctx);

drivers/misc/cxl/irq.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,6 @@ unsigned int cxl_map_irq(struct cxl *adapter, irq_hw_number_t hwirq,
203203
void cxl_unmap_irq(unsigned int virq, void *cookie)
204204
{
205205
free_irq(virq, cookie);
206-
irq_dispose_mapping(virq);
207206
}
208207

209208
int cxl_register_one_irq(struct cxl *adapter,

drivers/misc/cxl/native.c

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include <linux/mutex.h>
1515
#include <linux/mm.h>
1616
#include <linux/uaccess.h>
17+
#include <linux/delay.h>
1718
#include <asm/synch.h>
1819
#include <misc/cxl-base.h>
1920

@@ -797,6 +798,35 @@ static irqreturn_t native_irq_multiplexed(int irq, void *data)
797798
return fail_psl_irq(afu, &irq_info);
798799
}
799800

801+
void native_irq_wait(struct cxl_context *ctx)
802+
{
803+
u64 dsisr;
804+
int timeout = 1000;
805+
int ph;
806+
807+
/*
808+
* Wait until no further interrupts are presented by the PSL
809+
* for this context.
810+
*/
811+
while (timeout--) {
812+
ph = cxl_p2n_read(ctx->afu, CXL_PSL_PEHandle_An) & 0xffff;
813+
if (ph != ctx->pe)
814+
return;
815+
dsisr = cxl_p2n_read(ctx->afu, CXL_PSL_DSISR_An);
816+
if ((dsisr & CXL_PSL_DSISR_PENDING) == 0)
817+
return;
818+
/*
819+
* We are waiting for the workqueue to process our
820+
* irq, so need to let that run here.
821+
*/
822+
msleep(1);
823+
}
824+
825+
dev_warn(&ctx->afu->dev, "WARNING: waiting on DSI for PE %i"
826+
" DSISR %016llx!\n", ph, dsisr);
827+
return;
828+
}
829+
800830
static irqreturn_t native_slice_irq_err(int irq, void *data)
801831
{
802832
struct cxl_afu *afu = data;
@@ -1076,6 +1106,7 @@ const struct cxl_backend_ops cxl_native_ops = {
10761106
.handle_psl_slice_error = native_handle_psl_slice_error,
10771107
.psl_interrupt = NULL,
10781108
.ack_irq = native_ack_irq,
1109+
.irq_wait = native_irq_wait,
10791110
.attach_process = native_attach_process,
10801111
.detach_process = native_detach_process,
10811112
.support_attributes = native_support_attributes,

0 commit comments

Comments
 (0)