Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp3908608iog; Tue, 28 Jun 2022 05:24:07 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sHlxDoQ14u9oeA9Qp3w/3niHvB471FAevuX9qTnHVXIGeKQuFMqk/BxyAKwZM4z/QIfL+a X-Received: by 2002:a17:90a:f48a:b0:1ed:5ec:f890 with SMTP id bx10-20020a17090af48a00b001ed05ecf890mr26983510pjb.40.1656419047755; Tue, 28 Jun 2022 05:24:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656419047; cv=none; d=google.com; s=arc-20160816; b=cht9mdDlGAmMbPcpRTg4FEUQsU9U2iPa8SIw7PiCMx3+cVYehVSiWnSaXWYan+GVeh Gk3v7SBKgHiQnLMYNrC6KlByc9FmFgsDWNww2M1XUVuy1nCN1Ky3dZV1Sl6R4q524jcg zlWtyeiyM18meELQH5qD6zEsbnOLFiXaLuDWT/+i3YnwL0cV+2k0lODbt5qoEgtYXQ3k syW1MdNjtlRGeVnx7Bg0ea5bOLruRiGyPSfPII4UaFPdj2PPWxYxvdRzw/G1vAXz6S6M 9VlA3c8pd0xdHGzVHjTTTVJLhrwogzqdPvYvplMo0qzQ6hWCgXorucvrUdBKLZuOPSMh 89wQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:to:content-language:subject:cc:user-agent:mime-version :date:message-id:dkim-signature; bh=hpgLCsIF491TrzKfCryoVOJAgAssE7zHpQCFx20DcXU=; b=n7lWqeSRKn7T4IqF54Ac3ClQmhHNFR1XO3T6ZxdLnmc6rPcwOsS4UCKrxViu2dKmJ4 nO7pWi2/5UrXHyJ7rvORMGc2BEwX7UIuC0d1rYCpZyZ6vBwbD5QWGSGNvGxhupld+w5N l3XQ96K7eIYnCGFAGkeuHsbecTdH14hPYNClm1MPvzUQ8dJiGf9tMVlYo1uxrCSWd7LD NlGmkHiM/eGZ0yL8w+n6F25L99+3f4xYHlTgx7bw2iPbWODJPpKLDPxzVO4aaPaYRZor zUe7P14S4uO5VYs5xsd4VqFmXu8XEO0JPqelHXJPW0sOXEdJ2h5l6h282ScXMC9w+OAO bxSQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Ee82Rt5J; 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 z2-20020a170902ccc200b0016b7b1396cesi7973615ple.419.2022.06.28.05.23.54; Tue, 28 Jun 2022 05:24:07 -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=Ee82Rt5J; 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 S1344555AbiF1Llh (ORCPT + 99 others); Tue, 28 Jun 2022 07:41:37 -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 X-Spam-Status: No, score=-4.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,NICE_REPLY_A,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 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