Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

powerpc/xive: introduce H_INT_ESB hcall

The H_INT_ESB hcall() is used to issue a load or store to the ESB page
instead of using the MMIO pages. This can be used as a workaround on
some HW issues. The OS knows that this hcall should be used on an
interrupt source when the ESB hcall flag is set to 1 in the hcall
H_INT_GET_SOURCE_INFO.

To maintain the frontier between the xive frontend and backend, we
introduce a new xive operation 'esb_rw' to be used in the routines
doing memory accesses on the ESBs.

Signed-off-by: Cédric Le Goater <clg@kaod.org>
Acked-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>

authored by

Cédric Le Goater and committed by
Michael Ellerman
bed81ee1 c58a14a9

+53 -3
+1
arch/powerpc/include/asm/xive.h
··· 56 56 #define XIVE_IRQ_FLAG_SHIFT_BUG 0x04 57 57 #define XIVE_IRQ_FLAG_MASK_FW 0x08 58 58 #define XIVE_IRQ_FLAG_EOI_FW 0x10 59 + #define XIVE_IRQ_FLAG_H_INT_ESB 0x20 59 60 60 61 #define XIVE_INVALID_CHIP_ID -1 61 62
+8 -2
arch/powerpc/sysdev/xive/common.c
··· 198 198 if (xd->flags & XIVE_IRQ_FLAG_SHIFT_BUG) 199 199 offset |= offset << 4; 200 200 201 - val = in_be64(xd->eoi_mmio + offset); 201 + if ((xd->flags & XIVE_IRQ_FLAG_H_INT_ESB) && xive_ops->esb_rw) 202 + val = xive_ops->esb_rw(xd->hw_irq, offset, 0, 0); 203 + else 204 + val = in_be64(xd->eoi_mmio + offset); 202 205 203 206 return (u8)val; 204 207 } ··· 212 209 if (xd->flags & XIVE_IRQ_FLAG_SHIFT_BUG) 213 210 offset |= offset << 4; 214 211 215 - out_be64(xd->eoi_mmio + offset, data); 212 + if ((xd->flags & XIVE_IRQ_FLAG_H_INT_ESB) && xive_ops->esb_rw) 213 + xive_ops->esb_rw(xd->hw_irq, offset, data, 1); 214 + else 215 + out_be64(xd->eoi_mmio + offset, data); 216 216 } 217 217 218 218 #ifdef CONFIG_XMON
+43 -1
arch/powerpc/sysdev/xive/spapr.c
··· 224 224 return 0; 225 225 } 226 226 227 - #define XIVE_SRC_H_INT_ESB (1ull << (63 - 60)) /* TODO */ 227 + #define XIVE_ESB_FLAG_STORE (1ull << (63 - 63)) 228 + 229 + static long plpar_int_esb(unsigned long flags, 230 + unsigned long lisn, 231 + unsigned long offset, 232 + unsigned long in_data, 233 + unsigned long *out_data) 234 + { 235 + unsigned long retbuf[PLPAR_HCALL_BUFSIZE]; 236 + long rc; 237 + 238 + pr_devel("H_INT_ESB flags=%lx lisn=%lx offset=%lx in=%lx\n", 239 + flags, lisn, offset, in_data); 240 + 241 + rc = plpar_hcall(H_INT_ESB, retbuf, flags, lisn, offset, in_data); 242 + if (rc) { 243 + pr_err("H_INT_ESB lisn=%ld offset=%ld returned %ld\n", 244 + lisn, offset, rc); 245 + return rc; 246 + } 247 + 248 + *out_data = retbuf[0]; 249 + 250 + return 0; 251 + } 252 + 253 + static u64 xive_spapr_esb_rw(u32 lisn, u32 offset, u64 data, bool write) 254 + { 255 + unsigned long read_data; 256 + long rc; 257 + 258 + rc = plpar_int_esb(write ? XIVE_ESB_FLAG_STORE : 0, 259 + lisn, offset, data, &read_data); 260 + if (rc) 261 + return -1; 262 + 263 + return write ? 0 : read_data; 264 + } 265 + 266 + #define XIVE_SRC_H_INT_ESB (1ull << (63 - 60)) 228 267 #define XIVE_SRC_LSI (1ull << (63 - 61)) 229 268 #define XIVE_SRC_TRIGGER (1ull << (63 - 62)) 230 269 #define XIVE_SRC_STORE_EOI (1ull << (63 - 63)) ··· 283 244 if (rc) 284 245 return -EINVAL; 285 246 247 + if (flags & XIVE_SRC_H_INT_ESB) 248 + data->flags |= XIVE_IRQ_FLAG_H_INT_ESB; 286 249 if (flags & XIVE_SRC_STORE_EOI) 287 250 data->flags |= XIVE_IRQ_FLAG_STORE_EOI; 288 251 if (flags & XIVE_SRC_LSI) ··· 528 487 .setup_cpu = xive_spapr_setup_cpu, 529 488 .teardown_cpu = xive_spapr_teardown_cpu, 530 489 .sync_source = xive_spapr_sync_source, 490 + .esb_rw = xive_spapr_esb_rw, 531 491 #ifdef CONFIG_SMP 532 492 .get_ipi = xive_spapr_get_ipi, 533 493 .put_ipi = xive_spapr_put_ipi,
+1
arch/powerpc/sysdev/xive/xive-internal.h
··· 47 47 void (*update_pending)(struct xive_cpu *xc); 48 48 void (*eoi)(u32 hw_irq); 49 49 void (*sync_source)(u32 hw_irq); 50 + u64 (*esb_rw)(u32 hw_irq, u32 offset, u64 data, bool write); 50 51 #ifdef CONFIG_SMP 51 52 int (*get_ipi)(unsigned int cpu, struct xive_cpu *xc); 52 53 void (*put_ipi)(unsigned int cpu, struct xive_cpu *xc);