From patchwork Fri Jul 16 07:51:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manivannan Sadhasivam X-Patchwork-Id: 478362 Delivered-To: patch@linaro.org Received: by 2002:a02:c94a:0:0:0:0:0 with SMTP id u10csp1116372jao; Fri, 16 Jul 2021 00:51:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwnFoP7nkynihu0xVs8uKmP3FoB48k1gKlrMfmAltQpnJ4Buwtr21gAcSD3grQM5om9GUwm X-Received: by 2002:a17:907:d09:: with SMTP id gn9mr10439355ejc.447.1626421891320; Fri, 16 Jul 2021 00:51:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626421891; cv=none; d=google.com; s=arc-20160816; b=EAAuOMQ/m1fpA6uaTUrTsa5AxOP108dwo2Fb1L3uaCSKJGeyAmtC4XaLbAr2Yh5Dwx iY44mUcqnIVfRkxvrTYTG5RgNaZKjhvLaP3f4wivqlV6UjhhQSG35DuN8DDTJ5fS6Ef1 lVwAvOCAKMqCMTP3mx25RahTU/fArjKby8QC8iLuacdqhS2byV46HHYXwTc7YkcrKSlY Hg9aTv/nDW1dRSnKT5r+DtdcyD4KfDaQsS6x9XNc3jE9ltXRxCUCEDgBJ5zelfw1tujR K97kFYY30/PxQJMr6SbRier42SuraPyIJQ756zgi3LmO/UM/SnvGmNL3samspI2DvxfV EX3g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=3drlnqLci8b92FvhLSUmW1dM18kTxe4HZJWDZW845h8=; b=JeaFAV4oW/QVl7TV3AgzfxzNOorGGqj5rjIXUxPDL3S2yRT52ZEAViZTmeuq8JkGXj D7ra5n5a72YNwRVfqL6paewc4xXdjnEmoBsdyFAjQ18Tp5zqXbQeaQhlPcpjV8du3jXb Ovq5MQx0wLnofiWP+GRv42IRV8XyaZvE3vQGj6KGQ50Pwj9Es2rWlqdq7jiDa9+ocAz7 Ljnedv57kZUYmsY7PRoZf2EYmBAaynBJI0z9Ir0tduVebCgBtmKkqxvKZTH5FLQy0yFG R9n2EGTUNxUcrPd+1BG7wZrNA86UjcwqVNo8L5P+mUMYDi90tb2UD5fk3HQsUISguMoU usqQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Jdj9wk8b; spf=pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u22si5362084ejj.279.2021.07.16.00.51.30; Fri, 16 Jul 2021 00:51:31 -0700 (PDT) Received-SPF: pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Jdj9wk8b; spf=pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236704AbhGPHyX (ORCPT + 12 others); Fri, 16 Jul 2021 03:54:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35656 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236757AbhGPHyX (ORCPT ); Fri, 16 Jul 2021 03:54:23 -0400 Received: from mail-pl1-x633.google.com (mail-pl1-x633.google.com [IPv6:2607:f8b0:4864:20::633]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CF7C4C061762 for ; Fri, 16 Jul 2021 00:51:28 -0700 (PDT) Received: by mail-pl1-x633.google.com with SMTP id x16so4922613plg.3 for ; Fri, 16 Jul 2021 00:51: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 :mime-version:content-transfer-encoding; bh=3drlnqLci8b92FvhLSUmW1dM18kTxe4HZJWDZW845h8=; b=Jdj9wk8b2VbsBv1/xEpWv+SR/MxQH9P6VEjUfs0n1DxUpd3I6H1opD1dIAsBSKGSVu xeOJH1Sv4HM1ta6lO09VyrteUsmy7dEPpNojMlcaojxdmQHzd/0B1tIXYMylZaSpKyJG qwIjcStYGt/uy+esecFXWnHUPHhLf6Blk8XIZ4zW8qVPuGAq93kWcdm9zLP8GRPWNtMp BRJyhJKfPOZVd6Wj1WZ9iFF1qi6+LciVxiZyvOms6YJJ4Sj2EU8XNJKAynJAvOsB+9wl tcKqqCNgbhw4d3fe5qJiCH+2u9QHa3oksL1q5GwZw+9LVUnJ/jOBw8VeJOu6SJ/35v8E b7ig== 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:mime-version:content-transfer-encoding; bh=3drlnqLci8b92FvhLSUmW1dM18kTxe4HZJWDZW845h8=; b=o1Z+WyvOjhfgbYbflm1NF5PF9VoZoZ03mseI6JxcMblSD2N2KJWvRd7j3PZN+kuFTC LfTL3yuS7HmYKY2DbV/WNJjrCuP3NkEV8qPSJS6Ae6FWTtanBHvnBa0yUYECK2cqWaa9 liWgpqRSRc51aEH7m+Vycfw7l3CUxgWZ/SemUKxUNylEOU/i/BPdSyiv0GBIdsmBW7OT 9ZCs/6CC0DyTlWU6ZJIdbZEPfzlaQUeLbpw2NIBBNdpYKuEkgWwuu3l3WuFY6ZVVIG9K mblO0VPGiOCrri79imU8dZ9zT8vT+rOVFLcclRq8YClvuryLrSCrOCj+yKFSCUwCHoCZ Z4AA== X-Gm-Message-State: AOAM531tsOUO+TVYu/U75waC8WC9qSMzb4ZIoA9E68v89qa4/olDUN+S 4pY97fadlYs81Xv7T1PeS7/4 X-Received: by 2002:a17:90a:5204:: with SMTP id v4mr14324567pjh.147.1626421888238; Fri, 16 Jul 2021 00:51:28 -0700 (PDT) Received: from localhost.localdomain ([120.138.12.214]) by smtp.gmail.com with ESMTPSA id 21sm9253357pfp.211.2021.07.16.00.51.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Jul 2021 00:51: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, loic.poulain@linaro.org, stable@vger.kernel.org, Manivannan Sadhasivam Subject: [PATCH 1/3] bus: mhi: pci_generic: Apply no-op for wake using sideband wake boolean Date: Fri, 16 Jul 2021 13:21:04 +0530 Message-Id: <20210716075106.49938-2-manivannan.sadhasivam@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210716075106.49938-1-manivannan.sadhasivam@linaro.org> References: <20210716075106.49938-1-manivannan.sadhasivam@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Bhaumik Bhatt Devices such as SDX24 do not have the provision for inband wake doorbell in the form of channel 127 and instead have a sideband GPIO for it. Newer devices such as SDX55 or SDX65 support inband wake method by default. Ensure the functionality is used based on this such that device wake stays held when a client driver uses mhi_device_get() API or the equivalent debugfs entry. Cc: stable@vger.kernel.org #5.12 Fixes: e3e5e6508fc1 ("bus: mhi: pci_generic: No-Op for device_wake operations") Signed-off-by: Bhaumik Bhatt Reviewed-by: Manivannan Sadhasivam Link: https://lore.kernel.org/r/1624560809-30610-1-git-send-email-bbhatt@codeaurora.org Signed-off-by: Manivannan Sadhasivam --- drivers/bus/mhi/pci_generic.c | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) -- 2.25.1 diff --git a/drivers/bus/mhi/pci_generic.c b/drivers/bus/mhi/pci_generic.c index ca3bc40427f8..3396cb30ebec 100644 --- a/drivers/bus/mhi/pci_generic.c +++ b/drivers/bus/mhi/pci_generic.c @@ -32,6 +32,8 @@ * @edl: emergency download mode firmware path (if any) * @bar_num: PCI base address register to use for MHI MMIO register space * @dma_data_width: DMA transfer word size (32 or 64 bits) + * @sideband_wake: Devices using dedicated sideband GPIO for wakeup instead + * of inband wake support (such as sdx24) */ struct mhi_pci_dev_info { const struct mhi_controller_config *config; @@ -40,6 +42,7 @@ struct mhi_pci_dev_info { const char *edl; unsigned int bar_num; unsigned int dma_data_width; + bool sideband_wake; }; #define MHI_CHANNEL_CONFIG_UL(ch_num, ch_name, el_count, ev_ring) \ @@ -242,7 +245,8 @@ static const struct mhi_pci_dev_info mhi_qcom_sdx65_info = { .edl = "qcom/sdx65m/edl.mbn", .config = &modem_qcom_v1_mhiv_config, .bar_num = MHI_PCI_DEFAULT_BAR_NUM, - .dma_data_width = 32 + .dma_data_width = 32, + .sideband_wake = false, }; static const struct mhi_pci_dev_info mhi_qcom_sdx55_info = { @@ -251,7 +255,8 @@ static const struct mhi_pci_dev_info mhi_qcom_sdx55_info = { .edl = "qcom/sdx55m/edl.mbn", .config = &modem_qcom_v1_mhiv_config, .bar_num = MHI_PCI_DEFAULT_BAR_NUM, - .dma_data_width = 32 + .dma_data_width = 32, + .sideband_wake = false, }; static const struct mhi_pci_dev_info mhi_qcom_sdx24_info = { @@ -259,7 +264,8 @@ static const struct mhi_pci_dev_info mhi_qcom_sdx24_info = { .edl = "qcom/prog_firehose_sdx24.mbn", .config = &modem_qcom_v1_mhiv_config, .bar_num = MHI_PCI_DEFAULT_BAR_NUM, - .dma_data_width = 32 + .dma_data_width = 32, + .sideband_wake = true, }; static const struct mhi_channel_config mhi_quectel_em1xx_channels[] = { @@ -301,7 +307,8 @@ static const struct mhi_pci_dev_info mhi_quectel_em1xx_info = { .edl = "qcom/prog_firehose_sdx24.mbn", .config = &modem_quectel_em1xx_config, .bar_num = MHI_PCI_DEFAULT_BAR_NUM, - .dma_data_width = 32 + .dma_data_width = 32, + .sideband_wake = true, }; static const struct mhi_channel_config mhi_foxconn_sdx55_channels[] = { @@ -339,7 +346,8 @@ static const struct mhi_pci_dev_info mhi_foxconn_sdx55_info = { .edl = "qcom/sdx55m/edl.mbn", .config = &modem_foxconn_sdx55_config, .bar_num = MHI_PCI_DEFAULT_BAR_NUM, - .dma_data_width = 32 + .dma_data_width = 32, + .sideband_wake = false, }; static const struct pci_device_id mhi_pci_id_table[] = { @@ -640,9 +648,12 @@ static int mhi_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) mhi_cntrl->status_cb = mhi_pci_status_cb; mhi_cntrl->runtime_get = mhi_pci_runtime_get; mhi_cntrl->runtime_put = mhi_pci_runtime_put; - mhi_cntrl->wake_get = mhi_pci_wake_get_nop; - mhi_cntrl->wake_put = mhi_pci_wake_put_nop; - mhi_cntrl->wake_toggle = mhi_pci_wake_toggle_nop; + + if (info->sideband_wake) { + mhi_cntrl->wake_get = mhi_pci_wake_get_nop; + mhi_cntrl->wake_put = mhi_pci_wake_put_nop; + mhi_cntrl->wake_toggle = mhi_pci_wake_toggle_nop; + } err = mhi_pci_claim(mhi_cntrl, info->bar_num, DMA_BIT_MASK(info->dma_data_width)); if (err) From patchwork Fri Jul 16 07:51:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manivannan Sadhasivam X-Patchwork-Id: 478363 Delivered-To: patch@linaro.org Received: by 2002:a02:c94a:0:0:0:0:0 with SMTP id u10csp1116465jao; Fri, 16 Jul 2021 00:51:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz72upgdtcMdHqs/Wo0LDFuyoC+w/JW0UAdGTXEjLs7adaYv9FIzVDw8au1+MTJaKeui7Vi X-Received: by 2002:a05:6402:1b06:: with SMTP id by6mr12626530edb.95.1626421896866; Fri, 16 Jul 2021 00:51:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626421896; cv=none; d=google.com; s=arc-20160816; b=qQI7aJYOdiWHiv3Z+cuVyAU2UhDmvhsKaXMtk+iFphUMXqGMZuJuZGEfh6EbPhmtrC SVeU53CRKj7keO45fgC1BRq71qf7d3cLBK2sPc13QwIQryUXW0QG3XH+cz7NqaOD2O9C 2qesil2NXGBc8Tz4adYgcHKFeVga7k1DPjhAnFUX4wlxZQddMCuHr2/ZfsmZgAgq1fe9 Q6FuEFUtK7qHDUycz52fs0LZUx+7cgb4sJfZNlZFU8ECXHiCZ7jsocZ4Qy0smx1/5gxx HfMmXnYgBuUsiL30bVLAbRQLGo7BQOGqKP1/7W8DKxqG1tiVniYwvlbAH6IH5BXJxM/w mfoA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=7y1o6yqtjLQ46xl4Mz29qqqiixnPhzplTd0TzQ94aRg=; b=MnpoS+M46lCX2HmM79lyW1IYxPXLeaCfQdKJPBH4av0RaaF/0PG3adzIigRsvOcES+ 9pijazkKZd6LuSe7bbuHTv12V4EklyrtAZTf4aVFZgAzTyfuIOo/TJYWPh77PrRopdxG OjONHQgpAZQtJQ1dVDA+kTG/m0mQpTmawz3Tjz5WanCaE3MMvLfPWjj2J9Ry15cC4OGd sNVgjSdAn7ei9/eIshohXPAdMorJqPh/6b6rL1m1TdDqCG6mKxSicWwOY+w1pe+pjESx OfPLLhov+saTuvmVhXPvfxc12+wSswjMulGllezMZ5H0e7ejmcQUiBU3XW017BDNkqJy 4NAA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=tfpa7GBS; spf=pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u22si5362084ejj.279.2021.07.16.00.51.36; Fri, 16 Jul 2021 00:51:36 -0700 (PDT) Received-SPF: pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=tfpa7GBS; spf=pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236862AbhGPHy3 (ORCPT + 12 others); Fri, 16 Jul 2021 03:54:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35682 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236850AbhGPHy3 (ORCPT ); Fri, 16 Jul 2021 03:54:29 -0400 Received: from mail-pj1-x102c.google.com (mail-pj1-x102c.google.com [IPv6:2607:f8b0:4864:20::102c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5EFC9C061764 for ; Fri, 16 Jul 2021 00:51:33 -0700 (PDT) Received: by mail-pj1-x102c.google.com with SMTP id i16-20020a17090acf90b02901736d9d2218so6545924pju.1 for ; Fri, 16 Jul 2021 00:51:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=7y1o6yqtjLQ46xl4Mz29qqqiixnPhzplTd0TzQ94aRg=; b=tfpa7GBSViVK2gcM9PCAR1fkgHjvE6HDI85TLLUpapLIJ/DUKYyvZ30xL/g5+HZdSm QpcxwO8T1lDn6mRwdsOEBvVpFETyrkMrXIuevBi+wXjK3R4sB3bRcqX149B2IxlEzNcX 2FH7anYDx/vxVvMXMGsJTPjYKE7+wPpNOzPA3Cu8J72n/3X/muPfkCkmP56nZS+s2zvF DItFtkwKjB4rwKAAbI1jMSGK+Fpw2KY/jiWJoV9FKml6PbRN4VIBL3w/CxicA4IkbK9j U5FRtoTUVeNwnFnirhTR+ZVHa8jxbragi4URzMLp+qnb+UDKYSv2E8b2s/w32awe0yUz Pe6Q== 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:mime-version:content-transfer-encoding; bh=7y1o6yqtjLQ46xl4Mz29qqqiixnPhzplTd0TzQ94aRg=; b=keFn8usZ24V/3ngvmacm8OmTtUiJxiD9PdZCbzPAy/gHdB2glB6/BPzgYtrxufoVUY fPjvY00umKyOzQrGGeUpA/yHWTNuWzTbyH7gYnSAvkmjgecd3YOiEuLVqhqk9+LDjSnU HmqqC67QlaCDPCXhjUbvu9/AMfUBmWLAecg10AH93PksinXf5G6ZYk+0CooxucykZ4UJ /hCzhI0E4PPcSt/oj8MmT2WXSavbqJBPvP3c0Nggq8/lRAJr9Ob7cb2xnBu7fRxD3j80 h/+SstyE408xf4fgPuAKHCaPBD5qdpfguiK/HfT9A4O7q2+Uv/OyPrCxgCNNItKQ7T9p HJLw== X-Gm-Message-State: AOAM533V1sPi8ge4ILOWaAbfVy2MGh4v66GS/Q4EL6zrlL/ItDGOzSAm EFjoCKGDnm7LHhUQhPV42LI6 X-Received: by 2002:a17:902:ec06:b029:12b:55c9:3b51 with SMTP id l6-20020a170902ec06b029012b55c93b51mr6444777pld.4.1626421892881; Fri, 16 Jul 2021 00:51:32 -0700 (PDT) Received: from localhost.localdomain ([120.138.12.214]) by smtp.gmail.com with ESMTPSA id 21sm9253357pfp.211.2021.07.16.00.51.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Jul 2021 00:51:32 -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@linaro.org, stable@vger.kernel.org, Manivannan Sadhasivam , Jeffrey Hugo Subject: [PATCH 2/3] bus: mhi: core: Validate channel ID when processing command completions Date: Fri, 16 Jul 2021 13:21:05 +0530 Message-Id: <20210716075106.49938-3-manivannan.sadhasivam@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210716075106.49938-1-manivannan.sadhasivam@linaro.org> References: <20210716075106.49938-1-manivannan.sadhasivam@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Bhaumik Bhatt MHI reads the channel ID from the event ring element sent by the device which can be any value between 0 and 255. In order to prevent any out of bound accesses, add a check against the maximum number of channels supported by the controller and those channels not configured yet so as to skip processing of that event ring element. Cc: stable@vger.kernel.org #5.10 Fixes: 1d3173a3bae7 ("bus: mhi: core: Add support for processing events from client device") Signed-off-by: Bhaumik Bhatt Reviewed-by: Hemant Kumar Reviewed-by: Manivannan Sadhasivam Reviewed-by: Jeffrey Hugo Link: https://lore.kernel.org/r/1624558141-11045-1-git-send-email-bbhatt@codeaurora.org Signed-off-by: Manivannan Sadhasivam --- drivers/bus/mhi/core/main.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) -- 2.25.1 diff --git a/drivers/bus/mhi/core/main.c b/drivers/bus/mhi/core/main.c index 22acde118bc3..fc9196f11cb7 100644 --- a/drivers/bus/mhi/core/main.c +++ b/drivers/bus/mhi/core/main.c @@ -773,11 +773,18 @@ static void mhi_process_cmd_completion(struct mhi_controller *mhi_cntrl, cmd_pkt = mhi_to_virtual(mhi_ring, ptr); chan = MHI_TRE_GET_CMD_CHID(cmd_pkt); - mhi_chan = &mhi_cntrl->mhi_chan[chan]; - write_lock_bh(&mhi_chan->lock); - mhi_chan->ccs = MHI_TRE_GET_EV_CODE(tre); - complete(&mhi_chan->completion); - write_unlock_bh(&mhi_chan->lock); + + if (chan < mhi_cntrl->max_chan && + mhi_cntrl->mhi_chan[chan].configured) { + mhi_chan = &mhi_cntrl->mhi_chan[chan]; + write_lock_bh(&mhi_chan->lock); + mhi_chan->ccs = MHI_TRE_GET_EV_CODE(tre); + complete(&mhi_chan->completion); + write_unlock_bh(&mhi_chan->lock); + } else { + dev_err(&mhi_cntrl->mhi_dev->dev, + "Completion packet for invalid channel ID: %d\n", chan); + } mhi_del_ring_element(mhi_cntrl, mhi_ring); } From patchwork Fri Jul 16 07:51:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manivannan Sadhasivam X-Patchwork-Id: 478364 Delivered-To: patch@linaro.org Received: by 2002:a02:c94a:0:0:0:0:0 with SMTP id u10csp1116524jao; Fri, 16 Jul 2021 00:51:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyzNUA95MPjmFxjMxQ0EYaOMN+V+B/DpTZzUpUqpjQcKmTrV8VPT7yeWWfcteHTtreBh1+Y X-Received: by 2002:aa7:c9d8:: with SMTP id i24mr12925160edt.79.1626421900759; Fri, 16 Jul 2021 00:51:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626421900; cv=none; d=google.com; s=arc-20160816; b=EkNqUYZb65T7Sl/SjmHpCHyHf1l8MR5n80uzhuycejKfFFK0g8nA/gHkQgdMyNZ/c+ dvD3NCK8Z/tNeBV6SayziaG9xJe1k5Ltl8+IH8sDsZFp8R6zftKi2K1nOAoa7n00a12A 65NbAA+IXMiMK/VgLAzfkl0tMGotysy/EO2NP7EMXz3OO2p4U1udphwr1Gk4N8RIYxwg xURHEJRxoydaPkOjIHyVs7vfsfpkn4tCNXfEnusKtjIK1U/3ZFjnHnPyI1dh6u83q3Fu YSMHAbYE3IAeXvEtYAFaThtNmF4qihGp3N6MpsC3sc6QDZvgmrX6MWwMbQGjnyuclOTS 3aRg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=A5YTg0MnmWJbRIWQkegAwKJdKUa9X9i6zjHdjizNY+o=; b=BpUcx+YrqB7H+gb11Fr94lN0E9R6JKKaKDZag4oCc4I2H8HiKUcVfWh02bkasV5W/l G4aur/03qZlVdm43PyOSPxyrhE3oKwyS2pgWE8YQxO036DqzRJprZxcYd/XmxPiOhE1L 7ZFNdKbKOzaYkbOoM5NfFgt1CAiTVP9n2DBwFSBrhzYjDlQSN0zcxIdNOVNL6HQ2HHIL oDtVQQ2d21PigmCHCYvXLdiDECnTyh19IsagELrNwg+Q7cHFz5FYNN+DTFShT2V9uILA z1UULxvb34r/Ogi+s1rRrQ0AGCA5opcp2WrACOsWpTO39QFnKskOC8xYMQyAIyxHEiDJ aZZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Jc3SqWk2; spf=pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id du3si8183371ejc.406.2021.07.16.00.51.40; Fri, 16 Jul 2021 00:51:40 -0700 (PDT) Received-SPF: pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Jc3SqWk2; spf=pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236908AbhGPHyd (ORCPT + 12 others); Fri, 16 Jul 2021 03:54:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35704 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236450AbhGPHyc (ORCPT ); Fri, 16 Jul 2021 03:54:32 -0400 Received: from mail-pf1-x430.google.com (mail-pf1-x430.google.com [IPv6:2607:f8b0:4864:20::430]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D0EABC06175F for ; Fri, 16 Jul 2021 00:51:37 -0700 (PDT) Received: by mail-pf1-x430.google.com with SMTP id u126so513476pfb.8 for ; Fri, 16 Jul 2021 00:51: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 :mime-version:content-transfer-encoding; bh=A5YTg0MnmWJbRIWQkegAwKJdKUa9X9i6zjHdjizNY+o=; b=Jc3SqWk2rhU0EU8oc/KfB7YReeHkXS37Fzs+U9Pc5NXU3sEp+5NMNpROi/+0AP/wLZ M61GrRqFVq+A7BxmNH6XY8bZY0Fk7f9zwQZJ2S9ADp3ilmyM23I9UO9oDESd/OBREOhp ofraqRypc3xRe2gGaVijrhFZiwDPUanL/u+zFBzmuKZ6WMvRA85t6+YCOIuM/G++3UWK Wd84197KT81ZT608yNFy2VCJ5Yp6JnlLpeNLhfzDh3T9QIuYA2OYV+QH8E6xEt77EgPg W8QQ1b3+etohCmXNzUm8VduavoTdYaYNciKBm36EzC5TlJ3k/t4zY2OkGeSn9nodPGEQ CIoQ== 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:mime-version:content-transfer-encoding; bh=A5YTg0MnmWJbRIWQkegAwKJdKUa9X9i6zjHdjizNY+o=; b=NU88qczLX0gZr/jYdSi6BnDDlg2ckhr9uw9jkXQnzK3XZ1aiOqaUpCX+Y3tdDSilLh lBsr0Ao8lY+DL5875vn8EMY7wb7DHDfDFZIUFxpKzdqxrpSnkspZh7OaEOe/Vk8bDjtj uVDezsGYxdnp8cXWntus0TEgRNaB/mD19OzAfHJrLPYH3Ip6KRYjc2WP5a/11BfMlPfN pvh1X28GbOVFprQL6BHDO01bqA8zlIr2WLqlRiqhkYdnnuBQ6CENU1fDLPByJABLZxBj COPeyQwGPFYeYS+SY/s0IG4KjdtBsRKvJU4J2Pfk8Dsczdzbe9CxCqCLKY+ot3Gm+Dtp bGsA== X-Gm-Message-State: AOAM531yHm4ffG0wMOkFPsL6jfhH/1DmHOFnaSDVVtxYNvcRzySrX9zy Dj5pBtwxhHPtNtMQ7Ix8af9a X-Received: by 2002:aa7:95a4:0:b029:332:f4e1:1dac with SMTP id a4-20020aa795a40000b0290332f4e11dacmr8210346pfk.34.1626421897372; Fri, 16 Jul 2021 00:51:37 -0700 (PDT) Received: from localhost.localdomain ([120.138.12.214]) by smtp.gmail.com with ESMTPSA id 21sm9253357pfp.211.2021.07.16.00.51.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Jul 2021 00:51: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@linaro.org, stable@vger.kernel.org, Manivannan Sadhasivam , Manivannan Sadhasivam Subject: [PATCH 3/3] bus: mhi: pci_generic: Fix inbound IPCR channel Date: Fri, 16 Jul 2021 13:21:06 +0530 Message-Id: <20210716075106.49938-4-manivannan.sadhasivam@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210716075106.49938-1-manivannan.sadhasivam@linaro.org> References: <20210716075106.49938-1-manivannan.sadhasivam@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Loic Poulain The qrtr-mhi client driver assumes that inbound buffers are automatically allocated and queued by the MHI core, but this doesn't happen for mhi pci devices since IPCR inbound channel is not flagged with auto_queue, causing unusable IPCR (qrtr) feature. Fix that. Cc: stable@vger.kernel.org #5.10 Fixes: 855a70c12021 ("bus: mhi: Add MHI PCI support for WWAN modems") Signed-off-by: Loic Poulain Reviewed-by: Hemant kumar Reviewed-by: Manivannan Sadhasivam Link: https://lore.kernel.org/r/1625736749-24947-1-git-send-email-loic.poulain@linaro.org [mani: fixed a spelling mistake in commit description] Signed-off-by: Manivannan Sadhasivam --- drivers/bus/mhi/pci_generic.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) -- 2.25.1 diff --git a/drivers/bus/mhi/pci_generic.c b/drivers/bus/mhi/pci_generic.c index 3396cb30ebec..4dd1077354af 100644 --- a/drivers/bus/mhi/pci_generic.c +++ b/drivers/bus/mhi/pci_generic.c @@ -75,6 +75,22 @@ struct mhi_pci_dev_info { .doorbell_mode_switch = false, \ } +#define MHI_CHANNEL_CONFIG_DL_AUTOQUEUE(ch_num, ch_name, el_count, ev_ring) \ + { \ + .num = ch_num, \ + .name = ch_name, \ + .num_elements = el_count, \ + .event_ring = ev_ring, \ + .dir = DMA_FROM_DEVICE, \ + .ee_mask = BIT(MHI_EE_AMSS), \ + .pollcfg = 0, \ + .doorbell = MHI_DB_BRST_DISABLE, \ + .lpm_notify = false, \ + .offload_channel = false, \ + .doorbell_mode_switch = false, \ + .auto_queue = true, \ + } + #define MHI_EVENT_CONFIG_CTRL(ev_ring, el_count) \ { \ .num_elements = el_count, \ @@ -213,7 +229,7 @@ static const struct mhi_channel_config modem_qcom_v1_mhi_channels[] = { MHI_CHANNEL_CONFIG_UL(14, "QMI", 4, 0), MHI_CHANNEL_CONFIG_DL(15, "QMI", 4, 0), MHI_CHANNEL_CONFIG_UL(20, "IPCR", 8, 0), - MHI_CHANNEL_CONFIG_DL(21, "IPCR", 8, 0), + MHI_CHANNEL_CONFIG_DL_AUTOQUEUE(21, "IPCR", 8, 0), MHI_CHANNEL_CONFIG_UL_FP(34, "FIREHOSE", 32, 0), MHI_CHANNEL_CONFIG_DL_FP(35, "FIREHOSE", 32, 0), MHI_CHANNEL_CONFIG_HW_UL(100, "IP_HW0", 128, 2),