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); From patchwork Wed Dec 28 16:17:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manivannan Sadhasivam X-Patchwork-Id: 37230 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp1970378wrt; Wed, 28 Dec 2022 08:20:28 -0800 (PST) X-Google-Smtp-Source: AMrXdXuThVioTMzCq49f5r+NaSesEQKw2bV8chgmahxSrL4hgTQxLeTNAxGW2NezBhYwSvlA/p4s X-Received: by 2002:a05:6402:4518:b0:46c:b2a7:1e03 with SMTP id ez24-20020a056402451800b0046cb2a71e03mr18979952edb.36.1672244428531; Wed, 28 Dec 2022 08:20:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672244428; cv=none; d=google.com; s=arc-20160816; b=eB0CrWOu/iub6mMrqR5w82OJPsz86oIy02JTb05JMccWz1or3VdZHBqBGcrHBHUwVt 9GFXDejF8Z4nUnkOHAkpTbqX3VgvPMjwroYzB/eqNhE7LibLWHA1y21HRSUiRQV1OFe4 5hTFXZEvmu9dSe/h5kKuYrjLZEJo8ozhe62r4zrUg0IqRCWAuw8N/W2dc1WbsoT/SATE e6ivTHWqv7G4OarBcjJt1KTchnC30u5VFdQXeznkO13la2+1o6mZjn5zywLmEdMJm8/2 xIuX11NrLTo8n43QHIQYcpGe8u5HeyOnpzYMz3w4tFClzK/kkzoVMRga3jvUiSKPfRm5 E7cg== 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=cTBEJ8Yt1F+qFY4dSzBFOLsJDCyD/sILn8NSazfFNCk=; b=E1mxfV1pAvRGBzixqKTyHNHFbmKqg0M4uK+RBRNycunpAGRC7BY1Frf323nBJQv+vs t99D03Qxxxlh6JpBsvyBfgLwzwaWdof+smOnhnYJRrkiPiJqfXLyzae7AkIRMepWBrdh vgT7wuZJmljNQbNla8R/aNRx7F2jN+LrZD2INQ6vbXqR4Xutk0pEcreH4xPu2UMENYvQ iGcQpzdM6OaVEPcJb4PgnFS/U1R/cEJhAs79q0ydVskImQQSkrt/8oQ/mRNyBVuwRaL7 jjGsfotWpMWZbKOgjnsREU5HhJz8+pye2ngg+TcVDzy61nqh09tyikMML7ELlrd5eX/n //TA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="dj/Ub+3k"; 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 g12-20020a056402090c00b0048017a9576bsi13593129edz.543.2022.12.28.08.20.04; Wed, 28 Dec 2022 08:20:28 -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="dj/Ub+3k"; 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 S234571AbiL1QTT (ORCPT + 99 others); Wed, 28 Dec 2022 11:19:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36808 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234439AbiL1QSn (ORCPT ); Wed, 28 Dec 2022 11:18:43 -0500 Received: from mail-pj1-x1030.google.com (mail-pj1-x1030.google.com [IPv6:2607:f8b0:4864:20::1030]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7FE2619C0C for ; Wed, 28 Dec 2022 08:17:23 -0800 (PST) Received: by mail-pj1-x1030.google.com with SMTP id o1-20020a17090a678100b00219cf69e5f0so20455600pjj.2 for ; Wed, 28 Dec 2022 08:17:23 -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=cTBEJ8Yt1F+qFY4dSzBFOLsJDCyD/sILn8NSazfFNCk=; b=dj/Ub+3kYN0/agt2gS0Famnp0N3dkHl3+FQoEtgK8tVZZmkz0cvmZhpxMoXa1eohso W/q7ffJ3CL2rdK75bB9J1pelQS2Gl7fVyTt/u6b0c2MzkYmsDpSLTJ+n5S/PkQMVpxpg W3tx3uGeOsiW3kipxMk+3R6nTT0sfKA0ROiAjB2bdYkF6U4xG1RWl8CKDDbnBLmgQu/n ACSEHvnEFfsHMdlRyJjvYR5Q2ywytVYCohuJfc9xu46q4Lyb2vvy+gNZ4T48sjPzEgg/ ayNGNThqpMWVae/tFgumbIJFspGofWHAyjI7Q3rCIajcGJPV2nFAxsQnkr1zhMyVlz8H 8Gyw== 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=cTBEJ8Yt1F+qFY4dSzBFOLsJDCyD/sILn8NSazfFNCk=; b=BQY+RNsVhWZ1XTW/ynN+Yl1/upJi1NKbJyo3Zsb877a2FoddJW9ZKOWPTQwcRTI6b0 xl7DiiR3AewZ17j86VSbWnaHOpfpUMv1c/2G1STvSfF7GKd8VNr/vKbwlcjd/9ZkoBum 6K+IDFYxnpYvAZ3vAeT6sRwKBPnYuF2gm+fT8NXspif5XG3I+Ds7svkPztp8cfPMztpH KFVYbFEdMqlgQgxigG3UGEFVNaOz0yOKfiLDH5siKfgkx9S22LRflRPl93j5E79nOb8g y63u/+QWp+Yl+whXfMz1GFJGQJspjRCrkPPy1ctF4nEEChes+nyiDAXoIriPwokHFECu Nd6g== X-Gm-Message-State: AFqh2kqb0mk7ty63r4CbjHstYhqxkQEqNWDsmoMDbbrLMnJFKDBjwcrc PHIdC1gYRIbiiclmB5Wp0ZeW X-Received: by 2002:a17:902:cecf:b0:191:191f:e7a7 with SMTP id d15-20020a170902cecf00b00191191fe7a7mr36963609plg.69.1672244242997; Wed, 28 Dec 2022 08:17:22 -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.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Dec 2022 08:17:21 -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 2/6] bus: mhi: ep: Check if the channel is supported by the controller Date: Wed, 28 Dec 2022 21:47:00 +0530 Message-Id: <20221228161704.255268-3-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?1753475374099464439?= X-GMAIL-MSGID: =?utf-8?q?1753475374099464439?= Before processing the command ring for the channel, check if the channel is supported by the controller or not. Signed-off-by: Manivannan Sadhasivam Reviewed-by: Jeffrey Hugo --- drivers/bus/mhi/ep/main.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/bus/mhi/ep/main.c b/drivers/bus/mhi/ep/main.c index 55209d42a995..8b065a3cc848 100644 --- a/drivers/bus/mhi/ep/main.c +++ b/drivers/bus/mhi/ep/main.c @@ -123,6 +123,13 @@ static int mhi_ep_process_cmd_ring(struct mhi_ep_ring *ring, struct mhi_ring_ele int ret; ch_id = MHI_TRE_GET_CMD_CHID(el); + + /* Check if the channel is supported by the controller */ + if ((ch_id > mhi_cntrl->max_chan) || !mhi_cntrl->mhi_chan[ch_id].name) { + dev_err(dev, "Channel (%u) not supported!\n", ch_id); + return -ENODEV; + } + mhi_chan = &mhi_cntrl->mhi_chan[ch_id]; ch_ring = &mhi_cntrl->mhi_chan[ch_id].ring; From patchwork Wed Dec 28 16:17:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manivannan Sadhasivam X-Patchwork-Id: 37229 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp1970212wrt; Wed, 28 Dec 2022 08:20:03 -0800 (PST) X-Google-Smtp-Source: AMrXdXusw6TU2xs3i0NZzwjKFsv6aqOpxxWwcbVuveRgwfRlhU+m303qLq9lnWfbcXRbzyIftvii X-Received: by 2002:a05:6402:685:b0:46c:e558:ce60 with SMTP id f5-20020a056402068500b0046ce558ce60mr21907359edy.22.1672244403409; Wed, 28 Dec 2022 08:20:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672244403; cv=none; d=google.com; s=arc-20160816; b=UrOCzF2u+zfeKeulrd04A7SZgVY8dWRhmeEPUlL6hxYY+9jUj+VNdky0RzgJF5yfJX Jbg9ZefA5Mil9zSmqImv8JZ2Lbigj5DBmfsJUwzTazcW1ZmLLvirixI11lKqOL2+dtNT tz0QPAiufKd1q6CUZDmVG5ITzZjP633FWS+offzXoK+SjDjzuqHVxNDL7lDnmd/cy5Ln 0SgXWdPKuVIe/trTMNsLvwe1f6DzzP8GFetxfe3pa3E6V2JO55+VekO1/ObtVvz1fmoL BXQI3IxS2NDVK0M7z4gEI1wwo8FRN0yqDUOUhcLSG/vD4fEiD//7OHRXXXc4ApaY2ZGK n2yA== 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=nCFU0KCqTh7FlQ8evG955AiRt86XIvSnki+8nWo+njQ=; b=w950BUZQ3l84aF9U5/DDJHJrtWvM8xx01ozfW9ymlcRbAOS5Zs4e0E5Fq9/Cbx2JlV p1fZA8P0qh8IMA7OupwXYAZPpSefvX/Ce9GFb7dQRaKo3iUB6IHbo6d0EVt6W22BFHpH cQl5aQi9ptwACRL4shUs/iEp9DRlB35gylUJqNZf/Smf6lMLK4LyDWvunEi//hg3cHru 6fMT1zTTdgx/QyXtl9fRiazv3wY13Gw2ZvePk7YDa1FOruP7dfYWlWrGsedIiKtwo9kX FqDgGgXXg6RVUGNe7ScUe58PZ29c8/2a3DP04MGzr7sixr2FiihP2rCuLQNtjcaF/C52 C5kQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=GC4TcWpB; 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 k6-20020a056402048600b0046fbd084ea6si11889870edv.142.2022.12.28.08.19.39; Wed, 28 Dec 2022 08:20:03 -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=GC4TcWpB; 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 S234637AbiL1QTW (ORCPT + 99 others); Wed, 28 Dec 2022 11:19:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36532 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234438AbiL1QSo (ORCPT ); Wed, 28 Dec 2022 11:18:44 -0500 Received: from mail-pj1-x1033.google.com (mail-pj1-x1033.google.com [IPv6:2607:f8b0:4864:20::1033]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 80DBF19C16 for ; Wed, 28 Dec 2022 08:17:27 -0800 (PST) Received: by mail-pj1-x1033.google.com with SMTP id c8-20020a17090a4d0800b00225c3614161so13303097pjg.5 for ; Wed, 28 Dec 2022 08:17:27 -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=nCFU0KCqTh7FlQ8evG955AiRt86XIvSnki+8nWo+njQ=; b=GC4TcWpBQl00n4Y1fqaF8bTVq2/KnhyWyJ3s4AMB8/9MIP9ntBMY0TWweRIge8i1EQ lk4F1KiY+FtYLf2e7QqDESspd2fPqQoqPNNvhGinnvehLQ2M9LZ5gT14gT+7XcyvXzT1 rx1YJowuaJrw3OYziAYFJwAWOdKSo27bKmzAg4SM8exV+5Jp7tTRJTK2YN9Db2TJjIO6 KKXS2G8qz4MkJT+3Ky6SZklbrn/zo9a7xZbs5o49mRBSE7+5f6yy0+XiHzlBrlJNX9yW 3DgOnA3pjb+V1nngG6/WLfY/BaSWyelZpfesVsTNQPHd/iJFXocVBjkq7J//BxUxSsDv jMQg== 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=nCFU0KCqTh7FlQ8evG955AiRt86XIvSnki+8nWo+njQ=; b=laV8NmdiXGPp9wNbzeRMSJOH6jDVQRR+7ur6ENMx28nU9ktPhQlxFQkNnYlhn6OTKW p2IBTxYcm9b6kLoxyeuWks5G21jwcAPjn3FxgylhHsuSenLuBB/a5VHXkmx9TdaGteYY ugtjvzHRQGF6aLLjWx8YSoDgrVvhfWPQxpyvIHAnpuoIE851fZo5BgcuLkspRtYrVWFq p5R4PN04alCVIWHNPUfVuxiC9gDjm/YD6uXOpnXt21/MzIlBOw8y3wlf7HEoMsWRyGFt UASgUGA6q87b0WlFt7HUMDaL8G5FZH+rixOSi3MFxk/9cp1A27qcWw4PbRJ49nPi7G9u 9HIg== X-Gm-Message-State: AFqh2kp9xRWH29yzr/SUJ071bSB+Rui8A0hQ+xKnP6+IdTi1gGSutq6q 6JHcWUO6sclzD8ZcLxVfoR/a X-Received: by 2002:a17:902:b401:b0:189:aa51:e27f with SMTP id x1-20020a170902b40100b00189aa51e27fmr32379244plr.44.1672244246949; Wed, 28 Dec 2022 08:17:26 -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.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Dec 2022 08:17:26 -0800 (PST) From: Manivannan Sadhasivam To: mhi@lists.linux.dev Cc: linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Manivannan Sadhasivam , stable@vger.kernel.org Subject: [PATCH 3/6] bus: mhi: ep: Only send -ENOTCONN status if client driver is available Date: Wed, 28 Dec 2022 21:47:01 +0530 Message-Id: <20221228161704.255268-4-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?1753475347453873162?= X-GMAIL-MSGID: =?utf-8?q?1753475347453873162?= For the STOP and RESET commands, only send the channel disconnect status -ENOTCONN if client driver is available. Otherwise, it will result in null pointer dereference. Cc: # 5.19 Fixes: e827569062a8 ("bus: mhi: ep: Add support for processing command rings") Signed-off-by: Manivannan Sadhasivam Reviewed-by: Jeffrey Hugo --- drivers/bus/mhi/ep/main.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/drivers/bus/mhi/ep/main.c b/drivers/bus/mhi/ep/main.c index 8b065a3cc848..7d68b00bdbcf 100644 --- a/drivers/bus/mhi/ep/main.c +++ b/drivers/bus/mhi/ep/main.c @@ -203,9 +203,11 @@ static int mhi_ep_process_cmd_ring(struct mhi_ep_ring *ring, struct mhi_ring_ele mhi_ep_mmio_disable_chdb(mhi_cntrl, ch_id); /* Send channel disconnect status to client drivers */ - result.transaction_status = -ENOTCONN; - result.bytes_xferd = 0; - mhi_chan->xfer_cb(mhi_chan->mhi_dev, &result); + if (mhi_chan->xfer_cb) { + result.transaction_status = -ENOTCONN; + result.bytes_xferd = 0; + mhi_chan->xfer_cb(mhi_chan->mhi_dev, &result); + } /* Set channel state to STOP */ mhi_chan->state = MHI_CH_STATE_STOP; @@ -235,9 +237,11 @@ static int mhi_ep_process_cmd_ring(struct mhi_ep_ring *ring, struct mhi_ring_ele mhi_ep_ring_reset(mhi_cntrl, ch_ring); /* Send channel disconnect status to client driver */ - result.transaction_status = -ENOTCONN; - result.bytes_xferd = 0; - mhi_chan->xfer_cb(mhi_chan->mhi_dev, &result); + if (mhi_chan->xfer_cb) { + result.transaction_status = -ENOTCONN; + result.bytes_xferd = 0; + mhi_chan->xfer_cb(mhi_chan->mhi_dev, &result); + } /* Set channel state to DISABLED */ mhi_chan->state = MHI_CH_STATE_DISABLED; From patchwork Wed Dec 28 16:17:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manivannan Sadhasivam X-Patchwork-Id: 37232 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp1970381wrt; Wed, 28 Dec 2022 08:20:29 -0800 (PST) X-Google-Smtp-Source: AMrXdXtvenFyqt40XxqIwITIrnXvQhheeFAoSg1Y9onNV359g8fMkHPLZn22g3/e2EifgB+ACnyZ X-Received: by 2002:aa7:c053:0:b0:482:e3b9:f46e with SMTP id k19-20020aa7c053000000b00482e3b9f46emr12915443edo.39.1672244428901; Wed, 28 Dec 2022 08:20:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672244428; cv=none; d=google.com; s=arc-20160816; b=r6l/LK1gJaUzG+md5+MEkahyVn2J32O5ILoqW8HK7lwM7XE1b9cr3KZl0shMMxmHwu Oa5czDcy58pUuryuRmb5VBaNdnLLJRvxE75sKbSIDl8JjOzxGxXgjCzeKqyaKUTj2zNM cZ+KF1P5u2MVftVEn4gXCimsogeTQZBPu2bx9AoAZxcKfqpuecd+7A2J+S3jx3+7UErT hi0H9AoG9OAEXIckdr1FF3EU6+NrCcg8YqJv9kovbnO8x9kmabYEh+0nxotuUP6IFBV3 ljnd8XBIAdzvpEk0k7Eb2gnDyUEn4XBmcpU6eJiJc6789J7fmAPviSmCCg0nUnJAnwcr zLCA== 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=SbuT81cTqrWb06I08YNk/QYGpUnIYQwfiUqfqhuTPAs=; b=wNbqzsxBzg6xQvWdHrfH3zBg4yFkwUQk/Kfhq39RoACsLEVZplHlVvn2hQqg5iPCy+ SOWhQRGtnMBQpvDE/ICqbCT3LfIPjuvjWcnNvTSgam1RqHytElZfhw4bEy+cWeCIV/mB VJof7SFfm2AvHE5PKdZsYyl8Djm4jQlkhQjG1T915+i44hmdQVHE2jWozoBsDfz085kv DZjzWTpbP/GaPhfF2AS/H8WS4JJvtIkC+sXQBUGanBEA1s0wGslV2TvY/9XWh4ciqP3R vVg3fSyc6hGX8jVAQWGmIu3XOuq2357LNDgzg6W+eHFYzgwBwYYGdTFqHA8yYIw9dDMX PzPA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=JwkluDZy; 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 i14-20020a05640242ce00b0047531b0169asi15749002edc.301.2022.12.28.08.20.05; Wed, 28 Dec 2022 08:20:28 -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=JwkluDZy; 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 S234672AbiL1QTZ (ORCPT + 99 others); Wed, 28 Dec 2022 11:19:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38070 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234445AbiL1QSr (ORCPT ); Wed, 28 Dec 2022 11:18:47 -0500 Received: from mail-pj1-x1035.google.com (mail-pj1-x1035.google.com [IPv6:2607:f8b0:4864:20::1035]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BA17519C3A for ; Wed, 28 Dec 2022 08:17:31 -0800 (PST) Received: by mail-pj1-x1035.google.com with SMTP id fy4so16670204pjb.0 for ; Wed, 28 Dec 2022 08:17:31 -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=SbuT81cTqrWb06I08YNk/QYGpUnIYQwfiUqfqhuTPAs=; b=JwkluDZyi7Hbk8sR9WvMw++RLfzCX9DprsV3tjkhS2dzv1yi7hfwIIdDLn2zDn+WMU zXSx2D7xPxtwGEPFtzUYkN7s+Z2rUHQGfnEckae/t0WEY9i9Cens7510/Q4frn+bq0Y4 R4qgF86gnbPdO0DZQD0FODtGrIwqZzwXERjL3YpRvaLQEMHDtYBGMWkEigYpLp3Pqf7M Ffap7EyGYsRbUb08/5RNkuPLE8UKKZN/qnC66e00Hrtx+ElVMdBQaWfukcJqMczec70i S45NoYIx8YZCIx6JUzPTBO9Sa1PjT5kB9FOnLI2LTd8HSUkWv5wQAgmy3yxVZZDN28z6 3+yw== 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=SbuT81cTqrWb06I08YNk/QYGpUnIYQwfiUqfqhuTPAs=; b=vTfXkS1Gt2mdoIg2EmrwxCuBsBCPJwY+kZazcTAbyoM1euAbWXUZ000ZRgbkYBbvY2 uvEFYDJfS8IjSQLc6g+Epvu47qzHpxVwZUblpD+ppQGftlONKIMNvodW/010Om+yMX7A ttBtfHEADeK9/UGSxWUWrOd7/uVpuP+wJXUEbpLtG5sr+2TwSUMf8VWyl4fOj6/Untu2 v/I/VMPqnfCflU/kW+o+egf46Pwdzskbea/POijm1Q5hgzoXh/4hmgELh+oz9xnGJlW5 FJqiUioxrVQOqqGUlyOEVaj+9HYkx0fqmEvRE2WITqykmq7aORUEaHUL04udUgDZxdcg +QgA== X-Gm-Message-State: AFqh2kolr6GQIg0YB0wN0l8j8mLG6RjXics/GnLBvSZvLA2O8gds/VDr R8F+oso26kHWPRoQJ0jLr7Jh X-Received: by 2002:a17:902:be16:b0:188:f0eb:ce10 with SMTP id r22-20020a170902be1600b00188f0ebce10mr30387826pls.65.1672244251263; Wed, 28 Dec 2022 08:17:31 -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.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Dec 2022 08:17:29 -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 4/6] bus: mhi: ep: Fix the debug message for MHI_PKT_TYPE_RESET_CHAN_CMD cmd Date: Wed, 28 Dec 2022 21:47:02 +0530 Message-Id: <20221228161704.255268-5-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?1753475374258382303?= X-GMAIL-MSGID: =?utf-8?q?1753475374258382303?= The debug log incorrectly mentions that STOP command is received instead of RESET command. Fix that. Signed-off-by: Manivannan Sadhasivam Reviewed-by: Jeffrey Hugo --- drivers/bus/mhi/ep/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/bus/mhi/ep/main.c b/drivers/bus/mhi/ep/main.c index 7d68b00bdbcf..0bce6610ebf1 100644 --- a/drivers/bus/mhi/ep/main.c +++ b/drivers/bus/mhi/ep/main.c @@ -226,7 +226,7 @@ static int mhi_ep_process_cmd_ring(struct mhi_ep_ring *ring, struct mhi_ring_ele mutex_unlock(&mhi_chan->lock); break; case MHI_PKT_TYPE_RESET_CHAN_CMD: - dev_dbg(dev, "Received STOP command for channel (%u)\n", ch_id); + dev_dbg(dev, "Received RESET command for channel (%u)\n", ch_id); if (!ch_ring->started) { dev_err(dev, "Channel (%u) not opened\n", ch_id); return -ENODEV; From patchwork Wed Dec 28 16:17:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manivannan Sadhasivam X-Patchwork-Id: 37233 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp1970446wrt; Wed, 28 Dec 2022 08:20:36 -0800 (PST) X-Google-Smtp-Source: AMrXdXtWAbzbGhZ7NHjpgaSnEddgecIsnuHLBIQMUNpylb35AERQaTUERmII49XquqenIRbCqUx0 X-Received: by 2002:a05:6402:104d:b0:486:ac69:b9e4 with SMTP id e13-20020a056402104d00b00486ac69b9e4mr5740406edu.4.1672244436603; Wed, 28 Dec 2022 08:20:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672244436; cv=none; d=google.com; s=arc-20160816; b=FVcNVeUGILBJuh6q0YPw9O4p3on+JB/8uo+gioMmK9l3QA1yXbFxhODyWJLnRoCVSh NsrSvYI+kAoXewFmEXCqKukyzOft2XSz4NU/WxyBiZYwGxMzAeH+wAdQocWB2kTy5Cvz qu9hiX8z6xtA46QoewiP13F39R7qqhEOrwaxR1PBhBmqPnMERly7yrLTjD4Yfd0dE1E4 z3dxMj3ybhIDvpkkYSIHQsZZYQjzixSx/xwsw+EZIIOPdHjUPNkRBNgIAxitRS/V24ag RUABeKC1j+ltesOTTjNuPZ11WCpVghfQixzTyF0dY39NPnh7Yq28s8NQkTuqg7wedl0t t5cQ== 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=k+iHQs4uPoFa0chr8duXApXo2zq9mEU5tnmcTMS1VXc=; b=aPUDvuXf4IhJwWuhTkL5YZafU6Mk1mJWtaZugYj2Q+FVvyqQgH0ZEHt9ncklduJKxq oWOKrPneJ1PqrA3y4QLy3m37A3Vq00mlaci2HN09IlYMti+n4ink/3KQX1ge/lc044OR 2hif8MXPA6CiIA06Wy6CfU1r6e1HZKoMcg61743VdCBIMlmMulXqdIE6+STVMJw7M4xK iGHaDRcrO5F9r87cet4AkIpz9eI1+44jLD0MkmkG6Jw1+DiM+yfEqIWAtS7DswPTfo6m xjb0QgNb7P+8SFJ5B30eHUTZy008RzFHAZevun+NPMgmMAj5TB5wYBbLzQyHrsX2ohdi k1Iw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=RZ9ntAEH; 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 by3-20020a0564021b0300b0047f054cce3esi12713937edb.331.2022.12.28.08.20.12; Wed, 28 Dec 2022 08:20:36 -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=RZ9ntAEH; 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 S234648AbiL1QTc (ORCPT + 99 others); Wed, 28 Dec 2022 11:19:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39202 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234638AbiL1QSu (ORCPT ); Wed, 28 Dec 2022 11:18:50 -0500 Received: from mail-pl1-x62f.google.com (mail-pl1-x62f.google.com [IPv6:2607:f8b0:4864:20::62f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 80C081A055 for ; Wed, 28 Dec 2022 08:17:35 -0800 (PST) Received: by mail-pl1-x62f.google.com with SMTP id 20so3008277plo.3 for ; Wed, 28 Dec 2022 08:17:35 -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=k+iHQs4uPoFa0chr8duXApXo2zq9mEU5tnmcTMS1VXc=; b=RZ9ntAEHz2cR92CulW8lqRm6cxZJBAiKx+fRYPDJVU6e2bgPGYAIzC1QzJqFRS8YW3 FBA0rLpwRw/eUM3a6OJPyRUCmXpcdIWMPxR0wvrHy6EdQdtPZ6UUqHcSSDnG4LV3Rjzo gXCZ2oHxfUau2UB6QYgeMhS2RUny2GUcEj0/JNeRbqu/6UMEmoG24BSh64+fQ4T2Ra5E bs4k+WEFf2vUdGalc9kF/ZxE0bv7B234oYBb6BJKM+fOBoa77eAgWdIujcuDIzq9tu2S LI0Rt5j5EdRQ8BxOSUWXvBmDvuSdDUDfw/xi/OZV/y31G6FDeB3WhF3Wj049evchny7y XwKA== 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=k+iHQs4uPoFa0chr8duXApXo2zq9mEU5tnmcTMS1VXc=; b=QxxRP+q3rc5wfVOODESZslhVkziwMFR/lH0ui8IRUHjExNK3vKqjCoZ77h7PiQPqEw obH6fcjnLOE+yCis7MitmOYbVEqzsvWHQkS+M5+Y4X3kU4TeG+n71rh3cXMZysrjWwZi EzLMWqumR8tbYE1pPcMlLxaF6e4UWux89V6RhpJNd0Ya+0o1MCBzR60406n6D4yX1J5H c0fmgtqZ8bN6vbkIUVH1TrqWDg7ngrdF3GfenYExd495u4WxeS1i0SuKtX1xiYNougt1 ERgmtu8y2ZMFCUK99H9NftGrOE8uG7GZkPzLl5fcTctGNLPjd1Kixf4Uyc3HRfsCKx1g eAtQ== X-Gm-Message-State: AFqh2kqLcwr9FefwJJFcdgQz5SPxvGPdc7wuQXqBPX0jtNLI9e0qXFzp NjyUynCkrcHc8+o7ROGrEcXC X-Received: by 2002:a17:903:2781:b0:189:c3ef:c759 with SMTP id jw1-20020a170903278100b00189c3efc759mr29247326plb.68.1672244255068; Wed, 28 Dec 2022 08:17:35 -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.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Dec 2022 08:17:34 -0800 (PST) From: Manivannan Sadhasivam To: mhi@lists.linux.dev Cc: linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Manivannan Sadhasivam , stable@vger.kernel.org Subject: [PATCH 5/6] bus: mhi: ep: Move chan->lock to the start of processing queued ch ring Date: Wed, 28 Dec 2022 21:47:03 +0530 Message-Id: <20221228161704.255268-6-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?1753475382424603472?= X-GMAIL-MSGID: =?utf-8?q?1753475382424603472?= There is a good chance that while the channel ring gets processed, the STOP or RESET command for the channel might be received from the MHI host. In those cases, the entire channel ring processing needs to be protected by chan->lock to prevent the race where the corresponding channel ring might be reset. While at it, let's also add a sanity check to make sure that the ring is started before processing it. Because, if the STOP/RESET command gets processed while mhi_ep_ch_ring_worker() waited for chan->lock, the ring would've been reset. Cc: # 5.19 Fixes: 03c0bb8ec983 ("bus: mhi: ep: Add support for processing channel rings") Signed-off-by: Manivannan Sadhasivam Reviewed-by: Jeffrey Hugo --- drivers/bus/mhi/ep/main.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/drivers/bus/mhi/ep/main.c b/drivers/bus/mhi/ep/main.c index 0bce6610ebf1..2362fcc8b32c 100644 --- a/drivers/bus/mhi/ep/main.c +++ b/drivers/bus/mhi/ep/main.c @@ -730,24 +730,37 @@ static void mhi_ep_ch_ring_worker(struct work_struct *work) list_del(&itr->node); ring = itr->ring; + chan = &mhi_cntrl->mhi_chan[ring->ch_id]; + mutex_lock(&chan->lock); + + /* + * The ring could've stopped while we waited to grab the (chan->lock), so do + * a sanity check before going further. + */ + if (!ring->started) { + mutex_unlock(&chan->lock); + kfree(itr); + continue; + } + /* Update the write offset for the ring */ ret = mhi_ep_update_wr_offset(ring); if (ret) { dev_err(dev, "Error updating write offset for ring\n"); + mutex_unlock(&chan->lock); kfree(itr); continue; } /* Sanity check to make sure there are elements in the ring */ if (ring->rd_offset == ring->wr_offset) { + mutex_unlock(&chan->lock); kfree(itr); continue; } el = &ring->ring_cache[ring->rd_offset]; - chan = &mhi_cntrl->mhi_chan[ring->ch_id]; - mutex_lock(&chan->lock); dev_dbg(dev, "Processing the ring for channel (%u)\n", ring->ch_id); ret = mhi_ep_process_ch_ring(ring, el); if (ret) { From patchwork Wed Dec 28 16:17:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manivannan Sadhasivam X-Patchwork-Id: 37231 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp1970379wrt; Wed, 28 Dec 2022 08:20:28 -0800 (PST) X-Google-Smtp-Source: AMrXdXvzDPytFlmNf/DGMmV2eyHmszwQ3uVlDOoALFag1RTJItAEB+qQ7S6kXsbDoYpmFN4Eqn13 X-Received: by 2002:a17:906:9616:b0:78d:f457:108f with SMTP id s22-20020a170906961600b0078df457108fmr21202217ejx.76.1672244428567; Wed, 28 Dec 2022 08:20:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672244428; cv=none; d=google.com; s=arc-20160816; b=WNX+48LmNYT+uolLKs1nQmRysXJ+FSqXild0sBNH7Sw+XL/ETqIZBOw6rJAIwQv6cz 8/B8KoYhK6hzsIKg6ELE8T9FMvh4hf1V2I1c5FE6jNyip5PJSyl0js9VYZXo1Gufxuq8 Ul1//hzXR95VkevYKI+gTwG5exEr5QjQrGoYYAulRiKuqt82Q1WZU6ijACIfgWNwt/9+ NZfaDRJy+CrNJxTtFWOeYHbZQAdtXPnrjBDiqKX4s23kQIvQnV44qOPVpHCWNYoFueb0 avvseM77FNs7835aTzx2v22RVoDbvb0uD1VHscZZp6UKnu7lOgccjLZi4MDki2CqLRei 1MyA== 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=rSAJAAdg+x2pOzW2h8I4DWXP2kQcq5rdUpJcuztv9EE=; b=TQOB/Fj+87+Fnr/xpX2I3KywWEsbBltDotMK6/wC98mhbHorhgv2OAWBraWQejSE6R OP6M8EIU4mwZnh2DluTP8RwpJxGr09tr22xoKcw6Z6T9Nj29ffmfWlWeBxFxLT6Y7EjS aujdPq+Qr8RjoXCaKr/3vP6OYujMr3kiAS5pcFmWbwomIYyejGv+yqnJOW71oTrlcdzf OWTZoRL5p20hnFepp36zKxihSos8iTFGcuUZ9VkdRXffl2TNHEUy0W4xkt885xPoAOwm 9wZdqieWOOMM4DfORPCe94UXGvlkpTkkwpPzH/JvsewGRC6o4GtPIMGEMJW0DN25FbQx zsiA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=zFtugpRj; 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 v1-20020a056402348100b004511d552be3si14957442edc.4.2022.12.28.08.20.04; Wed, 28 Dec 2022 08:20:28 -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=zFtugpRj; 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 S234577AbiL1QTj (ORCPT + 99 others); Wed, 28 Dec 2022 11:19:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36438 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234572AbiL1QTG (ORCPT ); Wed, 28 Dec 2022 11:19:06 -0500 Received: from mail-pj1-x1033.google.com (mail-pj1-x1033.google.com [IPv6:2607:f8b0:4864:20::1033]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1CDE31A078 for ; Wed, 28 Dec 2022 08:17:39 -0800 (PST) Received: by mail-pj1-x1033.google.com with SMTP id j8-20020a17090a3e0800b00225fdd5007fso6859565pjc.2 for ; Wed, 28 Dec 2022 08:17:39 -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=rSAJAAdg+x2pOzW2h8I4DWXP2kQcq5rdUpJcuztv9EE=; b=zFtugpRj2SGg96qrJKKPlr+MyyNnNyuUCPvH4PdjNFsVHhZZmMIN/KOq4JeyQA8bys /Stl7IcHO4xx7yHuC3VjLzsueyqi0DOdGuZNyG7Uubuhene+VMbN6+vikXMigsNF05SZ zvcmwRX0TQ6HsWH3zzwpQ/vCnnK24FznH+UGjIwOWQ71x9sI+GgiaQziNz5Uj25Q28Uy xw5CcVwNaSFP/o1xg49J+RJdoV50/Mh/HnQfFslJNO4BOnMOMSLOeDNawr1LF5r4lKfg rU9UckkH2uomLEmwOiR8a0qewI0P2yFgk+YeXZFwJoJDB5zVNwYalIWdtpxnLG9FeUC5 UK+w== 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=rSAJAAdg+x2pOzW2h8I4DWXP2kQcq5rdUpJcuztv9EE=; b=jRlCpNKkZKImD9tZ58EkbHMDbfhZAPMAvhVFToCNi3hBJZRBOBinY1VdyO0grVVlAg kVG6yorL06TSiLBc1KxPm46bUqHwGqQKOkn0gEcZFo0cF0S3C6JouRPlHowlY597nAO2 b+dHJMv8tx7JPehoEAai3KLWZh+c+iLSmhPW5wuBIN/eVPVaz12ZOoPRWvoudFk4/ezI MAPafUb6ZCCyBpWjoU/6sM3xmYtphIFyBNUDNaNREkK/OcFA1izW13mdRKEsERZz/2hA 8ZNERgxqqEKB00dCEnUFgXg/Feb+n4lzkFEvnKJRkzMXPhiR567q+rVFDfChFLVyfHqR f4Yg== X-Gm-Message-State: AFqh2kqaWM5LZlL9Hl6ipA/MMSX+ePmeG6aNWqTWwPvyhcnakicUjgAR Ae9Msf1zTWte50bUzdIUPJPH X-Received: by 2002:a17:902:edd1:b0:192:50fe:504a with SMTP id q17-20020a170902edd100b0019250fe504amr23724967plk.16.1672244258560; Wed, 28 Dec 2022 08:17:38 -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.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Dec 2022 08:17:37 -0800 (PST) From: Manivannan Sadhasivam To: mhi@lists.linux.dev Cc: linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Manivannan Sadhasivam , stable@vger.kernel.org Subject: [PATCH 6/6] bus: mhi: ep: Save channel state locally during suspend and resume Date: Wed, 28 Dec 2022 21:47:04 +0530 Message-Id: <20221228161704.255268-7-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=unavailable 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?1753475373833706700?= X-GMAIL-MSGID: =?utf-8?q?1753475373833706700?= During suspend and resume, the channel state needs to be saved locally. Otherwise, the endpoint may access the channels while they were being suspended and causing access violations. Fix it by saving the channel state locally during suspend and resume. Cc: # 5.19 Fixes: e4b7b5f0f30a ("bus: mhi: ep: Add support for suspending and resuming channels") Signed-off-by: Manivannan Sadhasivam Reviewed-by: Jeffrey Hugo mhi_dev->dev, "Suspending channel\n"); /* Set channel state to SUSPENDED */ + mhi_chan->state = MHI_CH_STATE_SUSPENDED; tmp &= ~CHAN_CTX_CHSTATE_MASK; tmp |= FIELD_PREP(CHAN_CTX_CHSTATE_MASK, MHI_CH_STATE_SUSPENDED); mhi_cntrl->ch_ctx_cache[i].chcfg = cpu_to_le32(tmp); @@ -1151,6 +1152,7 @@ void mhi_ep_resume_channels(struct mhi_ep_cntrl *mhi_cntrl) dev_dbg(&mhi_chan->mhi_dev->dev, "Resuming channel\n"); /* Set channel state to RUNNING */ + mhi_chan->state = MHI_CH_STATE_RUNNING; tmp &= ~CHAN_CTX_CHSTATE_MASK; tmp |= FIELD_PREP(CHAN_CTX_CHSTATE_MASK, MHI_CH_STATE_RUNNING); mhi_cntrl->ch_ctx_cache[i].chcfg = cpu_to_le32(tmp);