1
/* Copyright 2013-2014 IBM Corp.
3
* Licensed under the Apache License, Version 2.0 (the "License");
4
* you may not use this file except in compliance with the License.
5
* You may obtain a copy of the License at
7
* http://www.apache.org/licenses/LICENSE-2.0
9
* Unless required by applicable law or agreed to in writing, software
10
* distributed under the License is distributed on an "AS IS" BASIS,
11
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
13
* See the License for the specific language governing permissions and
14
* limitations under the License.
26
#define OPAL_PCICFG_ACCESS(op, cb, type) \
27
static int64_t opal_pci_config_##op(uint64_t phb_id, \
28
uint64_t bus_dev_func, \
29
uint64_t offset, type data) \
31
struct phb *phb = pci_get_phb(phb_id); \
35
return OPAL_PARAMETER; \
37
rc = phb->ops->cfg_##cb(phb, bus_dev_func, offset, data); \
43
OPAL_PCICFG_ACCESS(read_byte, read8, uint8_t *)
44
OPAL_PCICFG_ACCESS(read_half_word, read16, uint16_t *)
45
OPAL_PCICFG_ACCESS(read_word, read32, uint32_t *)
46
OPAL_PCICFG_ACCESS(write_byte, write8, uint8_t)
47
OPAL_PCICFG_ACCESS(write_half_word, write16, uint16_t)
48
OPAL_PCICFG_ACCESS(write_word, write32, uint32_t)
50
opal_call(OPAL_PCI_CONFIG_READ_BYTE, opal_pci_config_read_byte, 4);
51
opal_call(OPAL_PCI_CONFIG_READ_HALF_WORD, opal_pci_config_read_half_word, 4);
52
opal_call(OPAL_PCI_CONFIG_READ_WORD, opal_pci_config_read_word, 4);
53
opal_call(OPAL_PCI_CONFIG_WRITE_BYTE, opal_pci_config_write_byte, 4);
54
opal_call(OPAL_PCI_CONFIG_WRITE_HALF_WORD, opal_pci_config_write_half_word, 4);
55
opal_call(OPAL_PCI_CONFIG_WRITE_WORD, opal_pci_config_write_word, 4);
57
static struct lock opal_eeh_evt_lock = LOCK_UNLOCKED;
58
static uint64_t opal_eeh_evt = 0;
60
void opal_pci_eeh_set_evt(uint64_t phb_id)
62
lock(&opal_eeh_evt_lock);
63
opal_eeh_evt |= 1ULL << phb_id;
64
opal_update_pending_evt(OPAL_EVENT_PCI_ERROR, OPAL_EVENT_PCI_ERROR);
65
unlock(&opal_eeh_evt_lock);
68
void opal_pci_eeh_clear_evt(uint64_t phb_id)
70
lock(&opal_eeh_evt_lock);
71
opal_eeh_evt &= ~(1ULL << phb_id);
73
opal_update_pending_evt(OPAL_EVENT_PCI_ERROR, 0);
74
unlock(&opal_eeh_evt_lock);
77
static int64_t opal_pci_eeh_freeze_status(uint64_t phb_id, uint64_t pe_number,
78
uint8_t *freeze_state,
79
uint16_t *pci_error_type,
82
struct phb *phb = pci_get_phb(phb_id);
86
return OPAL_PARAMETER;
87
if (!phb->ops->eeh_freeze_status)
88
return OPAL_UNSUPPORTED;
90
rc = phb->ops->eeh_freeze_status(phb, pe_number, freeze_state,
91
pci_error_type, NULL, phb_status);
96
opal_call(OPAL_PCI_EEH_FREEZE_STATUS, opal_pci_eeh_freeze_status, 5);
98
static int64_t opal_pci_eeh_freeze_clear(uint64_t phb_id, uint64_t pe_number,
99
uint64_t eeh_action_token)
101
struct phb *phb = pci_get_phb(phb_id);
105
return OPAL_PARAMETER;
106
if (!phb->ops->eeh_freeze_clear)
107
return OPAL_UNSUPPORTED;
109
rc = phb->ops->eeh_freeze_clear(phb, pe_number, eeh_action_token);
114
opal_call(OPAL_PCI_EEH_FREEZE_CLEAR, opal_pci_eeh_freeze_clear, 3);
116
static int64_t opal_pci_eeh_freeze_set(uint64_t phb_id, uint64_t pe_number,
117
uint64_t eeh_action_token)
119
struct phb *phb = pci_get_phb(phb_id);
123
return OPAL_PARAMETER;
124
if (!phb->ops->eeh_freeze_set)
125
return OPAL_UNSUPPORTED;
127
rc = phb->ops->eeh_freeze_set(phb, pe_number, eeh_action_token);
132
opal_call(OPAL_PCI_EEH_FREEZE_SET, opal_pci_eeh_freeze_set, 3);
134
static int64_t opal_pci_err_inject(uint64_t phb_id, uint32_t pe_no,
135
uint32_t type, uint32_t func,
136
uint64_t addr, uint64_t mask)
138
struct phb *phb = pci_get_phb(phb_id);
142
return OPAL_PARAMETER;
143
if (!phb->ops || !phb->ops->err_inject)
144
return OPAL_UNSUPPORTED;
146
if (type != OPAL_ERR_INJECT_TYPE_IOA_BUS_ERR &&
147
type != OPAL_ERR_INJECT_TYPE_IOA_BUS_ERR64)
148
return OPAL_PARAMETER;
151
rc = phb->ops->err_inject(phb, pe_no, type, func, addr, mask);
156
opal_call(OPAL_PCI_ERR_INJECT, opal_pci_err_inject, 6);
158
static int64_t opal_pci_phb_mmio_enable(uint64_t phb_id, uint16_t window_type,
159
uint16_t window_num, uint16_t enable)
161
struct phb *phb = pci_get_phb(phb_id);
165
return OPAL_PARAMETER;
166
if (!phb->ops->phb_mmio_enable)
167
return OPAL_UNSUPPORTED;
169
rc = phb->ops->phb_mmio_enable(phb, window_type, window_num, enable);
174
opal_call(OPAL_PCI_PHB_MMIO_ENABLE, opal_pci_phb_mmio_enable, 4);
176
static int64_t opal_pci_set_phb_mem_window(uint64_t phb_id,
177
uint16_t window_type,
183
struct phb *phb = pci_get_phb(phb_id);
187
return OPAL_PARAMETER;
188
if (!phb->ops->set_phb_mem_window)
189
return OPAL_UNSUPPORTED;
191
rc = phb->ops->set_phb_mem_window(phb, window_type, window_num,
192
addr, pci_addr, size);
197
opal_call(OPAL_PCI_SET_PHB_MEM_WINDOW, opal_pci_set_phb_mem_window, 6);
199
static int64_t opal_pci_map_pe_mmio_window(uint64_t phb_id, uint16_t pe_number,
200
uint16_t window_type,
202
uint16_t segment_num)
204
struct phb *phb = pci_get_phb(phb_id);
208
return OPAL_PARAMETER;
209
if (!phb->ops->map_pe_mmio_window)
210
return OPAL_UNSUPPORTED;
212
rc = phb->ops->map_pe_mmio_window(phb, pe_number, window_type,
213
window_num, segment_num);
218
opal_call(OPAL_PCI_MAP_PE_MMIO_WINDOW, opal_pci_map_pe_mmio_window, 5);
220
static int64_t opal_pci_set_phb_table_memory(uint64_t phb_id __unused,
221
uint64_t rtt_addr __unused,
222
uint64_t ivt_addr __unused,
223
uint64_t ivt_len __unused,
224
uint64_t rej_array_addr __unused,
225
uint64_t peltv_addr __unused)
227
/* IODA2 (P8) stuff, TODO */
228
return OPAL_UNSUPPORTED;
230
opal_call(OPAL_PCI_SET_PHB_TABLE_MEMORY, opal_pci_set_phb_table_memory, 6);
232
static int64_t opal_pci_set_pe(uint64_t phb_id, uint64_t pe_number,
233
uint64_t bus_dev_func, uint8_t bus_compare,
234
uint8_t dev_compare, uint8_t func_compare,
237
struct phb *phb = pci_get_phb(phb_id);
241
return OPAL_PARAMETER;
242
if (!phb->ops->set_pe)
243
return OPAL_UNSUPPORTED;
245
rc = phb->ops->set_pe(phb, pe_number, bus_dev_func, bus_compare,
246
dev_compare, func_compare, pe_action);
251
opal_call(OPAL_PCI_SET_PE, opal_pci_set_pe, 7);
253
static int64_t opal_pci_set_peltv(uint64_t phb_id, uint32_t parent_pe,
254
uint32_t child_pe, uint8_t state)
256
struct phb *phb = pci_get_phb(phb_id);
260
return OPAL_PARAMETER;
261
if (!phb->ops->set_peltv)
262
return OPAL_UNSUPPORTED;
264
rc = phb->ops->set_peltv(phb, parent_pe, child_pe, state);
269
opal_call(OPAL_PCI_SET_PELTV, opal_pci_set_peltv, 4);
271
static int64_t opal_pci_set_mve(uint64_t phb_id, uint32_t mve_number,
274
struct phb *phb = pci_get_phb(phb_id);
278
return OPAL_PARAMETER;
279
if (!phb->ops->set_mve)
280
return OPAL_UNSUPPORTED;
282
rc = phb->ops->set_mve(phb, mve_number, pe_number);
287
opal_call(OPAL_PCI_SET_MVE, opal_pci_set_mve, 3);
289
static int64_t opal_pci_set_mve_enable(uint64_t phb_id, uint32_t mve_number,
292
struct phb *phb = pci_get_phb(phb_id);
296
return OPAL_PARAMETER;
297
if (!phb->ops->set_mve_enable)
298
return OPAL_UNSUPPORTED;
300
rc = phb->ops->set_mve_enable(phb, mve_number, state);
305
opal_call(OPAL_PCI_SET_MVE_ENABLE, opal_pci_set_mve_enable, 3);
307
static int64_t opal_pci_get_xive_reissue(uint64_t phb_id __unused,
308
uint32_t xive_number __unused,
309
uint8_t *p_bit __unused,
310
uint8_t *q_bit __unused)
312
/* IODA2 (P8) stuff, TODO */
313
return OPAL_UNSUPPORTED;
315
opal_call(OPAL_PCI_GET_XIVE_REISSUE, opal_pci_get_xive_reissue, 4);
317
static int64_t opal_pci_set_xive_reissue(uint64_t phb_id __unused,
318
uint32_t xive_number __unused,
319
uint8_t p_bit __unused,
320
uint8_t q_bit __unused)
322
/* IODA2 (P8) stuff, TODO */
323
return OPAL_UNSUPPORTED;
325
opal_call(OPAL_PCI_SET_XIVE_REISSUE, opal_pci_set_xive_reissue, 4);
327
static int64_t opal_pci_msi_eoi(uint64_t phb_id,
330
struct phb *phb = pci_get_phb(phb_id);
334
return OPAL_PARAMETER;
335
if (!phb->ops->pci_msi_eoi)
336
return OPAL_UNSUPPORTED;
338
rc = phb->ops->pci_msi_eoi(phb, hwirq);
343
opal_call(OPAL_PCI_MSI_EOI, opal_pci_msi_eoi, 2);
345
static int64_t opal_pci_tce_kill(uint64_t phb_id,
347
uint32_t pe_num, uint32_t tce_size,
348
uint64_t dma_addr, uint32_t npages)
350
struct phb *phb = pci_get_phb(phb_id);
354
return OPAL_PARAMETER;
355
if (!phb->ops->tce_kill)
356
return OPAL_UNSUPPORTED;
358
rc = phb->ops->tce_kill(phb, kill_type, pe_num, tce_size,
364
opal_call(OPAL_PCI_TCE_KILL, opal_pci_tce_kill, 6);
366
static int64_t opal_pci_set_xive_pe(uint64_t phb_id, uint32_t pe_number,
369
struct phb *phb = pci_get_phb(phb_id);
373
return OPAL_PARAMETER;
374
if (!phb->ops->set_xive_pe)
375
return OPAL_UNSUPPORTED;
377
rc = phb->ops->set_xive_pe(phb, pe_number, xive_num);
382
opal_call(OPAL_PCI_SET_XIVE_PE, opal_pci_set_xive_pe, 3);
384
static int64_t opal_get_xive_source(uint64_t phb_id, uint32_t xive_num,
385
int32_t *interrupt_source_number)
387
struct phb *phb = pci_get_phb(phb_id);
391
return OPAL_PARAMETER;
392
if (!phb->ops->get_xive_source)
393
return OPAL_UNSUPPORTED;
395
rc = phb->ops->get_xive_source(phb, xive_num, interrupt_source_number);
400
opal_call(OPAL_GET_XIVE_SOURCE, opal_get_xive_source, 3);
402
static int64_t opal_get_msi_32(uint64_t phb_id, uint32_t mve_number,
403
uint32_t xive_num, uint8_t msi_range,
404
uint32_t *msi_address, uint32_t *message_data)
406
struct phb *phb = pci_get_phb(phb_id);
410
return OPAL_PARAMETER;
411
if (!phb->ops->get_msi_32)
412
return OPAL_UNSUPPORTED;
414
rc = phb->ops->get_msi_32(phb, mve_number, xive_num, msi_range,
415
msi_address, message_data);
420
opal_call(OPAL_GET_MSI_32, opal_get_msi_32, 6);
422
static int64_t opal_get_msi_64(uint64_t phb_id, uint32_t mve_number,
423
uint32_t xive_num, uint8_t msi_range,
424
uint64_t *msi_address, uint32_t *message_data)
426
struct phb *phb = pci_get_phb(phb_id);
430
return OPAL_PARAMETER;
431
if (!phb->ops->get_msi_64)
432
return OPAL_UNSUPPORTED;
434
rc = phb->ops->get_msi_64(phb, mve_number, xive_num, msi_range,
435
msi_address, message_data);
440
opal_call(OPAL_GET_MSI_64, opal_get_msi_64, 6);
442
static int64_t opal_pci_map_pe_dma_window(uint64_t phb_id, uint16_t pe_number,
445
uint64_t tce_table_addr,
446
uint64_t tce_table_size,
447
uint64_t tce_page_size)
449
struct phb *phb = pci_get_phb(phb_id);
453
return OPAL_PARAMETER;
454
if (!phb->ops->map_pe_dma_window)
455
return OPAL_UNSUPPORTED;
457
rc = phb->ops->map_pe_dma_window(phb, pe_number, window_id,
458
tce_levels, tce_table_addr,
459
tce_table_size, tce_page_size);
464
opal_call(OPAL_PCI_MAP_PE_DMA_WINDOW, opal_pci_map_pe_dma_window, 7);
466
static int64_t opal_pci_map_pe_dma_window_real(uint64_t phb_id,
469
uint64_t pci_start_addr,
470
uint64_t pci_mem_size)
472
struct phb *phb = pci_get_phb(phb_id);
476
return OPAL_PARAMETER;
477
if (!phb->ops->map_pe_dma_window_real)
478
return OPAL_UNSUPPORTED;
480
rc = phb->ops->map_pe_dma_window_real(phb, pe_number, window_id,
481
pci_start_addr, pci_mem_size);
486
opal_call(OPAL_PCI_MAP_PE_DMA_WINDOW_REAL, opal_pci_map_pe_dma_window_real, 5);
488
static int64_t opal_pci_reset(uint64_t id, uint8_t reset_scope,
489
uint8_t assert_state)
491
struct pci_slot *slot = pci_slot_find(id);
492
struct phb *phb = slot ? slot->phb : NULL;
493
int64_t rc = OPAL_SUCCESS;
496
return OPAL_PARAMETER;
497
if (assert_state != OPAL_ASSERT_RESET &&
498
assert_state != OPAL_DEASSERT_RESET)
499
return OPAL_PARAMETER;
503
switch(reset_scope) {
504
case OPAL_RESET_PHB_COMPLETE:
505
/* Complete reset is applicable to PHB slot only */
506
if (!slot->ops.creset || slot->pd) {
507
rc = OPAL_UNSUPPORTED;
511
if (assert_state != OPAL_ASSERT_RESET)
514
rc = slot->ops.creset(slot);
516
prlog(PR_ERR, "SLOT-%016llx: Error %lld on complete reset\n",
519
case OPAL_RESET_PCI_FUNDAMENTAL:
520
if (!slot->ops.freset) {
521
rc = OPAL_UNSUPPORTED;
525
/* We need do nothing on deassert time */
526
if (assert_state != OPAL_ASSERT_RESET)
529
rc = slot->ops.freset(slot);
531
prlog(PR_ERR, "SLOT-%016llx: Error %lld on fundamental reset\n",
534
case OPAL_RESET_PCI_HOT:
535
if (!slot->ops.hreset) {
536
rc = OPAL_UNSUPPORTED;
540
/* We need do nothing on deassert time */
541
if (assert_state != OPAL_ASSERT_RESET)
544
rc = slot->ops.hreset(slot);
546
prlog(PR_ERR, "SLOT-%016llx: Error %lld on hot reset\n",
549
case OPAL_RESET_PCI_IODA_TABLE:
550
/* It's allowed on PHB slot only */
551
if (slot->pd || !phb->ops || !phb->ops->ioda_reset) {
552
rc = OPAL_UNSUPPORTED;
556
if (assert_state != OPAL_ASSERT_RESET)
559
rc = phb->ops->ioda_reset(phb, true);
561
case OPAL_RESET_PHB_ERROR:
562
/* It's allowed on PHB slot only */
563
if (slot->pd || !phb->ops || !phb->ops->papr_errinjct_reset) {
564
rc = OPAL_UNSUPPORTED;
568
if (assert_state != OPAL_ASSERT_RESET)
571
rc = phb->ops->papr_errinjct_reset(phb);
574
rc = OPAL_UNSUPPORTED;
578
return (rc > 0) ? tb_to_msecs(rc) : rc;
580
opal_call(OPAL_PCI_RESET, opal_pci_reset, 3);
582
static int64_t opal_pci_reinit(uint64_t phb_id,
583
uint64_t reinit_scope,
586
struct phb *phb = pci_get_phb(phb_id);
590
return OPAL_PARAMETER;
591
if (!phb->ops || !phb->ops->pci_reinit)
592
return OPAL_UNSUPPORTED;
595
rc = phb->ops->pci_reinit(phb, reinit_scope, data);
600
opal_call(OPAL_PCI_REINIT, opal_pci_reinit, 3);
602
static int64_t opal_pci_poll(uint64_t id)
604
struct pci_slot *slot = pci_slot_find(id);
605
struct phb *phb = slot ? slot->phb : NULL;
609
return OPAL_PARAMETER;
611
return OPAL_UNSUPPORTED;
614
rc = slot->ops.poll(slot);
617
/* Return milliseconds for caller to sleep: round up */
619
rc = tb_to_msecs(rc);
626
opal_call(OPAL_PCI_POLL, opal_pci_poll, 1);
628
static int64_t opal_pci_get_presence_state(uint64_t id, uint64_t data)
630
struct pci_slot *slot = pci_slot_find(id);
631
struct phb *phb = slot ? slot->phb : NULL;
632
uint8_t *presence = (uint8_t *)data;
636
return OPAL_PARAMETER;
637
if (!slot->ops.get_presence_state)
638
return OPAL_UNSUPPORTED;
641
rc = slot->ops.get_presence_state(slot, presence);
646
opal_call(OPAL_PCI_GET_PRESENCE_STATE, opal_pci_get_presence_state, 2);
648
static int64_t opal_pci_get_power_state(uint64_t id, uint64_t data)
650
struct pci_slot *slot = pci_slot_find(id);
651
struct phb *phb = slot ? slot->phb : NULL;
652
uint8_t *power_state = (uint8_t *)data;
656
return OPAL_PARAMETER;
657
if (!slot->ops.get_power_state)
658
return OPAL_UNSUPPORTED;
661
rc = slot->ops.get_power_state(slot, power_state);
666
opal_call(OPAL_PCI_GET_POWER_STATE, opal_pci_get_power_state, 2);
668
static void set_power_timer(struct timer *t __unused, void *data,
669
uint64_t now __unused)
671
struct pci_slot *slot = data;
672
struct phb *phb = slot->phb;
673
struct pci_device *pd = slot->pd;
674
struct dt_node *dn = pd->dn;
677
switch (slot->state) {
678
case PCI_SLOT_STATE_SPOWER_START:
679
if (slot->retries-- == 0) {
680
pci_slot_set_state(slot, PCI_SLOT_STATE_NORMAL);
681
opal_queue_msg(OPAL_MSG_ASYNC_COMP, NULL, NULL,
682
slot->async_token, dn->phandle,
683
slot->power_state, OPAL_BUSY);
685
schedule_timer(&slot->timer, msecs_to_tb(10));
689
case PCI_SLOT_STATE_SPOWER_DONE:
690
if (slot->power_state == OPAL_PCI_SLOT_POWER_OFF) {
691
pci_remove_bus(phb, &pd->children);
692
pci_slot_set_state(slot, PCI_SLOT_STATE_NORMAL);
693
opal_queue_msg(OPAL_MSG_ASYNC_COMP, NULL, NULL,
694
slot->async_token, dn->phandle,
695
OPAL_PCI_SLOT_POWER_OFF, OPAL_SUCCESS);
700
if (slot->ops.get_link_state(slot, &link) != OPAL_SUCCESS)
703
slot->ops.prepare_link_change(slot, true);
704
pci_scan_bus(phb, pd->secondary_bus,
706
&pd->children, pd, true);
707
pci_add_device_nodes(phb, &pd->children, dn,
709
pci_slot_set_state(slot, PCI_SLOT_STATE_NORMAL);
710
opal_queue_msg(OPAL_MSG_ASYNC_COMP, NULL, NULL,
711
slot->async_token, dn->phandle,
712
OPAL_PCI_SLOT_POWER_ON, OPAL_SUCCESS);
713
} else if (slot->retries-- == 0) {
714
pci_slot_set_state(slot, PCI_SLOT_STATE_NORMAL);
715
opal_queue_msg(OPAL_MSG_ASYNC_COMP, NULL, NULL,
716
slot->async_token, dn->phandle,
717
OPAL_PCI_SLOT_POWER_ON, OPAL_BUSY);
719
schedule_timer(&slot->timer, msecs_to_tb(10));
724
prlog(PR_ERR, "PCI SLOT %016llx: Unexpected state 0x%08x\n",
725
slot->id, slot->state);
729
static int64_t opal_pci_set_power_state(uint64_t async_token,
733
struct pci_slot *slot = pci_slot_find(id);
734
struct phb *phb = slot ? slot->phb : NULL;
735
struct pci_device *pd = slot ? slot->pd : NULL;
736
uint8_t *state = (uint8_t *)data;
740
return OPAL_PARAMETER;
744
case OPAL_PCI_SLOT_POWER_OFF:
745
if (!slot->ops.prepare_link_change ||
746
!slot->ops.set_power_state)
747
return OPAL_UNSUPPORTED;
749
slot->async_token = async_token;
750
slot->ops.prepare_link_change(slot, false);
751
rc = slot->ops.set_power_state(slot, PCI_SLOT_POWER_OFF);
753
case OPAL_PCI_SLOT_POWER_ON:
754
if (!slot->ops.set_power_state ||
755
!slot->ops.get_link_state)
756
return OPAL_UNSUPPORTED;
758
slot->async_token = async_token;
759
rc = slot->ops.set_power_state(slot, PCI_SLOT_POWER_ON);
761
case OPAL_PCI_SLOT_OFFLINE:
763
return OPAL_PARAMETER;
765
pci_remove_bus(phb, &pd->children);
768
case OPAL_PCI_SLOT_ONLINE:
770
return OPAL_PARAMETER;
771
pci_scan_bus(phb, pd->secondary_bus, pd->subordinate_bus,
772
&pd->children, pd, true);
773
pci_add_device_nodes(phb, &pd->children, pd->dn,
782
if (rc == OPAL_ASYNC_COMPLETION) {
784
init_timer(&slot->timer, set_power_timer, slot);
785
schedule_timer(&slot->timer, msecs_to_tb(10));
790
opal_call(OPAL_PCI_SET_POWER_STATE, opal_pci_set_power_state, 3);
792
static int64_t opal_pci_set_phb_tce_memory(uint64_t phb_id,
793
uint64_t tce_mem_addr,
794
uint64_t tce_mem_size)
796
struct phb *phb = pci_get_phb(phb_id);
800
return OPAL_PARAMETER;
801
if (!phb->ops->set_phb_tce_memory)
802
return OPAL_UNSUPPORTED;
804
rc = phb->ops->set_phb_tce_memory(phb, tce_mem_addr, tce_mem_size);
809
opal_call(OPAL_PCI_SET_PHB_TCE_MEMORY, opal_pci_set_phb_tce_memory, 3);
811
static int64_t opal_pci_get_phb_diag_data(uint64_t phb_id,
813
uint64_t diag_buffer_len)
815
struct phb *phb = pci_get_phb(phb_id);
819
return OPAL_PARAMETER;
820
if (!phb->ops->get_diag_data)
821
return OPAL_UNSUPPORTED;
823
rc = phb->ops->get_diag_data(phb, diag_buffer, diag_buffer_len);
828
opal_call(OPAL_PCI_GET_PHB_DIAG_DATA, opal_pci_get_phb_diag_data, 3);
830
static int64_t opal_pci_get_phb_diag_data2(uint64_t phb_id,
832
uint64_t diag_buffer_len)
834
struct phb *phb = pci_get_phb(phb_id);
838
return OPAL_PARAMETER;
839
if (!phb->ops->get_diag_data2)
840
return OPAL_UNSUPPORTED;
842
rc = phb->ops->get_diag_data2(phb, diag_buffer, diag_buffer_len);
847
opal_call(OPAL_PCI_GET_PHB_DIAG_DATA2, opal_pci_get_phb_diag_data2, 3);
849
static int64_t opal_pci_next_error(uint64_t phb_id, uint64_t *first_frozen_pe,
850
uint16_t *pci_error_type, uint16_t *severity)
852
struct phb *phb = pci_get_phb(phb_id);
856
return OPAL_PARAMETER;
857
if (!phb->ops->next_error)
858
return OPAL_UNSUPPORTED;
861
opal_pci_eeh_clear_evt(phb_id);
862
rc = phb->ops->next_error(phb, first_frozen_pe, pci_error_type,
868
opal_call(OPAL_PCI_NEXT_ERROR, opal_pci_next_error, 4);
870
static int64_t opal_pci_eeh_freeze_status2(uint64_t phb_id, uint64_t pe_number,
871
uint8_t *freeze_state,
872
uint16_t *pci_error_type,
874
uint64_t *phb_status)
876
struct phb *phb = pci_get_phb(phb_id);
880
return OPAL_PARAMETER;
881
if (!phb->ops->eeh_freeze_status)
882
return OPAL_UNSUPPORTED;
884
rc = phb->ops->eeh_freeze_status(phb, pe_number, freeze_state,
885
pci_error_type, severity, phb_status);
890
opal_call(OPAL_PCI_EEH_FREEZE_STATUS2, opal_pci_eeh_freeze_status2, 6);
892
static int64_t opal_pci_set_phb_capi_mode(uint64_t phb_id, uint64_t mode, uint64_t pe_number)
894
struct phb *phb = pci_get_phb(phb_id);
898
return OPAL_PARAMETER;
899
if (!phb->ops->set_capi_mode)
900
return OPAL_UNSUPPORTED;
903
rc = phb->ops->set_capi_mode(phb, mode, pe_number);
907
opal_call(OPAL_PCI_SET_PHB_CAPI_MODE, opal_pci_set_phb_capi_mode, 3);