Skip to content

Commit b4868ff

Browse files
legoatermpe
authored andcommitted
powerpc/xive: Fix dump of XIVE interrupt under pseries
The xmon 'dxi' command calls OPAL to query the XIVE configuration of a interrupt. This can only be done on baremetal (PowerNV) and it will crash a pseries machine. Introduce a new XIVE get_irq_config() operation which implements a different query depending on the platform, PowerNV or pseries, and modify xmon to use a top level wrapper. Signed-off-by: Cédric Le Goater <clg@kaod.org> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au> Link: https://lore.kernel.org/r/20190814154754.23682-3-clg@kaod.org
1 parent c3e0dbd commit b4868ff

6 files changed

Lines changed: 83 additions & 6 deletions

File tree

‎arch/powerpc/include/asm/xive.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,8 @@ extern void xive_flush_interrupt(void);
9999

100100
/* xmon hook */
101101
extern void xmon_xive_do_dump(int cpu);
102+
extern int xmon_xive_get_irq_config(u32 irq, u32 *target, u8 *prio,
103+
u32 *sw_irq);
102104

103105
/* APIs used by KVM */
104106
extern u32 xive_native_default_eq_shift(void);

‎arch/powerpc/sysdev/xive/common.c‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,13 @@ notrace void xmon_xive_do_dump(int cpu)
257257
}
258258
#endif
259259
}
260+
261+
int xmon_xive_get_irq_config(u32 irq, u32 *target, u8 *prio,
262+
u32 *sw_irq)
263+
{
264+
return xive_ops->get_irq_config(irq, target, prio, sw_irq);
265+
}
266+
260267
#endif /* CONFIG_XMON */
261268

262269
static unsigned int xive_get_irq(void)

‎arch/powerpc/sysdev/xive/native.c‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,20 @@ int xive_native_configure_irq(u32 hw_irq, u32 target, u8 prio, u32 sw_irq)
111111
}
112112
EXPORT_SYMBOL_GPL(xive_native_configure_irq);
113113

114+
static int xive_native_get_irq_config(u32 hw_irq, u32 *target, u8 *prio,
115+
u32 *sw_irq)
116+
{
117+
s64 rc;
118+
__be64 vp;
119+
__be32 lirq;
120+
121+
rc = opal_xive_get_irq_config(hw_irq, &vp, prio, &lirq);
122+
123+
*target = be64_to_cpu(vp);
124+
*sw_irq = be32_to_cpu(lirq);
125+
126+
return rc == 0 ? 0 : -ENXIO;
127+
}
114128

