diff options
author | Logan Gunthorpe <logang@deltatee.com> | 2016-06-07 13:20:22 -0400 |
---|---|---|
committer | Jon Mason <jdmason@kudzu.us> | 2016-08-05 10:21:06 -0400 |
commit | 19645a077120c6417e9dc5ad469c45194cf78a82 (patch) | |
tree | 41676f4b27a17fb9b75ba47b33f0bdf6756adcf6 | |
parent | 8b71d285061181f91194114cc7dabce73185eed1 (diff) |
ntb_transport: Check the number of spads the hardware supports
I'm working on hardware that currently has a limited number of
scratchpad registers and ntb_ndev fails with no clue as to why. I
feel it is better to fail early and provide a reasonable error message
then to fail later on.
The same is done to ntb_perf, but it doesn't currently require enough
spads to actually fail. I've also removed the unused SPAD_MSG and
SPAD_ACK enums so that MAX_SPAD accurately reflects the number of
spads used.
Signed-off-by: Logan Gunthorpe <logang@deltatee.com>
Acked-by: Dave Jiang <dave.jiang@intel.com>
Signed-off-by: Jon Mason <jdmason@kudzu.us>
-rw-r--r-- | drivers/ntb/ntb_transport.c | 9 | ||||
-rw-r--r-- | drivers/ntb/test/ntb_perf.c | 8 |
2 files changed, 13 insertions, 4 deletions
diff --git a/drivers/ntb/ntb_transport.c b/drivers/ntb/ntb_transport.c index 6db8c8528f26..d5c5894f252e 100644 --- a/drivers/ntb/ntb_transport.c +++ b/drivers/ntb/ntb_transport.c | |||
@@ -1060,6 +1060,13 @@ static int ntb_transport_probe(struct ntb_client *self, struct ntb_dev *ndev) | |||
1060 | int node; | 1060 | int node; |
1061 | int rc, i; | 1061 | int rc, i; |
1062 | 1062 | ||
1063 | mw_count = ntb_mw_count(ndev); | ||
1064 | if (ntb_spad_count(ndev) < (NUM_MWS + 1 + mw_count * 2)) { | ||
1065 | dev_err(&ndev->dev, "Not enough scratch pad registers for %s", | ||
1066 | NTB_TRANSPORT_NAME); | ||
1067 | return -EIO; | ||
1068 | } | ||
1069 | |||
1063 | if (ntb_db_is_unsafe(ndev)) | 1070 | if (ntb_db_is_unsafe(ndev)) |
1064 | dev_dbg(&ndev->dev, | 1071 | dev_dbg(&ndev->dev, |
1065 | "doorbell is unsafe, proceed anyway...\n"); | 1072 | "doorbell is unsafe, proceed anyway...\n"); |
@@ -1075,8 +1082,6 @@ static int ntb_transport_probe(struct ntb_client *self, struct ntb_dev *ndev) | |||
1075 | 1082 | ||
1076 | nt->ndev = ndev; | 1083 | nt->ndev = ndev; |
1077 | 1084 | ||
1078 | mw_count = ntb_mw_count(ndev); | ||
1079 | |||
1080 | nt->mw_count = mw_count; | 1085 | nt->mw_count = mw_count; |
1081 | 1086 | ||
1082 | nt->mw_vec = kzalloc_node(mw_count * sizeof(*nt->mw_vec), | 1087 | nt->mw_vec = kzalloc_node(mw_count * sizeof(*nt->mw_vec), |
diff --git a/drivers/ntb/test/ntb_perf.c b/drivers/ntb/test/ntb_perf.c index 30635c89320c..4368519da102 100644 --- a/drivers/ntb/test/ntb_perf.c +++ b/drivers/ntb/test/ntb_perf.c | |||
@@ -143,8 +143,6 @@ enum { | |||
143 | VERSION = 0, | 143 | VERSION = 0, |
144 | MW_SZ_HIGH, | 144 | MW_SZ_HIGH, |
145 | MW_SZ_LOW, | 145 | MW_SZ_LOW, |
146 | SPAD_MSG, | ||
147 | SPAD_ACK, | ||
148 | MAX_SPAD | 146 | MAX_SPAD |
149 | }; | 147 | }; |
150 | 148 | ||
@@ -696,6 +694,12 @@ static int perf_probe(struct ntb_client *client, struct ntb_dev *ntb) | |||
696 | int node; | 694 | int node; |
697 | int rc = 0; | 695 | int rc = 0; |
698 | 696 | ||
697 | if (ntb_spad_count(ntb) < MAX_SPAD) { | ||
698 | dev_err(&ntb->dev, "Not enough scratch pad registers for %s", | ||
699 | DRIVER_NAME); | ||
700 | return -EIO; | ||
701 | } | ||
702 | |||
699 | node = dev_to_node(&pdev->dev); | 703 | node = dev_to_node(&pdev->dev); |
700 | 704 | ||
701 | perf = kzalloc_node(sizeof(*perf), GFP_KERNEL, node); | 705 | perf = kzalloc_node(sizeof(*perf), GFP_KERNEL, node); |