Received: by 2002:a05:6358:53a8:b0:117:f937:c515 with SMTP id z40csp4188459rwe; Mon, 17 Apr 2023 09:06:16 -0700 (PDT) X-Google-Smtp-Source: AKy350b08v9bCDwm3ipICF/QTGeqNBeKuul0RVyCdYIg5adCTCEZ3lqZM4NKDP0gcD3/W7wDICFg X-Received: by 2002:a17:90b:1244:b0:23f:ebf2:d3e9 with SMTP id gx4-20020a17090b124400b0023febf2d3e9mr15173922pjb.6.1681747575911; Mon, 17 Apr 2023 09:06:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681747575; cv=none; d=google.com; s=arc-20160816; b=DDOyHpzq8crWn93hO8OMGZyB+wDSp1QfWBvtL76oYR6kr3/81495KNszoSDlcAH7rV iRhFOekY3qDDD+3IHMwubIgXFF2O6c2RnqhhXx24DXwW3Ddixw3o+bIfQ1MCv485/NFp 7avrcGxEcIEJQHY0Kws/xews8YuG4d6RiMuo3OHYoFurXXWJRRbA9xEoR+I3BPQckukK pACyPEAnu2z2FYX8ZTH7kDWEEPFTJfrpoeUXi/GrP/SBPJnxeQjRPU9NGG3JhdfX5aWZ Gr2mwR9Rsun0jjYTLbXf5DnYx+OehWsn67an6axkoJVtpvbs4Vxlb6xnM/y1XBk03WfB FOxA== 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=bSwN27u2wupCtUvMKO4W68wwIr6cvD1oa6m7m5nLYd4=; b=Xu5V59K3Xp6dAA9VS9Zrv10CJZ+paqbr8i01OVq6SSy/e7DRJv8xAUs66o1JsoAGIC fvlG1fcGsycNZsJgrYe474GAUJRV2vmwJ9v5wzFK5r7bhC/DaI4lr4ktXTEFw1t/Qeq+ YKlXQbqeA93lh9OO3Fh8csZ/KmbQUNDvlrTotHsuBfHHKv0KelTd+AdZi92yni+5fFnc 1vr5knki2H7oNDBfDdhffdlSUH5PxzPazJk3957VwFcuLBBya8+UX9rcIV8xCS5ICrKb covaOOOWjK6zRXwr7cm7Riszyukq9RTlN8cwAe/ZusZCz3U1XMo3Fu/E9hmJVfC/F+2u rq6w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=AGvd9mVp; 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 m4-20020a17090a2c0400b0023d422d08c6si11736995pjd.27.2023.04.17.09.06.03; Mon, 17 Apr 2023 09:06:15 -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=AGvd9mVp; 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 S230090AbjDQQFF (ORCPT + 99 others); Mon, 17 Apr 2023 12:05:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60600 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230023AbjDQQFC (ORCPT ); Mon, 17 Apr 2023 12:05:02 -0400 Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 34EE35BB3; Mon, 17 Apr 2023 09:04:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1681747481; x=1713283481; h=date:from:to:cc:subject:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=7tLU5hrc39P7zYp6lZlpanLIEtDU8xZ/pBPxVlbteKA=; b=AGvd9mVposJKAnjdLBuZ1dXZwws+SSwEd08NGOmqfrZ7TVyfekK2wi2m bjEb1GK9wu4mbQ3mGa7+cXhn/GYM0F7Zky5NGaKIuIrpzNFTS4OLo4kYY p39O2cKGmtilqRvbe+t9T3puI+zoysS/sSevcnuS/BtBPMi95m64l0l+A 30F2TkDmmc0g3JKXSVQmAx+8L3lOtmVxtebIIDrq0UEFw1ALHj4MhE7a3 ueIh6iX+0L9Sl/Lf+P9evSu2X7aCYpGpWdtJaMDpOTjZkopFp/u8O+YU+ lnRUmUWahm6xi1RdSew8SRitpxWlkRoveEAy4/OAIcGCL+90RVmi6HsS7 g==; X-IronPort-AV: E=McAfee;i="6600,9927,10683"; a="344927320" X-IronPort-AV: E=Sophos;i="5.99,204,1677571200"; d="scan'208";a="344927320" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Apr 2023 09:02:55 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10683"; a="802172627" X-IronPort-AV: E=Sophos;i="5.99,204,1677571200"; d="scan'208";a="802172627" Received: from jacob-builder.jf.intel.com (HELO jacob-builder) ([10.24.100.114]) by fmsmga002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Apr 2023 09:02:52 -0700 Date: Mon, 17 Apr 2023 09:07:06 -0700 From: Jacob Pan To: "Tian, Kevin" Cc: LKML , "iommu@lists.linux.dev" , Robin Murphy , Jason Gunthorpe , Lu Baolu , Joerg Roedel , "dmaengine@vger.kernel.org" , "vkoul@kernel.org" , Will Deacon , David Woodhouse , "Raj, Ashok" , "Liu, Yi L" , "Yu, Fenghua" , "Jiang, Dave" , "Luck, Tony" , "Zanussi, Tom" , jacob.jun.pan@linux.intel.com Subject: Re: [PATCH v4 3/7] iommu: Support allocation of global PASIDs outside SVA Message-ID: <20230417090706.3ac5f858@jacob-builder> In-Reply-To: References: <20230407180554.2784285-1-jacob.jun.pan@linux.intel.com> <20230407180554.2784285-4-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_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE 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 Tue, 11 Apr 2023 08:02:55 +0000, "Tian, Kevin" wrote: > > From: Jacob Pan > > Sent: Saturday, April 8, 2023 2:06 AM > > @@ -28,8 +26,8 @@ static int iommu_sva_alloc_pasid(struct mm_struct > > *mm, ioasid_t min, ioasid_t ma > > goto out; > > } > > > > - ret = ida_alloc_range(&iommu_global_pasid_ida, min, max, > > GFP_KERNEL); > > - if (ret < min) > > + ret = iommu_alloc_global_pasid(min, max); > > I wonder whether this can take a device pointer so dev->iommu->max_pasids > is enforced inside the alloc function. > > and do we even need the min/max parameters? With special pasids reserved > then what driver needs is just to get a free pasid from the global space > within dev->iommu->max_pasids constraint... > > iommu_sva_alloc_pasid() can be reworked to avoid min/max by taking a > device pointer too. I think that will work too albeit a philosophical change. It probably should be called iommu_alloc_dev_global_pasid(dev). But I feel the current approach is more flexible in that device drivers can control the range if for some reason it does not want go max_pasid. Thanks, Jacob