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=-5.3 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 autolearn=no 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 ADDAAC4363D for ; Thu, 24 Sep 2020 10:16:46 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 1F7EB23600 for ; Thu, 24 Sep 2020 10:16:46 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="BeJYJaMC" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1F7EB23600 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 9BBFC6B009C; Thu, 24 Sep 2020 06:16:45 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 96CCF6B009D; Thu, 24 Sep 2020 06:16:45 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 85CDC6B009E; Thu, 24 Sep 2020 06:16:45 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0179.hostedemail.com [216.40.44.179]) by kanga.kvack.org (Postfix) with ESMTP id 70AE06B009C for ; Thu, 24 Sep 2020 06:16:45 -0400 (EDT) Received: from smtpin28.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 2C5CF181AE866 for ; Thu, 24 Sep 2020 10:16:45 +0000 (UTC) X-FDA: 77297551170.28.jail36_2a0425e2715e Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin28.hostedemail.com (Postfix) with ESMTP id 0B53D6C0B for ; Thu, 24 Sep 2020 10:16:45 +0000 (UTC) X-HE-Tag: jail36_2a0425e2715e X-Filterd-Recvd-Size: 6709 Received: from mail-wr1-f66.google.com (mail-wr1-f66.google.com [209.85.221.66]) by imf35.hostedemail.com (Postfix) with ESMTP for ; Thu, 24 Sep 2020 10:16:44 +0000 (UTC) Received: by mail-wr1-f66.google.com with SMTP id t10so3209328wrv.1 for ; Thu, 24 Sep 2020 03:16:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=aSjDAH2snju8R3q+4/T0EE6wjXqyrlifnf57RELtEPo=; b=BeJYJaMCHnL0aB6F/iUlSDLZ+jXsNh5J7eEl+OXczqw6pRlpuTvN4SJXSSKUXLKlK0 R74xoyip/4rRV4+yX2Is5Hsh9AXDdgUSlPpI6lrwwm6pq7skGowdiqZosccXmi9R2vIo juC/KMMAz3IxRUIgZ+T1f2GgInsH/087Kt5tYjcPnsq7d1bFF11ESnQvF/rlCFu5rtDJ E0eWyzGPoFAcR1hRlP2mAxOs7V31Mre4QKN5BG/du0BluLg+VOBorsrb9j7TutNbpP8y 3JqJGpiHG5tQHOE7CyVLyr2SnDs38sJ3wL0oAzz0q9ezic/QBCMBFtRwgsnuLp0GvzZF DDHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=aSjDAH2snju8R3q+4/T0EE6wjXqyrlifnf57RELtEPo=; b=TJKTDqqvTD+C87YvTLzvgwY+w9t37iNvoBoow7YTBhNsl5G0R0cKzNpOPCvUlA9bWi A/2rtZ+PZJ/zArKboRZ2VQYyoUX0Mvh0WBdpJzH0eLvPggFv4bgLft7vQzusRdF+UbCZ 8GzB/ppq95iNwR8rVJP9Qgvz3Y556Oc+99J9nXrT2Draue0/+Y0h2RGTs5pGT8E+tcfc XgomNsixqqUiApyDzyDeEX5fFQPs7qd9EK9YMYm5WRkw5aYRDHGAviRKtbZgwgo5rgZm HiY/D5XBcJT0xtW1Mg4RVbcrtJPUZZ4Mm2mAJnwcWhlHS6XWsgHDawUNA3tYHFjXKz9f pT+Q== X-Gm-Message-State: AOAM530DVdBVMUD7LjTGDFa1i/Ko6yHWkIl8mBf1mJ7lB8cfAdAojNIh tJGJtHiSMq+1Tv187HpLKRU= X-Google-Smtp-Source: ABdhPJwCKtAYprKKYxxF3JdUnbgwkJ2ifDcJjSlJEycf+CXdgujOEgIYaEmIkzffMUV24P0Rs870eg== X-Received: by 2002:a5d:69cd:: with SMTP id s13mr4120447wrw.379.1600942603215; Thu, 24 Sep 2020 03:16:43 -0700 (PDT) Received: from localhost ([217.111.27.204]) by smtp.gmail.com with ESMTPSA id y6sm2968176wrt.80.2020.09.24.03.16.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Sep 2020 03:16:41 -0700 (PDT) Date: Thu, 24 Sep 2020 12:16:40 +0200 From: Thierry Reding To: Marek Szyprowski Cc: Joerg Roedel , Shaik Ameer Basha , Robin Murphy , Ajay kumar , Linux IOMMU , linux-mm@kvack.org, Rob Clark , jean-philippe@linaro.org, will@kernel.org, hch@lst.de, baolu.lu@linux.intel.com, Shaik Ameer Basha Subject: Re: IOVA allocation dependency between firmware buffer and remaining buffers Message-ID: <20200924101640.GE2483160@ulmo> References: <59cda41f-170c-a1ad-a345-bc38b9ed4d73@arm.com> <11584d09-5995-6133-3bd3-8f7a0afd0e01@samsung.com> <20200924082830.GB27174@8bytes.org> <37e767b8-8ec4-ae80-ea0d-1caf3cdab8fa@samsung.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="7CZp05NP8/gJM8Cl" Content-Disposition: inline In-Reply-To: <37e767b8-8ec4-ae80-ea0d-1caf3cdab8fa@samsung.com> User-Agent: Mutt/1.14.7 (2020-08-29) X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: --7CZp05NP8/gJM8Cl Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Sep 24, 2020 at 10:46:46AM +0200, Marek Szyprowski wrote: > Hi Joerg, >=20 > On 24.09.2020 10:28, Joerg Roedel wrote: > > On Wed, Sep 23, 2020 at 08:48:26AM +0200, Marek Szyprowski wrote: > >> It allows to remap given buffer at the specific IOVA address, although > >> it doesn't guarantee that those specific addresses won't be later used > >> by the IOVA allocator. Probably it would make sense to add an API for > >> generic IOMMU-DMA framework to mark the given IOVA range as > >> reserved/unused to protect them. > > There is an API for that, the IOMMU driver can return IOVA reserved > > regions per device and the IOMMU core code will take care of mapping > > these regions and reserving them in the IOVA allocator, so that > > DMA-IOMMU code will not use it for allocations. > > > > Have a look at the iommu_ops->get_resv_regions() and > > iommu_ops->put_resv_regions(). >=20 > I know about the reserved regions IOMMU API, but the main problem here,= =20 > in case of Exynos, is that those reserved regions won't be created by=20 > the IOMMU driver but by the IOMMU client device. It is just a result how= =20 > the media drivers manages their IOVA space. They simply have to load=20 > firmware at the IOVA address lower than the any address of the used=20 > buffers. I've been working on adding a way to automatically add direct mappings using reserved-memory regions parsed from device tree, see: https://lore.kernel.org/lkml/20200904130000.691933-1-thierry.reding@gma= il.com/ Perhaps this can be of use? With that you should be able to add a reserved-memory region somewhere in the lower range that you need for firmware images and have that automatically added as a direct mapping so that it won't be reused later on for dynamic allocations. Thierry --7CZp05NP8/gJM8Cl Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCAAdFiEEiOrDCAFJzPfAjcif3SOs138+s6EFAl9scgUACgkQ3SOs138+ s6H9BhAAmPnnd7f1xF0OFvCBxYdVGJNgcXZ7BIrZYlC5j+o/KcGZeVycNplEvNMU vJMRLxDCE4xNx5nYf1xfLNovACaJ0vG2/fgdjIbGVVRPcehtz9b0TNVXCdp8OgVK uucQqx7/Pt34GRNLxVs99les7VYl9VffLL6BJWJ0ObuR6wtg6N50PcVXUXwnOEuX ojX6IUwPugc/64v1Go/8M384PWqggWzTgUD23RBhiLlGZoQD4xbMYsTLFmSutj16 qOix3SC5qDihQYFBZueF9iBTMBHtAlRSixxCZQh/7nBNkn56xm29VWe3C1b7d0eB vd/Yme5eSez/4tK71ml12mu2wvSv3pzrvKZwD2z6sDWoJX70tFWpnuLZCjZgjjlS 4abXFGtyLlPLDWJW5IWQiQulyMlQ1fk2NnKwZ9AUNOwXECIkf0JDgwqPznLi2S46 sarkEXPwrBW8OSBhwGlUasvw93IQHa+PxS12WT1LIIysUf0YMtRFP8G/c/rw+l42 M6BSXDxwN+bW7Hocae4IheLpVeuE/ycVClEG0S7uu+JIuloRuL8YePp4mPSPak0/ lJpt3rm0RHRaAzcdJ74R3wA8CJXyRRg+tQoyH88sj1JXD/zNneyqqmwRwTe3PiFh gasKuQv+uMHiJhna6XvHKskzVw5Eh+gVkSdVAbI6omLFKyICYfY= =THJe -----END PGP SIGNATURE----- --7CZp05NP8/gJM8Cl--