Skip to content

Commit 988fc3b

Browse files
bglympe
authored andcommitted
powerpc/pci: Separate SR-IOV Calls
SR-IOV can now be enabled for the powernv platform and pseries platform. Therefore move the appropriate calls to machine dependent code instead of relying on definition at compile time. Signed-off-by: Bryant G. Ly <[email protected]> Signed-off-by: Juan J. Alvarez <[email protected]> Acked-by: Russell Currey <[email protected]> Reviewed-by: Alexey Kardashevskiy <[email protected]> Signed-off-by: Michael Ellerman <[email protected]>
1 parent 5c45b52 commit 988fc3b

File tree

7 files changed

+55
-29
lines changed

7 files changed

+55
-29
lines changed

arch/powerpc/include/asm/machdep.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,11 +172,19 @@ struct machdep_calls {
172172
/* Called after scan and before resource survey */
173173
void (*pcibios_fixup_phb)(struct pci_controller *hose);
174174

175+
/*
176+
* Called after device has been added to bus and
177+
* before sysfs has been created.
178+
*/
179+
void (*pcibios_bus_add_device)(struct pci_dev *pdev);
180+
175181
resource_size_t (*pcibios_default_alignment)(void);
176182

177183
#ifdef CONFIG_PCI_IOV
178184
void (*pcibios_fixup_sriov)(struct pci_dev *pdev);
179185
resource_size_t (*pcibios_iov_resource_alignment)(struct pci_dev *, int resno);
186+
int (*pcibios_sriov_enable)(struct pci_dev *pdev, u16 num_vfs);
187+
int (*pcibios_sriov_disable)(struct pci_dev *pdev);
180188
#endif /* CONFIG_PCI_IOV */
181189

182190
/* Called to shutdown machine specific hardware not already controlled

arch/powerpc/include/asm/pci-bridge.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -203,10 +203,9 @@ struct pci_dn {
203203
struct eeh_dev *edev; /* eeh device */
204204
#endif
205205
#define IODA_INVALID_PE 0xFFFFFFFF
206-
#ifdef CONFIG_PPC_POWERNV
207206
unsigned int pe_number;
208-
int vf_index; /* VF index in the PF */
209207
#ifdef CONFIG_PCI_IOV
208+
int vf_index; /* VF index in the PF */
210209
u16 vfs_expanded; /* number of VFs IOV BAR expanded */
211210
u16 num_vfs; /* number of VFs enabled*/
212211
unsigned int *pe_num_map; /* PE# for the first VF PE or array */
@@ -215,7 +214,6 @@ struct pci_dn {
215214
int (*m64_map)[PCI_SRIOV_NUM_BARS];
216215
#endif /* CONFIG_PCI_IOV */
217216
int mps; /* Maximum Payload Size */
218-
#endif
219217
struct list_head child_list;
220218
struct list_head list;
221219
struct resource holes[PCI_SRIOV_NUM_BARS];

arch/powerpc/kernel/eeh_driver.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,7 @@ static void *eeh_add_virt_device(void *data, void *userdata)
440440
return NULL;
441441
}
442442

443-
#ifdef CONFIG_PPC_POWERNV
443+
#ifdef CONFIG_PCI_IOV
444444
pci_iov_add_virtfn(edev->physfn, pdn->vf_index);
445445
#endif
446446
return NULL;
@@ -496,7 +496,7 @@ static void *eeh_rmv_device(void *data, void *userdata)
496496
(*removed)++;
497497

498498
if (edev->physfn) {
499-
#ifdef CONFIG_PPC_POWERNV
499+
#ifdef CONFIG_PCI_IOV
500500
struct pci_dn *pdn = eeh_dev_to_pdn(edev);
501501

502502
pci_iov_remove_virtfn(edev->physfn, pdn->vf_index);

arch/powerpc/kernel/pci-common.c

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,8 +249,31 @@ resource_size_t pcibios_iov_resource_alignment(struct pci_dev *pdev, int resno)
249249

250250
return pci_iov_resource_size(pdev, resno);
251251
}
252+
253+
int pcibios_sriov_enable(struct pci_dev *pdev, u16 num_vfs)
254+
{
255+
if (ppc_md.pcibios_sriov_enable)
256+
return ppc_md.pcibios_sriov_enable(pdev, num_vfs);
257+
258+
return 0;
259+
}
260+
261+
int pcibios_sriov_disable(struct pci_dev *pdev)
262+
{
263+
if (ppc_md.pcibios_sriov_disable)
264+
return ppc_md.pcibios_sriov_disable(pdev);
265+
266+
return 0;
267+
}
268+
252269
#endif /* CONFIG_PCI_IOV */
253270

271+
void pcibios_bus_add_device(struct pci_dev *pdev)
272+
{
273+
if (ppc_md.pcibios_bus_add_device)
274+
ppc_md.pcibios_bus_add_device(pdev);
275+
}
276+
254277
static resource_size_t pcibios_io_size(const struct pci_controller *hose)
255278
{
256279
#ifdef CONFIG_PPC64

arch/powerpc/kernel/pci_dn.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -156,10 +156,8 @@ static struct pci_dn *add_one_dev_pci_data(struct pci_dn *parent,
156156
pdn->parent = parent;
157157
pdn->busno = busno;
158158
pdn->devfn = devfn;
159-
#ifdef CONFIG_PPC_POWERNV
160159
pdn->vf_index = vf_index;
161160
pdn->pe_number = IODA_INVALID_PE;
162-
#endif
163161
INIT_LIST_HEAD(&pdn->child_list);
164162
INIT_LIST_HEAD(&pdn->list);
165163
list_add_tail(&pdn->list, &parent->child_list);
@@ -226,9 +224,7 @@ void remove_dev_pci_data(struct pci_dev *pdev)
226224
*/
227225
if (pdev->is_virtfn) {
228226
pdn = pci_get_pdn(pdev);
229-
#ifdef CONFIG_PPC_POWERNV
230227
pdn->pe_number = IODA_INVALID_PE;
231-
#endif
232228
return;
233229
}
234230

@@ -294,9 +290,7 @@ struct pci_dn *pci_add_device_node_info(struct pci_controller *hose,
294290
return NULL;
295291
dn->data = pdn;
296292
pdn->phb = hose;
297-
#ifdef CONFIG_PPC_POWERNV
298293
pdn->pe_number = IODA_INVALID_PE;
299-
#endif
300294
regs = of_get_property(dn, "reg", NULL);
301295
if (regs) {
302296
u32 addr = of_read_number(regs, 1);

arch/powerpc/platforms/powernv/eeh-powernv.c

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,22 @@
4343

4444
static int eeh_event_irq = -EINVAL;
4545

46+
void pnv_pcibios_bus_add_device(struct pci_dev *pdev)
47+
{
48+
struct pci_dn *pdn = pci_get_pdn(pdev);
49+
50+
if (!pdev->is_virtfn)
51+
return;
52+
53+
/*
54+
* The following operations will fail if VF's sysfs files
55+
* aren't created or its resources aren't finalized.
56+
*/
57+
eeh_add_device_early(pdn);
58+
eeh_add_device_late(pdev);
59+
eeh_sysfs_add_device(pdev);
60+
}
61+
4662
static int pnv_eeh_init(void)
4763
{
4864
struct pci_controller *hose;
@@ -86,6 +102,7 @@ static int pnv_eeh_init(void)
86102
}
87103

88104
eeh_set_pe_aux_size(max_diag_size);
105+
ppc_md.pcibios_bus_add_device = pnv_pcibios_bus_add_device;
89106

90107
return 0;
91108
}
@@ -1749,22 +1766,6 @@ static struct eeh_ops pnv_eeh_ops = {
17491766
.restore_config = pnv_eeh_restore_config
17501767
};
17511768

1752-
void pcibios_bus_add_device(struct pci_dev *pdev)
1753-
{
1754-
struct pci_dn *pdn = pci_get_pdn(pdev);
1755-
1756-
if (!pdev->is_virtfn)
1757-
return;
1758-
1759-
/*
1760-
* The following operations will fail if VF's sysfs files
1761-
* aren't created or its resources aren't finalized.
1762-
*/
1763-
eeh_add_device_early(pdn);
1764-
eeh_add_device_late(pdev);
1765-
eeh_sysfs_add_device(pdev);
1766-
}
1767-
17681769
#ifdef CONFIG_PCI_IOV
17691770
static void pnv_pci_fixup_vf_mps(struct pci_dev *pdev)
17701771
{

arch/powerpc/platforms/powernv/pci-ioda.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1692,7 +1692,7 @@ int pnv_pci_sriov_enable(struct pci_dev *pdev, u16 num_vfs)
16921692
return ret;
16931693
}
16941694

1695-
int pcibios_sriov_disable(struct pci_dev *pdev)
1695+
int pnv_pcibios_sriov_disable(struct pci_dev *pdev)
16961696
{
16971697
pnv_pci_sriov_disable(pdev);
16981698

@@ -1701,7 +1701,7 @@ int pcibios_sriov_disable(struct pci_dev *pdev)
17011701
return 0;
17021702
}
17031703

1704-
int pcibios_sriov_enable(struct pci_dev *pdev, u16 num_vfs)
1704+
int pnv_pcibios_sriov_enable(struct pci_dev *pdev, u16 num_vfs)
17051705
{
17061706
/* Allocate PCI data */
17071707
add_dev_pci_data(pdev);
@@ -4019,6 +4019,8 @@ static void __init pnv_pci_init_ioda_phb(struct device_node *np,
40194019
#ifdef CONFIG_PCI_IOV
40204020
ppc_md.pcibios_fixup_sriov = pnv_pci_ioda_fixup_iov_resources;
40214021
ppc_md.pcibios_iov_resource_alignment = pnv_pci_iov_resource_alignment;
4022+
ppc_md.pcibios_sriov_enable = pnv_pcibios_sriov_enable;
4023+
ppc_md.pcibios_sriov_disable = pnv_pcibios_sriov_disable;
40224024
#endif
40234025

40244026
pci_add_flags(PCI_REASSIGN_ALL_RSRC);

0 commit comments

Comments
 (0)