From patchwork Thu Jan 10 13:49:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Loic Pallardy X-Patchwork-Id: 155160 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp1915718jaa; Thu, 10 Jan 2019 05:49:28 -0800 (PST) X-Google-Smtp-Source: ALg8bN4Bf4mf6WdvzXD96FkMal2o8FJGHMnEtYwP0u2n8ap7ELYmiLscUwwmn3jmg+TG0MSGu0mh X-Received: by 2002:a63:e101:: with SMTP id z1mr9473826pgh.310.1547128168838; Thu, 10 Jan 2019 05:49:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547128168; cv=none; d=google.com; s=arc-20160816; b=R3BBhO6A/YN5b405wxW0ELPQPElyYg7K1b4Pg5bhp90EDY5gL6LBiGz3sHrZdORBin L30jqNxRcW/OlQg8ctW4I9k4zVqMEHL0CLJA3WQcFaLhmBjWdh6Rd7xp73m7snGk0fnd SbMsz6IeM07cBwiiqKwu85ue5cmS/7wDHSEelmw4dxt3NDSXT79q7ZIvp7UJacCe9bk3 DIW9f8+hb4Gd88HUi4nafMYtiXVyEkz2iDs8wz3+E7PwlYf6nXsBZm7UOfCDvPr8QpA+ oMS5njx2aE8SL9BdEtqKqLWt3evZ8ygUD5+lUHnwnmpIrew+evSq7NVXC4VRwRUFFHrc QXRQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=LrK+xvanX+VbFSXQQPHrQdJY7FdRZXEWDYUWIUfn72o=; b=Oy6hAa/uPEvMcvKnRW0PlKTmWWxYm8nRTs8Mz1B/ELLPmofv+0nmqi3R8NnnVjcFWi /vhdrlyCmy/Y5rH1VC5GxmFSHVgJ6BcDh+Zs4NxiJQYcT866tle5/hQpn8DiWQtsI4Kg QEbSfujIRD7gATZsr37fy4mIaNuMrWtIhh6y3ZPJqntvzYEer1UA6U3cvL1GmJ2DJwr6 JnNmyfhZlhF6kBjzw7JsDTRRlrIVyNxEundQIK8c9XHVjdHJ6zh015JsZ6ncOXDxB4mA yWoah2pbOpmzR8uuCSPEAbvAA01OU84khJ0AQjiqwtqb1ZGRdEUvbr/ejkMhVYCLh/fu zwsg== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l13si61935512pgi.46.2019.01.10.05.49.28; Thu, 10 Jan 2019 05:49:28 -0800 (PST) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729043AbfAJNt2 (ORCPT + 31 others); Thu, 10 Jan 2019 08:49:28 -0500 Received: from mx08-00178001.pphosted.com ([91.207.212.93]:62999 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728810AbfAJNtY (ORCPT ); Thu, 10 Jan 2019 08:49:24 -0500 Received: from pps.filterd (m0046660.ppops.net [127.0.0.1]) by mx08-00178001.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x0ADgDuf012608; Thu, 10 Jan 2019 14:49:21 +0100 Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx08-00178001.pphosted.com with ESMTP id 2ptt12b5yb-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Thu, 10 Jan 2019 14:49:21 +0100 Received: from zeta.dmz-eu.st.com (zeta.dmz-eu.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 5829734; Thu, 10 Jan 2019 13:49:20 +0000 (GMT) Received: from Webmail-eu.st.com (Safex1hubcas23.st.com [10.75.90.46]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 398E3504D; Thu, 10 Jan 2019 13:49:20 +0000 (GMT) Received: from SAFEX1HUBCAS21.st.com (10.75.90.45) by SAFEX1HUBCAS23.st.com (10.75.90.46) with Microsoft SMTP Server (TLS) id 14.3.361.1; Thu, 10 Jan 2019 14:49:19 +0100 Received: from localhost (10.201.20.178) by Webmail-ga.st.com (10.75.90.48) with Microsoft SMTP Server (TLS) id 14.3.361.1; Thu, 10 Jan 2019 14:49:18 +0100 From: Loic Pallardy To: , CC: , , , , , Loic Pallardy Subject: [PATCH v2 1/7] remoteproc: correct rproc_mem_entry_init() comments Date: Thu, 10 Jan 2019 14:49:05 +0100 Message-ID: <1547128151-44077-2-git-send-email-loic.pallardy@st.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1547128151-44077-1-git-send-email-loic.pallardy@st.com> References: <1547128151-44077-1-git-send-email-loic.pallardy@st.com> MIME-Version: 1.0 X-Originating-IP: [10.201.20.178] X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2019-01-10_05:, , signatures=0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add alloc parameter description and correct comment about release one. Signed-off-by: Loic Pallardy --- drivers/remoteproc/remoteproc_core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) -- 2.7.4 diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index 54ec38fc5dca..c1a66e25b173 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -900,7 +900,8 @@ EXPORT_SYMBOL(rproc_add_carveout); * @dma: dma address * @len: memory carveout length * @da: device address - * @release: memory carveout function + * @alloc: memory carveout allocation function + * @release: memory carveout release function * @name: carveout name * * This function allocates a rproc_mem_entry struct and fill it with parameters From patchwork Thu Jan 10 13:49:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Loic Pallardy X-Patchwork-Id: 155163 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp1915962jaa; Thu, 10 Jan 2019 05:49:43 -0800 (PST) X-Google-Smtp-Source: ALg8bN7ggE4CFmcqnHzQuYJwjm+tfuoxowSaojcudUQlT20nVb+Hen44PkLr2frcIy23JUWliF8y X-Received: by 2002:a62:345:: with SMTP id 66mr10217194pfd.189.1547128183838; Thu, 10 Jan 2019 05:49:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547128183; cv=none; d=google.com; s=arc-20160816; b=t+xMeTzpsaNfVNDgw9xeD74jByqiqG3YhzeF6LiTvLHqMJx7SeB0DfwSNPSTZPcE2e wbY5lXVJXjj3jxQxnn8e6dxBn3mQP/X5LVUnaLu7ZoyYaF9Nc2T7m3ybroTnb+x/K72M IDN4XpVLHwenPwBB2RKLdrrU9cxREL0e98Uqt44nmgki7X4XfIE+SYS/GhkO/SI/ZEPy gH4NJEjAqtWlEIZkMPejit4ytJ/lI9rHaKXxkcbyoHcs9i1jDp0F/hMVKhfCsHjjbcaC YMZr8K8C1f/pdlny5kbJ73Gmnx4sEPazTJOUM25D96l9XqFUtaSemMqZGSTRUdLZ8TWe vdpg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=yunOxm7f641ArikQSrc8dqmBdmRcvehu5Wg1kzPhb0o=; b=bCR7wI0P+a8z5qFBbykKKqnRp7b/62It0U1KLRyIP2qycnpOx+2u2s0w03UrXwDo88 CW+5TqZs9F9GDNkiFwi5j6ICt4C+zolSsBkHZb+AWGKCEQM06tk2iuCftnnxszYZuonU pJtMFUP+gH0DG6TbhO4/5hHYFbY6GUtgEj9mKNDJP69wGJqkoq7xJuTQ2l6STAD8gc1B 3w3YTPM665aEtFV2th6Qo1LknuM7rUQapFHbevARberZAdXLHNjI/0KmBjULS+B1hgZR 2UKSHiB3GASxqGVHbgs0WEsEj4hsWexRXcaQej6Rhi5MChNzn0ET1lbQJQnxoSPM31eI xs9w== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x8si9294437plo.259.2019.01.10.05.49.43; Thu, 10 Jan 2019 05:49:43 -0800 (PST) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729080AbfAJNtb (ORCPT + 31 others); Thu, 10 Jan 2019 08:49:31 -0500 Received: from mx08-00178001.pphosted.com ([91.207.212.93]:45158 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729010AbfAJNt1 (ORCPT ); Thu, 10 Jan 2019 08:49:27 -0500 Received: from pps.filterd (m0046661.ppops.net [127.0.0.1]) by mx08-00178001.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x0ADf3oF008201; Thu, 10 Jan 2019 14:49:22 +0100 Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx08-00178001.pphosted.com with ESMTP id 2ptvjg2ptn-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Thu, 10 Jan 2019 14:49:22 +0100 Received: from zeta.dmz-eu.st.com (zeta.dmz-eu.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id AA93234; Thu, 10 Jan 2019 13:49:21 +0000 (GMT) Received: from Webmail-eu.st.com (Safex1hubcas22.st.com [10.75.90.92]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 8A08A504C; Thu, 10 Jan 2019 13:49:21 +0000 (GMT) Received: from SAFEX1HUBCAS21.st.com (10.75.90.45) by Safex1hubcas22.st.com (10.75.90.92) with Microsoft SMTP Server (TLS) id 14.3.361.1; Thu, 10 Jan 2019 14:49:21 +0100 Received: from localhost (10.201.20.178) by Webmail-ga.st.com (10.75.90.48) with Microsoft SMTP Server (TLS) id 14.3.361.1; Thu, 10 Jan 2019 14:49:20 +0100 From: Loic Pallardy To: , CC: , , , , , Loic Pallardy Subject: [PATCH v2 2/7] remoteproc: fix rproc_da_to_va in case of unallocated carveout Date: Thu, 10 Jan 2019 14:49:06 +0100 Message-ID: <1547128151-44077-3-git-send-email-loic.pallardy@st.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1547128151-44077-1-git-send-email-loic.pallardy@st.com> References: <1547128151-44077-1-git-send-email-loic.pallardy@st.com> MIME-Version: 1.0 X-Originating-IP: [10.201.20.178] X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2019-01-10_05:, , signatures=0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org With introduction of rproc_alloc_registered_carveouts() which delays carveout allocation just before the start of the remote processor, rproc_da_to_va() could be called before all carveouts are allocated. This patch adds a check in rproc_da_to_va() to return NULL if carveout is not allocated. Fixes: d7c51706d095 ("remoteproc: add alloc ops in rproc_mem_entry struct") Signed-off-by: Loic Pallardy --- drivers/remoteproc/remoteproc_core.c | 4 ++++ 1 file changed, 4 insertions(+) -- 2.7.4 diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index c1a66e25b173..28df71cb3fef 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -204,6 +204,10 @@ void *rproc_da_to_va(struct rproc *rproc, u64 da, int len) list_for_each_entry(carveout, &rproc->carveouts, node) { int offset = da - carveout->da; + /* Verify that carveout is allocated */ + if (!carveout->va) + continue; + /* try next carveout if da is too small */ if (offset < 0) continue; From patchwork Thu Jan 10 13:49:07 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Loic Pallardy X-Patchwork-Id: 155166 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp1916246jaa; Thu, 10 Jan 2019 05:50:03 -0800 (PST) X-Google-Smtp-Source: ALg8bN6XitBrWUW3HN67D9asGpcYdrZpjRiasG0snY3iDFqxPdCuz0frxYGlLlYIkQmFkFvrfRuW X-Received: by 2002:a65:4784:: with SMTP id e4mr9302910pgs.12.1547128203251; Thu, 10 Jan 2019 05:50:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547128203; cv=none; d=google.com; s=arc-20160816; b=G/jPqv2bme2VuIncmb9on9E7hR9MAm5GcEBiX5EQHOBMgOS4bxFuSunfq9wj0t6bD1 kLD/x5e9pWKiAsHf0RSVT3iUfverGpnunEWhBoad+1r5ysKIZYZ84POPCk9t+ApdeZBK z7329If9d5f+PsCHcmPoJLKAzvU3S8qb2NVAGWTjx5LANLZcq7cXUTcw6NswjNUzc+hx bHJLrTUl/r8XYxtJVX0DHW6kFZzlnpoXOEYDwIa8lbglJTY2HIWdf4dC1atPSq/KQRN6 bNj/M0TN05YDO5jszlYWGpToDwxk30ZDSplxXVoZZmq/M32hiUzAsleXbQ0YGgVK3JRR 7n8Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=rA8fav55VQysb1+JBFtRkjuVugYeszaFL50PCkyjE7U=; b=OueHGCt1/otsMA/RjKqkNQrtUpdZgilPy2BrSMViHMWwE9W2avZxSJpnOUNf23p3IL TiyZkHQuP0HnnC3yAuMcek+WyewRiFZes8AGTazEa0SmD+7Q7gbMzxRrdNEpyzEcGfIk 2SoyJGKNvpyHZNeGo1uU2abdMric1PCGQic0ka6+D5R+qEHITpxs2ioLdU9+jNMNOwkJ UjcvgLTRowBArMHmjRqq1mdo0kB2kQ7gnz3UyWfNrTNlmv1jO2/HzYOoblv4TlMo2Dzj qqXxhrC5R5H6zD6oho/7zJ/ZsPuB9KVY9o2IPnC56MZtf0ZQ1TF0Y6Vr8HQqe8fN6OWJ pv8w== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l123si373645pfc.187.2019.01.10.05.50.02; Thu, 10 Jan 2019 05:50:03 -0800 (PST) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729159AbfAJNuC (ORCPT + 31 others); Thu, 10 Jan 2019 08:50:02 -0500 Received: from mx08-00178001.pphosted.com ([91.207.212.93]:18251 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729011AbfAJNt1 (ORCPT ); Thu, 10 Jan 2019 08:49:27 -0500 Received: from pps.filterd (m0046660.ppops.net [127.0.0.1]) by mx08-00178001.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x0ADgC0c012603; Thu, 10 Jan 2019 14:49:23 +0100 Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx08-00178001.pphosted.com with ESMTP id 2ptt12b5ye-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Thu, 10 Jan 2019 14:49:23 +0100 Received: from zeta.dmz-eu.st.com (zeta.dmz-eu.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id B1C963D; Thu, 10 Jan 2019 13:49:22 +0000 (GMT) Received: from Webmail-eu.st.com (Safex1hubcas23.st.com [10.75.90.46]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 9860E504E; Thu, 10 Jan 2019 13:49:22 +0000 (GMT) Received: from SAFEX1HUBCAS21.st.com (10.75.90.45) by SAFEX1HUBCAS23.st.com (10.75.90.46) with Microsoft SMTP Server (TLS) id 14.3.361.1; Thu, 10 Jan 2019 14:49:22 +0100 Received: from localhost (10.201.20.178) by Webmail-ga.st.com (10.75.90.48) with Microsoft SMTP Server (TLS) id 14.3.361.1; Thu, 10 Jan 2019 14:49:21 +0100 From: Loic Pallardy To: , CC: , , , , , Loic Pallardy Subject: [PATCH v2 3/7] remoteproc: fix rproc_alloc_carveout() bad variable cast Date: Thu, 10 Jan 2019 14:49:07 +0100 Message-ID: <1547128151-44077-4-git-send-email-loic.pallardy@st.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1547128151-44077-1-git-send-email-loic.pallardy@st.com> References: <1547128151-44077-1-git-send-email-loic.pallardy@st.com> MIME-Version: 1.0 X-Originating-IP: [10.201.20.178] X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2019-01-10_05:, , signatures=0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org As dma member of struct rproc_mem_entry is dma_addr_t, no need to cast in u32. Fixes: d7c51706d095 ("remoteproc: add alloc ops in rproc_mem_entry struct") Signed-off-by: Loic Pallardy --- drivers/remoteproc/remoteproc_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.7.4 diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index 28df71cb3fef..18a1bbf820c9 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -775,7 +775,7 @@ static int rproc_alloc_carveout(struct rproc *rproc, mem->da = (u32)dma; } - mem->dma = (u32)dma; + mem->dma = dma; mem->va = va; return 0; From patchwork Thu Jan 10 13:49:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Loic Pallardy X-Patchwork-Id: 155161 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp1915816jaa; Thu, 10 Jan 2019 05:49:34 -0800 (PST) X-Google-Smtp-Source: ALg8bN5eOZsBo24I5HwRHDMzFU/K3ytGWcDCLqf9qiGEN52aRnTBnCvt9lCQWJOCbqp7CvVd2Bqg X-Received: by 2002:a63:1204:: with SMTP id h4mr9435310pgl.51.1547128174695; Thu, 10 Jan 2019 05:49:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547128174; cv=none; d=google.com; s=arc-20160816; b=D/mc5+unVM3eOWYcb3oczhcOcC7siUg+nd5S/lUoOrQXrh/7X8/+vcP+x7WnjliL0u 5yCOJl3vbGyuVQw1IEVqPEPUuO/kwlaDnMo9lyRjSATH8qpSFViSqTCSUEBMlSRX1GJF j5A04C2NVoCiE34pzyFzyv+/l3XNiCiG1NAQqbd0D09ZWejBBy30C50aYov83ak3EFQw KcUSlP++uwMEUVmjKikjCG3JYXASIVzhrY1ndaNWpVeYXCX14IJ+TQ61bvGlxDse8+zA pwkuwNHSDvuJpnwlfCXLpXzNNn6gZyOJEZ7OpRqQWJ5v+WAPnwxe9xs9opIGln7eRJxa fPSg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=cI9A+allQFcEpqsaTSUhcuR3/wZymitu3e5NCjn3BsY=; b=LHRaZeOUNYukoC+PUoWUEpIdfC4UEhwG8BqBTJN6OHbrTuPHjKlSMKtO14uXCY9ZYT uu/1Y207N4bTgGxe+Bz3j7gEwBDnC5wE6j/cJ2+CnzUBOh7WpCZHDFh+QclorEPGItjG frsEOXcJZayUhKx/74lQu/kZ5rv3AKlfJ/MPp119hhy0p+iAHjqjcEBk9WN8qvPJoEqQ uU7Fcn5oTGnfIXZDQlf/F5iYK+3xKyTfxEOlX3sxezEU4ommy8dyAGrDvKt4c8u/9gIl wVz5RbcQqOeVpR/cl3g6/zm4mEAB8qiDGVCnScsIgv3jtjZL8ZGL67SubkV7uaU2MZ0Q uRoQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x8si9294437plo.259.2019.01.10.05.49.34; Thu, 10 Jan 2019 05:49:34 -0800 (PST) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729098AbfAJNtc (ORCPT + 31 others); Thu, 10 Jan 2019 08:49:32 -0500 Received: from mx07-00178001.pphosted.com ([62.209.51.94]:32071 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729023AbfAJNt2 (ORCPT ); Thu, 10 Jan 2019 08:49:28 -0500 Received: from pps.filterd (m0046668.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x0ADfOr8008990; Thu, 10 Jan 2019 14:49:24 +0100 Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 2ptwtdsw0u-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Thu, 10 Jan 2019 14:49:24 +0100 Received: from zeta.dmz-eu.st.com (zeta.dmz-eu.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id E345234; Thu, 10 Jan 2019 13:49:23 +0000 (GMT) Received: from Webmail-eu.st.com (Safex1hubcas22.st.com [10.75.90.92]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id C6CEE504D; Thu, 10 Jan 2019 13:49:23 +0000 (GMT) Received: from SAFEX1HUBCAS21.st.com (10.75.90.45) by Safex1hubcas22.st.com (10.75.90.92) with Microsoft SMTP Server (TLS) id 14.3.361.1; Thu, 10 Jan 2019 14:49:23 +0100 Received: from localhost (10.201.20.178) by Webmail-ga.st.com (10.75.90.48) with Microsoft SMTP Server (TLS) id 14.3.361.1; Thu, 10 Jan 2019 14:49:22 +0100 From: Loic Pallardy To: , CC: , , , , , Loic Pallardy Subject: [PATCH v2 4/7] remoteproc: add warning on resource table cast Date: Thu, 10 Jan 2019 14:49:08 +0100 Message-ID: <1547128151-44077-5-git-send-email-loic.pallardy@st.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1547128151-44077-1-git-send-email-loic.pallardy@st.com> References: <1547128151-44077-1-git-send-email-loic.pallardy@st.com> MIME-Version: 1.0 X-Originating-IP: [10.201.20.178] X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2019-01-10_05:, , signatures=0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Today resource table supports only 32bit address fields. This is not compliant with 64bit platform for which addresses are cast in 32bit. This patch adds warn messages when address cast is done. Signed-off-by: Loic Pallardy --- Changes from v1: - modify implementation to display warning message only when data are modified by cast operation --- drivers/remoteproc/remoteproc_core.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) -- 2.7.4 diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index 18a1bbf820c9..0ecd37993f41 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -45,6 +45,8 @@ #include "remoteproc_internal.h" +#define HIGH_BITS_MASK 0xFFFFFFFF00000000ULL + static DEFINE_MUTEX(rproc_list_mutex); static LIST_HEAD(rproc_list); @@ -772,6 +774,10 @@ static int rproc_alloc_carveout(struct rproc *rproc, dev_dbg(dev, "carveout mapped 0x%x to %pad\n", mem->da, &dma); } else { + /* Update device address as undefined by requester */ + if ((u64)dma & HIGH_BITS_MASK) + dev_warn(dev, "DMA address cast in 32bit to fit resource table format\n"); + mem->da = (u32)dma; } @@ -1115,6 +1121,7 @@ static int rproc_alloc_registered_carveouts(struct rproc *rproc) struct rproc_mem_entry *entry, *tmp; struct fw_rsc_carveout *rsc; struct device *dev = &rproc->dev; + u64 pa; int ret; list_for_each_entry_safe(entry, tmp, &rproc->carveouts, node) { @@ -1151,10 +1158,15 @@ static int rproc_alloc_registered_carveouts(struct rproc *rproc) /* Use va if defined else dma to generate pa */ if (entry->va) - rsc->pa = (u32)rproc_va_to_pa(entry->va); + pa = (u64)rproc_va_to_pa(entry->va); else - rsc->pa = (u32)entry->dma; + pa = (u64)entry->dma; + + if (((u64)pa) & HIGH_BITS_MASK) + dev_warn(dev, + "Physical address cast in 32bit to fit resource table format\n"); + rsc->pa = (u32)pa; rsc->da = entry->da; rsc->len = entry->len; } From patchwork Thu Jan 10 13:49:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Loic Pallardy X-Patchwork-Id: 155165 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp1916178jaa; Thu, 10 Jan 2019 05:49:57 -0800 (PST) X-Google-Smtp-Source: ALg8bN6XzGD4+kyGf6m/StLJ4g7KSQQharWiNAevYSrQkCuU0feMrCVpmWS973xz1Yk40IEGZHgQ X-Received: by 2002:a63:9809:: with SMTP id q9mr9484834pgd.109.1547128197837; Thu, 10 Jan 2019 05:49:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547128197; cv=none; d=google.com; s=arc-20160816; b=fL5mikTIPodcf6uoX53L+zncpYE9t764ecJ0CR97WfFcE3a5RSNCiUavGlRHSYMW6j 14u3kLiRarD8Y1BhWWdrasVuOL/V4HMVVqoLeK9q2plfLlTh14csTK7fHaJ3q6TnfcdF w7r5o8T4cJPZucsAAiS8ujW1Sx+xq9jHSev1TPLssMw/pOa/LUUzSOhJ2QmakWoKKvSp EKwr50IL5a2FyJ+uUK3ABzj5OZvkIXr0A1dRjWkPlr07u4lgcubqrlk4J99rarOJ+lQu z6NfnbsToRCwGuBWuh8LT8KyeX6pvBaktV0p5WXcCQzaRki9fFa+jeAv06K2Bb/T34Ce IBPw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=LtbXhcTX37j3sqIOKcX8s/DC9p3Qh7QlITQygv/AnDk=; b=zB4ZhMa9VXh96MN+ovH8uklPgJzRNd/KpJgGukVVKoVr5jVGldb3bb0tBDjdeLAGv2 VYWe30OBO4MVyiGNpZO8rSb0kE+KBhJyU1+2eg1fXULsHVxMNnr2CoB2enfImp+ISfMg PoGo/m0xPP2aZV4rzOLmI+ZDf0N1WCVHe1nrL+MLCIb6Wmu/oefOYJN5sQ2uuVCplQS1 nCL+FviNsW/mWlWBCH7k0ZeFQYXyeLfAFGtnSrmNtGK/9Cs+XDAnjFwbPoVP4ssUXRNH b2ZiShRgP0tozl9KUJmhx9LqZiUUQQi2jLMTV9q0lZ4oN2yKApPLVegUSXwRzovYd5/a RGqg== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l123si373645pfc.187.2019.01.10.05.49.57; Thu, 10 Jan 2019 05:49:57 -0800 (PST) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729134AbfAJNtr (ORCPT + 31 others); Thu, 10 Jan 2019 08:49:47 -0500 Received: from mx07-00178001.pphosted.com ([62.209.51.94]:56059 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729056AbfAJNtb (ORCPT ); Thu, 10 Jan 2019 08:49:31 -0500 Received: from pps.filterd (m0046037.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x0ADfeXi000390; Thu, 10 Jan 2019 14:49:25 +0100 Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 2ptybn9m4m-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Thu, 10 Jan 2019 14:49:25 +0100 Received: from zeta.dmz-eu.st.com (zeta.dmz-eu.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id D6B2D38; Thu, 10 Jan 2019 13:49:24 +0000 (GMT) Received: from Webmail-eu.st.com (Safex1hubcas24.st.com [10.75.90.94]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id BB503504D; Thu, 10 Jan 2019 13:49:24 +0000 (GMT) Received: from SAFEX1HUBCAS21.st.com (10.75.90.45) by Safex1hubcas24.st.com (10.75.90.94) with Microsoft SMTP Server (TLS) id 14.3.361.1; Thu, 10 Jan 2019 14:49:24 +0100 Received: from localhost (10.201.20.178) by Webmail-ga.st.com (10.75.90.48) with Microsoft SMTP Server (TLS) id 14.3.361.1; Thu, 10 Jan 2019 14:49:24 +0100 From: Loic Pallardy To: , CC: , , , , , Loic Pallardy Subject: [PATCH v2 5/7] remoteproc: fix rproc_alloc_carveout() for rproc with iommu domain Date: Thu, 10 Jan 2019 14:49:09 +0100 Message-ID: <1547128151-44077-6-git-send-email-loic.pallardy@st.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1547128151-44077-1-git-send-email-loic.pallardy@st.com> References: <1547128151-44077-1-git-send-email-loic.pallardy@st.com> MIME-Version: 1.0 X-Originating-IP: [10.201.20.178] X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2019-01-10_04:, , signatures=0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Correct remoteproc core behavior when memory carveout device address is fixed in resource table and rproc device doesn't have associated IOMMU. Current returned error is breaking legacy on TI platforms. This patch restores previous behavior. It adds a warn message when allocation doesn't fit carveout request, but doesn't stop rproc_start() sequence anymore. Fixes: 3bc8140b157c ("remoteproc: configure IOMMU only if device address requested") Signed-off-by: Loic Pallardy --- drivers/remoteproc/remoteproc_core.c | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) -- 2.7.4 diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index 0ecd37993f41..e85722ee156b 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -721,6 +721,18 @@ static int rproc_alloc_carveout(struct rproc *rproc, dev_dbg(dev, "carveout va %pK, dma %pad, len 0x%x\n", va, &dma, mem->len); + if (mem->da != FW_RSC_ADDR_ANY && !rproc->domain) { + /* + * Check requested da is equal to dma address + * and print a warn message in case of missalignment. + * Don't stop rproc_start sequence as coprocessor may + * build pa to da translation on its side. + */ + if (mem->da != (u32)dma) + dev_warn(dev->parent, + "Allocated carveout doesn't fit device address request\n"); + } + /* * Ok, this is non-standard. * @@ -738,15 +750,7 @@ static int rproc_alloc_carveout(struct rproc *rproc, * to use the iommu-based DMA API: we expect 'dma' to contain the * physical address in this case. */ - - if (mem->da != FW_RSC_ADDR_ANY) { - if (!rproc->domain) { - dev_err(dev->parent, - "Bad carveout rsc configuration\n"); - ret = -ENOMEM; - goto dma_free; - } - + if (mem->da != FW_RSC_ADDR_ANY && rproc->domain) { mapping = kzalloc(sizeof(*mapping), GFP_KERNEL); if (!mapping) { ret = -ENOMEM; @@ -773,7 +777,9 @@ static int rproc_alloc_carveout(struct rproc *rproc, dev_dbg(dev, "carveout mapped 0x%x to %pad\n", mem->da, &dma); - } else { + } + + if (mem->da == FW_RSC_ADDR_ANY) { /* Update device address as undefined by requester */ if ((u64)dma & HIGH_BITS_MASK) dev_warn(dev, "DMA address cast in 32bit to fit resource table format\n"); From patchwork Thu Jan 10 13:49:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Loic Pallardy X-Patchwork-Id: 155164 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp1916096jaa; Thu, 10 Jan 2019 05:49:52 -0800 (PST) X-Google-Smtp-Source: ALg8bN47mLX0SRONOLuisXuskCkbZAThCvCxaL5W8EphUhxISLHZo5lQTD+/iljk5gBZJf+S6DrA X-Received: by 2002:a17:902:29ab:: with SMTP id h40mr10360438plb.238.1547128192408; Thu, 10 Jan 2019 05:49:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547128192; cv=none; d=google.com; s=arc-20160816; b=YhdHObUEKK39w2yTrsBOLYSjcqeV1KBxV9NSiVm3LsYqyB83/5clIxGUdDhcc2OfmE JyZiQz6xEnM3z74Grr4GuApTQjMoNwfyB17sd/b/mc7Jj2K3Muts0gQQxO+79nvycMgj PoL30KtPnIFyTC4G2YPYyYbwWEgc/IPIjZWDLMZon+ZJfgPF1HpRcCYVpbh0NfDOJ37P BBS3GZ25s2H7GeR2FTDaTHfqJuSu7pN0MW/co/umn65LO2KECMzAy145hAY3aOnROBfU a2VAbZorfy/9h3fsie27pBYTWGKjH2BzhHQ33Jp4IL2+imz/5Z+YOyZ/VGQa+k9Ol02H Tw1g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=slRnIFFKanCWJdTK/qdc0q2AH1m28Lp2/OfXrvGtEUo=; b=njw7AdxdOACDsgNYpPcQbieZcXiZMhuHmwpyP68FWzB0/bfYGZmpvNtBPWMizMVxWP R9uzPW4TLLzEJJjJ8uVJVAYFYChLTDMV4yoFaFZXecFo1ENs7IXxBRFBqTTvOQpWvrVH ZKPPi1Wes5XIPhREXEqqZk6rVOg+fbi3MAtuFzwfJJrMX2DnVWNW8kev6BejSBvk2P8u tnam3KqB+IRJ4GePBGH+D2FehclcPQ6ZEJzP628O5xueP7rAqXpPtVGzURfWrpbB+HWf EGzm6WiYVGY0v5uDZ2xCYgXj3nPRT7iTV6XpJK1r6U7xzgKvQOetW7t0wQIRyhGIRtTk Vn4w== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q17si5702646pfc.198.2019.01.10.05.49.52; Thu, 10 Jan 2019 05:49:52 -0800 (PST) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729152AbfAJNtv (ORCPT + 31 others); Thu, 10 Jan 2019 08:49:51 -0500 Received: from mx08-00178001.pphosted.com ([91.207.212.93]:45171 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729055AbfAJNta (ORCPT ); Thu, 10 Jan 2019 08:49:30 -0500 Received: from pps.filterd (m0046661.ppops.net [127.0.0.1]) by mx08-00178001.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x0ADf3T3008196; Thu, 10 Jan 2019 14:49:26 +0100 Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx08-00178001.pphosted.com with ESMTP id 2ptvjg2pu3-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Thu, 10 Jan 2019 14:49:26 +0100 Received: from zeta.dmz-eu.st.com (zeta.dmz-eu.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id E17AF31; Thu, 10 Jan 2019 13:49:25 +0000 (GMT) Received: from Webmail-eu.st.com (Safex1hubcas23.st.com [10.75.90.46]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id C113E504C; Thu, 10 Jan 2019 13:49:25 +0000 (GMT) Received: from SAFEX1HUBCAS21.st.com (10.75.90.45) by SAFEX1HUBCAS23.st.com (10.75.90.46) with Microsoft SMTP Server (TLS) id 14.3.361.1; Thu, 10 Jan 2019 14:49:25 +0100 Received: from localhost (10.201.20.178) by Webmail-ga.st.com (10.75.90.48) with Microsoft SMTP Server (TLS) id 14.3.361.1; Thu, 10 Jan 2019 14:49:25 +0100 From: Loic Pallardy To: , CC: , , , , , Loic Pallardy Subject: [PATCH v2 6/7] remoteproc: fix trace buffer va initialization Date: Thu, 10 Jan 2019 14:49:10 +0100 Message-ID: <1547128151-44077-7-git-send-email-loic.pallardy@st.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1547128151-44077-1-git-send-email-loic.pallardy@st.com> References: <1547128151-44077-1-git-send-email-loic.pallardy@st.com> MIME-Version: 1.0 X-Originating-IP: [10.201.20.178] X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2019-01-10_05:, , signatures=0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org With rproc_alloc_registered_carveouts() introduction, carveouts are allocated after resource table parsing. rproc_da_to_va() may return NULL at trace resource registering. This patch modifies trace debufs registering to provide device address (da) instead of va. da to va translation is done at each trace buffer access through debugfs interface. Fixes: d7c51706d095 ("remoteproc: add alloc ops in rproc_mem_entry struct") Signed-off-by: Loic Pallardy --- Changes from v1: - Add missing implementation in rproc_resources_cleanup() --- drivers/remoteproc/remoteproc_core.c | 35 ++++++++++++++------------------ drivers/remoteproc/remoteproc_debugfs.c | 21 +++++++++++++++---- drivers/remoteproc/remoteproc_internal.h | 9 +++++++- 3 files changed, 40 insertions(+), 25 deletions(-) -- 2.7.4 diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index e85722ee156b..45d97871ca69 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -564,9 +564,8 @@ void rproc_vdev_release(struct kref *ref) static int rproc_handle_trace(struct rproc *rproc, struct fw_rsc_trace *rsc, int offset, int avail) { - struct rproc_mem_entry *trace; + struct rproc_debug_trace *trace; struct device *dev = &rproc->dev; - void *ptr; char name[15]; if (sizeof(*rsc) > avail) { @@ -580,28 +579,23 @@ static int rproc_handle_trace(struct rproc *rproc, struct fw_rsc_trace *rsc, return -EINVAL; } - /* what's the kernel address of this resource ? */ - ptr = rproc_da_to_va(rproc, rsc->da, rsc->len); - if (!ptr) { - dev_err(dev, "erroneous trace resource entry\n"); - return -EINVAL; - } - trace = kzalloc(sizeof(*trace), GFP_KERNEL); if (!trace) return -ENOMEM; /* set the trace buffer dma properties */ - trace->len = rsc->len; - trace->va = ptr; + trace->trace_mem.len = rsc->len; + trace->trace_mem.da = rsc->da; + + /* set pointer on rproc device */ + trace->rproc = rproc; /* make sure snprintf always null terminates, even if truncating */ snprintf(name, sizeof(name), "trace%d", rproc->num_traces); /* create the debugfs entry */ - trace->priv = rproc_create_trace_file(name, rproc, trace); - if (!trace->priv) { - trace->va = NULL; + trace->tfile = rproc_create_trace_file(name, rproc, trace); + if (!trace->tfile) { kfree(trace); return -EINVAL; } @@ -610,8 +604,8 @@ static int rproc_handle_trace(struct rproc *rproc, struct fw_rsc_trace *rsc, rproc->num_traces++; - dev_dbg(dev, "%s added: va %pK, da 0x%x, len 0x%x\n", - name, ptr, rsc->da, rsc->len); + dev_dbg(dev, "%s added: da 0x%x, len 0x%x\n", + name, rsc->da, rsc->len); return 0; } @@ -1205,15 +1199,16 @@ static void rproc_coredump_cleanup(struct rproc *rproc) static void rproc_resource_cleanup(struct rproc *rproc) { struct rproc_mem_entry *entry, *tmp; + struct rproc_debug_trace *trace, *ttmp; struct rproc_vdev *rvdev, *rvtmp; struct device *dev = &rproc->dev; /* clean up debugfs trace entries */ - list_for_each_entry_safe(entry, tmp, &rproc->traces, node) { - rproc_remove_trace_file(entry->priv); + list_for_each_entry_safe(trace, ttmp, &rproc->traces, node) { + rproc_remove_trace_file(trace->tfile); rproc->num_traces--; - list_del(&entry->node); - kfree(entry); + list_del(&trace->node); + kfree(trace); } /* clean up iommu mapping entries */ diff --git a/drivers/remoteproc/remoteproc_debugfs.c b/drivers/remoteproc/remoteproc_debugfs.c index e90135c64af0..11240b4d0a91 100644 --- a/drivers/remoteproc/remoteproc_debugfs.c +++ b/drivers/remoteproc/remoteproc_debugfs.c @@ -47,10 +47,23 @@ static struct dentry *rproc_dbg; static ssize_t rproc_trace_read(struct file *filp, char __user *userbuf, size_t count, loff_t *ppos) { - struct rproc_mem_entry *trace = filp->private_data; - int len = strnlen(trace->va, trace->len); + struct rproc_debug_trace *data = filp->private_data; + struct rproc_mem_entry *trace = &data->trace_mem; + void *va; + char buf[100]; + int len; + + va = rproc_da_to_va(data->rproc, trace->da, trace->len); + + if (!va) { + len = scnprintf(buf, sizeof(buf), "Trace %s not available\n", + trace->name); + va = buf; + } else { + len = strnlen(va, trace->len); + } - return simple_read_from_buffer(userbuf, count, ppos, trace->va, len); + return simple_read_from_buffer(userbuf, count, ppos, va, len); } static const struct file_operations trace_rproc_ops = { @@ -288,7 +301,7 @@ void rproc_remove_trace_file(struct dentry *tfile) } struct dentry *rproc_create_trace_file(const char *name, struct rproc *rproc, - struct rproc_mem_entry *trace) + struct rproc_debug_trace *trace) { struct dentry *tfile; diff --git a/drivers/remoteproc/remoteproc_internal.h b/drivers/remoteproc/remoteproc_internal.h index f6cad243d7ca..7d8936688164 100644 --- a/drivers/remoteproc/remoteproc_internal.h +++ b/drivers/remoteproc/remoteproc_internal.h @@ -25,6 +25,13 @@ struct rproc; +struct rproc_debug_trace { + struct rproc *rproc; + struct dentry *tfile; + struct list_head node; + struct rproc_mem_entry trace_mem; +}; + /* from remoteproc_core.c */ void rproc_release(struct kref *kref); irqreturn_t rproc_vq_interrupt(struct rproc *rproc, int vq_id); @@ -37,7 +44,7 @@ void rproc_remove_virtio_dev(struct rproc_vdev *rvdev); /* from remoteproc_debugfs.c */ void rproc_remove_trace_file(struct dentry *tfile); struct dentry *rproc_create_trace_file(const char *name, struct rproc *rproc, - struct rproc_mem_entry *trace); + struct rproc_debug_trace *trace); void rproc_delete_debug_dir(struct rproc *rproc); void rproc_create_debug_dir(struct rproc *rproc); void rproc_init_debugfs(void); From patchwork Thu Jan 10 13:49:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Loic Pallardy X-Patchwork-Id: 155162 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp1915895jaa; Thu, 10 Jan 2019 05:49:39 -0800 (PST) X-Google-Smtp-Source: ALg8bN6oMR5qezVaJxhSayQrH/vF+n5S2a3ANSwvyfOkMj2CigoXnIwmHRK9Q3Mu4f7LsAz4g3AV X-Received: by 2002:a63:5b1f:: with SMTP id p31mr9380962pgb.56.1547128179251; Thu, 10 Jan 2019 05:49:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547128179; cv=none; d=google.com; s=arc-20160816; b=IUQngfX+1hTugSWY5RLVbwq+iM/zoSLK83v/ijiUEkHfqNawDMVCUD8RqPuEY9iZKN Dkg17vAeTtCL9h1CNbKWR+aCA7TFVfsXiMjLCgJpwDmN/JrGtWKxNIA3feodW1fKh2bj B2RijlKPXX1jZ863VrKsJNi3V/P6iWnBmWVLdUVOumeEhmRsz40gHL5lCPEB37OVMZTU ssZh/7rZ+JA32SaiB+vTVtRVIB2O5+GILFtTCtrDrFkeSRtqCtKGMrlqYdj7B+1G40LF D/c6D9FqF5XoyMbgRPsYOl3lLKsUiPfZW2VUXBbpkHocKw4IlpZnf3p6rcQukq2FvHOT OC5A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=oc26J+isWafGaTatzwdOstAV+HdG4YtCBSFc8EzUpHE=; b=HrmFrtcgv9bEHfj7lPMQ4Y2FCVcC2KEZiKyFS8ds6y75GKHmd2NSygBfd8U3UJmZVZ whXo6X8C7phfhFEfLR5cEzCIfyHcfmMuPajkV5CkkmodTZvUrnl7ZIPPipPEVSd+IgLa ofchr+/8KKYwTy+g6WW5I7pqfWKfFsWtVWT22tVXGfGmR1VOJqiYy0RtaKVspqZWTlw3 yt6Y+RKpeIsynY+u7nYrXBDNBbC1Xx4TuOKy549Pg+lNxNa7HEKh/8xVm5wfix3gLv72 00CeXauUwaGvwclWgRErZonjhP/k7C5WOAVB3I2PvT0Zs7rn+7NJ9qjoJPN/GFjO20Df iv6A== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x8si9294437plo.259.2019.01.10.05.49.38; Thu, 10 Jan 2019 05:49:39 -0800 (PST) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729119AbfAJNth (ORCPT + 31 others); Thu, 10 Jan 2019 08:49:37 -0500 Received: from mx08-00178001.pphosted.com ([91.207.212.93]:45172 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729071AbfAJNtc (ORCPT ); Thu, 10 Jan 2019 08:49:32 -0500 Received: from pps.filterd (m0046661.ppops.net [127.0.0.1]) by mx08-00178001.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x0ADf37u008195; Thu, 10 Jan 2019 14:49:27 +0100 Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx08-00178001.pphosted.com with ESMTP id 2ptvjg2pu5-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Thu, 10 Jan 2019 14:49:27 +0100 Received: from zeta.dmz-eu.st.com (zeta.dmz-eu.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 0787F38; Thu, 10 Jan 2019 13:49:27 +0000 (GMT) Received: from Webmail-eu.st.com (Safex1hubcas22.st.com [10.75.90.92]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id E4681504E; Thu, 10 Jan 2019 13:49:26 +0000 (GMT) Received: from SAFEX1HUBCAS21.st.com (10.75.90.45) by Safex1hubcas22.st.com (10.75.90.92) with Microsoft SMTP Server (TLS) id 14.3.361.1; Thu, 10 Jan 2019 14:49:26 +0100 Received: from localhost (10.201.20.178) by Webmail-ga.st.com (10.75.90.48) with Microsoft SMTP Server (TLS) id 14.3.361.1; Thu, 10 Jan 2019 14:49:26 +0100 From: Loic Pallardy To: , CC: , , , , , Loic Pallardy Subject: [PATCH v2 7/7] remoteproc: fix rproc_check_carveout_da() returned error and comments Date: Thu, 10 Jan 2019 14:49:11 +0100 Message-ID: <1547128151-44077-8-git-send-email-loic.pallardy@st.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1547128151-44077-1-git-send-email-loic.pallardy@st.com> References: <1547128151-44077-1-git-send-email-loic.pallardy@st.com> MIME-Version: 1.0 X-Originating-IP: [10.201.20.178] X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2019-01-10_05:, , signatures=0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Fix typo in comments. Change returned error from ENOMEM to EINVAL as not dealing with memory allocation. Remove carveout forced da update and return an error when no configuration match Fixes: c874bf59add0 ("remoteproc: add helper function to check carveout device address") Signed-off-by: Loic Pallardy --- drivers/remoteproc/remoteproc_core.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) -- 2.7.4 diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index 45d97871ca69..fc9bf99cd96f 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -278,25 +278,27 @@ rproc_find_carveout_by_name(struct rproc *rproc, const char *name, ...) * @len: associated area size * * This function is a helper function to verify requested device area (couple - * da, len) is part of specified carevout. + * da, len) is part of specified carveout. + * If da is not set (defined as FW_RSC_ADDR_ANY), only requested length is + * checked. * - * Return: 0 if carveout match request else -ENOMEM + * Return: 0 if carveout matches request else error */ -int rproc_check_carveout_da(struct rproc *rproc, struct rproc_mem_entry *mem, - u32 da, u32 len) +static int rproc_check_carveout_da(struct rproc *rproc, + struct rproc_mem_entry *mem, u32 da, u32 len) { struct device *dev = &rproc->dev; - int delta = 0; + int delta; /* Check requested resource length */ if (len > mem->len) { dev_err(dev, "Registered carveout doesn't fit len request\n"); - return -ENOMEM; + return -EINVAL; } if (da != FW_RSC_ADDR_ANY && mem->da == FW_RSC_ADDR_ANY) { - /* Update existing carveout da */ - mem->da = da; + /* Address doesn't match registered carveout configuration */ + return -EINVAL; } else if (da != FW_RSC_ADDR_ANY && mem->da != FW_RSC_ADDR_ANY) { delta = da - mem->da; @@ -304,13 +306,13 @@ int rproc_check_carveout_da(struct rproc *rproc, struct rproc_mem_entry *mem, if (delta < 0) { dev_err(dev, "Registered carveout doesn't fit da request\n"); - return -ENOMEM; + return -EINVAL; } if (delta + len > mem->len) { dev_err(dev, "Registered carveout doesn't fit len request\n"); - return -ENOMEM; + return -EINVAL; } }