Received: by 2002:a19:f614:0:0:0:0:0 with SMTP id x20csp36886lfe; Fri, 15 Apr 2022 18:15:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzXEnexvLwzwOYCKe3KKtIkCL0qXLhPfO4t1gQ0OxpzpAivO8OFYQAXIvOioZYdz6x/JtyV X-Received: by 2002:a17:902:9b92:b0:158:57d8:3a20 with SMTP id y18-20020a1709029b9200b0015857d83a20mr1568333plp.34.1650071732188; Fri, 15 Apr 2022 18:15:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650071732; cv=none; d=google.com; s=arc-20160816; b=X4ZDrGnRENTKxadTMebQnL9Y3iD3z/OxPd0kdoADowiQjZgyMLcK50EaV8yjZcx53s k3vtVkevn4w6yZXwSniREUhcKVYGy+cObvwjeUTh+QsZtlTQwGGqZDm+7ebJp651Tek2 HEQ8gaEwryzu1UDonSKPXpx4tCXTgz/gWeLzteEcu5W16nQlST8TjuZwmxrTRAGltv19 84tJrEhxAQ9WYNdv/I+F7to11qrVWg7vAn9eg53cmIgbn6QT7bFI4zcW3cUWRNBZpOe9 bIdskFxcu9eXtSoF0occMh+UeHsovr45pj0Wh61yylgpBS+Up2FK5Lt0BjSauchjfS4p waYA== 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=3kIdWbaHtEU0x9HW6lYv/3aJs5QjFHoVlujqamdmcyc=; b=nH3mOcUZBOOmt3Q4NRuwPKQeXJt9Lw+mW9IdDL21tD6Aov+++6U4MT7Jn9dGsfTRik 2MT9UMlVmFfZNOhKW2hmD892ljCY4Qu8z5PxaZW/a6nSMZVHY7ekJlt01USipTftuf84 Atsgz/8ag47oGIAlmIe3BdNpad9uw/DyyZhX+d3EjHWqQCw8OaurRIaj0kWg43ycPdZz 5LNADZYrE17H8PGe+KQToCXhXSCklvSyVYkE66tzWPHMuO6lsPCKijmmLh9e1XjrB0dq XYjjDBmWHzM/YJ270OZlNoOEWs1hbLfK14msPzTHadvmEvY9ciV2VGhTb/eBairv8Tru nglg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcdkim header.b=AXfVHdMq; 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 z3-20020a6553c3000000b0039d99f8ad4fsi2749920pgr.814.2022.04.15.18.15.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Apr 2022 18:15:32 -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=AXfVHdMq; 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 02F20137F4F; Fri, 15 Apr 2022 17:52:11 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236499AbiDMSzK (ORCPT + 99 others); Wed, 13 Apr 2022 14:55:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38986 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230176AbiDMSzI (ORCPT ); Wed, 13 Apr 2022 14:55:08 -0400 Received: from alexa-out.qualcomm.com (alexa-out.qualcomm.com [129.46.98.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BF51F3C493; Wed, 13 Apr 2022 11:52:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; i=@quicinc.com; q=dns/txt; s=qcdkim; t=1649875964; x=1681411964; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=3kIdWbaHtEU0x9HW6lYv/3aJs5QjFHoVlujqamdmcyc=; b=AXfVHdMqLIdOuk2XVpxhtiZLKOP0BGhBxy0n7qbJbKGanEDwZldC1qcg h9NKxfe1G6zkKKBwi37n2U3ngcg7+kUarLCWFQ/btRPQfi5hW/fIUtob7 yH0pxRqI4y4pCxZEihVts3dVbFwO0/H4ALHf146tpEEIs3DP9x4tjNN4a 4=; Received: from ironmsg09-lv.qualcomm.com ([10.47.202.153]) by alexa-out.qualcomm.com with ESMTP; 13 Apr 2022 11:52:43 -0700 X-QCInternal: smtphost Received: from nasanex01c.na.qualcomm.com ([10.47.97.222]) by ironmsg09-lv.qualcomm.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Apr 2022 11:52:43 -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; Wed, 13 Apr 2022 11:52:42 -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; Wed, 13 Apr 2022 11:52:41 -0700 From: Jeffrey Hugo To: , , CC: , , , Jeffrey Hugo , "Jeffrey Hugo" Subject: [PATCH v3] bus: mhi: host: Wait for ready state after reset Date: Wed, 13 Apr 2022 12:52:26 -0600 Message-ID: <1649875946-32516-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,T_SCC_BODY_TEXT_LINE 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 From: Jeffrey Hugo 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 Signed-off-by: Jeffrey Hugo --- 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 a0e91bd..f46158e 100644 --- a/drivers/bus/mhi/host/pm.c +++ b/drivers/bus/mhi/host/pm.c @@ -483,6 +483,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