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=-15.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=unavailable 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 A3A81C433ED for ; Wed, 7 Apr 2021 09:56:33 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 32CF261382 for ; Wed, 7 Apr 2021 09:56:33 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 32CF261382 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References:Message-ID: Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=4ZxtM2VOJVf85B28r3B3mS/dypPPQeHCVbbi1QSnhos=; b=VXZTFGrI3KYQ6e778Pwcvzmou 1oTTUxcTZsQgTXcQQL0ExsH5yPjGGhIgDvVQuPNnodXKGXvqu/6XzVWTDrtjm1f25A54OYqhsAJzy x10b4JIHkFDYWc0yh9MkS5vhzNPHR0w3PVS1CpncQKeG68R0E3ulG9addvUDgPljmsLUglFB36bFv AXxCWdbwecglqCm/HnmONy0m5gbxdiC+0IEefa+AabNL+/quVtZTzg1D5mZ6j5Cop0LIV600bGSRR tBYl4QOlMXRhab446QNFx6chgyJmQKw5rfsSsE4l9WSJ4X9y/fFMHTYUaq4bHa9HNAtyDuaIlYx9D x6GcYeYJg==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lU4tR-004eto-0n; Wed, 07 Apr 2021 09:54:38 +0000 Received: from mail.kernel.org ([198.145.29.99]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lU4tM-004esl-Dx for linux-arm-kernel@lists.infradead.org; Wed, 07 Apr 2021 09:54:34 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id AE12661382; Wed, 7 Apr 2021 09:54:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1617789270; bh=IDtrPHkJJOYZTWgUxwdWXTJZs4VaWPqqNPI5cyUO7jQ=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=FQ87ilWdr6b99mYNAwtdjO8sUVMD7/lvflLODf9ymnMJ8mjw5hZtDrjkYFdBiw8q7 KMmekW5H0hW62Ult2Ajp5jqdTm75ZwRoj9qGipIoAMwsVA6g46Z7L9G2KT79XUyN2p bhnfAFK0KiY1tCyYlGF+hI5jwvmezshFkQgKqhIhNHxdS4J/HRX5iOVRzRn99tr3si mYRZzJXH3UJE+CFhwq3ZsxRQw+cG33PK7rTKVsL5/EqPPTWBPn5I1eyIICNCuZTlBg wuVG5EJ4wjP9pXAdRfbCPNTATGhtFKqVUCNgWd9PsPfaoTdDXBHf6wz+3a9qxvZrSS a6p00b2NJeOtw== Date: Wed, 7 Apr 2021 10:54:26 +0100 From: Will Deacon To: isaacm@codeaurora.org Cc: iommu@lists.linux-foundation.org, linux-arm-kernel@lists.infradead.org, robin.murphy@arm.com, pratikp@codeaurora.org Subject: Re: [RFC PATCH v3 03/12] iommu/io-pgtable: Introduce map_pages() as a page table op Message-ID: <20210407095425.GA15057@willie-the-truck> References: <20210405191112.28192-1-isaacm@codeaurora.org> <20210405191112.28192-4-isaacm@codeaurora.org> <20210406115739.GD13747@willie-the-truck> <75a5d309498b8b41b5e24a2d9d36e78f@codeaurora.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <75a5d309498b8b41b5e24a2d9d36e78f@codeaurora.org> User-Agent: Mutt/1.10.1 (2018-07-13) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210407_105433_038682_C33D252A X-CRM114-Status: GOOD ( 27.20 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Tue, Apr 06, 2021 at 02:07:41PM -0700, isaacm@codeaurora.org wrote: > On 2021-04-06 04:57, Will Deacon wrote: > > On Mon, Apr 05, 2021 at 12:11:03PM -0700, Isaac J. Manjarres wrote: > > > Mapping memory into io-pgtables follows the same semantics > > > that unmapping memory used to follow (i.e. a buffer will be > > > mapped one page block per call to the io-pgtable code). This > > > means that it can be optimized in the same way that unmapping > > > memory was, so add a map_pages() callback to the io-pgtable > > > ops structure, so that a range of pages of the same size > > > can be mapped within the same call. > > > > > > Signed-off-by: Isaac J. Manjarres > > > Suggested-by: Will Deacon > > > --- > > > include/linux/io-pgtable.h | 4 ++++ > > > 1 file changed, 4 insertions(+) > > > > > > diff --git a/include/linux/io-pgtable.h b/include/linux/io-pgtable.h > > > index 2ed0c057d9e7..019149b204b8 100644 > > > --- a/include/linux/io-pgtable.h > > > +++ b/include/linux/io-pgtable.h > > > @@ -143,6 +143,7 @@ struct io_pgtable_cfg { > > > * struct io_pgtable_ops - Page table manipulation API for IOMMU > > > drivers. > > > * > > > * @map: Map a physically contiguous memory region. > > > + * @map_pages: Map a physically contiguous range of pages of the > > > same size. > > > * @unmap: Unmap a physically contiguous memory region. > > > * @unmap_pages: Unmap a range of virtually contiguous pages of > > > the same size. > > > * @iova_to_phys: Translate iova to physical address. > > > @@ -153,6 +154,9 @@ struct io_pgtable_cfg { > > > struct io_pgtable_ops { > > > int (*map)(struct io_pgtable_ops *ops, unsigned long iova, > > > phys_addr_t paddr, size_t size, int prot, gfp_t gfp); > > > + int (*map_pages)(struct io_pgtable_ops *ops, unsigned long iova, > > > + phys_addr_t paddr, size_t pgsize, size_t pgcount, > > > + int prot, gfp_t gfp, size_t *mapped); > > > > How about returning 'size_t' and using IS_ERR_VALUE() instead of adding > > the extra 'mapped' argument (i.e. return the size of the region mapped > > or an error code)? I don't think we realistically need to care about map > > sizes that overlap with the error region. > > > I'd given that a shot before, but the problem that I kept running into was > that > in case of an error, if I return an error code, I don't know how much memory > was mapped, so that I can invoke iommu_unmap from __iommu_map with that size > to > undo the partial mappings from a map_pages() call. Ah yes, sorry, I see it now. So keep this as you've got it. Pushing the cleanup path deeper doesn't feel like the right thing to do. Will _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel