Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp820283pxb; Fri, 22 Apr 2022 11:53:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy72u+oO5uS6g3mwUpGIVQO+RimGvH80hhwr9Evmi0Q+H0Yod1nBfLKM7RABarqK67ioFZJ X-Received: by 2002:a65:4c8e:0:b0:3aa:24bf:9e63 with SMTP id m14-20020a654c8e000000b003aa24bf9e63mr5146179pgt.592.1650653619716; Fri, 22 Apr 2022 11:53:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650653619; cv=none; d=google.com; s=arc-20160816; b=VpwWL1b20HDf8s8tzc+s54h5q+IgDFdhf4JpOlIo77pMQ5kH5KPB5QZA0AaVcxXix7 M5QeCeSCcE937x5/AdH8aRScOsauWWCci6tDAjXunLDPoBAMy1N4Zvlc3033dhi3zhEH w8VwHIC9zRE7UAV79YkuSmtXY7TtcCxddgU17ay5I2EsmD3yTsxJlB49FORJtVcte3ia jf3ox8m8tjJK7zNdQzvq55pwm2xXducaIE17SfZL1g3QIuU9fN0tNGiiMks4XXLqv+nl xQ7XdEOQGiPeC9hVD80GoiwvGb+9K/2OKOUkIztxRMZhBdzhBjVDg7MO5fMHa+9o4VxS dmBw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=TUDh1P4g0jsnsPATt1iFcZ2ZfjR5qo7apigNyVsZJ3k=; b=zhRUqe00wgOkCJS+SFycYeGBaB6hcTd3UHmacgnDC2YxYWpshQQopvF7miPvyg6aP0 tKsDgOGTkgO0Hp3LhWhe2nuceflY3+xJQx4eW6M9pXdiMI5LbSPSDB/zt0x/2N6YAvl8 VqkDPLNZaDJK/6X8oktOTlautdI5nqcNlYagGL61ynHG/dreCkdq/VqaaI7ICFypPeAQ 6Hw0176UblCmMSb4nljwVZniih+Fxfg6cBo/BhkSGIUTmRSsl8/pjgSk2mlY0WR0WbzK 8PRDxPrNSJpCbYiU3zJWMeyy6zyEVR8LfXYhks+LPGmL5MgLRcRWWw07U/ycNVMElbck DW1Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcdkim header.b=oHmQAETe; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id g7-20020a056a000b8700b0050ad51e0abbsi7171604pfj.70.2022.04.22.11.53.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Apr 2022 11:53:39 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcdkim header.b=oHmQAETe; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id DE46517DA0B; Fri, 22 Apr 2022 11:17:54 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347014AbiDRRZl (ORCPT + 99 others); Mon, 18 Apr 2022 13:25:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43594 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242820AbiDRRZj (ORCPT ); Mon, 18 Apr 2022 13:25:39 -0400 Received: from alexa-out.qualcomm.com (alexa-out.qualcomm.com [129.46.98.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2C15133A1A; Mon, 18 Apr 2022 10:23:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; i=@quicinc.com; q=dns/txt; s=qcdkim; t=1650302580; x=1681838580; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=TUDh1P4g0jsnsPATt1iFcZ2ZfjR5qo7apigNyVsZJ3k=; b=oHmQAETe7jJwaTHo6H1JyL3K2JdSVPH0Xmdw1SM0cup2JMq/R99Iui0W RmmlGSMArPNKSdrn3YlIsyqkfwd8Of+an9QXovuGVLh0SCxepJAErM/j8 baOPeiq4w/d6U+nWuXQKqk/5lWVkELSX4jqMdShNJJ2PfCA8heei8WwJs E=; Received: from ironmsg07-lv.qualcomm.com ([10.47.202.151]) by alexa-out.qualcomm.com with ESMTP; 18 Apr 2022 10:22:59 -0700 X-QCInternal: smtphost Received: from nasanex01c.na.qualcomm.com ([10.47.97.222]) by ironmsg07-lv.qualcomm.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Apr 2022 10:22:59 -0700 Received: from nalasex01a.na.qualcomm.com (10.47.209.196) by nasanex01c.na.qualcomm.com (10.47.97.222) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.22; Mon, 18 Apr 2022 10:22:52 -0700 Received: from jhugo-lnx.qualcomm.com (10.80.80.8) by nalasex01a.na.qualcomm.com (10.47.209.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.22; Mon, 18 Apr 2022 10:22:51 -0700 From: Jeffrey Hugo To: , , CC: , , , Jeffrey Hugo Subject: [PATCH v4] bus: mhi: host: Wait for ready state after reset Date: Mon, 18 Apr 2022 11:22:42 -0600 Message-ID: <1650302562-30964-1-git-send-email-quic_jhugo@quicinc.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nalasex01a.na.qualcomm.com (10.47.209.196) X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org After the device has signaled the end of reset by clearing the reset bit, it will automatically reinit MHI and the internal device structures. Once That is done, the device will signal it has entered the ready state. Signaling the ready state involves sending an interrupt (MSI) to the host which might cause IOMMU faults if it occurs at the wrong time. If the controller is being powered down, and possibly removed, then the reset flow would only wait for the end of reset. At which point, the host and device would start a race. The host may complete its reset work, and remove the interrupt handler, which would cause the interrupt to be disabled in the IOMMU. If that occurs before the device signals the ready state, then the IOMMU will fault since it blocked an interrupt. While harmless, the fault would appear like a serious issue has occurred so let's silence it by making sure the device hits the ready state before the host completes its reset processing. Signed-off-by: Jeffrey Hugo Reviewed-by: Hemant Kumar Reviewed-by: Manivannan Sadhasivam --- v4: Cleanup email domain change v3: Rebase and use dev_err over dev_warn v2: Fix subject and remove use of cur_state drivers/bus/mhi/host/pm.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/bus/mhi/host/pm.c b/drivers/bus/mhi/host/pm.c index 3d90b8e..c000a92 100644 --- a/drivers/bus/mhi/host/pm.c +++ b/drivers/bus/mhi/host/pm.c @@ -476,6 +476,15 @@ static void mhi_pm_disable_transition(struct mhi_controller *mhi_cntrl) * hence re-program it */ mhi_write_reg(mhi_cntrl, mhi_cntrl->bhi, BHI_INTVEC, 0); + + if (!MHI_IN_PBL(mhi_get_exec_env(mhi_cntrl))) { + /* wait for ready to be set */ + ret = mhi_poll_reg_field(mhi_cntrl, mhi_cntrl->regs, + MHISTATUS, + MHISTATUS_READY_MASK, 1, 25000); + if (ret) + dev_err(dev, "Device failed to enter READY state\n"); + } } dev_dbg(dev, -- 2.7.4