Skip to content

Commit e01c979

Browse files
floatiousMani-Sadhasivam
authored andcommitted
PCI: endpoint: Clean up hardware description for BARs
The hardware description for BARs is scattered in many different variables in pci_epc_features. Some of these things are mutually exclusive, so it can create confusion over which variable that has precedence over another. Improve the situation by creating a struct pci_epc_bar_desc, and a new enum pci_epc_bar_type, and convert the endpoint controller drivers to use this more well defined format. Additionally, some endpoint controller drivers mark the BAR succeeding a "64-bit only BAR" as reserved, while some do not. By definition, a 64-bit BAR uses the succeeding BAR for the upper 32-bits, so an EPF driver cannot use a BAR succeeding a 64-bit BAR. Ensure that all endpoint controller drivers are uniform, and actually describe a reserved BAR as reserved. Signed-off-by: Niklas Cassel <[email protected]> Reviewed-by: Kishon Vijay Abraham I <[email protected]> Reviewed-by: Manivannan Sadhasivam <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Manivannan Sadhasivam <[email protected]>
1 parent c670e29 commit e01c979

File tree

14 files changed

+108
-58
lines changed

14 files changed

+108
-58
lines changed

drivers/pci/controller/dwc/pci-imx6.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1081,7 +1081,8 @@ static const struct pci_epc_features imx8m_pcie_epc_features = {
10811081
.linkup_notifier = false,
10821082
.msi_capable = true,
10831083
.msix_capable = false,
1084-
.reserved_bar = 1 << BAR_1 | 1 << BAR_3,
1084+
.bar[BAR_1] = { .type = BAR_RESERVED, },
1085+
.bar[BAR_3] = { .type = BAR_RESERVED, },
10851086
.align = SZ_64K,
10861087
};
10871088

drivers/pci/controller/dwc/pci-keystone.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -924,12 +924,12 @@ static const struct pci_epc_features ks_pcie_am654_epc_features = {
924924
.linkup_notifier = false,
925925
.msi_capable = true,
926926
.msix_capable = true,
927-
.reserved_bar = 1 << BAR_0 | 1 << BAR_1,
928-
.bar_fixed_64bit = 1 << BAR_0,
929-
.bar_fixed_size[2] = SZ_1M,
930-
.bar_fixed_size[3] = SZ_64K,
931-
.bar_fixed_size[4] = 256,
932-
.bar_fixed_size[5] = SZ_1M,
927+
.bar[BAR_0] = { .type = BAR_RESERVED, .only_64bit = true, },
928+
.bar[BAR_1] = { .type = BAR_RESERVED, },
929+
.bar[BAR_2] = { .type = BAR_FIXED, .fixed_size = SZ_1M, },
930+
.bar[BAR_3] = { .type = BAR_FIXED, .fixed_size = SZ_64K, },
931+
.bar[BAR_4] = { .type = BAR_FIXED, .fixed_size = 256, },
932+
.bar[BAR_5] = { .type = BAR_FIXED, .fixed_size = SZ_1M, },
933933
.align = SZ_1M,
934934
};
935935

drivers/pci/controller/dwc/pci-layerscape-ep.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,10 @@ static int __init ls_pcie_ep_probe(struct platform_device *pdev)
250250
pci->dev = dev;
251251
pci->ops = pcie->drvdata->dw_pcie_ops;
252252

253-
ls_epc->bar_fixed_64bit = (1 << BAR_2) | (1 << BAR_4);
253+
ls_epc->bar[BAR_2].only_64bit = true;
254+
ls_epc->bar[BAR_3].type = BAR_RESERVED;
255+
ls_epc->bar[BAR_4].only_64bit = true;
256+
ls_epc->bar[BAR_5].type = BAR_RESERVED;
254257
ls_epc->linkup_notifier = true;
255258

256259
pcie->pci = pci;

