From patchwork Mon Sep 21 16:07:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manivannan Sadhasivam X-Patchwork-Id: 11790343 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 29839139A for ; Mon, 21 Sep 2020 16:08:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 07EF920708 for ; Mon, 21 Sep 2020 16:08:51 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="PGBD4gn0" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727611AbgIUQIv (ORCPT ); Mon, 21 Sep 2020 12:08:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56868 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727361AbgIUQIv (ORCPT ); Mon, 21 Sep 2020 12:08:51 -0400 Received: from mail-pf1-x442.google.com (mail-pf1-x442.google.com [IPv6:2607:f8b0:4864:20::442]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E0694C061755 for ; Mon, 21 Sep 2020 09:08:50 -0700 (PDT) Received: by mail-pf1-x442.google.com with SMTP id l126so9663226pfd.5 for ; Mon, 21 Sep 2020 09:08:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=N1lX7l+McFM6cV+ssdxZ5AClsLBq3ozRzVIZ+mY0GZo=; b=PGBD4gn0gX9UmsnVGK9vH38m106z+Y6nT5DCDjWZ2hzsDyi5MSDqS1crGbLps1oips AHoQ2Mse6whIk56/2008pKbV/iQ1pme/8ZtOXknHbMa/5F9wBvQsfvzNo48iujrcqAsn u7VqP0H3GwvcR1RgAwVmu/fMapdOF0+du/dBsjo/XkgLj4VVt6rN4YTeNSbPkdzsfkX+ Bc3fyQAJYRt7ISxM8zXKRR1eXJ55/H3JPFxaFL/WeD/ODFbh6OdO86WZp80+mnoH7vJp fpQvtsBJdwI76Tx3NG7MJsWVUe3Rr7IEFzU1TpJCwq94b1cn6/+4b2NO6cv0lq6LfH5L eHOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=N1lX7l+McFM6cV+ssdxZ5AClsLBq3ozRzVIZ+mY0GZo=; b=tdml6+FrPQ4fbuNz2YgIGH5P4zvAajCZio8cG+dIf/mkIs7+LdnUfYUbu9XZmsPlA5 6DsQONR/TkoDdfk2yIdYMJw78k1HACzQzjvEpQBVybF44VVq4vOjYkr80C1GUs5lrq6L 6DgTB/1Nn+07UWhlyS0LUEPET/R2mh5vLW71hDsd98UT2tXZETX8c+7xXWvMxdUHyzIz yg6Q/GaAfEyj1ZMS1uuJss8wuETknMDWIuNItdMLJhL3buzxLIQ+HVqk2N07v7C2Yibp mh6tzxn3awyf08hswNF+sdeTMWBvtZghEhIkgZBIaAoDpDGAYcyX/otXnKCi4NKz0hpn tlxw== X-Gm-Message-State: AOAM532CXnd+UwQfN97jA/ZOyT3RIL7SaS5c3QJtHNSi484uUQbPots0 MoydFESLVLxs+YcDbXbzbCHK X-Google-Smtp-Source: ABdhPJxKkrk77Tt5oFXXdQcdiz+2rhjVTQjfAXoPzMTOtQXWlt92v//AICi9Tn5yQw2Elnv7Ze+x4g== X-Received: by 2002:a17:902:8341:b029:d2:29fc:c400 with SMTP id z1-20020a1709028341b02900d229fcc400mr670185pln.5.1600704530376; Mon, 21 Sep 2020 09:08:50 -0700 (PDT) Received: from Mani-XPS-13-9360.localdomain ([2409:4072:6d03:bd12:1004:2ccf:6900:b97]) by smtp.gmail.com with ESMTPSA id f4sm9204577pgr.68.2020.09.21.09.08.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Sep 2020 09:08:49 -0700 (PDT) From: Manivannan Sadhasivam To: gregkh@linuxfoundation.org Cc: hemantk@codeaurora.org, jhugo@codeaurora.org, bbhatt@codeaurora.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Randy Dunlap , Manivannan Sadhasivam Subject: [PATCH 01/18] bus: mhi: fix doubled words and struct image_info kernel-doc Date: Mon, 21 Sep 2020 21:37:58 +0530 Message-Id: <20200921160815.28071-3-manivannan.sadhasivam@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200921160815.28071-1-manivannan.sadhasivam@linaro.org> References: <20200921160815.28071-1-manivannan.sadhasivam@linaro.org> Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org From: Randy Dunlap Drop doubled word "table" in kernel-doc. Fix syntax for the kernel-doc notation for struct image_info. Note that the bhi_vec field is private and not part of the kernel-doc. Drop doubled word "device" in a comment. Signed-off-by: Randy Dunlap Cc: Manivannan Sadhasivam Cc: Hemant Kumar Cc: linux-arm-msm@vger.kernel.org Reviewed-by: Manivannan Sadhasivam [mani: Added bus: prefix to the commit subject] Signed-off-by: Manivannan Sadhasivam --- include/linux/mhi.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/include/linux/mhi.h b/include/linux/mhi.h index c4a940d98912..0779bc689b3e 100644 --- a/include/linux/mhi.h +++ b/include/linux/mhi.h @@ -85,13 +85,15 @@ enum mhi_ch_type { }; /** - * struct image_info - Firmware and RDDM table table - * @mhi_buf - Buffer for firmware and RDDM table - * @entries - # of entries in table + * struct image_info - Firmware and RDDM table + * @mhi_buf: Buffer for firmware and RDDM table + * @entries: # of entries in table */ struct image_info { struct mhi_buf *mhi_buf; + /* private: from internal.h */ struct bhi_vec_entry *bhi_vec; + /* public: */ u32 entries; }; @@ -593,7 +595,7 @@ int mhi_async_power_up(struct mhi_controller *mhi_cntrl); /** * mhi_sync_power_up - Start MHI power up sequence and wait till the device - * device enters valid EE state + * enters valid EE state * @mhi_cntrl: MHI controller */ int mhi_sync_power_up(struct mhi_controller *mhi_cntrl); From patchwork Mon Sep 21 16:07:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manivannan Sadhasivam X-Patchwork-Id: 11790345 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2DF6859D for ; Mon, 21 Sep 2020 16:08:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 08729216C4 for ; Mon, 21 Sep 2020 16:08:56 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="vkyI7N2B" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728001AbgIUQI4 (ORCPT ); Mon, 21 Sep 2020 12:08:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56890 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727305AbgIUQI4 (ORCPT ); Mon, 21 Sep 2020 12:08:56 -0400 Received: from mail-pf1-x444.google.com (mail-pf1-x444.google.com [IPv6:2607:f8b0:4864:20::444]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2575AC0613CF for ; Mon, 21 Sep 2020 09:08:56 -0700 (PDT) Received: by mail-pf1-x444.google.com with SMTP id d9so9671645pfd.3 for ; Mon, 21 Sep 2020 09:08:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=bmv3vMkNMLZAUojDUc5hK8E8LQxr3ViBRDic1DDVfzI=; b=vkyI7N2BSW4Xxq9vxmjVpgswgAlTlKnABK65yu4BJ/gu8vJpocGZEAg/CXJ6FeZM6V DcfTqi54oPUHdozYn2C3Uw8zwy2AhUnLGHeY5q8h26bcT/jl6bEkjnGwoctSK09t6Q17 0ZGo4G8ZOgLPL1RRdZ2HLr/aAbCempa04zIAWBAmvZ9Gf0fa54gb931dbeWiNCeSeK01 1o9pFGJ7Gwx63SDBjnCa6xmCb3R0bz81IwRov6qgeW9F1+7ldC5aTH1TvUvd3+t1V4+T XMCJe/EbOY7keBrv58Mzspo6Y9GRa1ExpnTYjODdYbMiDYAhQX9DA84Yc3FqsZX7yXhf 8tSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=bmv3vMkNMLZAUojDUc5hK8E8LQxr3ViBRDic1DDVfzI=; b=a3IJCAVEvvfH98QTMnOU2xCkEVI3kaoPGF43nPrIdB0khPGMu2Dr0JxbcNSaz7bPBH QCzXsdWq+dJEeRCgq0atVKev7IekpMOFqlBT/wGr7kDKDpJ80ZkTrXAlNCB6osNHx3h7 +c88/6Xqw5GR6BJLCBPFkkyfRgtLWzQJwp+E6O6cDMtMzEy8L79j/EfH59dYTaaWAVPW aKjUEap5Crq2z665FBqEey6Y+9z9KLPjiT5+6knCZ+L1QgS+Pe1nZn40nk7B0awUP4GW ULH/FFS/taaD3dlZjrMKhsVB2v2Q1rmbzkViFF+qEPyfyFdMJCl8t+v/5/DaonLnECOz Pgfg== X-Gm-Message-State: AOAM532GiGKtYXTuFKVRKeEm4PO7zj8O4ariR65BR8Y0IY5/DjYB73G7 DXZmP3Vebx8LtshkhexAvnqT X-Google-Smtp-Source: ABdhPJzAEyZ6LnpjwsY7prLFC8HnmtRfEILqhk+IFYjpn1YRIB7bJv0jcX3n4n6XkjmUxFJZdC/hpg== X-Received: by 2002:a17:902:ba83:b029:d1:e5e7:be6c with SMTP id k3-20020a170902ba83b02900d1e5e7be6cmr599927pls.70.1600704535586; Mon, 21 Sep 2020 09:08:55 -0700 (PDT) Received: from Mani-XPS-13-9360.localdomain ([2409:4072:6d03:bd12:1004:2ccf:6900:b97]) by smtp.gmail.com with ESMTPSA id f4sm9204577pgr.68.2020.09.21.09.08.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Sep 2020 09:08:54 -0700 (PDT) From: Manivannan Sadhasivam To: gregkh@linuxfoundation.org Cc: hemantk@codeaurora.org, jhugo@codeaurora.org, bbhatt@codeaurora.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Manivannan Sadhasivam Subject: [PATCH 02/18] bus: mhi: core: Remove double occurrence for mhi_ctrl_ev_task() declaration Date: Mon, 21 Sep 2020 21:37:59 +0530 Message-Id: <20200921160815.28071-4-manivannan.sadhasivam@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200921160815.28071-1-manivannan.sadhasivam@linaro.org> References: <20200921160815.28071-1-manivannan.sadhasivam@linaro.org> Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org From: Bhaumik Bhatt mhi_ctrl_ev_task() in the internal header file occurred twice. Remove one of the occurrences for clean-up. Signed-off-by: Bhaumik Bhatt Reviewed-by: Manivannan Sadhasivam Signed-off-by: Manivannan Sadhasivam --- drivers/bus/mhi/core/internal.h | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/bus/mhi/core/internal.h b/drivers/bus/mhi/core/internal.h index b1f640b75a94..bcfa7b6558ef 100644 --- a/drivers/bus/mhi/core/internal.h +++ b/drivers/bus/mhi/core/internal.h @@ -592,7 +592,6 @@ void mhi_pm_st_worker(struct work_struct *work); void mhi_pm_sys_err_handler(struct mhi_controller *mhi_cntrl); void mhi_fw_load_worker(struct work_struct *work); int mhi_ready_state_transition(struct mhi_controller *mhi_cntrl); -void mhi_ctrl_ev_task(unsigned long data); int mhi_pm_m0_transition(struct mhi_controller *mhi_cntrl); void mhi_pm_m1_transition(struct mhi_controller *mhi_cntrl); int mhi_pm_m3_transition(struct mhi_controller *mhi_cntrl); From patchwork Mon Sep 21 16:08:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manivannan Sadhasivam X-Patchwork-Id: 11790349 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 61C5259D for ; Mon, 21 Sep 2020 16:09:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3D7B12151B for ; Mon, 21 Sep 2020 16:09:02 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="NTSt2v9a" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728024AbgIUQJB (ORCPT ); Mon, 21 Sep 2020 12:09:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56902 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727393AbgIUQJB (ORCPT ); Mon, 21 Sep 2020 12:09:01 -0400 Received: from mail-pf1-x444.google.com (mail-pf1-x444.google.com [IPv6:2607:f8b0:4864:20::444]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D61F4C061755 for ; Mon, 21 Sep 2020 09:09:00 -0700 (PDT) Received: by mail-pf1-x444.google.com with SMTP id x123so9651495pfc.7 for ; Mon, 21 Sep 2020 09:09:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=GocdqLYTODm0NoMZyaUYMh/e3m0B19dnr1p1DXm0VJA=; b=NTSt2v9arOod1uXHwNCfZHQFOzxV+1PVVM2RwfkQdnE/mJjLaVxKtlgJbxR7Cs8kxq /rJIjVnc5rOpdBlzcB7l8oNFRKmAVguCw51bnQOzx8B9W2SU89FLdVty2pP9ahea9g0/ vdR4SLG/ybdTt5LKJOaC3FDwC4oi+HFAbaxL8cDO8Cr4nM6KN3faBHi3ogTPGYnzvrMr DCAB9/j3Zrl0O4n664NYInCshskryZyddsDVIEkrX3/o1VzVlPC+jHdHzUm2hFXlmZJd rT17v7VbQdqgFKAH8C6nEqCydwp31IqtQjMm85WT6b+yv/0KYoaM83qa964tc/5EKl9h gqYg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=GocdqLYTODm0NoMZyaUYMh/e3m0B19dnr1p1DXm0VJA=; b=mY0O/WLpZ1DkOAmclLypE8iIP2+/2fOe+NXaIpQVr6p5pYg9CZnvtOGZgvk/hOUMbw f0hlbKSpTHSygYplzTAXjJmWsTT4WSEO7Qy//jGvxIuqnLAACcmDFIMa8SX2JVnbn2kK DQP8x9AY/lt6KrLUXM5sayEI8MFeryX0H6u8wsTXSoLRuygQnIoZd9XomT835UJcNoHF Xps5jyzKDB7Px9gN04a8hZqcSM17dejGU/3rzSNaGs6r5K87m9fn0+uvO63HpaNSJRVB KIMpZ9AK+UkrDntzZejTDCg4v/6+c4BInQbAqKEeClZvk4c25ZmShpg7XT+edlOctk9G liQQ== X-Gm-Message-State: AOAM530fqfIp/z2378deL7hzuHrFSwHkIX52LLgOf+GNEgwzPkee6/KY tzykUaEc8Kl2P0vlMG8leAJo X-Google-Smtp-Source: ABdhPJycjErgwLy6G8DhzkFy0bNL+f2tlRE0q3nsqZdFCGYa54iGIJNLnlfTuPupnIwi72bsM4a/vA== X-Received: by 2002:a63:d242:: with SMTP id t2mr286895pgi.47.1600704540289; Mon, 21 Sep 2020 09:09:00 -0700 (PDT) Received: from Mani-XPS-13-9360.localdomain ([2409:4072:6d03:bd12:1004:2ccf:6900:b97]) by smtp.gmail.com with ESMTPSA id f4sm9204577pgr.68.2020.09.21.09.08.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Sep 2020 09:08:59 -0700 (PDT) From: Manivannan Sadhasivam To: gregkh@linuxfoundation.org Cc: hemantk@codeaurora.org, jhugo@codeaurora.org, bbhatt@codeaurora.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Manivannan Sadhasivam Subject: [PATCH 03/18] bus: mhi: core: Abort suspends due to outgoing pending packets Date: Mon, 21 Sep 2020 21:38:00 +0530 Message-Id: <20200921160815.28071-5-manivannan.sadhasivam@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200921160815.28071-1-manivannan.sadhasivam@linaro.org> References: <20200921160815.28071-1-manivannan.sadhasivam@linaro.org> Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org From: Bhaumik Bhatt Add the missing check to abort suspends if a client driver has pending outgoing packets to send to the device. This allows better utilization of the MHI bus wherein clients on the host are not left waiting for longer suspend or resume cycles to finish for data transfers. Signed-off-by: Bhaumik Bhatt Reviewed-by: Manivannan Sadhasivam Signed-off-by: Manivannan Sadhasivam --- drivers/bus/mhi/core/pm.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/bus/mhi/core/pm.c b/drivers/bus/mhi/core/pm.c index 796098078083..661d704c8093 100644 --- a/drivers/bus/mhi/core/pm.c +++ b/drivers/bus/mhi/core/pm.c @@ -686,7 +686,8 @@ int mhi_pm_suspend(struct mhi_controller *mhi_cntrl) return -EIO; /* Return busy if there are any pending resources */ - if (atomic_read(&mhi_cntrl->dev_wake)) + if (atomic_read(&mhi_cntrl->dev_wake) || + atomic_read(&mhi_cntrl->pending_pkts)) return -EBUSY; /* Take MHI out of M2 state */ @@ -712,7 +713,8 @@ int mhi_pm_suspend(struct mhi_controller *mhi_cntrl) write_lock_irq(&mhi_cntrl->pm_lock); - if (atomic_read(&mhi_cntrl->dev_wake)) { + if (atomic_read(&mhi_cntrl->dev_wake) || + atomic_read(&mhi_cntrl->pending_pkts)) { write_unlock_irq(&mhi_cntrl->pm_lock); return -EBUSY; } From patchwork Mon Sep 21 16:08:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manivannan Sadhasivam X-Patchwork-Id: 11790351 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C61F0139A for ; Mon, 21 Sep 2020 16:09:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9932A20739 for ; Mon, 21 Sep 2020 16:09:17 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="RHzxsrck" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727830AbgIUQJR (ORCPT ); Mon, 21 Sep 2020 12:09:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56948 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727059AbgIUQJQ (ORCPT ); Mon, 21 Sep 2020 12:09:16 -0400 Received: from mail-pf1-x444.google.com (mail-pf1-x444.google.com [IPv6:2607:f8b0:4864:20::444]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 92E34C0613CF for ; Mon, 21 Sep 2020 09:09:16 -0700 (PDT) Received: by mail-pf1-x444.google.com with SMTP id w7so9667227pfi.4 for ; Mon, 21 Sep 2020 09:09:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=U2zjAyHMv+vNvI44PVm7WKt9xsmBm2Pl8T9zrZbzqsE=; b=RHzxsrckT/eMMi0ETqEu4Gdcz2j8ah8y3sUVa3w3gJC4JEYlMUTGCgNZU8FsvKPT8A 2Ge7FS0LlWx7eqQNwLyjsAw65cSkF7k0dzQu2V+XZzs3+NZAqEFNbbJY19ZJRTWnjt9s qrNJvtKHbATB70MTUbfvqCmrLFR0Q34pTsBzkRwpOjoi9cPXqRupiAJuLrVK9i8pX0VK znvOomIkpQ7fDtFvTmjtyArlYTI1ZGAmq9WZWd1023quxm1GSljLQ7Sy0Y4xJ3uspJsh V4bgm7YV5T2T1YbBr8Hu1OUFmZhrKtGneUDLHq9IR1a2EhpsHnOC5AripnH3QReDCk6F sPkA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=U2zjAyHMv+vNvI44PVm7WKt9xsmBm2Pl8T9zrZbzqsE=; b=tNmonccUVWzawkXQYksfAZKdNId8AVxODtIpUITkaqfzwMDmuJaIxDPwKbAgE0e/SZ 1NirxAwIE/wkeYnu3fF7c0y+lpRTAEdAFt8qKGulesJlIa3/6aVSHxresvR49trgzfUA 7Wh4ofcI44cTiuvgYK2W74wd0bxr9HywN2O0KvVfThf4bjyoqKVGepES8XoPAA3iVKEU HkRF+Nl8+0DyGEjEitPo7u5vlHRVM1UbCAoi60epPQGmG/sum0oU7YiK1BUqjw4C/Ec+ EWzRN/VUrraXQlQhAi9EI+73gnusKpEwT7jvm+8kRmHo9NfejLgx7n0chTVnB0fVhxC1 5/5w== X-Gm-Message-State: AOAM530WkYqwrmxiw2RQeEU8jHMGXFfB9INiQZulVyFiq22iTmeYxUur BG+O7MG9rP9gITgvzRKnvCz4 X-Google-Smtp-Source: ABdhPJzvVF03dR0sAwhJ205kg8Rtzbo2JPj4Cg9MTbZuQ7twyp5TXjHKyLh74/izds7eUnYO2nIdJQ== X-Received: by 2002:a63:c64f:: with SMTP id x15mr267779pgg.135.1600704556001; Mon, 21 Sep 2020 09:09:16 -0700 (PDT) Received: from Mani-XPS-13-9360.localdomain ([2409:4072:6d03:bd12:1004:2ccf:6900:b97]) by smtp.gmail.com with ESMTPSA id f4sm9204577pgr.68.2020.09.21.09.09.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Sep 2020 09:09:15 -0700 (PDT) From: Manivannan Sadhasivam To: gregkh@linuxfoundation.org Cc: hemantk@codeaurora.org, jhugo@codeaurora.org, bbhatt@codeaurora.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Manivannan Sadhasivam Subject: [PATCH 04/18] bus: mhi: core: Use helper API to trigger a non-blocking host resume Date: Mon, 21 Sep 2020 21:38:01 +0530 Message-Id: <20200921160815.28071-6-manivannan.sadhasivam@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200921160815.28071-1-manivannan.sadhasivam@linaro.org> References: <20200921160815.28071-1-manivannan.sadhasivam@linaro.org> Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org From: Bhaumik Bhatt Autonomous low power mode support requires the MHI host to resume from multiple places and post a wakeup source to exit system suspend. This needs to be done in a non-blocking manner. Introduce a helper API to trigger the host resume for data transfers and other non-blocking use cases while supporting implementation of autonomous low power modes. Signed-off-by: Bhaumik Bhatt Reviewed-by: Manivannan Sadhasivam Signed-off-by: Manivannan Sadhasivam --- drivers/bus/mhi/core/internal.h | 7 +++++++ drivers/bus/mhi/core/main.c | 21 +++++++-------------- drivers/bus/mhi/core/pm.c | 13 ++++--------- 3 files changed, 18 insertions(+), 23 deletions(-) diff --git a/drivers/bus/mhi/core/internal.h b/drivers/bus/mhi/core/internal.h index bcfa7b6558ef..1bbd6e99d38d 100644 --- a/drivers/bus/mhi/core/internal.h +++ b/drivers/bus/mhi/core/internal.h @@ -599,6 +599,13 @@ int __mhi_device_get_sync(struct mhi_controller *mhi_cntrl); int mhi_send_cmd(struct mhi_controller *mhi_cntrl, struct mhi_chan *mhi_chan, enum mhi_cmd_type cmd); +static inline void mhi_trigger_resume(struct mhi_controller *mhi_cntrl) +{ + pm_wakeup_event(&mhi_cntrl->mhi_dev->dev, 0); + mhi_cntrl->runtime_get(mhi_cntrl); + mhi_cntrl->runtime_put(mhi_cntrl); +} + /* Register access methods */ void mhi_db_brstmode(struct mhi_controller *mhi_cntrl, struct db_cfg *db_cfg, void __iomem *db_addr, dma_addr_t db_val); diff --git a/drivers/bus/mhi/core/main.c b/drivers/bus/mhi/core/main.c index 1f622ce6be8b..79be18ec2ebf 100644 --- a/drivers/bus/mhi/core/main.c +++ b/drivers/bus/mhi/core/main.c @@ -909,8 +909,7 @@ void mhi_ctrl_ev_task(unsigned long data) * process it since we are probably in a suspended state, * so trigger a resume. */ - mhi_cntrl->runtime_get(mhi_cntrl); - mhi_cntrl->runtime_put(mhi_cntrl); + mhi_trigger_resume(mhi_cntrl); return; } @@ -971,10 +970,8 @@ int mhi_queue_skb(struct mhi_device *mhi_dev, enum dma_data_direction dir, } /* we're in M3 or transitioning to M3 */ - if (MHI_PM_IN_SUSPEND_STATE(mhi_cntrl->pm_state)) { - mhi_cntrl->runtime_get(mhi_cntrl); - mhi_cntrl->runtime_put(mhi_cntrl); - } + if (MHI_PM_IN_SUSPEND_STATE(mhi_cntrl->pm_state)) + mhi_trigger_resume(mhi_cntrl); /* Toggle wake to exit out of M2 */ mhi_cntrl->wake_toggle(mhi_cntrl); @@ -1032,10 +1029,8 @@ int mhi_queue_dma(struct mhi_device *mhi_dev, enum dma_data_direction dir, } /* we're in M3 or transitioning to M3 */ - if (MHI_PM_IN_SUSPEND_STATE(mhi_cntrl->pm_state)) { - mhi_cntrl->runtime_get(mhi_cntrl); - mhi_cntrl->runtime_put(mhi_cntrl); - } + if (MHI_PM_IN_SUSPEND_STATE(mhi_cntrl->pm_state)) + mhi_trigger_resume(mhi_cntrl); /* Toggle wake to exit out of M2 */ mhi_cntrl->wake_toggle(mhi_cntrl); @@ -1147,10 +1142,8 @@ int mhi_queue_buf(struct mhi_device *mhi_dev, enum dma_data_direction dir, read_lock_irqsave(&mhi_cntrl->pm_lock, flags); /* we're in M3 or transitioning to M3 */ - if (MHI_PM_IN_SUSPEND_STATE(mhi_cntrl->pm_state)) { - mhi_cntrl->runtime_get(mhi_cntrl); - mhi_cntrl->runtime_put(mhi_cntrl); - } + if (MHI_PM_IN_SUSPEND_STATE(mhi_cntrl->pm_state)) + mhi_trigger_resume(mhi_cntrl); /* Toggle wake to exit out of M2 */ mhi_cntrl->wake_toggle(mhi_cntrl); diff --git a/drivers/bus/mhi/core/pm.c b/drivers/bus/mhi/core/pm.c index 661d704c8093..b227d415e937 100644 --- a/drivers/bus/mhi/core/pm.c +++ b/drivers/bus/mhi/core/pm.c @@ -824,11 +824,8 @@ int __mhi_device_get_sync(struct mhi_controller *mhi_cntrl) /* Wake up the device */ read_lock_bh(&mhi_cntrl->pm_lock); mhi_cntrl->wake_get(mhi_cntrl, true); - if (MHI_PM_IN_SUSPEND_STATE(mhi_cntrl->pm_state)) { - pm_wakeup_event(&mhi_cntrl->mhi_dev->dev, 0); - mhi_cntrl->runtime_get(mhi_cntrl); - mhi_cntrl->runtime_put(mhi_cntrl); - } + if (MHI_PM_IN_SUSPEND_STATE(mhi_cntrl->pm_state)) + mhi_trigger_resume(mhi_cntrl); read_unlock_bh(&mhi_cntrl->pm_lock); ret = wait_event_timeout(mhi_cntrl->state_event, @@ -1139,10 +1136,8 @@ void mhi_device_put(struct mhi_device *mhi_dev) mhi_dev->dev_wake--; read_lock_bh(&mhi_cntrl->pm_lock); - if (MHI_PM_IN_SUSPEND_STATE(mhi_cntrl->pm_state)) { - mhi_cntrl->runtime_get(mhi_cntrl); - mhi_cntrl->runtime_put(mhi_cntrl); - } + if (MHI_PM_IN_SUSPEND_STATE(mhi_cntrl->pm_state)) + mhi_trigger_resume(mhi_cntrl); mhi_cntrl->wake_put(mhi_cntrl, false); read_unlock_bh(&mhi_cntrl->pm_lock); From patchwork Mon Sep 21 16:08:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manivannan Sadhasivam X-Patchwork-Id: 11790353 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 246EA139A for ; Mon, 21 Sep 2020 16:09:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F04AC2151B for ; Mon, 21 Sep 2020 16:09:57 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="RTlt+ko6" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727584AbgIUQJ5 (ORCPT ); Mon, 21 Sep 2020 12:09:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57050 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726395AbgIUQJ5 (ORCPT ); Mon, 21 Sep 2020 12:09:57 -0400 Received: from mail-pf1-x442.google.com (mail-pf1-x442.google.com [IPv6:2607:f8b0:4864:20::442]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3B775C061755 for ; Mon, 21 Sep 2020 09:09:57 -0700 (PDT) Received: by mail-pf1-x442.google.com with SMTP id z18so9678433pfg.0 for ; Mon, 21 Sep 2020 09:09:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=mLM1ooiBRvHKnVHboD9nW5AfyUuBhafQkkCUD3MREGQ=; b=RTlt+ko60rK2/zapD8GKHlZvzBuw1IGAKR8ZEb2qajV5uohv9e9M77T+SlQGPWBnxV dOzDqtx6vXcsSro7q5q6lQhS2gsLQEH6TAt6jcWc09Uwvj4aDKHlrpXb+K0roAtRKV17 HqC4djsJ3cOGTI7UdKjOsf0HS2nJoTRi6emifrbWYvwjvTCnJENFdrkNxh2HI9c7Di5f M3J+KJjssFOFv2wBnk6DcQ83ICxaSw5cyAikweh9EtCTOH+UsDaiVNJQqHF/JTrSU2l0 UQSDrjZVgeK0uIoh72jfs/2FUuzAsmQ4pKgbd2EFEPGMh7Ima6r1YeY5eZOKMb4A3eP1 tWkg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=mLM1ooiBRvHKnVHboD9nW5AfyUuBhafQkkCUD3MREGQ=; b=tSO61pPrHg6PFCj29OKGGgOkgaE7LoKs2fo/NKGTyJ6TM3osynLCIKcz/MmWXk5YgH pGnsl9kHESJltEPM8BXcvNSY6uckt50Q4UyX+qWlxYHG/mDvej7Rvgrp6BBicRho8tA4 jBaFL86DusSIFAt2nap5ehwDqLZitcR7hl2tUIDcmP9d0D7YKSjlP8ddZA27Kp9RGaXp aC0zjMYG++OPALs9K/UdKGJh4sF1e5/f5YksRAi8yD9fuD62VdkLJSTONqPRD0XcfeFb hJ+j0ATeOOT5yJk56DSejddBi704I9efFs6JmMoBUuN9mys0s89WlhbFQoZtAoq5nv9d y0xQ== X-Gm-Message-State: AOAM532TDwJdu5ft01I/W6fiUcanP7iZ7iB4g9SCfknQi5HQv7YuvBCE VJ5dHaecyyajd+9iin2KjQph X-Google-Smtp-Source: ABdhPJxiPuI+p4Gw7kYi2ZVYeBdeqDIkwnTTAcKk8jfDI9JInlNlEiN3rqVRTgui3onFEznWXs+LMQ== X-Received: by 2002:a63:4a19:: with SMTP id x25mr308949pga.56.1600704596746; Mon, 21 Sep 2020 09:09:56 -0700 (PDT) Received: from Mani-XPS-13-9360.localdomain ([2409:4072:6d03:bd12:1004:2ccf:6900:b97]) by smtp.gmail.com with ESMTPSA id f4sm9204577pgr.68.2020.09.21.09.09.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Sep 2020 09:09:55 -0700 (PDT) From: Manivannan Sadhasivam To: gregkh@linuxfoundation.org Cc: hemantk@codeaurora.org, jhugo@codeaurora.org, bbhatt@codeaurora.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Manivannan Sadhasivam Subject: [PATCH 05/18] bus: mhi: core: Trigger host resume if suspended during mhi_device_get() Date: Mon, 21 Sep 2020 21:38:02 +0530 Message-Id: <20200921160815.28071-7-manivannan.sadhasivam@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200921160815.28071-1-manivannan.sadhasivam@linaro.org> References: <20200921160815.28071-1-manivannan.sadhasivam@linaro.org> Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org From: Bhaumik Bhatt It is possible that the host may be suspending or suspended and may not allow an outgoing device wake assert immediately if a client has requested for it. Ensure that the host wakes up and allows for it so the client does not have to wait for an external trigger or an outgoing packet to be queued for the host resume to occur. Signed-off-by: Bhaumik Bhatt Reviewed-by: Manivannan Sadhasivam Signed-off-by: Manivannan Sadhasivam --- drivers/bus/mhi/core/pm.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/bus/mhi/core/pm.c b/drivers/bus/mhi/core/pm.c index b227d415e937..27bb471c8f4e 100644 --- a/drivers/bus/mhi/core/pm.c +++ b/drivers/bus/mhi/core/pm.c @@ -1112,6 +1112,9 @@ void mhi_device_get(struct mhi_device *mhi_dev) mhi_dev->dev_wake++; read_lock_bh(&mhi_cntrl->pm_lock); + if (MHI_PM_IN_SUSPEND_STATE(mhi_cntrl->pm_state)) + mhi_trigger_resume(mhi_cntrl); + mhi_cntrl->wake_get(mhi_cntrl, true); read_unlock_bh(&mhi_cntrl->pm_lock); } From patchwork Mon Sep 21 16:08:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manivannan Sadhasivam X-Patchwork-Id: 11790355 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0EA6E59D for ; Mon, 21 Sep 2020 16:10:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D6DA82193E for ; Mon, 21 Sep 2020 16:10:04 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="VfZNr+Va" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728051AbgIUQKE (ORCPT ); Mon, 21 Sep 2020 12:10:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57072 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728049AbgIUQKE (ORCPT ); Mon, 21 Sep 2020 12:10:04 -0400 Received: from mail-pf1-x443.google.com (mail-pf1-x443.google.com [IPv6:2607:f8b0:4864:20::443]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D9683C0613CF for ; Mon, 21 Sep 2020 09:10:03 -0700 (PDT) Received: by mail-pf1-x443.google.com with SMTP id o20so9650886pfp.11 for ; Mon, 21 Sep 2020 09:10:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Sxs+p0qJGwlXlYqr5DnhuqsFJ9uI4G3h2LLCfE221Y0=; b=VfZNr+Vaszhu7SpDYzRxSOyuk+HYg5mh41E+BvIihuUmNrVtKo7B6b1niIsNoGdc7Y wwIE2NxXn+ssJHCY7ard9YOkaZIztRE2QEpm7utts7gj9RoXrCXWfGYu0rHeui/xciTW Zirvsz0JGbgjj/vzpdHPFbRn/DXGQK/E8yyqK7O8EcfsF+5fZZ50Km/CfeW3f8XPl+z5 cT22Dehv+nmafXtadko4tsMEW57cGqzj+CYhpauFJVUx1UihHU9z61t9gL/jRpSROjQX vBIXGNoSI59k6jkLwoyatjbnvEYxQQltjkZYAHECC611savMbgPm+mhJIzpg9eTOrJlQ DdCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Sxs+p0qJGwlXlYqr5DnhuqsFJ9uI4G3h2LLCfE221Y0=; b=HmLGOwiICsl/ygUYa6WHCesHu9zurWPkvkmvknNVFmi1sRiot3Os3MWUSm1Gyc4Pmy QgybguaZ7FqKJHLxxP20+1dANIjHqybjWkOElOyAw1+dEo4/BoC987SLrsRa7xxyX/Qa XR0nzk+DDBQP/vbRObpAda6wwKuWzcCvMFP2yjKLtZktiPcLrQsHn52hlB8WKvCOumCq IxGFozpXwqVlTxmIvEaRn1zXJvgQSnliSzj/ZC9kWTQjWAUakiC7SWjP0ub3Np+oNiVu pxHsdv8s0zimdeIxIZC5mo2Sdu8k8OX5eHTk9AOFjLoFmqwEZ7SPmwZT51UbBO++WZx0 y9lg== X-Gm-Message-State: AOAM530DXOrIG0+bXvBPgW5+AL01tF9o2ZjdSgO0rtT4hA5ZuLhk52wG AaEomSe9f2XIkQb1ch86RdmV X-Google-Smtp-Source: ABdhPJyqu/Lv+A82km5XUdALa6tDeEcsRrbpvWc5FqHn+rTNAV13eWd/x4ouH4AKiP3+8NIih3i1bw== X-Received: by 2002:a63:4450:: with SMTP id t16mr284327pgk.3.1600704603344; Mon, 21 Sep 2020 09:10:03 -0700 (PDT) Received: from Mani-XPS-13-9360.localdomain ([2409:4072:6d03:bd12:1004:2ccf:6900:b97]) by smtp.gmail.com with ESMTPSA id f4sm9204577pgr.68.2020.09.21.09.09.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Sep 2020 09:10:02 -0700 (PDT) From: Manivannan Sadhasivam To: gregkh@linuxfoundation.org Cc: hemantk@codeaurora.org, jhugo@codeaurora.org, bbhatt@codeaurora.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Manivannan Sadhasivam Subject: [PATCH 06/18] bus: mhi: core: Use generic name field for an MHI device Date: Mon, 21 Sep 2020 21:38:03 +0530 Message-Id: <20200921160815.28071-8-manivannan.sadhasivam@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200921160815.28071-1-manivannan.sadhasivam@linaro.org> References: <20200921160815.28071-1-manivannan.sadhasivam@linaro.org> Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org From: Bhaumik Bhatt An MHI device is not necessarily associated with only channels as we can have one associated with the controller itself. Hence, the chan_name field within the mhi_device structure should instead be replaced with a generic name to accurately reflect any type of MHI device. Signed-off-by: Bhaumik Bhatt Reviewed-by: Jeffrey Hugo Reviewed-by: Manivannan Sadhasivam Signed-off-by: Manivannan Sadhasivam --- drivers/bus/mhi/core/init.c | 5 +++-- drivers/bus/mhi/core/main.c | 6 +++--- include/linux/mhi.h | 8 ++++---- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/drivers/bus/mhi/core/init.c b/drivers/bus/mhi/core/init.c index e43a190a7a36..e2011ec46b92 100644 --- a/drivers/bus/mhi/core/init.c +++ b/drivers/bus/mhi/core/init.c @@ -904,6 +904,7 @@ int mhi_register_controller(struct mhi_controller *mhi_cntrl, mhi_dev->dev_type = MHI_DEVICE_CONTROLLER; mhi_dev->mhi_cntrl = mhi_cntrl; dev_set_name(&mhi_dev->dev, "%s", dev_name(mhi_cntrl->cntrl_dev)); + mhi_dev->name = dev_name(mhi_cntrl->cntrl_dev); /* Init wakeup source */ device_init_wakeup(&mhi_dev->dev, true); @@ -1249,7 +1250,7 @@ static int mhi_uevent(struct device *dev, struct kobj_uevent_env *env) struct mhi_device *mhi_dev = to_mhi_device(dev); return add_uevent_var(env, "MODALIAS=" MHI_DEVICE_MODALIAS_FMT, - mhi_dev->chan_name); + mhi_dev->name); } static int mhi_match(struct device *dev, struct device_driver *drv) @@ -1266,7 +1267,7 @@ static int mhi_match(struct device *dev, struct device_driver *drv) return 0; for (id = mhi_drv->id_table; id->chan[0]; id++) - if (!strcmp(mhi_dev->chan_name, id->chan)) { + if (!strcmp(mhi_dev->name, id->chan)) { mhi_dev->id = id; return 1; } diff --git a/drivers/bus/mhi/core/main.c b/drivers/bus/mhi/core/main.c index 79be18ec2ebf..2cff5ddff225 100644 --- a/drivers/bus/mhi/core/main.c +++ b/drivers/bus/mhi/core/main.c @@ -249,7 +249,7 @@ int mhi_destroy_device(struct device *dev, void *data) put_device(&mhi_dev->dl_chan->mhi_dev->dev); dev_dbg(&mhi_cntrl->mhi_dev->dev, "destroy device for chan:%s\n", - mhi_dev->chan_name); + mhi_dev->name); /* Notify the client and remove the device from MHI bus */ device_del(dev); @@ -327,10 +327,10 @@ void mhi_create_devices(struct mhi_controller *mhi_cntrl) } /* Channel name is same for both UL and DL */ - mhi_dev->chan_name = mhi_chan->name; + mhi_dev->name = mhi_chan->name; dev_set_name(&mhi_dev->dev, "%s_%s", dev_name(mhi_cntrl->cntrl_dev), - mhi_dev->chan_name); + mhi_dev->name); /* Init wakeup source if available */ if (mhi_dev->dl_chan && mhi_dev->dl_chan->wake_capable) diff --git a/include/linux/mhi.h b/include/linux/mhi.h index 0779bc689b3e..bb337d163dda 100644 --- a/include/linux/mhi.h +++ b/include/linux/mhi.h @@ -438,10 +438,10 @@ struct mhi_controller { }; /** - * struct mhi_device - Structure representing a MHI device which binds - * to channels + * struct mhi_device - Structure representing an MHI device which binds + * to channels or is associated with controllers * @id: Pointer to MHI device ID struct - * @chan_name: Name of the channel to which the device binds + * @name: Name of the associated MHI device * @mhi_cntrl: Controller the device belongs to * @ul_chan: UL channel for the device * @dl_chan: DL channel for the device @@ -453,7 +453,7 @@ struct mhi_controller { */ struct mhi_device { const struct mhi_device_id *id; - const char *chan_name; + const char *name; struct mhi_controller *mhi_cntrl; struct mhi_chan *ul_chan; struct mhi_chan *dl_chan; From patchwork Mon Sep 21 16:08:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manivannan Sadhasivam X-Patchwork-Id: 11790357 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 204CF139A for ; Mon, 21 Sep 2020 16:10:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 05AAE20739 for ; Mon, 21 Sep 2020 16:10:17 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="rdwKiMbw" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728061AbgIUQKR (ORCPT ); Mon, 21 Sep 2020 12:10:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57110 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727803AbgIUQKR (ORCPT ); Mon, 21 Sep 2020 12:10:17 -0400 Received: from mail-pf1-x442.google.com (mail-pf1-x442.google.com [IPv6:2607:f8b0:4864:20::442]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1C650C0613CF for ; Mon, 21 Sep 2020 09:10:17 -0700 (PDT) Received: by mail-pf1-x442.google.com with SMTP id b124so9642166pfg.13 for ; Mon, 21 Sep 2020 09:10:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=SCbfk5KhIaeQlvR4Cwr7GsH4vv2lp3s8XkSFmUeV6ps=; b=rdwKiMbw15soRTNgDT16iUi/RaR4vGcj998+9ku+WxSzu/MlxUra5XX0ii3CcLXYuR oXCFK+OzujkmeJmFnS8TBqqZaiDmAuyRNNF7vbr2/UV4F+z697ANlhePjuktJ9Xt0ZIW BDTguJyeFEvUilrZ4vWLSZBsnA774lzjXW2qJKsawrJBSyBEeF8i9+MvHIH8+8Or1ngA xCbqZetbs/Fh4YqLUq0+OUZd1x603vy0FGzVZPxqKLxPnTGPsEnTRylJu53eBzSt0yTb pBgjAka1/yZaXYsqIApPwdo/y0fZexuRrl3cplfdgFzVgTcJd6MHfygzfFC6U8wURfDq tytQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=SCbfk5KhIaeQlvR4Cwr7GsH4vv2lp3s8XkSFmUeV6ps=; b=tKwZZu2uG6Dwb+cz6+I50OexfjOYKdkRF5qalnQhxZGj3qOAApPo4MjjlJf66RhyQV X5ltgWC2pA42RTrxKYgkm1Y4FJgzV+JdkeMGGB+iCnuoJT0R4cHqn/0c2GOIS1oHZW24 /8+a8qJ0/nQ3ql4Gu9Xb+nenEi1TGSLvtXqOsMpoFBFphYjKpm3G1/ymRHpLB05i/bpw mCs2nqr7VXdDOHINAbnTDatlCjx628FEKFkoqUkR7OVY7s0mpLC4ZtWrwbu7pWwCRslD 6gOks0Yd6+wd/RY7hB8+Rxye4GSueLaw7C175FiN58XHyjMVpequmX9wWwPvQXrBxe0L PBIQ== X-Gm-Message-State: AOAM531hwTxsYY2JSaNx/OB38y2lwrWd/Yu+WymOWVP0LIdq2ztl2DgO XrY3XDb82KQZF924O1PzGX8vkyH8C5kn X-Google-Smtp-Source: ABdhPJzQxB9AAqs9pHSYgnLOqarkBdkFgsGhxoNxac2OdMjNlIPlqD4xSychnhw5DW+yGcF4q4aDJw== X-Received: by 2002:a17:902:d3d4:b029:d1:e598:3ff3 with SMTP id w20-20020a170902d3d4b02900d1e5983ff3mr630205plb.45.1600704616562; Mon, 21 Sep 2020 09:10:16 -0700 (PDT) Received: from Mani-XPS-13-9360.localdomain ([2409:4072:6d03:bd12:1004:2ccf:6900:b97]) by smtp.gmail.com with ESMTPSA id f4sm9204577pgr.68.2020.09.21.09.10.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Sep 2020 09:10:15 -0700 (PDT) From: Manivannan Sadhasivam To: gregkh@linuxfoundation.org Cc: hemantk@codeaurora.org, jhugo@codeaurora.org, bbhatt@codeaurora.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Manivannan Sadhasivam Subject: [PATCH 07/18] bus: mhi: core: Introduce helper function to check device state Date: Mon, 21 Sep 2020 21:38:04 +0530 Message-Id: <20200921160815.28071-9-manivannan.sadhasivam@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200921160815.28071-1-manivannan.sadhasivam@linaro.org> References: <20200921160815.28071-1-manivannan.sadhasivam@linaro.org> Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org From: Bhaumik Bhatt Introduce a helper function to determine whether the device is in a powered ON state and resides in one of the active MHI states. This will allow for some use cases where access can be pre-determined. Signed-off-by: Bhaumik Bhatt Reviewed-by: Jeffrey Hugo Reviewed-by: Manivannan Sadhasivam Signed-off-by: Manivannan Sadhasivam --- drivers/bus/mhi/core/internal.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/bus/mhi/core/internal.h b/drivers/bus/mhi/core/internal.h index 1bbd6e99d38d..5a81a428c4aa 100644 --- a/drivers/bus/mhi/core/internal.h +++ b/drivers/bus/mhi/core/internal.h @@ -598,6 +598,11 @@ int mhi_pm_m3_transition(struct mhi_controller *mhi_cntrl); int __mhi_device_get_sync(struct mhi_controller *mhi_cntrl); int mhi_send_cmd(struct mhi_controller *mhi_cntrl, struct mhi_chan *mhi_chan, enum mhi_cmd_type cmd); +static inline bool mhi_is_active(struct mhi_controller *mhi_cntrl) +{ + return (mhi_cntrl->dev_state >= MHI_STATE_M0 && + mhi_cntrl->dev_state <= MHI_STATE_M3_FAST); +} static inline void mhi_trigger_resume(struct mhi_controller *mhi_cntrl) { From patchwork Mon Sep 21 16:08:05 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manivannan Sadhasivam X-Patchwork-Id: 11790359 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 352CA139A for ; Mon, 21 Sep 2020 16:10:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 103C62193E for ; Mon, 21 Sep 2020 16:10:26 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="EeEywDoS" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728072AbgIUQKZ (ORCPT ); Mon, 21 Sep 2020 12:10:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57136 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728070AbgIUQKY (ORCPT ); Mon, 21 Sep 2020 12:10:24 -0400 Received: from mail-pg1-x544.google.com (mail-pg1-x544.google.com [IPv6:2607:f8b0:4864:20::544]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 50654C0613CF for ; Mon, 21 Sep 2020 09:10:24 -0700 (PDT) Received: by mail-pg1-x544.google.com with SMTP id k14so9439300pgi.9 for ; Mon, 21 Sep 2020 09:10:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=JMSzjnZoFPF6UWbIK88WIGtNwMDAVVwPEVBN0nLk6ZA=; b=EeEywDoSwGRzEUC249BrXsO5YAVjp38NLGC9vWyy3umokPXd3Is7NYC8/85/SF80/C HDkNINxRHcD4oV8LPG4mb55REayGb15zbOl61ujEbvl7EHKnioi/uNv/hQuFIMKIyAW3 8qTrng4DySI7pfguYgUvIac1V8HmwzFu0ygTS7KU2veioftcrdVSZwvz1qYIn8hR6w1U Hs2mXqISkfBc2Mlp4NDygoHNOjLfRJMsrZEzTcQBDHZezgybVCXuqsN6qn2V7sq25/7I KKBMijlHO1nyQjj+tegMX02PWvcDePL+avczuD0oDx/5uXzcq2bw9UpgIl0q1UaToBPY Hkxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=JMSzjnZoFPF6UWbIK88WIGtNwMDAVVwPEVBN0nLk6ZA=; b=VsK29i4Yk0TNGCq2forYPQwvMmOZsoFXa6vBzbVXsJti3S37H5hFLroFzdfw8KdHQW 79iXu4j1fxBmuUFEwZ/BDppq7vrAwNLMJG5knsw2b4vZgGSTVPiRFgJzj3eR6Yyty0ik l13EfDLX96dNSn4GHpiHlgkM1lMbXfeXsmW9PPtN6DQuhEPaVKoCBAY3nJ4MuZJPExx9 FUHWPh0H/9uuLvpoPTRIbX5vEcnOYMI79yrth722F2aHN/SU0xB4Lm1rQqfk2VXir47x cf23izDYHELcLK8QnQe13xADLnR/sQt42qvNOpKOMbGIlJsapb4lDzex7GbSTmCxmsQJ ihvA== X-Gm-Message-State: AOAM533nyhToAP+zxO7uuoLCsB5KXIJjt8swq+JgonAuQC5ew4140M/M +QVfCj289t5eCS4oE9fbd8mR X-Google-Smtp-Source: ABdhPJxr/hw/GlBiopC8cgyuObHmQpvPXB3uTO3S0LGg+QQxmAWO/dPgId9Ub/y/HEjLAuhmH+Hgcw== X-Received: by 2002:a17:902:8682:b029:d1:e5e7:be5b with SMTP id g2-20020a1709028682b02900d1e5e7be5bmr550986plo.53.1600704623762; Mon, 21 Sep 2020 09:10:23 -0700 (PDT) Received: from Mani-XPS-13-9360.localdomain ([2409:4072:6d03:bd12:1004:2ccf:6900:b97]) by smtp.gmail.com with ESMTPSA id f4sm9204577pgr.68.2020.09.21.09.10.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Sep 2020 09:10:23 -0700 (PDT) From: Manivannan Sadhasivam To: gregkh@linuxfoundation.org Cc: hemantk@codeaurora.org, jhugo@codeaurora.org, bbhatt@codeaurora.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Manivannan Sadhasivam Subject: [PATCH 08/18] bus: mhi: core: Introduce counters to track MHI device state transitions Date: Mon, 21 Sep 2020 21:38:05 +0530 Message-Id: <20200921160815.28071-10-manivannan.sadhasivam@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200921160815.28071-1-manivannan.sadhasivam@linaro.org> References: <20200921160815.28071-1-manivannan.sadhasivam@linaro.org> Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org From: Bhaumik Bhatt Use counters to track MHI device state transitions such as those to M0, M2, or M3 states. This can help in better debug, allowing the user to see the number of transitions to a certain MHI state when queried using debugfs entries or via other mechanisms. Signed-off-by: Bhaumik Bhatt Reviewed-by: Manivannan Sadhasivam Signed-off-by: Manivannan Sadhasivam --- drivers/bus/mhi/core/pm.c | 4 ++++ include/linux/mhi.h | 2 ++ 2 files changed, 6 insertions(+) diff --git a/drivers/bus/mhi/core/pm.c b/drivers/bus/mhi/core/pm.c index 27bb471c8f4e..ce4d969818b4 100644 --- a/drivers/bus/mhi/core/pm.c +++ b/drivers/bus/mhi/core/pm.c @@ -256,6 +256,7 @@ int mhi_pm_m0_transition(struct mhi_controller *mhi_cntrl) dev_err(dev, "Unable to transition to M0 state\n"); return -EIO; } + mhi_cntrl->M0++; /* Wake up the device */ read_lock_bh(&mhi_cntrl->pm_lock); @@ -326,6 +327,8 @@ void mhi_pm_m1_transition(struct mhi_controller *mhi_cntrl) mhi_cntrl->dev_state = MHI_STATE_M2; write_unlock_irq(&mhi_cntrl->pm_lock); + + mhi_cntrl->M2++; wake_up_all(&mhi_cntrl->state_event); /* If there are any pending resources, exit M2 immediately */ @@ -362,6 +365,7 @@ int mhi_pm_m3_transition(struct mhi_controller *mhi_cntrl) return -EIO; } + mhi_cntrl->M3++; wake_up_all(&mhi_cntrl->state_event); return 0; diff --git a/include/linux/mhi.h b/include/linux/mhi.h index bb337d163dda..c56b4447a4e9 100644 --- a/include/linux/mhi.h +++ b/include/linux/mhi.h @@ -328,6 +328,7 @@ struct mhi_controller_config { * @dev_state: MHI device state * @dev_wake: Device wakeup count * @pending_pkts: Pending packets for the controller + * @M0, M2, M3: Counters to track number of device MHI state changes * @transition_list: List of MHI state transitions * @transition_lock: Lock for protecting MHI state transition list * @wlock: Lock for protecting device wakeup @@ -407,6 +408,7 @@ struct mhi_controller { enum mhi_state dev_state; atomic_t dev_wake; atomic_t pending_pkts; + u32 M0, M2, M3; struct list_head transition_list; spinlock_t transition_lock; spinlock_t wlock; From patchwork Mon Sep 21 16:08:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manivannan Sadhasivam X-Patchwork-Id: 11790361 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CFF7D59D for ; Mon, 21 Sep 2020 16:10:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id ADBDB206BE for ; Mon, 21 Sep 2020 16:10:31 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="OnnKXHeu" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728090AbgIUQKa (ORCPT ); Mon, 21 Sep 2020 12:10:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57150 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727964AbgIUQK3 (ORCPT ); Mon, 21 Sep 2020 12:10:29 -0400 Received: from mail-pg1-x541.google.com (mail-pg1-x541.google.com [IPv6:2607:f8b0:4864:20::541]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B78A6C0613CF for ; Mon, 21 Sep 2020 09:10:29 -0700 (PDT) Received: by mail-pg1-x541.google.com with SMTP id d13so9447952pgl.6 for ; Mon, 21 Sep 2020 09:10:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Y1HDeSf7eMJfSl6ZK/D9lqct6zJN8sO0bd/DmJuThzk=; b=OnnKXHeu0gFD1wy19P35KkaXRDmcdtg7+nSvOwElegc3Jq7Ff43XEFR31TUL6MOxOJ XNy58SaR7p5nYyQFtNHHAin4eZTGKiOFyLodPLBDrq/FYaWTlpEE2N4fsO7VF/pfxZgH ksoJDLEmTFP5mbeLRUwRfl7llbZHfl7qAny34iTJFqJWQy+9L19mRc7uNTO4kr9hUG5y KnLpw9Y3IUyurWh8MQQF8qI3Y5r/1QY15mgcmd36OsUrSi/dO+RHs6SxWVLEprGjP0cd lchrtl2/8J340jhL2sD/JrPjAax+O59vksh2S2ljVGvdszYPeyvpcBz6Eldrc9w+7h+E M6nw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Y1HDeSf7eMJfSl6ZK/D9lqct6zJN8sO0bd/DmJuThzk=; b=ti+D2IKyfjfDrNKHcK/CkslDvFlT2RZczoQvgVyxFmBrWZ6p5mZ4vdniF9XztBTlm0 PffPo5D3YCcr45SKzwxnQCZP77nIMGY2ivPYtF1fymMW9l5hi90PBTz/+HBk4mYcx2RT U++U3dzgX/V5ry13kOlJV+IdQPIPX9xnb+svqslwg/mVtq2fUN/r8wlHmtUeZLDJWCZx guyGeyrRtc7AicZt0cqJ0nBDUm3Cq9BZwV4Nfr3SYDUodjTWGBZ0mbh+bbZ73LBtZPNZ HFZ2BsgaeYIJORyqE98SX43eJg2+vUzGNDY5GC8CS2/Acydxmbb+oQaQpSsBlPIlfUQH /kgQ== X-Gm-Message-State: AOAM532KP/00F8tD3xMwv6sa3Dz3AvlZtJyRv2ac0ZXCvxvt9MFQusOT jg3ubZ2scJXAYGNiTnwXg5aO X-Google-Smtp-Source: ABdhPJxh561hJTbROl0lX2I6xFhmCC0NCPNS+laM4pQefD5H4SOmInrX6T4BbslGYStvp299VRx13w== X-Received: by 2002:a05:6a00:d0:b029:150:959d:5139 with SMTP id e16-20020a056a0000d0b0290150959d5139mr581026pfj.38.1600704629136; Mon, 21 Sep 2020 09:10:29 -0700 (PDT) Received: from Mani-XPS-13-9360.localdomain ([2409:4072:6d03:bd12:1004:2ccf:6900:b97]) by smtp.gmail.com with ESMTPSA id f4sm9204577pgr.68.2020.09.21.09.10.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Sep 2020 09:10:28 -0700 (PDT) From: Manivannan Sadhasivam To: gregkh@linuxfoundation.org Cc: hemantk@codeaurora.org, jhugo@codeaurora.org, bbhatt@codeaurora.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Manivannan Sadhasivam Subject: [PATCH 09/18] bus: mhi: core: Read and save device hardware information from BHI Date: Mon, 21 Sep 2020 21:38:06 +0530 Message-Id: <20200921160815.28071-11-manivannan.sadhasivam@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200921160815.28071-1-manivannan.sadhasivam@linaro.org> References: <20200921160815.28071-1-manivannan.sadhasivam@linaro.org> Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org From: Bhaumik Bhatt Device hardware specific information such as serial number and the OEM PK hash can be read using BHI and saved on host to identify the endpoint. Signed-off-by: Bhaumik Bhatt Reviewed-by: Jeffrey Hugo Reviewed-by: Manivannan Sadhasivam Signed-off-by: Manivannan Sadhasivam --- drivers/bus/mhi/core/boot.c | 17 ++++++++++++++++- include/linux/mhi.h | 6 ++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/drivers/bus/mhi/core/boot.c b/drivers/bus/mhi/core/boot.c index 0b38014d040e..24422f5c3d80 100644 --- a/drivers/bus/mhi/core/boot.c +++ b/drivers/bus/mhi/core/boot.c @@ -392,13 +392,28 @@ void mhi_fw_load_handler(struct mhi_controller *mhi_cntrl) void *buf; dma_addr_t dma_addr; size_t size; - int ret; + int i, ret; if (MHI_PM_IN_ERROR_STATE(mhi_cntrl->pm_state)) { dev_err(dev, "Device MHI is not in valid state\n"); return; } + /* save hardware info from BHI */ + ret = mhi_read_reg(mhi_cntrl, mhi_cntrl->bhi, BHI_SERIALNU, + &mhi_cntrl->serial_number); + if (ret) + dev_err(dev, "Could not capture serial number via BHI\n"); + + for (i = 0; i < ARRAY_SIZE(mhi_cntrl->oem_pk_hash); i++) { + ret = mhi_read_reg(mhi_cntrl, mhi_cntrl->bhi, BHI_OEMPKHASH(i), + &mhi_cntrl->oem_pk_hash[i]); + if (ret) { + dev_err(dev, "Could not capture OEM PK HASH via BHI\n"); + break; + } + } + /* If device is in pass through, do reset to ready state transition */ if (mhi_cntrl->ee == MHI_EE_PTHRU) goto fw_load_ee_pthru; diff --git a/include/linux/mhi.h b/include/linux/mhi.h index c56b4447a4e9..0c97f4bc5fae 100644 --- a/include/linux/mhi.h +++ b/include/linux/mhi.h @@ -16,6 +16,8 @@ #include #include +#define MHI_MAX_OEM_PK_HASH_SEGMENTS 16 + struct mhi_chan; struct mhi_event; struct mhi_ctxt; @@ -316,6 +318,8 @@ struct mhi_controller_config { * @device_number: MHI controller device number * @major_version: MHI controller major revision number * @minor_version: MHI controller minor revision number + * @serial_number: MHI controller serial number obtained from BHI + * @oem_pk_hash: MHI controller OEM PK Hash obtained from BHI * @mhi_event: MHI event ring configurations table * @mhi_cmd: MHI command ring configurations table * @mhi_ctxt: MHI device context, shared memory between host and device @@ -394,6 +398,8 @@ struct mhi_controller { u32 device_number; u32 major_version; u32 minor_version; + u32 serial_number; + u32 oem_pk_hash[MHI_MAX_OEM_PK_HASH_SEGMENTS]; struct mhi_event *mhi_event; struct mhi_cmd *mhi_cmd; From patchwork Mon Sep 21 16:08:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manivannan Sadhasivam X-Patchwork-Id: 11790363 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2640C59D for ; Mon, 21 Sep 2020 16:10:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F3EDF206BE for ; Mon, 21 Sep 2020 16:10:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="Zi2U3hS5" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727386AbgIUQKf (ORCPT ); Mon, 21 Sep 2020 12:10:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57168 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727062AbgIUQKf (ORCPT ); Mon, 21 Sep 2020 12:10:35 -0400 Received: from mail-pj1-x1042.google.com (mail-pj1-x1042.google.com [IPv6:2607:f8b0:4864:20::1042]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D977CC0613CF for ; Mon, 21 Sep 2020 09:10:34 -0700 (PDT) Received: by mail-pj1-x1042.google.com with SMTP id u3so32451pjr.3 for ; Mon, 21 Sep 2020 09:10:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=s8QQquLL4oGKh6uhiaB6MoxZtKFnQbbrDA+3b3PoVuU=; b=Zi2U3hS5M6EGhoGn5mKRXB07Bcv1/S1tkfmfTtxc1SQ6NFrZ7Qno8QCqlFBnj5xVGo iQbOHHl1HP2PhKXv2+CNP6OXtK3j0XmiI8RJU1KqaJZ7DNar38nd8KYdsjnmd9lIML/X u1hcHuJnhox50tEnkKPlKIZvbjqyu8Vm8EjUk/3ACRFXPKUZylpwGSz1T+KR6gB7BiJT PYfG9mv/Lo8XoFfvTV3ZY4f4igck1RsbP+BCBXvRQC6tEWn+e243qGPQliTJbhdSXx1G Ttx3jUDDRUO/monukP979Othht1LqBIaTVw9GjN6EyWeCTYUIqF+lDmqlReWWVmlCRde SGNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=s8QQquLL4oGKh6uhiaB6MoxZtKFnQbbrDA+3b3PoVuU=; b=O7zzrmcticTNsqjT92Kwmms7ToIgcAyDgEeC2E9CAym3ww5Xem+Fe7dFCu4arRbrmW 7jV3w9FQsI05c/yR641iUdGGrYtNdhf+L4PNIW0gwuCULmHfmF6rx4jetx4FZIaypDd0 PFIwdDA3W+eVk6PB6AbX2NqmQ9K3OPexgDOSNfRUQgPHwBKI+vCuKPWrddF4F6j1/FMs BtguPWvTEu0CnWEcqa+ht8EBsWyfWmc3e9Ep/TP6KQkXg7+kv7qQaGujYjm2QDsxVThT wl4hcjo5Yvmsxia2E+g0KvFG59IpoSx8Vg9sYx3+VHdUrb+Uu8GyaAZK8rnfKhOXFogt DXRQ== X-Gm-Message-State: AOAM533SpWNRVU8rBN3g9yKtDcueC10VLp95L/5wgTi8d8uNt8TH6v36 Gbh20jtnfxoU3Fw5RB1lAuP3j3lpHWVd X-Google-Smtp-Source: ABdhPJxM8pxvY6U98jZYzYtId38lEuA44xz3LcayRJ8O8C7y0ehGeliqpDfU/erXTGe1qv5PJMe8tw== X-Received: by 2002:a17:90a:a613:: with SMTP id c19mr85910pjq.119.1600704634320; Mon, 21 Sep 2020 09:10:34 -0700 (PDT) Received: from Mani-XPS-13-9360.localdomain ([2409:4072:6d03:bd12:1004:2ccf:6900:b97]) by smtp.gmail.com with ESMTPSA id f4sm9204577pgr.68.2020.09.21.09.10.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Sep 2020 09:10:33 -0700 (PDT) From: Manivannan Sadhasivam To: gregkh@linuxfoundation.org Cc: hemantk@codeaurora.org, jhugo@codeaurora.org, bbhatt@codeaurora.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Manivannan Sadhasivam Subject: [PATCH 10/18] bus: mhi: core: Introduce APIs to allocate and free the MHI controller Date: Mon, 21 Sep 2020 21:38:07 +0530 Message-Id: <20200921160815.28071-12-manivannan.sadhasivam@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200921160815.28071-1-manivannan.sadhasivam@linaro.org> References: <20200921160815.28071-1-manivannan.sadhasivam@linaro.org> Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org From: Bhaumik Bhatt Client devices should use the APIs provided to allocate and free the MHI controller structure. This will help ensure that the structure is zero-initialized and there are no false positives with respect to reading any values such as the serial number or the OEM PK hash. Suggested-by: Manivannan Sadhasivam Signed-off-by: Bhaumik Bhatt Reviewed-by: Manivannan Sadhasivam Signed-off-by: Manivannan Sadhasivam --- drivers/bus/mhi/core/init.c | 16 ++++++++++++++++ include/linux/mhi.h | 12 ++++++++++++ 2 files changed, 28 insertions(+) diff --git a/drivers/bus/mhi/core/init.c b/drivers/bus/mhi/core/init.c index e2011ec46b92..f69a2f3d039d 100644 --- a/drivers/bus/mhi/core/init.c +++ b/drivers/bus/mhi/core/init.c @@ -954,6 +954,22 @@ void mhi_unregister_controller(struct mhi_controller *mhi_cntrl) } EXPORT_SYMBOL_GPL(mhi_unregister_controller); +struct mhi_controller *mhi_alloc_controller(void) +{ + struct mhi_controller *mhi_cntrl; + + mhi_cntrl = kzalloc(sizeof(*mhi_cntrl), GFP_KERNEL); + + return mhi_cntrl; +} +EXPORT_SYMBOL_GPL(mhi_alloc_controller); + +void mhi_free_controller(struct mhi_controller *mhi_cntrl) +{ + kfree(mhi_cntrl); +} +EXPORT_SYMBOL_GPL(mhi_free_controller); + int mhi_prepare_for_power_up(struct mhi_controller *mhi_cntrl) { struct device *dev = &mhi_cntrl->mhi_dev->dev; diff --git a/include/linux/mhi.h b/include/linux/mhi.h index 0c97f4bc5fae..6b987e8cc438 100644 --- a/include/linux/mhi.h +++ b/include/linux/mhi.h @@ -527,6 +527,18 @@ struct mhi_driver { #define to_mhi_driver(drv) container_of(drv, struct mhi_driver, driver) #define to_mhi_device(dev) container_of(dev, struct mhi_device, dev) +/** + * mhi_alloc_controller - Allocate the MHI Controller structure + * Allocate the mhi_controller structure using zero initialized memory + */ +struct mhi_controller *mhi_alloc_controller(void); + +/** + * mhi_free_controller - Free the MHI Controller structure + * Free the mhi_controller structure which was previously allocated + */ +void mhi_free_controller(struct mhi_controller *mhi_cntrl); + /** * mhi_register_controller - Register MHI controller * @mhi_cntrl: MHI controller to register From patchwork Mon Sep 21 16:08:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manivannan Sadhasivam X-Patchwork-Id: 11790365 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5EB03139A for ; Mon, 21 Sep 2020 16:10:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3D000206FB for ; Mon, 21 Sep 2020 16:10:41 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="LzdCBSVs" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728108AbgIUQKk (ORCPT ); Mon, 21 Sep 2020 12:10:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57188 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726696AbgIUQKk (ORCPT ); Mon, 21 Sep 2020 12:10:40 -0400 Received: from mail-pg1-x541.google.com (mail-pg1-x541.google.com [IPv6:2607:f8b0:4864:20::541]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4B73FC0613CF for ; Mon, 21 Sep 2020 09:10:40 -0700 (PDT) Received: by mail-pg1-x541.google.com with SMTP id o25so4504415pgm.0 for ; Mon, 21 Sep 2020 09:10:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=jNx5jfKYWZGFzKUONheqZrKSOvFz+O7hWeUKgyZ6/3A=; b=LzdCBSVsIZbg8EwXxwyxJP5SBlJdU8sfPtLhO9DKz7Qx6gL2BlwGCqUBv88BrT/lOJ wQN7w9tvbNZWd5AfQokR/ezQ95E9fvbwaLZb8N8TdwCmsNn/q1msTsR2dVAm3dbzF+Ou IzhrYJNFrpSdIUXbYtCp9HnniJ0jaS1my3BgMoziSOe7LKdt8dVqSuyuzCIqq8apMe3i k4r8TkOzPFzps1cJVfaWFcL5trVTM9pfeTEohs8MBgQQ2313M2U99ci8/V7/V9LLQwCW bi8IvVRG/J8zJM5MHE8fPIbsT2LCMFGb+zUoJF/vwVvo4rMSFe9uOFggjfddjAZQ6JnE XOsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=jNx5jfKYWZGFzKUONheqZrKSOvFz+O7hWeUKgyZ6/3A=; b=UyEEGmsLWzJA0qDbqsJCXHuww27xpHHPYgryMX38rSg059Uaga589ucx9hmzeoqwS5 B11M+ib6V8QvJxyB9cCgoMyL+/0C5fNqqN3HJS4aqnvcODD56VD2sTC3TTH/CSuvrjdU YKbA6U6O40+vXMjlVx4xRRN/DuUhk9pcpkgIm9hEz6vn+GVREngu5n9Om919iPHArdyJ 5Q3x7aiLBf4+lcruZmN0nRMiX5664ZJsNDPe5FHhYhzwV2qgQzA6jenOoNrNQxIkR77V KBWNFEe1hOMUKyMiJFijq21pxZq0HDjR84n6KPfN9s4v+gn8Qz+l8x8/S/Y2p0D4LgL5 QHOA== X-Gm-Message-State: AOAM533Lx6gHaQ+xuN/DjSn2F3dJv5vys52sGM42WhPobmt8qRDRevdY 0n/vm0TXBbol+xuIiNB3g+0E X-Google-Smtp-Source: ABdhPJyOwcOyAV3uHO339uG8sa9a/zsAgyRnHFQidQQUITv4rBBnFpBW3JRiwDZFcACc2rPhZIxYzQ== X-Received: by 2002:a63:7f59:: with SMTP id p25mr306778pgn.146.1600704639764; Mon, 21 Sep 2020 09:10:39 -0700 (PDT) Received: from Mani-XPS-13-9360.localdomain ([2409:4072:6d03:bd12:1004:2ccf:6900:b97]) by smtp.gmail.com with ESMTPSA id f4sm9204577pgr.68.2020.09.21.09.10.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Sep 2020 09:10:38 -0700 (PDT) From: Manivannan Sadhasivam To: gregkh@linuxfoundation.org Cc: hemantk@codeaurora.org, jhugo@codeaurora.org, bbhatt@codeaurora.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Manivannan Sadhasivam Subject: [PATCH 11/18] bus: mhi: core: Add const qualifier to MHI config information Date: Mon, 21 Sep 2020 21:38:08 +0530 Message-Id: <20200921160815.28071-13-manivannan.sadhasivam@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200921160815.28071-1-manivannan.sadhasivam@linaro.org> References: <20200921160815.28071-1-manivannan.sadhasivam@linaro.org> Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org From: Hemant Kumar MHI channel, event and controller config data needs to be treated read only information. Add const qualifier to make sure config information passed by MHI controller is not modified by MHI core driver. Suggested-by: Kalle Valo Signed-off-by: Hemant Kumar Reviewed-by: Manivannan Sadhasivam Signed-off-by: Manivannan Sadhasivam --- drivers/bus/mhi/core/init.c | 12 ++++++------ include/linux/mhi.h | 6 +++--- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/bus/mhi/core/init.c b/drivers/bus/mhi/core/init.c index f69a2f3d039d..d23293876be8 100644 --- a/drivers/bus/mhi/core/init.c +++ b/drivers/bus/mhi/core/init.c @@ -562,10 +562,10 @@ int mhi_init_chan_ctxt(struct mhi_controller *mhi_cntrl, } static int parse_ev_cfg(struct mhi_controller *mhi_cntrl, - struct mhi_controller_config *config) + const struct mhi_controller_config *config) { struct mhi_event *mhi_event; - struct mhi_event_config *event_cfg; + const struct mhi_event_config *event_cfg; struct device *dev = &mhi_cntrl->mhi_dev->dev; int i, num; @@ -648,9 +648,9 @@ static int parse_ev_cfg(struct mhi_controller *mhi_cntrl, } static int parse_ch_cfg(struct mhi_controller *mhi_cntrl, - struct mhi_controller_config *config) + const struct mhi_controller_config *config) { - struct mhi_channel_config *ch_cfg; + const struct mhi_channel_config *ch_cfg; struct device *dev = &mhi_cntrl->mhi_dev->dev; int i; u32 chan; @@ -766,7 +766,7 @@ static int parse_ch_cfg(struct mhi_controller *mhi_cntrl, } static int parse_config(struct mhi_controller *mhi_cntrl, - struct mhi_controller_config *config) + const struct mhi_controller_config *config) { int ret; @@ -803,7 +803,7 @@ static int parse_config(struct mhi_controller *mhi_cntrl, } int mhi_register_controller(struct mhi_controller *mhi_cntrl, - struct mhi_controller_config *config) + const struct mhi_controller_config *config) { struct mhi_event *mhi_event; struct mhi_chan *mhi_chan; diff --git a/include/linux/mhi.h b/include/linux/mhi.h index 6b987e8cc438..b2c0214bfbd6 100644 --- a/include/linux/mhi.h +++ b/include/linux/mhi.h @@ -280,9 +280,9 @@ struct mhi_controller_config { u32 timeout_ms; u32 buf_len; u32 num_channels; - struct mhi_channel_config *ch_cfg; + const struct mhi_channel_config *ch_cfg; u32 num_events; - struct mhi_event_config *event_cfg; + const struct mhi_event_config *event_cfg; bool use_bounce_buf; bool m2_no_db; }; @@ -545,7 +545,7 @@ void mhi_free_controller(struct mhi_controller *mhi_cntrl); * @config: Configuration to use for the controller */ int mhi_register_controller(struct mhi_controller *mhi_cntrl, - struct mhi_controller_config *config); + const struct mhi_controller_config *config); /** * mhi_unregister_controller - Unregister MHI controller From patchwork Mon Sep 21 16:08:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manivannan Sadhasivam X-Patchwork-Id: 11790367 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 513CB59D for ; Mon, 21 Sep 2020 16:10:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2B421206BE for ; Mon, 21 Sep 2020 16:10:47 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="BE73T3S/" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727517AbgIUQKq (ORCPT ); Mon, 21 Sep 2020 12:10:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57202 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727020AbgIUQKq (ORCPT ); Mon, 21 Sep 2020 12:10:46 -0400 Received: from mail-pj1-x1042.google.com (mail-pj1-x1042.google.com [IPv6:2607:f8b0:4864:20::1042]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1EE34C0613CF for ; Mon, 21 Sep 2020 09:10:46 -0700 (PDT) Received: by mail-pj1-x1042.google.com with SMTP id v14so30540pjd.4 for ; Mon, 21 Sep 2020 09:10:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=3OCoOb+JFwXi2wMv6xbpF4vbDUAK9pGDZl8s+55Ok38=; b=BE73T3S/tyHZjhE/erv6+Fp2AzREMLo2TCynxaqXuZRJ64fC1pcsvc7VzbKjwO/I7o SH4cURqL4vpii33opB9A96M8Q3WRE23pR/GUhB7o+WBdHu0wbtn4DfI1rMrTeSa98Pjq BWP6EDopO+LBlrpZQG/P8oHt/36a6oiugbaWyU8eTE3pvuLvdUyOLmMOfu+tKWpuUtYX jTthi20LmO17UXV3MbexJ9FdLsv0BHCqycRGmnmwNE+B63Y7esj5GArJ8SkTkO/8rHmv d/bwW2iCufKpWspTgVe1D+N47MUmGBWcPhxPLI/QpQTSP6tKbaCKfFm7ZRQTqBKR0iDy P4QQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=3OCoOb+JFwXi2wMv6xbpF4vbDUAK9pGDZl8s+55Ok38=; b=Lmd3UUy5998/1e09eUo6OAhnUZDHaAdbcVhb4b6WMtIye1cuAJMkC0PY1m1cXk6F1P fzri7IqiidJ0oAwJcQQjXYkv1oX0pcD0IUyiXWn7xTw2AE1ltbOlqO+6n2anSAy/pI3V kW5VQ/pQNRfAOhV61NEskzQ04tfjYRd8blVJRrGQ56It2S7T5h0c3TtWAO4WoX5s/RiE d46xOSMHYyMmSbN4nnV2j2CHEzfuOsl6lkLrsvIFhffVSKTvooHTrdCgi/2LZQYX0V0I pil5CVQ2mbQfu0/YlMeY+kTh5r1FmmN1jBqBTRsn96NuYbFA+RHj6L83sOFYd0bmqQNE tWiA== X-Gm-Message-State: AOAM532bGX7dBokoagCJcxzywegYGgHptD5DoIxraIEug2LRVv/34+VM uUldHwHSRaSTrTQgSJjJR+et X-Google-Smtp-Source: ABdhPJwpaVojx96jHcOWdx4H9eqAKTLKRQrWAw93+bEo8d17Qa7gp75oKV7hpU7GXAM3XfoPLDiNIQ== X-Received: by 2002:a17:90a:e60b:: with SMTP id j11mr132113pjy.38.1600704645585; Mon, 21 Sep 2020 09:10:45 -0700 (PDT) Received: from Mani-XPS-13-9360.localdomain ([2409:4072:6d03:bd12:1004:2ccf:6900:b97]) by smtp.gmail.com with ESMTPSA id f4sm9204577pgr.68.2020.09.21.09.10.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Sep 2020 09:10:44 -0700 (PDT) From: Manivannan Sadhasivam To: gregkh@linuxfoundation.org Cc: hemantk@codeaurora.org, jhugo@codeaurora.org, bbhatt@codeaurora.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Clark Williams , Sebastian Andrzej Siewior , Manivannan Sadhasivam Subject: [PATCH 12/18] bus: mhi: Remove include of rwlock_types.h Date: Mon, 21 Sep 2020 21:38:09 +0530 Message-Id: <20200921160815.28071-14-manivannan.sadhasivam@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200921160815.28071-1-manivannan.sadhasivam@linaro.org> References: <20200921160815.28071-1-manivannan.sadhasivam@linaro.org> Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org From: Clark Williams rwlock.h should not be included directly. Instead linux/splinlock.h should be included. Including it directly will break the RT build. Also there is no point in including _types.h headers directly. There is no benefit in including the type without the accessor. Fixes: 0cbf260820fa7 ("bus: mhi: core: Add support for registering MHI controllers") Signed-off-by: Clark Williams Signed-off-by: Sebastian Andrzej Siewior Reviewed-by: Manivannan Sadhasivam Signed-off-by: Manivannan Sadhasivam --- include/linux/mhi.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/include/linux/mhi.h b/include/linux/mhi.h index b2c0214bfbd6..008b8f6fa9ff 100644 --- a/include/linux/mhi.h +++ b/include/linux/mhi.h @@ -9,10 +9,9 @@ #include #include #include -#include #include #include -#include +#include #include #include From patchwork Mon Sep 21 16:08:10 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manivannan Sadhasivam X-Patchwork-Id: 11790369 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0037B139A for ; Mon, 21 Sep 2020 16:10:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D493820739 for ; Mon, 21 Sep 2020 16:10:56 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="k708Jdgd" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728127AbgIUQKx (ORCPT ); Mon, 21 Sep 2020 12:10:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57228 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727454AbgIUQKx (ORCPT ); Mon, 21 Sep 2020 12:10:53 -0400 Received: from mail-pj1-x1042.google.com (mail-pj1-x1042.google.com [IPv6:2607:f8b0:4864:20::1042]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5B44FC0613CF for ; Mon, 21 Sep 2020 09:10:53 -0700 (PDT) Received: by mail-pj1-x1042.google.com with SMTP id jw11so40951pjb.0 for ; Mon, 21 Sep 2020 09:10:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=+YUGt6aV7OP8RvUr5xgq7JykMZCPIUZje2/XDNY6QSI=; b=k708JdgdIi/nSpV4h2XycMDyP077KsVUlK0ZeNYIFirBmbKiGGjKFwwk9P9qFjQrh3 VOjnqrwORMsNCHfaWtcYiviVqU5JONwe8znOf/tcRo52+DbAnFbgrufqdDAJfA7HxB5P uXsj6yQ8YwQVZ+bULbYKD4OqUvj8HQme12sN0vRYTKZVOvNmJvDSOWoA9fhdFCCxQSVx ht5BOhSRX+sYx1Ntjfdh6zLwqpCMTYICjWyofGHuAQm8mj6PvdEVpMTSe9HBrz8pZz/n vq1mxPvIV1RwejCKPTXle2C2z3wDuKygJ9CrjxV5FQzhJnFL7d9BbA9/INBuFcnxL4bg ZM+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=+YUGt6aV7OP8RvUr5xgq7JykMZCPIUZje2/XDNY6QSI=; b=pXb+6cLFj+BrNRak9mfqZjOUZB+4ccdcG/WfOTiApgFk5eWVlo/gkD9qX9UkAbMoLI IfX8Ak8J5t5LPmRSVeJivFRTwOVtA6voDlrIH72CI5AQDUyPIcL74YRyYpfR3QACVy55 c8f2n/eHaNc2iO4NZ8yGSiYZa/hxcAWVFKuVB561YjTf234gu1DawABBLp2lSUvaYxyB ZD54xE2ZU1Vkj3sPIOnfx1KDSvCLWnmI8DCqZAffdoorkjL3E3J1oU3fNs3nMLyk1j/6 DKd80WhKHQ2O1J4c3eExA8jzbS+A592/QXRF2zFOTbGsioEPkxvyerlhNJDiGl1toTxz dp8w== X-Gm-Message-State: AOAM5338J/v/AkBm900ZBLq2KM089dJVKqMTvuw76ko3B35EACTRl9UY q+TSEDTNB2UCcf/nHY87U4b7 X-Google-Smtp-Source: ABdhPJxW8TyC2msT8AHrIOLt25DoGImJ36P3WMzJLDSbMKQj9eph6jiHbEz5WgY61kGXVNY0e+sOoQ== X-Received: by 2002:a17:90a:ce95:: with SMTP id g21mr78477pju.175.1600704652764; Mon, 21 Sep 2020 09:10:52 -0700 (PDT) Received: from Mani-XPS-13-9360.localdomain ([2409:4072:6d03:bd12:1004:2ccf:6900:b97]) by smtp.gmail.com with ESMTPSA id f4sm9204577pgr.68.2020.09.21.09.10.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Sep 2020 09:10:52 -0700 (PDT) From: Manivannan Sadhasivam To: gregkh@linuxfoundation.org Cc: hemantk@codeaurora.org, jhugo@codeaurora.org, bbhatt@codeaurora.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Manivannan Sadhasivam Subject: [PATCH 13/18] bus: mhi: Fix entries based on Kconfig coding style Date: Mon, 21 Sep 2020 21:38:10 +0530 Message-Id: <20200921160815.28071-15-manivannan.sadhasivam@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200921160815.28071-1-manivannan.sadhasivam@linaro.org> References: <20200921160815.28071-1-manivannan.sadhasivam@linaro.org> Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org From: Bhaumik Bhatt Kconfig coding style mandates use of tabs for the configuration definition and an additional two spaces for the help text. Make the required changes to the MHI Kconfig adhering to those guidelines. Signed-off-by: Bhaumik Bhatt Reviewed-by: Manivannan Sadhasivam Acked-by: Randy Dunlap Signed-off-by: Manivannan Sadhasivam --- drivers/bus/mhi/Kconfig | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/bus/mhi/Kconfig b/drivers/bus/mhi/Kconfig index a8bd9bd7db7c..6677cccd61f3 100644 --- a/drivers/bus/mhi/Kconfig +++ b/drivers/bus/mhi/Kconfig @@ -6,9 +6,9 @@ # config MHI_BUS - tristate "Modem Host Interface (MHI) bus" - help - Bus driver for MHI protocol. Modem Host Interface (MHI) is a - communication protocol used by the host processors to control - and communicate with modem devices over a high speed peripheral - bus or shared memory. + tristate "Modem Host Interface (MHI) bus" + help + Bus driver for MHI protocol. Modem Host Interface (MHI) is a + communication protocol used by the host processors to control + and communicate with modem devices over a high speed peripheral + bus or shared memory. From patchwork Mon Sep 21 16:08:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manivannan Sadhasivam X-Patchwork-Id: 11790371 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6AC0059D for ; Mon, 21 Sep 2020 16:11:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3A62620739 for ; Mon, 21 Sep 2020 16:11:07 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="rrpZH+wt" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727654AbgIUQLG (ORCPT ); Mon, 21 Sep 2020 12:11:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57264 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727197AbgIUQLG (ORCPT ); Mon, 21 Sep 2020 12:11:06 -0400 Received: from mail-pj1-x1043.google.com (mail-pj1-x1043.google.com [IPv6:2607:f8b0:4864:20::1043]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 67576C061755 for ; Mon, 21 Sep 2020 09:11:06 -0700 (PDT) Received: by mail-pj1-x1043.google.com with SMTP id t7so35448pjd.3 for ; Mon, 21 Sep 2020 09:11:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=cl8WuaqT6daB8SQvBeU9AT51frnXwBiNmDdAf60b8R4=; b=rrpZH+wtJ3Tamj4Ut8mtStjGlCZj1ZoXmr1W1kmytMX43JE9C020ObcaAg6regv3Tn qd7EKrtnsceN8mRBaQC3WNSRL0IJKM/uDId80tbFrH2tXk4AuwI0RlPh9BgoXGKKuRz9 qkI5CIAYFXyjU11RfNpyzH54FN3GgP9kNJZGRORsfOu+u2yKtx4INBH997VOKYBlVmpB f7hVlzkJYGPTwmDeCPaOPGOFJCrctvqHwyzsGHayr/2xmmhB3bpkFYEhLfojpguKETht oQTrpekiUDkkmVk/ECYO6j7ya1oqbGU6h2vPY9Z9bCioCaliD/ZmWTyRmd1dns6T8Lcc yLEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=cl8WuaqT6daB8SQvBeU9AT51frnXwBiNmDdAf60b8R4=; b=AlT7iN3lgtci/7b8edqpQTx32n526s3xt3e0mtx5lR84aWPW2CwiUC/KTl3BXHUneb WuAEvLCEdhIw2yWvas9AcH11CsEbwLcyn/dkBCUvyO2o0z0JGQOqWuSTxU0xYCTXnLzS 5c/NAb/yCrPWbVuNwGg4pOcOxdiJ+/TC8X65Jp3fAH2BSkkn1jctyaj9qRHFLIgZbyai l7+AQEQ0jrANClx5T5UI4fCpfEQHfZ7+Pk+AluzrJeXf9V03FOsKG8DByL7JZU7z8DjN 8zNpsZaIflld2PnueT1NAK8/hzuTwtcMyjxSPDdosjNCm/m/gqt3fq7zFzFxvH5hpsfV elkg== X-Gm-Message-State: AOAM531B7cLV89+N4tJZd03vvYY6FUFQXlNAZm1q0gq3A2RBsEG4yCkg dyaWxjD66KhODRa8DdBGqS0R X-Google-Smtp-Source: ABdhPJyxClWwVE49dYZiwvGkyyz6Vx55L6pMLdQH9gMx7ZVTCwfoTdLAPgznuvHsVky/zJOwWwRCgw== X-Received: by 2002:a17:90a:520b:: with SMTP id v11mr133575pjh.54.1600704665738; Mon, 21 Sep 2020 09:11:05 -0700 (PDT) Received: from Mani-XPS-13-9360.localdomain ([2409:4072:6d03:bd12:1004:2ccf:6900:b97]) by smtp.gmail.com with ESMTPSA id f4sm9204577pgr.68.2020.09.21.09.10.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Sep 2020 09:11:05 -0700 (PDT) From: Manivannan Sadhasivam To: gregkh@linuxfoundation.org Cc: hemantk@codeaurora.org, jhugo@codeaurora.org, bbhatt@codeaurora.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Manivannan Sadhasivam Subject: [PATCH 14/18] bus: mhi: core: Introduce debugfs entries for MHI Date: Mon, 21 Sep 2020 21:38:11 +0530 Message-Id: <20200921160815.28071-16-manivannan.sadhasivam@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200921160815.28071-1-manivannan.sadhasivam@linaro.org> References: <20200921160815.28071-1-manivannan.sadhasivam@linaro.org> Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org From: Bhaumik Bhatt Introduce debugfs entries to show state, register, channel, device, and event rings information. Allow the host to dump registers, issue device wake, and change the MHI timeout to help in debug. Signed-off-by: Bhaumik Bhatt Reviewed-by: Manivannan Sadhasivam Signed-off-by: Manivannan Sadhasivam --- drivers/bus/mhi/Kconfig | 8 + drivers/bus/mhi/core/Makefile | 1 + drivers/bus/mhi/core/debugfs.c | 410 ++++++++++++++++++++++++++++++++ drivers/bus/mhi/core/init.c | 7 + drivers/bus/mhi/core/internal.h | 24 ++ include/linux/mhi.h | 2 + 6 files changed, 452 insertions(+) create mode 100644 drivers/bus/mhi/core/debugfs.c diff --git a/drivers/bus/mhi/Kconfig b/drivers/bus/mhi/Kconfig index 6677cccd61f3..e841c1097fb4 100644 --- a/drivers/bus/mhi/Kconfig +++ b/drivers/bus/mhi/Kconfig @@ -12,3 +12,11 @@ config MHI_BUS communication protocol used by the host processors to control and communicate with modem devices over a high speed peripheral bus or shared memory. + +config MHI_BUS_DEBUG + bool "Debugfs support for the MHI bus" + depends on MHI_BUS && DEBUG_FS + help + Enable debugfs support for use with the MHI transport. Allows + reading and/or modifying some values within the MHI controller + for debug and test purposes. diff --git a/drivers/bus/mhi/core/Makefile b/drivers/bus/mhi/core/Makefile index 66e2700c9032..12c57ab3724c 100644 --- a/drivers/bus/mhi/core/Makefile +++ b/drivers/bus/mhi/core/Makefile @@ -1,3 +1,4 @@ obj-$(CONFIG_MHI_BUS) := mhi.o mhi-y := init.o main.o pm.o boot.o +mhi-$(CONFIG_MHI_BUS_DEBUG) += debugfs.o diff --git a/drivers/bus/mhi/core/debugfs.c b/drivers/bus/mhi/core/debugfs.c new file mode 100644 index 000000000000..53d05a8e168d --- /dev/null +++ b/drivers/bus/mhi/core/debugfs.c @@ -0,0 +1,410 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (c) 2020, The Linux Foundation. All rights reserved. + * + */ + +#include +#include +#include +#include +#include +#include +#include "internal.h" + +static int mhi_debugfs_states_show(struct seq_file *m, void *d) +{ + struct mhi_controller *mhi_cntrl = m->private; + + /* states */ + seq_printf(m, "PM state: %s Device: %s MHI state: %s EE: %s wake: %s\n", + to_mhi_pm_state_str(mhi_cntrl->pm_state), + mhi_is_active(mhi_cntrl) ? "Active" : "Inactive", + TO_MHI_STATE_STR(mhi_cntrl->dev_state), + TO_MHI_EXEC_STR(mhi_cntrl->ee), + mhi_cntrl->wake_set ? "true" : "false"); + + /* counters */ + seq_printf(m, "M0: %u M2: %u M3: %u", mhi_cntrl->M0, mhi_cntrl->M2, + mhi_cntrl->M3); + + seq_printf(m, " device wake: %u pending packets: %u\n", + atomic_read(&mhi_cntrl->dev_wake), + atomic_read(&mhi_cntrl->pending_pkts)); + + return 0; +} + +static int mhi_debugfs_events_show(struct seq_file *m, void *d) +{ + struct mhi_controller *mhi_cntrl = m->private; + struct mhi_event *mhi_event; + struct mhi_event_ctxt *er_ctxt; + int i; + + if (!mhi_is_active(mhi_cntrl)) { + seq_puts(m, "Device not ready\n"); + return -ENODEV; + } + + er_ctxt = mhi_cntrl->mhi_ctxt->er_ctxt; + mhi_event = mhi_cntrl->mhi_event; + for (i = 0; i < mhi_cntrl->total_ev_rings; + i++, er_ctxt++, mhi_event++) { + struct mhi_ring *ring = &mhi_event->ring; + + if (mhi_event->offload_ev) { + seq_printf(m, "Index: %d is an offload event ring\n", + i); + continue; + } + + seq_printf(m, "Index: %d intmod count: %lu time: %lu", + i, (er_ctxt->intmod & EV_CTX_INTMODC_MASK) >> + EV_CTX_INTMODC_SHIFT, + (er_ctxt->intmod & EV_CTX_INTMODT_MASK) >> + EV_CTX_INTMODT_SHIFT); + + seq_printf(m, " base: 0x%0llx len: 0x%llx", er_ctxt->rbase, + er_ctxt->rlen); + + seq_printf(m, " rp: 0x%llx wp: 0x%llx", er_ctxt->rp, + er_ctxt->wp); + + seq_printf(m, " local rp: 0x%llx db: 0x%llx\n", (u64)ring->rp, + mhi_event->db_cfg.db_val); + } + + return 0; +} + +static int mhi_debugfs_channels_show(struct seq_file *m, void *d) +{ + struct mhi_controller *mhi_cntrl = m->private; + struct mhi_chan *mhi_chan; + struct mhi_chan_ctxt *chan_ctxt; + int i; + + if (!mhi_is_active(mhi_cntrl)) { + seq_puts(m, "Device not ready\n"); + return -ENODEV; + } + + mhi_chan = mhi_cntrl->mhi_chan; + chan_ctxt = mhi_cntrl->mhi_ctxt->chan_ctxt; + for (i = 0; i < mhi_cntrl->max_chan; i++, chan_ctxt++, mhi_chan++) { + struct mhi_ring *ring = &mhi_chan->tre_ring; + + if (mhi_chan->offload_ch) { + seq_printf(m, "%s(%u) is an offload channel\n", + mhi_chan->name, mhi_chan->chan); + continue; + } + + if (!mhi_chan->mhi_dev) + continue; + + seq_printf(m, + "%s(%u) state: 0x%lx brstmode: 0x%lx pollcfg: 0x%lx", + mhi_chan->name, mhi_chan->chan, (chan_ctxt->chcfg & + CHAN_CTX_CHSTATE_MASK) >> CHAN_CTX_CHSTATE_SHIFT, + (chan_ctxt->chcfg & CHAN_CTX_BRSTMODE_MASK) >> + CHAN_CTX_BRSTMODE_SHIFT, (chan_ctxt->chcfg & + CHAN_CTX_POLLCFG_MASK) >> CHAN_CTX_POLLCFG_SHIFT); + + seq_printf(m, " type: 0x%x event ring: %u", chan_ctxt->chtype, + chan_ctxt->erindex); + + seq_printf(m, " base: 0x%llx len: 0x%llx wp: 0x%llx", + chan_ctxt->rbase, chan_ctxt->rlen, chan_ctxt->wp); + + seq_printf(m, " local rp: 0x%llx local wp: 0x%llx db: 0x%llx\n", + (u64)ring->rp, (u64)ring->wp, + mhi_chan->db_cfg.db_val); + } + + return 0; +} + +static int mhi_device_info_show(struct device *dev, void *data) +{ + struct mhi_device *mhi_dev; + + if (dev->bus != &mhi_bus_type) + return 0; + + mhi_dev = to_mhi_device(dev); + + seq_printf((struct seq_file *)data, "%s: type: %s dev_wake: %u", + mhi_dev->name, mhi_dev->dev_type ? "Controller" : "Transfer", + mhi_dev->dev_wake); + + /* for transfer device types only */ + if (mhi_dev->dev_type == MHI_DEVICE_XFER) + seq_printf((struct seq_file *)data, " channels: %u(UL)/%u(DL)", + mhi_dev->ul_chan_id, mhi_dev->dl_chan_id); + + seq_puts((struct seq_file *)data, "\n"); + + return 0; +} + +static int mhi_debugfs_devices_show(struct seq_file *m, void *d) +{ + struct mhi_controller *mhi_cntrl = m->private; + + if (!mhi_is_active(mhi_cntrl)) { + seq_puts(m, "Device not ready\n"); + return -ENODEV; + } + + device_for_each_child(mhi_cntrl->cntrl_dev, m, mhi_device_info_show); + + return 0; +} + +static int mhi_debugfs_regdump_show(struct seq_file *m, void *d) +{ + struct mhi_controller *mhi_cntrl = m->private; + enum mhi_state state; + enum mhi_ee_type ee; + int i, ret = -EIO; + u32 val; + void __iomem *mhi_base = mhi_cntrl->regs; + void __iomem *bhi_base = mhi_cntrl->bhi; + void __iomem *bhie_base = mhi_cntrl->bhie; + void __iomem *wake_db = mhi_cntrl->wake_db; + struct { + const char *name; + int offset; + void __iomem *base; + } regs[] = { + { "MHI_REGLEN", MHIREGLEN, mhi_base}, + { "MHI_VER", MHIVER, mhi_base}, + { "MHI_CFG", MHICFG, mhi_base}, + { "MHI_CTRL", MHICTRL, mhi_base}, + { "MHI_STATUS", MHISTATUS, mhi_base}, + { "MHI_WAKE_DB", 0, wake_db}, + { "BHI_EXECENV", BHI_EXECENV, bhi_base}, + { "BHI_STATUS", BHI_STATUS, bhi_base}, + { "BHI_ERRCODE", BHI_ERRCODE, bhi_base}, + { "BHI_ERRDBG1", BHI_ERRDBG1, bhi_base}, + { "BHI_ERRDBG2", BHI_ERRDBG2, bhi_base}, + { "BHI_ERRDBG3", BHI_ERRDBG3, bhi_base}, + { "BHIE_TXVEC_DB", BHIE_TXVECDB_OFFS, bhie_base}, + { "BHIE_TXVEC_STATUS", BHIE_TXVECSTATUS_OFFS, bhie_base}, + { "BHIE_RXVEC_DB", BHIE_RXVECDB_OFFS, bhie_base}, + { "BHIE_RXVEC_STATUS", BHIE_RXVECSTATUS_OFFS, bhie_base}, + { NULL }, + }; + + if (!MHI_REG_ACCESS_VALID(mhi_cntrl->pm_state)) + return ret; + + seq_printf(m, "Host PM state: %s Device state: %s EE: %s\n", + to_mhi_pm_state_str(mhi_cntrl->pm_state), + TO_MHI_STATE_STR(mhi_cntrl->dev_state), + TO_MHI_EXEC_STR(mhi_cntrl->ee)); + + state = mhi_get_mhi_state(mhi_cntrl); + ee = mhi_get_exec_env(mhi_cntrl); + seq_printf(m, "Device EE: %s state: %s\n", TO_MHI_EXEC_STR(ee), + TO_MHI_STATE_STR(state)); + + for (i = 0; regs[i].name; i++) { + if (!regs[i].base) + continue; + ret = mhi_read_reg(mhi_cntrl, regs[i].base, regs[i].offset, + &val); + if (ret) + continue; + + seq_printf(m, "%s: 0x%x\n", regs[i].name, val); + } + + return 0; +} + +static int mhi_debugfs_device_wake_show(struct seq_file *m, void *d) +{ + struct mhi_controller *mhi_cntrl = m->private; + struct mhi_device *mhi_dev = mhi_cntrl->mhi_dev; + + if (!mhi_is_active(mhi_cntrl)) { + seq_puts(m, "Device not ready\n"); + return -ENODEV; + } + + seq_printf(m, + "Wake count: %d\n%s\n", mhi_dev->dev_wake, + "Usage: echo get/put > device_wake to vote/unvote for M0"); + + return 0; +} + +static ssize_t mhi_debugfs_device_wake_write(struct file *file, + const char __user *ubuf, + size_t count, loff_t *ppos) +{ + struct seq_file *m = file->private_data; + struct mhi_controller *mhi_cntrl = m->private; + struct mhi_device *mhi_dev = mhi_cntrl->mhi_dev; + char buf[16]; + int ret = -EINVAL; + + if (copy_from_user(&buf, ubuf, min_t(size_t, sizeof(buf) - 1, count))) + return -EFAULT; + + if (!strncmp(buf, "get", 3)) { + ret = mhi_device_get_sync(mhi_dev); + } else if (!strncmp(buf, "put", 3)) { + mhi_device_put(mhi_dev); + ret = 0; + } + + return ret ? ret : count; +} + +static int mhi_debugfs_timeout_ms_show(struct seq_file *m, void *d) +{ + struct mhi_controller *mhi_cntrl = m->private; + + seq_printf(m, "%u ms\n", mhi_cntrl->timeout_ms); + + return 0; +} + +static ssize_t mhi_debugfs_timeout_ms_write(struct file *file, + const char __user *ubuf, + size_t count, loff_t *ppos) +{ + struct seq_file *m = file->private_data; + struct mhi_controller *mhi_cntrl = m->private; + u32 timeout_ms; + + if (kstrtou32_from_user(ubuf, count, 0, &timeout_ms)) + return -EINVAL; + + mhi_cntrl->timeout_ms = timeout_ms; + + return count; +} + +static int mhi_debugfs_states_open(struct inode *inode, struct file *fp) +{ + return single_open(fp, mhi_debugfs_states_show, inode->i_private); +} + +static int mhi_debugfs_events_open(struct inode *inode, struct file *fp) +{ + return single_open(fp, mhi_debugfs_events_show, inode->i_private); +} + +static int mhi_debugfs_channels_open(struct inode *inode, struct file *fp) +{ + return single_open(fp, mhi_debugfs_channels_show, inode->i_private); +} + +static int mhi_debugfs_devices_open(struct inode *inode, struct file *fp) +{ + return single_open(fp, mhi_debugfs_devices_show, inode->i_private); +} + +static int mhi_debugfs_regdump_open(struct inode *inode, struct file *fp) +{ + return single_open(fp, mhi_debugfs_regdump_show, inode->i_private); +} + +static int mhi_debugfs_device_wake_open(struct inode *inode, struct file *fp) +{ + return single_open(fp, mhi_debugfs_device_wake_show, inode->i_private); +} + +static int mhi_debugfs_timeout_ms_open(struct inode *inode, struct file *fp) +{ + return single_open(fp, mhi_debugfs_timeout_ms_show, inode->i_private); +} + +static const struct file_operations debugfs_states_fops = { + .open = mhi_debugfs_states_open, + .release = single_release, + .read = seq_read, +}; + +static const struct file_operations debugfs_events_fops = { + .open = mhi_debugfs_events_open, + .release = single_release, + .read = seq_read, +}; + +static const struct file_operations debugfs_channels_fops = { + .open = mhi_debugfs_channels_open, + .release = single_release, + .read = seq_read, +}; + +static const struct file_operations debugfs_devices_fops = { + .open = mhi_debugfs_devices_open, + .release = single_release, + .read = seq_read, +}; + +static const struct file_operations debugfs_regdump_fops = { + .open = mhi_debugfs_regdump_open, + .release = single_release, + .read = seq_read, +}; + +static const struct file_operations debugfs_device_wake_fops = { + .open = mhi_debugfs_device_wake_open, + .write = mhi_debugfs_device_wake_write, + .release = single_release, + .read = seq_read, +}; + +static const struct file_operations debugfs_timeout_ms_fops = { + .open = mhi_debugfs_timeout_ms_open, + .write = mhi_debugfs_timeout_ms_write, + .release = single_release, + .read = seq_read, +}; + +static struct dentry *mhi_debugfs_root; + +void mhi_create_debugfs(struct mhi_controller *mhi_cntrl) +{ + mhi_cntrl->debugfs_dentry = + debugfs_create_dir(dev_name(mhi_cntrl->cntrl_dev), + mhi_debugfs_root); + + debugfs_create_file("states", 0444, mhi_cntrl->debugfs_dentry, + mhi_cntrl, &debugfs_states_fops); + debugfs_create_file("events", 0444, mhi_cntrl->debugfs_dentry, + mhi_cntrl, &debugfs_events_fops); + debugfs_create_file("channels", 0444, mhi_cntrl->debugfs_dentry, + mhi_cntrl, &debugfs_channels_fops); + debugfs_create_file("devices", 0444, mhi_cntrl->debugfs_dentry, + mhi_cntrl, &debugfs_devices_fops); + debugfs_create_file("regdump", 0444, mhi_cntrl->debugfs_dentry, + mhi_cntrl, &debugfs_regdump_fops); + debugfs_create_file("device_wake", 0644, mhi_cntrl->debugfs_dentry, + mhi_cntrl, &debugfs_device_wake_fops); + debugfs_create_file("timeout_ms", 0644, mhi_cntrl->debugfs_dentry, + mhi_cntrl, &debugfs_timeout_ms_fops); +} + +void mhi_destroy_debugfs(struct mhi_controller *mhi_cntrl) +{ + debugfs_remove_recursive(mhi_cntrl->debugfs_dentry); + mhi_cntrl->debugfs_dentry = NULL; +} + +void mhi_debugfs_init(void) +{ + mhi_debugfs_root = debugfs_create_dir(mhi_bus_type.name, NULL); +} + +void mhi_debugfs_exit(void) +{ + debugfs_remove_recursive(mhi_debugfs_root); +} diff --git a/drivers/bus/mhi/core/init.c b/drivers/bus/mhi/core/init.c index d23293876be8..61e5885a331a 100644 --- a/drivers/bus/mhi/core/init.c +++ b/drivers/bus/mhi/core/init.c @@ -4,6 +4,7 @@ * */ +#include #include #include #include @@ -915,6 +916,8 @@ int mhi_register_controller(struct mhi_controller *mhi_cntrl, mhi_cntrl->mhi_dev = mhi_dev; + mhi_create_debugfs(mhi_cntrl); + return 0; error_add_dev: @@ -937,6 +940,8 @@ void mhi_unregister_controller(struct mhi_controller *mhi_cntrl) struct mhi_chan *mhi_chan = mhi_cntrl->mhi_chan; unsigned int i; + mhi_destroy_debugfs(mhi_cntrl); + kfree(mhi_cntrl->mhi_cmd); kfree(mhi_cntrl->mhi_event); @@ -1300,11 +1305,13 @@ struct bus_type mhi_bus_type = { static int __init mhi_init(void) { + mhi_debugfs_init(); return bus_register(&mhi_bus_type); } static void __exit mhi_exit(void) { + mhi_debugfs_exit(); bus_unregister(&mhi_bus_type); } diff --git a/drivers/bus/mhi/core/internal.h b/drivers/bus/mhi/core/internal.h index 5a81a428c4aa..7989269ddd96 100644 --- a/drivers/bus/mhi/core/internal.h +++ b/drivers/bus/mhi/core/internal.h @@ -570,6 +570,30 @@ struct mhi_chan { /* Default MHI timeout */ #define MHI_TIMEOUT_MS (1000) +/* debugfs related functions */ +#ifdef CONFIG_MHI_BUS_DEBUG +void mhi_create_debugfs(struct mhi_controller *mhi_cntrl); +void mhi_destroy_debugfs(struct mhi_controller *mhi_cntrl); +void mhi_debugfs_init(void); +void mhi_debugfs_exit(void); +#else +static inline void mhi_create_debugfs(struct mhi_controller *mhi_cntrl) +{ +} + +static inline void mhi_destroy_debugfs(struct mhi_controller *mhi_cntrl) +{ +} + +static inline void mhi_debugfs_init(void) +{ +} + +static inline void mhi_debugfs_exit(void) +{ +} +#endif + struct mhi_device *mhi_alloc_device(struct mhi_controller *mhi_cntrl); int mhi_destroy_device(struct device *dev, void *data); diff --git a/include/linux/mhi.h b/include/linux/mhi.h index 008b8f6fa9ff..fb45a0ff9aa3 100644 --- a/include/linux/mhi.h +++ b/include/linux/mhi.h @@ -291,6 +291,7 @@ struct mhi_controller_config { * @cntrl_dev: Pointer to the struct device of physical bus acting as the MHI * controller (required) * @mhi_dev: MHI device instance for the controller + * @debugfs_dentry: MHI controller debugfs directory * @regs: Base address of MHI MMIO register space (required) * @bhi: Points to base of MHI BHI register space * @bhie: Points to base of MHI BHIe register space @@ -370,6 +371,7 @@ struct mhi_controller_config { struct mhi_controller { struct device *cntrl_dev; struct mhi_device *mhi_dev; + struct dentry *debugfs_dentry; void __iomem *regs; void __iomem *bhi; void __iomem *bhie; From patchwork Mon Sep 21 16:08:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manivannan Sadhasivam X-Patchwork-Id: 11790373 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 821B359D for ; Mon, 21 Sep 2020 16:11:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6537F20739 for ; Mon, 21 Sep 2020 16:11:18 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="c9k5iknw" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727423AbgIUQLR (ORCPT ); Mon, 21 Sep 2020 12:11:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57294 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727392AbgIUQLR (ORCPT ); Mon, 21 Sep 2020 12:11:17 -0400 Received: from mail-pf1-x441.google.com (mail-pf1-x441.google.com [IPv6:2607:f8b0:4864:20::441]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8241DC061755 for ; Mon, 21 Sep 2020 09:11:17 -0700 (PDT) Received: by mail-pf1-x441.google.com with SMTP id k13so9156505pfg.1 for ; Mon, 21 Sep 2020 09:11:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=t7YL/sHl4cdMau2Whx59EhUvH+vo5PeoHAXBaAy8cvg=; b=c9k5iknwn/GrvfZhHp/Cpu6YCcJXdHDwzCtsvNIeMggPw6QM4qtDbFjTX/idNoeTgs Qz36wKL7cbPFWNJC5qZqsJOuw9p+5AWvf9nWfJShJ2Bk+JnAd0synd9rRGFdER9xlC1K VUc+QVBcVbUnYm0hLzRLKRtEwFsou3y3vSTYSJuSNvaK9N0MSDfmGjhf3sMDdetKnw5n A/Q2u2AqUvE+dMmy2Ax6P9G0kGxkamoiPMPMRlFjDM/3Jv05a6XYUbFVgAD9alc+eaCz /VQnK5VrArNu5CPu1pkyXDShtglF2/5HIpX5ki3Yl9fXvTAkznABjJDGBzFSbmtPj7NA f8fg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=t7YL/sHl4cdMau2Whx59EhUvH+vo5PeoHAXBaAy8cvg=; b=a2uf6AsygrV2nw9t+lW7KlRdcUkTbhVRAavoM7cwbMqy3tMMGfx5CjvBguRZelTc19 gibBhe6EgbtVCc8aSAJFCGLGHIEYvL4Bs2Ar+p+tl6P0OWfjCj2QmiBAXMHEELac8H5l iCp7ZxEoC0SpkE6wZADqWy9O9ThZ7Nck5x2WYD+UcRqo1wNRjHmt2LoSuZyzGAql1UYC VlrwLX227RjfFEttZC5hbEjXhl8+1Gvv52ZQrhAfrrI4WRikRcuuNtwJiUmGtwye1YiJ adQ7KOQpQMp+n3RdnjKmonvY8PnubjdfS0RwL6+bLgWvtK+ChA0d33IcotrS9jbDqPWz 4zcA== X-Gm-Message-State: AOAM532AZFAEpm4BTvkAtC7WKUQXxYG9iInMIhPFt16EhVU8o9xiVoo7 ao8THmFfwdloZBp8ukQZGnYYtNgYRrmL X-Google-Smtp-Source: ABdhPJyadhhD+8e8EsAvuZXkGKlrm/WuwbkaudLPezjS5yYHOpdoX2rYBFyJ2Ze5WfIzhIHi+OLN9Q== X-Received: by 2002:a63:d242:: with SMTP id t2mr295254pgi.47.1600704676971; Mon, 21 Sep 2020 09:11:16 -0700 (PDT) Received: from Mani-XPS-13-9360.localdomain ([2409:4072:6d03:bd12:1004:2ccf:6900:b97]) by smtp.gmail.com with ESMTPSA id f4sm9204577pgr.68.2020.09.21.09.11.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Sep 2020 09:11:16 -0700 (PDT) From: Manivannan Sadhasivam To: gregkh@linuxfoundation.org Cc: hemantk@codeaurora.org, jhugo@codeaurora.org, bbhatt@codeaurora.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Manivannan Sadhasivam Subject: [PATCH 15/18] bus: mhi: core: Introduce sysfs entries for MHI Date: Mon, 21 Sep 2020 21:38:12 +0530 Message-Id: <20200921160815.28071-17-manivannan.sadhasivam@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200921160815.28071-1-manivannan.sadhasivam@linaro.org> References: <20200921160815.28071-1-manivannan.sadhasivam@linaro.org> Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org From: Bhaumik Bhatt Introduce sysfs entries to enable userspace clients the ability to read the serial number and the OEM PK Hash values obtained from BHI. OEMs need to read these device-specific hardware information values through userspace for factory testing purposes and cannot be exposed via degbufs as it may remain disabled for performance reasons. Also, update the documentation for ABI to include these entries. Signed-off-by: Bhaumik Bhatt Reviewed-by: Manivannan Sadhasivam Signed-off-by: Manivannan Sadhasivam --- Documentation/ABI/stable/sysfs-bus-mhi | 21 ++++++++++ MAINTAINERS | 1 + drivers/bus/mhi/core/init.c | 53 ++++++++++++++++++++++++++ 3 files changed, 75 insertions(+) create mode 100644 Documentation/ABI/stable/sysfs-bus-mhi diff --git a/Documentation/ABI/stable/sysfs-bus-mhi b/Documentation/ABI/stable/sysfs-bus-mhi new file mode 100644 index 000000000000..ecfe7662f8d0 --- /dev/null +++ b/Documentation/ABI/stable/sysfs-bus-mhi @@ -0,0 +1,21 @@ +What: /sys/bus/mhi/devices/.../serialnumber +Date: Sept 2020 +KernelVersion: 5.10 +Contact: Bhaumik Bhatt +Description: The file holds the serial number of the client device obtained + using a BHI (Boot Host Interface) register read after at least + one attempt to power up the device has been done. If read + without having the device power on at least once, the file will + read all 0's. +Users: Any userspace application or clients interested in device info. + +What: /sys/bus/mhi/devices/.../oem_pk_hash +Date: Sept 2020 +KernelVersion: 5.10 +Contact: Bhaumik Bhatt +Description: The file holds the OEM PK Hash value of the endpoint device + obtained using a BHI (Boot Host Interface) register read after + at least one attempt to power up the device has been done. If + read without having the device power on at least once, the file + will read all 0's. +Users: Any userspace application or clients interested in device info. diff --git a/MAINTAINERS b/MAINTAINERS index deaafb617361..11e7be9b9163 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -11323,6 +11323,7 @@ M: Hemant Kumar L: linux-arm-msm@vger.kernel.org S: Maintained T: git git://git.kernel.org/pub/scm/linux/kernel/git/mani/mhi.git +F: Documentation/ABI/stable/sysfs-bus-mhi F: Documentation/mhi/ F: drivers/bus/mhi/ F: include/linux/mhi.h diff --git a/drivers/bus/mhi/core/init.c b/drivers/bus/mhi/core/init.c index 61e5885a331a..1b4161eaf0d8 100644 --- a/drivers/bus/mhi/core/init.c +++ b/drivers/bus/mhi/core/init.c @@ -76,6 +76,56 @@ const char *to_mhi_pm_state_str(enum mhi_pm_state state) return mhi_pm_state_str[index]; } +static ssize_t serial_number_show(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + struct mhi_device *mhi_dev = to_mhi_device(dev); + struct mhi_controller *mhi_cntrl = mhi_dev->mhi_cntrl; + + return snprintf(buf, PAGE_SIZE, "Serial Number: %u\n", + mhi_cntrl->serial_number); +} +static DEVICE_ATTR_RO(serial_number); + +static ssize_t oem_pk_hash_show(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + struct mhi_device *mhi_dev = to_mhi_device(dev); + struct mhi_controller *mhi_cntrl = mhi_dev->mhi_cntrl; + int i, cnt = 0; + + for (i = 0; i < ARRAY_SIZE(mhi_cntrl->oem_pk_hash); i++) + cnt += snprintf(buf + cnt, PAGE_SIZE - cnt, + "OEMPKHASH[%d]: 0x%x\n", i, + mhi_cntrl->oem_pk_hash[i]); + + return cnt; +} +static DEVICE_ATTR_RO(oem_pk_hash); + +static struct attribute *mhi_sysfs_attrs[] = { + &dev_attr_serial_number.attr, + &dev_attr_oem_pk_hash.attr, + NULL, +}; + +static const struct attribute_group mhi_sysfs_group = { + .attrs = mhi_sysfs_attrs, +}; + +static int mhi_create_sysfs(struct mhi_controller *mhi_cntrl) +{ + return sysfs_create_group(&mhi_cntrl->mhi_dev->dev.kobj, + &mhi_sysfs_group); +} + +static void mhi_destroy_sysfs(struct mhi_controller *mhi_cntrl) +{ + sysfs_remove_group(&mhi_cntrl->mhi_dev->dev.kobj, &mhi_sysfs_group); +} + /* MHI protocol requires the transfer ring to be aligned with ring length */ static int mhi_alloc_aligned_ring(struct mhi_controller *mhi_cntrl, struct mhi_ring *ring, @@ -917,6 +967,8 @@ int mhi_register_controller(struct mhi_controller *mhi_cntrl, mhi_cntrl->mhi_dev = mhi_dev; mhi_create_debugfs(mhi_cntrl); + if (mhi_create_sysfs(mhi_cntrl)) + dev_err(mhi_cntrl->cntrl_dev, "Failed to create sysfs entries\n"); return 0; @@ -940,6 +992,7 @@ void mhi_unregister_controller(struct mhi_controller *mhi_cntrl) struct mhi_chan *mhi_chan = mhi_cntrl->mhi_chan; unsigned int i; + mhi_destroy_sysfs(mhi_cntrl); mhi_destroy_debugfs(mhi_cntrl); kfree(mhi_cntrl->mhi_cmd); From patchwork Mon Sep 21 16:08:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manivannan Sadhasivam X-Patchwork-Id: 11790375 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CF8B3139A for ; Mon, 21 Sep 2020 16:11:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A9A1720739 for ; Mon, 21 Sep 2020 16:11:26 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="OlOZByl6" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727956AbgIUQL0 (ORCPT ); Mon, 21 Sep 2020 12:11:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57318 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727392AbgIUQLZ (ORCPT ); Mon, 21 Sep 2020 12:11:25 -0400 Received: from mail-pg1-x544.google.com (mail-pg1-x544.google.com [IPv6:2607:f8b0:4864:20::544]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A1904C061755 for ; Mon, 21 Sep 2020 09:11:25 -0700 (PDT) Received: by mail-pg1-x544.google.com with SMTP id o25so4506378pgm.0 for ; Mon, 21 Sep 2020 09:11:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=W6u4t3Pbx0oHy8S60PgkiPGv5xHHohbjjHW48fCGizs=; b=OlOZByl6C6kArp5eQ9uN20JHij+N3zfzyM1G11l4zjnzvFQC9YfIzA2ZePN4r61Fmp 5UNCLzc8Afn4Fu2kQxjIeV1pUZeX6f7vm/4ZzJsrvrcQCS4JBVDThduFyXd/EyqIf8bm jvu8Gvr/1ZKOcNK+MC8IaeC84pcqO8jg7dsmi7pFaZ6N/BfvQ0x97ipg/a+A7QIwJOWv eWHby3cZdkWnlvAk40TBuvub+sKtGcr6zw71yyCiXNTcJ/S4hW9JifTgMBREnRkw7IfE p2z4JNLx9A2dGSlzn6XBfETy6MBYGRNkVHpxtLErwZmgj+bGWoDwM2GsGi4FKZX6gtEy l2+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=W6u4t3Pbx0oHy8S60PgkiPGv5xHHohbjjHW48fCGizs=; b=J3Qsbh89kqyto2Ga280qAf7hl9t45qPDoZ7r1HzhBr7dSfUkpY332nmpXO3bO7oLdY m+WA0PVmTYql1gpyDjxeksPIQFIrnkyIcu4UM8kLdI5ImcpyGHQ80UqMriobMWd8dqsA Fb+R75HQQeFUu0RTguYHMVDL1AdY+yrNCNrqgVbCmk2gOs1YVQj1763xqTwa0CjdRjB5 2Gp5lzcOIN32Yp8JWBxs9ERDxSMkMZ2ea4FqIR/3grQYy7OW3KDvWapfOJwrN6V2ebnU vGQkNXLlEO/JB9maYoxCdBw5qB9Yy8Wtp6WRu8fcpGA6H9Mkk1r/jVlT0lsePULywsq3 06Cg== X-Gm-Message-State: AOAM531luerYgRsSKwWWdjhvOVL8nThFUpALGz4ynbBuRpgLmYQhOk3f lH4byp+aA+D09e8m+z0WDTTS X-Google-Smtp-Source: ABdhPJxUV5ExId9rP2h82ljXLR9+5mzdOyCY2LmK38cQFKKn16nqUGgI/Rlvu0x/rRQ15sgSpNatZg== X-Received: by 2002:a17:902:c3d3:b029:d1:e5e7:c4da with SMTP id j19-20020a170902c3d3b02900d1e5e7c4damr704218plj.46.1600704685107; Mon, 21 Sep 2020 09:11:25 -0700 (PDT) Received: from Mani-XPS-13-9360.localdomain ([2409:4072:6d03:bd12:1004:2ccf:6900:b97]) by smtp.gmail.com with ESMTPSA id f4sm9204577pgr.68.2020.09.21.09.11.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Sep 2020 09:11:24 -0700 (PDT) From: Manivannan Sadhasivam To: gregkh@linuxfoundation.org Cc: hemantk@codeaurora.org, jhugo@codeaurora.org, bbhatt@codeaurora.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Loic Poulain , Manivannan Sadhasivam Subject: [PATCH 16/18] bus: mhi: core: Allow shared IRQ for event rings Date: Mon, 21 Sep 2020 21:38:13 +0530 Message-Id: <20200921160815.28071-18-manivannan.sadhasivam@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200921160815.28071-1-manivannan.sadhasivam@linaro.org> References: <20200921160815.28071-1-manivannan.sadhasivam@linaro.org> Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org From: Loic Poulain There is no requirement for using a dedicated IRQ per event ring. Some systems does not support multiple MSI vectors (e.g. intel without CONFIG_IRQ_REMAP), In that case the MHI controller can configure all the event rings to use the same interrupt (as fallback). Allow this by removing the nr_irqs = ev_ring test and add extra check in the irq_setup function. Signed-off-by: Loic Poulain Reviewed-by: Manivannan Sadhasivam Signed-off-by: Manivannan Sadhasivam --- drivers/bus/mhi/core/init.c | 7 +++++++ drivers/bus/mhi/core/pm.c | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/bus/mhi/core/init.c b/drivers/bus/mhi/core/init.c index 1b4161eaf0d8..049a10fa42d7 100644 --- a/drivers/bus/mhi/core/init.c +++ b/drivers/bus/mhi/core/init.c @@ -176,6 +176,13 @@ int mhi_init_irq_setup(struct mhi_controller *mhi_cntrl) if (mhi_event->offload_ev) continue; + if (mhi_event->irq >= mhi_cntrl->nr_irqs) { + dev_err(dev, "irq %d not available for event ring\n", + mhi_event->irq); + ret = -EINVAL; + goto error_request; + } + ret = request_irq(mhi_cntrl->irq[mhi_event->irq], mhi_irq_handler, IRQF_SHARED | IRQF_NO_SUSPEND, diff --git a/drivers/bus/mhi/core/pm.c b/drivers/bus/mhi/core/pm.c index ce4d969818b4..3de7b1639ec6 100644 --- a/drivers/bus/mhi/core/pm.c +++ b/drivers/bus/mhi/core/pm.c @@ -918,7 +918,7 @@ int mhi_async_power_up(struct mhi_controller *mhi_cntrl) dev_info(dev, "Requested to power ON\n"); - if (mhi_cntrl->nr_irqs < mhi_cntrl->total_ev_rings) + if (mhi_cntrl->nr_irqs < 1) return -EINVAL; /* Supply default wake routines if not provided by controller driver */ From patchwork Mon Sep 21 16:08:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manivannan Sadhasivam X-Patchwork-Id: 11790377 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 468D959D for ; Mon, 21 Sep 2020 16:11:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 20DF9206FB for ; Mon, 21 Sep 2020 16:11:34 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="VeKxncsL" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727720AbgIUQLd (ORCPT ); Mon, 21 Sep 2020 12:11:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57344 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727557AbgIUQLd (ORCPT ); Mon, 21 Sep 2020 12:11:33 -0400 Received: from mail-pg1-x544.google.com (mail-pg1-x544.google.com [IPv6:2607:f8b0:4864:20::544]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1FCD5C0613CF for ; Mon, 21 Sep 2020 09:11:33 -0700 (PDT) Received: by mail-pg1-x544.google.com with SMTP id 34so9439714pgo.13 for ; Mon, 21 Sep 2020 09:11:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=XoxjnAxcXSK+doGfZtwAsYYDHZgQmagtLGt6UeBmKRw=; b=VeKxncsL1VI/xZ1xbiiWNoLrums/HMt3vbur7JrZTdPqAodBaMgQ0m1q8kvyXQ3Qzk lLjWxYaykZvqQwWJ3oCrM07DpQ1Z12Yp5trlNKw3TGeiuy7aI3A9jVb/u0IuTrfIIKXq pkXXH4Mo8HCeBVZYVZM9k/MhJJVYJ/kUlnOQ1WrFsxM57AmQKOXFHhXVMRX1D8PxHJAw 1jSTH1np9g99Kc/HENcgrv8/osk/V9kLOPkldWOsCTm5izrBJo0AQJEzioXKqp4JKC4d CySgc900VaTLkpdLZkpcAaXFHIvMm4mNbiTYmqlXVAsxEqRSA2Lw1rWyKamgN71yAAeY QMbA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=XoxjnAxcXSK+doGfZtwAsYYDHZgQmagtLGt6UeBmKRw=; b=h/XjZSyiFOAe8lxiuD7iGOtmEViy2ChYjXAkBRwkJ8Qt5sK0f1UQ+hjDzqalhnxq80 kM2U+Qj9yK2+175fEe1TyfiaDBqBULIa2NdMdSccyNSu40Xicel1F+4G/Hc7GtnE75nh PDs2iDlKkVSIEgAu1HMR4xC6+F/UPgq00vLlslF/HVVpTKSqYTwwzFgd0gj9xKC0qsMP 5pt9TilbVf7edCkfchfrs2Dyaf3b4uWepWyf3/Ydk/sFtksDpQVsSnYXvCWGScCaojLb 4k2OcBkaN/n4fCxN9tSl0aDwg4cUS/jZR+PYM6IJuKYL7GwX/g7zPSRFxeiD/fjW2rpG QvKw== X-Gm-Message-State: AOAM530+7U4VpIgc2od4axcz58lHU1dKTxiR6FnJFqIZy3b3NNtGIG3T D6sz9w/dR6p5yL8esqlsrcxk X-Google-Smtp-Source: ABdhPJzqHcCGFdcUHtPcwks1H7hUGoxCU3aM/u+L4EjcGahZb7Sa2qHIK0kdwJnuCQbagDPA4D+9ew== X-Received: by 2002:a63:b47:: with SMTP id a7mr291507pgl.57.1600704692608; Mon, 21 Sep 2020 09:11:32 -0700 (PDT) Received: from Mani-XPS-13-9360.localdomain ([2409:4072:6d03:bd12:1004:2ccf:6900:b97]) by smtp.gmail.com with ESMTPSA id f4sm9204577pgr.68.2020.09.21.09.11.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Sep 2020 09:11:31 -0700 (PDT) From: Manivannan Sadhasivam To: gregkh@linuxfoundation.org Cc: hemantk@codeaurora.org, jhugo@codeaurora.org, bbhatt@codeaurora.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Loic Poulain , Manivannan Sadhasivam Subject: [PATCH 17/18] bus: mhi: Remove unused nr_irqs_req variable Date: Mon, 21 Sep 2020 21:38:14 +0530 Message-Id: <20200921160815.28071-19-manivannan.sadhasivam@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200921160815.28071-1-manivannan.sadhasivam@linaro.org> References: <20200921160815.28071-1-manivannan.sadhasivam@linaro.org> Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org From: Loic Poulain nr_irqs_req is unused in MHI stack. Signed-off-by: Loic Poulain Reviewed-by: Manivannan Sadhasivam Signed-off-by: Manivannan Sadhasivam --- drivers/bus/mhi/core/init.c | 3 --- include/linux/mhi.h | 2 -- 2 files changed, 5 deletions(-) diff --git a/drivers/bus/mhi/core/init.c b/drivers/bus/mhi/core/init.c index 049a10fa42d7..799111baceba 100644 --- a/drivers/bus/mhi/core/init.c +++ b/drivers/bus/mhi/core/init.c @@ -694,9 +694,6 @@ static int parse_ev_cfg(struct mhi_controller *mhi_cntrl, mhi_event++; } - /* We need IRQ for each event ring + additional one for BHI */ - mhi_cntrl->nr_irqs_req = mhi_cntrl->total_ev_rings + 1; - return 0; error_ev_cfg: diff --git a/include/linux/mhi.h b/include/linux/mhi.h index fb45a0ff9aa3..d4841e5a5f45 100644 --- a/include/linux/mhi.h +++ b/include/linux/mhi.h @@ -312,7 +312,6 @@ struct mhi_controller_config { * @total_ev_rings: Total # of event rings allocated * @hw_ev_rings: Number of hardware event rings * @sw_ev_rings: Number of software event rings - * @nr_irqs_req: Number of IRQs required to operate (optional) * @nr_irqs: Number of IRQ allocated by bus master (required) * @family_number: MHI controller family number * @device_number: MHI controller device number @@ -393,7 +392,6 @@ struct mhi_controller { u32 total_ev_rings; u32 hw_ev_rings; u32 sw_ev_rings; - u32 nr_irqs_req; u32 nr_irqs; u32 family_number; u32 device_number; From patchwork Mon Sep 21 16:08:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manivannan Sadhasivam X-Patchwork-Id: 11790379 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 381A9139A for ; Mon, 21 Sep 2020 16:11:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 169DD22262 for ; Mon, 21 Sep 2020 16:11:41 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="N2RvolYF" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728160AbgIUQLk (ORCPT ); Mon, 21 Sep 2020 12:11:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57362 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727174AbgIUQLk (ORCPT ); Mon, 21 Sep 2020 12:11:40 -0400 Received: from mail-pg1-x544.google.com (mail-pg1-x544.google.com [IPv6:2607:f8b0:4864:20::544]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1B298C061755 for ; Mon, 21 Sep 2020 09:11:40 -0700 (PDT) Received: by mail-pg1-x544.google.com with SMTP id o25so4507004pgm.0 for ; Mon, 21 Sep 2020 09:11:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=jN92Mz9LhRgMy6R9r5bCTsDXQ/6vWkXL7O/cDsot2BM=; b=N2RvolYFayc5fsOh1gJB3DMK8oIMyBLRgMfxg0FMJLL7xfLAZBP01+r5QYj+1GffUM 9BxtINmxg9fRU+P1ec6xIBuRVD0tqNgD2LTsF3vyOHR5mYyDOOjr01s0CP9v9JCMZGQF QA9oxgiD7HKR4dOk3wBA93ftpmen3Zowd7yd58R2TufsBRIds7Ij3caLJWNI6n66MFoJ MZhOZpDv6Ao0RNg6HFEfyLQE7V/MSJZxG+VeFCZwqLkpPp4lEIoMNmmSWpVZKDzg2J0O NZotg/bCnTmE06vbBS7PbT3MZfyvR2+uaptpqg4YwTRWBYv2lbwSW57Gq78Aaqo+1vu7 iQ9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=jN92Mz9LhRgMy6R9r5bCTsDXQ/6vWkXL7O/cDsot2BM=; b=FuieGG3qEf+5rfj4nQDvQOHSnVJlWMPM5wSYjXQKI8748a1oAVN8bcNXyN9MCHmrIl DV9CShQzP8q6mezBMATmdEOhB/CvIRY8BidLgaGWRk/GEGQ+nTQTiTIg34fUzOMMdOq1 X2oDiDbDCSqT5+1Onr8cJnx2GhHznO9Zr1ZTC2sdW040TKMha4C7KjNeQQInf+TfYO9e YeA94m/6NzdvPP8tXQC3TSLvMKRl0Bak5FBlGjH+GPgL2Ljdpwys+5dq4EukEu3R8/Qq UE4S41uryHLXTKQtL9eA7YSaBXfl0liAY2bz88fQTU/zGxpHXBCWeVep9QAZ5niLGbtK nvuQ== X-Gm-Message-State: AOAM531VcAgL9SBeg/j7A1Cb+xj13ONl78/w7m5P2hgyVl59P9D75XtS A93lxQm/tTQNw6s221AqIqI3 X-Google-Smtp-Source: ABdhPJw8SItFJiNDC55yGBHXRfsp10m1RmOM+ZPdNrLv6b91hudCqSZkRXGKp2kqd4I6H8Ssmr6RcA== X-Received: by 2002:a17:902:c394:b029:d2:4ca:2e22 with SMTP id g20-20020a170902c394b02900d204ca2e22mr621403plg.77.1600704699579; Mon, 21 Sep 2020 09:11:39 -0700 (PDT) Received: from Mani-XPS-13-9360.localdomain ([2409:4072:6d03:bd12:1004:2ccf:6900:b97]) by smtp.gmail.com with ESMTPSA id f4sm9204577pgr.68.2020.09.21.09.11.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Sep 2020 09:11:39 -0700 (PDT) From: Manivannan Sadhasivam To: gregkh@linuxfoundation.org Cc: hemantk@codeaurora.org, jhugo@codeaurora.org, bbhatt@codeaurora.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Manivannan Sadhasivam Subject: [PATCH 18/18] bus: mhi: core: Fix the building of MHI module Date: Mon, 21 Sep 2020 21:38:15 +0530 Message-Id: <20200921160815.28071-20-manivannan.sadhasivam@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200921160815.28071-1-manivannan.sadhasivam@linaro.org> References: <20200921160815.28071-1-manivannan.sadhasivam@linaro.org> Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org The Kbuild rule to build MHI should use the append operator. This fixes the below warning reported by Kbuild test bot. WARNING: modpost: missing MODULE_LICENSE() in drivers/bus/mhi/core/main.o WARNING: modpost: missing MODULE_LICENSE() in drivers/bus/mhi/core/pm.o WARNING: modpost: missing MODULE_LICENSE() in drivers/bus/mhi/core/boot.o Reported-by: kernel test robot Signed-off-by: Manivannan Sadhasivam --- drivers/bus/mhi/core/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/bus/mhi/core/Makefile b/drivers/bus/mhi/core/Makefile index 12c57ab3724c..c3feb4130aa3 100644 --- a/drivers/bus/mhi/core/Makefile +++ b/drivers/bus/mhi/core/Makefile @@ -1,4 +1,4 @@ -obj-$(CONFIG_MHI_BUS) := mhi.o +obj-$(CONFIG_MHI_BUS) += mhi.o mhi-y := init.o main.o pm.o boot.o mhi-$(CONFIG_MHI_BUS_DEBUG) += debugfs.o