Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp156134pxb; Fri, 16 Apr 2021 02:08:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwNqVZXOJ3/i2WRjfTH5VTinPiQ21VaCcSney/yQewKWSXgqFQKeEh5WsqLgPo2mh6i5W55 X-Received: by 2002:a05:6402:212:: with SMTP id t18mr8837060edv.165.1618564129181; Fri, 16 Apr 2021 02:08:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618564129; cv=none; d=google.com; s=arc-20160816; b=TnTkm401xzfcHX+YoN4opzaXZiswdanQeZfZKU2ajNQV8zA5d55rmLKAel1vXCVC+A QX2i5Zn4pm594quJugRpujboLhEb9HrmvESSkjMKmSkMFBJ8NYpegZEegKhFX2eyF1DC vh3Voe/MCgfj2g2dj0DtOHHkExDLn4AIeHK5mYry2KtPhfA0gvr+h1IqCxz9BpekpEXl ZicoJqpNKycDnVyynlw3n4gVnKG3i4lQUl2fNHBhOH2TSTPb3pT02MwzX2yqB4cYDj+o /eq/6oDrxp6db/c/SaVJfP5IlOhBDd37Fdj4yweMbjenwyMi47nabGmh5maJ+3j5EzgS wQFQ== 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 :mime-version:user-agent:date:message-id:from:cc:references:to :subject; bh=hS3kA64kshtYaweEnkxTIvfJjD4q4j93x7dk3fz8kc0=; b=mYPamcxsh85j06NtI6YsfwrVWds7lQ6SwClY8egrw8HBjquUVUEo4N0uUy5SUAe8Zn eMB7Fp+Dl5/B7H2IUlzplWfy5E9yZEUpxDOmz0f950tb3ngysigl2qIIJcWYHl7qjG/m 93LcsAvdKKSnewkHpxeA/1iumlvt5jUj9SacB8KRlWqFB/8CqD4KoLpH3SZ3+ARE9L5p gkjm7Ht+SYiKvlDsWGViW9D1R3SU8ARUd/rcGyXTE3RIqTB9m+34PPYRFOcPxZPck+Ih ZVW53+IMlUb6ixpl4esrLmVUQJPzQp3DZXAOOCriy7MmuyThp7PEBLQZaxBDT8SmtdcD v+eg== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id hc13si4384834ejc.352.2021.04.16.02.08.25; Fri, 16 Apr 2021 02:08:49 -0700 (PDT) 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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240580AbhDPJIB (ORCPT + 99 others); Fri, 16 Apr 2021 05:08:01 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:16469 "EHLO szxga05-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235236AbhDPJIA (ORCPT ); Fri, 16 Apr 2021 05:08:00 -0400 Received: from DGGEMS409-HUB.china.huawei.com (unknown [172.30.72.60]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4FM9K82181zwRnd; Fri, 16 Apr 2021 17:05:16 +0800 (CST) Received: from [10.174.187.224] (10.174.187.224) by DGGEMS409-HUB.china.huawei.com (10.3.19.209) with Microsoft SMTP Server id 14.3.498.0; Fri, 16 Apr 2021 17:07:28 +0800 Subject: Re: [PATCH v3 01/12] iommu: Introduce dirty log tracking framework To: Lu Baolu , , , , Robin Murphy , Will Deacon , "Joerg Roedel" , Yi Sun , "Jean-Philippe Brucker" , Jonathan Cameron , Tian Kevin References: <20210413085457.25400-1-zhukeqian1@huawei.com> <20210413085457.25400-2-zhukeqian1@huawei.com> <56b001fa-b4fe-c595-dc5e-f362d2f07a19@linux.intel.com> <88cba608-2f22-eb83-f22e-50cb547b6ee8@huawei.com> <2c01425f-813c-4278-ba06-26d651496a5c@linux.intel.com> CC: Alex Williamson , Cornelia Huck , Kirti Wankhede , , , , From: Keqian Zhu Message-ID: <64c87f67-3687-61bd-1587-724cc2f9cc97@huawei.com> Date: Fri, 16 Apr 2021 17:07:27 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.7.1 MIME-Version: 1.0 In-Reply-To: <2c01425f-813c-4278-ba06-26d651496a5c@linux.intel.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.174.187.224] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Baolu, On 2021/4/15 18:21, Lu Baolu wrote: > Hi, > > On 2021/4/15 15:43, Keqian Zhu wrote: >>>> design it as not switchable. I will modify the commit message of patch#12, thanks! >>> I am not sure that I fully get your point. But I can't see any gaps of >>> using iommu_dev_enable/disable_feature() to switch dirty log on and off. >>> Probably I missed anything. >> IOMMU_DEV_FEAT_HWDBM just tells user whether underlying IOMMU driver supports >> dirty tracking, it is not used to management the status of dirty log tracking. >> >> The feature reporting is per device, but the status management is per iommu_domain. >> Only when all devices in a domain support HWDBM, we can start dirty log for the domain. > > So why not > > for_each_device_attached_domain() > iommu_dev_enable_feature(IOMMU_DEV_FEAT_HWDBM) Looks reasonable, but the problem is that we just need to enable dirty log once per domain. > > ? >> >> And I think we'd better not mix the feature reporting and status management. Thoughts? >> > > I am worrying about having two sets of APIs for single purpose. From > vendor iommu driver's point of view, this feature is per device. Hence, > it still needs to do the same thing. Yes, we can unify the granule of feature reporting and status management. The basic granule of dirty tracking is iommu_domain, I think it's very reasonable. We need an interface to report the feature of iommu_domain, then the logic is much more clear. Every time we add new device or remove device from the domain, we should update the feature (e.g., maintain a counter of unsupported devices). What do you think about this idea? Thanks, Keqian