Skip to content

Commit d8c226a

Browse files
committed
Merge branch 'pci/controller/endpoint'
- Change "PCI Endpoint Virtual NTB driver" Kconfig prompt to be different from "PCI Endpoint NTB driver" (Shunsuke Mie) - Automatically create a function specific attributes group for endpoint drivers to avoid reference counting issues (Damien Le Moal) - Move and unexport pci_epf_type_add_cfs() (Damien Le Moal) - Reinitialize EPF test DMA transfer completion before submitting it to avoid losing the completion notification (Damien Le Moal) - Fix EPF test DMA transfer completion detection (Damien Le Moal) - Submit EPF test DMA transfers with dmaengine_submit(), not tx_submit() (Damien Le Moal) - Simplify EPF test read/write/copy functions (Damien Le Moal) - Simplify EPF test "raise IRQ" interface (Damien Le Moal) - Simplify EPF test IRQ command execution (Damien Le Moal) - Improve EPF test command/status register handling (Damien Le Moal) - Free IRQs before removing device (Damien Le Moal) - Reinitialize IRQ completions for every test (Damien Le Moal) - Don't write status in IRQ handler to avoid race (Damien Le Moal) - Fix dma_chan direction in data transfer test (Yoshihiro Shimoda) - Return pci_epf_type_add_cfs() error if EPF has no driver (Damien Le Moal) - Add kernel-doc for pci_epc_raise_irq() and pci_epc_map_msi_irq() MSI vector parameters (Manivannan Sadhasivam) - Pass EPF device ID to driver probe functions (Manivannan Sadhasivam) - Return -EALREADY if EPC has already been started/stopped (Manivannan Sadhasivam) - Add linkdown notifier support and use it in qcom-ep (Manivannan Sadhasivam) - Add Bus Master Enable event support and use it in qcom-ep (Manivannan Sadhasivam) - Add Qualcomm Modem Host Interface (MHI) endpoint driver (Manivannan Sadhasivam) - Add Layerscape PME interrupt handling to manage link-up notification (Frank Li) * pci/controller/endpoint: PCI: layerscape: Add the endpoint linkup notifier support PCI: endpoint: pci-epf-vntb: Fix typo in comments MAINTAINERS: Add PCI MHI endpoint function driver under MHI bus PCI: endpoint: Add PCI Endpoint function driver for MHI bus PCI: qcom-ep: Add support for BME notification PCI: qcom-ep: Add support for Link down notification PCI: endpoint: Add BME notifier support PCI: endpoint: Add linkdown notifier support PCI: endpoint: Return error if EPC is started/stopped multiple times PCI: endpoint: Pass EPF device ID to the probe function PCI: endpoint: Add missing documentation about the MSI/MSI-X range PCI: endpoint: Improve pci_epf_type_add_cfs() PCI: endpoint: functions/pci-epf-test: Fix dma_chan direction misc: pci_endpoint_test: Simplify pci_endpoint_test_msi_irq() misc: pci_endpoint_test: Do not write status in IRQ handler misc: pci_endpoint_test: Re-init completion for every test misc: pci_endpoint_test: Free IRQs before removing the device PCI: epf-test: Simplify transfers result print PCI: epf-test: Simplify DMA support checks PCI: epf-test: Cleanup request result handling PCI: epf-test: Cleanup pci_epf_test_cmd_handler() PCI: epf-test: Improve handling of command and status registers PCI: epf-test: Simplify IRQ test commands execution PCI: epf-test: Simplify pci_epf_test_raise_irq() PCI: epf-test: Simplify read/write/copy test functions PCI: epf-test: Use dmaengine_submit() to initiate DMA transfer PCI: epf-test: Fix DMA transfer completion detection PCI: epf-test: Fix DMA transfer completion initialization PCI: endpoint: Move pci_epf_type_add_cfs() code PCI: endpoint: Automatically create a function specific attributes group PCI: endpoint: Fix a Kconfig prompt of vNTB driver
2 parents b5abb12 + 061cbfa commit d8c226a

File tree

17 files changed

+848
-246
lines changed

17 files changed

+848
-246
lines changed

Documentation/PCI/endpoint/pci-ntb-howto.rst

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -88,13 +88,10 @@ commands can be used::
8888
# echo 0x104c > functions/pci_epf_ntb/func1/vendorid
8989
# echo 0xb00d > functions/pci_epf_ntb/func1/deviceid
9090

91-
In order to configure NTB specific attributes, a new sub-directory to func1
92-
should be created::
93-
94-
# mkdir functions/pci_epf_ntb/func1/pci_epf_ntb.0/
95-
96-
The NTB function driver will populate this directory with various attributes
97-
that can be configured by the user::
91+
The PCI endpoint framework also automatically creates a sub-directory in the
92+
function attribute directory. This sub-directory has the same name as the name
93+
of the function device and is populated with the following NTB specific
94+
attributes that can be configured by the user::
9895

