From patchwork Mon Jun 4 20:30:35 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 137664 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp100596lji; Mon, 4 Jun 2018 13:32:04 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIHJAC+MSuc+fOoWEMp6qA4ZLYCTzH4X40KOeCI4AO+tmhjULvFqiqXNDKWQEucWuW1XT+4 X-Received: by 2002:a17:902:708c:: with SMTP id z12-v6mr14981953plk.373.1528144324303; Mon, 04 Jun 2018 13:32:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528144324; cv=none; d=google.com; s=arc-20160816; b=j2gwWB2thXVhuTbNWs1PMeoSZWM9MLsieMsQBE14uk9PzGieUYSn8IVmoNgpJHqzat xqQLFskhUN1PKiDBVEVmH54lXXFfBRjZPNaqdB3oqYXL+FN7GEeLUjI9/US7uz4f0hYg p3MJJQT2rHUBBHtVbRfqj/BG4Lcj+XgUmfU8TImdwTXyGqZf4fnJF+9JsBONpHIvlcKz hwZ7xVZoi7obULg7YWTPdPDTqOPvtox/+QRggshIW/cljAI6vEpKlv1WdlA5RkuDIbiT D+yGTs3qxGXkihdvh3FNKlpWCf+19P8q2N43j61jaX/vlrBHzD4R5fXE6yEcK866J86E QKeg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=G1QoiKbu5vH50VrBKHaWykEtMXCXwGbaQ/SQCGj/VUw=; b=jC0lqwgk26ynmmjRbtx4oQkUNyxV4RmB/S1nAPeJfg/Q/Sv4oqH2Bo+kxhWxny5YZv kOVcDPIGgdyD+Dn1GxIGJjLAYxPCyKLaX9KOSEKCmgKOwobPoDWzJiQxKrQhHSj9tKpk HFCvEDLza+Z/uQusnc3aThe08S2HUv5AVGf04+3fchmGca4CT795z8oasLtfo5Rk5LI/ y+oSdIU9mbZjJjpdLFND6LkZEG5GLnGgizyAFGq6nyFk2eLa7eF9Jdzi4s5o9ZTgdEky WVE9iTb/+fDe7zPKrq0DAztfvSfcCFpBRYM7TxCmWllBSZIXN2lzxrsA6QiMgKc+EW0z itvw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=RtCCBKqV; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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. [209.132.180.67]) by mx.google.com with ESMTP id 3-v6si46278041plx.591.2018.06.04.13.32.03; Mon, 04 Jun 2018 13:32:04 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=RtCCBKqV; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751552AbeFDUcC (ORCPT + 30 others); Mon, 4 Jun 2018 16:32:02 -0400 Received: from mail-pl0-f67.google.com ([209.85.160.67]:35017 "EHLO mail-pl0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751258AbeFDUao (ORCPT ); Mon, 4 Jun 2018 16:30:44 -0400 Received: by mail-pl0-f67.google.com with SMTP id i5-v6so2122plt.2 for ; Mon, 04 Jun 2018 13:30:44 -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=G1QoiKbu5vH50VrBKHaWykEtMXCXwGbaQ/SQCGj/VUw=; b=RtCCBKqVxKD/oNWUCOmTyNo4EQctVfGsX1P61pqiy1eAoQfr/1VOKxyM5ZPffwsBvs hiIDVmAsDk8mWxIS0NsCi7mUQoCisui9MlMC25hOA+rOxHnvZcPxbZWkpGEZUiA42OyY UopzYSDSgQJ71nrjxXS2+JGsoYenEXH3pFWqQ= 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=G1QoiKbu5vH50VrBKHaWykEtMXCXwGbaQ/SQCGj/VUw=; b=GMEycybFktZ6AgiNveTWwT8mNSKuTCvzB/Vi1mrD7pVxjG0nDcCq2mRsbcsfNDJp2B f03wvkapn/PleZNdNvjXiAf+GFZFE7F7oVJ3We0oLYSYjZ4L+aha7sf0pRFqD2Dhmf3f +ZBPGq0F+C2KDqunBdZ/2xvAu8n5xLWFxi9OFruSmLgqi2FVpXvmsNJRUBE+q/6NQiqx DKiTTg4JpGiv4lHYhPytH6+6fiRCeBccmMNja6gOzUm+sThdqHbMU9y3tM/5My9j3dH9 G9CPfnPiuCkzpG4El6OaSNFiraqIaKe9UV0qWVMpIEhU+fWqP4FMAwEL7FhkHTqcaQBX FvNQ== X-Gm-Message-State: ALKqPwdWzzWQPj1TADnMMcY0X3VEdlatGjKKXGnm9XTQAOKHJqqE5sTr 85uRH/k2hlR2OsLc+bhjnJPOTQ== X-Received: by 2002:a17:902:422:: with SMTP id 31-v6mr23925215ple.320.1528144244039; Mon, 04 Jun 2018 13:30:44 -0700 (PDT) Received: from localhost.localdomain (104-188-17-28.lightspeed.sndgca.sbcglobal.net. [104.188.17.28]) by smtp.gmail.com with ESMTPSA id u68-v6sm83058641pfu.32.2018.06.04.13.30.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 04 Jun 2018 13:30:43 -0700 (PDT) From: Bjorn Andersson To: Ohad Ben-Cohen , Bjorn Andersson , Sricharan R , Sibi Sankar , Rohit kumar , Andy Gross Cc: linux-kernel@vger.kernel.org, linux-remoteproc@vger.kernel.org, linux-arm-msm@vger.kernel.org Subject: [PATCH 1/4] remoteproc: qcom: mdt_loader: Make the firmware authentication optional Date: Mon, 4 Jun 2018 13:30:35 -0700 Message-Id: <20180604203038.14080-2-bjorn.andersson@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180604203038.14080-1-bjorn.andersson@linaro.org> References: <20180604203038.14080-1-bjorn.andersson@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Sricharan R qcom_mdt_load function loads the mdt type firmware and initialises the secure memory as well. Make the initialisation only when requested by the caller, so that the function can be used by self-authenticating remoteproc as well. Signed-off-by: Sricharan R Signed-off-by: Bjorn Andersson --- Changes since RFC: - None drivers/soc/qcom/mdt_loader.c | 87 ++++++++++++++++++++--------- include/linux/soc/qcom/mdt_loader.h | 4 ++ 2 files changed, 66 insertions(+), 25 deletions(-) -- 2.17.0 diff --git a/drivers/soc/qcom/mdt_loader.c b/drivers/soc/qcom/mdt_loader.c index dc09d7ac905f..1c488024c698 100644 --- a/drivers/soc/qcom/mdt_loader.c +++ b/drivers/soc/qcom/mdt_loader.c @@ -74,23 +74,10 @@ ssize_t qcom_mdt_get_size(const struct firmware *fw) } EXPORT_SYMBOL_GPL(qcom_mdt_get_size); -/** - * qcom_mdt_load() - load the firmware which header is loaded as fw - * @dev: device handle to associate resources with - * @fw: firmware object for the mdt file - * @firmware: name of the firmware, for construction of segment file names - * @pas_id: PAS identifier - * @mem_region: allocated memory region to load firmware into - * @mem_phys: physical address of allocated memory region - * @mem_size: size of the allocated memory region - * @reloc_base: adjusted physical address after relocation - * - * Returns 0 on success, negative errno otherwise. - */ -int qcom_mdt_load(struct device *dev, const struct firmware *fw, - const char *firmware, int pas_id, void *mem_region, - phys_addr_t mem_phys, size_t mem_size, - phys_addr_t *reloc_base) +static int __qcom_mdt_load(struct device *dev, const struct firmware *fw, + const char *firmware, int pas_id, void *mem_region, + phys_addr_t mem_phys, size_t mem_size, + phys_addr_t *reloc_base, bool pas_init) { const struct elf32_phdr *phdrs; const struct elf32_phdr *phdr; @@ -121,10 +108,12 @@ int qcom_mdt_load(struct device *dev, const struct firmware *fw, if (!fw_name) return -ENOMEM; - ret = qcom_scm_pas_init_image(pas_id, fw->data, fw->size); - if (ret) { - dev_err(dev, "invalid firmware metadata\n"); - goto out; + if (pas_init) { + ret = qcom_scm_pas_init_image(pas_id, fw->data, fw->size); + if (ret) { + dev_err(dev, "invalid firmware metadata\n"); + goto out; + } } for (i = 0; i < ehdr->e_phnum; i++) { @@ -144,10 +133,13 @@ int qcom_mdt_load(struct device *dev, const struct firmware *fw, } if (relocate) { - ret = qcom_scm_pas_mem_setup(pas_id, mem_phys, max_addr - min_addr); - if (ret) { - dev_err(dev, "unable to setup relocation\n"); - goto out; + if (pas_init) { + ret = qcom_scm_pas_mem_setup(pas_id, mem_phys, + max_addr - min_addr); + if (ret) { + dev_err(dev, "unable to setup relocation\n"); + goto out; + } } /* @@ -202,7 +194,52 @@ int qcom_mdt_load(struct device *dev, const struct firmware *fw, return ret; } + +/** + * qcom_mdt_load() - load the firmware which header is loaded as fw + * @dev: device handle to associate resources with + * @fw: firmware object for the mdt file + * @firmware: name of the firmware, for construction of segment file names + * @pas_id: PAS identifier + * @mem_region: allocated memory region to load firmware into + * @mem_phys: physical address of allocated memory region + * @mem_size: size of the allocated memory region + * @reloc_base: adjusted physical address after relocation + * + * Returns 0 on success, negative errno otherwise. + */ +int qcom_mdt_load(struct device *dev, const struct firmware *fw, + const char *firmware, int pas_id, void *mem_region, + phys_addr_t mem_phys, size_t mem_size, + phys_addr_t *reloc_base) +{ + return __qcom_mdt_load(dev, fw, firmware, pas_id, mem_region, mem_phys, + mem_size, reloc_base, true); +} EXPORT_SYMBOL_GPL(qcom_mdt_load); +/** + * qcom_mdt_load_no_init() - load the firmware which header is loaded as fw + * @dev: device handle to associate resources with + * @fw: firmware object for the mdt file + * @firmware: name of the firmware, for construction of segment file names + * @pas_id: PAS identifier + * @mem_region: allocated memory region to load firmware into + * @mem_phys: physical address of allocated memory region + * @mem_size: size of the allocated memory region + * @reloc_base: adjusted physical address after relocation + * + * Returns 0 on success, negative errno otherwise. + */ +int qcom_mdt_load_no_init(struct device *dev, const struct firmware *fw, + const char *firmware, int pas_id, + void *mem_region, phys_addr_t mem_phys, + size_t mem_size, phys_addr_t *reloc_base) +{ + return __qcom_mdt_load(dev, fw, firmware, pas_id, mem_region, mem_phys, + mem_size, reloc_base, false); +} +EXPORT_SYMBOL_GPL(qcom_mdt_load_no_init); + MODULE_DESCRIPTION("Firmware parser for Qualcomm MDT format"); MODULE_LICENSE("GPL v2"); diff --git a/include/linux/soc/qcom/mdt_loader.h b/include/linux/soc/qcom/mdt_loader.h index 5b98bbdabc25..944b06aefb0f 100644 --- a/include/linux/soc/qcom/mdt_loader.h +++ b/include/linux/soc/qcom/mdt_loader.h @@ -17,4 +17,8 @@ int qcom_mdt_load(struct device *dev, const struct firmware *fw, phys_addr_t mem_phys, size_t mem_size, phys_addr_t *reloc_base); +int qcom_mdt_load_no_init(struct device *dev, const struct firmware *fw, + const char *fw_name, int pas_id, void *mem_region, + phys_addr_t mem_phys, size_t mem_size, + phys_addr_t *reloc_base); #endif From patchwork Mon Jun 4 20:30:36 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 137663 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp100140lji; Mon, 4 Jun 2018 13:31:33 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLW4OLjSS6zz54OTrhGMRfxLCc8Xl5QpeikH+8OyqQulqkmqTzv/zxraQ2jaM6u3o2Z3u1X X-Received: by 2002:a17:902:b7c4:: with SMTP id v4-v6mr23543231plz.188.1528144293325; Mon, 04 Jun 2018 13:31:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528144293; cv=none; d=google.com; s=arc-20160816; b=iQe8U7lUrRV6+uR8zdMOSPSYnDcXNlBiBlAKU0alfxslyGWXVHbOyHAFCORqKr/84q 7jsI6Ue/m+1yQJMk4N5gz89MqFq79Gk4hPzpcKWi3Nr3InkcISYtRGjvybv+ucOz912Z gCwjXGsbrL8nHCY9J+gCIT+30ULyckFHhcbpReIowBvHtArSbj2/9pGOVSJ0urvO/HJP GHx8RX0ZVvfLvLselwOsxPSL4g7jTYYt1YXjAxDDSb2+znS65F80g5BUNm6f7ibNidTX a0X5YqhpK9eEiG6lAgouJxGJ7enHLWONZ9QzI1N7+8ZEyVhEcJhByTctcKq3TO/5eGBF wjqQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=3aV1z6ctVDm8/cwV8AHVCWQoYhfwsPmr95jE9Y1HWi0=; b=trbMRrHi7f/A4Hz9Kb5nO8QU3+3Je7kH8aUki2rzndOE7SbPKiaFbi7LdmeqNruKBM URHfH8rqEJBScTgB4Fri9aDkw0v096eqTNB/Gi1RqxzIJ/JqBxkYb7+YmjYg6echYI01 PlOSNZ9EXpnNXoASyzO2mYgUxMRnqd09LAfEV8xuwo3MtOUDtdBI3P1HmfmD5IsHI1Di Ajl1oy471k/ZIcEoN7isq43ahmJhJLqSoMXlRo7uoolmm0zkxJiVIpspehl5q9nSG2Hu rJIksAtJksFI+IuANjUL2/hG6SMbGlexAX4XK54f6SRglXYpYuteeS9aRlooZvjsxKLu ABWA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=kb1H64+i; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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. [209.132.180.67]) by mx.google.com with ESMTP id e3-v6si4818848pgn.523.2018.06.04.13.31.33; Mon, 04 Jun 2018 13:31:33 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=kb1H64+i; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751526AbeFDUb2 (ORCPT + 30 others); Mon, 4 Jun 2018 16:31:28 -0400 Received: from mail-pl0-f68.google.com ([209.85.160.68]:43989 "EHLO mail-pl0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751313AbeFDUaq (ORCPT ); Mon, 4 Jun 2018 16:30:46 -0400 Received: by mail-pl0-f68.google.com with SMTP id c41-v6so20376207plj.10 for ; Mon, 04 Jun 2018 13:30:45 -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=3aV1z6ctVDm8/cwV8AHVCWQoYhfwsPmr95jE9Y1HWi0=; b=kb1H64+izBWNBVfzjY3M/JvlnM37+tLi9enBBkq4UY3tZBsD0U4BKl8McpK/zEYWi+ bSGYSL+tKet8+q7TdT/zZzQcbBXUMXG3YcRVdMzuEq/UZbySUIj29swmyxPjLZKyOvdx w32WalYkCNfvpLP7xGoAYwguZ5OUDjQVMV4Ak= 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=3aV1z6ctVDm8/cwV8AHVCWQoYhfwsPmr95jE9Y1HWi0=; b=m5CpRRLKYH67vIKvPqPMf4OLJ4r7JoHqzXu1lvThrCjzRPIxPeNyr1IkS8yfAwfz6L t7EvTu7wmt50VHaLvE6bbvI2X+GqLQTfH7ZCs98Zdvt0OvWi5s0oHN2EU86TtO7y/Hoj oBG9+LuIO9nFONj5ePZf8YomcYVkOutz7U3+8J2huj/Km1XHSrxQAHo7APZsI8GA0l5f p/crTzf8Mu+RVe7CySCD/WPDDSKHRZOR6j1ETX8+YiZKuIOTD+DehPcYH8VKABM/c3lG oXsEjjSEDIIDNsCDhdxO3uaVOnxjRF/H/mAco9dvXmNblQxPLjXHA+8/vh3oOGIIKrVw Q2Ow== X-Gm-Message-State: ALKqPwf7+zvWahe6UD0S6KYU3xlaYzB1lSh6HeiHhE6nRf8sZbLjlOcx 46B8d9L2M+qMl7k1hjHK5UDfTWTJL1o= X-Received: by 2002:a17:902:aa95:: with SMTP id d21-v6mr22959924plr.73.1528144245425; Mon, 04 Jun 2018 13:30:45 -0700 (PDT) Received: from localhost.localdomain (104-188-17-28.lightspeed.sndgca.sbcglobal.net. [104.188.17.28]) by smtp.gmail.com with ESMTPSA id u68-v6sm83058641pfu.32.2018.06.04.13.30.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 04 Jun 2018 13:30:44 -0700 (PDT) From: Bjorn Andersson To: Ohad Ben-Cohen , Bjorn Andersson , Sricharan R , Sibi Sankar , Rohit kumar Cc: Andy Gross , linux-kernel@vger.kernel.org, linux-remoteproc@vger.kernel.org, linux-arm-msm@vger.kernel.org Subject: [PATCH 2/4] remoteproc: q6v5: Extract common resource handling Date: Mon, 4 Jun 2018 13:30:36 -0700 Message-Id: <20180604203038.14080-3-bjorn.andersson@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180604203038.14080-1-bjorn.andersson@linaro.org> References: <20180604203038.14080-1-bjorn.andersson@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Shared between all Hexagon V5 based remoteprocs is the handling of the 5 interrupts and the SMP2P stop request, so break this out into a separate function in order to allow these drivers to be cleaned up. Reviewed-by: Rohit kumar Tested-by: Rohit kumar Signed-off-by: Bjorn Andersson --- Changes since RFC: - Corrected header comment - Corrected copy-pasted crash type in wdog_intr - Picked up Rohit's reviewed-by drivers/remoteproc/Kconfig | 5 + drivers/remoteproc/Makefile | 1 + drivers/remoteproc/qcom_q6v5.c | 243 +++++++++++++++++++++++++++++++++ drivers/remoteproc/qcom_q6v5.h | 46 +++++++ 4 files changed, 295 insertions(+) create mode 100644 drivers/remoteproc/qcom_q6v5.c create mode 100644 drivers/remoteproc/qcom_q6v5.h -- 2.17.0 diff --git a/drivers/remoteproc/Kconfig b/drivers/remoteproc/Kconfig index cd1c168fd188..63b79ea91a21 100644 --- a/drivers/remoteproc/Kconfig +++ b/drivers/remoteproc/Kconfig @@ -102,6 +102,11 @@ config QCOM_ADSP_PIL config QCOM_RPROC_COMMON tristate +config QCOM_Q6V5_COMMON + tristate + depends on ARCH_QCOM + depends on QCOM_SMEM + config QCOM_Q6V5_PIL tristate "Qualcomm Hexagon V5 Peripherial Image Loader" depends on OF && ARCH_QCOM diff --git a/drivers/remoteproc/Makefile b/drivers/remoteproc/Makefile index 02627ede8d4a..5dd0249cf76a 100644 --- a/drivers/remoteproc/Makefile +++ b/drivers/remoteproc/Makefile @@ -16,6 +16,7 @@ obj-$(CONFIG_DA8XX_REMOTEPROC) += da8xx_remoteproc.o obj-$(CONFIG_KEYSTONE_REMOTEPROC) += keystone_remoteproc.o obj-$(CONFIG_QCOM_ADSP_PIL) += qcom_adsp_pil.o obj-$(CONFIG_QCOM_RPROC_COMMON) += qcom_common.o +obj-$(CONFIG_QCOM_Q6V5_COMMON) += qcom_q6v5.o obj-$(CONFIG_QCOM_Q6V5_PIL) += qcom_q6v5_pil.o obj-$(CONFIG_QCOM_SYSMON) += qcom_sysmon.o obj-$(CONFIG_QCOM_WCNSS_PIL) += qcom_wcnss_pil.o diff --git a/drivers/remoteproc/qcom_q6v5.c b/drivers/remoteproc/qcom_q6v5.c new file mode 100644 index 000000000000..400cdf936f6b --- /dev/null +++ b/drivers/remoteproc/qcom_q6v5.c @@ -0,0 +1,243 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Qualcomm Peripheral Image Loader for Q6V5 + * + * Copyright (C) 2016-2018 Linaro Ltd. + * Copyright (C) 2014 Sony Mobile Communications AB + * Copyright (c) 2012-2013, The Linux Foundation. All rights reserved. + */ +#include +#include +#include +#include +#include +#include +#include "qcom_q6v5.h" + +/** + * qcom_q6v5_prepare() - reinitialize the qcom_q6v5 context before start + * @q6v5: reference to qcom_q6v5 context to be reinitialized + * + * Return: 0 on success, negative errno on failure + */ +int qcom_q6v5_prepare(struct qcom_q6v5 *q6v5) +{ + reinit_completion(&q6v5->start_done); + reinit_completion(&q6v5->stop_done); + + q6v5->running = true; + q6v5->handover_issued = false; + + enable_irq(q6v5->handover_irq); + + return 0; +} + +/** + * qcom_q6v5_unprepare() - unprepare the qcom_q6v5 context after stop + * @q6v5: reference to qcom_q6v5 context to be unprepared + * + * Return: 0 on success, 1 if handover hasn't yet been called + */ +int qcom_q6v5_unprepare(struct qcom_q6v5 *q6v5) +{ + disable_irq(q6v5->handover_irq); + + return !q6v5->handover_issued; +} + +static irqreturn_t q6v5_wdog_interrupt(int irq, void *data) +{ + struct qcom_q6v5 *q6v5 = data; + size_t len; + char *msg; + + /* Sometimes the stop triggers a watchdog rather than a stop-ack */ + if (!q6v5->running) { + complete(&q6v5->stop_done); + return IRQ_HANDLED; + } + + msg = qcom_smem_get(QCOM_SMEM_HOST_ANY, q6v5->crash_reason, &len); + if (!IS_ERR(msg) && len > 0 && msg[0]) + dev_err(q6v5->dev, "watchdog received: %s\n", msg); + else + dev_err(q6v5->dev, "watchdog without message\n"); + + rproc_report_crash(q6v5->rproc, RPROC_WATCHDOG); + + return IRQ_HANDLED; +} + +static irqreturn_t q6v5_fatal_interrupt(int irq, void *data) +{ + struct qcom_q6v5 *q6v5 = data; + size_t len; + char *msg; + + msg = qcom_smem_get(QCOM_SMEM_HOST_ANY, q6v5->crash_reason, &len); + if (!IS_ERR(msg) && len > 0 && msg[0]) + dev_err(q6v5->dev, "fatal error received: %s\n", msg); + else + dev_err(q6v5->dev, "fatal error without message\n"); + + rproc_report_crash(q6v5->rproc, RPROC_FATAL_ERROR); + + return IRQ_HANDLED; +} + +static irqreturn_t q6v5_ready_interrupt(int irq, void *data) +{ + struct qcom_q6v5 *q6v5 = data; + + complete(&q6v5->start_done); + + return IRQ_HANDLED; +} + +/** + * qcom_q6v5_wait_for_start() - wait for remote processor start signal + * @q6v5: reference to qcom_q6v5 context + * @timeout: timeout to wait for the event, in jiffies + * + * qcom_q6v5_unprepare() should not be called when this function fails. + * + * Return: 0 on success, -ETIMEDOUT on timeout + */ +int qcom_q6v5_wait_for_start(struct qcom_q6v5 *q6v5, int timeout) +{ + int ret; + + ret = wait_for_completion_timeout(&q6v5->start_done, timeout); + if (!ret) + disable_irq(q6v5->handover_irq); + + return !ret ? -ETIMEDOUT : 0; +} + +static irqreturn_t q6v5_handover_interrupt(int irq, void *data) +{ + struct qcom_q6v5 *q6v5 = data; + + if (q6v5->handover) + q6v5->handover(q6v5); + + q6v5->handover_issued = true; + + return IRQ_HANDLED; +} + +static irqreturn_t q6v5_stop_interrupt(int irq, void *data) +{ + struct qcom_q6v5 *q6v5 = data; + + complete(&q6v5->stop_done); + + return IRQ_HANDLED; +} + +/** + * qcom_q6v5_request_stop() - request the remote processor to stop + * @q6v5: reference to qcom_q6v5 context + * + * Return: 0 on success, negative errno on failure + */ +int qcom_q6v5_request_stop(struct qcom_q6v5 *q6v5) +{ + int ret; + + q6v5->running = false; + + qcom_smem_state_update_bits(q6v5->state, + BIT(q6v5->stop_bit), BIT(q6v5->stop_bit)); + + ret = wait_for_completion_timeout(&q6v5->stop_done, 5 * HZ); + + qcom_smem_state_update_bits(q6v5->state, BIT(q6v5->stop_bit), 0); + + return ret == 0 ? -ETIMEDOUT : 0; +} + +/** + * qcom_q6v5_init() - initializer of the q6v5 common struct + * @q6v5: handle to be initialized + * @pdev: platform_device reference for acquiring resources + * @rproc: associated remoteproc instance + * @crash_reason: SMEM id for crash reason string, or 0 if none + * @handover: function to be called when proxy resources should be released + * + * Return: 0 on success, negative errno on failure + */ +int qcom_q6v5_init(struct qcom_q6v5 *q6v5, struct platform_device *pdev, + struct rproc *rproc, int crash_reason, + void (*handover)(struct qcom_q6v5 *q6v5)) +{ + int ret; + + q6v5->rproc = rproc; + q6v5->dev = &pdev->dev; + q6v5->crash_reason = crash_reason; + q6v5->handover = handover; + + init_completion(&q6v5->start_done); + init_completion(&q6v5->stop_done); + + q6v5->wdog_irq = platform_get_irq_byname(pdev, "wdog"); + ret = devm_request_threaded_irq(&pdev->dev, q6v5->wdog_irq, + NULL, q6v5_wdog_interrupt, + IRQF_TRIGGER_RISING | IRQF_ONESHOT, + "q6v5 wdog", q6v5); + if (ret) { + dev_err(&pdev->dev, "failed to acquire wdog IRQ\n"); + return ret; + } + + q6v5->fatal_irq = platform_get_irq_byname(pdev, "fatal"); + ret = devm_request_threaded_irq(&pdev->dev, q6v5->fatal_irq, + NULL, q6v5_fatal_interrupt, + IRQF_TRIGGER_RISING | IRQF_ONESHOT, + "q6v5 fatal", q6v5); + if (ret) { + dev_err(&pdev->dev, "failed to acquire fatal IRQ\n"); + return ret; + } + + q6v5->ready_irq = platform_get_irq_byname(pdev, "ready"); + ret = devm_request_threaded_irq(&pdev->dev, q6v5->ready_irq, + NULL, q6v5_ready_interrupt, + IRQF_TRIGGER_RISING | IRQF_ONESHOT, + "q6v5 ready", q6v5); + if (ret) { + dev_err(&pdev->dev, "failed to acquire ready IRQ\n"); + return ret; + } + + q6v5->handover_irq = platform_get_irq_byname(pdev, "handover"); + ret = devm_request_threaded_irq(&pdev->dev, q6v5->handover_irq, + NULL, q6v5_handover_interrupt, + IRQF_TRIGGER_RISING | IRQF_ONESHOT, + "q6v5 handover", q6v5); + if (ret) { + dev_err(&pdev->dev, "failed to acquire handover IRQ\n"); + return ret; + } + disable_irq(q6v5->handover_irq); + + q6v5->stop_irq = platform_get_irq_byname(pdev, "stop-ack"); + ret = devm_request_threaded_irq(&pdev->dev, q6v5->stop_irq, + NULL, q6v5_stop_interrupt, + IRQF_TRIGGER_RISING | IRQF_ONESHOT, + "q6v5 stop", q6v5); + if (ret) { + dev_err(&pdev->dev, "failed to acquire stop-ack IRQ\n"); + return ret; + } + + q6v5->state = qcom_smem_state_get(&pdev->dev, "stop", &q6v5->stop_bit); + if (IS_ERR(q6v5->state)) { + dev_err(&pdev->dev, "failed to acquire stop state\n"); + return PTR_ERR(q6v5->state); + } + + return 0; +} diff --git a/drivers/remoteproc/qcom_q6v5.h b/drivers/remoteproc/qcom_q6v5.h new file mode 100644 index 000000000000..7ac92c1e0f49 --- /dev/null +++ b/drivers/remoteproc/qcom_q6v5.h @@ -0,0 +1,46 @@ +/* SPDX-License-Identifier: GPL-2.0 */ + +#ifndef __QCOM_Q6V5_H__ +#define __QCOM_Q6V5_H__ + +#include +#include + +struct rproc; +struct qcom_smem_state; + +struct qcom_q6v5 { + struct device *dev; + struct rproc *rproc; + + struct qcom_smem_state *state; + unsigned stop_bit; + + int wdog_irq; + int fatal_irq; + int ready_irq; + int handover_irq; + int stop_irq; + + bool handover_issued; + + struct completion start_done; + struct completion stop_done; + + int crash_reason; + + bool running; + + void (*handover)(struct qcom_q6v5 *q6v5); +}; + +int qcom_q6v5_init(struct qcom_q6v5 *q6v5, struct platform_device *pdev, + struct rproc *rproc, int crash_reason, + void (*handover)(struct qcom_q6v5 *q6v5)); + +int qcom_q6v5_prepare(struct qcom_q6v5 *q6v5); +int qcom_q6v5_unprepare(struct qcom_q6v5 *q6v5); +int qcom_q6v5_request_stop(struct qcom_q6v5 *q6v5); +int qcom_q6v5_wait_for_start(struct qcom_q6v5 *q6v5, int timeout); + +#endif From patchwork Mon Jun 4 20:30:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 137662 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp99905lji; Mon, 4 Jun 2018 13:31:15 -0700 (PDT) X-Google-Smtp-Source: ADUXVKK+zWbfnrJTHfxCouU5EQxv6g/I0y2Q9kFObL/G2zavvGN31fLfeE8ooNRupGVoCT7JYGP0 X-Received: by 2002:a63:745a:: with SMTP id e26-v6mr18057339pgn.377.1528144275139; Mon, 04 Jun 2018 13:31:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528144275; cv=none; d=google.com; s=arc-20160816; b=ZqTEK6CXFX6eLU9dl8I3SQAXewbqpT/SIe3UyQfmW6n82rVZLAfmdASN2Z2Uxf/bSu +sVYcs1Azf5p/b5BaOGgQDqqaqmGAQqgW1a7o4jmaZX8tDdmLjS1eFC4WTop4hlciQ+B +9BYKnVbwjinPJP13RgiDDn46sgEUimcdpnSYeTLvfMRUsIsYRB16ZVC/VJ2hlBdVWYS zcX74ae19Nd2s863snmDvK73zLBNXT2J3sfUa5VIdUP0S5mWfa2MRlTkYhAX02cUQZu+ nanK2b4LGw8TMI+JsfNxRiW4dwbpDK4F2RcJjJhjnzx/2g5MPmFNBM8fdekrpvLIUHz2 RwMQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=uAl9rAktf6cGaotAwTR5doJyObHYJnERsq4ZMpNg7u8=; b=Q/xiGqvRZgMg6Pq9AUNUSjJX9/lNNkV2yLZVmJTYRcnpL/vZwefLhbTeIWRENGWCQP 6HHlBn6MtUAecUm+F9/otJjagcclv1iK6ddJcAq8fb7OkZD+siEUi6P6VbnlDJF+8LLU piGRPYBOj0RbiiYn3oWVLI94RyKi9Yzo435fhGYANfDRCLwVCmzR6JU4Xu4J20wzl1mv trwYT8E1BWkfv4LjgxaCull0emoow0dBT79R5G+L6AjIf60pWc/ZGIlc6vcNNdx7wpAP ZX19Zpgdj/OSSsA4HqTLBDWmSp0exMAdbFQoJK411PawTplf1ExRDJVyC8Ugoa2xwXhV aaaA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hg6CssO5; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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. [209.132.180.67]) by mx.google.com with ESMTP id p21-v6si8493012pgv.112.2018.06.04.13.31.14; Mon, 04 Jun 2018 13:31:15 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hg6CssO5; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751470AbeFDUbM (ORCPT + 30 others); Mon, 4 Jun 2018 16:31:12 -0400 Received: from mail-pl0-f68.google.com ([209.85.160.68]:44482 "EHLO mail-pl0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751332AbeFDUar (ORCPT ); Mon, 4 Jun 2018 16:30:47 -0400 Received: by mail-pl0-f68.google.com with SMTP id z9-v6so17060122plk.11 for ; Mon, 04 Jun 2018 13:30: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=uAl9rAktf6cGaotAwTR5doJyObHYJnERsq4ZMpNg7u8=; b=hg6CssO5E3w65Mzf07N1kXoCJ2RvlYv5iLHjxhWWWDU8+92MMa7yVEriLvfdUZMZ0c sVsnKvAXI28ZH3yjrK5NIKCFPk2Lt55Eq8QdUnZRJ+1WEhG43WESI0nVow1kn6Uz41CI InEPWK6aUzMfhkof0mBXG2TOT7viRhY+5wMFs= 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=uAl9rAktf6cGaotAwTR5doJyObHYJnERsq4ZMpNg7u8=; b=SPNfe6G9ad643CJyYp+IpSUhOncBAg5Q6zF9La77g0oCOlI+y5sYv75V2MHwSrp8sT kJJUnyxiILXWOxVe5CZ1MPXJ9f07/tmF7v/yMeCOx5AU3xqdovte7Exrc6TFOou1O1NK JXSrH8QVAgPOkgyLCRSItfRQXGbe0WzO7yEvN+X2OG8lEu6H/tEmVYwxY7azfe+hU0oR dOPYvp9pkwgDJSEgGMFlMN6AityI/SYDVscbZ2uQNr9lpeSdL2txjPIJNiIyBW9NDXA8 GC0jICz3vTFqb3vDW3o+WcOG/IJ9yr2b1oECsbGp1ebBC+RvVHmt2FPUqfnNWmvjri3t 9ZCA== X-Gm-Message-State: APt69E3hgv6nkqA/tVwxjkDW7p63Z+0zL6KG294tyf7LViRhJjCoF2QK EwabXE1kV5axpDnSQeUYYGnGeQ== X-Received: by 2002:a17:902:900a:: with SMTP id a10-v6mr5138220plp.41.1528144247092; Mon, 04 Jun 2018 13:30:47 -0700 (PDT) Received: from localhost.localdomain (104-188-17-28.lightspeed.sndgca.sbcglobal.net. [104.188.17.28]) by smtp.gmail.com with ESMTPSA id u68-v6sm83058641pfu.32.2018.06.04.13.30.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 04 Jun 2018 13:30:46 -0700 (PDT) From: Bjorn Andersson To: Ohad Ben-Cohen , Bjorn Andersson , Sricharan R , Sibi Sankar , Rohit kumar Cc: Andy Gross , linux-kernel@vger.kernel.org, linux-remoteproc@vger.kernel.org, linux-arm-msm@vger.kernel.org Subject: [PATCH 3/4] remoteproc: qcom: adsp: Use common q6v5 helpers Date: Mon, 4 Jun 2018 13:30:37 -0700 Message-Id: <20180604203038.14080-4-bjorn.andersson@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180604203038.14080-1-bjorn.andersson@linaro.org> References: <20180604203038.14080-1-bjorn.andersson@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Migrate the Hexagon V5 PAS (ADSP) driver to using the newly extracted helper functions. The use of the handover callback does introduce latent disabling of proxy resources. But apart from this there should be no change in functionality. Reviewed-by: Rohit kumar Reviewed-by: Sricharan R Tested-by: Rohit kumar Signed-off-by: Bjorn Andersson --- Changes since RFC: - Picked up reviewed-by from Rohit and Sricharan drivers/remoteproc/Kconfig | 1 + drivers/remoteproc/qcom_adsp_pil.c | 156 +++++------------------------ 2 files changed, 28 insertions(+), 129 deletions(-) -- 2.17.0 diff --git a/drivers/remoteproc/Kconfig b/drivers/remoteproc/Kconfig index 63b79ea91a21..d51d155cf8bd 100644 --- a/drivers/remoteproc/Kconfig +++ b/drivers/remoteproc/Kconfig @@ -93,6 +93,7 @@ config QCOM_ADSP_PIL depends on QCOM_SYSMON || QCOM_SYSMON=n select MFD_SYSCON select QCOM_MDT_LOADER + select QCOM_Q6V5_COMMON select QCOM_RPROC_COMMON select QCOM_SCM help diff --git a/drivers/remoteproc/qcom_adsp_pil.c b/drivers/remoteproc/qcom_adsp_pil.c index 89a86ce07f99..d4339a6da616 100644 --- a/drivers/remoteproc/qcom_adsp_pil.c +++ b/drivers/remoteproc/qcom_adsp_pil.c @@ -31,6 +31,7 @@ #include #include "qcom_common.h" +#include "qcom_q6v5.h" #include "remoteproc_internal.h" struct adsp_data { @@ -48,14 +49,7 @@ struct qcom_adsp { struct device *dev; struct rproc *rproc; - int wdog_irq; - int fatal_irq; - int ready_irq; - int handover_irq; - int stop_ack_irq; - - struct qcom_smem_state *state; - unsigned stop_bit; + struct qcom_q6v5 q6v5; struct clk *xo; struct clk *aggre2_clk; @@ -96,6 +90,8 @@ static int adsp_start(struct rproc *rproc) struct qcom_adsp *adsp = (struct qcom_adsp *)rproc->priv; int ret; + qcom_q6v5_prepare(&adsp->q6v5); + ret = clk_prepare_enable(adsp->xo); if (ret) return ret; @@ -119,16 +115,14 @@ static int adsp_start(struct rproc *rproc) goto disable_px_supply; } - ret = wait_for_completion_timeout(&adsp->start_done, - msecs_to_jiffies(5000)); - if (!ret) { + ret = qcom_q6v5_wait_for_start(&adsp->q6v5, msecs_to_jiffies(5000)); + if (ret == -ETIMEDOUT) { dev_err(adsp->dev, "start timed out\n"); qcom_scm_pas_shutdown(adsp->pas_id); - ret = -ETIMEDOUT; goto disable_px_supply; } - ret = 0; + return 0; disable_px_supply: regulator_disable(adsp->px_supply); @@ -142,28 +136,34 @@ static int adsp_start(struct rproc *rproc) return ret; } +static void qcom_pas_handover(struct qcom_q6v5 *q6v5) +{ + struct qcom_adsp *adsp = container_of(q6v5, struct qcom_adsp, q6v5); + + regulator_disable(adsp->px_supply); + regulator_disable(adsp->cx_supply); + clk_disable_unprepare(adsp->aggre2_clk); + clk_disable_unprepare(adsp->xo); +} + static int adsp_stop(struct rproc *rproc) { struct qcom_adsp *adsp = (struct qcom_adsp *)rproc->priv; + int handover; int ret; - qcom_smem_state_update_bits(adsp->state, - BIT(adsp->stop_bit), - BIT(adsp->stop_bit)); - - ret = wait_for_completion_timeout(&adsp->stop_done, - msecs_to_jiffies(5000)); - if (ret == 0) + ret = qcom_q6v5_request_stop(&adsp->q6v5); + if (ret == -ETIMEDOUT) dev_err(adsp->dev, "timed out on wait\n"); - qcom_smem_state_update_bits(adsp->state, - BIT(adsp->stop_bit), - 0); - ret = qcom_scm_pas_shutdown(adsp->pas_id); if (ret) dev_err(adsp->dev, "failed to shutdown: %d\n", ret); + handover = qcom_q6v5_unprepare(&adsp->q6v5); + if (handover) + qcom_pas_handover(&adsp->q6v5); + return ret; } @@ -187,53 +187,6 @@ static const struct rproc_ops adsp_ops = { .load = adsp_load, }; -static irqreturn_t adsp_wdog_interrupt(int irq, void *dev) -{ - struct qcom_adsp *adsp = dev; - - rproc_report_crash(adsp->rproc, RPROC_WATCHDOG); - - return IRQ_HANDLED; -} - -static irqreturn_t adsp_fatal_interrupt(int irq, void *dev) -{ - struct qcom_adsp *adsp = dev; - size_t len; - char *msg; - - msg = qcom_smem_get(QCOM_SMEM_HOST_ANY, adsp->crash_reason_smem, &len); - if (!IS_ERR(msg) && len > 0 && msg[0]) - dev_err(adsp->dev, "fatal error received: %s\n", msg); - - rproc_report_crash(adsp->rproc, RPROC_FATAL_ERROR); - - return IRQ_HANDLED; -} - -static irqreturn_t adsp_ready_interrupt(int irq, void *dev) -{ - return IRQ_HANDLED; -} - -static irqreturn_t adsp_handover_interrupt(int irq, void *dev) -{ - struct qcom_adsp *adsp = dev; - - complete(&adsp->start_done); - - return IRQ_HANDLED; -} - -static irqreturn_t adsp_stop_ack_interrupt(int irq, void *dev) -{ - struct qcom_adsp *adsp = dev; - - complete(&adsp->stop_done); - - return IRQ_HANDLED; -} - static int adsp_init_clock(struct qcom_adsp *adsp) { int ret; @@ -272,29 +225,6 @@ static int adsp_init_regulator(struct qcom_adsp *adsp) return PTR_ERR_OR_ZERO(adsp->px_supply); } -static int adsp_request_irq(struct qcom_adsp *adsp, - struct platform_device *pdev, - const char *name, - irq_handler_t thread_fn) -{ - int ret; - - ret = platform_get_irq_byname(pdev, name); - if (ret < 0) { - dev_err(&pdev->dev, "no %s IRQ defined\n", name); - return ret; - } - - ret = devm_request_threaded_irq(&pdev->dev, ret, - NULL, thread_fn, - IRQF_ONESHOT, - "adsp", adsp); - if (ret) - dev_err(&pdev->dev, "request %s IRQ failed\n", name); - - return ret; -} - static int adsp_alloc_memory_region(struct qcom_adsp *adsp) { struct device_node *node; @@ -348,13 +278,9 @@ static int adsp_probe(struct platform_device *pdev) adsp->dev = &pdev->dev; adsp->rproc = rproc; adsp->pas_id = desc->pas_id; - adsp->crash_reason_smem = desc->crash_reason_smem; adsp->has_aggre2_clk = desc->has_aggre2_clk; platform_set_drvdata(pdev, adsp); - init_completion(&adsp->start_done); - init_completion(&adsp->stop_done); - ret = adsp_alloc_memory_region(adsp); if (ret) goto free_rproc; @@ -367,37 +293,10 @@ static int adsp_probe(struct platform_device *pdev) if (ret) goto free_rproc; - ret = adsp_request_irq(adsp, pdev, "wdog", adsp_wdog_interrupt); - if (ret < 0) - goto free_rproc; - adsp->wdog_irq = ret; - - ret = adsp_request_irq(adsp, pdev, "fatal", adsp_fatal_interrupt); - if (ret < 0) - goto free_rproc; - adsp->fatal_irq = ret; - - ret = adsp_request_irq(adsp, pdev, "ready", adsp_ready_interrupt); - if (ret < 0) - goto free_rproc; - adsp->ready_irq = ret; - - ret = adsp_request_irq(adsp, pdev, "handover", adsp_handover_interrupt); - if (ret < 0) - goto free_rproc; - adsp->handover_irq = ret; - - ret = adsp_request_irq(adsp, pdev, "stop-ack", adsp_stop_ack_interrupt); - if (ret < 0) - goto free_rproc; - adsp->stop_ack_irq = ret; - - adsp->state = qcom_smem_state_get(&pdev->dev, "stop", - &adsp->stop_bit); - if (IS_ERR(adsp->state)) { - ret = PTR_ERR(adsp->state); + ret = qcom_q6v5_init(&adsp->q6v5, pdev, rproc, desc->crash_reason_smem, + qcom_pas_handover); + if (ret) goto free_rproc; - } qcom_add_glink_subdev(rproc, &adsp->glink_subdev); qcom_add_smd_subdev(rproc, &adsp->smd_subdev); @@ -422,7 +321,6 @@ static int adsp_remove(struct platform_device *pdev) { struct qcom_adsp *adsp = platform_get_drvdata(pdev); - qcom_smem_state_put(adsp->state); rproc_del(adsp->rproc); qcom_remove_glink_subdev(adsp->rproc, &adsp->glink_subdev); From patchwork Mon Jun 4 20:30:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 137661 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp99617lji; Mon, 4 Jun 2018 13:30:56 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJfQ5ma7xXlKIjoPe8LVJa+Hylb5foSVh3JW4Fi/7G9Krf8x0ajRe0D6a/TXhTxAhJBt6x0 X-Received: by 2002:a62:8b0a:: with SMTP id j10-v6mr22717390pfe.28.1528144255912; Mon, 04 Jun 2018 13:30:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528144255; cv=none; d=google.com; s=arc-20160816; b=G/qmKP/dJqGUOJjn+kMM15rXFuxcrbf6iZG4aNLt5C0205HOz24CrSz5NKxaRPmmvD zxiylonj/x7diJs+dy7UCxsRRcyIh00iqem2ndz7a6vEMDN2XELHLWnmvzfbmFQSiYtI SBiJWpCBlsR6cq8TNCQBVYCTVuh78aeEljM/PADKVyP19njsZMH4t5vud9ub63OfOVf+ 0hwTBsx4CYA8J6Rj7GW6GvoGdc+0HSV4afWVbCwMbx7BJc6mUDxCHk6nFo3cDXYlOhzl enLcLoSVXs48j+ahbtlMMqrrOraNUbuSDLl6OLBkZTV4AaLn3O+I/HPhwhRmfRo1+i7m jfPg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=G5MoFK0JNXnsVRqzS5lZDAk7A+RB3u9qcgxQw2TtchA=; b=nwSc2cw8CyxQ/145O7ON9b475g0mu/tS1v/xQE1ouH0M255v1ZzqHwcaJL2/nZp1vE CHww5jo9KmHTiptcNfiRLxSjRxAl6lyaBT19asH3UoIdHR1s9peab19n8N7G8exTMUeu 6z7ra/0YGxd2ywHCOohL9oFpN/pjy0dQoCmZKWVcknYSoyHXS1VXFyEQAYLH0II4WymI cghu56gr8EH+kbUpBBg8B8cCW7xySDxXlxNzfqyXX6aYM8dtTB3ByTa9QGI/khim6INw 98+lptarMlqj6YgZ99oWpYNJl76tTuf2kW5g2UG02GZSOW6kVvt1a9gkrQHegpIUuhqs /o8A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=a/KRXj7n; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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. [209.132.180.67]) by mx.google.com with ESMTP id x5-v6si15419945pgr.436.2018.06.04.13.30.55; Mon, 04 Jun 2018 13:30:55 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=a/KRXj7n; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751453AbeFDUaw (ORCPT + 30 others); Mon, 4 Jun 2018 16:30:52 -0400 Received: from mail-pl0-f68.google.com ([209.85.160.68]:46424 "EHLO mail-pl0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751400AbeFDUat (ORCPT ); Mon, 4 Jun 2018 16:30:49 -0400 Received: by mail-pl0-f68.google.com with SMTP id 30-v6so20377575pld.13 for ; Mon, 04 Jun 2018 13:30:48 -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=G5MoFK0JNXnsVRqzS5lZDAk7A+RB3u9qcgxQw2TtchA=; b=a/KRXj7neds2BgG+XDbJBBThLXgqvB9T1tYqhn5OxHis4VHdXvRMZkumyV6RA1efjn R2F8xGdbOETsVPloUOesnNM9+aikVfWXQ8LDJZlpHXKxWPhVyHYH96mnCPGBkw+3Tqlh XtvaFZwFe2x5PwVDvU3BUMQxd/SeSjmX//LRA= 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=G5MoFK0JNXnsVRqzS5lZDAk7A+RB3u9qcgxQw2TtchA=; b=suGrkHY8FjQhdrdQdPx+ZshQlI8HPahziIhqwfz4I6cqD93aSXszMnfLeXmx+IkECt ahaekfL+58cmTJVM1WfIl9Pd7bVENoaeXIxW9spdUa7bUfH/bzrdzLVccPR3cgE/jzWH 3wTgRx65dyvQokdcsR+dTDyi+SRz9TTfVZ5uZijEXCMCsCCRrQEKEjGTnN9kbV/YA53f kAGW4D6A+YRu5S0cF1/QbpHsYiuv6NUpBbjQH0ZitroZa/Ho6X31/pOT0QWAe/PGsMQ4 OrII0iYVeanvkKQeVIW41UbPzATZ2aBqQAr5yiyPjOSV0F4GppeK57mFpIiRJ9zUbGmB v5hg== X-Gm-Message-State: ALKqPwflCKNl6Xj9uJYbtQ9FH4xbmtlXGC6NnOBULO1Q+Fm70cnZ2rwu JCjUoPEkBckcqtSEAJ86TFrpdg== X-Received: by 2002:a17:902:43a4:: with SMTP id j33-v6mr23704563pld.118.1528144248349; Mon, 04 Jun 2018 13:30:48 -0700 (PDT) Received: from localhost.localdomain (104-188-17-28.lightspeed.sndgca.sbcglobal.net. [104.188.17.28]) by smtp.gmail.com with ESMTPSA id u68-v6sm83058641pfu.32.2018.06.04.13.30.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 04 Jun 2018 13:30:47 -0700 (PDT) From: Bjorn Andersson To: Ohad Ben-Cohen , Bjorn Andersson , Sricharan R , Sibi Sankar , Rohit kumar Cc: Andy Gross , linux-kernel@vger.kernel.org, linux-remoteproc@vger.kernel.org, linux-arm-msm@vger.kernel.org Subject: [PATCH 4/4] remoteproc: qcom: q6v5-pil: Use common q6v5 helpers Date: Mon, 4 Jun 2018 13:30:38 -0700 Message-Id: <20180604203038.14080-5-bjorn.andersson@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180604203038.14080-1-bjorn.andersson@linaro.org> References: <20180604203038.14080-1-bjorn.andersson@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Migrate the MSS remoteproc driver to use the newly extracted helper functions. Reviewed-by: Sricharan R Signed-off-by: Bjorn Andersson --- Changes since RFC: - Remove duplicate Kconfig selects - Picked up Sricharan's reviewed-by drivers/remoteproc/Kconfig | 1 + drivers/remoteproc/qcom_q6v5_pil.c | 157 +++-------------------------- 2 files changed, 16 insertions(+), 142 deletions(-) -- 2.17.0 diff --git a/drivers/remoteproc/Kconfig b/drivers/remoteproc/Kconfig index d51d155cf8bd..a6a74bde906a 100644 --- a/drivers/remoteproc/Kconfig +++ b/drivers/remoteproc/Kconfig @@ -116,6 +116,7 @@ config QCOM_Q6V5_PIL depends on RPMSG_QCOM_GLINK_SMEM || RPMSG_QCOM_GLINK_SMEM=n depends on QCOM_SYSMON || QCOM_SYSMON=n select MFD_SYSCON + select QCOM_Q6V5_COMMON select QCOM_RPROC_COMMON select QCOM_SCM help diff --git a/drivers/remoteproc/qcom_q6v5_pil.c b/drivers/remoteproc/qcom_q6v5_pil.c index 2bf8e7c49f2a..e04319573c91 100644 --- a/drivers/remoteproc/qcom_q6v5_pil.c +++ b/drivers/remoteproc/qcom_q6v5_pil.c @@ -30,12 +30,11 @@ #include #include #include -#include -#include #include #include "remoteproc_internal.h" #include "qcom_common.h" +#include "qcom_q6v5.h" #include @@ -151,12 +150,7 @@ struct q6v5 { struct reset_control *mss_restart; - struct qcom_smem_state *state; - unsigned stop_bit; - - int handover_irq; - - bool proxy_unvoted; + struct qcom_q6v5 q6v5; struct clk *active_clks[8]; struct clk *reset_clks[4]; @@ -170,8 +164,6 @@ struct q6v5 { int active_reg_count; int proxy_reg_count; - struct completion start_done; - struct completion stop_done; bool running; phys_addr_t mba_phys; @@ -798,9 +790,7 @@ static int q6v5_start(struct rproc *rproc) int xfermemop_ret; int ret; - qproc->proxy_unvoted = false; - - enable_irq(qproc->handover_irq); + qcom_q6v5_prepare(&qproc->q6v5); ret = q6v5_regulator_enable(qproc, qproc->proxy_regs, qproc->proxy_reg_count); @@ -875,11 +865,9 @@ static int q6v5_start(struct rproc *rproc) if (ret) goto reclaim_mpss; - ret = wait_for_completion_timeout(&qproc->start_done, - msecs_to_jiffies(5000)); - if (ret == 0) { + ret = qcom_q6v5_wait_for_start(&qproc->q6v5, msecs_to_jiffies(5000)); + if (ret == -ETIMEDOUT) { dev_err(qproc->dev, "start timed out\n"); - ret = -ETIMEDOUT; goto reclaim_mpss; } @@ -933,7 +921,7 @@ static int q6v5_start(struct rproc *rproc) qproc->proxy_reg_count); disable_irqs: - disable_irq(qproc->handover_irq); + qcom_q6v5_unprepare(&qproc->q6v5); return ret; } @@ -946,16 +934,10 @@ static int q6v5_stop(struct rproc *rproc) qproc->running = false; - qcom_smem_state_update_bits(qproc->state, - BIT(qproc->stop_bit), BIT(qproc->stop_bit)); - - ret = wait_for_completion_timeout(&qproc->stop_done, - msecs_to_jiffies(5000)); - if (ret == 0) + ret = qcom_q6v5_request_stop(&qproc->q6v5); + if (ret == -ETIMEDOUT) dev_err(qproc->dev, "timed out on wait\n"); - qcom_smem_state_update_bits(qproc->state, BIT(qproc->stop_bit), 0); - q6v5proc_halt_axi_port(qproc, qproc->halt_map, qproc->halt_q6); q6v5proc_halt_axi_port(qproc, qproc->halt_map, qproc->halt_modem); q6v5proc_halt_axi_port(qproc, qproc->halt_map, qproc->halt_nc); @@ -976,9 +958,8 @@ static int q6v5_stop(struct rproc *rproc) q6v5_reset_assert(qproc); - disable_irq(qproc->handover_irq); - - if (!qproc->proxy_unvoted) { + ret = qcom_q6v5_unprepare(&qproc->q6v5); + if (ret) { q6v5_clk_disable(qproc->dev, qproc->proxy_clks, qproc->proxy_clk_count); q6v5_regulator_disable(qproc, qproc->proxy_regs, @@ -1014,74 +995,14 @@ static const struct rproc_ops q6v5_ops = { .load = q6v5_load, }; -static irqreturn_t q6v5_wdog_interrupt(int irq, void *dev) -{ - struct q6v5 *qproc = dev; - size_t len; - char *msg; - - /* Sometimes the stop triggers a watchdog rather than a stop-ack */ - if (!qproc->running) { - complete(&qproc->stop_done); - return IRQ_HANDLED; - } - - msg = qcom_smem_get(QCOM_SMEM_HOST_ANY, MPSS_CRASH_REASON_SMEM, &len); - if (!IS_ERR(msg) && len > 0 && msg[0]) - dev_err(qproc->dev, "watchdog received: %s\n", msg); - else - dev_err(qproc->dev, "watchdog without message\n"); - - rproc_report_crash(qproc->rproc, RPROC_WATCHDOG); - - return IRQ_HANDLED; -} - -static irqreturn_t q6v5_fatal_interrupt(int irq, void *dev) -{ - struct q6v5 *qproc = dev; - size_t len; - char *msg; - - msg = qcom_smem_get(QCOM_SMEM_HOST_ANY, MPSS_CRASH_REASON_SMEM, &len); - if (!IS_ERR(msg) && len > 0 && msg[0]) - dev_err(qproc->dev, "fatal error received: %s\n", msg); - else - dev_err(qproc->dev, "fatal error without message\n"); - - rproc_report_crash(qproc->rproc, RPROC_FATAL_ERROR); - - return IRQ_HANDLED; -} - -static irqreturn_t q6v5_ready_interrupt(int irq, void *dev) -{ - struct q6v5 *qproc = dev; - - complete(&qproc->start_done); - return IRQ_HANDLED; -} - -static irqreturn_t q6v5_handover_interrupt(int irq, void *dev) +static void qcom_msa_handover(struct qcom_q6v5 *q6v5) { - struct q6v5 *qproc = dev; + struct q6v5 *qproc = container_of(q6v5, struct q6v5, q6v5); q6v5_clk_disable(qproc->dev, qproc->proxy_clks, qproc->proxy_clk_count); q6v5_regulator_disable(qproc, qproc->proxy_regs, qproc->proxy_reg_count); - - qproc->proxy_unvoted = true; - - return IRQ_HANDLED; -} - -static irqreturn_t q6v5_stop_ack_interrupt(int irq, void *dev) -{ - struct q6v5 *qproc = dev; - - complete(&qproc->stop_done); - return IRQ_HANDLED; } static int q6v5_init_mem(struct q6v5 *qproc, struct platform_device *pdev) @@ -1154,30 +1075,6 @@ static int q6v5_init_reset(struct q6v5 *qproc) return 0; } -static int q6v5_request_irq(struct q6v5 *qproc, - struct platform_device *pdev, - const char *name, - irq_handler_t thread_fn) -{ - int irq; - int ret; - - irq = platform_get_irq_byname(pdev, name); - if (irq < 0) { - dev_err(&pdev->dev, "no %s IRQ defined\n", name); - return irq; - } - - ret = devm_request_threaded_irq(&pdev->dev, irq, - NULL, thread_fn, - IRQF_TRIGGER_RISING | IRQF_ONESHOT, - "q6v5", qproc); - if (ret) - dev_err(&pdev->dev, "request %s IRQ failed\n", name); - - return ret ? : irq; -} - static int q6v5_alloc_memory_region(struct q6v5 *qproc) { struct device_node *child; @@ -1247,9 +1144,6 @@ static int q6v5_probe(struct platform_device *pdev) qproc->rproc = rproc; platform_set_drvdata(pdev, qproc); - init_completion(&qproc->start_done); - init_completion(&qproc->stop_done); - ret = q6v5_init_mem(qproc, pdev); if (ret) goto free_rproc; @@ -1305,33 +1199,12 @@ static int q6v5_probe(struct platform_device *pdev) qproc->version = desc->version; qproc->has_alt_reset = desc->has_alt_reset; qproc->need_mem_protection = desc->need_mem_protection; - ret = q6v5_request_irq(qproc, pdev, "wdog", q6v5_wdog_interrupt); - if (ret < 0) - goto free_rproc; - ret = q6v5_request_irq(qproc, pdev, "fatal", q6v5_fatal_interrupt); - if (ret < 0) - goto free_rproc; - - ret = q6v5_request_irq(qproc, pdev, "ready", q6v5_ready_interrupt); - if (ret < 0) - goto free_rproc; - - ret = q6v5_request_irq(qproc, pdev, "handover", q6v5_handover_interrupt); - if (ret < 0) - goto free_rproc; - qproc->handover_irq = ret; - disable_irq(qproc->handover_irq); - - ret = q6v5_request_irq(qproc, pdev, "stop-ack", q6v5_stop_ack_interrupt); - if (ret < 0) + ret = qcom_q6v5_init(&qproc->q6v5, pdev, rproc, MPSS_CRASH_REASON_SMEM, + qcom_msa_handover); + if (ret) goto free_rproc; - qproc->state = qcom_smem_state_get(&pdev->dev, "stop", &qproc->stop_bit); - if (IS_ERR(qproc->state)) { - ret = PTR_ERR(qproc->state); - goto free_rproc; - } qproc->mpss_perm = BIT(QCOM_SCM_VMID_HLOS); qproc->mba_perm = BIT(QCOM_SCM_VMID_HLOS); qcom_add_glink_subdev(rproc, &qproc->glink_subdev);