Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp355556rwb; Thu, 22 Sep 2022 19:45:48 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7D2uL/Kyl4qRFsTB/qr9FYibDpnimMXCBjJcfOCiGTEcmxeJ5CGdIT9If5CpJFypXBcyFQ X-Received: by 2002:a17:907:1dcc:b0:77a:c5f3:708b with SMTP id og12-20020a1709071dcc00b0077ac5f3708bmr5302058ejc.331.1663901148141; Thu, 22 Sep 2022 19:45:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663901148; cv=none; d=google.com; s=arc-20160816; b=Rlff25HA+vVowwIOvYE4jUhuFxiz/i7Zg0FsUv4UtBIChHGAuqRJqBV/ZOfQOEBUQQ b215kryn4YRPGatfJ1BEVaEIkS1atpayRBGezkq48RSIx4hxQy6V3ly1pb8DQCPJsIEs O3zcZmIpjBypubaKaCqithi/sc9HVxfxvIzQcRDS9x0bCHmUkzFFW++uTq61vGBQsqc6 yGxv6Y9c7UJLpqsVmZD32ihxqb5wX9o2QrhKlwVQMZhBC+K3Ggb+ynK94lnki16vlETr Nuw+x7esQ2icvn+9MZE5iD4OeJLmTrkaXQeqSLVs6VJc1otJC6yjEb0XVn4MR799MIWV Lhzg== 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:subject :from:references:to:content-language:cc:user-agent:mime-version:date :message-id:dkim-signature; bh=XBcXiSqHjEJrpE4xQy5aHU/ZjGTmdXEMfIgSzy/cCPk=; b=XdhHjOQ7N/k3xX5YWTKfq1ievPTBUHMpeULBsd2sc+fiADVXWDivtIzq7dr1MwexUw hwIs0/neGbcsyN1K0aRgrOKPzGfo2n/4ABs7zcNWhOcpLCB1YljHd+xRyDp8fpCNdwys dtM+PkkAi4uVgeX4IT6VCJ8b5iS3kSfzDatMQHKtOzosskj2zxrSzqP7ysxYy/x3+3Zo Xnh2oi/FeOGxlnHSbuWRPmG8IfI5MYkZuSnOyp30H9N8wG0AAR2ZFlF8tIJbXnkDEhRy YxQ83j14LXkhF887zq8AmVLMG9mMva6ALHf38TkrZBjgrsj0qKlv0F7iZfwUVlxmPXT2 jd4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=iSwyTWNS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u19-20020a50c053000000b00447d0d8e385si6561983edd.237.2022.09.22.19.45.22; Thu, 22 Sep 2022 19:45:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=iSwyTWNS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S230495AbiIWCWB (ORCPT + 99 others); Thu, 22 Sep 2022 22:22:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56474 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230144AbiIWCV7 (ORCPT ); Thu, 22 Sep 2022 22:21:59 -0400 Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 132581181CF; Thu, 22 Sep 2022 19:21:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1663899719; x=1695435719; h=message-id:date:mime-version:cc:to:references:from: subject:in-reply-to:content-transfer-encoding; bh=UwDG7pDg4q+ikiSIyDkSSay/EkxC20ZvQE0rFh71LXs=; b=iSwyTWNSeLffzQzp5pTUMUGSvqDdVDcvuUdNhPYhKCrD4W3DTx9Z2tx8 EHVDDUPdrE9sTmwqPWPPecC2IKgZQ4BHNJhzcE9tSl7ybqCkjFjDM5TGx RClO5kGjCoDuyN9eXWfD+kz+E0xvjVh2QvKmIIZAjJWURQ/cvOjJ26Bum 3IclQio2IIR5n0BfsQGnD5Pg58Ay6uSXSpA323hFX0Q0IMIm9l5TpnXed OGcjvKJb/Qsy19mlSts+GzfhJ0cVNjPCqYksAjdAIDT4fSlJ88mcUWfWR iTSqxwN1jeLk2tVcjj9PJBPvwC+jaB4CPNGRGx/CCVdua3J5zjrzRe1Vz w==; X-IronPort-AV: E=McAfee;i="6500,9779,10478"; a="298089181" X-IronPort-AV: E=Sophos;i="5.93,337,1654585200"; d="scan'208";a="298089181" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Sep 2022 19:21:58 -0700 X-IronPort-AV: E=Sophos;i="5.93,337,1654585200"; d="scan'208";a="653238520" Received: from ningqu-mobl1.ccr.corp.intel.com (HELO [10.254.210.156]) ([10.254.210.156]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Sep 2022 19:21:53 -0700 Message-ID: <075278e0-77ce-2361-8ded-6cd6bb20216f@linux.intel.com> Date: Fri, 23 Sep 2022 10:21:51 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.2.2 Cc: baolu.lu@linux.intel.com, Joerg Roedel , Christoph Hellwig , Bjorn Helgaas , Kevin Tian , Ashok Raj , Will Deacon , Robin Murphy , Jean-Philippe Brucker , Dave Jiang , Fenghua Yu , Vinod Koul , Eric Auger , Liu Yi L , Jacob jun Pan , Zhangfei Gao , Zhu Tony , iommu@lists.linux.dev, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org Content-Language: en-US To: Jason Gunthorpe References: <20220906124458.46461-1-baolu.lu@linux.intel.com> <20220906124458.46461-8-baolu.lu@linux.intel.com> From: Baolu Lu Subject: Re: [PATCH v13 07/13] iommu/vt-d: Add SVA domain support In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-8.9 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_NONE autolearn=ham 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 On 2022/9/22 23:49, Jason Gunthorpe wrote: > On Tue, Sep 06, 2022 at 08:44:52PM +0800, Lu Baolu wrote: >> +static void intel_iommu_remove_dev_pasid(struct device *dev, ioasid_t pasid) >> +{ >> + struct intel_iommu *iommu = device_to_iommu(dev, NULL, NULL); >> + struct iommu_domain *domain; >> + >> + /* Domain type specific cleanup: */ >> + domain = iommu_get_domain_for_dev_pasid(dev, pasid, 0); >> + if (domain) { >> + switch (domain->type) { >> + case IOMMU_DOMAIN_SVA: >> + intel_svm_remove_dev_pasid(dev, pasid); >> + break; >> + default: >> + /* should never reach here */ >> + WARN_ON(1); >> + break; > > This is eventually going to need a lot more cleaning up to split out > the PASID from the SVM stuff. > > SVA should *only* be a set of predefined handlers (in the core code!) > for the generic PRI mechanism, it shouldn't be entangled deeply into > PASID or the drivers like this. > > When we get done with this, the flow should have the core code attach > a SVA domain to a PASID with PRI enabled and the core code should > supply a generic PRI implementation that does the mmu_notifier > stuff. Yes. Agreed. At the beginning of this project, I wanted to consolidate the mm notifications into the core. However, ARM SMMUv3 and Intel handle the mm notifications a little differently. Then I decided to do this work separately from the current series. > > Also, stuff like this: > > /* We mandate that no page faults may be outstanding > * for the PASID when intel_svm_unbind_mm() is called. > * If that is not obeyed, subtle errors will happen. > * Let's make them less subtle... */ > > Are going to be problematic for VFIO as well. In a VFIO world the > entire RID and its entire PASID table has to be owned by VFIO and > never shared - so these sequencing issues should be solvable. > > But this is all for further series.. Yes. All these sound interesting future series. > > Reviewed-by: Jason Gunthorpe I'm very appreciated for your time. Best regards, baolu