diff options
author | Trevor Bunker <trevorbunker@google.com> | 2017-10-11 15:22:58 -0700 |
---|---|---|
committer | Trevor Bunker <trevorbunker@google.com> | 2017-11-06 20:04:20 -0800 |
commit | 9620e9dda7ccf3c19ea8de047147da2b8ca0ce2c (patch) | |
tree | 4e03f59e9fd8b62752dcac8113bb93a981687d19 | |
parent | f01453811b499d69eeb0f992454e33e98e3d2f7f (diff) | |
download | arm64-9620e9dda7ccf3c19ea8de047147da2b8ca0ce2c.tar.gz |
mnh_pcie_ep: check for grant after msi request
Bug: 68210429
Change-Id: I82814ff1d74401e4a158a2fc81c7bdb4d04fcb47
Signed-off-by: Trevor Bunker <trevorbunker@google.com>
-rwxr-xr-x | drivers/pcie_ep/mnh_pcie_ep.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/drivers/pcie_ep/mnh_pcie_ep.c b/drivers/pcie_ep/mnh_pcie_ep.c index f95e85dbad8c..3d0270c643ab 100755 --- a/drivers/pcie_ep/mnh_pcie_ep.c +++ b/drivers/pcie_ep/mnh_pcie_ep.c @@ -61,6 +61,8 @@ #define VENDOR_ID 0x8086 #define DEVICE_ID 0x3140 +/* timeout for msi request to grant, in microseconds */ +#define MSI_REQUEST_TIMEOUT 50 #define COMBINE_SG 1 @@ -307,6 +309,7 @@ static void release_link(void) static int pcie_send_msi_p(uint32_t msi) { uint32_t tc, data, msg; + int timeout; data = CSR_IN(PCIE_MSI_TRIG) & CSR_MASK(PCIE_MSI_TRIG, PCIE_VEN_MSI_REQ); @@ -320,6 +323,21 @@ static int pcie_send_msi_p(uint32_t msi) data |= tc | msg; CSR_OUT(PCIE_MSI_TRIG, data); CSR_OUTf(PCIE_MSI_TRIG, PCIE_VEN_MSI_REQ, 1); + + /* make sure the request was granted, takes 20-40 usecs */ + usleep_range(15, 20); + for (timeout = 0; timeout < MSI_REQUEST_TIMEOUT; timeout++) { + if (!CSR_INf(PCIE_MSI_TRIG, PCIE_VEN_MSI_REQ)) + break; + + udelay(1); + } + + if (CSR_INf(PCIE_MSI_TRIG, PCIE_VEN_MSI_REQ)) { + dev_err(pcie_ep_dev->dev, "%s: send msi timeout\n", __func__); + return -ETIMEDOUT; + } + return 0; } |