drivers/pci/controller/dwc/pcie-keembay.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -312,8 +312,12 @@ static const struct pci_epc_features keembay_pcie_epc_features = {
312312
.linkup_notifier = false,
313313
.msi_capable = true,
314314
.msix_capable = true,
315-
.reserved_bar = BIT(BAR_1) | BIT(BAR_3) | BIT(BAR_5),
316-
.bar_fixed_64bit = BIT(BAR_0) | BIT(BAR_2) | BIT(BAR_4),
315+
.bar[BAR_0] = { .only_64bit = true, },
316+
.bar[BAR_1] = { .type = BAR_RESERVED, },
317+
.bar[BAR_2] = { .only_64bit = true, },
318+
.bar[BAR_3] = { .type = BAR_RESERVED, },
319+
.bar[BAR_4] = { .only_64bit = true, },
320+
.bar[BAR_5] = { .type = BAR_RESERVED, },
317321
.align = SZ_16K,
318322
};
319323

drivers/pci/controller/dwc/pcie-rcar-gen4.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,9 @@ static const struct pci_epc_features rcar_gen4_pcie_epc_features = {
383383
.linkup_notifier = false,
384384
.msi_capable = true,
385385
.msix_capable = false,
386-
.reserved_bar = 1 << BAR_1 | 1 << BAR_3 | 1 << BAR_5,
386+
.bar[BAR_1] = { .type = BAR_RESERVED, },
387+
.bar[BAR_3] = { .type = BAR_RESERVED, },
388+
.bar[BAR_5] = { .type = BAR_RESERVED, },
387389
.align = SZ_1M,
388390
};
389391

drivers/pci/controller/dwc/pcie-tegra194.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2007,9 +2007,13 @@ static const struct pci_epc_features tegra_pcie_epc_features = {
20072007
.core_init_notifier = true,
20082008
.msi_capable = false,
20092009
.msix_capable = false,
2010-
.reserved_bar = 1 << BAR_2 | 1 << BAR_3 | 1 << BAR_4 | 1 << BAR_5,
2011-
.bar_fixed_64bit = 1 << BAR_0,
2012-
.bar_fixed_size[0] = SZ_1M,
2010+
.bar[BAR_0] = { .type = BAR_FIXED, .fixed_size = SZ_1M,
2011+
.only_64bit = true, },
2012+
.bar[BAR_1] = { .type = BAR_RESERVED, },
2013+
.bar[BAR_2] = { .type = BAR_RESERVED, },
2014+
.bar[BAR_3] = { .type = BAR_RESERVED, },
2015+
.bar[BAR_4] = { .type = BAR_RESERVED, },
2016+
.bar[BAR_5] = { .type = BAR_RESERVED, },
20132017
};
20142018

20152019
static const struct pci_epc_features*

drivers/pci/controller/dwc/pcie-uniphier-ep.c

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -411,8 +411,12 @@ static const struct uniphier_pcie_ep_soc_data uniphier_pro5_data = {
411411
.msi_capable = true,
412412
.msix_capable = false,
413413
.align = 1 << 16,
414-
.bar_fixed_64bit = BIT(BAR_0) | BIT(BAR_2) | BIT(BAR_4),
415-
.reserved_bar = BIT(BAR_4),
414+
.bar[BAR_0] = { .only_64bit = true, },
415+
.bar[BAR_1] = { .type = BAR_RESERVED, },
416+
.bar[BAR_2] = { .only_64bit = true, },
417+
.bar[BAR_3] = { .type = BAR_RESERVED, },
418+
.bar[BAR_4] = { .type = BAR_RESERVED, .only_64bit = true, },
419+
.bar[BAR_5] = { .type = BAR_RESERVED, },
416420
},
417421
};
418422

@@ -425,7 +429,12 @@ static const struct uniphier_pcie_ep_soc_data uniphier_nx1_data = {
425429
.msi_capable = true,
426430
.msix_capable = false,
427431
.align = 1 << 12,
428-
.bar_fixed_64bit = BIT(BAR_0) | BIT(BAR_2) | BIT(BAR_4),
432+
.bar[BAR_0] = { .only_64bit = true, },
433+
.bar[BAR_1] = { .type = BAR_RESERVED, },
434+
.bar[BAR_2] = { .only_64bit = true, },
435+
.bar[BAR_3] = { .type = BAR_RESERVED, },
436+
.bar[BAR_4] = { .only_64bit = true, },
437+
.bar[BAR_5] = { .type = BAR_RESERVED, },
429438
},
430439
};
431440

