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 87B8AC4363D for ; Thu, 24 Sep 2020 14:33:11 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 0994C2220D for ; Thu, 24 Sep 2020 14:33:10 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="TwhIrp96" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0994C2220D 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 370B78E0001; Thu, 24 Sep 2020 10:33:10 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 320C66B005D; Thu, 24 Sep 2020 10:33:10 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 20FF48E0001; Thu, 24 Sep 2020 10:33:10 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0173.hostedemail.com [216.40.44.173]) by kanga.kvack.org (Postfix) with ESMTP id 083756B005C for ; Thu, 24 Sep 2020 10:33:10 -0400 (EDT) Received: from smtpin16.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id C13D72470 for ; Thu, 24 Sep 2020 14:33:09 +0000 (UTC) X-FDA: 77298197298.16.help70_000d0b92715f Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin16.hostedemail.com (Postfix) with ESMTP id A871B10123F9D for ; Thu, 24 Sep 2020 14:33:09 +0000 (UTC) X-HE-Tag: help70_000d0b92715f X-Filterd-Recvd-Size: 7492 Received: from mail-wr1-f68.google.com (mail-wr1-f68.google.com [209.85.221.68]) by imf04.hostedemail.com (Postfix) with ESMTP for ; Thu, 24 Sep 2020 14:33:08 +0000 (UTC) Received: by mail-wr1-f68.google.com with SMTP id m6so4122758wrn.0 for ; Thu, 24 Sep 2020 07:33:08 -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=MsatcEHSQFvWMlRInUfKW6BCLff8AD73JZ7rX3OfMM8=; b=TwhIrp96H14uVN9tZJjHeh/CQnRq/CUna+Ngssh4dqKiMW/JzDn7qWsKs0QukCvMMc dI+GNseO9PoWBM39BHTD7grMnf32mYCdZP1RN4xmYVXaKr0/bc1qkJcOtUtVsEe8LDwa x9ZkcFgp3hp1LD4XIoJ/U2ZOZNF6TxcI8wZgZGh9yovlwufNL7rMEHPuXBqiyKOOWUXi 959w3EGjAfNBOkMrdckhZBrOhnLphzFca0gFXACDQBxvR7Ot7thQPcF8rTUHWsxXU179 U8EUv+q2ZQk0y7EIXZsx/3xqLP66SCNeI9ZeiYFNdkOk7Xph2TU7AmfW2B2MCAnO0Nax MIug== 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=MsatcEHSQFvWMlRInUfKW6BCLff8AD73JZ7rX3OfMM8=; b=KCrb5TjrnEKj7yDBHAwjzoK62DJ/zDvFsktmRofnsKXuOzRK23tnvlLMMURKyN78/Z jGcDwTBeeo5QxR46ni6aPuMH6weK1Itjb0G/T2YailY6W70quBf13AoF28cmPGpTgGNf B1YY+wz/V8IpToMjt8UyNofRmzd10A+9dieNYE7FSqyC+YFK8urnLJtqE7Rr9xCcKlqE Ud5BqKse6gC3yCCBLbteWWeXBgVsZZ0IjzC8cFn7rsBApCw52UnS1wiVgregA6fud/m8 bu/NsfGWBd8wd5zTE4wV+2g6a8YwyOHEFKw90Roa8ElS+EUuFRGTVqSEI/yaWMqoRWJK 1UHQ== X-Gm-Message-State: AOAM533pVosSlCpfoTmO+DXrvdeWs9DnAoYYI+6MrQmcne1QirWenPXd jH6BW4pJ4FWcNP6b0u1oRvw= X-Google-Smtp-Source: ABdhPJySTNV3Gh2SLKq9Es0zyjW1sXzUyxQ2vgtBS1NRxfkElGSkiJAlBOiHkgNOtsh9a3+kPF0Lpw== X-Received: by 2002:adf:f5c7:: with SMTP id k7mr84776wrp.246.1600957987713; Thu, 24 Sep 2020 07:33:07 -0700 (PDT) Received: from localhost ([217.111.27.204]) by smtp.gmail.com with ESMTPSA id i14sm3993711wro.96.2020.09.24.07.33.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Sep 2020 07:33:05 -0700 (PDT) Date: Thu, 24 Sep 2020 16:33:04 +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: <20200924143304.GB2527337@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> <20200924101640.GE2483160@ulmo> <1451f2dc-b64f-e7df-f0fa-f4107e18ee35@samsung.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="GID0FwUMdk1T2AWN" Content-Disposition: inline In-Reply-To: <1451f2dc-b64f-e7df-f0fa-f4107e18ee35@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: --GID0FwUMdk1T2AWN Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Sep 24, 2020 at 12:41:29PM +0200, Marek Szyprowski wrote: > Hi Thierry, >=20 > On 24.09.2020 12:16, Thierry Reding wrote: > > On Thu, Sep 24, 2020 at 10:46:46AM +0200, Marek Szyprowski wrote: > >> 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, althou= gh > >>>> it doesn't guarantee that those specific addresses won't be later us= ed > >>>> 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(). > >> I know about the reserved regions IOMMU API, but the main problem here, > >> in case of Exynos, is that those reserved regions won't be created by > >> the IOMMU driver but by the IOMMU client device. It is just a result h= ow > >> the media drivers manages their IOVA space. They simply have to load > >> firmware at the IOVA address lower than the any address of the used > >> 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.redin= g@gmail.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. >=20 > Frankly, using that would be even bigger hack than what I've proposed in= =20 > my workaround. I see no point polluting DT with such artificial regions= =20 > just to ensure specific IOVA space layout. I think I misunderstood the requirements that you have. Sounds like there are no actual restrictions for where exactly the memory resides for the firmware, it just has to be lower than any of the buffer allocations. I agree, in that case using reserved memory regions does not make sense at all. Thierry --GID0FwUMdk1T2AWN Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCAAdFiEEiOrDCAFJzPfAjcif3SOs138+s6EFAl9srhwACgkQ3SOs138+ s6Fc7g/6A2Cp3eZpcHF0cd3eW5gVBXB88kLcUUeD0VxSf5Iv2XUJESqQnWe/l8ok VL6RyHOFTBJYP85WadEyoGoeWfCCIqjTCRQ822jYCuDYyd9b+gbiPMgt9jpT+K9R 0dyFGPQ+cGFpRyW0wAqEOS0aSXx3/CGkFaRYtKW2F8r0lzisjfkGB4FFAp1qMzsQ VCLt+fKrLGXJn6QGcAyoI5q9oQxQKdvMd3ezpMaLMig6zZRgXQXn/ozx0zUQBhmO WiOeQg3S8dBV1wxEH9IldweFBxo7DHCoIDp+n3UNpBIAYgfXeyFX90rZpqxC7oyB allMlErNm1yQNfKz6dt+cbnO9sujnL1jSEBVLp3LCpxNGxjKn7oIXXHL4k4v+HlD FpPgfjN4YR9Eb154uYQ6Vu68eDFce/iDLLEQU76o1kXapMRFl/r3KYij95sZPOe3 KyqXN9h+MBOvcFCxXszm3bCl+bWZY+++duRd6fq8ipccjWTU61Dvz4/mtQaSIIS6 u23k/dExNW719AqL/cTck0NnAHOSJZHwuiDOP2a8P1jPwzOeo26+tTQRoo/bLenC GpwZfonqUshLZtvxzQM4R0+OyApWBn+9CMyUKACnvc2Nj3o4drswpBtmMlvNHTv/ rBAupHSkMW31kAEI7dsBUmEJbsrC3XEbSn0G45iu+oOpggYc6bc= =+L/4 -----END PGP SIGNATURE----- --GID0FwUMdk1T2AWN--