Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 87fc34b5 authored by Michael J. Ruhl's avatar Michael J. Ruhl Committed by Doug Ledford
Browse files

IB/{hfi1,qib}: Cleanup open coded sge sizing



Sge sizing is done in several places using an open coded method.

This can cause maintenance issues.  The open coded method is
encapsulated in a helper routine.  The helper was introduced with
commit:

1198fcea ("IB/hfi1, rdmavt: Move SGE state helper routines into
rdmavt")

Update all call sites that have the open coded path with the helper
routine.

Reviewed-by: default avatarMike Marciniszyn <mike.marciniszyn@intel.com>
Signed-off-by: default avatarMichael J. Ruhl <michael.j.ruhl@intel.com>
Signed-off-by: default avatarDennis Dalessandro <dennis.dalessandro@intel.com>
Signed-off-by: default avatarDoug Ledford <dledford@redhat.com>
parent ed0bc265
Loading
Loading
Loading
Loading
+2 −10
Original line number Diff line number Diff line
@@ -553,11 +553,7 @@ static noinline int build_verbs_ulp_payload(
	int ret = 0;

	while (length) {
		len = ss->sge.length;
		if (len > length)
			len = length;
		if (len > ss->sge.sge_length)
			len = ss->sge.sge_length;
		len = rvt_get_sge_length(&ss->sge, length);
		WARN_ON_ONCE(len == 0);
		ret = sdma_txadd_kvaddr(
			sde->dd,
@@ -914,12 +910,8 @@ int hfi1_verbs_send_pio(struct rvt_qp *qp, struct hfi1_pkt_state *ps,
		if (ss) {
			while (len) {
				void *addr = ss->sge.vaddr;
				u32 slen = ss->sge.length;
				u32 slen = rvt_get_sge_length(&ss->sge, len);

				if (slen > len)
					slen = len;
				if (slen > ss->sge.sge_length)
					slen = ss->sge.sge_length;
				rvt_update_sge(ss, slen, false);
				seg_pio_copy_mid(pbuf, addr, slen);
				len -= slen;
+1 −5
Original line number Diff line number Diff line
@@ -172,12 +172,8 @@ static void qib_ud_loopback(struct rvt_qp *sqp, struct rvt_swqe *swqe)
	ssge.num_sge = swqe->wr.num_sge;
	sge = &ssge.sge;
	while (length) {
		u32 len = sge->length;
		u32 len = rvt_get_sge_length(sge, length);

		if (len > length)
			len = length;
		if (len > sge->sge_length)
			len = sge->sge_length;
		rvt_copy_sge(qp, &qp->r_sge, sge->vaddr, len, true, false);
		sge->vaddr += len;
		sge->length -= len;
+3 −15
Original line number Diff line number Diff line
@@ -144,12 +144,8 @@ static u32 qib_count_sge(struct rvt_sge_state *ss, u32 length)
	u32 ndesc = 1;  /* count the header */

	while (length) {
		u32 len = sge.length;
		u32 len = rvt_get_sge_length(&sge, length);

		if (len > length)
			len = length;
		if (len > sge.sge_length)
			len = sge.sge_length;
		if (((long) sge.vaddr & (sizeof(u32) - 1)) ||
		    (len != length && (len & (sizeof(u32) - 1)))) {
			ndesc = 0;
@@ -186,12 +182,8 @@ static void qib_copy_from_sge(void *data, struct rvt_sge_state *ss, u32 length)
	struct rvt_sge *sge = &ss->sge;

	while (length) {
		u32 len = sge->length;
		u32 len = rvt_get_sge_length(sge, length);

		if (len > length)
			len = length;
		if (len > sge->sge_length)
			len = sge->sge_length;
		memcpy(data, sge->vaddr, len);
		sge->vaddr += len;
		sge->length -= len;
@@ -440,13 +432,9 @@ static void copy_io(u32 __iomem *piobuf, struct rvt_sge_state *ss,
	u32 last;

	while (1) {
		u32 len = ss->sge.length;
		u32 len = rvt_get_sge_length(&ss->sge, length);
		u32 off;

		if (len > length)
			len = length;
		if (len > ss->sge.sge_length)
			len = ss->sge.sge_length;
		/* If the source address is not aligned, try to align it. */
		off = (unsigned long)ss->sge.vaddr & (sizeof(u32) - 1);
		if (off) {