Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1282954
| From | Ley Foon Tan <lftan@altera.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH 2/3] PCI: altera: check TLP completion status |
| Date | 2015-12-03 12:20 +0100 |
| Message-ID | <qBA5A-4dT-19@gated-at.bofh.it> (permalink) |
| References | <qBA5A-4dT-5@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
Check TLP packet successful completion status. This fix the issue when
accessing multi-function devices in enumeration process, TLP will return
error when accessing non-exist function number. Returns PCI error code
instead of generic errno.
Tested on Ethernet adapter card with multi-functions.
Signed-off-by: Ley Foon Tan <lftan@altera.com>
---
drivers/pci/host/pcie-altera.c | 18 +++++++++++++-----
1 file changed, 13 insertions(+), 5 deletions(-)
diff --git a/drivers/pci/host/pcie-altera.c b/drivers/pci/host/pcie-altera.c
index f05180f..e4176b3 100644
--- a/drivers/pci/host/pcie-altera.c
+++ b/drivers/pci/host/pcie-altera.c
@@ -55,6 +55,7 @@
#define TLP_CFG_DW2(bus, devfn, offset) \
(((bus) << 24) | ((devfn) << 16) | (offset))
#define TLP_REQ_ID(bus, devfn) (((bus) << 8) | (devfn))
+#define TLP_COMP_STATUS(s) (((s) >> 12) & 7)
#define TLP_HDR_SIZE 3
#define TLP_LOOP 500
#define RP_DEVFN 0
@@ -171,6 +172,7 @@ static int tlp_read_packet(struct altera_pcie *pcie, u32 *value)
bool sop = 0;
u32 ctrl;
u32 reg0, reg1;
+ u32 comp_status = 1;
/*
* Minimum 2 loops to read TLP headers and 1 loop to read data
@@ -182,19 +184,25 @@ static int tlp_read_packet(struct altera_pcie *pcie, u32 *value)
reg0 = cra_readl(pcie, RP_RXCPL_REG0);
reg1 = cra_readl(pcie, RP_RXCPL_REG1);
- if (ctrl & RP_RXCPL_SOP)
+ if (ctrl & RP_RXCPL_SOP) {
sop = true;
+ comp_status = TLP_COMP_STATUS(reg1);
+ }
if (ctrl & RP_RXCPL_EOP) {
- if (value)
- *value = reg0;
- return PCIBIOS_SUCCESSFUL;
+ if (!comp_status) {
+ if (value)
+ *value = reg0;
+ return PCIBIOS_SUCCESSFUL;
+ } else {
+ return PCIBIOS_DEVICE_NOT_FOUND;
+ }
}
}
udelay(5);
}
- return -ENOENT;
+ return PCIBIOS_DEVICE_NOT_FOUND;
}
static void tlp_write_packet(struct altera_pcie *pcie, u32 *headers,
--
1.8.2.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH 0/3] fixes to support multi-functions device Ley Foon Tan <lftan@altera.com> - 2015-12-03 12:20 +0100
[PATCH 3/3] PCI: altera: fix error when INTX is 4 Ley Foon Tan <lftan@altera.com> - 2015-12-03 12:20 +0100
[PATCH 2/3] PCI: altera: check TLP completion status Ley Foon Tan <lftan@altera.com> - 2015-12-03 12:20 +0100
Re: [PATCH 0/3] fixes to support multi-functions device Bjorn Helgaas <helgaas@kernel.org> - 2015-12-04 23:30 +0100
Re: [PATCH 0/3] fixes to support multi-functions device Ley Foon Tan <lftan@altera.com> - 2015-12-07 02:50 +0100
csiph-web