diff --git a/drivers/platform/msm/mhi_dev/mhi.c b/drivers/platform/msm/mhi_dev/mhi.c index 99a7cca705ad..fa551f5ee600 100644 --- a/drivers/platform/msm/mhi_dev/mhi.c +++ b/drivers/platform/msm/mhi_dev/mhi.c @@ -57,6 +57,7 @@ #define HOST_ADDR_MSB(addr) ((addr >> 32) & 0xFFFFFFFF) #define MHI_IPC_LOG_PAGES (100) +#define MHI_IPC_ERR_LOG_PAGES (10) #define MHI_REGLEN 0x100 #define MHI_INIT 0 #define MHI_REINIT 1 @@ -71,7 +72,9 @@ uint32_t bhi_imgtxdb; enum mhi_msg_level mhi_msg_lvl = MHI_MSG_ERROR; enum mhi_msg_level mhi_ipc_msg_lvl = MHI_MSG_VERBOSE; +enum mhi_msg_level mhi_ipc_err_msg_lvl = MHI_MSG_ERROR; void *mhi_ipc_log; +void *mhi_ipc_err_log; static struct mhi_dev *mhi_ctx; static void mhi_hwc_cb(void *priv, enum ipa_mhi_event_type event, @@ -156,7 +159,8 @@ void mhi_dev_read_from_host_ipa(struct mhi_dev *mhi, struct mhi_addr *transfer) (int)transfer->size, mhi_dev_ring_cache_completion_cb, &ring_req); if (rc) - pr_err("error while reading from host:%d\n", rc); + mhi_log(MHI_MSG_ERROR, "error while reading from host:%d\n", + rc); wait_for_completion(&done); } @@ -226,7 +230,8 @@ void mhi_dev_write_to_host_ipa(struct mhi_dev *mhi, struct mhi_addr *transfer, (int)transfer->size, cb_func, ereq); if (rc) - pr_err("error while writing to host:%d\n", rc); + mhi_log(MHI_MSG_ERROR, + "error while writing to host:%d\n", rc); } else if (tr_type == MHI_DEV_DMA_SYNC) { /* Copy the device content to a local device * physical address. @@ -237,7 +242,8 @@ void mhi_dev_write_to_host_ipa(struct mhi_dev *mhi, struct mhi_addr *transfer, (u64) mhi->cache_dma_handle, (int) transfer->size); if (rc) - pr_err("error while writing to host:%d\n", rc); + mhi_log(MHI_MSG_ERROR, + "error while writing to host:%d\n", rc); } } @@ -276,7 +282,7 @@ static int mhi_dev_schedule_msi_ipa(struct mhi_dev *mhi, struct event_req *ereq) rc = ep_pcie_get_msi_config(mhi->phandle, &cfg); if (rc) { - pr_err("Error retrieving pcie msi logic\n"); + mhi_log(MHI_MSG_ERROR, "Error retrieving pcie msi logic\n"); return rc; } @@ -408,7 +414,8 @@ static int mhi_trigger_msi_edma(struct mhi_dev_ring *ring, u32 idx) if (!mhi_ctx->msi_lower) { rc = ep_pcie_get_msi_config(mhi_ctx->phandle, &cfg); if (rc) { - pr_err("Error retrieving pcie msi logic\n"); + mhi_log(MHI_MSG_ERROR, + "Error retrieving pcie msi logic\n"); return rc; } @@ -431,7 +438,8 @@ static int mhi_trigger_msi_edma(struct mhi_dev_ring *ring, u32 idx) sizeof(u32), DMA_PREP_INTERRUPT); if (!descriptor) { - pr_err("%s(): desc is null, MSI to Host failed\n", __func__); + mhi_log(MHI_MSG_ERROR, + "desc is null, MSI to Host failed\n"); spin_unlock_irqrestore(&mhi_ctx->msi_lock, flags); return -EFAULT; } @@ -457,17 +465,19 @@ static int mhi_dev_send_multiple_tr_events(struct mhi_dev *mhi, int evnt_ring, struct mhi_dev_channel *ch; if (!ereq) { - pr_err("%s(): invalid event req\n", __func__); + mhi_log(MHI_MSG_ERROR, "invalid event req\n"); return -EINVAL; } if (evnt_ring_idx > mhi->cfg.event_rings) { - pr_err("Invalid event ring idx: %lld\n", evnt_ring_idx); + mhi_log(MHI_MSG_ERROR, + "Invalid event ring idx: %lld\n", evnt_ring_idx); return -EINVAL; } if (!ring) { - pr_err("%s(): Ring %d not present\n", __func__, evnt_ring_idx); + mhi_log(MHI_MSG_ERROR, "Ring %d not present\n", + evnt_ring_idx); return -EINVAL; } @@ -518,7 +528,8 @@ static int mhi_dev_send_multiple_tr_events(struct mhi_dev *mhi, int evnt_ring, rc = mhi_dev_add_element(ring, ereq->tr_events, ereq, evt_len); if (rc) { - pr_err("%s(): error in adding element rc %d\n", __func__, rc); + mhi_log(MHI_MSG_ERROR, + "error in adding element rc %d\n", rc); goto exit; } @@ -560,12 +571,12 @@ static int mhi_dev_send_multiple_tr_events(struct mhi_dev *mhi, int evnt_ring, if (mhi_ctx->use_edma) { rc = mhi_trigger_msi_edma(ring, ctx->ev.msivec); if (rc) - pr_err("%s: error sending in msi\n", __func__); + mhi_log(MHI_MSG_ERROR, "error sending in msi\n"); } else { /* Schedule DMA for MSI*/ rc = mhi_dev_schedule_msi_ipa(mhi, ereq); if (rc) - pr_err("%s: error sending in msi\n", __func__); + mhi_log(MHI_MSG_ERROR, "error sending in msi\n"); } exit: @@ -663,8 +674,6 @@ static int mhi_dev_flush_transfer_completion_events(struct mhi_dev *mhi, if (flush_ereq->tr_events < ch->tr_events || (flush_ereq->tr_events + flush_ereq->num_events) > (ch->tr_events + ch->evt_buf_size)) { - pr_err("%s: Invalid completion event buffer!\n", - __func__); mhi_log(MHI_MSG_ERROR, "Invalid cmpl evt buf - start %pK, end %pK\n", flush_ereq->tr_events, @@ -800,7 +809,6 @@ static int mhi_dev_queue_transfer_completion(struct mhi_req *mreq, bool *flush) ch->curr_ereq->num_events = 0; ch->curr_ereq->start = ch->evt_buf_rp; } else { - pr_err("%s evt req buffers empty\n", __func__); mhi_log(MHI_MSG_ERROR, "evt req buffers empty\n"); ch->curr_ereq = NULL; @@ -848,7 +856,8 @@ int mhi_transfer_host_to_device_ipa(void *dev, uint64_t host_pa, uint32_t len, rc = ipa_dma_sync_memcpy((u64) mhi->read_dma_handle, host_addr_pa, (int) len); if (rc) { - pr_err("error while reading chan using sync:%d\n", rc); + mhi_log(MHI_MSG_ERROR, + "error while reading chan using sync:%d\n", rc); return rc; } memcpy(dev, mhi->read_handle, len); @@ -943,7 +952,8 @@ int mhi_transfer_device_to_host_ipa(uint64_t host_addr, void *dev, uint32_t len, /* Queue the completion event for the current transfer */ rc = mhi_dev_queue_transfer_completion(req, &flush); if (rc) { - pr_err("Failed to queue completion: %d\n", rc); + mhi_log(MHI_MSG_ERROR, + "Failed to queue completion: %d\n", rc); return rc; } @@ -1001,7 +1011,7 @@ void mhi_dev_read_from_host_edma(struct mhi_dev *mhi, struct mhi_addr *transfer) transfer->phy_addr, host_addr_pa, (int)transfer->size, DMA_PREP_INTERRUPT); if (!descriptor) { - pr_err("%s(): descriptor is null\n", __func__); + mhi_log(MHI_MSG_ERROR, "descriptor is null\n"); return; } descriptor->callback_param = &read_from_host; @@ -1052,7 +1062,8 @@ void mhi_dev_write_to_host_edma(struct mhi_dev *mhi, struct mhi_addr *transfer, transfer->virt_addr, transfer->size, DMA_TO_DEVICE); if (dma_mapping_error(&mhi->pdev->dev, dma)) { - pr_err("%s(): dma mapping failed\n", __func__); + mhi_log(MHI_MSG_ERROR, + "dma mapping failed\n"); return; } } @@ -1076,7 +1087,7 @@ void mhi_dev_write_to_host_edma(struct mhi_dev *mhi, struct mhi_addr *transfer, dma, (int)transfer->size, DMA_PREP_INTERRUPT); if (!descriptor) { - pr_err("%s(): descriptor is null\n", __func__); + mhi_log(MHI_MSG_ERROR, "descriptor is null\n"); dma_unmap_single(&mhi->pdev->dev, (size_t)transfer->virt_addr, transfer->size, DMA_TO_DEVICE); @@ -1097,7 +1108,7 @@ void mhi_dev_write_to_host_edma(struct mhi_dev *mhi, struct mhi_addr *transfer, (int)transfer->size, DMA_PREP_INTERRUPT); if (!descriptor) { - pr_err("%s(): descriptor is null\n", __func__); + mhi_log(MHI_MSG_ERROR, "descriptor is null\n"); return; } @@ -1148,7 +1159,7 @@ int mhi_transfer_host_to_device_edma(void *dev, uint64_t host_pa, uint32_t len, host_addr_pa, (int)len, DMA_PREP_INTERRUPT); if (!descriptor) { - pr_err("%s(): descriptor is null\n", __func__); + mhi_log(MHI_MSG_ERROR, "descriptor is null\n"); return -EFAULT; } descriptor->callback_param = &transfer_host_to_device; @@ -1168,7 +1179,7 @@ int mhi_transfer_host_to_device_edma(void *dev, uint64_t host_pa, uint32_t len, mreq->dma = dma_map_single(&mhi->pdev->dev, dev, len, DMA_FROM_DEVICE); if (dma_mapping_error(&mhi->pdev->dev, mreq->dma)) { - pr_err("%s(): dma map single failed\n", __func__); + mhi_log(MHI_MSG_ERROR, "dma map single failed\n"); return -ENOMEM; } @@ -1183,7 +1194,8 @@ int mhi_transfer_host_to_device_edma(void *dev, uint64_t host_pa, uint32_t len, /* Queue the completion event for the current transfer */ rc = mhi_dev_queue_transfer_completion(mreq, NULL); if (rc) { - pr_err("Failed to queue completion: %d\n", rc); + mhi_log(MHI_MSG_ERROR, + "Failed to queue completion: %d\n", rc); return rc; } @@ -1192,7 +1204,7 @@ int mhi_transfer_host_to_device_edma(void *dev, uint64_t host_pa, uint32_t len, host_addr_pa, (int)len, DMA_PREP_INTERRUPT); if (!descriptor) { - pr_err("%s(): descriptor is null\n", __func__); + mhi_log(MHI_MSG_ERROR, "descriptor is null\n"); /* Roll back the completion event that we wrote above */ mhi_dev_rollback_compl_evt(ch); dma_unmap_single(&mhi->pdev->dev, (size_t)dev, len, @@ -1244,7 +1256,7 @@ int mhi_transfer_device_to_host_edma(uint64_t host_addr, void *dev, host_addr_pa, mhi->write_dma_handle, (int)len, DMA_PREP_INTERRUPT); if (!descriptor) { - pr_err("%s(): descriptor is null\n", __func__); + mhi_log(MHI_MSG_ERROR, "descriptor is null\n"); return -EFAULT; } descriptor->callback_param = &transfer_device_to_host; @@ -1262,7 +1274,7 @@ int mhi_transfer_device_to_host_edma(uint64_t host_addr, void *dev, req->dma = dma_map_single(&mhi->pdev->dev, req->buf, req->len, DMA_TO_DEVICE); if (dma_mapping_error(&mhi->pdev->dev, req->dma)) { - pr_err("%s(): dma map single failed\n", __func__); + mhi_log(MHI_MSG_ERROR, "dma map single failed\n"); return -ENOMEM; } @@ -1274,7 +1286,8 @@ int mhi_transfer_device_to_host_edma(uint64_t host_addr, void *dev, /* Queue the completion event for the current transfer */ rc = mhi_dev_queue_transfer_completion(req, &flush); if (rc) { - pr_err("Failed to queue completion: %d\n", rc); + mhi_log(MHI_MSG_ERROR, + "Failed to queue completion: %d\n", rc); return rc; } @@ -1282,7 +1295,7 @@ int mhi_transfer_device_to_host_edma(uint64_t host_addr, void *dev, host_addr_pa, req->dma, (int) len, DMA_PREP_INTERRUPT); if (!descriptor) { - pr_err("%s(): descriptor is null\n", __func__); + mhi_log(MHI_MSG_ERROR, "descriptor is null\n"); /* Roll back the completion event that we wrote above */ mhi_dev_rollback_compl_evt(ch); /* Unmap the buffer */ @@ -1364,13 +1377,15 @@ static int mhi_enable_int(void) rc = mhi_dev_mmio_enable_ctrl_interrupt(mhi_ctx); if (rc) { - pr_err("Failed to enable control interrupt: %d\n", rc); + mhi_log(MHI_MSG_ERROR, + "Failed to enable control interrupt: %d\n", rc); return rc; } rc = mhi_dev_mmio_enable_cmdb_interrupt(mhi_ctx); if (rc) { - pr_err("Failed to enable command db: %d\n", rc); + mhi_log(MHI_MSG_ERROR, + "Failed to enable command db: %d\n", rc); return rc; } mhi_update_state_info(MHI_STATE_CONNECTED); @@ -1395,20 +1410,22 @@ static int mhi_hwc_init(struct mhi_dev *mhi) */ rc = mhi_enable_int(); if (rc) - pr_err("Error configuring interrupts: rc = %d\n", rc); + mhi_log(MHI_MSG_ERROR, + "Error configuring interrupts: rc = %d\n", rc); return rc; } /* Call IPA HW_ACC Init with MSI Address and db routing info */ rc = ep_pcie_get_msi_config(mhi_ctx->phandle, &cfg); if (rc) { - pr_err("Error retrieving pcie msi logic\n"); + mhi_log(MHI_MSG_ERROR, + "Error retrieving pcie msi logic\n"); return rc; } rc = mhi_pcie_config_db_routing(mhi); if (rc) { - pr_err("Error configuring DB routing\n"); + mhi_log(MHI_MSG_ERROR, "Error configuring DB routing\n"); return rc; } @@ -1475,13 +1492,15 @@ static void mhi_hwc_cb(void *priv, enum ipa_mhi_event_type event, "HW Channel uC is ready event=0x%X\n", event); rc = mhi_hwc_start(mhi_ctx); if (rc) { - pr_err("hwc_init start failed with %d\n", rc); + mhi_log(MHI_MSG_ERROR, + "hwc_init start failed with %d\n", rc); return; } rc = mhi_enable_int(); if (rc) { - pr_err("Error configuring interrupts, rc = %d\n", rc); + mhi_log(MHI_MSG_ERROR, + "Error configuring interrupts, rc = %d\n", rc); return; } @@ -1490,12 +1509,14 @@ static void mhi_hwc_cb(void *priv, enum ipa_mhi_event_type event, case IPA_MHI_EVENT_DATA_AVAILABLE: rc = mhi_dev_notify_sm_event(MHI_DEV_EVENT_HW_ACC_WAKEUP); if (rc) { - pr_err("Event HW_ACC_WAKEUP failed with %d\n", rc); + mhi_log(MHI_MSG_ERROR, + "Event HW_ACC_WAKEUP failed with %d\n", rc); return; } break; default: - pr_err("HW Channel uC unknown event 0x%X\n", event); + mhi_log(MHI_MSG_ERROR, + "HW Channel uC unknown event 0x%X\n", event); break; } } @@ -1512,14 +1533,16 @@ static int mhi_hwc_chcmd(struct mhi_dev *mhi, uint chid, case MHI_DEV_RING_EL_RESET: case MHI_DEV_RING_EL_STOP: if ((chid-HW_CHANNEL_BASE) > NUM_HW_CHANNELS) { - pr_err("Invalid Channel ID = 0x%X\n", chid); + mhi_log(MHI_MSG_ERROR, + "Invalid Channel ID = 0x%X\n", chid); return -EINVAL; } rc = ipa_mhi_disconnect_pipe( mhi->ipa_clnt_hndl[chid-HW_CHANNEL_BASE]); if (rc) - pr_err("Stopping HW Channel%d failed 0x%X\n", + mhi_log(MHI_MSG_ERROR, + "Stopping HW Channel%d failed 0x%X\n", chid, rc); break; case MHI_DEV_RING_EL_START: @@ -1527,24 +1550,28 @@ static int mhi_hwc_chcmd(struct mhi_dev *mhi, uint chid, connect_params.sys.skip_ep_cfg = true; if (chid > HW_CHANNEL_END) { - pr_err("Channel DB for %d not enabled\n", chid); + mhi_log(MHI_MSG_ERROR, + "Channel DB for %d not enabled\n", chid); return -EINVAL; } if ((chid-HW_CHANNEL_BASE) > NUM_HW_CHANNELS) { - pr_err("Invalid Channel = 0x%X\n", chid); + mhi_log(MHI_MSG_ERROR, + "Invalid Channel = 0x%X\n", chid); return -EINVAL; } rc = ipa_mhi_connect_pipe(&connect_params, &mhi->ipa_clnt_hndl[chid-HW_CHANNEL_BASE]); if (rc) - pr_err("HW Channel%d start failed : %d\n", + mhi_log(MHI_MSG_ERROR, + "HW Channel%d start failed : %d\n", chid, rc); break; case MHI_DEV_RING_EL_INVALID: default: - pr_err("Invalid Ring Element type = 0x%X\n", type); + mhi_log(MHI_MSG_ERROR, + "Invalid Ring Element type = 0x%X\n", type); break; } @@ -1558,13 +1585,13 @@ static void mhi_dev_core_ack_ctrl_interrupts(struct mhi_dev *dev, rc = mhi_dev_mmio_read(dev, MHI_CTRL_INT_STATUS_A7, int_value); if (rc) { - pr_err("Failed to read A7 status\n"); + mhi_log(MHI_MSG_ERROR, "Failed to read A7 status\n"); return; } rc = mhi_dev_mmio_write(dev, MHI_CTRL_INT_CLEAR_A7, *int_value); if (rc) { - pr_err("Failed to clear A7 status\n"); + mhi_log(MHI_MSG_ERROR, "Failed to clear A7 status\n"); return; } } @@ -1590,7 +1617,7 @@ int mhi_dev_syserr(struct mhi_dev *mhi) if (WARN_ON(!mhi)) return -EINVAL; - pr_err("MHI dev sys error\n"); + mhi_log(MHI_MSG_ERROR, "MHI dev sys error\n"); return mhi_dev_dump_mmio(mhi); } @@ -1608,12 +1635,13 @@ int mhi_dev_send_event(struct mhi_dev *mhi, int evnt_ring, rc = ep_pcie_get_msi_config(mhi->phandle, &cfg); if (rc) { - pr_err("Error retrieving pcie msi logic\n"); + mhi_log(MHI_MSG_ERROR, "Error retrieving pcie msi logic\n"); return rc; } if (evnt_ring_idx > mhi->cfg.event_rings) { - pr_err("Invalid event ring idx: %lld\n", evnt_ring_idx); + mhi_log(MHI_MSG_ERROR, + "Invalid event ring idx: %lld\n", evnt_ring_idx); return -EINVAL; } @@ -1900,7 +1928,8 @@ static void mhi_dev_process_reset_cmd(struct mhi_dev *mhi, int ch_id) rc = mhi_dev_send_cmd_comp_event(mhi, MHI_CMD_COMPL_CODE_SUCCESS); if (rc) - pr_err("Error sending command completion event\n"); + mhi_log(MHI_MSG_ERROR, + "Error sending command completion event\n"); ch->reset_pending = false; } @@ -2004,7 +2033,8 @@ send_start_completion_event: rc = mhi_dev_send_cmd_comp_event(mhi, MHI_CMD_COMPL_CODE_SUCCESS); if (rc) - pr_err("Error sending command completion event\n"); + mhi_log(MHI_MSG_ERROR, + "Error sending command completion event\n"); mhi_update_state_info_ch(ch_id, MHI_STATE_CONNECTED); /* Trigger callback to clients */ @@ -2047,7 +2077,8 @@ send_undef_completion_event: rc = mhi_dev_flush_cmd_completion_events(mhi, &event); if (rc) { - pr_err("stop event send failed\n"); + mhi_log(MHI_MSG_ERROR, + "stop event send failed\n"); return rc; } } else { @@ -2060,7 +2091,8 @@ send_undef_completion_event: */ ring = &mhi->ring[ch_id + mhi->ch_ring_start]; if (ring->state == RING_STATE_UINT) { - pr_err("Channel not opened for %d\n", ch_id); + mhi_log(MHI_MSG_ERROR, + "Channel not opened for %d\n", ch_id); return -EINVAL; } @@ -2074,7 +2106,8 @@ send_undef_completion_event: &mhi->ring[mhi->ch_ring_start + ch_id], ch_id, mhi); if (rc) - pr_err("stop event send failed\n"); + mhi_log(MHI_MSG_ERROR, + "stop event send failed\n"); mutex_unlock(&ch->ring->event_lock); mutex_unlock(&ch->ch_lock); @@ -2109,7 +2142,8 @@ send_undef_completion_event: rc = mhi_dev_flush_cmd_completion_events(mhi, &event); if (rc) { - pr_err("stop event send failed\n"); + mhi_log(MHI_MSG_ERROR, + "stop event send failed\n"); return rc; } } else { @@ -2120,7 +2154,8 @@ send_undef_completion_event: ring = &mhi->ring[ch_id + mhi->ch_ring_start]; if (ring->state == RING_STATE_UINT) { - pr_err("Channel not opened for %d\n", ch_id); + mhi_log(MHI_MSG_ERROR, + "Channel not opened for %d\n", ch_id); return -EINVAL; } ch = &mhi->ch[ch_id]; @@ -2146,7 +2181,8 @@ send_undef_completion_event: } break; default: - pr_err("%s: Invalid command:%d\n", __func__, el->generic.type); + mhi_log(MHI_MSG_ERROR, + "Invalid command:%d\n", el->generic.type); break; } return rc; @@ -2301,7 +2337,8 @@ static bool mhi_dev_queue_channel_db(struct mhi_dev *mhi, mutex_unlock(&ch->ch_lock); rc = mhi_dev_mmio_disable_chdb_a7(mhi, ch_num); if (rc) { - pr_err("Error disabling chdb\n"); + mhi_log(MHI_MSG_ERROR, + "Error disabling chdb\n"); return work_pending; } } @@ -2404,25 +2441,28 @@ static int mhi_dev_abort(struct mhi_dev *mhi) /* Clean up initialized channels */ rc = mhi_deinit(mhi); if (rc) { - pr_err("Error during mhi_deinit with %d\n", rc); + mhi_log(MHI_MSG_ERROR, + "Error during mhi_deinit with %d\n", rc); return rc; } rc = mhi_dev_mmio_mask_chdb_interrupts(mhi_ctx); if (rc) { - pr_err("Failed to enable channel db\n"); + mhi_log(MHI_MSG_ERROR, + "Failed to enable channel db\n"); return rc; } rc = mhi_dev_mmio_disable_ctrl_interrupt(mhi_ctx); if (rc) { - pr_err("Failed to enable control interrupt\n"); + mhi_log(MHI_MSG_ERROR, + "Failed to enable control interrupt\n"); return rc; } rc = mhi_dev_mmio_disable_cmdb_interrupt(mhi_ctx); if (rc) { - pr_err("Failed to enable command db\n"); + mhi_log(MHI_MSG_ERROR, "Failed to enable command db\n"); return rc; } @@ -2440,7 +2480,8 @@ static int mhi_dev_abort(struct mhi_dev *mhi) rc = ep_pcie_register_event(mhi_ctx->phandle, &mhi_ctx->event_reg); if (rc) { - pr_err("Failed to register for events from PCIe\n"); + mhi_log(MHI_MSG_ERROR, + "Failed to register for events from PCIe\n"); return rc; } @@ -2534,7 +2575,7 @@ static void mhi_dev_scheduler(struct work_struct *work) rc = mhi_dev_mmio_get_mhi_state(mhi, &state, &mhi_reset); if (rc) { - pr_err("%s: get mhi state failed\n", __func__); + mhi_log(MHI_MSG_ERROR, "get mhi state failed\n"); mutex_unlock(&mhi_ctx->mhi_lock); return; } @@ -2544,7 +2585,8 @@ static void mhi_dev_scheduler(struct work_struct *work) "processing mhi device reset\n"); rc = mhi_dev_abort(mhi); if (rc) - pr_err("device reset failed:%d\n", rc); + mhi_log(MHI_MSG_ERROR, + "device reset failed:%d\n", rc); mutex_unlock(&mhi_ctx->mhi_lock); queue_work(mhi->ring_init_wq, &mhi->re_init); return; @@ -2552,13 +2594,14 @@ static void mhi_dev_scheduler(struct work_struct *work) rc = mhi_dev_get_event_notify(state, &event); if (rc) { - pr_err("unsupported state :%d\n", state); + mhi_log(MHI_MSG_ERROR, + "unsupported state :%d\n", state); goto fail; } rc = mhi_dev_notify_sm_event(event); if (rc) { - pr_err("error sending SM event\n"); + mhi_log(MHI_MSG_ERROR, "error sending SM event\n"); goto fail; } } @@ -2681,7 +2724,8 @@ static int mhi_dev_cache_host_cfg(struct mhi_dev *mhi) mhi->ctrl_base.device_pa, mhi->ctrl_base.size); if (!mhi->ctrl_base.device_va) { - pr_err("io remap failed for mhi address\n"); + mhi_log(MHI_MSG_ERROR, + "io remap failed for mhi address\n"); return -EINVAL; } } @@ -2690,7 +2734,7 @@ static int mhi_dev_cache_host_cfg(struct mhi_dev *mhi) if (mhi->config_iatu) { rc = mhi_dev_config_outbound_iatu(mhi); if (rc) { - pr_err("Configuring iATU failed\n"); + mhi_log(MHI_MSG_ERROR, "Configuring iATU failed\n"); return rc; } } @@ -2698,25 +2742,25 @@ static int mhi_dev_cache_host_cfg(struct mhi_dev *mhi) /* Get Channel, event and command context base pointer */ rc = mhi_dev_mmio_get_chc_base(mhi); if (rc) { - pr_err("Fetching channel context failed\n"); + mhi_log(MHI_MSG_ERROR, "Fetching channel context failed\n"); return rc; } rc = mhi_dev_mmio_get_erc_base(mhi); if (rc) { - pr_err("Fetching event ring context failed\n"); + mhi_log(MHI_MSG_ERROR, "Fetching event ring context failed\n"); return rc; } rc = mhi_dev_mmio_get_crc_base(mhi); if (rc) { - pr_err("Fetching command ring context failed\n"); + mhi_log(MHI_MSG_ERROR, "Fetching command ring context failed\n"); return rc; } rc = mhi_dev_update_ner(mhi); if (rc) { - pr_err("Fetching NER failed\n"); + mhi_log(MHI_MSG_ERROR, "Fetching NER failed\n"); return rc; } @@ -2761,7 +2805,8 @@ static int mhi_dev_cache_host_cfg(struct mhi_dev *mhi) &mhi->cmd_ctx_cache_dma_handle, GFP_KERNEL); if (!mhi->cmd_ctx_cache) { - pr_err("no memory while allocating cmd ctx\n"); + mhi_log(MHI_MSG_ERROR, + "no memory while allocating cmd ctx\n"); rc = -ENOMEM; goto exit; } @@ -2834,7 +2879,7 @@ static int mhi_dev_cache_host_cfg(struct mhi_dev *mhi) rc = mhi_ring_start(&mhi->ring[0], (union mhi_dev_ring_ctx *)mhi->cmd_ctx_cache, mhi); if (rc) { - pr_err("MHI ring start failed:%d\n", rc); + mhi_log(MHI_MSG_ERROR, "MHI ring start failed:%d\n", rc); goto exit; } @@ -3350,7 +3395,8 @@ int mhi_dev_read_channel(struct mhi_req *mreq) return -ENXIO; if (mhi_ctx->ctrl_info != MHI_STATE_CONNECTED) { - pr_err("Channel not connected:%d\n", mhi_ctx->ctrl_info); + mhi_log(MHI_MSG_ERROR, + "Channel not connected:%d\n", mhi_ctx->ctrl_info); return -ENODEV; } @@ -3501,12 +3547,14 @@ int mhi_dev_write_channel(struct mhi_req *wreq) enum mhi_ctrl_info info; if (WARN_ON(!wreq || !wreq->client || !wreq->buf)) { - pr_err("%s: invalid parameters\n", __func__); + mhi_log(MHI_MSG_ERROR, + "invalid parameters\n"); return -ENXIO; } if (mhi_ctx->ctrl_info != MHI_STATE_CONNECTED) { - pr_err("Channel not connected:%d\n", mhi_ctx->ctrl_info); + mhi_log(MHI_MSG_ERROR, + "Channel not connected:%d\n", mhi_ctx->ctrl_info); return -ENODEV; } @@ -3524,7 +3572,8 @@ int mhi_dev_write_channel(struct mhi_req *wreq) mhi_log(MHI_MSG_CRITICAL, "Wakeup by chan:%d\n", ch->ch_id); rc = mhi_dev_notify_sm_event(MHI_DEV_EVENT_CORE_WAKEUP); if (rc) { - pr_err("error sending core wakeup event\n"); + mhi_log(MHI_MSG_ERROR, + "error sending core wakeup event\n"); mutex_unlock(&mhi_ctx->mhi_lock); mutex_unlock(&mhi_ctx->mhi_write_test); return rc; @@ -3541,7 +3590,7 @@ int mhi_dev_write_channel(struct mhi_req *wreq) if (suspend_wait_timeout >= MHI_WAKEUP_TIMEOUT_CNT || mhi_ctx->ctrl_info != MHI_STATE_CONNECTED) { - pr_err("Failed to wake up core\n"); + mhi_log(MHI_MSG_ERROR, "Failed to wake up core\n"); mutex_unlock(&mhi_ctx->mhi_write_test); return -ENODEV; } @@ -3581,8 +3630,8 @@ int mhi_dev_write_channel(struct mhi_req *wreq) do { if (ring->rd_offset == ring->wr_offset) { mhi_log(MHI_MSG_ERROR, - "%s():rd & wr offsets are equal\n", - __func__); + "rd & wr offsets are equal for channel-id %d\n", + wreq->chan); mhi_log(MHI_MSG_INFO, "No TREs available\n"); break; } @@ -3590,8 +3639,9 @@ int mhi_dev_write_channel(struct mhi_req *wreq) el = &ring->ring_cache[ring->rd_offset]; tre_len = el->tre.len; if (wreq->len > tre_len) { - pr_err("%s(): rlen = %lu, tlen = %d: client buf > tre len\n", - __func__, wreq->len, tre_len); + mhi_log(MHI_MSG_ERROR, + "rlen = %lu, tlen = %d: client buf > tre len\n", + wreq->len, tre_len); bytes_written = -ENOMEM; goto exit; } @@ -3679,7 +3729,8 @@ static int mhi_dev_recover(struct mhi_dev *mhi) /* Poll for the host to set the reset bit */ rc = mhi_dev_mmio_get_mhi_state(mhi, &state, &mhi_reset); if (rc) { - pr_err("%s: get mhi state failed\n", __func__); + mhi_log(MHI_MSG_ERROR, + "get mhi state failed\n"); return rc; } @@ -3698,7 +3749,8 @@ static int mhi_dev_recover(struct mhi_dev *mhi) "Wait for Host to set BHI_INTVEC\n"); rc = mhi_dev_mmio_read(mhi, BHI_INTVEC, &bhi_intvec); if (rc) { - pr_err("%s: Get BHI_INTVEC failed\n", __func__); + mhi_log(MHI_MSG_ERROR, + "Get BHI_INTVEC failed\n"); return rc; } bhi_max_cnt++; @@ -3714,7 +3766,7 @@ static int mhi_dev_recover(struct mhi_dev *mhi) /* Indicate the host that the device is ready */ rc = ep_pcie_trigger_msi(mhi->phandle, bhi_intvec); if (rc) { - pr_err("%s: error sending msi\n", __func__); + mhi_log(MHI_MSG_ERROR, "error sending msi\n"); return rc; } } @@ -3722,7 +3774,7 @@ static int mhi_dev_recover(struct mhi_dev *mhi) /* Poll for the host to set the reset bit */ rc = mhi_dev_mmio_get_mhi_state(mhi, &state, &mhi_reset); if (rc) { - pr_err("%s: get mhi state failed\n", __func__); + mhi_log(MHI_MSG_ERROR, "get mhi state failed\n"); return rc; } @@ -3735,7 +3787,8 @@ static int mhi_dev_recover(struct mhi_dev *mhi) rc = mhi_dev_mmio_get_mhi_state(mhi, &state, &mhi_reset); if (rc) { - pr_err("%s: get mhi state failed\n", __func__); + mhi_log(MHI_MSG_ERROR, + "get mhi state failed\n"); return rc; } max_cnt++; @@ -3766,20 +3819,20 @@ static void mhi_dev_enable(struct work_struct *work) if (mhi->use_ipa) { rc = ipa_dma_init(); if (rc) { - pr_err("ipa dma init failed\n"); + mhi_log(MHI_MSG_ERROR, "ipa dma init failed\n"); return; } rc = ipa_dma_enable(); if (rc) { - pr_err("ipa enable failed\n"); + mhi_log(MHI_MSG_ERROR, "ipa enable failed\n"); return; } } rc = mhi_dev_mmio_get_mhi_state(mhi, &state, &mhi_reset); if (rc) { - pr_err("%s: get mhi state failed\n", __func__); + mhi_log(MHI_MSG_ERROR, "get mhi state failed\n"); return; } if (mhi_reset) { @@ -3794,7 +3847,7 @@ static void mhi_dev_enable(struct work_struct *work) msleep(MHI_SUSPEND_MIN); rc = mhi_dev_mmio_get_mhi_state(mhi, &state, &mhi_reset); if (rc) { - pr_err("%s: get mhi state failed\n", __func__); + mhi_log(MHI_MSG_ERROR, "get mhi state failed\n"); return; } if (mhi_reset) { @@ -3810,23 +3863,24 @@ static void mhi_dev_enable(struct work_struct *work) if (state == MHI_DEV_M0_STATE) { rc = mhi_dev_cache_host_cfg(mhi); if (rc) { - pr_err("Failed to cache the host config\n"); + mhi_log(MHI_MSG_ERROR, + "Failed to cache the host config\n"); return; } rc = mhi_dev_mmio_set_env(mhi, MHI_ENV_VALUE); if (rc) { - pr_err("%s: env setting failed\n", __func__); + mhi_log(MHI_MSG_ERROR, "env setting failed\n"); return; } } else { - pr_err("MHI device failed to enter M0\n"); + mhi_log(MHI_MSG_ERROR, "MHI device failed to enter M0\n"); return; } rc = mhi_hwc_init(mhi_ctx); if (rc) { - pr_err("error during hwc_init\n"); + mhi_log(MHI_MSG_ERROR, "error during hwc_init\n"); return; } @@ -3847,7 +3901,8 @@ static void mhi_dev_enable(struct work_struct *work) /*Enable MHI dev network stack Interface*/ rc = mhi_dev_net_interface_init(); if (rc) - pr_err("%s Failed to initialize mhi_dev_net iface\n", __func__); + mhi_log(MHI_MSG_ERROR, + "Failed to initialize mhi_dev_net iface\n"); } static void mhi_ring_init_cb(void *data) @@ -3870,7 +3925,7 @@ int mhi_register_state_cb(void (*mhi_state_cb) return -ENXIO; if (channel >= MHI_MAX_SOFTWARE_CHANNELS) { - pr_err("Invalid channel :%d\n", channel); + mhi_log(MHI_MSG_ERROR, "Invalid channel :%d\n", channel); return -EINVAL; } @@ -3959,14 +4014,16 @@ static int get_device_tree_data(struct platform_device *pdev) res_mem = platform_get_resource_byname(pdev, IORESOURCE_MEM, "mhi_mmio_base"); if (!res_mem) { - pr_err("Request MHI MMIO physical memory region failed\n"); + mhi_log(MHI_MSG_ERROR, + "Request MHI MMIO physical memory region failed\n"); return -EINVAL; } mhi->mmio_base_pa_addr = res_mem->start; mhi->mmio_base_addr = ioremap_nocache(res_mem->start, MHI_1K_SIZE); if (!mhi->mmio_base_addr) { - pr_err("Failed to IO map MMIO registers\n"); + mhi_log(MHI_MSG_ERROR, + "Failed to IO map MMIO registers\n"); return -EINVAL; } @@ -3976,7 +4033,8 @@ static int get_device_tree_data(struct platform_device *pdev) res_mem = platform_get_resource_byname(pdev, IORESOURCE_MEM, "ipa_uc_mbox_crdb"); if (!res_mem) { - pr_err("Request IPA_UC_MBOX CRDB physical region failed\n"); + mhi_log(MHI_MSG_ERROR, + "Request IPA_UC_MBOX CRDB physical region failed\n"); rc = -EINVAL; goto err; } @@ -3986,7 +4044,8 @@ static int get_device_tree_data(struct platform_device *pdev) res_mem = platform_get_resource_byname(pdev, IORESOURCE_MEM, "ipa_uc_mbox_erdb"); if (!res_mem) { - pr_err("Request IPA_UC_MBOX ERDB physical region failed\n"); + mhi_log(MHI_MSG_ERROR, + "Request IPA_UC_MBOX ERDB physical region failed\n"); rc = -EINVAL; goto err; } @@ -4000,7 +4059,7 @@ static int get_device_tree_data(struct platform_device *pdev) "qcom,mhi-ifc-id", &mhi_ctx->ifc_id); if (rc) { - pr_err("qcom,mhi-ifc-id does not exist\n"); + mhi_log(MHI_MSG_ERROR, "qcom,mhi-ifc-id does not exist\n"); goto err; } @@ -4008,7 +4067,7 @@ static int get_device_tree_data(struct platform_device *pdev) "qcom,mhi-ep-msi", &mhi_ctx->mhi_ep_msi_num); if (rc) { - pr_err("qcom,mhi-ep-msi does not exist\n"); + mhi_log(MHI_MSG_ERROR, "qcom,mhi-ep-msi does not exist\n"); goto err; } @@ -4016,7 +4075,8 @@ static int get_device_tree_data(struct platform_device *pdev) "qcom,mhi-version", &mhi_ctx->mhi_version); if (rc) { - pr_err("qcom,mhi-version does not exist\n"); + mhi_log(MHI_MSG_ERROR, + "qcom,mhi-version does not exist\n"); goto err; } @@ -4031,7 +4091,8 @@ static int get_device_tree_data(struct platform_device *pdev) "qcom,mhi-local-pa-base", &mhi_ctx->device_local_pa_base); if (rc) { - pr_err("qcom,mhi-local-pa-base does not exist\n"); + mhi_log(MHI_MSG_ERROR, + "qcom,mhi-local-pa-base does not exist\n"); goto err; } } @@ -4042,7 +4103,8 @@ static int get_device_tree_data(struct platform_device *pdev) if (mhi->config_iatu || mhi_ctx->mhi_int) { mhi->mhi_irq = platform_get_irq_byname(pdev, "mhi-device-inta"); if (mhi->mhi_irq < 0) { - pr_err("Invalid MHI device interrupt\n"); + mhi_log(MHI_MSG_ERROR, + "Invalid MHI device interrupt\n"); rc = mhi->mhi_irq; goto err; } @@ -4086,7 +4148,8 @@ static int mhi_init(struct mhi_dev *mhi) rc = mhi_dev_mmio_init(mhi); if (rc) { - pr_err("Failed to update the MMIO init\n"); + mhi_log(MHI_MSG_ERROR, + "Failed to update the MMIO init\n"); return rc; } @@ -4134,7 +4197,8 @@ static int mhi_dev_resume_mmio_mhi_reinit(struct mhi_dev *mhi_ctx) rc = mhi_init(mhi_ctx); if (rc) { - pr_err("Error initializing MHI MMIO with %d\n", rc); + mhi_log(MHI_MSG_ERROR, + "Error initializing MHI MMIO with %d\n", rc); goto fail; } @@ -4153,7 +4217,8 @@ static int mhi_dev_resume_mmio_mhi_reinit(struct mhi_dev *mhi_ctx) rc = ep_pcie_register_event(mhi_ctx->phandle, &mhi_ctx->event_reg); if (rc) { - pr_err("Failed to register for events from PCIe\n"); + mhi_log(MHI_MSG_ERROR, + "Failed to register for events from PCIe\n"); goto fail; } @@ -4163,7 +4228,8 @@ static int mhi_dev_resume_mmio_mhi_reinit(struct mhi_dev *mhi_ctx) if (rc == -EEXIST) { mhi_ring_init_cb(mhi_ctx); } else { - pr_err("Error calling IPA cb with %d\n", rc); + mhi_log(MHI_MSG_ERROR, + "Error calling IPA cb with %d\n", rc); goto fail; } } @@ -4172,21 +4238,22 @@ static int mhi_dev_resume_mmio_mhi_reinit(struct mhi_dev *mhi_ctx) /* Invoke MHI SM when device is in RESET state */ rc = mhi_dev_sm_init(mhi_ctx); if (rc) { - pr_err("%s: Error during SM init\n", __func__); + mhi_log(MHI_MSG_ERROR, "Error during SM init\n"); goto fail; } /* set the env before setting the ready bit */ rc = mhi_dev_mmio_set_env(mhi_ctx, MHI_ENV_VALUE); if (rc) { - pr_err("%s: env setting failed\n", __func__); + mhi_log(MHI_MSG_ERROR, "env setting failed\n"); goto fail; } /* All set, notify the host */ rc = mhi_dev_sm_set_ready(); if (rc) { - pr_err("%s: unable to set ready bit\n", __func__); + mhi_log(MHI_MSG_ERROR, + "unable to set ready bit\n"); goto fail; } @@ -4212,7 +4279,8 @@ static void mhi_dev_reinit(struct work_struct *work) /* PCIe link is up with BME set */ rc = mhi_dev_resume_mmio_mhi_reinit(mhi_ctx); if (rc) { - pr_err("Failed to register for events from PCIe\n"); + mhi_log(MHI_MSG_ERROR, + "Failed to register for events from PCIe\n"); return; } } @@ -4265,13 +4333,14 @@ static int mhi_dev_resume_mmio_mhi_init(struct mhi_dev *mhi_ctx) mhi_ctx->phandle = ep_pcie_get_phandle(mhi_ctx->ifc_id); if (!mhi_ctx->phandle) { - pr_err("PCIe driver get handle failed.\n"); + mhi_log(MHI_MSG_ERROR, + "PCIe driver get handle failed.\n"); return -EINVAL; } rc = mhi_dev_recover(mhi_ctx); if (rc) { - pr_err("%s: get mhi state failed\n", __func__); + mhi_log(MHI_MSG_ERROR, "get mhi state failed\n"); return rc; } @@ -4301,7 +4370,8 @@ static int mhi_dev_resume_mmio_mhi_init(struct mhi_dev *mhi_ctx) rc = mhi_dev_mmio_write(mhi_ctx, MHIVER, mhi_ctx->mhi_version); if (rc) { - pr_err("Failed to update the MHI version\n"); + mhi_log(MHI_MSG_ERROR, + "Failed to update the MHI version\n"); return rc; } mhi_ctx->event_reg.events = EP_PCIE_EVENT_PM_D3_HOT | @@ -4319,19 +4389,21 @@ static int mhi_dev_resume_mmio_mhi_init(struct mhi_dev *mhi_ctx) rc = ep_pcie_register_event(mhi_ctx->phandle, &mhi_ctx->event_reg); if (rc) { - pr_err("Failed to register for events from PCIe\n"); + mhi_log(MHI_MSG_ERROR, + "Failed to register for events from PCIe\n"); return rc; } if (mhi_ctx->use_ipa) { - pr_err("Registering with IPA\n"); + mhi_log(MHI_MSG_ERROR, "Registering with IPA\n"); rc = ipa_register_ipa_ready_cb(mhi_ring_init_cb, mhi_ctx); if (rc < 0) { if (rc == -EEXIST) { mhi_ring_init_cb(mhi_ctx); } else { - pr_err("Error calling IPA cb with %d\n", rc); + mhi_log(MHI_MSG_ERROR, + "Error calling IPA cb with %d\n", rc); return rc; } } @@ -4340,14 +4412,14 @@ static int mhi_dev_resume_mmio_mhi_init(struct mhi_dev *mhi_ctx) /* Invoke MHI SM when device is in RESET state */ rc = mhi_dev_sm_init(mhi_ctx); if (rc) { - pr_err("%s: Error during SM init\n", __func__); + mhi_log(MHI_MSG_ERROR, "Error during SM init\n"); return rc; } /* set the env before setting the ready bit */ rc = mhi_dev_mmio_set_env(mhi_ctx, MHI_ENV_VALUE); if (rc) { - pr_err("%s: env setting failed\n", __func__); + mhi_log(MHI_MSG_ERROR, "env setting failed\n"); return rc; } @@ -4376,7 +4448,7 @@ static int mhi_dev_resume_mmio_mhi_init(struct mhi_dev *mhi_ctx) static void mhi_dev_resume_init_with_link_up(struct ep_pcie_notify *notify) { if (!notify || !notify->user) { - pr_err("Null argument for notify\n"); + mhi_log(MHI_MSG_ERROR, "Null argument for notify\n"); return; } @@ -4396,13 +4468,15 @@ static void mhi_dev_pcie_handle_event(struct work_struct *work) if (mhi_dev_pcie_notify_event == MHI_INIT) { rc = mhi_dev_resume_mmio_mhi_init(mhi_ctx); if (rc) { - pr_err("Error during MHI device initialization\n"); + mhi_log(MHI_MSG_ERROR, + "Error during MHI device initialization\n"); return; } } else if (mhi_dev_pcie_notify_event == MHI_REINIT) { rc = mhi_dev_resume_mmio_mhi_reinit(mhi_ctx); if (rc) { - pr_err("Error during MHI device re-initialization\n"); + mhi_log(MHI_MSG_ERROR, + "Error during MHI device re-initialization\n"); return; } } @@ -4412,7 +4486,8 @@ static int mhi_edma_init(struct device *dev) { mhi_ctx->tx_dma_chan = dma_request_slave_channel(dev, "tx"); if (IS_ERR_OR_NULL(mhi_ctx->tx_dma_chan)) { - pr_err("%s(): request for TX chan failed\n", __func__); + mhi_log(MHI_MSG_ERROR, + "request for TX chan failed\n"); return -EIO; } @@ -4421,7 +4496,8 @@ static int mhi_edma_init(struct device *dev) mhi_ctx->rx_dma_chan = dma_request_slave_channel(dev, "rx"); if (IS_ERR_OR_NULL(mhi_ctx->rx_dma_chan)) { - pr_err("%s(): request for RX chan failed\n", __func__); + mhi_log(MHI_MSG_ERROR, + "request for RX chan failed\n"); return -EIO; } mhi_log(MHI_MSG_VERBOSE, "request for RX chan returned :%pK\n", @@ -4436,7 +4512,8 @@ static int mhi_dev_probe(struct platform_device *pdev) if (pdev->dev.of_node) { rc = get_device_tree_data(pdev); if (rc) { - pr_err("Error reading MHI Dev DT\n"); + mhi_log(MHI_MSG_ERROR, + "Error reading MHI Dev DT\n"); return rc; } mhi_ipc_log = ipc_log_context_create(MHI_IPC_LOG_PAGES, @@ -4445,6 +4522,12 @@ static int mhi_dev_probe(struct platform_device *pdev) dev_err(&pdev->dev, "Failed to create IPC logging context\n"); } + mhi_ipc_err_log = ipc_log_context_create(MHI_IPC_ERR_LOG_PAGES, + "mhi_err", 0); + if (mhi_ipc_err_log == NULL) { + dev_err(&pdev->dev, + "Failed to create IPC ERR logging context\n"); + } /* * The below list and mutex should be initialized * before calling mhi_uci_init to avoid crash in @@ -4460,13 +4543,15 @@ static int mhi_dev_probe(struct platform_device *pdev) if (mhi_ctx->use_edma) { rc = mhi_edma_init(&pdev->dev); if (rc) { - pr_err("MHI: mhi edma init failed, rc = %d\n", rc); + mhi_log(MHI_MSG_ERROR, + "MHI: mhi edma init failed, rc = %d\n", rc); return rc; } rc = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64)); if (rc) { - pr_err("Error set MHI DMA mask: rc = %d\n", rc); + mhi_log(MHI_MSG_ERROR, + "Error set MHI DMA mask: rc = %d\n", rc); return rc; } } @@ -4487,7 +4572,7 @@ static int mhi_dev_probe(struct platform_device *pdev) mhi_ctx->pcie_event_wq = alloc_workqueue("mhi_dev_pcie_event_wq", WQ_HIGHPRI, 0); if (!mhi_ctx->pcie_event_wq) { - pr_err("no memory\n"); + mhi_log(MHI_MSG_ERROR, "no memory\n"); rc = -ENOMEM; return rc; } @@ -4497,7 +4582,8 @@ static int mhi_dev_probe(struct platform_device *pdev) /* PCIe link is already up */ rc = mhi_dev_resume_mmio_mhi_init(mhi_ctx); if (rc) { - pr_err("Error during MHI device initialization\n"); + mhi_log(MHI_MSG_ERROR, + "Error during MHI device initialization\n"); return rc; } } else { @@ -4511,7 +4597,8 @@ static int mhi_dev_probe(struct platform_device *pdev) rc = ep_pcie_register_event(mhi_ctx->phandle, &mhi_ctx->event_reg); if (rc) { - pr_err("Failed to register for events from PCIe\n"); + mhi_log(MHI_MSG_ERROR, + "Failed to register for events from PCIe\n"); return rc; } } diff --git a/drivers/platform/msm/mhi_dev/mhi.h b/drivers/platform/msm/mhi_dev/mhi.h index a7a34668a04f..16e0c1f7ed0a 100644 --- a/drivers/platform/msm/mhi_dev/mhi.h +++ b/drivers/platform/msm/mhi_dev/mhi.h @@ -673,7 +673,9 @@ enum mhi_msg_level { extern uint32_t bhi_imgtxdb; extern enum mhi_msg_level mhi_msg_lvl; extern enum mhi_msg_level mhi_ipc_msg_lvl; +extern enum mhi_msg_level mhi_ipc_err_msg_lvl; extern void *mhi_ipc_log; +extern void *mhi_ipc_err_log; #define mhi_log(_msg_lvl, _msg, ...) do { \ if (_msg_lvl >= mhi_msg_lvl) { \ @@ -682,7 +684,11 @@ extern void *mhi_ipc_log; } \ if (mhi_ipc_log && (_msg_lvl >= mhi_ipc_msg_lvl)) { \ ipc_log_string(mhi_ipc_log, \ - "[0x%x %s] " _msg, bhi_imgtxdb, __func__, ##__VA_ARGS__); \ + "[0x%x %s] " _msg, bhi_imgtxdb, __func__, ##__VA_ARGS__); \ + } \ + if (mhi_ipc_err_log && (_msg_lvl >= mhi_ipc_err_msg_lvl)) { \ + ipc_log_string(mhi_ipc_err_log, \ + "[0x%x %s] " _msg, bhi_imgtxdb, __func__, ##__VA_ARGS__); \ } \ } while (0) diff --git a/drivers/platform/msm/mhi_dev/mhi_dev_net.c b/drivers/platform/msm/mhi_dev/mhi_dev_net.c index c4b9d6972e33..ac236edfe928 100644 --- a/drivers/platform/msm/mhi_dev/mhi_dev_net.c +++ b/drivers/platform/msm/mhi_dev/mhi_dev_net.c @@ -43,7 +43,7 @@ enum mhi_dev_net_dbg_lvl { MSG_NET_reserved = 0x80000000 }; -static enum mhi_dev_net_dbg_lvl mhi_net_msg_lvl = MHI_CRITICAL; +static enum mhi_dev_net_dbg_lvl mhi_net_msg_lvl = MHI_ERROR; static enum mhi_dev_net_dbg_lvl mhi_net_ipc_log_lvl = MHI_VERBOSE; static void *mhi_net_ipc_log; @@ -144,7 +144,7 @@ static void mhi_dev_net_process_queue_packets(struct work_struct *work) struct mhi_req *wreq = NULL; if (mhi_dev_channel_isempty(client->in_handle)) { - mhi_dev_net_log(MHI_INFO, "%s stop network xmmit\n", __func__); + mhi_dev_net_log(MHI_INFO, "stop network xmmit\n"); netif_stop_queue(client->dev); return; } @@ -176,8 +176,9 @@ static void mhi_dev_net_process_queue_packets(struct work_struct *work) spin_unlock_irqrestore(&client->wrt_lock, flags); xfer_data = mhi_dev_write_channel(wreq); if (xfer_data <= 0) { - pr_err("%s(): Failed to write skb len %d\n", - __func__, skb->len); + mhi_dev_net_log(MHI_ERROR, + "Failed to write skb len %d\n", + skb->len); kfree_skb(skb); return; } @@ -186,8 +187,7 @@ static void mhi_dev_net_process_queue_packets(struct work_struct *work) /* Check if free buffers are available*/ if (mhi_dev_channel_isempty(client->in_handle)) { mhi_dev_net_log(MHI_INFO, - "%s buffers are full stop xmit\n", - __func__); + "buffers are full stop xmit\n"); netif_stop_queue(client->dev); break; } @@ -281,7 +281,7 @@ static ssize_t mhi_dev_net_client_read(struct mhi_dev_net_client *mhi_handle) spin_unlock_irqrestore(&mhi_handle->rd_lock, flags); skb = alloc_skb(MHI_NET_DEFAULT_MTU, GFP_KERNEL); if (skb == NULL) { - pr_err("%s(): skb alloc failed\n", __func__); + mhi_dev_net_log(MHI_ERROR, "skb alloc failed\n"); spin_lock_irqsave(&mhi_handle->rd_lock, flags); list_add_tail(&req->list, &mhi_handle->rx_buffers); spin_unlock_irqrestore(&mhi_handle->rd_lock, flags); @@ -298,7 +298,8 @@ static ssize_t mhi_dev_net_client_read(struct mhi_dev_net_client *mhi_handle) bytes_avail = mhi_dev_read_channel(req); if (bytes_avail < 0) { - pr_err("Failed to read chan %d bytes_avail = %d\n", + mhi_dev_net_log(MHI_ERROR, + "Failed to read chan %d bytes_avail = %d\n", chan, bytes_avail); spin_lock_irqsave(&mhi_handle->rd_lock, flags); kfree_skb(skb); @@ -473,7 +474,8 @@ static int mhi_dev_net_enable_iface(struct mhi_dev_net_client *mhi_dev_net_ptr) mhi_dev_net_ether_setup : mhi_dev_net_rawip_setup); if (!netdev) { - pr_err("Failed to allocate netdev for mhi_dev_net\n"); + mhi_dev_net_log(MHI_ERROR, + "Failed to allocate netdev for mhi_dev_net\n"); goto net_dev_alloc_fail; } @@ -488,7 +490,8 @@ static int mhi_dev_net_enable_iface(struct mhi_dev_net_client *mhi_dev_net_ptr) *mhi_dev_net_ctxt = mhi_dev_net_ptr; ret = register_netdev(mhi_dev_net_ptr->dev); if (ret) { - pr_err("Failed to register mhi_dev_net device\n"); + mhi_dev_net_log(MHI_ERROR, + "Failed to register mhi_dev_net device\n"); goto net_dev_reg_fail; } mhi_dev_net_log(MHI_INFO, "Successfully registred mhi_dev_net\n"); @@ -546,12 +549,14 @@ static int mhi_dev_net_open_chan_create_netif(struct mhi_dev_net_client *client) ret = mhi_dev_net_alloc_read_reqs(client); if (ret) { - pr_err("failed to allocate rx req buffers\n"); + mhi_dev_net_log(MHI_ERROR, + "failed to allocate rx req buffers\n"); goto rx_req_failed; } ret = mhi_dev_net_alloc_write_reqs(client); if (ret) { - pr_err("failed to allocate write req buffers\n"); + mhi_dev_net_log(MHI_ERROR, + "failed to allocate write req buffers\n"); goto tx_req_failed; } if (atomic_read(&client->tx_enabled)) { diff --git a/drivers/platform/msm/mhi_dev/mhi_mmio.c b/drivers/platform/msm/mhi_dev/mhi_mmio.c index a6aebc969a59..44f64b679cb5 100644 --- a/drivers/platform/msm/mhi_dev/mhi_mmio.c +++ b/drivers/platform/msm/mhi_dev/mhi_mmio.c @@ -101,7 +101,7 @@ static int mhi_dev_mmio_mask_set_chdb_int_a7(struct mhi_dev *dev, chid_idx = chdb_id/32; if (chid_idx >= MHI_MASK_ROWS_CH_EV_DB) { - pr_err("Invalid channel id:%d\n", chid_idx); + mhi_log(MHI_MSG_ERROR, "Invalid channel id:%d\n", chid_idx); return -EINVAL; } @@ -633,7 +633,7 @@ int mhi_dev_restore_mmio(struct mhi_dev *dev) rc = mhi_dev_mmio_write(dev, MHI_CHDB_INT_MASK_A7_n(i), dev->chdb[i].mask); if (rc) { - mhi_log(MHI_MSG_VERBOSE, + mhi_log(MHI_MSG_ERROR, "Error writing enable for A7\n"); return rc; } diff --git a/drivers/platform/msm/mhi_dev/mhi_ring.c b/drivers/platform/msm/mhi_dev/mhi_ring.c index e7b6fb4c389e..a94cc2389efe 100644 --- a/drivers/platform/msm/mhi_dev/mhi_ring.c +++ b/drivers/platform/msm/mhi_dev/mhi_ring.c @@ -143,7 +143,7 @@ int mhi_dev_update_wr_offset(struct mhi_dev_ring *ring) case RING_TYPE_CMD: rc = mhi_dev_mmio_get_cmd_db(ring, &wr_offset); if (rc) { - pr_err("%s: CMD DB read failed\n", __func__); + mhi_log(MHI_MSG_ERROR, "CMD DB read failed\n"); return rc; } mhi_log(MHI_MSG_VERBOSE, @@ -153,14 +153,14 @@ int mhi_dev_update_wr_offset(struct mhi_dev_ring *ring) case RING_TYPE_ER: rc = mhi_dev_mmio_get_erc_db(ring, &wr_offset); if (rc) { - pr_err("%s: EVT DB read failed\n", __func__); + mhi_log(MHI_MSG_ERROR, "EVT DB read failed\n"); return rc; } break; case RING_TYPE_CH: rc = mhi_dev_mmio_get_ch_db(ring, &wr_offset); if (rc) { - pr_err("%s: CH DB read failed\n", __func__); + mhi_log(MHI_MSG_ERROR, "CH DB read failed\n"); return rc; } mhi_log(MHI_MSG_VERBOSE, @@ -237,7 +237,7 @@ int mhi_dev_process_ring(struct mhi_dev_ring *ring) /* notify the clients that there are elements in the ring */ rc = mhi_dev_process_ring_element(ring, ring->rd_offset); if (rc) - pr_err("Error fetching elements\n"); + mhi_log(MHI_MSG_ERROR, "Error fetching elements\n"); return rc; } mhi_log(MHI_MSG_VERBOSE, @@ -490,19 +490,6 @@ int mhi_ring_start(struct mhi_dev_ring *ring, union mhi_dev_ring_ctx *ctx, ring->ring_shadow.device_va = mhi->ctrl_base.device_va + offset; ring->ring_shadow.host_pa = mhi->ctrl_base.host_pa + offset; - if (ring->type == RING_TYPE_ER) - ring->ring_ctx_shadow = - (union mhi_dev_ring_ctx *) (mhi->ev_ctx_shadow.device_va + - (ring->id - mhi->ev_ring_start) * - sizeof(union mhi_dev_ring_ctx)); - else if (ring->type == RING_TYPE_CMD) - ring->ring_ctx_shadow = - (union mhi_dev_ring_ctx *) mhi->cmd_ctx_shadow.device_va; - else if (ring->type == RING_TYPE_CH) - ring->ring_ctx_shadow = - (union mhi_dev_ring_ctx *) (mhi->ch_ctx_shadow.device_va + - (ring->id - mhi->ch_ring_start)*sizeof(union mhi_dev_ring_ctx)); - ring->ring_ctx_shadow = ring->ring_ctx; if (ring->type != RING_TYPE_ER || ring->type != RING_TYPE_CH) { @@ -574,7 +561,7 @@ void mhi_ring_set_state(struct mhi_dev_ring *ring, return; if (state > RING_STATE_PENDING) { - pr_err("%s: Invalid ring state\n", __func__); + mhi_log(MHI_MSG_ERROR, "Invalid ring state\n"); return; } diff --git a/drivers/platform/msm/mhi_dev/mhi_uci.c b/drivers/platform/msm/mhi_dev/mhi_uci.c index 0039fa48c561..2b458e130201 100644 --- a/drivers/platform/msm/mhi_dev/mhi_uci.c +++ b/drivers/platform/msm/mhi_dev/mhi_uci.c @@ -55,7 +55,7 @@ enum uci_dbg_level { UCI_DBG_reserved = 0x80000000 }; -static enum uci_dbg_level mhi_uci_msg_lvl = UCI_DBG_CRITICAL; +static enum uci_dbg_level mhi_uci_msg_lvl = UCI_DBG_ERROR; static enum uci_dbg_level mhi_uci_ipc_log_lvl = UCI_DBG_INFO; static void *mhi_uci_ipc_log; @@ -944,7 +944,7 @@ static int mhi_uci_read_sync(struct uci_client *uci_handle, int *bytes_avail) struct mhi_req ureq; struct mhi_dev_client *client_handle; - uci_log(UCI_DBG_ERROR, + uci_log(UCI_DBG_INFO, "Sync read for ch %d\n", uci_handle->in_chan); client_handle = uci_handle->in_handle; @@ -985,8 +985,7 @@ static int open_client_mhi_channels(struct uci_client *uci_client) int rc = 0; if (!mhi_uci_are_channels_connected(uci_client)) { - uci_log(UCI_DBG_ERROR, "%s:Channels are not connected\n", - __func__); + uci_log(UCI_DBG_ERROR, "Channels are not connected\n"); return -ENODEV; } @@ -1247,7 +1246,7 @@ static int mhi_state_uevent(struct device *dev, struct kobj_uevent_env *env) rc = mhi_ctrl_state_info(MHI_DEV_UEVENT_CTRL, &info); if (rc) { - pr_err("Failed to obtain MHI_STATE\n"); + uci_log(UCI_DBG_ERROR, "Failed to obtain MHI_STATE\n"); return -EINVAL; } @@ -1257,12 +1256,13 @@ static int mhi_state_uevent(struct device *dev, struct kobj_uevent_env *env) for (i = 0; i < ARRAY_SIZE(mhi_chan_attr_table); i++) { chan_attrib = &mhi_chan_attr_table[i]; if (chan_attrib->state_bcast) { - uci_log(UCI_DBG_ERROR, "Calling notify for ch %d\n", + uci_log(UCI_DBG_INFO, "Calling notify for ch %d\n", chan_attrib->chan_id); rc = mhi_ctrl_state_info(chan_attrib->chan_id, &info); if (rc) { - pr_err("Failed to obtain channel %d state\n", - chan_attrib->chan_id); + uci_log(UCI_DBG_ERROR, + "Failed to obtain channel %d state\n", + chan_attrib->chan_id); return -EINVAL; } nbytes = 0; @@ -1307,7 +1307,7 @@ static ssize_t mhi_uci_ctrl_client_read(struct file *file, "MHI_STATE=DISCONNECTED"); break; default: - pr_err("invalid info:%d\n", info); + uci_log(UCI_DBG_ERROR, "invalid info:%d\n", info); return -EINVAL; } @@ -1329,8 +1329,7 @@ static int __mhi_uci_client_read(struct uci_client *uci_handle, do { if (!mhi_uci_are_channels_connected(uci_handle)) { - uci_log(UCI_DBG_ERROR, - "%s:Channels are not connected\n", __func__); + uci_log(UCI_DBG_ERROR, "Channels are not connected\n"); return -ENODEV; } @@ -1481,8 +1480,7 @@ static ssize_t mhi_uci_client_write(struct file *file, } if (!mhi_uci_are_channels_connected(uci_handle)) { - uci_log(UCI_DBG_ERROR, "%s:Channels are not connected\n", - __func__); + uci_log(UCI_DBG_ERROR, "Channels are not connected\n"); return -ENODEV; } @@ -1541,8 +1539,7 @@ static ssize_t mhi_uci_client_write_iter(struct kiocb *iocb, } if (!mhi_uci_are_channels_connected(uci_handle)) { - uci_log(UCI_DBG_ERROR, "%s:Channels are not connected\n", - __func__); + uci_log(UCI_DBG_ERROR, "Channels are not connected\n"); return -ENODEV; } @@ -1651,7 +1648,7 @@ void uci_ctrl_update(struct mhi_dev_client_cb_reason *reason) if (reason->reason == MHI_DEV_CTRL_UPDATE) { uci_ctrl_handle = &uci_ctxt.ctrl_handle; if (!uci_ctrl_handle) { - pr_err("Invalid uci ctrl handle\n"); + uci_log(UCI_DBG_ERROR, "Invalid uci ctrl handle\n"); return; } @@ -2254,7 +2251,7 @@ int mhi_uci_init(void) /* Control node */ uci_ctxt.cdev_ctrl = cdev_alloc(); if (uci_ctxt.cdev_ctrl == NULL) { - pr_err("%s: ctrl cdev alloc failed\n", __func__); + uci_log(UCI_DBG_ERROR, "ctrl cdev alloc failed\n"); return 0; }