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 94E6EC433EF for ; Tue, 28 Jun 2022 11:41:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344954AbiF1Lli (ORCPT ); Tue, 28 Jun 2022 07:41:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36994 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242226AbiF1Lle (ORCPT ); Tue, 28 Jun 2022 07:41:34 -0400 Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0306C2EA32 for ; Tue, 28 Jun 2022 04:41:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1656416493; x=1687952493; h=message-id:date:mime-version:cc:subject:to:references: from:in-reply-to:content-transfer-encoding; bh=e5sDkMOObEeUMkZBt6eVhm9iKgpXHF4MwlPjCkr+LpE=; b=Ee82Rt5JzBb4WMg+z9dvxkd4a/kOCimgZ7NzmcP+WL98txVBeJNDXAqL uknkxcy0zIKEedefBJ9f+8tLU6xPYVUuE7OuzbwlFT84XcblnhSXuv8/9 LP0+WpqVtTE9MvKL//qkIJ8bTb+IRXHsQ7Lza7sDD/FS/DoyjgSZBhYsf A9pg//4FUOU4/Qfb8lmckyVQexBxsY8kXlw2mBSwB0ZjairgF0Z0uWTR6 KchYTS+oD8gbhfB+jB+3Nz7DNCi/csF1NFwbWg0HpK2XAFT5HoXXgQVDP AvXTZh8UfNbrTCUAnVsOlZOD63qaztB1G2jyyFqsvNp9EHPvDZop/i/2W g==; X-IronPort-AV: E=McAfee;i="6400,9594,10391"; a="262127424" X-IronPort-AV: E=Sophos;i="5.92,227,1650956400"; d="scan'208";a="262127424" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Jun 2022 04:41:33 -0700 X-IronPort-AV: E=Sophos;i="5.92,227,1650956400"; d="scan'208";a="646879736" Received: from ltang11-mobl1.ccr.corp.intel.com (HELO [10.249.169.64]) ([10.249.169.64]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Jun 2022 04:41:29 -0700 Message-ID: <31116b7f-2ce5-ba18-bcc7-97076199d745@linux.intel.com> Date: Tue, 28 Jun 2022 19:41:28 +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, Eric Auger , "Liu, Yi L" , "Pan, Jacob jun" , "iommu@lists.linux-foundation.org" , "iommu@lists.linux.dev" , "linux-kernel@vger.kernel.org" , Jean-Philippe Brucker Subject: Re: [PATCH v9 04/11] iommu: Add sva iommu_domain support Content-Language: en-US To: "Tian, Kevin" , Joerg Roedel , Jason Gunthorpe , Christoph Hellwig , "Raj, Ashok" , Will Deacon , Robin Murphy , Jean-Philippe Brucker , "Jiang, Dave" , Vinod Koul References: <20220621144353.17547-1-baolu.lu@linux.intel.com> <20220621144353.17547-5-baolu.lu@linux.intel.com> <42825be5-e24c-0f95-f49d-5f50d608506d@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/28 16:50, Tian, Kevin wrote: >>>> + >>>> + mutex_lock(&group->mutex); >>>> + curr = xa_cmpxchg(&group->pasid_array, pasid, NULL, domain, >>>> GFP_KERNEL); >>>> + if (curr) >>>> + goto out_unlock; >>> Need check xa_is_err(old). >> Either >> >> (1) old entry is a valid pointer, or > return -EBUSY in this case > >> (2) xa_is_err(curr) > return xa_err(cur) > >> are failure cases. Hence, "curr == NULL" is the only check we need. Did >> I miss anything? >> > But now you always return -EBUSY for all kinds of xa errors. Fair enough. Updated like below. curr = xa_cmpxchg(&group->pasid_array, pasid, NULL, domain, GFP_KERNEL); if (curr) { ret = xa_err(curr) ? : -EBUSY; goto out_unlock; } Best regards, baolu