From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: From: Loic Pallardy Subject: [PATCH v4 01/17] remoteproc: configure IOMMU only if device address requested Date: Fri, 27 Jul 2018 15:14:36 +0200 Message-ID: <1532697292-14272-2-git-send-email-loic.pallardy@st.com> In-Reply-To: <1532697292-14272-1-git-send-email-loic.pallardy@st.com> References: <1532697292-14272-1-git-send-email-loic.pallardy@st.com> MIME-Version: 1.0 Content-Type: text/plain To: bjorn.andersson@linaro.org, ohad@wizery.com Cc: linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org, arnaud.pouliquen@st.com, benjamin.gaignard@linaro.org, s-anna@ti.com, Loic Pallardy List-ID: If there is no IOMMU associate to remote processor device, remoteproc_core won't be able to satisfy device address requested in firmware resource table. Return an error as configuration won't be coherent. Signed-off-by: Loic Pallardy --- drivers/remoteproc/remoteproc_core.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index 4cd1a8e..437fabf 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -657,7 +657,15 @@ static int rproc_handle_carveout(struct rproc *rproc, * to use the iommu-based DMA API: we expect 'dma' to contain the * physical address in this case. */ - if (rproc->domain) { + + if (rsc->da != FW_RSC_ADDR_ANY && !rproc->domain) { + dev_err(dev->parent, + "Bad carveout rsc configuration\n"); + ret = -ENOMEM; + goto dma_free; + } + + if (rsc->da != FW_RSC_ADDR_ANY && rproc->domain) { mapping = kzalloc(sizeof(*mapping), GFP_KERNEL); if (!mapping) { ret = -ENOMEM; -- 1.9.1 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 55449C67790 for ; Fri, 27 Jul 2018 13:15:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0A86E208B0 for ; Fri, 27 Jul 2018 13:15:25 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0A86E208B0 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=st.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388141AbeG0OhQ (ORCPT ); Fri, 27 Jul 2018 10:37:16 -0400 Received: from mx08-00178001.pphosted.com ([91.207.212.93]:39841 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1730395AbeG0OhQ (ORCPT ); Fri, 27 Jul 2018 10:37:16 -0400 Received: from pps.filterd (m0046661.ppops.net [127.0.0.1]) by mx08-.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id w6RDE18o014480; Fri, 27 Jul 2018 15:15:18 +0200 Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx08-00178001.pphosted.com with ESMTP id 2kg1tj8psw-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Fri, 27 Jul 2018 15:15:18 +0200 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 D4FF431; Fri, 27 Jul 2018 13:15:17 +0000 (GMT) Received: from Webmail-eu.st.com (sfhdag7node2.st.com [10.75.127.20]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id B1138577A; Fri, 27 Jul 2018 13:15:17 +0000 (GMT) Received: from localhost (10.75.127.48) by SFHDAG7NODE2.st.com (10.75.127.20) with Microsoft SMTP Server (TLS) id 15.0.1347.2; Fri, 27 Jul 2018 15:15:17 +0200 From: Loic Pallardy To: , CC: , , , , , Loic Pallardy Subject: [PATCH v4 01/17] remoteproc: configure IOMMU only if device address requested Date: Fri, 27 Jul 2018 15:14:36 +0200 Message-ID: <1532697292-14272-2-git-send-email-loic.pallardy@st.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1532697292-14272-1-git-send-email-loic.pallardy@st.com> References: <1532697292-14272-1-git-send-email-loic.pallardy@st.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.75.127.48] X-ClientProxiedBy: SFHDAG6NODE1.st.com (10.75.127.16) To SFHDAG7NODE2.st.com (10.75.127.20) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-07-27_06:,, signatures=0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If there is no IOMMU associate to remote processor device, remoteproc_core won't be able to satisfy device address requested in firmware resource table. Return an error as configuration won't be coherent. Signed-off-by: Loic Pallardy --- drivers/remoteproc/remoteproc_core.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index 4cd1a8e..437fabf 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -657,7 +657,15 @@ static int rproc_handle_carveout(struct rproc *rproc, * to use the iommu-based DMA API: we expect 'dma' to contain the * physical address in this case. */ - if (rproc->domain) { + + if (rsc->da != FW_RSC_ADDR_ANY && !rproc->domain) { + dev_err(dev->parent, + "Bad carveout rsc configuration\n"); + ret = -ENOMEM; + goto dma_free; + } + + if (rsc->da != FW_RSC_ADDR_ANY && rproc->domain) { mapping = kzalloc(sizeof(*mapping), GFP_KERNEL); if (!mapping) { ret = -ENOMEM; -- 1.9.1