drivers/pci/controller/pcie-rcar-ep.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -440,11 +440,15 @@ static const struct pci_epc_features rcar_pcie_epc_features = {
440440
.msi_capable = true,
441441
.msix_capable = false,
442442
/* use 64-bit BARs so mark BAR[1,3,5] as reserved */
443-
.reserved_bar = 1 << BAR_1 | 1 << BAR_3 | 1 << BAR_5,
444-
.bar_fixed_64bit = 1 << BAR_0 | 1 << BAR_2 | 1 << BAR_4,
445-
.bar_fixed_size[0] = 128,
446-
.bar_fixed_size[2] = 256,
447-
.bar_fixed_size[4] = 256,
443+
.bar[BAR_0] = { .type = BAR_FIXED, .fixed_size = 128,
444+
.only_64bit = true, },
445+
.bar[BAR_1] = { .type = BAR_RESERVED, },
446+
.bar[BAR_2] = { .type = BAR_FIXED, .fixed_size = 256,
447+
.only_64bit = true, },
448+
.bar[BAR_3] = { .type = BAR_RESERVED, },
449+
.bar[BAR_4] = { .type = BAR_FIXED, .fixed_size = 256,
450+
.only_64bit = true, },
451+
.bar[BAR_5] = { .type = BAR_RESERVED, },
448452
};
449453

450454
static const struct pci_epc_features*

drivers/pci/endpoint/functions/pci-epf-ntb.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1012,13 +1012,13 @@ static int epf_ntb_config_spad_bar_alloc(struct epf_ntb *ntb,
10121012

10131013
epc_features = ntb_epc->epc_features;
10141014
barno = ntb_epc->epf_ntb_bar[BAR_CONFIG];
1015-
size = epc_features->bar_fixed_size[barno];
1015+
size = epc_features->bar[barno].fixed_size;
10161016
align = epc_features->align;
10171017

10181018
peer_ntb_epc = ntb->epc[!type];
10191019
peer_epc_features = peer_ntb_epc->epc_features;
10201020
peer_barno = ntb_epc->epf_ntb_bar[BAR_PEER_SPAD];
1021-
peer_size = peer_epc_features->bar_fixed_size[peer_barno];
1021+
peer_size = peer_epc_features->bar[peer_barno].fixed_size;
10221022

10231023
/* Check if epc_features is populated incorrectly */
10241024
if ((!IS_ALIGNED(size, align)))

drivers/pci/endpoint/functions/pci-epf-test.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -729,7 +729,7 @@ static int pci_epf_test_set_bar(struct pci_epf *epf)
729729
*/
730730
add = (epf_bar->flags & PCI_BASE_ADDRESS_MEM_TYPE_64) ? 2 : 1;
731731

732-
if (!!(epc_features->reserved_bar & (1 << bar)))
732+
if (epc_features->bar[bar].type == BAR_RESERVED)
733733
continue;
734734

735735
ret = pci_epc_set_bar(epc, epf->func_no, epf->vfunc_no,
@@ -856,7 +856,7 @@ static int pci_epf_test_alloc_space(struct pci_epf *epf)
856856
if (bar == test_reg_bar)
857857
continue;
858858

859-
if (!!(epc_features->reserved_bar & (1 << bar)))
859+
if (epc_features->bar[bar].type == BAR_RESERVED)
860860
continue;
861861

862862
base = pci_epf_alloc_space(epf, bar_size[bar], bar,
@@ -874,13 +874,11 @@ static void pci_epf_configure_bar(struct pci_epf *epf,
874874
const struct pci_epc_features *epc_features)
875875
{
876876
struct pci_epf_bar *epf_bar;
877-
bool bar_fixed_64bit;
878877
int i;
879878

880879
for (i = 0; i < PCI_STD_NUM_BARS; i++) {
881880
epf_bar = &epf->bar[i];
882-
bar_fixed_64bit = !!(epc_features->bar_fixed_64bit & (1 << i));
883-
if (bar_fixed_64bit)
881+
if (epc_features->bar[i].only_64bit)
884882
epf_bar->flags |= PCI_BASE_ADDRESS_MEM_TYPE_64;
885883
}
886884
}

0 commit comments

Comments
 (0)