From patchwork Thu Nov 29 21:29:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Loic Pallardy X-Patchwork-Id: 152459 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp2887797ljp; Thu, 29 Nov 2018 13:29:50 -0800 (PST) X-Google-Smtp-Source: AFSGD/Xk6v95wrD9c1ddbCaLkbYbdYiKFiiruxnx14otbOgej8Zhn6ap++yRVTBQwbX52SDrQ5kI X-Received: by 2002:a17:902:4681:: with SMTP id p1mr3175148pld.184.1543526989944; Thu, 29 Nov 2018 13:29:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543526989; cv=none; d=google.com; s=arc-20160816; b=ZSDt4/PZKqBoR6NFAAzqdXWnbwQCLzN6QL+PMDMNRjGEGqHp6ntxf8Cz2DYxLjpomf KP2S/Um2ftfiv5xYEqQ4D77zMuYUu2kFDjhQ9fX5RfPxWaeqEBkiV7GLXk4H16UWXk8k vI+fe7tmY1urJQZEr1vUB//2pCmSI8S7VWD31+BCPGCjTqz+aj4G3dlF3slW0hosLShm y+ekvXFJWiCYuAZvxFuhY6inJfvYMGREWVw01YazLl2imJkTdaI98UXRE2tXaPVqrw3o DjgH2q4XUP09NdsL4cEGm8bR3O3VwdyGuzgkMD6ix6Wo+FsbTnZLPpXT0GUMAoOJ5bC8 PaJw== 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=QjgkYydcPQ19a8RRYgxBA0+hBjt8Z2TiwahP41fs1RmBF7qVFf/8spMRdxBCfjVus3 n2zNPCTKtnM+lnsXSuRxVWT00fMtYm7CxmOuHtWWsRDN0hRofq2+WXfHX1nuLTd3kypK 2vEwOq/yETDTt15QPF7vxCAMfKdOEMhbu1/1qj+48wGAjOqa2/lumjgh/G7iCrjpIFgh ryZi0wcYiqGvY4CxV9C3VHQdype4Cqs47xWLEahIPh978Afg69LZqDo+iETuDGGEydI4 XuNA5NeN984KBvEeS6H9N2EQYQAgIkmEST0X2aPerzoVwvQGQlC2zLvk258mf56qyGtI tPMQ== 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 r4si3000558pgi.387.2018.11.29.13.29.49; Thu, 29 Nov 2018 13:29:49 -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 S1727013AbeK3Igc (ORCPT + 32 others); Fri, 30 Nov 2018 03:36:32 -0500 Received: from mx07-00178001.pphosted.com ([62.209.51.94]:32618 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726976AbeK3Igb (ORCPT ); Fri, 30 Nov 2018 03:36:31 -0500 Received: from pps.filterd (m0046037.ppops.net [127.0.0.1]) by mx07-.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id wATLSifc032046; Thu, 29 Nov 2018 22:29:40 +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 2nxw9xdtkc-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Thu, 29 Nov 2018 22:29:40 +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 C7873468; Thu, 29 Nov 2018 22:29:10 +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 0A6CA5981; Thu, 29 Nov 2018 21:29:40 +0000 (GMT) Received: from SAFEX1HUBCAS24.st.com (10.75.90.95) by Safex1hubcas22.st.com (10.75.90.92) with Microsoft SMTP Server (TLS) id 14.3.361.1; Thu, 29 Nov 2018 22:29:39 +0100 Received: from localhost (10.129.6.191) by webmail-ga.st.com (10.75.90.48) with Microsoft SMTP Server (TLS) id 14.3.361.1; Thu, 29 Nov 2018 22:29:39 +0100 From: Loic Pallardy To: , CC: , , , , , Loic Pallardy Subject: [PATCH 1/7] remoteproc: correct rproc_mem_entry_init() comments Date: Thu, 29 Nov 2018 22:29:22 +0100 Message-ID: <1543526968-56091-2-git-send-email-loic.pallardy@st.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1543526968-56091-1-git-send-email-loic.pallardy@st.com> References: <1543526968-56091-1-git-send-email-loic.pallardy@st.com> MIME-Version: 1.0 X-Originating-IP: [10.129.6.191] X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2018-11-29_13:, , 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 Nov 29 21:29:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Loic Pallardy X-Patchwork-Id: 152460 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp2887831ljp; Thu, 29 Nov 2018 13:29:53 -0800 (PST) X-Google-Smtp-Source: AFSGD/VtFuS1zhBs12ynjPEmRsf/XpxFxdy/eRoRHBmzgkqkCVaKmbo8maa5dPd1MCXwJIzBpTPV X-Received: by 2002:aa7:80d7:: with SMTP id a23mr2962411pfn.86.1543526993159; Thu, 29 Nov 2018 13:29:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543526993; cv=none; d=google.com; s=arc-20160816; b=qjYKJal6wyPMjQ38n778B2Qq02kydytWEKvPDMJ+J5oFkxv+3wNBkW3ljHD+Zuhsbf 8AIGG7rHT8N3K7nPAT/np8XwHOcczsZIicY16x8zLyBnGqAS0Q+naX+aZceIIk1z4PLQ PlxmPVSLJdQl3pAYl9eH0sBERkhmebNnaZSMhlewYP6rIPksKTloocpfN4U6eoK+EJDT if13iFqCUVOTKUDGn60wkvpQ9B74q+jBIUwOxwZGB8UF1KCgS368b/8CP7W3MQKYiIDj qm0NXfdQzUlN0s9IoeB9EGeLDX0Hs+z5zDZ4pYzUxbZI4/58dWFhmvxrSz+ua5cOQiwp LaGQ== 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=n2oFOudRt1yHFMk1LUhcKyrqrD/weoLeLiUrE5+a2mtHNamnswTGnwYtKIOBILU00L 6UX6Rissvz6TRIzCtgdlBDsdQhrAkpz0NQaX5m3mulk97wHGgjURage4iYNYMmUIApxE nuTQloMTzN2L92vqbmWBvbFLqI27rU3g1/ARZS5gItwxSlacJMovpBsKANZotdMoeEYn C3dl+fvP3S79b7ws2drUGPPSUcV71XKO1sz8hy4ip6Y9pblXHCMVl8ZbpOxWT7S7rsOS A/cv77KgqW4CAFg5RGyN9cgecuDz7tn3IuisylZ5KQTJIVj9Og9G63aAcJGPyZOt7OsZ xaIA== 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 n3si3266365pld.36.2018.11.29.13.29.52; Thu, 29 Nov 2018 13:29:53 -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 S1726648AbeK3Igh (ORCPT + 32 others); Fri, 30 Nov 2018 03:36:37 -0500 Received: from mx07-00178001.pphosted.com ([62.209.51.94]:6599 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726932AbeK3Igh (ORCPT ); Fri, 30 Nov 2018 03:36:37 -0500 Received: from pps.filterd (m0046668.ppops.net [127.0.0.1]) by mx07-.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id wATLSxo6023175; Thu, 29 Nov 2018 22:29:46 +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 2nxw02wvrb-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Thu, 29 Nov 2018 22:29:46 +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 6E80A468; Thu, 29 Nov 2018 22:29:16 +0000 (GMT) Received: from Webmail-eu.st.com (Safex1hubcas21.st.com [10.75.90.44]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id A7EFD5981; Thu, 29 Nov 2018 21:29:45 +0000 (GMT) Received: from SAFEX1HUBCAS24.st.com (10.75.90.95) by SAFEX1HUBCAS21.st.com (10.75.90.44) with Microsoft SMTP Server (TLS) id 14.3.361.1; Thu, 29 Nov 2018 22:29:45 +0100 Received: from localhost (10.129.6.191) by webmail-ga.st.com (10.75.90.48) with Microsoft SMTP Server (TLS) id 14.3.361.1; Thu, 29 Nov 2018 22:29:44 +0100 From: Loic Pallardy To: , CC: , , , , , Loic Pallardy Subject: [PATCH 2/7] remoteproc: fix rproc_da_to_va in case of unallocated carveout Date: Thu, 29 Nov 2018 22:29:23 +0100 Message-ID: <1543526968-56091-3-git-send-email-loic.pallardy@st.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1543526968-56091-1-git-send-email-loic.pallardy@st.com> References: <1543526968-56091-1-git-send-email-loic.pallardy@st.com> MIME-Version: 1.0 X-Originating-IP: [10.129.6.191] X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2018-11-29_13:, , 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 Nov 29 21:29:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Loic Pallardy X-Patchwork-Id: 152461 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp2887900ljp; Thu, 29 Nov 2018 13:29:58 -0800 (PST) X-Google-Smtp-Source: AFSGD/WpB3f/nLPrMmt6aei4hGPXEghf+587gwOiLcnS0MQdpCRCOm8EblQ0b/eXWksZONRZPxRY X-Received: by 2002:a63:3d03:: with SMTP id k3mr2606369pga.191.1543526997989; Thu, 29 Nov 2018 13:29:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543526997; cv=none; d=google.com; s=arc-20160816; b=vd+H8BKjA8qaCkHPty0f/7R+xNDvcyuVIhVxUp1x0DAi340rYve3B5l3vkS3X3LIps sccZigR6mmeE3/6TP5E0IvV6KTcOHSD3PC5HAg3U6lo/eZr8lj47RjXy7h4Uc/2n4QiX QICaf03ZPTK86HL50i+t2NBfgxnW0t++UmdjcZWHBuZZA5G9PsjR6tjIH+sPWvEevbbj XdJgMuxcJr33lTRUFPlPJbwHfMjN5cujQJ25Pxwl/uFR1Ql0za5imnTIQHFUZt3KeK1A SCD/gSjhQcMkF0kgUclaNeY0ZfAmCaL8xHJhYFD84DiyCedB5tXxD2qLWKoiZtbpZD6D /cQQ== 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=JHZX83FzROHY8tyCcHddlDVDjR3F32z8y0dTCCV3pxnG0mB2YfXZq61zHg+smx3byj WkeRFaVgVHL1vx7D1KkjWZhIpaFvQ3uK6rB/Xdcgc3FS0VtO685rmZXWNKoiv7d2H20S qTVK23gq+bBgaBlhAf4176E2e4WkCxZ7ViipFQwQTz5tduj0Ejp8dUZ0n9nC1d5az7Dd 9NjgzUt3GOAJ6Msm1Nl37v9IkclLpAowA552TcpehMUkGLpiq0LRlbCgY5SXZqORF9Yr gUhlv1GHQ76pZIHyoIVg9MDPL/oJFhaWqBrAKYK0YOXNJXW00ryffm+53efXngneXij1 VCYA== 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 v69si2879334pgd.284.2018.11.29.13.29.57; Thu, 29 Nov 2018 13:29: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 S1727080AbeK3Ign (ORCPT + 32 others); Fri, 30 Nov 2018 03:36:43 -0500 Received: from mx08-00178001.pphosted.com ([91.207.212.93]:47085 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726932AbeK3Igm (ORCPT ); Fri, 30 Nov 2018 03:36:42 -0500 Received: from pps.filterd (m0046660.ppops.net [127.0.0.1]) by mx08-.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id wATLTaCi001701; Thu, 29 Nov 2018 22:29:51 +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 2nxvnb6gfh-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Thu, 29 Nov 2018 22:29:51 +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 5DEC7468; Thu, 29 Nov 2018 22:29:21 +0000 (GMT) Received: from Webmail-eu.st.com (Safex1hubcas21.st.com [10.75.90.44]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 957325981; Thu, 29 Nov 2018 21:29:50 +0000 (GMT) Received: from SAFEX1HUBCAS24.st.com (10.75.90.95) by SAFEX1HUBCAS21.st.com (10.75.90.44) with Microsoft SMTP Server (TLS) id 14.3.361.1; Thu, 29 Nov 2018 22:29:50 +0100 Received: from localhost (10.129.6.191) by webmail-ga.st.com (10.75.90.48) with Microsoft SMTP Server (TLS) id 14.3.361.1; Thu, 29 Nov 2018 22:29:49 +0100 From: Loic Pallardy To: , CC: , , , , , Loic Pallardy Subject: [PATCH 3/7] remoteproc: fix rproc_alloc_carveout() bad variable cast Date: Thu, 29 Nov 2018 22:29:24 +0100 Message-ID: <1543526968-56091-4-git-send-email-loic.pallardy@st.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1543526968-56091-1-git-send-email-loic.pallardy@st.com> References: <1543526968-56091-1-git-send-email-loic.pallardy@st.com> MIME-Version: 1.0 X-Originating-IP: [10.129.6.191] X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2018-11-29_13:, , 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 Nov 29 21:29:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Loic Pallardy X-Patchwork-Id: 152462 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp2887969ljp; Thu, 29 Nov 2018 13:30:03 -0800 (PST) X-Google-Smtp-Source: AFSGD/VbVX6ar1mTsHDeZSNMFSHrGwxx0mT16X9DojQ2Wx/jCu73EYKzgDtcdlNBhCkEOPSj65rF X-Received: by 2002:a63:3858:: with SMTP id h24mr1379346pgn.300.1543527003027; Thu, 29 Nov 2018 13:30:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543527003; cv=none; d=google.com; s=arc-20160816; b=XimoJR0jdA4Z1jVSZVTUvEsZt5cx2BpuAhH0ytnz3iaCwiUw6+ZkkuGNp154kxHDSd II2qAZf2z/QCIYLL7h2t3w1R7/HA6KnBZspScRgmri26qy96y8WXbzWXwFn4s+suWPTl rKu9jg7DB5mJ7FGOYNsCv6h0AJ8J6p6hgVymdo048uZA9UF+htQseN9uLz3Faiy2O45W 2IA4Qgn1CSm0hFEE8UssT7jk/+mbNF5QHrPCYUHDQKKhPwp1xMUcUtiHIlqbqF3BvqvH ETChsW+qaZdbAv7Gfs4nFb/zmlWbZ1kkG1Eq3IzuTX+ojcIPy4Gm4BBaZwtBCDJagrmR u1Vg== 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=GGaW6BrYtmBj5C8b5QY/JDd6fBsE0NAWmji6ZLBYMvI=; b=S04uOdTtPd3WfG1VH0StLSSKIrWjNHBbfr/GJKWfOFwxjvPwYzqHaRsMFKlMFnjz90 YOIjtAgXEUxC8yem4WvMP2hgQNSc6jrCCGhEtP59ZOHnkjtlacgArQwkC4fLL+hd+PDW 6L0V9p8GlXlPHnrecY31iC8ecVRlPCFzTNbGZPmn5BKFGbL2+riB+QoJqjxkK3sAkA4n pbnb5b7shVdZiRiY7fHJJy84m0pOk2a1ZSBJn1W6SX6lfm7WdOr4kC64tSbRul+Wu8KQ Csqtu7wFnyqIX//WBcJKk0wlLarTkbfmnlQ/Sgcwd4q5tMMi4q/Q4ipG2Jpaq+nsnVii ujHw== 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 c31si3001528pgc.465.2018.11.29.13.30.02; Thu, 29 Nov 2018 13:30: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 S1727109AbeK3Igs (ORCPT + 32 others); Fri, 30 Nov 2018 03:36:48 -0500 Received: from mx08-00178001.pphosted.com ([91.207.212.93]:52626 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726932AbeK3Igs (ORCPT ); Fri, 30 Nov 2018 03:36:48 -0500 Received: from pps.filterd (m0046660.ppops.net [127.0.0.1]) by mx08-.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id wATLTvHu001812; Thu, 29 Nov 2018 22:29:57 +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 2nxvnb6gft-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Thu, 29 Nov 2018 22:29:57 +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 226D3468; Thu, 29 Nov 2018 22:29: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 5BDDE5981; Thu, 29 Nov 2018 21:29:56 +0000 (GMT) Received: from SAFEX1HUBCAS24.st.com (10.75.90.95) by Safex1hubcas22.st.com (10.75.90.92) with Microsoft SMTP Server (TLS) id 14.3.361.1; Thu, 29 Nov 2018 22:29:56 +0100 Received: from localhost (10.129.6.191) by webmail-ga.st.com (10.75.90.48) with Microsoft SMTP Server (TLS) id 14.3.361.1; Thu, 29 Nov 2018 22:29:55 +0100 From: Loic Pallardy To: , CC: , , , , , Loic Pallardy Subject: [PATCH 4/7] remoteproc: add warning on resource table cast Date: Thu, 29 Nov 2018 22:29:25 +0100 Message-ID: <1543526968-56091-5-git-send-email-loic.pallardy@st.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1543526968-56091-1-git-send-email-loic.pallardy@st.com> References: <1543526968-56091-1-git-send-email-loic.pallardy@st.com> MIME-Version: 1.0 X-Originating-IP: [10.129.6.191] X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2018-11-29_13:, , 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 --- drivers/remoteproc/remoteproc_core.c | 8 ++++++++ 1 file changed, 8 insertions(+) -- 2.7.4 diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index 18a1bbf820c9..61c954bd695e 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -772,6 +772,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 (sizeof(dma_addr_t) > sizeof(u32)) + dev_warn(dev, "DMA address cast in 32bit to fit resource table format\n"); + mem->da = (u32)dma; } @@ -1150,6 +1154,10 @@ static int rproc_alloc_registered_carveouts(struct rproc *rproc) */ /* Use va if defined else dma to generate pa */ + if (sizeof(dma_addr_t) > sizeof(u32) || + sizeof(phys_addr_t) > sizeof(u32)) + dev_warn(dev, "Physical address cast in 32bit to fit resource table format\n"); + if (entry->va) rsc->pa = (u32)rproc_va_to_pa(entry->va); else From patchwork Thu Nov 29 21:29:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Loic Pallardy X-Patchwork-Id: 152463 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp2888083ljp; Thu, 29 Nov 2018 13:30:10 -0800 (PST) X-Google-Smtp-Source: AFSGD/VjPpr6cPdX7vw7oHD4YFqm5LdFp3CzO1ldpaa/HpmlvSHVAImm1Pxo6gbx0LgQZBv8M1ge X-Received: by 2002:a17:902:8687:: with SMTP id g7mr3053565plo.96.1543527010577; Thu, 29 Nov 2018 13:30:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543527010; cv=none; d=google.com; s=arc-20160816; b=qRXrimf7CMdRo7hZfHueGMOgmRs7/0I68XCOAKX4voJfxTD6jt/wWtSdoWa7Or9eRw ZK6sn0wmEh52xjlsaJpQT5Ie7g8CtiJmFgSNKJJmRASc/OxUX6TH221U4zBikpoKOFlh kM7WlNsmzmkZvKmeKTAOd8A4en0YNk5j3KgQyvWgiDZySZ0pjl49zxBIG2F8sag7B+tY /RPb7dHkAdds8xF93qv3hMVIchDfWsztEEQATIrW6WE+d9QJ8RStos6joBEeWkgm7cVI TYl5k8am0op+RTQDdtJZkYRSFL4gD2oWEHmrtGsqdJI0JADRliYUz5xS8igiDoe+m1Jj 9ajA== 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=0H4XBaOafa723u+NFanMMn/TDtLvKh097gzgkuuKTeQ=; b=xAQ5lAoAy0yuymLjpTO1HMxwPv/NGchogp3oOCg2eeN3VdoADy/9wJofh9ciM/msW8 p23Fxq+VpmYgwtVY7pWKCY78Sz9P/DNDhwM7iGC/m4JibXHbOUNf4xkKDK8I2OtdEEUK GoaIVZxvP4WTIWFYx3pXMi8bKIXhoA3hwes0WoWdfC4LDOP0kwSMGl4ma0vAUFfCpoXP uo1MipKy29G/X5MflpJyrj4zyxT89gXRor0D+ym4zg2ymSowpHIGwEJZ3tWykMzLP8PU 75JX9L/t0HrX9aE8SDEhQladF+/6zmSBTkAF1UX90Vj2+UqcKfuMZJ6h5GKFFMf6Rl6R RQjg== 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 u202si3319335pgb.115.2018.11.29.13.30.09; Thu, 29 Nov 2018 13:30:10 -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 S1727133AbeK3Igz (ORCPT + 32 others); Fri, 30 Nov 2018 03:36:55 -0500 Received: from mx08-00178001.pphosted.com ([91.207.212.93]:64871 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726932AbeK3Igz (ORCPT ); Fri, 30 Nov 2018 03:36:55 -0500 Received: from pps.filterd (m0046660.ppops.net [127.0.0.1]) by mx08-.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id wATLTaCk001701; Thu, 29 Nov 2018 22:30:03 +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 2nxvnb6ggj-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Thu, 29 Nov 2018 22:30:03 +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 BEFB4468; Thu, 29 Nov 2018 22:29:33 +0000 (GMT) Received: from Webmail-eu.st.com (Safex1hubcas21.st.com [10.75.90.44]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id F0DD55983; Thu, 29 Nov 2018 21:30:02 +0000 (GMT) Received: from SAFEX1HUBCAS24.st.com (10.75.90.95) by SAFEX1HUBCAS21.st.com (10.75.90.44) with Microsoft SMTP Server (TLS) id 14.3.361.1; Thu, 29 Nov 2018 22:30:02 +0100 Received: from localhost (10.129.6.191) by webmail-ga.st.com (10.75.90.48) with Microsoft SMTP Server (TLS) id 14.3.361.1; Thu, 29 Nov 2018 22:30:01 +0100 From: Loic Pallardy To: , CC: , , , , , Loic Pallardy Subject: [PATCH 5/7] remoteproc: fix rproc_alloc_carveout() for rproc with iommu domain Date: Thu, 29 Nov 2018 22:29:26 +0100 Message-ID: <1543526968-56091-6-git-send-email-loic.pallardy@st.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1543526968-56091-1-git-send-email-loic.pallardy@st.com> References: <1543526968-56091-1-git-send-email-loic.pallardy@st.com> MIME-Version: 1.0 X-Originating-IP: [10.129.6.191] X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2018-11-29_13:, , 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 61c954bd695e..f19bc6961e40 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -719,6 +719,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. * @@ -736,15 +748,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; @@ -771,7 +775,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 (sizeof(dma_addr_t) > sizeof(u32)) dev_warn(dev, "DMA address cast in 32bit to fit resource table format\n"); From patchwork Thu Nov 29 21:29:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Loic Pallardy X-Patchwork-Id: 152464 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp2888205ljp; Thu, 29 Nov 2018 13:30:17 -0800 (PST) X-Google-Smtp-Source: AFSGD/WOiiF1QbkAx9EBMKJOjAa4bFfyFlEJn8MdbNiLP1qqKEcLamO7532np68YUQs+GGnMlmUl X-Received: by 2002:a63:d846:: with SMTP id k6mr1462374pgj.251.1543527017358; Thu, 29 Nov 2018 13:30:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543527017; cv=none; d=google.com; s=arc-20160816; b=TAVCuVXFiH729nIw5HcCg5E3HR5b5atleov9TsOaOw+S9U6RGHXfp/axhBmxhVPc25 CQ3FLRE2dHBvxafUHrU2pr2Wi/p7MVEbj8yK7yrSrf/rKj5PZPRSez99r0E4a+F2aN5u ilpR2dm4gjB2/6YYF8f13zt4Kd7YFFFU/77Fd89FJwS7aYyP9ktu9nnw08/hWsZv1wE5 CUUFAMgS8DVgplAPEV7AVDmooj6TfG6eCOeHmoiXS0QtrZ2Fv5GWeA4UHqsCrpphjvTC L5v3fkq1pu6n1WreoX9YWjZl/s3Tit+tWv7hFgJwiD+pJnEDdzfddy4Hefvr/D610unT mqTg== 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=P0SJ0KBDSIlYofuK+UUJaB0pPQTREdUr4d1eUJp4mqE=; b=GSLhSr6EPUV3w8U4hDC346iSzogFZcTsXMgGgSz2yxxManiNGqu0a9UHrcXHdYut4w i5dD1QtnWvE0B5XPgUie6dBFOvg4ZddFhmMSdl1KiXSg7Gsd7mBMZpUj0Y4F/pJ0fHgN tymNOt78oSueuGplY97GkBf1A7RdORFStvtOEWrLUAVcgU05wvXnG6yKdtVSZ1aPExNx fS3IOvN/WZ8dsNF7E2r9NQ+5Fjr4+4Abbum/vn62mdGJsZlmG0dPZY/VxCpDrp9+aaXj y1P1Ipu3e6bmSbemOXZdjyUkHCNrpaTX1BrjrMVuyQJwLBdWo9RO7uxvL04ECUXzPcy8 N1bw== 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 d9si3027860pgb.105.2018.11.29.13.30.17; Thu, 29 Nov 2018 13:30:17 -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 S1727156AbeK3IhC (ORCPT + 32 others); Fri, 30 Nov 2018 03:37:02 -0500 Received: from mx07-00178001.pphosted.com ([62.209.51.94]:11835 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726932AbeK3IhB (ORCPT ); Fri, 30 Nov 2018 03:37:01 -0500 Received: from pps.filterd (m0046668.ppops.net [127.0.0.1]) by mx07-.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id wATLTV2g023623; Thu, 29 Nov 2018 22:30:09 +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 2nxw02wvt0-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Thu, 29 Nov 2018 22:30:09 +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 9AA5A484; Thu, 29 Nov 2018 22:29:39 +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 D0ADA5985; Thu, 29 Nov 2018 21:30:08 +0000 (GMT) Received: from SAFEX1HUBCAS24.st.com (10.75.90.95) by SAFEX1HUBCAS23.st.com (10.75.90.46) with Microsoft SMTP Server (TLS) id 14.3.361.1; Thu, 29 Nov 2018 22:30:08 +0100 Received: from localhost (10.129.6.191) by webmail-ga.st.com (10.75.90.48) with Microsoft SMTP Server (TLS) id 14.3.361.1; Thu, 29 Nov 2018 22:30:07 +0100 From: Loic Pallardy To: , CC: , , , , , Loic Pallardy Subject: [PATCH 6/7] remoteproc: fix trace buffer va initialization Date: Thu, 29 Nov 2018 22:29:27 +0100 Message-ID: <1543526968-56091-7-git-send-email-loic.pallardy@st.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1543526968-56091-1-git-send-email-loic.pallardy@st.com> References: <1543526968-56091-1-git-send-email-loic.pallardy@st.com> MIME-Version: 1.0 X-Originating-IP: [10.129.6.191] X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2018-11-29_13:, , 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 --- drivers/remoteproc/remoteproc_core.c | 26 ++++++++++---------------- drivers/remoteproc/remoteproc_debugfs.c | 21 +++++++++++++++++---- drivers/remoteproc/remoteproc_internal.h | 9 ++++++++- 3 files changed, 35 insertions(+), 21 deletions(-) -- 2.7.4 diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index f19bc6961e40..9dbcc16f8782 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -562,9 +562,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) { @@ -578,28 +577,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; } @@ -608,8 +602,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; } 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 Nov 29 21:29:28 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Loic Pallardy X-Patchwork-Id: 152465 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp2888314ljp; Thu, 29 Nov 2018 13:30:23 -0800 (PST) X-Google-Smtp-Source: AFSGD/VnneFBGQfFgeC25N6x+slK7m+1MGnBFT1HNwdxQjiMIOH/kVgHhunixAmd8/PHYEo8LSNo X-Received: by 2002:a63:cf56:: with SMTP id b22mr2462251pgj.336.1543527023382; Thu, 29 Nov 2018 13:30:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543527023; cv=none; d=google.com; s=arc-20160816; b=apfbbwncdC+FN+KhzI6hExda7ZUoh71rIE9pqpDw5l8beYrbfuQkFShUxypAEL4JiS h+UvdsJcxb5EKQAGG4dxYxSQwVe56qy6Bm1AgR5E09AhPXH7Op4EjeFMaQLHOCY2Y2fm YadmRbNnzQkiDdNBB3VtCenSZljmRTA8DFv67pV4FAVeaD/0HjrG8QNc6MkyxFDv6EBO WQsjNug8rD3DMMIBeGxBFE1jLnZdMI9WAYxrIcWHwhFOn7enm70vd/KIt9ccy9yYM+/S Szd/bTFXb9WTNsRHjBq4R6aMN+ojv/1sPI52YgWb1wZH3nP01V4faz1YKpjuB9DDdVYY 03VQ== 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=b87iNikHj6/s4M3IQbTHwkfIiMxUQnUAb5kyNsNPTBs=; b=Z4XYpzlo1F9mo9z8Kqp6CBBLH/B5PrEyQqDfxwFW/8nM2dV3dsZtSJT30+9vDHHl1f m7PYQ7eqQb0yux2y+jeNngEYl5phqJcdHBxoo0kqUKzbsOAS2o9ee2g6n7sEUZmwwKI5 HZ/9Drz63/B9/mwKxzpOLquKyQqR6Vm4pEnYAVv90h3o08BGv/60l2/5PJfHnZ+9Bz7g +cj4EkURGU/7n8yhkNIOWA7PeFz4Ca8BLzBDv0lzA4bU8JzeTX99yT/VuE47lUp1B0Za JbC8qA/0BDS8y7qgAPcymcK75yXPC2dJGsNFxSQxKLMf/lqIiYUEACrYMOPB7m6ASiXf tmZA== 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 b14si3501758plk.333.2018.11.29.13.30.22; Thu, 29 Nov 2018 13:30:23 -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 S1727184AbeK3IhJ (ORCPT + 32 others); Fri, 30 Nov 2018 03:37:09 -0500 Received: from mx07-00178001.pphosted.com ([62.209.51.94]:31895 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726932AbeK3IhI (ORCPT ); Fri, 30 Nov 2018 03:37:08 -0500 Received: from pps.filterd (m0046668.ppops.net [127.0.0.1]) by mx07-.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id wATLSxoC023175; Thu, 29 Nov 2018 22:30:15 +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 2nxw02wvt5-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Thu, 29 Nov 2018 22:30:15 +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 38ED1468; Thu, 29 Nov 2018 22:29:45 +0000 (GMT) Received: from Webmail-eu.st.com (Safex1hubcas21.st.com [10.75.90.44]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 76A365986; Thu, 29 Nov 2018 21:30:14 +0000 (GMT) Received: from SAFEX1HUBCAS24.st.com (10.75.90.95) by SAFEX1HUBCAS21.st.com (10.75.90.44) with Microsoft SMTP Server (TLS) id 14.3.361.1; Thu, 29 Nov 2018 22:30:14 +0100 Received: from localhost (10.129.6.191) by webmail-ga.st.com (10.75.90.48) with Microsoft SMTP Server (TLS) id 14.3.361.1; Thu, 29 Nov 2018 22:30:13 +0100 From: Loic Pallardy To: , CC: , , , , , Loic Pallardy Subject: [PATCH 7/7] remoteproc: fix rproc_check_carveout_da() returned error and comments Date: Thu, 29 Nov 2018 22:29:28 +0100 Message-ID: <1543526968-56091-8-git-send-email-loic.pallardy@st.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1543526968-56091-1-git-send-email-loic.pallardy@st.com> References: <1543526968-56091-1-git-send-email-loic.pallardy@st.com> MIME-Version: 1.0 X-Originating-IP: [10.129.6.191] X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2018-11-29_13:, , 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 9dbcc16f8782..b69ce5bff732 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -276,25 +276,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; @@ -302,13 +304,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; } }