Skip to contentSkip to conversation

ib_srp: initialize dma_length in srp_map_idb

PATCH In review Christoph Hellwig 5 participants 7 messages Nov 15, 2015 – Nov 16, 2015 2 messages not in the archive

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ib_srp: initialize dma_length in srp_map_idb

Without this sg_dma_len will return 0 on architectures tha have the dma_length field.

---
 drivers/infiniband/ulp/srp/ib_srp.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/infiniband/ulp/srp/ib_srp.c +3 -0
index 32f7962..445c0a6 100644
@@ -1520,6 +1520,9 @@ static int srp_map_idb(struct srp_rdma_ch *ch, struct srp_request *req,
 		state.sg_nents = 1;
 		sg_set_buf(idb_sg, req->indirect_desc, idb_len);
 		idb_sg->dma_address = req->indirect_dma_addr; /* hack! */
+#ifdef CONFIG_NEED_SG_DMA_LENGTH
+		idb_sg->dma_length = idb_sg->length;	      /* hack^2 */
+#endif
 		ret = srp_map_finish_fr(&state, ch);
 		if (ret < 0)
 			return ret;
Signature · 1 line
1.9.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 13 lines · Christoph Hellwig

Without this sg_dma_len will return 0 on architectures tha have the dma_length field.

---
  drivers/infiniband/ulp/srp/ib_srp.c | 3 +++
  1 file changed, 3 insertions(+)
drivers/infiniband/ulp/srp/ib_srp.c +0 -0
index 32f7962..445c0a6 100644

drivers/infiniband/ulp/srp/ib_srp.c static int srp_map_idb(struct srp_rdma_ch *ch, struct srp_request *req, · line 1525

Quoted 6 lines
drivers/infiniband/ulp/srp/ib_srp.c +3 -0
@@ -1520,6 +1520,9 @@ static int srp_map_idb(struct srp_rdma_ch *ch, struct srp_request *req,
  		state.sg_nents = 1;
  		sg_set_buf(idb_sg, req->indirect_desc, idb_len);
  		idb_sg->dma_address = req->indirect_dma_addr; /* hack! */
+#ifdef CONFIG_NEED_SG_DMA_LENGTH
+		idb_sg->dma_length = idb_sg->length;	      /* hack^2 */
+#endif

:)

We should really get this properly map/unmap per IO at some point. Probably do it in both code paths...

Having said that,

Looks fine,

A message that is not in the archive (sent off-list or not yet received): 5648CD03.4000206-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org

#3 lore raw
Quoted 4 lines · Sagi Grimberg
Quoted 2 lines · Christoph Hellwig

Without this sg_dma_len will return 0 on architectures tha have the dma_length field.

and what wrong with that?

Christoph, probably typo here? "tha" needs to be "that"

Quoted 22 lines
Quoted 11 lines
---
  drivers/infiniband/ulp/srp/ib_srp.c | 3 +++
  1 file changed, 3 insertions(+)
drivers/infiniband/ulp/srp/ib_srp.c +0 -0
index 32f7962..445c0a6 100644

drivers/infiniband/ulp/srp/ib_srp.c static int srp_map_idb(struct srp_rdma_ch *ch, · line 1526

Quoted 7 lines
drivers/infiniband/ulp/srp/ib_srp.c +3 -0
@@ -1520,6 +1520,9 @@ static int srp_map_idb(struct srp_rdma_ch *ch,
 struct srp_request *req,
                state.sg_nents = 1;
                sg_set_buf(idb_sg, req->indirect_desc, idb_len);
                idb_sg->dma_address = req->indirect_dma_addr; /* hack! */
+#ifdef CONFIG_NEED_SG_DMA_LENGTH
+               idb_sg->dma_length = idb_sg->length;          /* hack^2 */
+#endif

:)

Quoted 2 lines

We should really get this properly map/unmap per IO at some point. Probably do it in both code paths...

Sagi, can you please elaborate a little further on the problem, srpt WA, what do we do in isert and what is the proposed not WA solution?

Quoted 3 lines

Having said that,
Looks fine,

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#4 lore raw
Quoted 7 lines · Or Gerlitz
Quoted 4 lines · Sagi Grimberg
Quoted 2 lines · Christoph Hellwig

Without this sg_dma_len will return 0 on architectures tha have the dma_length field.

and what wrong with that?

Because it's not length 0. It's because I did a (documented) hack with the new memory registration API. I hope we can fix it soon.

Quoted 25 lines

Christoph, probably typo here? "tha" needs to be "that"

Quoted 22 lines
Quoted 11 lines
---
   drivers/infiniband/ulp/srp/ib_srp.c | 3 +++
   1 file changed, 3 insertions(+)
drivers/infiniband/ulp/srp/ib_srp.c +0 -0
index 32f7962..445c0a6 100644

drivers/infiniband/ulp/srp/ib_srp.c static int srp_map_idb(struct srp_rdma_ch *ch, · line 1526

Quoted 7 lines
drivers/infiniband/ulp/srp/ib_srp.c +3 -0
@@ -1520,6 +1520,9 @@ static int srp_map_idb(struct srp_rdma_ch *ch,
 struct srp_request *req,
                 state.sg_nents = 1;
                 sg_set_buf(idb_sg, req->indirect_desc, idb_len);
                 idb_sg->dma_address = req->indirect_dma_addr; /* hack! */
+#ifdef CONFIG_NEED_SG_DMA_LENGTH
+               idb_sg->dma_length = idb_sg->length;          /* hack^2 */
+#endif

:)

Quoted 5 lines
Quoted 2 lines

We should really get this properly map/unmap per IO at some point. Probably do it in both code paths...

Sagi, can you please elaborate a little further on the problem, srpt WA,

It's srp initiator. This falls in the case where srp sends an indirect buffer descriptor to the target (which is registered). For this descriptor it uses a pre-dma-mapped buffer, so in order to fit it into the new memory registration scheme (which works on SG lists), I hacked a single entry SG and used the pre-dma-mapped address. What was missing is the dma_length setting (because we didn't dma mapped the SG).

The proper fix is doing correct map/unmap per IO.

Quoted 1 line

what do we do in isert and what is the proposed not WA solution?

iser does not have indirect buffer descriptors, only a single rkey (per-direction).

A message that is not in the archive (sent off-list or not yet received): 1447610393-2899-1-git-send-email-hch-jcswGhMUV9g@public.gmane.org

#6 lore raw
Quoted 14 lines · Christoph Hellwig

Without this sg_dma_len will return 0 on architectures tha have the dma_length field.

---
  drivers/infiniband/ulp/srp/ib_srp.c | 3 +++
  1 file changed, 3 insertions(+)
drivers/infiniband/ulp/srp/ib_srp.c +0 -0
index 32f7962..445c0a6 100644

drivers/infiniband/ulp/srp/ib_srp.c static int srp_map_idb(struct srp_rdma_ch *ch, struct srp_request *req, · line 1528

Quoted 9 lines
drivers/infiniband/ulp/srp/ib_srp.c +3 -0
@@ -1520,6 +1520,9 @@ static int srp_map_idb(struct srp_rdma_ch *ch, struct srp_request *req,
  		state.sg_nents = 1;
  		sg_set_buf(idb_sg, req->indirect_desc, idb_len);
  		idb_sg->dma_address = req->indirect_dma_addr; /* hack! */
+#ifdef CONFIG_NEED_SG_DMA_LENGTH
+		idb_sg->dma_length = idb_sg->length;	      /* hack^2 */
+#endif
  		ret = srp_map_finish_fr(&state, ch);
  		if (ret < 0)
  			return ret;

Hello Christoph,

How about adding "Cc: stable" to this patch such that it not only will be integrated in kernel v4.4 but also in kernel v4.3.1 or later ?

Thanks,

Bart.
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#7 lore raw

Hi Bart,

the code in this area changed enough since 4.3 that it won't easily apply. But a backport would still be very useful!