* PCI: altera: Fix TLP completion status
@ 2017-02-17 0:19 Yadi Hu
2017-02-17 0:19 ` [PATCH] PCI: altera: Check " Yadi Hu
0 siblings, 1 reply; 6+ messages in thread
From: Yadi Hu @ 2017-02-17 0:19 UTC (permalink / raw)
To: yadi.hu, lftan; +Cc: linux-pci, rfi
'Completion Status' value in TLP should be b15:13 while the fix is
using b14:12.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH] PCI: altera: Check TLP completion status
2017-02-17 0:19 PCI: altera: Fix TLP completion status Yadi Hu
@ 2017-02-17 0:19 ` Yadi Hu
2017-02-17 0:20 ` yhu2
0 siblings, 1 reply; 6+ messages in thread
From: Yadi Hu @ 2017-02-17 0:19 UTC (permalink / raw)
To: yadi.hu, lftan; +Cc: linux-pci, rfi
From: Ley Foon Tan <lftan@altera.com>
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.
[bhelgaas: simplify completion status checking code]
Signed-off-by: Ley Foon Tan <lftan@altera.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
drivers/pci/host/pcie-altera.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/drivers/pci/host/pcie-altera.c b/drivers/pci/host/pcie-altera.c
index ed736a9..072255d 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 (comp_status)
+ return PCIBIOS_DEVICE_NOT_FOUND;
+
if (value)
*value = reg0;
+
return PCIBIOS_SUCCESSFUL;
}
}
udelay(5);
}
- return -ENOENT;
+ return PCIBIOS_DEVICE_NOT_FOUND;
}
static void tlp_write_packet(struct altera_pcie *pcie, u32 *headers,
--
2.9.3
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] PCI: altera: Check TLP completion status
2017-02-17 0:19 ` [PATCH] PCI: altera: Check " Yadi Hu
@ 2017-02-17 0:20 ` yhu2
0 siblings, 0 replies; 6+ messages in thread
From: yhu2 @ 2017-02-17 0:20 UTC (permalink / raw)
To: lftan; +Cc: linux-pci, rfi
please ignore this letter
On 2017年02月17日 08:19, Yadi Hu wrote:
> From: Ley Foon Tan <lftan@altera.com>
>
> 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.
>
> [bhelgaas: simplify completion status checking code]
> Signed-off-by: Ley Foon Tan <lftan@altera.com>
> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
> ---
> drivers/pci/host/pcie-altera.c | 12 ++++++++++--
> 1 file changed, 10 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/pci/host/pcie-altera.c b/drivers/pci/host/pcie-altera.c
> index ed736a9..072255d 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 (comp_status)
> + return PCIBIOS_DEVICE_NOT_FOUND;
> +
> if (value)
> *value = reg0;
> +
> return PCIBIOS_SUCCESSFUL;
> }
> }
> udelay(5);
> }
>
> - return -ENOENT;
> + return PCIBIOS_DEVICE_NOT_FOUND;
> }
>
> static void tlp_write_packet(struct altera_pcie *pcie, u32 *headers,
^ permalink raw reply [flat|nested] 6+ messages in thread
* PCI: altera: Fix TLP completion status
@ 2017-02-17 0:27 Yadi Hu
0 siblings, 0 replies; 6+ messages in thread
From: Yadi Hu @ 2017-02-17 0:27 UTC (permalink / raw)
To: yadi.hu, lftan; +Cc: linux-pci, rfi
the upstream driver does not use exactly 'Completion Status' value
in TLP, these bits should be b15:13 not b14:12.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: PCI: altera: Fix TLP completion status
2017-02-16 9:54 yhu2
@ 2017-02-16 10:07 ` Ley Foon Tan
0 siblings, 0 replies; 6+ messages in thread
From: Ley Foon Tan @ 2017-02-16 10:07 UTC (permalink / raw)
To: yhu2; +Cc: linux-pci, Rocketboard Maillist
On Thu, Feb 16, 2017 at 5:54 PM, yhu2 <yadi.hu@windriver.com> wrote:
> PCI: altera: Fix TLP completion status
>
> 'Completion Status' value in TLP should be b15:13 while the fix is
> using b14:12
>
> Signed-off-by: Hu Yadi<yadi.hu@windriver.com>
> ---
> drivers/pci/host/pcie-altera.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
Please resubmit again with git send-email .
Thanks.
Regards
Ley Foon
^ permalink raw reply [flat|nested] 6+ messages in thread
* PCI: altera: Fix TLP completion status
@ 2017-02-16 9:54 yhu2
2017-02-16 10:07 ` Ley Foon Tan
0 siblings, 1 reply; 6+ messages in thread
From: yhu2 @ 2017-02-16 9:54 UTC (permalink / raw)
To: Ley Foon Tan; +Cc: linux-pci, rfi
[-- Attachment #1: Type: text/plain, Size: 260 bytes --]
PCI: altera: Fix TLP completion status
'Completion Status' value in TLP should be b15:13 while the fix is
using b14:12
Signed-off-by: Hu Yadi<yadi.hu@windriver.com>
---
drivers/pci/host/pcie-altera.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[-- Attachment #2: 0001-PCI-altera-Fix-TLP-completion-status.patch --]
[-- Type: text/x-patch, Size: 952 bytes --]
>From 6c7563a2bb2d46d60a089d5d326bf14a2d868d78 Mon Sep 17 00:00:00 2001
From: "Hu Yadi" <yadi.hu@windriver.com>
Date: Thu, 16 Feb 2017 01:50:11 -0800
Subject: [PATCH] PCI: altera: Fix TLP completion status
'Completion Status' value in TLP should be b15:13 while the fix is
using b14:12
Signed-off-by: Hu Yadi<yadi.hu@windriver.com>
---
drivers/pci/host/pcie-altera.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/pci/host/pcie-altera.c b/drivers/pci/host/pcie-altera.c
index dbac6fb..650862e 100644
--- a/drivers/pci/host/pcie-altera.c
+++ b/drivers/pci/host/pcie-altera.c
@@ -56,7 +56,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_COMP_STATUS(s) (((s) >> 13) & 7)
#define TLP_HDR_SIZE 3
#define TLP_LOOP 500
#define RP_DEVFN 0
--
2.9.3
^ permalink raw reply related [flat|nested] 6+ messages in thread
end of thread, other threads:[~2017-02-17 0:27 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-17 0:19 PCI: altera: Fix TLP completion status Yadi Hu
2017-02-17 0:19 ` [PATCH] PCI: altera: Check " Yadi Hu
2017-02-17 0:20 ` yhu2
-- strict thread matches above, loose matches on Subject: below --
2017-02-17 0:27 PCI: altera: Fix " Yadi Hu
2017-02-16 9:54 yhu2
2017-02-16 10:07 ` Ley Foon Tan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).