115129
/* This can be called multiple time to change a queue configuration */
116130
int xive_native_configure_queue(u32 vp_id, struct xive_q *q, u8 prio,
@@ -442,6 +456,7 @@ EXPORT_SYMBOL_GPL(xive_native_sync_queue);
442456
static const struct xive_ops xive_native_ops = {
443457
.populate_irq_data = xive_native_populate_irq_data,
444458
.configure_irq = xive_native_configure_irq,
459+
.get_irq_config = xive_native_get_irq_config,
445460
.setup_queue = xive_native_setup_queue,
446461
.cleanup_queue = xive_native_cleanup_queue,
447462
.match = xive_native_match,

‎arch/powerpc/sysdev/xive/spapr.c‎

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,38 @@ static long plpar_int_set_source_config(unsigned long flags,
215215
return 0;
216216
}
217217

218+
static long plpar_int_get_source_config(unsigned long flags,
219+
unsigned long lisn,
220+
unsigned long *target,
221+
unsigned long *prio,
222+
unsigned long *sw_irq)
223+
{
224+
unsigned long retbuf[PLPAR_HCALL_BUFSIZE];
225+
long rc;
226+
227+
pr_devel("H_INT_GET_SOURCE_CONFIG flags=%lx lisn=%lx\n", flags, lisn);
228+
229+
do {
230+
rc = plpar_hcall(H_INT_GET_SOURCE_CONFIG, retbuf, flags, lisn,
231+
target, prio, sw_irq);
232+
} while (plpar_busy_delay(rc));
233+
234+
if (rc) {
235+
pr_err("H_INT_GET_SOURCE_CONFIG lisn=%ld failed %ld\n",
236+
lisn, rc);
237+
return rc;
238+
}
239+
240+
*target = retbuf[0];
241+
*prio = retbuf[1];
242+
*sw_irq = retbuf[2];
243+
244+
pr_devel("H_INT_GET_SOURCE_CONFIG target=%lx prio=%lx sw_irq=%lx\n",
245+
retbuf[0], retbuf[1], retbuf[2]);
246+
247+
return 0;
248+
}
249+
218250
static long plpar_int_get_queue_info(unsigned long flags,
219251
unsigned long target,
220252
unsigned long priority,
@@ -398,6 +430,24 @@ static int xive_spapr_configure_irq(u32 hw_irq, u32 target, u8 prio, u32 sw_irq)
398430
return rc == 0 ? 0 : -ENXIO;
399431
}
400432

433+
static int xive_spapr_get_irq_config(u32 hw_irq, u32 *target, u8 *prio,
434+
u32 *sw_irq)
435+
{
436+
long rc;
437+
unsigned long h_target;
438+
unsigned long h_prio;
439+
unsigned long h_sw_irq;
440+
441+
rc = plpar_int_get_source_config(0, hw_irq, &h_target, &h_prio,
442+
&h_sw_irq);
443+
444+
*target = h_target;
445+
*prio = h_prio;
446+
*sw_irq = h_sw_irq;
447+
448+
return rc == 0 ? 0 : -ENXIO;
449+
}
450+
401451
/* This can be called multiple time to change a queue configuration */
402452
static int xive_spapr_configure_queue(u32 target, struct xive_q *q, u8 prio,
403453
__be32 *qpage, u32 order)
@@ -590,6 +640,7 @@ static void xive_spapr_sync_source(u32 hw_irq)
590640
static const struct xive_ops xive_spapr_ops = {
591641
.populate_irq_data = xive_spapr_populate_irq_data,
592642
.configure_irq = xive_spapr_configure_irq,
643+
.get_irq_config = xive_spapr_get_irq_config,
593644
.setup_queue = xive_spapr_setup_queue,
594645
.cleanup_queue = xive_spapr_cleanup_queue,
595646
.match = xive_spapr_match,

‎arch/powerpc/sysdev/xive/xive-internal.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ struct xive_cpu {
3333
struct xive_ops {
3434
int (*populate_irq_data)(u32 hw_irq, struct xive_irq_data *data);
3535
int (*configure_irq)(u32 hw_irq, u32 target, u8 prio, u32 sw_irq);
36+
int (*get_irq_config)(u32 hw_irq, u32 *target, u8 *prio,
37+
u32 *sw_irq);
3638
int (*setup_queue)(unsigned int cpu, struct xive_cpu *xc, u8 prio);
3739
void (*cleanup_queue)(unsigned int cpu, struct xive_cpu *xc, u8 prio);
3840
void (*setup_cpu)(unsigned int cpu, struct xive_cpu *xc);

‎arch/powerpc/xmon/xmon.c‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2574,14 +2574,14 @@ static void dump_all_xives(void)
25742574

25752575
static void dump_one_xive_irq(u32 num)
25762576
{
2577-
s64 rc;
2578-
__be64 vp;
2577+
int rc;
2578+
u32 target;
25792579
u8 prio;
2580-
__be32 lirq;
2580+
u32 lirq;
25812581

2582-
rc = opal_xive_get_irq_config(num, &vp, &prio, &lirq);
2583-
xmon_printf("IRQ 0x%x config: vp=0x%llx prio=%d lirq=0x%x (rc=%lld)\n",
2584-
num, be64_to_cpu(vp), prio, be32_to_cpu(lirq), rc);
2582+
rc = xmon_xive_get_irq_config(num, &target, &prio, &lirq);
2583+
xmon_printf("IRQ 0x%08x : target=0x%x prio=%d lirq=0x%x (rc=%d)\n",
2584+
num, target, prio, lirq, rc);
25852585
}
25862586

25872587
static void dump_xives(void)

0 commit comments

Comments
 (0)