9996
# ls functions/pci_epf_ntb/func1/pci_epf_ntb.0/
10097
db_count mw1 mw2 mw3 mw4 num_mws

Documentation/PCI/endpoint/pci-vntb-howto.rst

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -84,13 +84,10 @@ commands can be used::
8484
# echo 0x1957 > functions/pci_epf_vntb/func1/vendorid
8585
# echo 0x0809 > functions/pci_epf_vntb/func1/deviceid
8686

87-
In order to configure NTB specific attributes, a new sub-directory to func1
88-
should be created::
89-
90-
# mkdir functions/pci_epf_vntb/func1/pci_epf_vntb.0/
91-
92-
The NTB function driver will populate this directory with various attributes
93-
that can be configured by the user::
87+
The PCI endpoint framework also automatically creates a sub-directory in the
88+
function attribute directory. This sub-directory has the same name as the name
89+
of the function device and is populated with the following NTB specific
90+
attributes that can be configured by the user::
9491

9592
# ls functions/pci_epf_vntb/func1/pci_epf_vntb.0/
9693
db_count mw1 mw2 mw3 mw4 num_mws

MAINTAINERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13629,6 +13629,7 @@ T: git git://git.kernel.org/pub/scm/linux/kernel/git/mani/mhi.git
1362913629
F: Documentation/ABI/stable/sysfs-bus-mhi
1363013630
F: Documentation/mhi/
1363113631
F: drivers/bus/mhi/
13632+
F: drivers/pci/endpoint/functions/pci-epf-mhi.c
1363213633
F: include/linux/mhi.h
1363313634

1363413635
MICROBLAZE ARCHITECTURE

drivers/misc/pci_endpoint_test.c

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -159,10 +159,7 @@ static irqreturn_t pci_endpoint_test_irqhandler(int irq, void *dev_id)
159159
if (reg & STATUS_IRQ_RAISED) {
160160
test->last_irq = irq;
161161
complete(&test->irq_raised);
162-
reg &= ~STATUS_IRQ_RAISED;
163162
}
164-
pci_endpoint_test_writel(test, PCI_ENDPOINT_TEST_STATUS,
165-
reg);
166163

167164
return IRQ_HANDLED;
168165
}
@@ -316,21 +313,17 @@ static bool pci_endpoint_test_msi_irq(struct pci_endpoint_test *test,
316313
struct pci_dev *pdev = test->pdev;
317314

318315
pci_endpoint_test_writel(test, PCI_ENDPOINT_TEST_IRQ_TYPE,
319-
msix == false ? IRQ_TYPE_MSI :
320-
IRQ_TYPE_MSIX);
316+
msix ? IRQ_TYPE_MSIX : IRQ_TYPE_MSI);
321317
pci_endpoint_test_writel(test, PCI_ENDPOINT_TEST_IRQ_NUMBER, msi_num);
322318
pci_endpoint_test_writel(test, PCI_ENDPOINT_TEST_COMMAND,
323-
msix == false ? COMMAND_RAISE_MSI_IRQ :
324-
COMMAND_RAISE_MSIX_IRQ);
319+
msix ? COMMAND_RAISE_MSIX_IRQ :
320+
COMMAND_RAISE_MSI_IRQ);
325321
val = wait_for_completion_timeout(&test->irq_raised,
326322
msecs_to_jiffies(1000));
327323
if (!val)
328324
return false;
329325

330-
if (pci_irq_vector(pdev, msi_num - 1) == test->last_irq)
331-
return true;
332-
333-
return false;
326+
return pci_irq_vector(pdev, msi_num - 1) == test->last_irq;
334327
}
335328

