Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp1171393rwd; Thu, 25 May 2023 08:55:56 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ63ktcX7PSlAzjQ6bMjsKLVnHOTRtoAu97lkkV2PDhieXfJjwh3rVEcxL+KgI5Bhk0U8SRq X-Received: by 2002:a17:90a:ab14:b0:255:5d65:3a86 with SMTP id m20-20020a17090aab1400b002555d653a86mr2554772pjq.8.1685030154675; Thu, 25 May 2023 08:55:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685030154; cv=none; d=google.com; s=arc-20160816; b=BOtYQDZZ3HC3sn8aDGOjy/9KeeKIinGgRsg+7trwRvY0QkCT2Qy4b6YqAFB4SIE2OV 34OtzDEIPmBSgZf3tpNaZeU9iXM4RpXBQnuwA3P+VtJIgA4m/10LjRzrHJkZGS+G5mvI ODzPFEflf40V67dz/1JbZf2SG2LwsANTPMf8Ogrh1ztzwwAkT60zPSQdpHbdTeijsWUs iUnZy8s/pm4rhM6+wv4tmZ9F7LmUWOTaXVUXEJ0CFCPKCOPW9BzUEkju8XIARg7nK/RB K7yiL+fJoDha0LSxDi2oOZFGcOB4eXcy6hCs/RdL5mxwk5suwQONhNmDkmNWmTXhdaOR qXYg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :organization:references:in-reply-to:message-id:subject:cc:to:from :date:dkim-signature; bh=14mxb+IjucaJ7iMFhxtAOPwVcRkLAxi4f7X4aE1sz2U=; b=I4IO3Y5YE0tqUVNBAKjcXgNZHj6smVFZoNAR7aO9UukuUJJQSxRH106pXkDXgUO1ds oowxU1bnJBAEB4ROjPVdv8uko5bPeagD5eTv4/kk4PRJuuBmL/r1xuwHeTNIP1P8YIuw Bv48tRjLzhGifJkvJK4kWOVHirp6a88HKLS1s+YCZ/XMahWSYuKakEClyI8BqmZB0f2l kWh4ut/npCjC75DClrvCTjm4Fm4pxl8af8wA6YyrwTp0pkQASZNaVYF/uuZIPaLs4pWL OygIHnhi9CDMlLb2kLM43GOowfT/tsAUjOefgyl9ctO+aPowCZic0nGwPwUPfeGDefKS cOFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="HKY/xP4V"; 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 i2-20020a17090ac40200b0023d22d0f0fdsi4026370pjt.19.2023.05.25.08.55.39; Thu, 25 May 2023 08:55:54 -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="HKY/xP4V"; 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 S233904AbjEYPuh (ORCPT + 99 others); Thu, 25 May 2023 11:50:37 -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 X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_PASS, SPF_NONE,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 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