Received: by 2002:a05:6602:2086:0:0:0:0 with SMTP id a6csp3343467ioa; Tue, 26 Apr 2022 01:37:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyIS5ysxQFx+QP1wN5530C5iSITSox6a9mtxzJ7+a1zjjVNAE34qVeL8gWsiAbXQjDQYNLq X-Received: by 2002:a05:6402:3509:b0:423:f906:8e2d with SMTP id b9-20020a056402350900b00423f9068e2dmr23450885edd.333.1650962264036; Tue, 26 Apr 2022 01:37:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650962264; cv=none; d=google.com; s=arc-20160816; b=WDdAJey3mjH1KJM5ZPmNI9yD2nSGaiXDWthaMDYuYfEGIe5gWuOWY0tkk1jd4v2tOm rFrTcjMhUHVQxeppVvJszG946Y0brEGGIUcD+MEcoVJ/VwkPYw0jF5In0wpRdTs3Jn6W uw1Th7IweqncbPwWLpjzzyOTCAchv26xC9LMwc/Mp3Cpw65L/PFlIsNlVTMSkjMUp3Lm 6+SlOQsW/BPnPNGEWxtg/fagHX+pipZsvaamlQmHdtiVlyUDh4a7LDxggO0zC0foXVFM 44kIC5A8+75s0mLqQmqMm/0+hITmRLbBvlphWN0X9Gi9EYIP/95sYgel43v0PHbFoLUB k5og== 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:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=qCsDT4aOwQ2/7iTu3G9aVcxSkWdx+ROiZ3JUo9ellF0=; b=sA7wtJVv+epqrzcoZSZ90mdnRFzqAsywmlYcKO/FiFOULf9DKUKM22XA50J2smQn+j RVanqSjUewcy0MG5TRBY+WJdS6D7TBDeIjbaN+uB3BWwfRCQwCM7U8DgSx4/tmMNjFmm 5lif6q2onqzmuzvwSwZ928UxTJGDZlpZfTz7fwX6pP68W1TaO2Q7gF75uP5ZBGadhZ2V n6xGzYqLrUKOG1vBVCMYmEgReUdD3mVzWD1RIw/5/29Z8D+O9JlRKO6+5M+47T6pCLZU J4RXIJmp/QHsFH5yejhNkvZg9YdJ6aTVEeTGHiJA5IW+2oYx4iu41MpYBZuiCek5Na/G BJwQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="Bh30bf/f"; 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 h18-20020a50ed92000000b00423e3538ee2si8533378edr.335.2022.04.26.01.37.20; Tue, 26 Apr 2022 01:37:44 -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="Bh30bf/f"; 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 S243059AbiDYP45 (ORCPT + 99 others); Mon, 25 Apr 2022 11:56:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59738 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243054AbiDYP44 (ORCPT ); Mon, 25 Apr 2022 11:56:56 -0400 Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1D78045ACE for ; Mon, 25 Apr 2022 08:53:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1650902032; x=1682438032; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=OgI7VQnUPjqMWNGxE5sNT1Rye9YtELUHcykl0maLGbY=; b=Bh30bf/fA29fkTaIvRzGNYDS93Qo9O+z3OiwjJ6OP53sNdRd6tvtHEwS Y+nJ/GT4DhE6dFBEgjq+Tgvv4chDC8jkfZSvvrHeV+jJi9wTuIL4bRx8a +V8A7hWt2BoiXbV871HeIJMBqKPM4eLcjOMeaGu1LE0V0LqLfjopwT8D+ I1sHDChx9JKYakzrk3Au1QtzddQLFWotwj4jvzar00IWgeOuf6G1LUxqA fLzXlTsnm/bWLsXN6pJTkvYuYiel+Kgbua45cn5rTLOYc8E1EwFAmTsuS vljzLDZBk2h97DBX/Cmx6876IyBkMyd1QLPrC6PJ+/DHXHFzhBMihciPM w==; X-IronPort-AV: E=McAfee;i="6400,9594,10328"; a="262883593" X-IronPort-AV: E=Sophos;i="5.90,288,1643702400"; d="scan'208";a="262883593" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Apr 2022 08:53:51 -0700 X-IronPort-AV: E=Sophos;i="5.90,288,1643702400"; d="scan'208";a="595294518" Received: from bjkrist-mobl.amr.corp.intel.com (HELO [10.212.88.70]) ([10.212.88.70]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Apr 2022 08:53:50 -0700 Message-ID: <22b659c7-e972-7a56-2bd7-8df3b4820d4e@intel.com> Date: Mon, 25 Apr 2022 08:55:46 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.7.0 Subject: Re: [PATCH v4 05/11] iommu/sva: Assign a PASID to mm on PASID allocation and free it on mm exit Content-Language: en-US To: Jean-Philippe Brucker Cc: "zhangfei.gao@foxmail.com" , Fenghua Yu , Joerg Roedel , Ravi V Shankar , Tony Luck , Ashok Raj , Peter Zijlstra , Dave Hansen , x86 , linux-kernel , iommu , Ingo Molnar , Borislav Petkov , Andy Lutomirski , Josh Poimboeuf , Thomas Gleixner , will@kernel.org, robin.murphy@arm.com, zhangfei.gao@linaro.org References: <76ec6342-0d7c-7c7b-c132-2892e4048fa1@intel.com> From: Dave Hansen In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-9.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,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 4/25/22 07:26, Jean-Philippe Brucker wrote: >> >> How does the IOMMU hardware know that all activity to a given PASID is >> finished? That activity should, today, be independent of an mm or a >> fd's lifetime. > In the case of uacce, it's tied to the fd lifetime: opening an accelerator > queue calls iommu_sva_bind_device(), which sets up the PASID context in > the IOMMU. Closing the queue calls iommu_sva_unbind_device() which > destroys the PASID context (after the device driver stopped all DMA for > this PASID). Could this PASID context destruction move from being "fd-based" to happening under mm_pasid_drop()? Logically, it seems like that should work because mm_pasid_drop() happens after exit_mmap() where the VMAs (which hold references to 'struct file' via vma->vm_file) are torn down.