From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.2 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_2 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 42F43C33CAC for ; Thu, 6 Feb 2020 18:07:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2282120838 for ; Thu, 6 Feb 2020 18:07:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727822AbgBFSHg (ORCPT ); Thu, 6 Feb 2020 13:07:36 -0500 Received: from mga18.intel.com ([134.134.136.126]:14788 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727662AbgBFSHg (ORCPT ); Thu, 6 Feb 2020 13:07:36 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 06 Feb 2020 10:07:35 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,410,1574150400"; d="scan'208";a="379143775" Received: from jacob-builder.jf.intel.com (HELO jacob-builder) ([10.7.199.155]) by orsmga004.jf.intel.com with ESMTP; 06 Feb 2020 10:07:35 -0800 Date: Thu, 6 Feb 2020 10:12:53 -0800 From: Jacob Pan To: "Liu, Yi L" Cc: Alex Williamson , "eric.auger@redhat.com" , "Tian, Kevin" , "joro@8bytes.org" , "Raj, Ashok" , "Tian, Jun J" , "Sun, Yi Y" , "jean-philippe.brucker@arm.com" , "peterx@redhat.com" , "iommu@lists.linux-foundation.org" , "kvm@vger.kernel.org" , "linux-kernel@vger.kernel.org" , jacob.jun.pan@linux.intel.com Subject: Re: [RFC v3 1/8] vfio: Add VFIO_IOMMU_PASID_REQUEST(alloc/free) Message-ID: <20200206101253.7fb43e07@jacob-builder> In-Reply-To: References: <1580299912-86084-1-git-send-email-yi.l.liu@intel.com> <1580299912-86084-2-git-send-email-yi.l.liu@intel.com> <20200129165540.335774d5@w520.home> Organization: OTC X-Mailer: Claws Mail 3.13.2 (GTK+ 2.24.30; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Alex, On Fri, 31 Jan 2020 12:41:06 +0000 "Liu, Yi L" wrote: > > > +static int vfio_iommu_type1_pasid_free(struct vfio_iommu *iommu, > > > + unsigned int pasid) > > > +{ > > > + struct vfio_mm *vmm = iommu->vmm; > > > + int ret = 0; > > > + > > > + mutex_lock(&iommu->lock); > > > + if (!IS_IOMMU_CAP_DOMAIN_IN_CONTAINER(iommu)) { > > > > But we could have been IOMMU backed when the pasid was allocated, > > did we just leak something? In fact, I didn't spot anything in > > this series that handles a container with pasids allocated losing > > iommu backing. I'd think we want to release all pasids when that > > happens since permission for the user to hold pasids goes along > > with having an iommu backed device. > > oh, yes. If a container lose iommu backend, then needs to reclaim the > allocated PASIDs. right? I'll add it. :-) > > > Also, do we want _free() paths that can fail? > > I remember we discussed if a _free() path can fail, I think we agreed > to let _free() path always success. :-) Just to add some details. We introduced IOASID notifier such that when VFIO frees a PASID, consumers such as IOMMU, can do the cleanup therefore ensure free always succeeds. https://www.spinics.net/lists/kernel/msg3349928.html https://www.spinics.net/lists/kernel/msg3349930.html This was not in my v9 set as I was considering some race conditions w.r.t. registering notifier, gets notifications, and free call. I will post it in v10. Thanks, Jacob