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");