336329
static int pci_endpoint_test_validate_xfer_params(struct device *dev,
@@ -729,6 +722,10 @@ static long pci_endpoint_test_ioctl(struct file *file, unsigned int cmd,
729722
struct pci_dev *pdev = test->pdev;
730723

731724
mutex_lock(&test->mutex);
725+
726+
reinit_completion(&test->irq_raised);
727+
test->last_irq = -ENODATA;
728+
732729
switch (cmd) {
733730
case PCITEST_BAR:
734731
bar = arg;
@@ -938,6 +935,9 @@ static void pci_endpoint_test_remove(struct pci_dev *pdev)
938935
if (id < 0)
939936
return;
940937

938+
pci_endpoint_test_release_irq(test);
939+
pci_endpoint_test_free_irq_vectors(test);
940+
941941
misc_deregister(&test->miscdev);
942942
kfree(misc_device->name);
943943
kfree(test->name);
@@ -947,9 +947,6 @@ static void pci_endpoint_test_remove(struct pci_dev *pdev)
947947
pci_iounmap(pdev, test->bar[bar]);
948948
}
949949

950-
pci_endpoint_test_release_irq(test);
951-
pci_endpoint_test_free_irq_vectors(test);
952-
953950
pci_release_regions(pdev);
954951
pci_disable_device(pdev);
955952
}

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

Lines changed: 99 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,20 @@
1818

1919
#include "pcie-designware.h"
2020

21+
#define PEX_PF0_CONFIG 0xC0014
22+
#define PEX_PF0_CFG_READY BIT(0)
23+
24+
/* PEX PFa PCIE PME and message interrupt registers*/
25+
#define PEX_PF0_PME_MES_DR 0xC0020
26+
#define PEX_PF0_PME_MES_DR_LUD BIT(7)
27+
#define PEX_PF0_PME_MES_DR_LDD BIT(9)
28+
#define PEX_PF0_PME_MES_DR_HRD BIT(10)
29+
30+
#define PEX_PF0_PME_MES_IER 0xC0028
31+
#define PEX_PF0_PME_MES_IER_LUDIE BIT(7)
32+
#define PEX_PF0_PME_MES_IER_LDDIE BIT(9)
33+
#define PEX_PF0_PME_MES_IER_HRDIE BIT(10)
34+
2135
#define to_ls_pcie_ep(x) dev_get_drvdata((x)->dev)
2236

2337
struct ls_pcie_ep_drvdata {
@@ -30,8 +44,84 @@ struct ls_pcie_ep {
3044
struct dw_pcie *pci;
3145
struct pci_epc_features *ls_epc;
3246
const struct ls_pcie_ep_drvdata *drvdata;
47+
int irq;
48+
bool big_endian;
3349
};
3450

51+
static u32 ls_lut_readl(struct ls_pcie_ep *pcie, u32 offset)
52+
{
53+
struct dw_pcie *pci = pcie->pci;
54+
55+
if (pcie->big_endian)
56+
return ioread32be(pci->dbi_base + offset);
57+
else
58+
return ioread32(pci->dbi_base + offset);
59+
}
60+
61+
static void ls_lut_writel(struct ls_pcie_ep *pcie, u32 offset, u32 value)
62+
{
63+
struct dw_pcie *pci = pcie->pci;
64+
65+
if (pcie->big_endian)
66+
iowrite32be(value, pci->dbi_base + offset);
67+
else
68+
iowrite32(value, pci->dbi_base + offset);
69+
}
70+
71+
static irqreturn_t ls_pcie_ep_event_handler(int irq, void *dev_id)
72+
{
73+
struct ls_pcie_ep *pcie = dev_id;
74+
struct dw_pcie *pci = pcie->pci;
75+
u32 val, cfg;
76+
77+
val = ls_lut_readl(pcie, PEX_PF0_PME_MES_DR);
78+
ls_lut_writel(pcie, PEX_PF0_PME_MES_DR, val);
79+
80+
if (!val)
81+
return IRQ_NONE;
82+
83+
if (val & PEX_PF0_PME_MES_DR_LUD) {
84+
cfg = ls_lut_readl(pcie, PEX_PF0_CONFIG);
85+
cfg |= PEX_PF0_CFG_READY;
86+
ls_lut_writel(pcie, PEX_PF0_CONFIG, cfg);
87+
dw_pcie_ep_linkup(&pci->ep);
88+
89+
dev_dbg(pci->dev, "Link up\n");
90+
} else if (val & PEX_PF0_PME_MES_DR_LDD) {
91+
dev_dbg(pci->dev, "Link down\n");
92+
} else if (val & PEX_PF0_PME_MES_DR_HRD) {
93+
dev_dbg(pci->dev, "Hot reset\n");
94+
}
95+
96+
return IRQ_HANDLED;
97+
}
98+
99+
static int ls_pcie_ep_interrupt_init(struct ls_pcie_ep *pcie,
100+
struct platform_device *pdev)
101+
{
102+
u32 val;
103+
int ret;
104+
105+
pcie->irq = platform_get_irq_byname(pdev, "pme");
106+
if (pcie->irq < 0)
107+
return pcie->irq;
108+
109+
ret = devm_request_irq(&pdev->dev, pcie->irq, ls_pcie_ep_event_handler,
110+
IRQF_SHARED, pdev->name, pcie);
111+
if (ret) {
112+
dev_err(&pdev->dev, "Can't register PCIe IRQ\n");
113+
return ret;
114+
}
115+
116+
/* Enable interrupts */
117+
val = ls_lut_readl(pcie, PEX_PF0_PME_MES_IER);
118+
val |= PEX_PF0_PME_MES_IER_LDDIE | PEX_PF0_PME_MES_IER_HRDIE |
119+
PEX_PF0_PME_MES_IER_LUDIE;
120+
ls_lut_writel(pcie, PEX_PF0_PME_MES_IER, val);
121+
122+
return 0;
123+
}
124+
35125
static const struct pci_epc_features*
36126
ls_pcie_ep_get_features(struct dw_pcie_ep *ep)
37127
{
@@ -125,6 +215,7 @@ static int __init ls_pcie_ep_probe(struct platform_device *pdev)
125215
struct ls_pcie_ep *pcie;
126216
struct pci_epc_features *ls_epc;
127217
struct resource *dbi_base;
218+
int ret;
128219

129220
pcie = devm_kzalloc(dev, sizeof(*pcie), GFP_KERNEL);
130221
if (!pcie)
@@ -144,6 +235,7 @@ static int __init ls_pcie_ep_probe(struct platform_device *pdev)
144235
pci->ops = pcie->drvdata->dw_pcie_ops;
145236

146237
ls_epc->bar_fixed_64bit = (1 << BAR_2) | (1 << BAR_4);
238+
ls_epc->linkup_notifier = true;
147239

148240
pcie->pci = pci;
149241
pcie->ls_epc = ls_epc;
@@ -155,9 +247,15 @@ static int __init ls_pcie_ep_probe(struct platform_device *pdev)
155247

156248
pci->ep.ops = &ls_pcie_ep_ops;
157249

250+
pcie->big_endian = of_property_read_bool(dev->of_node, "big-endian");
251+
158252
platform_set_drvdata(pdev, pcie);
159253

160-
return dw_pcie_ep_init(&pci->ep);
254+
ret = dw_pcie_ep_init(&pci->ep);
255+
if (ret)
256+
return ret;
257+
258+
return ls_pcie_ep_interrupt_init(pcie, pdev);
161259
}
162260

163261
static struct platform_driver ls_pcie_ep_driver = {

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -569,9 +569,11 @@ static irqreturn_t qcom_pcie_ep_global_irq_thread(int irq, void *data)
569569
if (FIELD_GET(PARF_INT_ALL_LINK_DOWN, status)) {
570570
dev_dbg(dev, "Received Linkdown event\n");
571571
pcie_ep->link_status = QCOM_PCIE_EP_LINK_DOWN;
572+
pci_epc_linkdown(pci->ep.epc);
572573
} else if (FIELD_GET(PARF_INT_ALL_BME, status)) {
573574
dev_dbg(dev, "Received BME event. Link is enabled!\n");
574575
pcie_ep->link_status = QCOM_PCIE_EP_LINK_ENABLED;
576+
pci_epc_bme_notify(pci->ep.epc);
575577
} else if (FIELD_GET(PARF_INT_ALL_PM_TURNOFF, status)) {
576578
dev_dbg(dev, "Received PM Turn-off event! Entering L23\n");
577579
val = readl_relaxed(pcie_ep->parf + PARF_PM_CTRL);

drivers/pci/endpoint/functions/Kconfig

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ config PCI_EPF_NTB
2727
If in doubt, say "N" to disable Endpoint NTB driver.
2828

2929
config PCI_EPF_VNTB
30-
tristate "PCI Endpoint NTB driver"
30+
tristate "PCI Endpoint Virtual NTB driver"
3131
depends on PCI_ENDPOINT
3232
depends on NTB
3333
select CONFIGFS_FS
@@ -37,3 +37,13 @@ config PCI_EPF_VNTB
3737
between PCI Root Port and PCIe Endpoint.
3838

3939
If in doubt, say "N" to disable Endpoint NTB driver.
40+
41+
config PCI_EPF_MHI
42+
tristate "PCI Endpoint driver for MHI bus"
43+
depends on PCI_ENDPOINT && MHI_BUS_EP
44+
help
45+
Enable this configuration option to enable the PCI Endpoint
46+
driver for Modem Host Interface (MHI) bus in Qualcomm Endpoint
47+
devices such as SDX55.
48+
49+
If in doubt, say "N" to disable Endpoint driver for MHI bus.

drivers/pci/endpoint/functions/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@
66
obj-$(CONFIG_PCI_EPF_TEST) += pci-epf-test.o
77
obj-$(CONFIG_PCI_EPF_NTB) += pci-epf-ntb.o
88
obj-$(CONFIG_PCI_EPF_VNTB) += pci-epf-vntb.o
9+
obj-$(CONFIG_PCI_EPF_MHI) += pci-epf-mhi.o

0 commit comments

Comments
 (0)