From patchwork Mon Sep 28 04:09:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manivannan Sadhasivam X-Patchwork-Id: 11802789 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 E9E29618 for ; Mon, 28 Sep 2020 04:10:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C68AB23119 for ; Mon, 28 Sep 2020 04:10:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="Zsb4ex2+" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726504AbgI1EKf (ORCPT ); Mon, 28 Sep 2020 00:10:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57364 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725290AbgI1EKe (ORCPT ); Mon, 28 Sep 2020 00:10:34 -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 CF218C0613CE for ; Sun, 27 Sep 2020 21:10:34 -0700 (PDT) Received: by mail-pf1-x444.google.com with SMTP id k13so8170316pfg.1 for ; Sun, 27 Sep 2020 21: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=N1lX7l+McFM6cV+ssdxZ5AClsLBq3ozRzVIZ+mY0GZo=; b=Zsb4ex2+zDbadoDBlAJE+0lEop1QXXdIQXburj46gULleI+ODVb6gUDXw5lZPME3WP htU4xBZmkEuY85h0YBC11Eqej5iVA3KDybeo0Bijo3jkY5ZiYG8lUNchf15iW39oM9cf Q/cAVhVS8YhpDpOB5Bb0TTsNDXIDDNIkMkSMsUp7qwuTx0HWIuRs80ylOjSwH4nyYaqf Q7O3jCe3c6rXE+bFGG/QJ0SO3/PEYfrcQQEYqz/8H7I8TSbvgmB2ywAxBl+K8AbZcgua kTazgSkEe53N1Nq0+2P3Q/RPgdyF3fDk9PFXdpWM+XoIadxO5DCux4p6StaiY97kpDv3 ZxHg== 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=lLcrIEoiJI03dkm8u37+2N1p7NL/MypeyZiAjRTCRDJXX52YASQtZcqJWGXoDP6WIJ znE+v8mDqO55Wc86s1XH6573lhrRqEyMG8xYNA74xeo9FYeTP71RZKwrCvX8DIBXs9jS MqxnoK+FsHuT9x5CpOtQ+zcsZp/ZlKLACXUPFoYTJa6OVxTqWRv6mALrH6zQvoZWYtL5 E4uG6KWa9DfnPaY95a0Ch/VHYLXnsVvyZTwAsyNYhGkC+9m4ZQiyVUsmlhA0zjdc1z89 dNEBQLn71YgRyffnoFu5Op3/qor6q7V0/MoJ3VqyjSyKbD7dVDYMkzm/hHtMRbmQoaLV +v3w== X-Gm-Message-State: AOAM5327bwNwBnk5JhrYhLZTaAGq+rR6Q1oWwfArZMTknBECM1Rq+G5T eNM0sHhlgSAzKswB1uiQkKD7 X-Google-Smtp-Source: ABdhPJxzFdxTnbyAekcwlFMHPtG82khFWyb9XDbCbl4Xmfh6/f20JojZrbdL4AIrtxv/pyWU4mvlvA== X-Received: by 2002:aa7:9427:0:b029:142:2501:35df with SMTP id y7-20020aa794270000b0290142250135dfmr9138883pfo.63.1601266234299; Sun, 27 Sep 2020 21:10:34 -0700 (PDT) Received: from Mani-XPS-13-9360.localdomain ([2409:4072:6003:40df:7c40:5a87:eb86:87b0]) by smtp.gmail.com with ESMTPSA id n21sm8306322pgl.7.2020.09.27.21.10.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Sep 2020 21:10:33 -0700 (PDT) From: Manivannan Sadhasivam To: gregkh@linuxfoundation.org Cc: hemantk@codeaurora.org, bbhatt@codeaurora.org, linux-arm-msm@vger.kernel.org, jhugo@codeaurora.org, linux-kernel@vger.kernel.org, Randy Dunlap , Manivannan Sadhasivam Subject: [PATCH v2 01/21] bus: mhi: fix doubled words and struct image_info kernel-doc Date: Mon, 28 Sep 2020 09:39:31 +0530 Message-Id: <20200928040951.18207-2-manivannan.sadhasivam@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200928040951.18207-1-manivannan.sadhasivam@linaro.org> References: <20200928040951.18207-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 28 04:09:32 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manivannan Sadhasivam X-Patchwork-Id: 11802791 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 E098E618 for ; Mon, 28 Sep 2020 04:10:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C52F423119 for ; Mon, 28 Sep 2020 04:10:39 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="l9NBZSiz" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726634AbgI1EKj (ORCPT ); Mon, 28 Sep 2020 00:10:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57380 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726497AbgI1EKi (ORCPT ); Mon, 28 Sep 2020 00:10:38 -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 C2C76C0613CE for ; Sun, 27 Sep 2020 21:10:38 -0700 (PDT) Received: by mail-pf1-x442.google.com with SMTP id w7so8161876pfi.4 for ; Sun, 27 Sep 2020 21:10:38 -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=l9NBZSizfObRrViXEC9TUkn0DLL85baGs1fAd2GYZac/cUQKeJYNgmECMOFT7ij5Hm 8nPQ8Ja9gt9O/DjSV5JoTEQxPB0CJy5tZxZzaqQO0nBn4vbdfRhrAyY4o+95tBoMRoZ7 BiLQIK4npSydys54KduM+dlvInNX5XArLOrfh2e77/VGNTNlBC7IMypubWEqPjuf2Xdk DUztWXbnvllzMYnxMke8stQhAgXj70XpDPpWNSOaGtIryMa2aaeacW54Ma7YwPEv3CX1 gwlPaBpgBOzovig5K7nCwZWjwa0fVKvkiIYDzhDLh7mPkrNxBvJ9Y4OnT1k+qhw/OfgU j3SA== 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=YpavPxtVMP7ywpn+6NmJboxzqlL4c2C/A51JmxLyfr59nCsr9rqaJlPnOUB3QbTkEB YaqbS3JVMQO32iSAnzgRUP+4PZ1GKUAB0ISRIPqvnFIRcGSBZYkvGO28IeiVuZKUrOK0 rIHD8VPEgr2L8/4R1uQlNm18mG74HPW4u0Po1jO0LlpV60b1d49y/CT+TJxSAKTpCRPW FYpb4Ia5CoJAMUet0S9PCeU3HGPaQw0LRkXoAEWTG/pa00J/buNW2hBbqJD87cBBlKa+ EF4+V9R4e3UMcUVGKWoDrtHaE7IFyZ+vsxMRchkTHleo2+nfg3Xd4LHp1r0G4Jlo0IGy wjIA== X-Gm-Message-State: AOAM531cI8wDs1g7bZaghT/4BcMwxllaXtE9CJeL0vegqW7ku6q1PPoP TCQuqnsXIw23TYIf/q65t2+V X-Google-Smtp-Source: ABdhPJywSfq6jeasAfbCMyJ/sERK9m0CyYR1TyAuBxPiuq4t1TaJISYfDXw8ChBwyzeu7PJz1eAfQA== X-Received: by 2002:aa7:8c11:0:b029:151:b0bd:d607 with SMTP id c17-20020aa78c110000b0290151b0bdd607mr9254226pfd.76.1601266238184; Sun, 27 Sep 2020 21:10:38 -0700 (PDT) Received: from Mani-XPS-13-9360.localdomain ([2409:4072:6003:40df:7c40:5a87:eb86:87b0]) by smtp.gmail.com with ESMTPSA id n21sm8306322pgl.7.2020.09.27.21.10.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Sep 2020 21:10:37 -0700 (PDT) From: Manivannan Sadhasivam To: gregkh@linuxfoundation.org Cc: hemantk@codeaurora.org, bbhatt@codeaurora.org, linux-arm-msm@vger.kernel.org, jhugo@codeaurora.org, linux-kernel@vger.kernel.org, Manivannan Sadhasivam Subject: [PATCH v2 02/21] bus: mhi: core: Remove double occurrence for mhi_ctrl_ev_task() declaration Date: Mon, 28 Sep 2020 09:39:32 +0530 Message-Id: <20200928040951.18207-3-manivannan.sadhasivam@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200928040951.18207-1-manivannan.sadhasivam@linaro.org> References: <20200928040951.18207-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 28 04:09:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manivannan Sadhasivam X-Patchwork-Id: 11802793 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 284F7618 for ; Mon, 28 Sep 2020 04:10:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0BB6723998 for ; Mon, 28 Sep 2020 04:10:44 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="JCDThFoV" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726500AbgI1EKn (ORCPT ); Mon, 28 Sep 2020 00:10:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57394 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726485AbgI1EKm (ORCPT ); Mon, 28 Sep 2020 00:10:42 -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 D7A66C0613CE for ; Sun, 27 Sep 2020 21:10:42 -0700 (PDT) Received: by mail-pf1-x444.google.com with SMTP id x123so8156694pfc.7 for ; Sun, 27 Sep 2020 21:10:42 -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=JCDThFoVyxPd9b3A/1MW/Sdi6meq9xj57CE08UCY4B7qIAP8PyoiBYp16E8y1bVavg ubsag0KuY+KHZyOyrtjKToCvzVq2EoiZbd+r/hjdQaJdgH9a0rROl1L9Ct+rJLjyUxO9 fGAC5zZfP3cPNmvcfQEh2f22laEAEBUqRlt9ITfvhbHljYQ8NK+vFywAujHWkNY2dqES dKyj9xPsHrl8wlxVwnZjLirxYI947CjqiJBovKyoweHfGedtv0i+P5CAhsUW6RsMsIHp gIVD8T6an6PiMCu9riDspMnUL3G/1AUVNiMCCMLMzbHPY07rt7oyFQkdBV9FCDYg1NQc pOJg== 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=pNVePQwCvPY3nilTHK0xJxcOBS0q+1sv2H4cmVaNd8FY0HnUtJko+/+RnCwlVvUpCz uzYEhHRJbtdUDxb0zTXsB0Grwk1slLhEE/BXkBnD8LarY2JRr5ReuHULqnAVWlnJZ4ln K7tivac2XMZ/fipbBWNaEDEw/ZZt0gERCfxCpvlCO/pUFWjqBou6haeEnEFSrmrpPwA5 kPGouh2BXJf0ZPWwSuN8ClwdpkiuktRTmetaGp1SsgHWQMBMVv5pO7Mb5V+QHdlJhYeJ 9kGH6W7dwzpzo1Spd0TXsg2fXAQ96o9bE9pbjX26/43JrPug31WvWzvTQrQI0o3v+r6w vG4g== X-Gm-Message-State: AOAM533Y93gZBXrsqPeLgKKFd4ip1yCmwIstrKWcv/nkppqf8A4m8bPQ CTBuOr7LeeSuQsVkPDb73I43H1Xq4SOg X-Google-Smtp-Source: ABdhPJxVT1maMqXRa4scqbmEviqWptyut/JIa0Gzcefg59Q5HEIOuGXBzHyHjrmji/3Vw4wHPkaYow== X-Received: by 2002:a17:902:9b89:b029:d2:42a6:88f with SMTP id y9-20020a1709029b89b02900d242a6088fmr9695952plp.71.1601266242364; Sun, 27 Sep 2020 21:10:42 -0700 (PDT) Received: from Mani-XPS-13-9360.localdomain ([2409:4072:6003:40df:7c40:5a87:eb86:87b0]) by smtp.gmail.com with ESMTPSA id n21sm8306322pgl.7.2020.09.27.21.10.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Sep 2020 21:10:41 -0700 (PDT) From: Manivannan Sadhasivam To: gregkh@linuxfoundation.org Cc: hemantk@codeaurora.org, bbhatt@codeaurora.org, linux-arm-msm@vger.kernel.org, jhugo@codeaurora.org, linux-kernel@vger.kernel.org, Manivannan Sadhasivam Subject: [PATCH v2 03/21] bus: mhi: core: Abort suspends due to outgoing pending packets Date: Mon, 28 Sep 2020 09:39:33 +0530 Message-Id: <20200928040951.18207-4-manivannan.sadhasivam@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200928040951.18207-1-manivannan.sadhasivam@linaro.org> References: <20200928040951.18207-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 28 04:09:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manivannan Sadhasivam X-Patchwork-Id: 11802795 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 95D26618 for ; Mon, 28 Sep 2020 04:10:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 770E223119 for ; Mon, 28 Sep 2020 04:10:48 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="P8HRw07s" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726547AbgI1EKs (ORCPT ); Mon, 28 Sep 2020 00:10:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57408 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726328AbgI1EKr (ORCPT ); Mon, 28 Sep 2020 00:10:47 -0400 Received: from mail-pg1-x543.google.com (mail-pg1-x543.google.com [IPv6:2607:f8b0:4864:20::543]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 74E20C0613CE for ; Sun, 27 Sep 2020 21:10:47 -0700 (PDT) Received: by mail-pg1-x543.google.com with SMTP id o25so7174137pgm.0 for ; Sun, 27 Sep 2020 21:10:47 -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=P8HRw07sM/afMTDqTerSbPH12CyAJVBdNySTeo7qRkYGnL6ijMSLXZXFqbRGD3GVLd R4u+KhahYem6mO7tN3APbLWhii7TzucUnXvMIiWMHPUXA7n+yn8t28ovDxp7L+As8GM7 umCcJk7HFVtFiYGEbO0RF2lKqkkUX+gGJTO65XmXY7OwU/UCHUZUB4sxMWzpBFiQJlnd zJKyPgS3b0LqATO6ENGhUrt+Y8PjEj4GdNrUlyv1lX1b5XgBtW8xbfQY+bbEjQCcLhHg V9SbIZYOfToKM/mINctKx8CuUBV49Y2epUqtf5/WYGmRkR/reTdDQlgk01vvpMLpLmFD zrUA== 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=g9fFLGMG5700crllmwrHzNiX/eKY4MRZcwSs97NpqX/AGtTEkVPAf4RiiZiqRpFVxq KDMtyWm+Mk6AP+ObVZkLsPxFwOTIGV5JzEg7nUphgeK9gnM03CM2NNqTbKgW6JvMBO7s fWem7jfXcDSbsW3fy1lumVMkhr+KbPfZfUhOVsWDw5fgtbZ4ilMAFlNRhov6M1ZaNKpL WxXmetaCRI4JEUEQvZbVJzBEpzc20D6WhCtwF+Y8UYMH+/DtxOqk0+EO43gTAAln+s/R CwuypIlnTnITAHDLCOXFI6d8blnDcTtuzJyawgVBbcTHM6WBKBMT75FQQPo40HPj6q6Z Za5g== X-Gm-Message-State: AOAM533GNT5wz9ty/3WelDG7O0zzgUV/wjqAxpUHwjpBUUNV0zhwEfJd HCCs8REd2BMnIwRO1pk/hRIyUPlg6Whd X-Google-Smtp-Source: ABdhPJzdQLTKEt73hgHQmPsSdxsd1n13ty38qmiVicOb0sJcK7PgLdoEPAuwCPqqfpm8LUKYUmcx2w== X-Received: by 2002:a63:4f10:: with SMTP id d16mr7486397pgb.152.1601266246973; Sun, 27 Sep 2020 21:10:46 -0700 (PDT) Received: from Mani-XPS-13-9360.localdomain ([2409:4072:6003:40df:7c40:5a87:eb86:87b0]) by smtp.gmail.com with ESMTPSA id n21sm8306322pgl.7.2020.09.27.21.10.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Sep 2020 21:10:45 -0700 (PDT) From: Manivannan Sadhasivam To: gregkh@linuxfoundation.org Cc: hemantk@codeaurora.org, bbhatt@codeaurora.org, linux-arm-msm@vger.kernel.org, jhugo@codeaurora.org, linux-kernel@vger.kernel.org, Manivannan Sadhasivam Subject: [PATCH v2 04/21] bus: mhi: core: Use helper API to trigger a non-blocking host resume Date: Mon, 28 Sep 2020 09:39:34 +0530 Message-Id: <20200928040951.18207-5-manivannan.sadhasivam@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200928040951.18207-1-manivannan.sadhasivam@linaro.org> References: <20200928040951.18207-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 28 04:09:35 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manivannan Sadhasivam X-Patchwork-Id: 11802797 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 94379139A for ; Mon, 28 Sep 2020 04:10:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7B1D5239A1 for ; Mon, 28 Sep 2020 04:10:52 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="uj70iwN7" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726595AbgI1EKv (ORCPT ); Mon, 28 Sep 2020 00:10:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57422 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726540AbgI1EKv (ORCPT ); Mon, 28 Sep 2020 00:10:51 -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 7A69BC0613CE for ; Sun, 27 Sep 2020 21:10:51 -0700 (PDT) Received: by mail-pf1-x444.google.com with SMTP id l126so8155659pfd.5 for ; Sun, 27 Sep 2020 21:10:51 -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=uj70iwN7Om8mBXDBHTyn3n9uBZav9OQBi2ibF4cPRnAJv1Fgmjp9d0PA6yKsUNCo8p Zml8+Jr/GHooh+CAQ62UnpDtJprVYnoQJvt9i/W9gvJMCjmg9Zgb8i1CgpZV78PNZgar p9F3oueAZEnQdSOBNtQjH0YdD1YAGs6JQcs/pcpqNcw3s2p+PWQGYROh2eMBgJDJ3Vu+ smGF3vvG+kv/tTi6lEoaGsKQ9h3dtE4Uj2JSDZ/FtYMFlblSPE0IhtSrCY8Bo98IBZad S05NDWDclJIxPKPpbKFojFRRfq10cLNTh6LD2Osnyck3cAGVwRKUPzKFFYjXImFN8dih /W/A== 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=mMbhpDX/n1Ykh5XqS+Hx/QctC+O8MxyZ2g22MQMJezj3HGA1H2idWSRSIGX+IHRvJ8 zlIU+CIf90CQ1JVs5QaNI9/oVlVJYBinP3TJXP5D+XH5m8i3HRLB9/xS5MWeJPGN1QCV hR4G38DwuNVIkZ7rYRlaEmDkQpe0tOVza2PhOziFKuSPydmb0+lBFsENNGmq/+NBT1Mr y0mC4jpt7JszKwpT6nIGrklLCcoYfux0+u9uZuHQ8TctvFetdR+NfZl1op4wLb/aCvc7 eqVorIkHm8ltVTEPBjDAo+UFg664ryXAyjuGcXd+5lsz1Rc7TQFNfverVUVhS0dPv+cy 1eCA== X-Gm-Message-State: AOAM5305z/iMM74UQYGzNxUWY2Vf7FckTHGnMsBi7087AP9L+Y8K2yL6 F/am8BjOTPMFi9H/mDCgiKH0 X-Google-Smtp-Source: ABdhPJymDsdfy18yONaUhpTsOEGUG1/Au6IP4UUUgdj7FzjnwfJppAc1PWzIrjCdRn1IjWFRxHaMgw== X-Received: by 2002:a63:e655:: with SMTP id p21mr7539114pgj.420.1601266250974; Sun, 27 Sep 2020 21:10:50 -0700 (PDT) Received: from Mani-XPS-13-9360.localdomain ([2409:4072:6003:40df:7c40:5a87:eb86:87b0]) by smtp.gmail.com with ESMTPSA id n21sm8306322pgl.7.2020.09.27.21.10.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Sep 2020 21:10:50 -0700 (PDT) From: Manivannan Sadhasivam To: gregkh@linuxfoundation.org Cc: hemantk@codeaurora.org, bbhatt@codeaurora.org, linux-arm-msm@vger.kernel.org, jhugo@codeaurora.org, linux-kernel@vger.kernel.org, Manivannan Sadhasivam Subject: [PATCH v2 05/21] bus: mhi: core: Trigger host resume if suspended during mhi_device_get() Date: Mon, 28 Sep 2020 09:39:35 +0530 Message-Id: <20200928040951.18207-6-manivannan.sadhasivam@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200928040951.18207-1-manivannan.sadhasivam@linaro.org> References: <20200928040951.18207-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 28 04:09:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manivannan Sadhasivam X-Patchwork-Id: 11802799 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 14895618 for ; Mon, 28 Sep 2020 04:10:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E7E3623998 for ; Mon, 28 Sep 2020 04:10:56 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="cmfJOFLt" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726683AbgI1EK4 (ORCPT ); Mon, 28 Sep 2020 00:10:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57438 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726420AbgI1EK4 (ORCPT ); Mon, 28 Sep 2020 00:10:56 -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 E597EC0613CE for ; Sun, 27 Sep 2020 21:10:55 -0700 (PDT) Received: by mail-pf1-x443.google.com with SMTP id d6so8136911pfn.9 for ; Sun, 27 Sep 2020 21:10:55 -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=cmfJOFLt+hXPrXXbkHEAXFz8nPhToOeufju7CxHnVqHyKI6uccDkriiAyaxm4sx3Bt 19rklAdbaApNUy9HqKXWq2l+r+DtreSXRqxb8RCmJH6BN1VcYXvK5C5H3/5DNTg0FrtW vAU4aYLkjDRN2jggi/MA89f4hsPu2eQQmWBFpkj13cY5SxUDJAqBdGBLKiPNko4PXZ0K 52rQEcJBcKpbU7l3Z05gU1Cm0j48C8IrnHzdGA3dj/WsggkuhB+WxL769OKC4Asm8Dqq cthbF/iREyQ3cDx8GpJ/1JthqKqZ3oWMr6/x2Y2CdPisqSOqB9T+dEj3RqHSiHJfCmSN FHVg== 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=BeeVrif1RN8PACKyGw8CtHmjxvAjQpcurQKweEXOpwWiAlzlkBjzNtOC322QvjGK7x C60K4uTcgyNBO96MG8MnNe8ZujY8nsz4YVJamiMowJ2kPHfGqxSEbvU7OUJjlEAfhem9 gm4k/XxuehGThRzspb1Gx2mRqcwNvCWgk8lBIITD5QxYgDmkqTBG9m0ZJHpsn1SwMrjM CvH/HOmj+mRaVtO4WGJwOtT5THnq8uc1ARb/oGRSLZPd/2qLCeCCiVsKrU+St7RnDolW nPKZuGTCbr3jMj6JwNDWarsyjW4AWKyoA5W6kVnLc1ZISSjdcAkxUgEEjbz65X9vqf61 3MLg== X-Gm-Message-State: AOAM531SAUfEFiatQvZqq+ftzCSHr8wDmK9tu80ltUDCQ17yhYbKx31b 5OeHRndt+3xHsdZ6CTVWwn59 X-Google-Smtp-Source: ABdhPJwW/soFnhyF/P0hV3/oRZBmnj1P9ecMyWs1Wql7Rw8q7XqXOL+ja0YP+SYfFqYb8CHJJpbcaw== X-Received: by 2002:a62:6dc3:0:b029:13c:1611:658d with SMTP id i186-20020a626dc30000b029013c1611658dmr8611001pfc.10.1601266255388; Sun, 27 Sep 2020 21:10:55 -0700 (PDT) Received: from Mani-XPS-13-9360.localdomain ([2409:4072:6003:40df:7c40:5a87:eb86:87b0]) by smtp.gmail.com with ESMTPSA id n21sm8306322pgl.7.2020.09.27.21.10.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Sep 2020 21:10:54 -0700 (PDT) From: Manivannan Sadhasivam To: gregkh@linuxfoundation.org Cc: hemantk@codeaurora.org, bbhatt@codeaurora.org, linux-arm-msm@vger.kernel.org, jhugo@codeaurora.org, linux-kernel@vger.kernel.org, Manivannan Sadhasivam Subject: [PATCH v2 06/21] bus: mhi: core: Use generic name field for an MHI device Date: Mon, 28 Sep 2020 09:39:36 +0530 Message-Id: <20200928040951.18207-7-manivannan.sadhasivam@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200928040951.18207-1-manivannan.sadhasivam@linaro.org> References: <20200928040951.18207-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 28 04:09:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manivannan Sadhasivam X-Patchwork-Id: 11802801 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 92E17139A for ; Mon, 28 Sep 2020 04:11:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7864D239E5 for ; Mon, 28 Sep 2020 04:11:01 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="QgP6YMRe" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726645AbgI1ELA (ORCPT ); Mon, 28 Sep 2020 00:11:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57452 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726603AbgI1EK7 (ORCPT ); Mon, 28 Sep 2020 00:10:59 -0400 Received: from mail-pg1-x542.google.com (mail-pg1-x542.google.com [IPv6:2607:f8b0:4864:20::542]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 93C07C0613CE for ; Sun, 27 Sep 2020 21:10:59 -0700 (PDT) Received: by mail-pg1-x542.google.com with SMTP id y14so7131143pgf.12 for ; Sun, 27 Sep 2020 21:10:59 -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=QgP6YMRe9W0moxUsSUcMTvkEySzzxbKPx4352s7GySLUMaQ3C2PecB4QuBMTKWZtxe eO4I2+/C0Z3OkOCRkeOv2sifn+et6uZmNBRPT6+GMJJLep26Fl/32aqUJi/PtXoE3ejO taAbWm9Y4EW9SWYIFCFiVkgcwifnvjWvvbbYG68nd+zmbFVmWIcrh1Ia9q3CMEv1tUie sCd9PQn2CQsWsgwVzxrzvXtgVWUsoB8vSOmn3adjPzc1f9CV3pRbNvk1UPjhJruR+DGy 4n23/rHhuiHsNrl7DpFRgg73FqYQDq6TBDS1oa78SZEWTw5sBttKnPc/xjlANYOAEFUe tTQQ== 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=sgiqoDCFJobWInqlT5/NxvwMbS3JCD68c5jE4CJmxhocZx3Du7dmMF9Bzlcxx/0uP4 veGuF6bRnTyXBrlE7RWN9NtV4s+XBJlpZQ+7GNRGkfrNYEzMElTqUVuk1FuRqNI706Ye UyZManyfl7t0kEccHxR9ZYI5toj3ggGe4hb10f/6OXe59U6bvi2Y9xSbt1SfA3dC6IF/ 96oulsSfq8v7Amm8U2ZbPNVyZfN5GIbnhDXoIVIwpaGH1IRBJTTDD+LawtoNJ8hktvTh 9qWJpWqk4FKDraIsAjd085mqvmi9vd6wdV8vgP4rrrS39RR6UagU5VpqW0E72B/au4dt IJyA== X-Gm-Message-State: AOAM530KK8YrYaQrXD+ZEpLjsukDPvM93RD/fcU/exDSRLXbULcJZqQP FsSxbhjjRZi9eczgC+D8iulU X-Google-Smtp-Source: ABdhPJwThe1gR/zeva+rBcg5zMxyuxLMlqYqCgfXcaiOxVpKx8M3wuVH8pPKNRFbnDqh0ILT8usJJg== X-Received: by 2002:a17:902:6803:b029:d2:42a6:312 with SMTP id h3-20020a1709026803b02900d242a60312mr9590562plk.24.1601266259136; Sun, 27 Sep 2020 21:10:59 -0700 (PDT) Received: from Mani-XPS-13-9360.localdomain ([2409:4072:6003:40df:7c40:5a87:eb86:87b0]) by smtp.gmail.com with ESMTPSA id n21sm8306322pgl.7.2020.09.27.21.10.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Sep 2020 21:10:58 -0700 (PDT) From: Manivannan Sadhasivam To: gregkh@linuxfoundation.org Cc: hemantk@codeaurora.org, bbhatt@codeaurora.org, linux-arm-msm@vger.kernel.org, jhugo@codeaurora.org, linux-kernel@vger.kernel.org, Manivannan Sadhasivam Subject: [PATCH v2 07/21] bus: mhi: core: Introduce helper function to check device state Date: Mon, 28 Sep 2020 09:39:37 +0530 Message-Id: <20200928040951.18207-8-manivannan.sadhasivam@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200928040951.18207-1-manivannan.sadhasivam@linaro.org> References: <20200928040951.18207-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 28 04:09:38 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manivannan Sadhasivam X-Patchwork-Id: 11802803 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 36AFF139A for ; Mon, 28 Sep 2020 04:11:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1B4BF23119 for ; Mon, 28 Sep 2020 04:11:06 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="m+tEeKFm" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726705AbgI1ELF (ORCPT ); Mon, 28 Sep 2020 00:11:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57466 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726702AbgI1ELD (ORCPT ); Mon, 28 Sep 2020 00:11:03 -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 3CE45C0613CF for ; Sun, 27 Sep 2020 21:11:03 -0700 (PDT) Received: by mail-pf1-x442.google.com with SMTP id o20so8132224pfp.11 for ; Sun, 27 Sep 2020 21:11: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=JMSzjnZoFPF6UWbIK88WIGtNwMDAVVwPEVBN0nLk6ZA=; b=m+tEeKFm0efkXSSMp4n1PbZzLbUsxFZzLuYHss7vX5TFP1/24DQszkvbNvNpi9XeHm oMo+94cNk1lPBpfaMlhbj1tUdwo28Tv4IUqa2Sgs7MENTrB0hAcRupdgDKrDKSkH/Lqq qLx3Q//EkqABDc+M6qoBw3msFhpy/VLo96X5WGHSKxygRrvFzCHleYpV4ekxQ/FaIc+r JlOIwt88P75Gn0OeodlPfAfBRt/D1pTggN3Ac3iXAzdvqQVMaCr/4E3fOzav8mTZC3nR Kn95D4tynpTuA+iYfkyCF+97YXlQ+ETkFw29fId4USazidqv84Z+ETRNqgLUDhuCNZPi 1brg== 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=XYga3QQzgaJE0DhXnqGtfmCAcCUJR7oasT4EkKN5pjObxO3toa53hkhcgHIzFEjxIh 9+iPjbRjcTjoBJJv7SL4D6rUZ5YZB3XWSKXhvbEH4/vgG2O+v0zApIsbj4v15PqsL2+C EaeMZlJANeHIiAwwS379rEkSI09Qx+970kB0heTziyQ9G2wMdr2f93cQRe/WQR/kGrDo ju02ofdluTCmUR4t19HpoTFbpfnr8LVgs6TlrQbaVxEAz2rVwRZwnJ2vzERUA/0MEEKX 6ezHYzdWn21uHuWn1QLpe7zz92cfGOUAwNVsOMImKHnQcJI/pgrWHnq21Ak6JpoZ0Vry RIAA== X-Gm-Message-State: AOAM531xhTTo7KvbZgoq+AaLzXzCts1PMh04FDo9AyFo5Tam+TymXY6E EhDdg1tTTWQtquLIbmBUcAU0 X-Google-Smtp-Source: ABdhPJwwKqwrVPktFn60oMw4LFMpJij3yFG0pFb+NIUkdFoTAa7Db/LFR7YwhBxxZIAt6CDtoQoPJQ== X-Received: by 2002:a17:902:146:b029:d2:5615:5700 with SMTP id 64-20020a1709020146b02900d256155700mr9286113plb.84.1601266262719; Sun, 27 Sep 2020 21:11:02 -0700 (PDT) Received: from Mani-XPS-13-9360.localdomain ([2409:4072:6003:40df:7c40:5a87:eb86:87b0]) by smtp.gmail.com with ESMTPSA id n21sm8306322pgl.7.2020.09.27.21.10.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Sep 2020 21:11:02 -0700 (PDT) From: Manivannan Sadhasivam To: gregkh@linuxfoundation.org Cc: hemantk@codeaurora.org, bbhatt@codeaurora.org, linux-arm-msm@vger.kernel.org, jhugo@codeaurora.org, linux-kernel@vger.kernel.org, Manivannan Sadhasivam Subject: [PATCH v2 08/21] bus: mhi: core: Introduce counters to track MHI device state transitions Date: Mon, 28 Sep 2020 09:39:38 +0530 Message-Id: <20200928040951.18207-9-manivannan.sadhasivam@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200928040951.18207-1-manivannan.sadhasivam@linaro.org> References: <20200928040951.18207-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 28 04:09:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manivannan Sadhasivam X-Patchwork-Id: 11802805 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 8B72E618 for ; Mon, 28 Sep 2020 04:11:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7259623998 for ; Mon, 28 Sep 2020 04:11:10 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="GWmJumpQ" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726558AbgI1ELJ (ORCPT ); Mon, 28 Sep 2020 00:11:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57482 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726615AbgI1ELH (ORCPT ); Mon, 28 Sep 2020 00:11:07 -0400 Received: from mail-pj1-x1044.google.com (mail-pj1-x1044.google.com [IPv6:2607:f8b0:4864:20::1044]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A8650C0613CF for ; Sun, 27 Sep 2020 21:11:07 -0700 (PDT) Received: by mail-pj1-x1044.google.com with SMTP id a9so2822991pjg.1 for ; Sun, 27 Sep 2020 21:11:07 -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=GWmJumpQNYDpkW+si2fcpKk90e7hbuTjKyNSdHcpiMp7cEBlXKXGhvmL/JJrTTBPR4 8lQckHiKQ3Io3UHTz9Gp3aeigNONs/l+P7+3pXxwYSbWNFAvoepYa7ZnSytuZKo9e7AU vz+l2KOOBr2hy0NE2PjXRaT1BydvQZGyo/klKGx0oL/ch6h6igLP7TtZg+XnnnFL/lkm 8ILMpZ7/3d6uKABUgk48/M5b4iGkEuPIKiq4r7gCxcJgGfrFyIL52QUKksYqt5Fp7u6I rnhbxcxXgxwq+tZwQqyrGjjwCu+a/DY3Iy0IVoetyWtn97nOddAZWHlEAHKZMezpBWnU KdsA== 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=BOPpWURKdx7F8CvrYcU4ZZaqWrCyAs/m7+FD8aXJjrQt+cBY+25NuxB9wcRdhz3tW4 jDHhjD4BHQ/yrhiJpDiGConxi8UUrXaAkDkg7iXn8LEYp6WkcGWrPw3HM8I7Q4d9rOXN aeD+5Y+ibo2CKm0BL1VL9wbIdKs17A9brAXrSObDDuBAHaTUpXiNjQWkTpJmw8QBzXTV 3tS6YNMbRglZLuSuoIy+KEpWgFDcBiiAZDyjjkrZSd3/RsrLM27vRaeVxAYIiFTOZzsb ASexdqFlcYgRGADgwQ22MEORVlZ5D9M6LSgQXHxqtMIx+9LphA3FujaGpiujpsgBd5zm YEHw== X-Gm-Message-State: AOAM533d0VUlYoPSlvGzkDbbRfzRAyY7ui2leLj7BX6xaONA5syI7VN5 /w7Y23V8hQFXMyWo0yW69Zca X-Google-Smtp-Source: ABdhPJx3Uzp+u6iVp2aTZdDvgZro+BN+JLXttA1Njr02Hi37JBxDdySbXYKvdzb0x1fOkjcTRLC0RQ== X-Received: by 2002:a17:90a:c705:: with SMTP id o5mr7853978pjt.68.1601266266730; Sun, 27 Sep 2020 21:11:06 -0700 (PDT) Received: from Mani-XPS-13-9360.localdomain ([2409:4072:6003:40df:7c40:5a87:eb86:87b0]) by smtp.gmail.com with ESMTPSA id n21sm8306322pgl.7.2020.09.27.21.11.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Sep 2020 21:11:06 -0700 (PDT) From: Manivannan Sadhasivam To: gregkh@linuxfoundation.org Cc: hemantk@codeaurora.org, bbhatt@codeaurora.org, linux-arm-msm@vger.kernel.org, jhugo@codeaurora.org, linux-kernel@vger.kernel.org, Manivannan Sadhasivam Subject: [PATCH v2 09/21] bus: mhi: core: Read and save device hardware information from BHI Date: Mon, 28 Sep 2020 09:39:39 +0530 Message-Id: <20200928040951.18207-10-manivannan.sadhasivam@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200928040951.18207-1-manivannan.sadhasivam@linaro.org> References: <20200928040951.18207-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 28 04:09:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manivannan Sadhasivam X-Patchwork-Id: 11802807 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 3E444139A for ; Mon, 28 Sep 2020 04:11:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2319423998 for ; Mon, 28 Sep 2020 04:11:15 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="wHCNDEXc" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726737AbgI1ELO (ORCPT ); Mon, 28 Sep 2020 00:11:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57496 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726632AbgI1ELM (ORCPT ); Mon, 28 Sep 2020 00:11:12 -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 DB8F0C0613CF for ; Sun, 27 Sep 2020 21:11:11 -0700 (PDT) Received: by mail-pj1-x1042.google.com with SMTP id u3so2782198pjr.3 for ; Sun, 27 Sep 2020 21:11:11 -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=wHCNDEXc26IQgoaQXav00ZFDq34qWtVx/rMNeAqTVCeEQn1jDIcUkssuKyMSFb8wo4 GZZRpP8R3cHqKa/q2KYfUViMTiKKMUv9ZJK4Nl6H21T7kxlVs8ttkwScVYayrODPge4Y dEqx5z7JKjxt74LTIEDXRN8M7JQZTU4GtEGB/36bTgx8AypwrYQTZHgu/z2aBbYHyqHE U/4A56vQo2uvOkXY+nEimuOvffYXp5uCP8+CVO86+72i2SEHCsB+OrhLmTONM6nLlgpv wD6REPCmvirZur2bejFhNC1ZDjzVdKQszHT0gS6I1zpERM6BSWKV2lyKe/ykVjAvYFF0 tksA== 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=mo0jKVTKPbza8bEH9A6PImuwYNQHf07d1WA+eDrw9vNRKAZ1o1AerLv7UL8dYYLhr1 F9Mjq/8Zfhcw1dLygk7NZSF/xaKi2p+eSl5L4RyY515PGouw/DrIdWwAbthgREV4q3nM +JVdB988eo1fdIHVo0cntWuIo4N2gehSbu74qnz7YLrKSJ1oTgCVuGr4Zk5j46o3BlzJ our07dRzw2xOnxoIK/cSY60R9naFz/jS6Ya70sTQxT8AEmx6GyEaq3aOtOp0tP4dRag5 VL5n7AHeCkWa0e9ZGnYZVqclBJwnhrvbQ6tUueCiVG6T4qBNAoPrpfcjpP3NPoaVbSxk Ef9A== X-Gm-Message-State: AOAM531XjH8akG+RFkvrapMjX6r4Aghe9O2Tlf7Cpw6uBtlCFnOuSMsX rMKsRGT+7kD+Ko492NrrnWXI X-Google-Smtp-Source: ABdhPJyLIm54o21Pm7IrO14eOqYhVc2i0HrUBOlquw1kD5bFIE3B3HsVxXDQe/GnwqNf7FM6T+1Ugg== X-Received: by 2002:a17:90b:693:: with SMTP id m19mr7496580pjz.111.1601266271389; Sun, 27 Sep 2020 21:11:11 -0700 (PDT) Received: from Mani-XPS-13-9360.localdomain ([2409:4072:6003:40df:7c40:5a87:eb86:87b0]) by smtp.gmail.com with ESMTPSA id n21sm8306322pgl.7.2020.09.27.21.11.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Sep 2020 21:11:10 -0700 (PDT) From: Manivannan Sadhasivam To: gregkh@linuxfoundation.org Cc: hemantk@codeaurora.org, bbhatt@codeaurora.org, linux-arm-msm@vger.kernel.org, jhugo@codeaurora.org, linux-kernel@vger.kernel.org, Manivannan Sadhasivam Subject: [PATCH v2 10/21] bus: mhi: core: Introduce APIs to allocate and free the MHI controller Date: Mon, 28 Sep 2020 09:39:40 +0530 Message-Id: <20200928040951.18207-11-manivannan.sadhasivam@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200928040951.18207-1-manivannan.sadhasivam@linaro.org> References: <20200928040951.18207-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 28 04:09:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manivannan Sadhasivam X-Patchwork-Id: 11802809 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 9FE7D618 for ; Mon, 28 Sep 2020 04:11:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 857AC23119 for ; Mon, 28 Sep 2020 04:11:19 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="rXH/AXxs" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726752AbgI1ELT (ORCPT ); Mon, 28 Sep 2020 00:11:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57508 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726736AbgI1ELQ (ORCPT ); Mon, 28 Sep 2020 00:11:16 -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 07D88C0613CE for ; Sun, 27 Sep 2020 21:11:16 -0700 (PDT) Received: by mail-pf1-x442.google.com with SMTP id k13so8171754pfg.1 for ; Sun, 27 Sep 2020 21:11: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=jNx5jfKYWZGFzKUONheqZrKSOvFz+O7hWeUKgyZ6/3A=; b=rXH/AXxsotOvE6H5ZL1ejX5HIo79s5TxkQkKEEJPSx5mYXQjE6GcLrArrrWubLylPC MBkxNfdVAJs/YssxxrOi9h235MtJVY2Pma+/Vy3QuotzklYNC1Rk7D/JelKr47nc4eoS 4h89AmskTIUZcCKV09rp7W39jE7RpUDS+UKneKvC51jK5SqXTxhU539ln7YhhcnDw10H zLYeYDa1kAFJGE6g4ezOr24gGlse7MKrrxxtxGq+6e4bGfcP0rYW841lQHygGksfDK2Q SqV2ncEnfGxw71j97dvpQoOPBqhvG7dQL4BON/Eio81mU38YWGH5FZC40o60HdXTfVHr BcoQ== 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=n5ZLOftSmPVPPk5rp9ILnQ7y2NKaHSEdkQ4sCWP0n2aqOlPaprAGUh8YQrg5lzTjYS 3EUOiNf2JapyoffrDulMOfb1Z7Txv372DyUvTEDgY/5ysA9jEJK+vKcuLn/U13tBGJtr J3Liwi7E2/FwczFsLmcCAlVNrh4VJTMHHmnZ+fE9FgcK0PO72uWu9tqYeivyEjzp7vE5 gLpKYJ2YBH99cvLgVTFK34ZMvII+X6QYaQj80Qo7BLDzum6yoYNMXDswaeLchbzFo/43 11nbfBsPAP8Sedl1SEIxIyd5q6Xz7lmMPryBMPQ4pSiVzqFuDoTS6hGGVgbmXvhHfjs/ EPwQ== X-Gm-Message-State: AOAM531EKYxOL4wPJv0FbhiWXPQ4u6J1iGnAySm9H3aefXHanAR4TD6+ 0wQD57mqJzaIsZYzF4TlcqDa X-Google-Smtp-Source: ABdhPJw7S0V7OPYrtp6V3QMvPbwcNpwIvSx3qX4Vt1Cvi2YF5ONPwVCdVL4Jrb1EXy4ws0u7eWs4Ng== X-Received: by 2002:aa7:96c7:0:b029:142:38cd:13de with SMTP id h7-20020aa796c70000b029014238cd13demr9100217pfq.66.1601266275512; Sun, 27 Sep 2020 21:11:15 -0700 (PDT) Received: from Mani-XPS-13-9360.localdomain ([2409:4072:6003:40df:7c40:5a87:eb86:87b0]) by smtp.gmail.com with ESMTPSA id n21sm8306322pgl.7.2020.09.27.21.11.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Sep 2020 21:11:14 -0700 (PDT) From: Manivannan Sadhasivam To: gregkh@linuxfoundation.org Cc: hemantk@codeaurora.org, bbhatt@codeaurora.org, linux-arm-msm@vger.kernel.org, jhugo@codeaurora.org, linux-kernel@vger.kernel.org, Manivannan Sadhasivam Subject: [PATCH v2 11/21] bus: mhi: core: Add const qualifier to MHI config information Date: Mon, 28 Sep 2020 09:39:41 +0530 Message-Id: <20200928040951.18207-12-manivannan.sadhasivam@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200928040951.18207-1-manivannan.sadhasivam@linaro.org> References: <20200928040951.18207-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 28 04:09:42 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manivannan Sadhasivam X-Patchwork-Id: 11802815 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 766D3139A for ; Mon, 28 Sep 2020 04:11:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5A36123998 for ; Mon, 28 Sep 2020 04:11:34 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="z24vRPeo" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726774AbgI1EL0 (ORCPT ); Mon, 28 Sep 2020 00:11:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57528 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726749AbgI1ELU (ORCPT ); Mon, 28 Sep 2020 00:11:20 -0400 Received: from mail-pg1-x543.google.com (mail-pg1-x543.google.com [IPv6:2607:f8b0:4864:20::543]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C3DFCC0613CF for ; Sun, 27 Sep 2020 21:11:20 -0700 (PDT) Received: by mail-pg1-x543.google.com with SMTP id g29so7172585pgl.2 for ; Sun, 27 Sep 2020 21:11:20 -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=z24vRPeoJKagqb/kdX+yCqnuSqIOxDDAS7o4YTJpieZQwOGxPov04sY6Kn9yJvo4yf Sgrsd2EugHoNLyaPk1EbmCpqRrr0ahacAraeQbkX2TQQuAwv+LoQd1k7s4ZcEnWmov5a 71cDsQCoeHFlPfO7TjxYaZPMSc++WjIIPcC2y4Qr8xLlTJI24C8NosyLBdVBf8RjUFIh RHqfghkXwwW450d7y9eE4MasGZbPYaQiYjicQD5+PDR5XLaVfKEd/snYE59Z7P1JCvkd K5XImZIrCN+CGrd7ZjP7qK3EUOzlna8Z2R0uHImoZLVc5+4D+6ogo/n7p+UsBaQYlp5T pMDQ== 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=LrpTNj07mfy/PKfMyxKUitRu/yajYAqVp5SYKQ3M+xWCvHGTbagyMpW6jPteCwuFm5 goh0D44GtZ4+pBzKxZtEr6SM0kVGtsEM6oE5b/k0AJfXuE1da6CadqSe7GxAjiJPjBoD CPr8ljxOVDjvCzOO0/tlhXizFPWvMN4gK19kgPMEuH5tKkBFFfO/V4Y2a/jK7IiqD8Rp 5eIJ9BC2aQ6WDwoYMDGTjrLf90reaMRGBjbiDFZFCDymRV7uPlnrjaYgKr+a8cGBsAPT oexxIu95GzY0JMHA9CUTvqYhZ0GQWd+L1EWl7/IDtPox79roK/tu+cX/RJ2tmXUxFduo J6/g== X-Gm-Message-State: AOAM531PrmuJCO6che5zBbgLpKQrzBwnHUyV6L2q//uQ87WJ/aR7pFxZ hOAWvIl/Jbf2dbh1x4QpwFyJ X-Google-Smtp-Source: ABdhPJw36czW94voSqKYm/WVdQlEmcDvKGs5RwDrCGhnli9+XXi1q/qHVYkZsB89q8v/X+zW0o6rTg== X-Received: by 2002:a63:eb09:: with SMTP id t9mr7461458pgh.182.1601266280320; Sun, 27 Sep 2020 21:11:20 -0700 (PDT) Received: from Mani-XPS-13-9360.localdomain ([2409:4072:6003:40df:7c40:5a87:eb86:87b0]) by smtp.gmail.com with ESMTPSA id n21sm8306322pgl.7.2020.09.27.21.11.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Sep 2020 21:11:19 -0700 (PDT) From: Manivannan Sadhasivam To: gregkh@linuxfoundation.org Cc: hemantk@codeaurora.org, bbhatt@codeaurora.org, linux-arm-msm@vger.kernel.org, jhugo@codeaurora.org, linux-kernel@vger.kernel.org, Clark Williams , Sebastian Andrzej Siewior , Manivannan Sadhasivam Subject: [PATCH v2 12/21] bus: mhi: Remove include of rwlock_types.h Date: Mon, 28 Sep 2020 09:39:42 +0530 Message-Id: <20200928040951.18207-13-manivannan.sadhasivam@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200928040951.18207-1-manivannan.sadhasivam@linaro.org> References: <20200928040951.18207-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 28 04:09:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manivannan Sadhasivam X-Patchwork-Id: 11802811 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 7CE53139A for ; Mon, 28 Sep 2020 04:11:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6200B23998 for ; Mon, 28 Sep 2020 04:11:26 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="AOeLHt/K" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726769AbgI1ELZ (ORCPT ); Mon, 28 Sep 2020 00:11:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57540 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726765AbgI1ELY (ORCPT ); Mon, 28 Sep 2020 00:11:24 -0400 Received: from mail-pg1-x543.google.com (mail-pg1-x543.google.com [IPv6:2607:f8b0:4864:20::543]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CB2CDC0613D3 for ; Sun, 27 Sep 2020 21:11:24 -0700 (PDT) Received: by mail-pg1-x543.google.com with SMTP id u24so7164943pgi.1 for ; Sun, 27 Sep 2020 21:11: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=+YUGt6aV7OP8RvUr5xgq7JykMZCPIUZje2/XDNY6QSI=; b=AOeLHt/KDm80VKiduR8Ny1aiS600MblMO8wr+UFAVtGy8ynNYhB6EqPpBWGvv2lg6r 5zPnMMi59qGXKVdR/N7PTEtgjwAzGEUEASaaMi/EjIjxcFNlaYH0K7UeKhN4wPeZQJrI ASKRXDJmUKlje8EiKsArwTef6qEqjbXvUXmfOFaFAa1kkluqew9WwfMJgq1rFXUPRsjI 0d//gNgWYfGFyTUNEN6OxG6I56N2CzLpi4u3aQyqcdmAammzoOWIvBO6QGTsMAtN8v3W mA1dmqf4p/ohWieRbTOaSIIgQ5D5QgBYJLqz45XovJCprwQFnPOfBml9VQTCV++B901O tAyw== 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=eo28TMWhfIHu8PkIiy7IfTT2WlRRi5WHxo14WGhaYe9DmZMF1TQ91nyAuiSClJsp9D ZrgAOI0JWpzP1MXl7hg0jimATtPf8Y5SAwCsT+92/rITo0YRqOqHDzI47zKOZRpR9e0D cszu5G9+s4ed5izyKzey8qHhI2yCzamWJ2Qm8LTe0nqV1VOWnaSLj+A+r9+QehrHTMr7 lXhJ9wyx3+n8jMzgKKbdbISwSXWYOe/2NpaGD63KfrKEyZqhSKxCARANPmfMIYZdGM4d JEpepzvmKm67nGO4mECn5pZBS+ffeMA4JYEQ8wXZ6VCLMgU3589hm30ziTWXpYu9hIBw BUSw== X-Gm-Message-State: AOAM531mKxJMcpcFGA7ViCN43DqKwGtxStT3qlwcla8Z4nADi0C07FgA YvtK7yFXZXT/7paB8/9jT/Re X-Google-Smtp-Source: ABdhPJy5NlcTy2vGgfZAtEyXp28882bTlk7+SZpb1IT19eAjj79KZzuV1VUbXyFmEt/KxYkYDEY5qw== X-Received: by 2002:a17:902:8493:b029:d2:42a6:238 with SMTP id c19-20020a1709028493b02900d242a60238mr9474319plo.4.1601266284258; Sun, 27 Sep 2020 21:11:24 -0700 (PDT) Received: from Mani-XPS-13-9360.localdomain ([2409:4072:6003:40df:7c40:5a87:eb86:87b0]) by smtp.gmail.com with ESMTPSA id n21sm8306322pgl.7.2020.09.27.21.11.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Sep 2020 21:11:23 -0700 (PDT) From: Manivannan Sadhasivam To: gregkh@linuxfoundation.org Cc: hemantk@codeaurora.org, bbhatt@codeaurora.org, linux-arm-msm@vger.kernel.org, jhugo@codeaurora.org, linux-kernel@vger.kernel.org, Manivannan Sadhasivam Subject: [PATCH v2 13/21] bus: mhi: Fix entries based on Kconfig coding style Date: Mon, 28 Sep 2020 09:39:43 +0530 Message-Id: <20200928040951.18207-14-manivannan.sadhasivam@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200928040951.18207-1-manivannan.sadhasivam@linaro.org> References: <20200928040951.18207-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 28 04:09:44 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manivannan Sadhasivam X-Patchwork-Id: 11802813 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 38AD7618 for ; Mon, 28 Sep 2020 04:11:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0C17723998 for ; Mon, 28 Sep 2020 04:11:34 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="ZyUhuJ7e" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726792AbgI1ELa (ORCPT ); Mon, 28 Sep 2020 00:11:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57554 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725308AbgI1EL3 (ORCPT ); Mon, 28 Sep 2020 00:11:29 -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 EDBE5C0613CE for ; Sun, 27 Sep 2020 21:11:28 -0700 (PDT) Received: by mail-pf1-x443.google.com with SMTP id w7so8163535pfi.4 for ; Sun, 27 Sep 2020 21:11:28 -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=mMw/Ksp0P1U2sI/VwrzNDLr3GW08so3zHnsJ9YYxsqo=; b=ZyUhuJ7eWrbdWHluu/6nEhtf+dC8j86Cn0K7oRlvM9XF8kfVlbgaZ09TwBic009DfB O4awMyS4lAdPT8e3aFr5g1mXuAnVYGiSHDsquVoil2prcY1BAN5MDUKm2XNbyCno4cH6 +bzraXmNzHPMSBJ3WciTaDUyA/GIQ40YL7ijDGnHWp2B2PWEOGmkEaCeOvqsXlINaZTf H1MOLKJsNCGhKxXIDjJy+2pB2TI8ENjDcqYJyMd89CTrqe49q2IHKQnXOpeP3SBXNQNm rimI7+79/UFHSJUYt7SsjIsOSVh7til9A8Fr5z4MAO6BO1f95aTrGuzcAvmmmdPxHYf/ xG8g== 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=mMw/Ksp0P1U2sI/VwrzNDLr3GW08so3zHnsJ9YYxsqo=; b=lp/J/Qf3A9AacPTDRtS9lHSnLoZl1NUMmCoK5l50oMvbNAT+nEnxorf+OHdlKc5mPE GtH+iGWe67qRCTXPtafVKF+pYM9P7qiMDIyCTcQN53Fit71gOEy6gJdN3Zm6dW20Dn5k vbIej5d3NJUrh+tFM8Zf3PGvl3J9O7kEl1MWax5pcPlJLVKO8wBal4Ljjlm7ZAUwli9a 3kZiUxPXXbaKeg8Pz8GIHNO+SKuyZ6A+ecmb15j4oTG56Q8Fs2n6N7X/JNBlQoJWuUi0 DzDGXjjviGazOtox4C0q+lRaalt3rY+HRRBFFyLeru4tPSPT2CCEDF/MNfqN4hfwAIVP +QOA== X-Gm-Message-State: AOAM530XI7Ji2LZolpU6BSPqZo/jZlzvQySpf+BAV+U1VB8Qc1Kx8GEs Hvl7m8La8vRwj9RBah81v91k X-Google-Smtp-Source: ABdhPJyyBuAFGrm2dlx3feFIEFDjTUW/Fy0dc/x82vSQqgw0w1uaKcX9y4NBj5RT5CGduxyHZKgcbQ== X-Received: by 2002:a62:178d:0:b029:13e:d13d:a0f8 with SMTP id 135-20020a62178d0000b029013ed13da0f8mr8576004pfx.20.1601266288325; Sun, 27 Sep 2020 21:11:28 -0700 (PDT) Received: from Mani-XPS-13-9360.localdomain ([2409:4072:6003:40df:7c40:5a87:eb86:87b0]) by smtp.gmail.com with ESMTPSA id n21sm8306322pgl.7.2020.09.27.21.11.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Sep 2020 21:11:27 -0700 (PDT) From: Manivannan Sadhasivam To: gregkh@linuxfoundation.org Cc: hemantk@codeaurora.org, bbhatt@codeaurora.org, linux-arm-msm@vger.kernel.org, jhugo@codeaurora.org, linux-kernel@vger.kernel.org, Manivannan Sadhasivam Subject: [PATCH v2 14/21] bus: mhi: core: Introduce debugfs entries for MHI Date: Mon, 28 Sep 2020 09:39:44 +0530 Message-Id: <20200928040951.18207-15-manivannan.sadhasivam@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200928040951.18207-1-manivannan.sadhasivam@linaro.org> References: <20200928040951.18207-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..f50d73054db4 --- /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%pK db: 0x%pad\n", 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%pK local wp: 0x%pK db: 0x%pad\n", + ring->rp, 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 28 04:09:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manivannan Sadhasivam X-Patchwork-Id: 11802817 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 900FC139A for ; Mon, 28 Sep 2020 04:11:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 73A1C23119 for ; Mon, 28 Sep 2020 04:11:37 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="sCrjJAvp" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726802AbgI1ELh (ORCPT ); Mon, 28 Sep 2020 00:11:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57570 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726763AbgI1ELd (ORCPT ); Mon, 28 Sep 2020 00:11:33 -0400 Received: from mail-pg1-x542.google.com (mail-pg1-x542.google.com [IPv6:2607:f8b0:4864:20::542]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EEDEBC0613CF for ; Sun, 27 Sep 2020 21:11:32 -0700 (PDT) Received: by mail-pg1-x542.google.com with SMTP id u24so7165235pgi.1 for ; Sun, 27 Sep 2020 21:11:32 -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=L3CU+DoqUHiRxVgJAceWJlznOoGillE+BlhtluWnPFM=; b=sCrjJAvp9cuBWp9Knm8maBWh7YqKBJfFuwLRunOz8FEIXENz/y9dpS8UQlKauHoh+R thVn5j9kq07sTfTyIxhPrsVE1mFDdMbj9hlFlpMOLnb1cqN+V3Ak+QNwWgVne7aQsAbz +d1h5l1lYsKfAo8B0j4Xf/5Ut+1haPzcrd/3tBnlqo5EsDoP0/GtEX0yJ9XKQUWWHjcS XPjRSQayrykVPX1XPUxNaYv1iNNUAkdMTESnrCompK7iRMRAWt0oPr54rsEtoPUQPVUf l5nVtLTXIOOLRae+TujUXL0BDNu7F/uUeekNLGNlPW+fcE1s6sI6abzlPLEse0tE5hG5 Ay3Q== 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=L3CU+DoqUHiRxVgJAceWJlznOoGillE+BlhtluWnPFM=; b=IWh7XrIz+1SpQMe5KS5bN4K3IB0rF6VesbFAJQRWDcjuONj6hioF66+VtMI8/NaixW shkzklpiVXfPYCSzGlEYcb2T3++JZUF0NMz2rahmzBsIwIA9+YPz7eBeQdqgX+RtqTRI FqeydjFaOjPzqegUJMP7OYZQl8aPYXMgpZAX9mlFT4FWKXPQN2eUoHWDptp4ekwU7K9j 7dnXpHdMICfcAIKVHqJ6Wu7CU0D0TpDw0p7tB7MtWrQjcJITKhSF5v1nvWUh+F/GJvDH C6o2O5HEQOJGldUXihnxQQfYbJpLxc+ip+Bm1nZgfWxJaChHpkuDjHKkoYWQjovAeWET 7GBA== X-Gm-Message-State: AOAM5318TBffn/k4Z1sLyt+mTfHvlb/cL30weGwBq1C6ye8NF3lzNm0K rThZh3bM5j8T3BtbeMG9xn5R X-Google-Smtp-Source: ABdhPJwk+6BQpg+mtpglgm7vcwRHPQ1c5HCB9Xx6Kv9UpY0C1y9RfGHALHrQyF8lO4ja1aF7U/CsAQ== X-Received: by 2002:a17:902:b949:b029:d2:8abd:c8ed with SMTP id h9-20020a170902b949b02900d28abdc8edmr2188859pls.63.1601266292412; Sun, 27 Sep 2020 21:11:32 -0700 (PDT) Received: from Mani-XPS-13-9360.localdomain ([2409:4072:6003:40df:7c40:5a87:eb86:87b0]) by smtp.gmail.com with ESMTPSA id n21sm8306322pgl.7.2020.09.27.21.11.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Sep 2020 21:11:31 -0700 (PDT) From: Manivannan Sadhasivam To: gregkh@linuxfoundation.org Cc: hemantk@codeaurora.org, bbhatt@codeaurora.org, linux-arm-msm@vger.kernel.org, jhugo@codeaurora.org, linux-kernel@vger.kernel.org, Manivannan Sadhasivam Subject: [PATCH v2 15/21] bus: mhi: core: Introduce sysfs entries for MHI Date: Mon, 28 Sep 2020 09:39:45 +0530 Message-Id: <20200928040951.18207-16-manivannan.sadhasivam@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200928040951.18207-1-manivannan.sadhasivam@linaro.org> References: <20200928040951.18207-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 [mani: used dev_groups to manage sysfs attributes] Signed-off-by: Manivannan Sadhasivam --- Documentation/ABI/stable/sysfs-bus-mhi | 21 +++++++++++++++ MAINTAINERS | 1 + drivers/bus/mhi/core/init.c | 37 ++++++++++++++++++++++++++ 3 files changed, 59 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..a33665b7ee54 100644 --- a/drivers/bus/mhi/core/init.c +++ b/drivers/bus/mhi/core/init.c @@ -76,6 +76,42 @@ 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_dev_attrs[] = { + &dev_attr_serial_number.attr, + &dev_attr_oem_pk_hash.attr, + NULL, +}; +ATTRIBUTE_GROUPS(mhi_dev); + /* 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, @@ -1301,6 +1337,7 @@ struct bus_type mhi_bus_type = { .dev_name = "mhi", .match = mhi_match, .uevent = mhi_uevent, + .dev_groups = mhi_dev_groups, }; static int __init mhi_init(void) From patchwork Mon Sep 28 04:09:46 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manivannan Sadhasivam X-Patchwork-Id: 11802819 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 5EE14618 for ; Mon, 28 Sep 2020 04:11:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3D79023998 for ; Mon, 28 Sep 2020 04:11:42 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="JOr0kWpv" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726469AbgI1ELi (ORCPT ); Mon, 28 Sep 2020 00:11:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57584 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726814AbgI1ELh (ORCPT ); Mon, 28 Sep 2020 00:11:37 -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 7565BC0613CF for ; Sun, 27 Sep 2020 21:11:37 -0700 (PDT) Received: by mail-pf1-x444.google.com with SMTP id o20so8133326pfp.11 for ; Sun, 27 Sep 2020 21:11:37 -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=I4sYG/yonx2Z4e3j5HjpsSaE/IQcEPtF5lwUAPBhXso=; b=JOr0kWpvxIwSipBfP+YmyZnOa9oYI+cAwTFhN44O7ZJQM/y0tSQJUF1aVfARGPQZR2 5NZniJyc6+NoQULJrmQ2zUL8mvo4Y/mm/bvVgXDz0GWjZ8KpL4aJulf9hIk0jvlL2WIA dDV7gBHIwF1fh6uUyHl+soeGv3f1qf0b8eOXwZF3/mfmtyCXCizlBZDy7ZkV0Hf3uMjN lzD4LBl1LNtPor4vBxp0dSJyii8rgXzz+NBL5BeBGGzopCDMkCxVmNQNi7+ceu7M2PFY 9VxdrR7Z5ajJyHRgKwr8fXcMaklFW0avudimSFXM2FArwo6HUKj61D/h1Ea8Zc+ID3oD Bd4Q== 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=I4sYG/yonx2Z4e3j5HjpsSaE/IQcEPtF5lwUAPBhXso=; b=saM4T2k4ZP2qbrrRB4FuiW7fktPMracFyry8bccauavi9vgEAtayc5v5yDJ5Uua8GP 6cOYNZ0TIdsc3ZqIOm9zzY1mlFf4MFocX220EYMIr4UR8ARJQXh6Zyqc8uxr/X2WuHBw dKFld9ov0CfAr+klZBhqf4SFPHm9XshYsCbuYKFjY/zLSjljqwN8IJlSIPeTzXIY54Qi 1C4DWkKtFF4vz2AOr4YA1DHPtUifGynAwiaBBJP9tNzeyM6db3A3c62U/0W2x218s65A 8KW8BIrwwHT0Anogl/7ECk2LZ1/6cj1o05ixMAyEtKwiSJDME8kFdA2+KmpdgG5mSWWU kauw== X-Gm-Message-State: AOAM532kflWiHhQP4ByBrTfkwRyhlEVn5Hg3I1eUylUW95bwiu34/oYi jC+oy81PI721kziuQhMr4n/t X-Google-Smtp-Source: ABdhPJwQm5agO+LBr1X5clx74u+gGn6503Q4nj3KvSBitxHdozj5fS0fGDl7TnwclaUDUNIoApwRDQ== X-Received: by 2002:a63:1a50:: with SMTP id a16mr7454288pgm.331.1601266296971; Sun, 27 Sep 2020 21:11:36 -0700 (PDT) Received: from Mani-XPS-13-9360.localdomain ([2409:4072:6003:40df:7c40:5a87:eb86:87b0]) by smtp.gmail.com with ESMTPSA id n21sm8306322pgl.7.2020.09.27.21.11.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Sep 2020 21:11:36 -0700 (PDT) From: Manivannan Sadhasivam To: gregkh@linuxfoundation.org Cc: hemantk@codeaurora.org, bbhatt@codeaurora.org, linux-arm-msm@vger.kernel.org, jhugo@codeaurora.org, linux-kernel@vger.kernel.org, Loic Poulain , Manivannan Sadhasivam Subject: [PATCH v2 16/21] bus: mhi: core: Allow shared IRQ for event rings Date: Mon, 28 Sep 2020 09:39:46 +0530 Message-Id: <20200928040951.18207-17-manivannan.sadhasivam@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200928040951.18207-1-manivannan.sadhasivam@linaro.org> References: <20200928040951.18207-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 a33665b7ee54..103d51f35e28 100644 --- a/drivers/bus/mhi/core/init.c +++ b/drivers/bus/mhi/core/init.c @@ -162,6 +162,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 28 04:09:47 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manivannan Sadhasivam X-Patchwork-Id: 11802821 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 335FD618 for ; Mon, 28 Sep 2020 04:11:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 13E21239A1 for ; Mon, 28 Sep 2020 04:11:46 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="FwfRqc2f" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726825AbgI1ELn (ORCPT ); Mon, 28 Sep 2020 00:11:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57600 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726600AbgI1ELm (ORCPT ); Mon, 28 Sep 2020 00:11:42 -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 16A9CC0613CF for ; Sun, 27 Sep 2020 21:11:42 -0700 (PDT) Received: by mail-pf1-x441.google.com with SMTP id z19so8140686pfn.8 for ; Sun, 27 Sep 2020 21:11:42 -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=d5NHMOfzoZtUI9mNkF0dRKXjszoqYK7ekBI5K8v9id0=; b=FwfRqc2fUQHMLsff4W9Dft9bi2yyvQYDrmzhkFpw/ePGL6JsK5V9BP8YcCCNn0fYrQ wbrH0hWZq/8XHqJAB92g+tPafACCwA7Qzr3FWZisvCLR9itF/CTRVEhN8kt4EkgvjfIA J2pigzAWswiWIdOiFcuaaSy5vCumaaeXIwRUwXgPu4xqkpG+ePlwtmdf/HM/e0h82fU+ p3E7kFTasvX84jakIGzFD0eymH0Y6zvCP2y3aKFu6ExHPkYUxshzzGptE2VkhJB2gu0H e9h4OsZBJTJy0qyR66wl8skGLTl3VleiwiSYeAkE8yFKM9ZizZO9M08DfGkw0KtRnFCD WODg== 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=d5NHMOfzoZtUI9mNkF0dRKXjszoqYK7ekBI5K8v9id0=; b=mu8BbL6Tswtdec+bpsqZFgpQ0XiE7rYvsL4DsXe5hy5SDqQy5n0LR4DGEVLIwnBQbb yutkxQYG9L7Tw77zkcVrW6BQOc01vj+wpABRgQm+/wrPbQaEHfFw+i5Qf4T/2XRiEs30 pVN6QJ1PqjXzazPN4iQKSkAGc3b0CmgME2UPFDpLD5qmsh3lD+SJgTPFN+usROloQ/TI dPRtEmUtsOE8NdFSFebyCGAmAva5Fy3nDHtTEBchyCsajW/3Pas1fLAGgpmGeOSPZoka zThZjoFJ764KgoIv83FoQzmL9z9TrnIRhYODInygnNG6ZCAKwWcTHlSu5a4/dP4hODI8 2Tfw== X-Gm-Message-State: AOAM532rRnSqBFfkXcrInJZoDdO16ggVadarWuHiqLgnkyr1wKM5YnJQ NkhqsyFZ+jrtc1+pvUshDyID X-Google-Smtp-Source: ABdhPJwBP30K9zmOpXBvNlFlCfq6/G/amVrj8J2SLRxb3vgucuwV1w2iD79cymQmb83qh4yZAMds1Q== X-Received: by 2002:a63:4945:: with SMTP id y5mr7423665pgk.181.1601266301533; Sun, 27 Sep 2020 21:11:41 -0700 (PDT) Received: from Mani-XPS-13-9360.localdomain ([2409:4072:6003:40df:7c40:5a87:eb86:87b0]) by smtp.gmail.com with ESMTPSA id n21sm8306322pgl.7.2020.09.27.21.11.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Sep 2020 21:11:40 -0700 (PDT) From: Manivannan Sadhasivam To: gregkh@linuxfoundation.org Cc: hemantk@codeaurora.org, bbhatt@codeaurora.org, linux-arm-msm@vger.kernel.org, jhugo@codeaurora.org, linux-kernel@vger.kernel.org, Loic Poulain , Manivannan Sadhasivam Subject: [PATCH v2 17/21] bus: mhi: Remove unused nr_irqs_req variable Date: Mon, 28 Sep 2020 09:39:47 +0530 Message-Id: <20200928040951.18207-18-manivannan.sadhasivam@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200928040951.18207-1-manivannan.sadhasivam@linaro.org> References: <20200928040951.18207-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 103d51f35e28..0ffdebde8265 100644 --- a/drivers/bus/mhi/core/init.c +++ b/drivers/bus/mhi/core/init.c @@ -680,9 +680,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 28 04:09:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manivannan Sadhasivam X-Patchwork-Id: 11802823 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 48D87618 for ; Mon, 28 Sep 2020 04:11:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2E00423119 for ; Mon, 28 Sep 2020 04:11:47 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="tn5Gy1gF" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726837AbgI1ELq (ORCPT ); Mon, 28 Sep 2020 00:11:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57614 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726573AbgI1ELq (ORCPT ); Mon, 28 Sep 2020 00:11:46 -0400 Received: from mail-pg1-x542.google.com (mail-pg1-x542.google.com [IPv6:2607:f8b0:4864:20::542]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3313AC0613D3 for ; Sun, 27 Sep 2020 21:11:46 -0700 (PDT) Received: by mail-pg1-x542.google.com with SMTP id o25so7176145pgm.0 for ; Sun, 27 Sep 2020 21:11: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=1xlErZ6+GH/dFW2F7UNH0x194BKPh+D1csCpYINewdA=; b=tn5Gy1gFVmYfYLIuDCmfddudD2JU00xcsk4peN4JygrM4xccWww+oN6ysrGdcUj7TF RpYOUWZuylGPv+kVXygncq0d8qwPYFK/3yePpzCR+/l6wOGx0rRhEuQVDw2NQjQpa0Gl QGMNyvd2Gd8KKChOyYkwsEqDG5A/E/otXZ/f6X+2beFCniZav+95yG4EPS+SRAYcpIpT 7zMFzSXToVQzbr4JHUZivPfdDLzNoAtBZOilpXHj/e0AcHIVCTpmTBw/6J8QdfxgDhcT UnTs5nwbLC72Eq7qHRNvEGslHXbfJ0EC5TxdutACDPX8BmhPkecGQkwVnDYSU7c6AHLw 7vXg== 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=1xlErZ6+GH/dFW2F7UNH0x194BKPh+D1csCpYINewdA=; b=YFXIfI26g+FaOb+N0ElP4i39rly1H6KTZK4WnvB7vVJORSm/t384DJmhgM/4ecvMcj IDZ6HfIVI0L+mC48Ygk0KDgt2j2VvAFf7uBZU8UvI12rsg9dfpl/Pkj1Di7cCuhd10nN 4V63pfuP/3Jy31HaUyOKvmz0Oz88jDEnV73b2EsiaNXq7T/kDxIMs8EZI9evdY1dYb0C TUVg9TkjbqOyBZybPNfQWTxlcS2QrS01LN22Hc19fkA8s9a6KJWG+N7NalY0qD3yRW5W RAFVP0SJqTs0bgcHh8VojcfFlIXBOvm0LGvT0rdXp/hV8vxmZCYRKnX8ab8A6eCikRML kL1g== X-Gm-Message-State: AOAM530C2uKxcSumcVlv3xPuOHoHEdxvfbFyRj+hzcRIAmNjNnHsi0pF /31o621fQvhTMIksOCxN9k07 X-Google-Smtp-Source: ABdhPJyVKvIqmNXeugpSqcZtt5LQm4ML6GlhjBWgWsCFlxQIqQ4TrwXr3l2UkvB5ConCHYvcopnVdA== X-Received: by 2002:a63:121d:: with SMTP id h29mr7390503pgl.285.1601266305646; Sun, 27 Sep 2020 21:11:45 -0700 (PDT) Received: from Mani-XPS-13-9360.localdomain ([2409:4072:6003:40df:7c40:5a87:eb86:87b0]) by smtp.gmail.com with ESMTPSA id n21sm8306322pgl.7.2020.09.27.21.11.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Sep 2020 21:11:45 -0700 (PDT) From: Manivannan Sadhasivam To: gregkh@linuxfoundation.org Cc: hemantk@codeaurora.org, bbhatt@codeaurora.org, linux-arm-msm@vger.kernel.org, jhugo@codeaurora.org, linux-kernel@vger.kernel.org, Manivannan Sadhasivam Subject: [PATCH v2 18/21] bus: mhi: core: Fix the building of MHI module Date: Mon, 28 Sep 2020 09:39:48 +0530 Message-Id: <20200928040951.18207-19-manivannan.sadhasivam@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200928040951.18207-1-manivannan.sadhasivam@linaro.org> References: <20200928040951.18207-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 Fixes: 0cbf260820fa ("bus: mhi: core: Add support for registering MHI controllers") 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 From patchwork Mon Sep 28 04:09:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manivannan Sadhasivam X-Patchwork-Id: 11802825 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 9D9E8618 for ; Mon, 28 Sep 2020 04:11:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 84CEA23A05 for ; Mon, 28 Sep 2020 04:11:51 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="EnGXoE45" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726564AbgI1ELu (ORCPT ); Mon, 28 Sep 2020 00:11:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57626 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726461AbgI1ELu (ORCPT ); Mon, 28 Sep 2020 00:11:50 -0400 Received: from mail-pj1-x1041.google.com (mail-pj1-x1041.google.com [IPv6:2607:f8b0:4864:20::1041]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6E10FC0613CF for ; Sun, 27 Sep 2020 21:11:50 -0700 (PDT) Received: by mail-pj1-x1041.google.com with SMTP id jw11so2787381pjb.0 for ; Sun, 27 Sep 2020 21:11: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=maouQTMrsxpLVka2tVtG0rlrDbgTOcw+DDAUcgByUy4=; b=EnGXoE45L2FBqA4SXbEjfeVSxc2ztg3wwOZ+fEZzRbUGKitcNafLTeyH2WkeYTDkW6 E2TJ+991gVG7P5Kgy8Gb5EOgKri0dIbX6WoNAFyoWs2yDYa795WIdwT4G4l4Q6RnU2Oo ISMqPoaEAjZwff0QW3YKriJHNCqcqr5kZfiM0b8UdnTtgNm3jJyVMv286TY0s+/xVGCj z0Ne254IIky1Kqvczz+Qlho3J1ST2Sy+VzzJdMV5ayg3wcJvGqpBWF3ajJRgu2LA1LRB s8WoNUtspSS8jrWcPwdD71v7J2lLpU/TZ381A0sNbSs2M6iDnXurVdgLwIOJr+4hWXkm eM6Q== 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=maouQTMrsxpLVka2tVtG0rlrDbgTOcw+DDAUcgByUy4=; b=ajL972gZceNX9QBK21kxfj+m5sbLhwWdwRlwzVpZGwMCCUDIEWsK0LDPyPTqqubpA/ 3UquQ4houlWJf2lrmxDxYPrtAzuwO9DJsEzA6uiprpwzXhN24eNNJHcY7Yy8RcRDW0nm N1r794INHUu20XVyARRA2AkTkbEilmHEUz7nJCBK8BX+w1horV7Tm9AuCVwl9dJjMbfZ gC7H2aWQ/TtboYNY3kVNBJqG6GxxWp/r3Bn6BVACIDrn7u27oofbF5w0mfwAyDfzBrI3 G738T3sjD06p8ykMiXmWeen7uoQAhpXBF+x9AyhX2hPaDGow7eaccAQbSYciSLpqjib4 uIzQ== X-Gm-Message-State: AOAM5330AlIFqq8cxf33Q8Kb80LnU65UzWGU9tTd5oROM4PP/z36+Msm L0CYL2uW5+4qISkCYTai4pSz X-Google-Smtp-Source: ABdhPJyNZWpa3JZqrcjoZjGCi1aIKKfaOSkrrDX84qOzktwQZaEOsv65o+NS1VwYYaPWvm0z4ZX2hw== X-Received: by 2002:a17:90a:b78b:: with SMTP id m11mr7788468pjr.13.1601266309959; Sun, 27 Sep 2020 21:11:49 -0700 (PDT) Received: from Mani-XPS-13-9360.localdomain ([2409:4072:6003:40df:7c40:5a87:eb86:87b0]) by smtp.gmail.com with ESMTPSA id n21sm8306322pgl.7.2020.09.27.21.11.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Sep 2020 21:11:49 -0700 (PDT) From: Manivannan Sadhasivam To: gregkh@linuxfoundation.org Cc: hemantk@codeaurora.org, bbhatt@codeaurora.org, linux-arm-msm@vger.kernel.org, jhugo@codeaurora.org, linux-kernel@vger.kernel.org, Loic Poulain , Manivannan Sadhasivam Subject: [PATCH v2 19/21] bus: mhi: debugfs: Print channel context read-pointer Date: Mon, 28 Sep 2020 09:39:49 +0530 Message-Id: <20200928040951.18207-20-manivannan.sadhasivam@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200928040951.18207-1-manivannan.sadhasivam@linaro.org> References: <20200928040951.18207-1-manivannan.sadhasivam@linaro.org> Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org From: Loic Poulain This value was missing in the channel debugfs output. Signed-off-by: Loic Poulain Reviewed-by: Manivannan Sadhasivam Signed-off-by: Manivannan Sadhasivam --- drivers/bus/mhi/core/debugfs.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/bus/mhi/core/debugfs.c b/drivers/bus/mhi/core/debugfs.c index f50d73054db4..3a48801e01f4 100644 --- a/drivers/bus/mhi/core/debugfs.c +++ b/drivers/bus/mhi/core/debugfs.c @@ -115,8 +115,9 @@ static int mhi_debugfs_channels_show(struct seq_file *m, void *d) 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, " base: 0x%llx len: 0x%llx rp: 0x%llx wp: 0x%llx", + chan_ctxt->rbase, chan_ctxt->rlen, chan_ctxt->rp, + chan_ctxt->wp); seq_printf(m, " local rp: 0x%pK local wp: 0x%pK db: 0x%pad\n", ring->rp, ring->wp, From patchwork Mon Sep 28 04:09:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manivannan Sadhasivam X-Patchwork-Id: 11802827 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 73A83139A for ; Mon, 28 Sep 2020 04:11:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 55D6F23998 for ; Mon, 28 Sep 2020 04:11:58 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="mtTcmXef" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726608AbgI1EL5 (ORCPT ); Mon, 28 Sep 2020 00:11:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57642 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726583AbgI1ELy (ORCPT ); Mon, 28 Sep 2020 00:11:54 -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 DABBCC0613CE for ; Sun, 27 Sep 2020 21:11:54 -0700 (PDT) Received: by mail-pf1-x443.google.com with SMTP id x123so8159172pfc.7 for ; Sun, 27 Sep 2020 21:11:54 -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=44pLa5JX2/SLNxroWCLNyZ+c2d/9HVL2NIevNA6RND8=; b=mtTcmXef4Uvo3bLkHQ8r9nDdPknQL7P7RwEO8wYXU7UDAd9jUz52gDmDZWN5Lf7gek mM+IyeoBjXNBy+CHlPewp/EBN2CoBq//gZtmE3/aWzYQVx6QG5PyDGdRu6DOjS4z2hkE HeZU8Vq89T3YLhCfFW9z2PzmBCQl7kxLgkq4j2xkDqvI2fizmDE7iUnAFtmvujGhxgap n2ycA+ZTaCwB/YkhrgE2+FtYlz5mBxaj4i8VI4igV9b8K93WIqRe9W9phXygGPMT5KJv D23Hlt9crKsRX8hkt/ZEQTsKfnYOvKNeym7vdK5YY9NUpnZq+hixmoa10RcyBAkC3Grv e1bA== 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=44pLa5JX2/SLNxroWCLNyZ+c2d/9HVL2NIevNA6RND8=; b=QJqLbo8VQj9noqmIGlqS/sx6oFEMXpzi+KIURlkyS6CxccrIPcgUq+D2nn3L1w4VLw Yq4AAHWpWpF37aa6LQGc+CavCSi68uxpEhtPh7fznpLsXjsNXvrbPusqh5u0xK4dytq0 iT90KOLJ/evUqMBkyIHWB1sN4pWbVkrCer58fVhX7P1iI01Ty8C8fFYDCzIRaBrcOsI9 QUseoSUkr3YFcOa3ih7zYHEVZ7VW0G/DROI3S/9KCwlT18z4ekXni7oyKiC0UA5l8WhS HobS+rlAT7rSWyeiIu/hBbth9atFNm9llv4PK6XPuKZDhFv03yghDxRGAILluyAB59r+ J1NA== X-Gm-Message-State: AOAM533z32lc0epDGT6MCRKwf7qVagngE4+///U027cclxGOgPluKK7E qtiok7zi+Jqc7GLrSkPVJIWU X-Google-Smtp-Source: ABdhPJyUer06dc+T7SHZCBbNnscJZFhuvmrBXx8UId6U7FpDXL2tkJTudSg8fAMefdyf9SZ+cvLzXQ== X-Received: by 2002:a62:5:0:b029:13e:d13d:a05a with SMTP id 5-20020a6200050000b029013ed13da05amr9173747pfa.32.1601266314368; Sun, 27 Sep 2020 21:11:54 -0700 (PDT) Received: from Mani-XPS-13-9360.localdomain ([2409:4072:6003:40df:7c40:5a87:eb86:87b0]) by smtp.gmail.com with ESMTPSA id n21sm8306322pgl.7.2020.09.27.21.11.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Sep 2020 21:11:53 -0700 (PDT) From: Manivannan Sadhasivam To: gregkh@linuxfoundation.org Cc: hemantk@codeaurora.org, bbhatt@codeaurora.org, linux-arm-msm@vger.kernel.org, jhugo@codeaurora.org, linux-kernel@vger.kernel.org, Loic Poulain , Manivannan Sadhasivam Subject: [PATCH v2 20/21] bus: mhi: Remove auto-start option Date: Mon, 28 Sep 2020 09:39:50 +0530 Message-Id: <20200928040951.18207-21-manivannan.sadhasivam@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200928040951.18207-1-manivannan.sadhasivam@linaro.org> References: <20200928040951.18207-1-manivannan.sadhasivam@linaro.org> Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org From: Loic Poulain There is really no point having an auto-start for channels. This is confusing for the device drivers, some have to enable the channels, others don't have... and waste resources (e.g. pre allocated buffers) that may never be used. This is really up to the MHI device(channel) driver to manage the state of its channels. Signed-off-by: Loic Poulain Reviewed-by: Manivannan Sadhasivam Signed-off-by: Manivannan Sadhasivam --- drivers/bus/mhi/core/init.c | 9 --------- drivers/bus/mhi/core/internal.h | 1 - include/linux/mhi.h | 2 -- 3 files changed, 12 deletions(-) diff --git a/drivers/bus/mhi/core/init.c b/drivers/bus/mhi/core/init.c index 0ffdebde8265..381fdea2eb9f 100644 --- a/drivers/bus/mhi/core/init.c +++ b/drivers/bus/mhi/core/init.c @@ -758,7 +758,6 @@ static int parse_ch_cfg(struct mhi_controller *mhi_cntrl, mhi_chan->offload_ch = ch_cfg->offload_channel; mhi_chan->db_cfg.reset_req = ch_cfg->doorbell_mode_switch; mhi_chan->pre_alloc = ch_cfg->auto_queue; - mhi_chan->auto_start = ch_cfg->auto_start; /* * If MHI host allocates buffers, then the channel direction @@ -1160,11 +1159,6 @@ static int mhi_driver_probe(struct device *dev) goto exit_probe; ul_chan->xfer_cb = mhi_drv->ul_xfer_cb; - if (ul_chan->auto_start) { - ret = mhi_prepare_channel(mhi_cntrl, ul_chan); - if (ret) - goto exit_probe; - } } ret = -EINVAL; @@ -1198,9 +1192,6 @@ static int mhi_driver_probe(struct device *dev) if (ret) goto exit_probe; - if (dl_chan && dl_chan->auto_start) - mhi_prepare_channel(mhi_cntrl, dl_chan); - mhi_device_put(mhi_dev); return ret; diff --git a/drivers/bus/mhi/core/internal.h b/drivers/bus/mhi/core/internal.h index 7989269ddd96..33c23203c531 100644 --- a/drivers/bus/mhi/core/internal.h +++ b/drivers/bus/mhi/core/internal.h @@ -563,7 +563,6 @@ struct mhi_chan { bool configured; bool offload_ch; bool pre_alloc; - bool auto_start; bool wake_capable; }; diff --git a/include/linux/mhi.h b/include/linux/mhi.h index d4841e5a5f45..6522a4adc794 100644 --- a/include/linux/mhi.h +++ b/include/linux/mhi.h @@ -214,7 +214,6 @@ enum mhi_db_brst_mode { * @offload_channel: The client manages the channel completely * @doorbell_mode_switch: Channel switches to doorbell mode on M0 transition * @auto_queue: Framework will automatically queue buffers for DL traffic - * @auto_start: Automatically start (open) this channel * @wake-capable: Channel capable of waking up the system */ struct mhi_channel_config { @@ -232,7 +231,6 @@ struct mhi_channel_config { bool offload_channel; bool doorbell_mode_switch; bool auto_queue; - bool auto_start; bool wake_capable; }; From patchwork Mon Sep 28 04:09:51 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manivannan Sadhasivam X-Patchwork-Id: 11802829 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 1504D139A for ; Mon, 28 Sep 2020 04:12:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EBFE023119 for ; Mon, 28 Sep 2020 04:12:03 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="qOFxpflt" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726854AbgI1EMA (ORCPT ); Mon, 28 Sep 2020 00:12:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57658 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726851AbgI1EL7 (ORCPT ); Mon, 28 Sep 2020 00:11:59 -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 01535C0613CF for ; Sun, 27 Sep 2020 21:11:59 -0700 (PDT) Received: by mail-pf1-x442.google.com with SMTP id b124so8124158pfg.13 for ; Sun, 27 Sep 2020 21:11:58 -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=2a29PGE7XTP2XdT1J2AnCKNgX28qIiZ+/+2Zu4a2uQE=; b=qOFxpfltv2nyxZI+cjYjiLOGvx57COZ5pGaozBuNzonXJA58pxLLqsZ0RISOH2s5GS GaK5dMQxciCryHZXnuyu6M5zTnJGCU6uagObzP/Vk1zvF1CLZ60xRiZFIO+0WJYMEq/l rNuVRex2pXu3fwdW8+7Ugk35Sn/KUcqbIpm68TzvPk7lprRfvw+tUHVrAZfAkAwOmtqM JtQ5PpCx2AtsA55yZ/AfdV/jCFxaEFcMbma2KO6of2DQ6Xz8MU3rsJWbrgPjLBgXGYos tl+0dODN6Wjb64XYq4e0yMD2hXJMHoCJ+E5Ls5UAE9ibM3apHT3S2W9deQxFpNzSrrUA HZ8Q== 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=2a29PGE7XTP2XdT1J2AnCKNgX28qIiZ+/+2Zu4a2uQE=; b=iemC3l27tSwhz0QcnB4qMusRfZlvq1p7QiO1ecbZzi8YS5C2QOs6A8Zi+XPslXa1l3 KgW3gZsfgngcoATXHcuSDlSQ29Ob2/QzgMJz3M3zW+E6vlyBlwcDPU07spFE5ZoUFngQ Le1dRNF8YFI399m4ylm4crsOMVxRUozS6NSbNYY64z4eW7AWyFOtHi1qX46yu5QZPlVZ /baUuWhF9vvdN1+rdfx5zVDm1iQcJ3Fi6DC2kBeOW4BGCpLqKcqw3r2d1K0TmPRyE8IH Jyi5KNRce1FsZzB0gfZxBN/NfZD8SmAsdw7QGZYLex1ZI0/ScA6lRTMjW5ReLlyUCgjV 0Jug== X-Gm-Message-State: AOAM533qxS5nPV6UV3ti0u5nRHwX4Zk6+qeYlH0Rh/7OvMIryRFgk7ot xoVOUj+doODwRtZELd2xdEG8 X-Google-Smtp-Source: ABdhPJylsw/GoIc/xNcMYtcp/205txCMbyEfgrjl5QkueXjuBpXxnUvZGQKXcR/6JdZU93fsfPUojg== X-Received: by 2002:a17:902:be09:b029:d2:83ee:dc2b with SMTP id r9-20020a170902be09b02900d283eedc2bmr5971464pls.20.1601266318524; Sun, 27 Sep 2020 21:11:58 -0700 (PDT) Received: from Mani-XPS-13-9360.localdomain ([2409:4072:6003:40df:7c40:5a87:eb86:87b0]) by smtp.gmail.com with ESMTPSA id n21sm8306322pgl.7.2020.09.27.21.11.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Sep 2020 21:11:57 -0700 (PDT) From: Manivannan Sadhasivam To: gregkh@linuxfoundation.org Cc: hemantk@codeaurora.org, bbhatt@codeaurora.org, linux-arm-msm@vger.kernel.org, jhugo@codeaurora.org, linux-kernel@vger.kernel.org, Loic Poulain , Manivannan Sadhasivam Subject: [PATCH v2 21/21] net: qrtr: Start MHI channels during init Date: Mon, 28 Sep 2020 09:39:51 +0530 Message-Id: <20200928040951.18207-22-manivannan.sadhasivam@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200928040951.18207-1-manivannan.sadhasivam@linaro.org> References: <20200928040951.18207-1-manivannan.sadhasivam@linaro.org> Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org From: Loic Poulain Start MHI device channels so that transfers can be performed. The MHI stack does not auto-start channels anymore. Signed-off-by: Loic Poulain Reviewed-by: Manivannan Sadhasivam Acked-by: David S. Miller Signed-off-by: Manivannan Sadhasivam --- net/qrtr/mhi.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/net/qrtr/mhi.c b/net/qrtr/mhi.c index ff0c41467fc1..7100f0bac4c6 100644 --- a/net/qrtr/mhi.c +++ b/net/qrtr/mhi.c @@ -76,6 +76,11 @@ static int qcom_mhi_qrtr_probe(struct mhi_device *mhi_dev, struct qrtr_mhi_dev *qdev; int rc; + /* start channels */ + rc = mhi_prepare_for_transfer(mhi_dev); + if (rc) + return rc; + qdev = devm_kzalloc(&mhi_dev->dev, sizeof(*qdev), GFP_KERNEL); if (!qdev) return -ENOMEM;