aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLogan Gunthorpe <logang@deltatee.com>2017-11-29 12:55:25 -0500
committerJon Mason <jdmason@kudzu.us>2018-01-28 22:17:23 -0500
commitc3585cd8708edb1c16fa84f8f3dee31741a66a9e (patch)
tree7a7ce399a6d8ce8d6a820bb642b0fa4dddc04fb2
parent3df54c870f52b4c47b53eead8d22a109f741b91c (diff)
ntb_hw_switchtec: Keep track of the number of LUT windows used by the driver
This is a prep patch in order to support the crosslink feature which will require the driver to use another reserved LUT window. To simplify this, we add some code to track the number of reserved LUT windows in use instead of assuming this is always 1. Signed-off-by: Logan Gunthorpe <logang@deltatee.com> Signed-off-by: Jon Mason <jdmason@kudzu.us>
-rw-r--r--drivers/ntb/hw/mscc/ntb_hw_switchtec.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/drivers/ntb/hw/mscc/ntb_hw_switchtec.c b/drivers/ntb/hw/mscc/ntb_hw_switchtec.c
index 088ae220ecb4..51fec6497164 100644
--- a/drivers/ntb/hw/mscc/ntb_hw_switchtec.c
+++ b/drivers/ntb/hw/mscc/ntb_hw_switchtec.c
@@ -109,6 +109,7 @@ struct switchtec_ntb {
109 109
110 int nr_direct_mw; 110 int nr_direct_mw;
111 int nr_lut_mw; 111 int nr_lut_mw;
112 int nr_rsvd_luts;
112 int direct_mw_to_bar[MAX_DIRECT_MW]; 113 int direct_mw_to_bar[MAX_DIRECT_MW];
113 114
114 int peer_nr_direct_mw; 115 int peer_nr_direct_mw;
@@ -197,7 +198,7 @@ static int switchtec_ntb_mw_count(struct ntb_dev *ntb, int pidx)
197{ 198{
198 struct switchtec_ntb *sndev = ntb_sndev(ntb); 199 struct switchtec_ntb *sndev = ntb_sndev(ntb);
199 int nr_direct_mw = sndev->peer_nr_direct_mw; 200 int nr_direct_mw = sndev->peer_nr_direct_mw;
200 int nr_lut_mw = sndev->peer_nr_lut_mw - 1; 201 int nr_lut_mw = sndev->peer_nr_lut_mw - sndev->nr_rsvd_luts;
201 202
202 if (pidx != NTB_DEF_PEER_IDX) 203 if (pidx != NTB_DEF_PEER_IDX)
203 return -EINVAL; 204 return -EINVAL;
@@ -210,12 +211,12 @@ static int switchtec_ntb_mw_count(struct ntb_dev *ntb, int pidx)
210 211
211static int lut_index(struct switchtec_ntb *sndev, int mw_idx) 212static int lut_index(struct switchtec_ntb *sndev, int mw_idx)
212{ 213{
213 return mw_idx - sndev->nr_direct_mw + 1; 214 return mw_idx - sndev->nr_direct_mw + sndev->nr_rsvd_luts;
214} 215}
215 216
216static int peer_lut_index(struct switchtec_ntb *sndev, int mw_idx) 217static int peer_lut_index(struct switchtec_ntb *sndev, int mw_idx)
217{ 218{
218 return mw_idx - sndev->peer_nr_direct_mw + 1; 219 return mw_idx - sndev->peer_nr_direct_mw + sndev->nr_rsvd_luts;
219} 220}
220 221
221static int switchtec_ntb_mw_get_align(struct ntb_dev *ntb, int pidx, 222static int switchtec_ntb_mw_get_align(struct ntb_dev *ntb, int pidx,
@@ -355,8 +356,9 @@ static int switchtec_ntb_mw_set_trans(struct ntb_dev *ntb, int pidx, int widx,
355static int switchtec_ntb_peer_mw_count(struct ntb_dev *ntb) 356static int switchtec_ntb_peer_mw_count(struct ntb_dev *ntb)
356{ 357{
357 struct switchtec_ntb *sndev = ntb_sndev(ntb); 358 struct switchtec_ntb *sndev = ntb_sndev(ntb);
359 int nr_lut_mw = sndev->nr_lut_mw - sndev->nr_rsvd_luts;
358 360
359 return sndev->nr_direct_mw + (use_lut_mws ? sndev->nr_lut_mw - 1 : 0); 361 return sndev->nr_direct_mw + (use_lut_mws ? nr_lut_mw : 0);
360} 362}
361 363
362static int switchtec_ntb_direct_get_addr(struct switchtec_ntb *sndev, 364static int switchtec_ntb_direct_get_addr(struct switchtec_ntb *sndev,
@@ -1008,6 +1010,7 @@ static int switchtec_ntb_init_shared_mw(struct switchtec_ntb *sndev)
1008 u32 ctl_val; 1010 u32 ctl_val;
1009 int rc; 1011 int rc;
1010 1012
1013 sndev->nr_rsvd_luts++;
1011 sndev->self_shared = dma_zalloc_coherent(&sndev->stdev->pdev->dev, 1014 sndev->self_shared = dma_zalloc_coherent(&sndev->stdev->pdev->dev,
1012 LUT_SIZE, 1015 LUT_SIZE,
1013 &sndev->self_shared_dma, 1016 &sndev->self_shared_dma,
@@ -1074,6 +1077,7 @@ static void switchtec_ntb_deinit_shared_mw(struct switchtec_ntb *sndev)
1074 dma_free_coherent(&sndev->stdev->pdev->dev, LUT_SIZE, 1077 dma_free_coherent(&sndev->stdev->pdev->dev, LUT_SIZE,
1075 sndev->self_shared, 1078 sndev->self_shared,
1076 sndev->self_shared_dma); 1079 sndev->self_shared_dma);
1080 sndev->nr_rsvd_luts--;
1077} 1081}
1078 1082
1079static irqreturn_t switchtec_ntb_doorbell_isr(int irq, void *dev) 1083static irqreturn_t switchtec_ntb_doorbell_isr(int irq, void *dev)