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 8F795C433EF for ; Wed, 1 Jun 2022 10:48:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1352580AbiFAKsp (ORCPT ); Wed, 1 Jun 2022 06:48:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50980 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352578AbiFAKsd (ORCPT ); Wed, 1 Jun 2022 06:48:33 -0400 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 03DB8275DB for ; Wed, 1 Jun 2022 03:48:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1654080509; x=1685616509; h=message-id:date:mime-version:cc:subject:to:references: from:in-reply-to:content-transfer-encoding; bh=FljOfQd0ovis2myCMXGwjQ7sjwvP24kidUblqHsfnRA=; b=iI5F11nidUOKCcnuKJ41h/+z2jp0jbZKE4egwyAgHuFf4dwqeTWv3Bjz 6kI2zKANJYYFTanquxbPblXL/hwFk5G3wIXr0vwhFo6Gq7DCLnE0qweKt DSIglapHdvN5odEhC5sREBRZtiRj5/pHSi9B9D52ERv+iX0L1p7IfKB9J EK3TL5lPj+/hJogs1+078WybXtc0mvydnHGN6u0lPz2m7ND+O0z2jR4Jb TH3t/mv6XhwyZzrzvGwwVrKm1NbYpBfhbXJl5kFtp+/n2rV5XKsldz4Ms WC4T8i1VI0Wmzz+dgY/LtbLZGM6bBoL7FjLEtBrX8mazgN1e2/fN2TZhb A==; X-IronPort-AV: E=McAfee;i="6400,9594,10364"; a="300898703" X-IronPort-AV: E=Sophos;i="5.91,268,1647327600"; d="scan'208";a="300898703" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jun 2022 03:48:28 -0700 X-IronPort-AV: E=Sophos;i="5.91,268,1647327600"; d="scan'208";a="707004298" Received: from hej1-mobl.ccr.corp.intel.com (HELO [10.255.28.123]) ([10.255.28.123]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jun 2022 03:48:25 -0700 Message-ID: Date: Wed, 1 Jun 2022 18:48:23 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.1 Cc: baolu.lu@linux.intel.com, Will Deacon , Robin Murphy , "Liu, Yi L" , "Pan, Jacob jun" , "iommu@lists.linux-foundation.org" , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH 07/12] iommu/vt-d: Acquiring lock in pasid manipulation helpers Content-Language: en-US To: "Tian, Kevin" , Joerg Roedel , "Raj, Ashok" , Christoph Hellwig , Jason Gunthorpe References: <20220527063019.3112905-1-baolu.lu@linux.intel.com> <20220527063019.3112905-8-baolu.lu@linux.intel.com> From: Baolu Lu In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2022/6/1 17:18, Tian, Kevin wrote: >> From: Lu Baolu >> Sent: Friday, May 27, 2022 2:30 PM >> >> The iommu->lock is used to protect the per-IOMMU pasid directory table >> and pasid table. Move the spinlock acquisition/release into the helpers >> to make the code self-contained. >> >> Signed-off-by: Lu Baolu > > Reviewed-by: Kevin Tian , with one nit > >> >> - /* Caller must ensure PASID entry is not in use. */ >> - if (pasid_pte_is_present(pte)) >> - return -EBUSY; >> + spin_lock(&iommu->lock); >> + pte = get_non_present_pasid_entry(dev, pasid); >> + if (!pte) { >> + spin_unlock(&iommu->lock); >> + return -ENODEV; >> + } > > I don't think above is a good abstraction and it changes the error > code for an present entry from -EBUSY to -ENODEV. Sure. I will roll it back to -EBUSY. I added this helper because the same code appears at least three times in this file. Best regards, baolu