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

Commit dff6ad0a authored by Jack Pham's avatar Jack Pham
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>
parent 41ea0e89
Loading
Loading
Loading
Loading
+18 −8
Original line number Diff line number Diff line
@@ -1282,15 +1282,22 @@ 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));
	if (!gsi_dbl_address_lsb)
		dev_dbg(mdwc->dev, "Failed to get GSI DBL address LSB\n");
	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 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));
	if (!gsi_dbl_address_msb)
		dev_dbg(mdwc->dev, "Failed to get GSI DBL address MSB\n");
	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 map GSI DBL address MSB 0x%x\n",
				request->db_reg_phs_addr_msb);
		iounmap(gsi_dbl_address_lsb);
		return;
	}

	offset = dwc3_trb_dma_offset(dep, &dep->trb_pool[num_trbs-1]);
	dev_dbg(mdwc->dev, "Writing link TRB addr: %pa to %pK (%x) for ep:%s\n",
@@ -1299,6 +1306,9 @@ static void gsi_ring_db(struct usb_ep *ep, struct usb_gsi_request *request)

	writel_relaxed(offset, gsi_dbl_address_lsb);
	writel_relaxed(0, gsi_dbl_address_msb);

	iounmap(gsi_dbl_address_lsb);
	iounmap(gsi_dbl_address_msb);
}

/**