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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 883F1C77B7E for ; Thu, 25 May 2023 15:50:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231344AbjEYPug (ORCPT ); Thu, 25 May 2023 11:50:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40992 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241111AbjEYPu0 (ORCPT ); Thu, 25 May 2023 11:50:26 -0400 Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7920AB6; Thu, 25 May 2023 08:50:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1685029816; x=1716565816; h=date:from:to:cc:subject:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=emj39pN1Kh0TKycX7k6GT4QnYMEV4/dD9je4KRuZQhU=; b=HKY/xP4VV5ZPrgdQJ8Q8w7ZOuAMoqUyraIj/g818+3UcTubLbTX76Fq1 e1XyGK3HKXLF9r3AyrlM6M5rt3GcHIU+BILkiuKd4FS40xK78vnrHMZ9f 7OA6jDi4OLouOO/WqAap82ANR49JNz7DkuYXErS1003YmsSq/vgdey0Sg y/RaswgxcXAL3BLp532E54vq1fUEsBqHaLyrHnSnvyss38uCzVK9gPQYd XLqEUWyBZeRz1NhURD9uGfKOkTDbCvqxI47z5VXARPhBGfE6YHiy7z7z/ cuq2oKBdacYnDio00xSWJafw29TXvoTvfwJviXBugCEf0CL8531OlQFiX g==; X-IronPort-AV: E=McAfee;i="6600,9927,10721"; a="333547642" X-IronPort-AV: E=Sophos;i="6.00,191,1681196400"; d="scan'208";a="333547642" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 May 2023 08:50:16 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10721"; a="682371590" X-IronPort-AV: E=Sophos;i="6.00,191,1681196400"; d="scan'208";a="682371590" Received: from jacob-builder.jf.intel.com (HELO jacob-builder) ([10.24.100.114]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 May 2023 08:50:15 -0700 Date: Thu, 25 May 2023 08:54:48 -0700 From: Jacob Pan To: "Tian, Kevin" Cc: LKML , "iommu@lists.linux.dev" , Jason Gunthorpe , Lu Baolu , Joerg Roedel , Robin Murphy , Jean-Philippe Brucker , "dmaengine@vger.kernel.org" , "vkoul@kernel.org" , Will Deacon , David Woodhouse , "Raj, Ashok" , "Liu, Yi L" , "Yu, Fenghua" , "Jiang, Dave" , "Luck, Tony" , "Zanussi, Tom" , "Ranganathan, Narayan" , jacob.jun.pan@linux.intel.com Subject: Re: [PATCH v7 2/4] iommu: Move global PASID allocation from SVA to core Message-ID: <20230525085448.40194a42@jacob-builder> In-Reply-To: References: <20230523173451.2932113-1-jacob.jun.pan@linux.intel.com> <20230523173451.2932113-3-jacob.jun.pan@linux.intel.com> Organization: OTC X-Mailer: Claws Mail 3.17.5 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: dmaengine@vger.kernel.org Hi Kevin, On Thu, 25 May 2023 06:27:40 +0000, "Tian, Kevin" wrote: > > From: Jacob Pan > > Sent: Wednesday, May 24, 2023 1:35 AM > > > > /* Allocate a PASID for the mm within range (inclusive) */ > > -static int iommu_sva_alloc_pasid(struct mm_struct *mm, ioasid_t min, > > ioasid_t max) > > +static int iommu_sva_alloc_pasid(struct mm_struct *mm, struct device > > *dev) { > > + ioasid_t pasid; > > int ret = 0; > > > > - if (min == IOMMU_PASID_INVALID || > > - max == IOMMU_PASID_INVALID || > > - min == 0 || max < min) > > - return -EINVAL; > > - > > if (!arch_pgtable_dma_compat(mm)) > > return -EBUSY; > > > > mutex_lock(&iommu_sva_lock); > > /* Is a PASID already associated with this mm? */ > > if (mm_valid_pasid(mm)) { > > - if (mm->pasid < min || mm->pasid > max) > > + if (mm->pasid > dev->iommu->max_pasids) > > ">" should be ">=" right, will do > > +ioasid_t iommu_alloc_global_pasid_dev(struct device *dev) > > +{ > > + int ret; > > + ioasid_t max; > > + > > + max = dev->iommu->max_pasids; > > + ret = ida_alloc_range(&iommu_global_pasid_ida, > > IOMMU_FIRST_GLOBAL_PASID, max, GFP_KERNEL); > > max is inclusive. Here should minus one. yeah, should be -1 > otherwise looks good to me, > > Reviewed-by: Kevin Tian Thanks, Jacob