dwc3-msm: Map IPA GSI channel doorbell register for different UDC core

Currently GSI endpoint usb_request pointer is allocated only once
during boot time and it used by dwc3 driver for mapping doorbell register
address with USB endpoint request only once. During composition switch
or connect/disconnect scenarios same USB endpoint is being re-enabled and
does not create mapping again.

On some platforms multiple UDC cores can work in device mode. In case
of binding the UDC with primary controller first and then disconnect the
primary and bind UDC to secondary controller. Driver does not re-mapping
the doorbell address with current UDC core and USB GSI wrapper is trying
to access previously mapped GSI DBL address with previous core
resulting into smmu fault.

Fix this issue by adding re-mapping of doorbell using dwc->sysdev node
to map the doorbell register with correct UDC.

Change-Id: I327126148c2311884aee2aa99bb59b7add06e302
Signed-off-by: Chandana Kishori Chiluveru <cchiluve@codeaurora.org>
Signed-off-by: Mayank Rana <mrana@codeaurora.org>
This commit is contained in:
Chandana Kishori Chiluveru 2019-05-07 19:21:52 +05:30 • committed by Mayank Rana
commit b8f0783b2e
2 changed files with 13 additions and 0 deletions

View file

@ -1264,11 +1264,20 @@ static void gsi_store_ringbase_dbl_info(struct usb_ep *ep,
lower_32_bits(dwc3_trb_dma_offset(dep, &dep->trb_pool[0])),
upper_32_bits(dwc3_trb_dma_offset(dep, &dep->trb_pool[0])));
if (request->mapped_db_reg_phs_addr_lsb &&
dwc->sysdev != request->dev) {
dma_unmap_resource(request->dev,
request->mapped_db_reg_phs_addr_lsb,
PAGE_SIZE, DMA_BIDIRECTIONAL, 0);
request->mapped_db_reg_phs_addr_lsb = 0;
}
if (!request->mapped_db_reg_phs_addr_lsb) {
request->mapped_db_reg_phs_addr_lsb =
dma_map_resource(dwc->sysdev,
(phys_addr_t)request->db_reg_phs_addr_lsb,
PAGE_SIZE, DMA_BIDIRECTIONAL, 0);
request->dev = dwc->sysdev;
if (dma_mapping_error(dwc->sysdev,
request->mapped_db_reg_phs_addr_lsb))
dev_err(mdwc->dev, "mapping error for db_reg_phs_addr_lsb\n");

View file

@ -68,6 +68,9 @@ enum gsi_ep_op {
* @mapped_db_reg_phs_addr_lsb: doorbell LSB IOVA address mapped with IOMMU
* @db_reg_phs_addr_msb: IPA channel doorbell register's physical address MSB
* @ep_intr_num: Interrupter number for EP.
* @sgt_trb_xfer_ring: USB TRB ring related sgtable entries
* @sgt_data_buff: Data buffer related sgtable entries
* @dev: pointer to the DMA-capable dwc device
*/
struct usb_gsi_request {
void *buf_base_addr;
@ -80,6 +83,7 @@ struct usb_gsi_request {
u8 ep_intr_num;
struct sg_table sgt_trb_xfer_ring;
struct sg_table sgt_data_buff;
struct device *dev;
};
/*