Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2985201imu; Thu, 29 Nov 2018 13:31:16 -0800 (PST) X-Google-Smtp-Source: AFSGD/UPvWnAShIOTyWbPpsgkeBCwQuRuhlLiEH0ZLhr3nzCLeItLwF240uvzXlJNNe3EKb7tciK X-Received: by 2002:a63:9a09:: with SMTP id o9mr2537571pge.94.1543527076267; Thu, 29 Nov 2018 13:31:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543527076; cv=none; d=google.com; s=arc-20160816; b=kFRzKTUe8FqC8a7sUH2GeaOzrIF/itjFxj/CoWq54yit/vK8nfBGSfrP1hHS7aZX3E C8igfOKQRrRkTIYypBD6Mosp4khV0etNTG7qs73Bd/Gke3oy8xTzoA0/t4kziNZavi34 q7NScAhlOizgxO8IxvAHsrxT1KQZ7UpJneY3/JpqX8myunZ01ynT+bK/1ttOOddmH2JO cMWb4vITUyALb/uryE9PgAl64CF+EvpVl8fQny2f6W20mbIq5F5Fi+VBNTQVTPHutyqR K6ll4UvgespdIHeC8FrLOZNyv+DhPoW6Cxvg7TVcWQyfG3xMHQqEizocZxlvnNnaXVU3 yT3g== 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 3si3166431plq.138.2018.11.29.13.31.02; Thu, 29 Nov 2018 13:31:16 -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 S1727126AbeK3Igz (ORCPT + 99 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 Content-Type: text/plain 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(-) 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"); -- 2.7.4