Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp1064115pxb; Fri, 1 Apr 2022 03:43:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz0OS7QfuLPfAMcaU9Ds7twGvudGD0nu/FEnYm2A6OBdstIjXjxz4393WIHAhBEPjQXJkgU X-Received: by 2002:a17:907:1b1b:b0:6e4:7fac:6ce0 with SMTP id mp27-20020a1709071b1b00b006e47fac6ce0mr8642993ejc.617.1648809780768; Fri, 01 Apr 2022 03:43:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648809780; cv=none; d=google.com; s=arc-20160816; b=tHkLqTkD5AjNUzthGkYpI2heiEOI5Ztnd6sgnUmvgd1TO5VgXzz+rlDVAGEem9aSz1 kBSrM+UvfAgeqLkhKTI3gK0P7iMehu016Df65gcaZRdcn/zG99pcJ5ZXfKRRGrhX9Iyb w+onz4/IMbc7E3Bkn/A+YYVQvbZWxUjbtTUbwxOHv0n04FIL/g3gIH9HNzx9cbGo+QWN AKneOUODeWtkFU4Ui0fdbPAjCIeG8Z70wFQnq6xa35b7nla5fQhBz6sf4a2TjUTskdAI 82/O/l3aBOs90Z7BkGC20dFPEHIeQmWNGr1jSss824YvppGFEUGWzHY+5CPdNtH1J0gM gapg== 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:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=FHRegosT8vsbhDwdeowRuY5iVgtyCfDHpUSSu3vrY50=; b=aXlDe+KqQ/Olk9IHto4iW7qnCMVTc/0lLNE7kXch0DbUQfn1WNVXVGb7D+IRHCgQ6w OSEPiXrudFNxaitkftcswC/M7lDbQpdICoXs78wo9DeAmHiyutqsehzatQa6e8AFzuU4 VUuNWPNWPkLoHzHqZdiK/tEXYyNV+d/LT2VcZldj3xR/2D2Zm1wlRQOD0NcxYtOMapPx Z9/wnajEZDhyZoON1PafeSkz0fW4RZ5H5SMVO7y8CNMD0uzDD76atxVxzlF7AgfNyIk7 r3hvm7+4a3G9iyPUcPytIy6MVPZqT+MnjQOLSNx2FpYSntjrD5wFGedh/TB1Ar8p6SVO scpg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=Pvdo9fWI; 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=collabora.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b19-20020a1709063f9300b006df76385edbsi1309352ejj.891.2022.04.01.03.42.35; Fri, 01 Apr 2022 03:43:00 -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=@collabora.com header.s=mail header.b=Pvdo9fWI; 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=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234379AbiCaS3U (ORCPT + 99 others); Thu, 31 Mar 2022 14:29:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60638 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233699AbiCaS3T (ORCPT ); Thu, 31 Mar 2022 14:29:19 -0400 Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e3e3]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DD2B113E85; Thu, 31 Mar 2022 11:27:30 -0700 (PDT) Received: from [IPV6:2a00:5f00:102:0:10b3:10ff:fe5d:4ec1] (unknown [IPv6:2a00:5f00:102:0:10b3:10ff:fe5d:4ec1]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: dmitry.osipenko) by bhuna.collabora.co.uk (Postfix) with ESMTPSA id DB2721F470F3; Thu, 31 Mar 2022 19:27:28 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1648751249; bh=uP7q/xYsT32zx3bzbweG0t9nZq+UAL3kQqtb4RqJLm8=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=Pvdo9fWIRW4W+gzpHQiwinvhXLCRyAC1ZPTm5yM2woYZMseQ7vo4JNJmwR796bUjh HSAJcrJ5+PpFcwE83BAgE5NctvFxx6okVEh6E4tiA8jlbE4O/nUCc3sgMw61Iu/lHE q0L+/W2EOOCjdle1t11TZzFYqp0mx8QRfe2npCwt6C7pymmtTF/CHPxZVWqBF/7cP1 5BSPqivxVGrip5/vffd9looqQiB4Bfllg/+HMmXLfv7ERgJYtxArrZmgY/D7ynIw+e cpNEXdAcygH+288NqW5YJFa3i3fKyVvWGz657DWYO7IrAUFA8iK0y3SLdkkkhttXz2 0ahKTKkrU/YOQ== Message-ID: <83979c7b-8a8a-5006-6af3-f3ca8b0d8ced@collabora.com> Date: Thu, 31 Mar 2022 21:27:25 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.7.0 Subject: Re: [PATCH v2 07/10] drm/msm/gem: Rework vma lookup and pin Content-Language: en-US To: Rob Clark , dri-devel@lists.freedesktop.org Cc: freedreno@lists.freedesktop.org, linux-arm-msm@vger.kernel.org, Dmitry Baryshkov , Rob Clark , Sean Paul , Abhinav Kumar , David Airlie , Daniel Vetter , open list References: <20220330204804.660819-1-robdclark@gmail.com> <20220330204804.660819-8-robdclark@gmail.com> From: Dmitry Osipenko In-Reply-To: <20220330204804.660819-8-robdclark@gmail.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,SPF_HELO_PASS, SPF_PASS,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 3/30/22 23:47, Rob Clark wrote: > From: Rob Clark > > Combines duplicate vma lookup in the get_and_pin path. > > Signed-off-by: Rob Clark > --- > drivers/gpu/drm/msm/msm_gem.c | 50 ++++++++++++++++++----------------- > 1 file changed, 26 insertions(+), 24 deletions(-) > > diff --git a/drivers/gpu/drm/msm/msm_gem.c b/drivers/gpu/drm/msm/msm_gem.c > index deafae6feaa8..218744a490a4 100644 > --- a/drivers/gpu/drm/msm/msm_gem.c > +++ b/drivers/gpu/drm/msm/msm_gem.c > @@ -376,39 +376,40 @@ put_iova_vmas(struct drm_gem_object *obj) > } > } > > -static int get_iova_locked(struct drm_gem_object *obj, > - struct msm_gem_address_space *aspace, uint64_t *iova, > +static struct msm_gem_vma *get_vma_locked(struct drm_gem_object *obj, > + struct msm_gem_address_space *aspace, > u64 range_start, u64 range_end) > { > struct msm_gem_vma *vma; > - int ret = 0; > > GEM_WARN_ON(!msm_gem_is_locked(obj)); > > vma = lookup_vma(obj, aspace); > > if (!vma) { > + int ret; > + > vma = add_vma(obj, aspace); > if (IS_ERR(vma)) > - return PTR_ERR(vma); > + return vma; > > ret = msm_gem_init_vma(aspace, vma, obj->size, > range_start, range_end); > if (ret) { You're allocation range_start -> range_end > del_vma(vma); > - return ret; > + return ERR_PTR(ret); > } > + } else { > + GEM_WARN_ON(vma->iova < range_start); > + GEM_WARN_ON((vma->iova + obj->size) > range_end); and then comparing range_start -> range_start + obj->size, hence you're assuming that range_end always equals to obj->size during the allocation. I'm not sure what is the idea here.. this looks inconsistent. I think you wanted to write: GEM_WARN_ON(vma->iova < range_start); GEM_WARN_ON(vma->iova + (vma->node.size << PAGE_SHIFT) > range_end); But is it really useful to check whether the new range is inside of the old range? Shouldn't it be always a error to change the IOVA range without reallocating vma? I'd expect to see: GEM_WARN_ON(vma->iova != range_start); GEM_WARN_ON(vma->iova + (vma->node.size << PAGE_SHIFT) != range_end); and then error out if range mismatches.