Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp1876321pxb; Sat, 2 Apr 2022 06:49:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJye2tS11roLx4XbSpn05tqs4sOYZ++8NqgYFPZ3TekKQ7qnAd2m0IpcEwKxpXRG87Rv/aN0 X-Received: by 2002:a17:906:2ac9:b0:6ce:dc0f:9139 with SMTP id m9-20020a1709062ac900b006cedc0f9139mr4001908eje.206.1648907340216; Sat, 02 Apr 2022 06:49:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648907340; cv=none; d=google.com; s=arc-20160816; b=Ux0OE1XExImPvncGmqR2297XPvQXuCBUZiknKbQA+Pv3o3LVAfvusxhYFUttuSNZk5 M11D7FylvNWcYqPjcllh7gX0JyK8/w/he0wlOG8IBnEjb1hCS4PQETuG8gY3bpoKXQFz 2rkcAxbgAD38efh1WHDRktRU34lldzHbDgHZrozMJ0fsjPArqofJVxxOSo1savpPhxFm SkntHWutY3x+pWh2Duu1amtjxTUNNzVrHUT5PvueZS5hVhklxmlRw+AWSTNoglrmjY5U MBgBmk6ge5tD0DuPDpQpf6g488CuYiohlEc2C1y5SMD/UX/AWMhkJLRIhHDM3bsejOPX Kwaw== 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:references :cc:to:from:content-language:subject:user-agent:mime-version:date :message-id:dkim-signature; bh=uzk/bUAs7XhTGmTg7nlbg5A2UHMg424PM7HVEqP04wQ=; b=KCbvroZKUHmhnDk6S0COIJBgTZNEoPIxCHGL7Et1SSL6tzflDVRv4t6naHfAtUqXey 0CwGBL/fghrahGVQkG10uNJiNZRsjhpcdSGVkj7szaYd4ucW89o0/ktipmNcoj632YFR 636W6UUazwx2uzVssbnysguZM/C9sGuojCkD4t858H1urAUvNEkdA6M1Jv4BACEE1eFK m2gySxMoEv/yOEGRsUIi311tZy4L6ATKhZl2j92OnInS/71Tw/wE/nzOV/oLRM7SMoqw 5IXn+LsfFlEs+WtK6CYwE41G7kLc6j9NqkCE+32NbLE/3ym9wWD8lv3Z69XGEWc29zDu RTmw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=NMyTkxSb; 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 l24-20020a17090612d800b006e753f09757si134103ejb.344.2022.04.02.06.48.35; Sat, 02 Apr 2022 06:49: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=NMyTkxSb; 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 S234424AbiCaSae (ORCPT + 99 others); Thu, 31 Mar 2022 14:30:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34980 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233699AbiCaSac (ORCPT ); Thu, 31 Mar 2022 14:30:32 -0400 Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [46.235.227.227]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 466EE12ACF; Thu, 31 Mar 2022 11:28:41 -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 6200B1F470F2; Thu, 31 Mar 2022 19:28:39 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1648751320; bh=vyOpcTiaZFvqT16kUkwfJxPfiNIA9t77ryyYGvjS/kw=; h=Date:Subject:From:To:Cc:References:In-Reply-To:From; b=NMyTkxSbhyiuoFfcFGjiJyAE9DRsNObCQKZQXAVR3GccmNasEavDSS9JG49G7SZXX D8Ay0nWAQ/IOOH8ja8FJcrhJ5Vnh7uPICpOKuQjvV3g7XS+PjtOJT+gQ0Y4qdJeYJ8 OcejZY1IQU6kplmnz/oCoatfHdynMDdrQRNQRQjNBY3AHF89dgUI+JJgF2qeTdBSwD X8DXf+Id1WysC//XGj61Kx2qR3g2Y/0rApjvKXc4IxLHOHFBBVIlPS7GJLN1A1PYfg 1OjijavP4rtuG+4X/sBfcCJ5nVBG9x2VxH/roZ4/JSy87rqQ5jAaAOd2o4IySFMm3x ldAvQQrpLkHZg== Message-ID: <9de85a5a-0b61-0b20-d8b2-d412fc081647@collabora.com> Date: Thu, 31 Mar 2022 21:28:36 +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 From: Dmitry Osipenko 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> <83979c7b-8a8a-5006-6af3-f3ca8b0d8ced@collabora.com> In-Reply-To: <83979c7b-8a8a-5006-6af3-f3ca8b0d8ced@collabora.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/31/22 21:27, 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 *allocating > >> 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.