usb_bam: Delete IPA resources in usb_bam_remove()

Whenever dwc3_msm_probe() fails, it calls of_depopulate() to remove child
devices as part of cleanup. Due to this, usb_bam_remove() gets called to
do cleanup. But this API is not deleting IPA resources created during
probe and leads to creation of IPA resources fail, when probe is called
again. This eventually results in crash, when IPA driver calls notify
callback after PROD resource granted. Hence fix it by deleting IPA
resources in usb_bam_remove().

Also change enum type of ipa_rm_resource_prod/ipa_rm_resource_cons arrays
to enum ipa_rm_resource_name to fix sparse errors.

Change-Id: I3d9d0e1b26f1de0ba2b56b42c7e10a097d4fa8be
Signed-off-by: Vijayavardhan Vennapusa <vvreddy@codeaurora.org>
This commit is contained in:
Vijayavardhan Vennapusa 2017-09-08 15:40:21 +05:30
parent 8aedd70842
commit 4fe177ec88

View file

@ -126,13 +126,13 @@ static char *bam_enable_strings[MAX_BAMS] = {
* CI_CTRL & DWC3_CTRL shouldn't be used simultaneously
* since both share the same prod & cons rm resourses
*/
static enum ipa_client_type ipa_rm_resource_prod[MAX_BAMS] = {
static enum ipa_rm_resource_name ipa_rm_resource_prod[MAX_BAMS] = {
[CI_CTRL] = IPA_RM_RESOURCE_USB_PROD,
[HSIC_CTRL] = IPA_RM_RESOURCE_HSIC_PROD,
[DWC3_CTRL] = IPA_RM_RESOURCE_USB_PROD,
};
static enum ipa_client_type ipa_rm_resource_cons[MAX_BAMS] = {
static enum ipa_rm_resource_name ipa_rm_resource_cons[MAX_BAMS] = {
[CI_CTRL] = IPA_RM_RESOURCE_USB_CONS,
[HSIC_CTRL] = IPA_RM_RESOURCE_HSIC_CONS,
[DWC3_CTRL] = IPA_RM_RESOURCE_USB_CONS,
@ -1625,6 +1625,22 @@ static void usb_bam_ipa_create_resources(enum usb_ctrl cur_bam)
}
}
static void usb_bam_ipa_delete_resources(enum usb_ctrl cur_bam)
{
int ret;
ret = ipa_rm_delete_resource(ipa_rm_resource_prod[cur_bam]);
if (ret)
log_event_err("%s: Failed to delete USB_PROD resource\n",
__func__);
ret = ipa_rm_delete_resource(ipa_rm_resource_cons[cur_bam]);
if (ret)
log_event_err("%s: Failed to delete USB_CONS resource\n",
__func__);
}
static void wait_for_prod_granted(enum usb_ctrl cur_bam)
{
int ret;
@ -3401,6 +3417,7 @@ static int usb_bam_remove(struct platform_device *pdev)
{
struct usb_bam_ctx_type *ctx = dev_get_drvdata(&pdev->dev);
usb_bam_ipa_delete_resources(ctx->usb_bam_data->bam_type);
usb_bam_unregister_panic_hdlr();
sps_deregister_bam_device(ctx->h_bam);
destroy_workqueue(ctx->usb_bam_wq);