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

Commit a96e8bc9 authored by Jack Pham's avatar Jack Pham Committed by Pratham Pratap
Browse files

usb: dwc3-msm: Don't use devm_ioremap when ringing GSI DB



Each time gsi_ring_db() is invoked, devm_ioremap_nocache() is
called to map the physical IO address in order to use writel().
However, devm_* calls will allocate a pointer to store with the
struct device and will not get freed until the device or
driver is removed, so in effect causes memory to be slowly
eaten for every GSI doorbell update, such as function bind.

Change the devm_ call to ioremap_nocache() followed by explicit
iounmap(). Also, if ioremap() fails, print an error message
and bail since the writel() would have no chance of succeeding.

Change-Id: I055774c24e2fbe86422756ea34b6a6e34ec21fb6
Signed-off-by: default avatarJack Pham <jackp@codeaurora.org>
Signed-off-by: default avatarPratham Pratap <prathampratap@codeaurora.org>
parent e6f07063
Loading
Loading
Loading
Loading
+12 −6
Original line number Diff line number Diff line
@@ -1046,17 +1046,20 @@ static void gsi_ring_db(struct usb_ep *ep, struct usb_gsi_request *request)
	int num_trbs = (dep->direction) ? (2 * (request->num_bufs) + 2)
					: (request->num_bufs + 2);

	gsi_dbl_address_lsb = devm_ioremap_nocache(mdwc->dev,
				request->db_reg_phs_addr_lsb, sizeof(u32));
	gsi_dbl_address_lsb = ioremap_nocache(request->db_reg_phs_addr_lsb,
				sizeof(u32));
	if (!gsi_dbl_address_lsb) {
		dev_err(mdwc->dev, "Failed to get GSI DBL address LSB\n");
		dev_err(mdwc->dev, "Failed to map GSI DBL address LSB 0x%x\n",
				request->db_reg_phs_addr_lsb);
		return;
	}

	gsi_dbl_address_msb = devm_ioremap_nocache(mdwc->dev,
			request->db_reg_phs_addr_msb, sizeof(u32));
	gsi_dbl_address_msb = ioremap_nocache(request->db_reg_phs_addr_msb,
				sizeof(u32));
	if (!gsi_dbl_address_msb) {
		dev_err(mdwc->dev, "Failed to get GSI DBL address MSB\n");
		dev_err(mdwc->dev, "Failed to map GSI DBL address MSB 0x%x\n",
				request->db_reg_phs_addr_msb);
		iounmap(gsi_dbl_address_lsb);
		return;
	}

@@ -1072,6 +1075,9 @@ static void gsi_ring_db(struct usb_ep *ep, struct usb_gsi_request *request)
	readl_relaxed(gsi_dbl_address_lsb);
	writel_relaxed(0, gsi_dbl_address_msb);
	readl_relaxed(gsi_dbl_address_msb);

	iounmap(gsi_dbl_address_lsb);
	iounmap(gsi_dbl_address_msb);
}

/**