Received: by 2002:a19:651b:0:0:0:0:0 with SMTP id z27csp3654825lfb; Mon, 9 May 2022 00:55:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzHzTEhLIrCJkqdPJlY9MrqterWrzH3iZfR29AWOrOFLBSxFjqNdWbVjjW6DAmKdpXH4GbX X-Received: by 2002:a65:6942:0:b0:378:9365:5963 with SMTP id w2-20020a656942000000b0037893655963mr12177813pgq.142.1652082946442; Mon, 09 May 2022 00:55:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652082946; cv=none; d=google.com; s=arc-20160816; b=Q0h59Q8uxpgXBFJwcPUoC9sFNzwhuZWJ0cY0jiyOnBnnffauSDAsoR87Ogf3dlIPEb aYOygUPYIf7zHehVhchLy/j3uoHmU2kxbUH1sHhxGDADg+XGQmrXoSK6aCbi+4I3iMU8 KUFx2NCQWDk6HdYWkehhVhMTFjNhHmkUtb8KE8ia9Vme3lagAzgDJR2Yhn57I+bglW34 HLu00m0TqkoT3ymvx8GVWInGeK++V4PguHlxzHJAVpcuhLy2wTT/BIsURmwaq6BBV+5r r6yAl5YHaPXeTmhBun+PHdGNj9dz2aklKydgYYAciEXI6nlAJA/zRZ0MzHELtm2+orE7 qPGA== 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:references :cc:to:from:content-language:subject:user-agent:mime-version:date :message-id:dkim-signature; bh=MSy/fh1ZP5Qc/8eA6x3Xr9DFgwWUxv3D04bRIHCjRV8=; b=fGkv1nHDQQMLiNIiXGyhidAHfhg2KYpgFVYYohpJc+5Kpb4kjlyl0ixCA77+jRtM7f N5OfSzr1FgncTjninrL5ZopQkoMNumCWT74beCwe8DkgvcoQ8U758MPAPDMUpUpH7JwQ WjoRPs38sBnCwY8FpYEdvcpABykrD0cph26HPgg3jCdD6dvKel9D3oJWyesfJG8LGsvo EklP+Bck6Ybq14jfCuTnfMVGYXverehb1LpQD5qAX2xQrbG7CyIGjP/3XXqSa5izgDeb rnvRN8E/3Lqm7gZo8tHef05ugg0INtYUznRZRP69fSI18RKegkn19mTpwkxcR/0XYDGV ND3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=REQLKspC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1: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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id d189-20020a621dc6000000b0050dec7ee78dsi12961722pfd.43.2022.05.09.00.55.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 May 2022 00:55:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=REQLKspC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1: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: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id C41AB1D043A; Mon, 9 May 2022 00:48:09 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1446087AbiEGIgx (ORCPT + 99 others); Sat, 7 May 2022 04:36:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54932 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1388495AbiEGIgu (ORCPT ); Sat, 7 May 2022 04:36:50 -0400 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 10DEE3EF31 for ; Sat, 7 May 2022 01:33:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1651912385; x=1683448385; h=message-id:date:mime-version:subject:from:to:cc: references:in-reply-to:content-transfer-encoding; bh=RBU8lfPbnJq0/IUDWjwcu17pUEjRs6Stfy9C+m2jzMs=; b=REQLKspCi7KiyR2n0dFZHx4vIfFY3T+q0vB5ccpa7Dvn6WzoAwHa5Ape jjTEkQz/GbG8rAFwiT4q0Nivp0Anwd+Wfp/jzdcxRtzLawnjX8Gkvdg+B k1BFUVNhZ527GFlxhvPQRWddm7YnxkgFfiSRqkH1heXlUloohJRQFNWYn 2eJE9zm+0FITJvJU7VhJv61e+UqGNJ6hvxpVLYUU1hPfdziyq89Hc6WzY 8K0s3vwqaIgaMyQDEPm4Q0NSODjuJvInKOypD7pVFPdKVu3GNrZ1Iu3D1 ImSJXDLk7oei9GnV2+D2mh0EjZVgd0wPXMaTMV0n/n976JKUmi8F1yzoE g==; X-IronPort-AV: E=McAfee;i="6400,9594,10339"; a="293893102" X-IronPort-AV: E=Sophos;i="5.91,206,1647327600"; d="scan'208";a="293893102" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 May 2022 01:33:04 -0700 X-IronPort-AV: E=Sophos;i="5.91,206,1647327600"; d="scan'208";a="586422113" Received: from zhuangxi-mobl.ccr.corp.intel.com (HELO [10.255.30.94]) ([10.255.30.94]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 May 2022 01:33:00 -0700 Message-ID: <669fb111-9821-aadc-acbf-de42bc551fc4@linux.intel.com> Date: Sat, 7 May 2022 16:32:58 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.8.1 Subject: Re: [PATCH v5 04/12] iommu/sva: Basic data structures for SVA Content-Language: en-US From: Baolu Lu To: Jean-Philippe Brucker Cc: Kevin Tian , Dave Jiang , Ashok Raj , Robin Murphy , iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org, Christoph Hellwig , Jean-Philippe Brucker , Vinod Koul , Jacob jun Pan , Jason Gunthorpe , Will Deacon References: <20220502014842.991097-1-baolu.lu@linux.intel.com> <20220502014842.991097-5-baolu.lu@linux.intel.com> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,RDNS_NONE,SPF_HELO_NONE, T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 Hi Jean, On 2022/5/5 14:42, Baolu Lu wrote: > On 2022/5/4 02:09, Jean-Philippe Brucker wrote: >> On Mon, May 02, 2022 at 09:48:34AM +0800, Lu Baolu wrote: >>> Use below data structures for SVA implementation in the IOMMU core: >>> >>> - struct iommu_sva_ioas >>>    Represent the I/O address space shared with an application CPU >>> address >>>    space. This structure has a 1:1 relationship with an mm_struct. It >>>    grabs a "mm->mm_count" refcount during creation and drop it on >>> release. >> >> Do we actually need this structure?  At the moment it only keeps track of >> bonds, which we can move to struct dev_iommu. Replacing it by a mm >> pointer >> in struct iommu_domain simplifies the driver and seems to work > > Fair enough. > > +struct iommu_sva_ioas { > +    struct mm_struct *mm; > +    ioasid_t pasid; > + > +    /* Counter of domains attached to this ioas. */ > +    refcount_t users; > + > +    /* All bindings are linked here. */ > +    struct list_head bonds; > +}; > > By moving @mm to struct iommu_domain and @bonds to struct dev_iommu, the > code looks simpler. The mm, sva domain and per-device dev_iommu are > guaranteed to be valid during bind() and unbind(). > > Will head this direction in the next version. I'm trying to implement this idea in real code. It seems that we need additional fields in struct iommu_domain to track which devices the mm was bound to. It doesn't simplify the code much. Any thoughts? Best regards, baolu