Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp316499ybl; Tue, 7 Jan 2020 06:39:08 -0800 (PST) X-Google-Smtp-Source: APXvYqxdoopIoAs0YSauxQNlRsPiilcErRazF154Wc5+MbbKpwGDVIXBXbtkd2Cg9VWhJxCEyl8l X-Received: by 2002:a9d:6acd:: with SMTP id m13mr9183otq.313.1578407948537; Tue, 07 Jan 2020 06:39:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578407948; cv=none; d=google.com; s=arc-20160816; b=uCVSvemZsHp/9mNo4LvO9/I8bfxVe1lwOQGA37P528lSJeoXZCWlVSi9ibmT8zd5Xv 9n1oI9HF34FXANr+Y8UXVeSoozCZtMdFV7BKq7bxC2GZM5YsZkedIIjaqk32s1U73lK/ 8Sg/BjmVecsOJvivblO1TF3iyDMwQUZTePHoP8BPsxvA6GnIbz7C/wdZGec35hYP9s3/ xW7/4XbQxQn4uSVjq1NJiJsq2/NOVMP0TnBar3P4ZNi2Ug83TqsH1q3nyf4tckEfJbTQ /WxNki/Xx0gecdpeoeH2taRA0byfICb6bIRNEdZH+oNTW64QnPuFseX2EZ6BjzkSxZLT n5bg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=YgGSzprZT125RtCJvkZ/hvT+sodJn5nabPsNInBAm6k=; b=iF5VVMFVuN4ycRLIlq0TlihtdqlEXg/LLKZDlOLqFWBfgjr8lmil3mO7MSkqb0a05p UxnBlaVBBImxVp6jOtaDQU2UTnAWwaVEPHnYwBoSBGZCGnVc5pisi95zEHSuMdWfyPap fZSuOseNmYREqWC1Ju9RZVsPcX5vtqlVApvZt3a5NV/10bYrDBzyXFHQ5c8ZxeAlm2rx h/4xfOy7zPixHnKNL83kFTMj1eO8liNMRkShIivAY0/W1uCpZlAMMqfm1IVLSDO8HqBI 7J1mmEi0E6/3cB6HQ14TmFuH+MAOEYkOl2/Gn+3aWNo0wg8j1fiVQph75u4mLPoZAxRn HlbQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=AWpfBKjp; 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; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 92si38155601otr.25.2020.01.07.06.38.56; Tue, 07 Jan 2020 06:39:08 -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; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=AWpfBKjp; 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; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728357AbgAGOhL (ORCPT + 99 others); Tue, 7 Jan 2020 09:37:11 -0500 Received: from fllv0015.ext.ti.com ([198.47.19.141]:54712 "EHLO fllv0015.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727894AbgAGOhL (ORCPT ); Tue, 7 Jan 2020 09:37:11 -0500 Received: from fllv0035.itg.ti.com ([10.64.41.0]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id 007Eb9UN009479; Tue, 7 Jan 2020 08:37:09 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1578407829; bh=YgGSzprZT125RtCJvkZ/hvT+sodJn5nabPsNInBAm6k=; h=Subject:To:CC:References:From:Date:In-Reply-To; b=AWpfBKjpPokmiZp2/EGjnupGenGQQBYq4nQ1mr1aKyOfHHoSpBZLsh8kPAQK7C0qc Pvt4fI3RiWenw+9YScFmVe2uyorf/glOQpNzBFrr/BdgLcG5zCRzpHcXqoum7fHo3z bOEs3uE4ucsfApwiopNiQcrxc5IHEcamYy36QONo= Received: from DFLE100.ent.ti.com (dfle100.ent.ti.com [10.64.6.21]) by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTP id 007Eb9t4085873; Tue, 7 Jan 2020 08:37:09 -0600 Received: from DFLE107.ent.ti.com (10.64.6.28) by DFLE100.ent.ti.com (10.64.6.21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1847.3; Tue, 7 Jan 2020 08:37:09 -0600 Received: from lelv0326.itg.ti.com (10.180.67.84) by DFLE107.ent.ti.com (10.64.6.28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1847.3 via Frontend Transport; Tue, 7 Jan 2020 08:37:09 -0600 Received: from [10.250.65.50] (ileax41-snat.itg.ti.com [10.172.224.153]) by lelv0326.itg.ti.com (8.15.2/8.15.2) with ESMTP id 007Eb8ha048731; Tue, 7 Jan 2020 08:37:09 -0600 Subject: Re: [PATCHv4 06/14] remoteproc/omap: Initialize and assign reserved memory node To: Tero Kristo , , , CC: , , , References: <20200102131845.12992-1-t-kristo@ti.com> <20200102131845.12992-7-t-kristo@ti.com> <1a3fcb85-59d5-ebe4-fe3e-e9cc3311785a@ti.com> From: "Andrew F. Davis" Message-ID: Date: Tue, 7 Jan 2020 09:37:08 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.2.2 MIME-Version: 1.0 In-Reply-To: <1a3fcb85-59d5-ebe4-fe3e-e9cc3311785a@ti.com> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 8bit X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 1/7/20 9:25 AM, Tero Kristo wrote: > On 07/01/2020 15:37, Andrew F. Davis wrote: >> On 1/2/20 8:18 AM, Tero Kristo wrote: >>> From: Suman Anna >>> >>> The reserved memory nodes are not assigned to platform devices by >>> default in the driver core to avoid the lookup for every platform >>> device and incur a penalty as the real users are expected to be >>> only a few devices. >>> >>> OMAP remoteproc devices fall into the above category and the OMAP >>> remoteproc driver _requires_ specific CMA pools to be assigned >>> for each device at the moment to align on the location of the >>> vrings and vring buffers in the RTOS-side firmware images. So, >> >> >> Requires only at the moment due to firmware.. >> >> This sounds like some firmware images hard-coded their vring addresses >> instead of getting them dynamically as they should and we are hacking >> around that on the kernel side by giving them the addresses they use as >> carveouts. > > The firmwares are built on specific device addresses, this includes data > + code. > >> Should we rather make use of the IOMMU attached to the DSP to map any >> kernel address to the DSP where the firmware expects it? Or better yet >> fixup the firmwares. > > Well, we do use IOMMU to map the corresponding memory area to specific > device address. What this patch does, is to allocate a contiguous memory > area for the remoteproc shared memories. Using completely random memory > location would potentially fragment the remoteproc memory around page > boundaries, resulting in a complex (read ineffective) IOMMU mapping. Complex is not always ineffective, this is what the (IO)MMUs are for, memory gets fragmented on page boundaries, they put it back together, that's part of modern computing despite its crazy complexity. Shying away from that and just using big static memory carveouts for usecases like this (that could otherwise work without them) will not scale. > Also, we are going to need the reserved memory mechanism for the > remoteproc anyways later, as we are going to introduce the support for > early-boot / late-attach. Bootloader would pass the used memory regions > to the kernel via the reserved memory nodes in that case (unless we > assume to use some hardcoded region, which would be worse than passing > it via DT.) This is a different case, I can see a more valid use here (although I'd argue passing bootloader generated software configuration like this to kernel is a gray area for DT, but I'll leave that for our DT maintainer friends). At very least can we make the reserved memory node optional here? DSP/IPU Firmware can/should be made to work without it. Andrew > > -Tero > >> >> DRAM carveouts should be a last resort used only for when hardware >> really requires it. >> >> Andrew >> >> >>> use the of_reserved_mem_device_init/release() API appropriately >>> to assign the corresponding reserved memory region to the OMAP >>> remoteproc device. Note that only one region per device is >>> allowed by the framework. >>> >>> Signed-off-by: Suman Anna >>> Signed-off-by: Tero Kristo >>> Reviewed-by: Bjorn Andersson >>> --- >>>   drivers/remoteproc/omap_remoteproc.c | 12 +++++++++++- >>>   1 file changed, 11 insertions(+), 1 deletion(-) >>> >>> diff --git a/drivers/remoteproc/omap_remoteproc.c >>> b/drivers/remoteproc/omap_remoteproc.c >>> index 9ca337f18ac2..8a6dd742a8b1 100644 >>> --- a/drivers/remoteproc/omap_remoteproc.c >>> +++ b/drivers/remoteproc/omap_remoteproc.c >>> @@ -17,6 +17,7 @@ >>>   #include >>>   #include >>>   #include >>> +#include >>>   #include >>>   #include >>>   #include >>> @@ -480,14 +481,22 @@ static int omap_rproc_probe(struct >>> platform_device *pdev) >>>       if (ret) >>>           goto free_rproc; >>>   +    ret = of_reserved_mem_device_init(&pdev->dev); >>> +    if (ret) { >>> +        dev_err(&pdev->dev, "device does not have specific CMA >>> pool\n"); >>> +        goto free_rproc; >>> +    } >>> + >>>       platform_set_drvdata(pdev, rproc); >>>         ret = rproc_add(rproc); >>>       if (ret) >>> -        goto free_rproc; >>> +        goto release_mem; >>>         return 0; >>>   +release_mem: >>> +    of_reserved_mem_device_release(&pdev->dev); >>>   free_rproc: >>>       rproc_free(rproc); >>>       return ret; >>> @@ -499,6 +508,7 @@ static int omap_rproc_remove(struct >>> platform_device *pdev) >>>         rproc_del(rproc); >>>       rproc_free(rproc); >>> +    of_reserved_mem_device_release(&pdev->dev); >>>         return 0; >>>   } >>> > > -- > Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. > Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki