Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp995544pxb; Fri, 1 Apr 2022 01:30:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyIyAzCswnYo5b7e0TfCjCp+/5HbXTmggm+9y7fMp80GA+nGMjSx/QRjvyVHnZAJ1UgY91p X-Received: by 2002:a17:90a:1389:b0:1c7:a9e0:ef23 with SMTP id i9-20020a17090a138900b001c7a9e0ef23mr10575371pja.138.1648801806876; Fri, 01 Apr 2022 01:30:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648801806; cv=none; d=google.com; s=arc-20160816; b=jKfJ82um5egEsXYWbekpHsCOweajUd5zIrdWjOvVczPwimVNIow/H/LHMo7dGQgXoA XFtpsVFR6eG2gXnXsFmO4GCSvpJE6gBG6wyFDiaU4mNeYHrfDT0JDvTEDxnPgumcupCy dTgABmynJx8x7yMiG2+nwPGHTtASTM7qlDYHZ3+M+gAVjuWfx0WhdWRhPsoa8S4S0VME tyNvcI5pxC/XlhCaxetoCsmJu+E+uT05RovcsJYmbT+tJyCBhjcX3p6jDqJBlPQ6XTko xsm0cPd5pbK4bkRfnRaxoIOLBRl4hcYCNlUjNb+ES0YlccnjGZx6/PY82D+prDkXE4kq CtfQ== 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=2Uw4F94DVjhSo57lCcyOwtEZyhVdUCkBukvbiaDfQ+0=; b=WTwFe+NQu4V6HAJznPpQPkwcjCgLRdjKcfM6i0MbLQ4f8WDNSioO7VkJss2w8kjpCD SX1V6Se5sYszooV0myaK4Efswluep1wdJMmPQ/Z8bF3hMX00+8KazDJpKo7usNg4ecnn JCpr36MR88wIFT86arR4Uu/190ad5uqlVryb0aFdH7FJkLrxY7BFclpdcnOREYpLDgRD DHBmtxBPFhna/BJpJCNZYNwkIo3anp+S+NauDCXCLLT7BEuVhWMgI3y4GtHGTWOTdda8 TG/tp1GhCdeI3jckcCJZ8vGPppMkaYgF0At8PGYgVwBXWvtprHCRbCDZgorY+KQg+QDf 7M/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=aU+ySryv; 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 q20-20020a170902b11400b00155e8c68779si1347906plr.601.2022.04.01.01.29.43; Fri, 01 Apr 2022 01:30:06 -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=aU+ySryv; 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 S241535AbiCaUvZ (ORCPT + 99 others); Thu, 31 Mar 2022 16:51:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53958 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233946AbiCaUvX (ORCPT ); Thu, 31 Mar 2022 16:51:23 -0400 Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [46.235.227.227]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 19B72381AC; Thu, 31 Mar 2022 13:49:32 -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 663461F472B4; Thu, 31 Mar 2022 21:49:30 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1648759771; bh=euVVKOinX78LJMKrZP4o6rrvu4hdAz3jFyyNapFRAMg=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=aU+ySryv7hPIyjtk1t95Bj5UstgWJyj78s4NVbEyHDyWjwOtULLr7i2QvQwOftsYu mZIgLpZ6ebi8zPN2sXml8PlXsD5ECqjXsQfA3AIw85HoYC+2wtVXtR5kb8k726rBEE siqevoQ98XYD2sGobZMzx3fxt1bB3LiMrLqrJTBXlh75VzqVVnKCLV7Uk+xf2/GIX+ ogEg+um7F6OVbP/BsCJe0Z9VvDLneQJCNxw2VqGYxHbxe/OWJmZqcUPQ/Xt7ITr/Wz lQ6xw9mkBmmD2bK1rMkryNPtbb/Fvj16gQ5ZMVynxb/nBa3J1zlJK2sivGTnxdRUp5 xnAHZP6ZtCuxw== Message-ID: <8b1aa75d-1de4-40d2-c80b-7d23605dd49e@collabora.com> Date: Thu, 31 Mar 2022 23:49:27 +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 Cc: dri-devel , freedreno , linux-arm-msm , 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> <83979c7b-8a8a-5006-6af3-f3ca8b0d8ced@collabora.com> From: Dmitry Osipenko In-Reply-To: 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/31/22 21:58, Rob Clark wrote: > On Thu, Mar 31, 2022 at 11:27 AM Dmitry Osipenko > wrote: >> >> 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? > > There are a few cases (for allocations for GMU) where the range is > larger than the bo.. see a6xx_gmu_memory_alloc() Ahh, I didn't read the code properly and see now why you're using the obj->size. It's the range where you want to put the BO. Looks good then. Reviewed-by: Dmitry Osipenko