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 X-Spam-Level: X-Spam-Status: No, score=-6.7 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3DEDAC43461 for ; Thu, 17 Sep 2020 14:38:42 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B7BF52223C for ; Thu, 17 Sep 2020 14:38:41 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="vB0MJqG5"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="QGCPcwui" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B7BF52223C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References:Message-ID: Subject:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=eU/PtCVkMYN+wweN6RU24w9n6Vhomq7OurhEu4og7ig=; b=vB0MJqG5zban4w0JbMVBJpqlc IbAog8cc81nVX6TFNd3MAEIrekNx/KwmXvIyORh0iHNcZwokHz/qDFtIhim+JX+nh72EggouZewyQ /bWC7QQkTIvioNybce/OP5BxbhYn99Rp2vDvXMY3KQUsmrzSgs0na09I/wgOcwZnGfyQuQzIniC84 j3f38ZEzEbVtpoiHR8DAlQMV4GSwN9efxe2tPdAr419NTbcdEKdKPIL3SpTTAd6aXmfnpTt+z7t2s qTcgzLOspiPyDJM/bUlMiY4exUQ3K1ED2LeoVtXMj0oeCozCYpDt4t8OH9Zejt5cZwklRmsKlIuic 72vNYMQoQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kIv2B-00048K-BR; Thu, 17 Sep 2020 14:37:15 +0000 Received: from mail-wr1-x441.google.com ([2a00:1450:4864:20::441]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kIv28-00047C-Fl for linux-arm-kernel@lists.infradead.org; Thu, 17 Sep 2020 14:37:13 +0000 Received: by mail-wr1-x441.google.com with SMTP id m6so2372216wrn.0 for ; Thu, 17 Sep 2020 07:37:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=M9gS3287S0Kty1lGdTSSCUjtzHa87iOilMiBEXqgZIk=; b=QGCPcwui9PV57DotV3CplBVPzt42u0IkvemUt457Qhs+LHjck33+OGWcTqa7LtXO0s uHHrZ8JPmk/b3rEnq+fLJgP1/p0jClEJKL/0bsdwJYEEsIyIEt4nui+gvDAR3XyQsz5R rYStTHVP08VBv6suUBEyMYVR1py/TW9AB3eV8cGsVTCM3x1sCxMgxbEukBjucM9bF8Vc agHj56m1MLiCSLkt03Pg+BnW8t0jw10/OXMzqMroJqy6WJIMBWcaR0MG7sGor9XlAtTJ kqKSL1SPepJb0Sj/FoNlcwaem1AXE2zzX6y79ne5wrBbFML0KNC5iq2EsK2lD7r2xUsl 3CVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=M9gS3287S0Kty1lGdTSSCUjtzHa87iOilMiBEXqgZIk=; b=NYHycX4yHBgGkkwcIlheLFvOow2jA08vJOG5UmcebyC38ohHShnzhIWsPTB3PSVh0D RqxuSmVJ7oiS7nlAJqU3CGLFzCSF+5pTKJ5MZt5VdKDGaLl06CiY7Au6iyTleSFsxCX1 DO7XVNhx370UO2W7Cl9EP5QAdl53jNUwU/aeYNAopc0tuky0MTDEc/oiK5pny+LlD/hk H2vwaWEFTDa/8DNnpyfkDpeo5xS2syXT4BSEEqms8gx85pztCWRpNwYpeu787Lf8S0Vb pPBEeXz4nelRDGzaduEO7zDwPay8w3gNVXPu+KZq+OTo3uTtv0IbM4IhIQE6P2U7Chhy Z4kw== X-Gm-Message-State: AOAM530EB1FXlqBxLYHipTK0vosneuu/c57yzYz3ZPT70Y2TiKConyaV b3TCzPEkyDRrbdKOg1OY6BAouQ== X-Google-Smtp-Source: ABdhPJy+rAGuUfzGgur2eYJh6s3fwt8jTwpxbS/gPLgICs9OoxIliDD0/uDvO6wDOciThy3TNN1RmQ== X-Received: by 2002:a5d:56cd:: with SMTP id m13mr32002851wrw.261.1600353431301; Thu, 17 Sep 2020 07:37:11 -0700 (PDT) Received: from myrica ([2001:1715:4e26:a7e0:116c:c27a:3e7f:5eaf]) by smtp.gmail.com with ESMTPSA id p11sm10707199wma.11.2020.09.17.07.37.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Sep 2020 07:37:10 -0700 (PDT) Date: Thu, 17 Sep 2020 16:36:51 +0200 From: Jean-Philippe Brucker To: Auger Eric Subject: Re: [PATCH RESEND v9 03/13] iommu/sva: Add PASID helpers Message-ID: <20200917143651.GB134903@myrica> References: <20200817171558.325917-1-jean-philippe@linaro.org> <20200817171558.325917-4-jean-philippe@linaro.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200917_103712_526286_B56FE172 X-CRM114-Status: GOOD ( 16.66 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: fenghua.yu@intel.com, will@kernel.org, catalin.marinas@arm.com, zhengxiang9@huawei.com, linux-mm@kvack.org, iommu@lists.linux-foundation.org, zhangfei.gao@linaro.org, robin.murphy@arm.com, linux-arm-kernel@lists.infradead.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Tue, Sep 08, 2020 at 09:45:02AM +0200, Auger Eric wrote: > > +int iommu_sva_alloc_pasid(struct mm_struct *mm, ioasid_t min, ioasid_t max) > > +{ > > + int ret = 0; > > + ioasid_t pasid; > > + > > + if (min == INVALID_IOASID || max == INVALID_IOASID || > > + min == 0 || max < min) > you may add a comment explaining why min == 0 is forbidden. Right, I'll add to the function doc "@min must be greater than 0 because 0 indicates an unused mm->pasid." > > + return -EINVAL; > > + > > + mutex_lock(&iommu_sva_lock); > > + if (mm->pasid) { > > + if (mm->pasid >= min && mm->pasid <= max) > > + ioasid_get(mm->pasid); > > + else > > + ret = -EOVERFLOW; > > + } else { > > + pasid = ioasid_alloc(&iommu_sva_pasid, min, max, mm); > > + if (pasid == INVALID_IOASID) > > + ret = -ENOMEM; > > + else > > + mm->pasid = pasid; > > + } > > + mutex_unlock(&iommu_sva_lock); > > + return ret; > > +} > > +EXPORT_SYMBOL_GPL(iommu_sva_alloc_pasid); > > + > > +/** > > + * iommu_sva_free_pasid - Release the mm's PASID > > + * @mm: the mm. > > + * > > + * Drop one reference to a PASID allocated with iommu_sva_alloc_pasid() > > + */ > > +void iommu_sva_free_pasid(struct mm_struct *mm) > > +{ > > + mutex_lock(&iommu_sva_lock); > > + if (ioasid_put(mm->pasid)) > > + mm->pasid = 0; > ditto: 0 versus INVALID_IOASID > > + mutex_unlock(&iommu_sva_lock); > > +} > > +EXPORT_SYMBOL_GPL(iommu_sva_free_pasid); > > + > > +/* ioasid wants a void * argument */ > shouldn't it be: > ioasid_find getter() requires a void *arg? Ok Thanks, Jean > > +static bool __mmget_not_zero(void *mm) > > +{ > > + return mmget_not_zero(mm); > > +} > > + > > +/** > > + * iommu_sva_find() - Find mm associated to the given PASID > > + * @pasid: Process Address Space ID assigned to the mm > > + * > > + * On success a reference to the mm is taken, and must be released with mmput(). > > + * > > + * Returns the mm corresponding to this PASID, or an error if not found. > > + */ > > +struct mm_struct *iommu_sva_find(ioasid_t pasid) > > +{ > > + return ioasid_find(&iommu_sva_pasid, pasid, __mmget_not_zero); > > +} > > +EXPORT_SYMBOL_GPL(iommu_sva_find); > > > Thanks > > Eric > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel