Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3994619pxb; Tue, 25 Jan 2022 00:57:33 -0800 (PST) X-Google-Smtp-Source: ABdhPJxSGFjxV0yHnJuvVtNxiV0IMU7L8dkOqZ6IwSuEnciDtZl0Qpou/MWqF1euA0MzowkOIXSb X-Received: by 2002:a63:5b5f:: with SMTP id l31mr2842130pgm.427.1643101052940; Tue, 25 Jan 2022 00:57:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643101052; cv=none; d=google.com; s=arc-20160816; b=eaWNp2JkNuK+WN9UdTuJXLW+qJC4aDNApjEvwe1egWhmFUrP99YqB9qu77F2zIpGOT MDVPCaDP82mBHQK0lqeWgQMruVLqMyBuO0n+FqDxdtgcA1KNc+Kw2d3KleCRanJkAHvW zy8olrOlAAeOnbJC+A+owrxsTBF7Glm5Kr4r4FUJO0SXFfzqPZuA6ZOaBvXGJli4if/B 2XKc7TVhqD6YjdYVQofgsiEkwZN335OvAQr7MqRG/psgEj5f7AeqMW8kdy0JiERE+dml NgNxlDGSnFumTFHzOktZBk1xWPiku3B8L9wFX5CYZwyDsh+OnRoUgKhE5Z7xJrP5Py+/ q1sg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :to:subject:cc:dkim-signature; bh=dxeo2Z/FWPVldYZa+YreyZ/Yd6quXw0NYVDW+0Fq7NY=; b=HYVWygTYA8V/kTZDqsyOjvqJjVeNkef/I8jCdOLJE4KbFQERiWnLKFIp4b8HQ72Fr8 JNvibp8aQ7IPz/yn0mKCsacumcn1DcDq6aHluvF67XJ/HOITgPk0kMED37ylWz7vsQGJ iTFJmg2E/DIbi0Vvq2UWamAO9zd0BJQkFSibnR3S9xEg2Ked5xqcOcixZpyOslNjgH1D quW479JkVazrojWzyqx1Yq5GVrMFnuJ7Isc60Em7/qrMUt9fkVZK9rGOYlR1F6zKf+Y6 I2EoAcYopUhiedRPYD//hxZKzwhOX1DhF2zf//+XqRX5woKIdwrolic9f0zGwhoAzYmL nQkg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=WqqCtDqH; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id mi3si1789878pjb.99.2022.01.25.00.57.21; Tue, 25 Jan 2022 00:57:32 -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=@intel.com header.s=Intel header.b=WqqCtDqH; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1324654AbiAYEw4 (ORCPT + 99 others); Mon, 24 Jan 2022 23:52:56 -0500 Received: from mga02.intel.com ([134.134.136.20]:56207 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1325657AbiAYEn4 (ORCPT ); Mon, 24 Jan 2022 23:43:56 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1643085836; x=1674621836; h=cc:subject:to:references:from:message-id:date: mime-version:in-reply-to:content-transfer-encoding; bh=ePB8x5wsn46fcq0gstZC9w5tmuRZOJRLGU6KysgfNoE=; b=WqqCtDqH5DNkEa6FYxhKPyQ9RApBxIMMbkvlJkSLSnS9j7iw4dLsd3FR 66dHYB4LVAR36U16XsYRPsBYiYwHC897pws24zV5FVteeUsA9+AEiA9tS mDF8muX1JeumUSbzED+hVFjx83Ff62gHzE7Z30Ymj6CHALRumkFdF/R4/ 5iGNKPkIvEqpj6o262Q5wQZ8bhdsrzOeyT3ELrUcngYkMe3VWboIakkBa LSajQ/LF+WUPLKYrRa9HjitF4LHSO98JU9IKQau9odszOaDW68bg/rPXb s3IFewZhVvdZwLRr2dSDnatNdicn83jGr25f3XP+8BVJWZlAjHaEJ+yO0 Q==; X-IronPort-AV: E=McAfee;i="6200,9189,10237"; a="233585515" X-IronPort-AV: E=Sophos;i="5.88,314,1635231600"; d="scan'208";a="233585515" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Jan 2022 20:43:55 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.88,314,1635231600"; d="scan'208";a="534559224" Received: from allen-box.sh.intel.com (HELO [10.239.159.118]) ([10.239.159.118]) by orsmga008.jf.intel.com with ESMTP; 24 Jan 2022 20:43:50 -0800 Cc: baolu.lu@linux.intel.com, Joerg Roedel , Jason Gunthorpe , 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 To: Christoph Hellwig References: <20220124071103.2097118-1-baolu.lu@linux.intel.com> <20220124071103.2097118-8-baolu.lu@linux.intel.com> From: Lu Baolu Message-ID: <62b47e7f-8704-24b1-2a94-bc456e7ad3a0@linux.intel.com> Date: Tue, 25 Jan 2022 12:42:50 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.14.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 1/24/22 5:37 PM, Christoph Hellwig wrote: > 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. Sure. Will use above description. > >> +struct domain_ops { > > This needs to keep an iommu in the name, i.e. iommu_domain_ops. Sure. > >> + phys_addr_t (*iova_to_phys)(struct iommu_domain *domain, dma_addr_t iova); > > Overly long line. ./scripts/checkpatch.pl --strict *.patch didn't give me a WARN or CHECK. I will make it short anyway. > >> +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? Unnecessary. I can set the pointer directly in the drivers. > >> +static const struct domain_ops amd_domain_ops; > > Can we avoid these forward declarations or would that cause too much > churn? > I don't like this either. But it's common to put the ops at the bottom of the file in almost all iommu drivers. Best regards, baolu