From patchwork Wed Dec 28 16:16:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manivannan Sadhasivam X-Patchwork-Id: 37228 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp1970172wrt; Wed, 28 Dec 2022 08:19:58 -0800 (PST) X-Google-Smtp-Source: AMrXdXubBk2jWgkr4OPKkit57bReAgvYA1lbg9d6dJyffV3JbN5stFmpRZDwr7nBzeF4PkLJVzbl X-Received: by 2002:a05:6402:25c6:b0:46c:d2a3:76b3 with SMTP id x6-20020a05640225c600b0046cd2a376b3mr23547526edb.14.1672244398333; Wed, 28 Dec 2022 08:19:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672244398; cv=none; d=google.com; s=arc-20160816; b=uFOtfkYXxk5eDnBcaZt88Bj2xGCJ0D0+ueiMjCDsp8rX3a8m7mplzlG6ug9W8Myi1h Q3AjpLXxG9GLkI0mFtVVidCd3R8usEoixp6kEtgz1eJeob60SDzGT1G1RBEPGv/djtXC ouQ4CD+vaLXL3KgjlEV8WlW6DC68E/i7miGsoHrlZ7OBnHNZgG6XVXSIwOi82qPmzyII RTHe46oGaLraDf37TY2tLSKvNj6TCuSb+5AecxpucQc5du2vgWHBjIrlpmH7Oi6kdqaK rJpJl6EKAGs1vaKfFvpR1p7Eb71Ej4C16giY6DzF7ZjhamB7xugfHS9UAEwCRp4GvARI OEBg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Xfte3Mm+Q7Ad+w1mdjEpYINvANGy6sSgiMeaTWx+ZUM=; b=jxsbK2V9yTlppyBoCZIX/uX9YIfaxrlrSjf15Whc04ZLHclBanNTIMOmNTvA2BULIB WOqCAeLJUUflIvahldXWQImYbVAPigTLoJv8jvhOOl/4tQTAGrWRSKb97ccDWBGG0Joj lK8AhED01LdFzXqfLbBJnx1lqJ2bXjCv+jaffDS65W+1T2O4grWmzoDFlV5pTdvS+e3c MBZ9TA4j7z627DYM1xQZOQ0ap8Dgcrri2VvlBbS94LfM3hEi0ZYTyZtYSi3pQtSLZ25m cslffGvLeVq2FXXkAsAVK5yHQID6/PDouzh8kquWid7vMyGEX/00p3ChUajE4we1+Z3v OkMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=AVus0hl2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ch2-20020a0564021bc200b0047e99118fe1si12469441edb.595.2022.12.28.08.19.34; Wed, 28 Dec 2022 08:19:58 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=AVus0hl2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234633AbiL1QTN (ORCPT + 99 others); Wed, 28 Dec 2022 11:19:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36762 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234360AbiL1QSl (ORCPT ); Wed, 28 Dec 2022 11:18:41 -0500 Received: from mail-pl1-x629.google.com (mail-pl1-x629.google.com [IPv6:2607:f8b0:4864:20::629]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CC71E140C8 for ; Wed, 28 Dec 2022 08:17:19 -0800 (PST) Received: by mail-pl1-x629.google.com with SMTP id s7so16442414plk.5 for ; Wed, 28 Dec 2022 08:17:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Xfte3Mm+Q7Ad+w1mdjEpYINvANGy6sSgiMeaTWx+ZUM=; b=AVus0hl2aWU+oOARmRRFGyJNgBJkZJ01FOmx33rCQRJh5e3ByUiks54iFbVwZwKACE Es0ZECVwsUMNP4xRgUeRbGIYwuOwuzZWg+zQYSsYGmdan5/M8sCS2KR8Rq+wqebSZCI0 YVr/UAo8BFAmVWVKpmhFefnGhsnSDhRUr35t1xUeTDzLBbeso2ykmjX87W7ykNtWQ8dM 88XMvC3g22yUbDAy61wH2hjFuOIvw9le+qCO2xL/Gls+45derwF9U7ZrVm5i4sWPnrYQ TzGUV007cL84pFaCNuETvGaUJwdwMqNrqe01IyqUiglkyeg3XRl5lk7JYq6GalJGln2l jRhw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Xfte3Mm+Q7Ad+w1mdjEpYINvANGy6sSgiMeaTWx+ZUM=; b=CHBvsvEQIcBRbArhoCFMXxROQYec3tyqO9NIxHdtixUqf7/CgeN/N3mQl1T8qRKMT2 jJ3So8cjmjX45Y7LU8C5W5xGUXV99RxqNtNd1QMIfzfXkrytwZ0oURENXi5G3BT8y8PO M1nLm6K/v52SFVhfLbD+0ZWicBEfiyV4mFUiD1aLmfWDox2KKgrr0pmmc/aSViwKqHlE KnH7Hy/4i+xAp8WJIKZVC+xs8o8PoD4qX59Ia2OlEup5869TUtzhTocMeMcTrz4r9nCB 9qrxuHoq3/vdpHQ3Ln3uZZkkRXKWCi+agbVW9BOrGyKXTsqd6UttZ5wb5eFSez9w7vDG OEmA== X-Gm-Message-State: AFqh2kp24mrrp24yTYo2dbLBRAuzW7sTy3Y9EANGifqWSfHxtzTHCw2O TbuAYZtp71mikGrVypZFU7pS X-Received: by 2002:a17:902:8c8b:b0:189:c536:c745 with SMTP id t11-20020a1709028c8b00b00189c536c745mr27298284plo.2.1672244239307; Wed, 28 Dec 2022 08:17:19 -0800 (PST) Received: from localhost.localdomain ([117.217.178.100]) by smtp.gmail.com with ESMTPSA id s3-20020a170902c64300b00186abb95bfdsm11256798pls.25.2022.12.28.08.17.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Dec 2022 08:17:18 -0800 (PST) From: Manivannan Sadhasivam To: mhi@lists.linux.dev Cc: linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Manivannan Sadhasivam Subject: [PATCH 1/6] bus: mhi: ep: Power up/down MHI stack during MHI RESET Date: Wed, 28 Dec 2022 21:46:59 +0530 Message-Id: <20221228161704.255268-2-manivannan.sadhasivam@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221228161704.255268-1-manivannan.sadhasivam@linaro.org> References: <20221228161704.255268-1-manivannan.sadhasivam@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=ham 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1753475342352079232?= X-GMAIL-MSGID: =?utf-8?q?1753475342352079232?= During graceful shutdown scenario, host will issue MHI RESET to the endpoint device before initiating shutdown. In that case, it makes sense to completely power down the MHI stack as sooner or later the access to MMIO registers will be prohibited. Also, the stack needs to be powered up in the case of SYS_ERR to recover the device. Signed-off-by: Manivannan Sadhasivam Reviewed-by: Jeffrey Hugo --- drivers/bus/mhi/ep/main.c | 35 +++++++---------------------------- 1 file changed, 7 insertions(+), 28 deletions(-) diff --git a/drivers/bus/mhi/ep/main.c b/drivers/bus/mhi/ep/main.c index 1dc8a3557a46..55209d42a995 100644 --- a/drivers/bus/mhi/ep/main.c +++ b/drivers/bus/mhi/ep/main.c @@ -973,11 +973,9 @@ static void mhi_ep_abort_transfer(struct mhi_ep_cntrl *mhi_cntrl) static void mhi_ep_reset_worker(struct work_struct *work) { struct mhi_ep_cntrl *mhi_cntrl = container_of(work, struct mhi_ep_cntrl, reset_work); - struct device *dev = &mhi_cntrl->mhi_dev->dev; enum mhi_state cur_state; - int ret; - mhi_ep_abort_transfer(mhi_cntrl); + mhi_ep_power_down(mhi_cntrl); spin_lock_bh(&mhi_cntrl->state_lock); /* Reset MMIO to signal host that the MHI_RESET is completed in endpoint */ @@ -990,27 +988,8 @@ static void mhi_ep_reset_worker(struct work_struct *work) * issue reset during shutdown also and we don't need to do re-init in * that case. */ - if (cur_state == MHI_STATE_SYS_ERR) { - mhi_ep_mmio_init(mhi_cntrl); - - /* Set AMSS EE before signaling ready state */ - mhi_ep_mmio_set_env(mhi_cntrl, MHI_EE_AMSS); - - /* All set, notify the host that we are ready */ - ret = mhi_ep_set_ready_state(mhi_cntrl); - if (ret) - return; - - dev_dbg(dev, "READY state notification sent to the host\n"); - - ret = mhi_ep_enable(mhi_cntrl); - if (ret) { - dev_err(dev, "Failed to enable MHI endpoint: %d\n", ret); - return; - } - - enable_irq(mhi_cntrl->irq); - } + if (cur_state == MHI_STATE_SYS_ERR) + mhi_ep_power_up(mhi_cntrl); } /* @@ -1089,11 +1068,11 @@ EXPORT_SYMBOL_GPL(mhi_ep_power_up); void mhi_ep_power_down(struct mhi_ep_cntrl *mhi_cntrl) { - if (mhi_cntrl->enabled) + if (mhi_cntrl->enabled) { mhi_ep_abort_transfer(mhi_cntrl); - - kfree(mhi_cntrl->mhi_event); - disable_irq(mhi_cntrl->irq); + kfree(mhi_cntrl->mhi_event); + disable_irq(mhi_cntrl->irq); + } } EXPORT_SYMBOL_GPL(mhi_ep_power_down);