Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp9263982rwd; Wed, 21 Jun 2023 05:22:52 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4NihGTvdWqzkT+r4eOnWtx6K64pV+UhwhbKNuLd04Gz0gTiXdFrUcWHFAkse/0/UyWwyRH X-Received: by 2002:a17:90a:194a:b0:253:45ce:fad7 with SMTP id 10-20020a17090a194a00b0025345cefad7mr9170199pjh.31.1687350171973; Wed, 21 Jun 2023 05:22:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687350171; cv=none; d=google.com; s=arc-20160816; b=ExpcHNyk/sOxGb38F5r5lCeAQNZYvEHQcLzKHjHNpAsBl5YbbBZ105s3SfIngiSeZC Cz+/nmLWpbJ7VNXXEngWgJ4mhbh6aE3spVGAn8K7z69uk7k080pPXEwsw9JC9M2FLg2/ GGmpkJ049FQOU4Ipakp+0KjNY0GqhyrgFdWpopGzpgr4zbeM0Tz6g3BPiPYr/3I50uCC p+G8S+f7rCToP9t9z3D/6YbvYDD0Sa8XK9W9U++8j609Mhs3NgTzze/GGLr6L2BeWTuS sgY7h8ya/lUYXPcM17/s54MUnivGGM5ujC0jhKFEcW3x5lCYMf/2vfFPiXN9rRZt93jk 23vw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id; bh=GBa4ozUaCrp8psBREdC2Anl9/TZKiKrxP9ythcfvuew=; b=ob8/+KL9hMkiOrY5AAHSsOFr79BDIUtbkW24dDrP4XxObrQg6nA9PB5900xJVUG4v3 wP8tyfjA4yEWIOVy4abg2YM61w/z/bILQ3H09HLKo/LRLMqVdyyv1G5+6uDL52LvY9WC drDvBcxjEII/55jA5GrErB8ea6fCYPKB4HooHEJBmMsZ64OHFQyA+vamS0kxoypT6qFf snqiPvegLS+2UeqDz7gVYT0wHe0d7tN7ZzexIOisxtES+580afuruEBZFNY5ihjeAvc9 cM/EAJX0iyDf56C8MZrn7VFLNLhsi29Rc+/x0JGv5R3dDcuVDIYs0iUgiV6nxGrKCa/3 nWog== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 40-20020a17090a09ab00b0025ea83fe637si11745067pjo.27.2023.06.21.05.22.38; Wed, 21 Jun 2023 05:22:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232256AbjFULay (ORCPT + 99 others); Wed, 21 Jun 2023 07:30:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51790 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231876AbjFULax (ORCPT ); Wed, 21 Jun 2023 07:30:53 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id EDC01E57; Wed, 21 Jun 2023 04:30:51 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 7324A1063; Wed, 21 Jun 2023 04:31:35 -0700 (PDT) Received: from [10.57.35.147] (unknown [10.57.35.147]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 410803F663; Wed, 21 Jun 2023 04:30:50 -0700 (PDT) Message-ID: Date: Wed, 21 Jun 2023 12:30:42 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; rv:102.0) Gecko/20100101 Thunderbird/102.12.0 Subject: Re: Question about reserved_regions w/ Intel IOMMU To: Alexander Duyck , Jason Gunthorpe Cc: "Tian, Kevin" , Alex Williamson , Baolu Lu , LKML , linux-pci , "iommu@lists.linux.dev" References: <520e2be4-726f-c680-c010-a308cdddbae0@arm.com> <90823b33-1f44-8789-9a38-282407fd9f15@arm.com> Content-Language: en-GB From: Robin Murphy In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2023-06-20 18:47, Alexander Duyck wrote: > On Tue, Jun 20, 2023 at 9:55 AM Jason Gunthorpe wrote: >> >> On Tue, Jun 20, 2023 at 07:57:57AM -0700, Alexander Duyck wrote: >> >>> I think this may have gone off down a rathole as my original question >>> wasn't anything about adding extra reserved regions. It was about >>> exposing what the IOVA is already reserving so it could be user >>> visible. >> >> Your question points out that dma-iommu.c uses a different set of >> reserved regions than everything else, and its set is closer to >> functionally correct. >> >> IMHO the resolution to what you are talking about is not to add more >> debugging to dma-iommu but to make the set of reserved regions >> consistently correct for everyone, which will make them viewable in >> sysfs. > > Okay, that makes sense to me, and I agree. If we had a consistent set > of reserved regions then it would make it easier to understand. It would also be wrong, unfortunately, because it's conflating multiple different things (there are overlapping notions of "reserve" at play here...). IOMMU API reserved regions are specific things that the IOMMU driver knows are special and all IOMMU domain users definitely need to be aware of. iommu-dma is merely one of those users; it is another layer on top of the API which manages its own IOVA space how it sees fit, just like VFIO or other IOMMU-aware drivers. It honours those reserved regions (via iommu_group_create_direct_mappings()), but it also carves out plenty of IOVA space which is probably perfectly usable - some of which is related to possible upstream bus constraints, to save the hassle of checking; some purely for its own convenience, like the page at IOVA 0 - but it still *doesn't* carve out more IOVA regions which are also unusable overall due to other upstream bus or endpoint constraints, since those are handled dynamically in its allocator instead (dma_mask, bus_dma_limit etc.) > If > nothing else my request would be to expose the iova reserved regions > and then most likely the other ones could be deprecated since they > seem to all be consolidated in the IOVA anyway. FWIW there's no upstream provision for debugging iommu-dma from userspace since it's not something that anyone other than me has ever had any apparent need to do, and you can get an idea of how long it's been since even I thought about that from when I seem to have given up rebasing my local patches for it[1] :) Thanks, Robin. [1] https://gitlab.arm.com/linux-arm/linux-rm/-/commits/iommu/misc/