Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3505240pxb; Mon, 24 Jan 2022 10:58:46 -0800 (PST) X-Google-Smtp-Source: ABdhPJzkWmzkp79Tvy6HaFdg33LBt/2ScXVREVjshB1CwVb4/Yy9hXyz5gmSCvZCfR09LPQoF1Wf X-Received: by 2002:aa7:825a:0:b0:4c7:f79e:9fcc with SMTP id e26-20020aa7825a000000b004c7f79e9fccmr9492374pfn.8.1643050726781; Mon, 24 Jan 2022 10:58:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643050726; cv=none; d=google.com; s=arc-20160816; b=iH6zZ772qWTN0FcO2s4sPcK6fdcSMl1Vtfu6s+eWXxG4vhc/T2bn5DNwoIrZ+M9ByK wxKVubdJJ0ac6Pf8KagNBNf6E/VtorCCQWXxeFCTXoFS4dFgxt3XZfH4dbprkgc0EV9r nf0JiBNbO3pgwtagpbA/L8gZdi/k0Tp4Rj7saWGB81mRCtxYXN37/rOBweTKf/pAIxTd px7eEIr4iy/xStJq5tQsCURZzShDRWylyHTMETdvGLmXAdeXfylYUXwL0AlfJbUftbIJ MjZJoNYrZcLP/qB1xHprmjK0mmvghwoMknB4y60BNpfXhq7zZ+gMUQ19JHO/9FyEBw+e 4pfg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=z/r63EfvVm9RGMh2KAen4T39zB4cnOCdcpB+cKli6kk=; b=UcTjyLwS1OOE6kkr5PwhV0cZD/dUPr1cvW+dxUYn/8WRk2yjD/s3ajrxg/oXqhnRcb WDYexKYHmsYaVZH95BVCTyfquXN4Sdz9az7L7WvBMICsskyQRmMnbG1No5wQ9gLqB9WA p4x/EORWiP9KyDP37sPqZ43nN4GDbaeyfmo/nwB67BElbw0Yntn/6BpJMMg3SIe5ALnd RPl6vhiDIGAzAHO/r/c2Z57T0FmmpAI+7BUkMmwbKmFfDSTVR6s7sqxgv9TBT81G/cHZ B+PYHac6AOkS5LwYYgzLYdV8k5HcyUnu/3vlgTNh2CuKfJekMnvE+CuFiADlXntnEeAq KTeg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=44hIObpm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y7si15017405pfi.78.2022.01.24.10.58.33; Mon, 24 Jan 2022 10:58:46 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=44hIObpm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231856AbiAXJhc (ORCPT + 99 others); Mon, 24 Jan 2022 04:37:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53298 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229629AbiAXJha (ORCPT ); Mon, 24 Jan 2022 04:37:30 -0500 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B3986C06173B for ; Mon, 24 Jan 2022 01:37:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=z/r63EfvVm9RGMh2KAen4T39zB4cnOCdcpB+cKli6kk=; b=44hIObpmhtBGdpXCw/Owm1z15D gX3B43MrVba/2WBdQfup9/lzCAMQUm574OPNrXbV9oozMfw5HxE96QnNtc8jdo9JbaFSEQsq69UHq xYViMyqTzihvBZAyNoQHnIh39jq5hr7SBtYvZn3S3GW1s3LiVnrPbxdul/P8pIUT5cGDzRuLcyJ6J o098rl9sploiMtLIIa/7RPAv8stiyivLwWVQ6wSaI3BMD5kYiYImyma7TCz8XIy9B2+iB8Wc2ODZq v9IJe+4PH9SUnn+OHDjjsVrp0A0cctGZf45rGQv1GUhVOYhPAQ5RapGmD/t7d5wsFASILlYgnlSzZ 1xm7p5YA==; Received: from hch by bombadil.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1nBvmr-002p4d-M0; Mon, 24 Jan 2022 09:37:21 +0000 Date: Mon, 24 Jan 2022 01:37:21 -0800 From: Christoph Hellwig To: Lu Baolu Cc: Joerg Roedel , Jason Gunthorpe , Christoph Hellwig , Ben Skeggs , Kevin Tian , Ashok Raj , Will Deacon , Robin Murphy , Alex Williamson , Eric Auger , Liu Yi L , Jacob jun Pan , David Airlie , Daniel Vetter , Thierry Reding , Jonathan Hunter , iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 7/7] iommu: Add iommu_domain::domain_ops Message-ID: References: <20220124071103.2097118-1-baolu.lu@linux.intel.com> <20220124071103.2097118-8-baolu.lu@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220124071103.2097118-8-baolu.lu@linux.intel.com> X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jan 24, 2022 at 03:11:02PM +0800, Lu Baolu wrote: > Add a domain specific callback set, domain_ops, for vendor iommu driver > to provide domain specific operations. Move domain-specific callbacks > from iommu_ops to the domain_ops and hook them when a domain is allocated. Ah, that's what I meant earlier. Perfect! Nit: I don't think vendor is the right term here. Maybe something like: iommut: split struct iommu_ops Move the domain specific operations out of struct iommu_ops into a new structure that only has domain specific operations. This solves the problem of needing to know if the method vector for a given operation needs to be retreived from the device or th domain. > +struct domain_ops { This needs to keep an iommu in the name, i.e. iommu_domain_ops. > + phys_addr_t (*iova_to_phys)(struct iommu_domain *domain, dma_addr_t iova); Overly long line. > +static inline void iommu_domain_set_ops(struct iommu_domain *domain, > + const struct domain_ops *ops) > +{ > + domain->ops = ops; > +} Do we really need this helper? > +static const struct domain_ops amd_domain_ops; Can we avoid these forward declarations or would that cause too much churn?