Message ID | 20230622101412.78426-4-thomas.hellstrom@linux.intel.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp4974306vqr; Thu, 22 Jun 2023 03:56:05 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ71RL4CMtMzElnuSjDKtHkCKNXaCNB/I51K/216s7hrV4yzsGFUkhx8WGdKQ+TJ2ATdnwUw X-Received: by 2002:a05:6358:57:b0:132:ce1f:6793 with SMTP id 23-20020a056358005700b00132ce1f6793mr1845710rwx.21.1687431365011; Thu, 22 Jun 2023 03:56:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687431364; cv=none; d=google.com; s=arc-20160816; b=j2ktXC+oZ9DuK836cIfvUM2IGk23sUDJvRHNELzbBK57nxOcse1/ShEHhM7oC6eDHR Icm7qSdsIRSDbKbx+caISw5qZMcrDXQmCkXvB2tU8iklx7A52YSndmJ9qqgAdYsOk50M pnN4zJ02vEG66/jRHel09ELbtN/EnspA3N7ncpqUeKMT5zVVlmRvncQ1IDuNzStxTpGx abgxZTZDLq5a1+34ZVdrwmiwIR8N7Ab2Cf84TNnfOaaeLtoKyvWH0KOTHQacTX4UCS1c uQ5LlSJ2x5hQEwpnrz+HPQkX9IYwvdD6hhmqpSHIhW+RGJgXJ7kjyGlokuVEBm5N2UKF JI4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=GMMBu0aP34+bQADVdA4hm+8QHh6m3LblEeOkazTZokA=; b=G7QDQS1BgDGyKwJnCXfegiPGFAIUxkrOfVQh+HIGDpFzOdg+IZLkQiGXkzWCcZT2rE k7M5Nioa4eG68hScaxhPz5LL62bzmUXpr8lOjQDr1CWJrKVpyURgk+bEFvIzZRbYDb76 8263qv3qlTWfcWkKr/QMkQIuKJptJexXbdoYoTWrwRkmf9wRlDDfWXUN5H+lmfDigoxM VCELYGmTn9bi0+gAnLhawYpJlUJK2e1jTbMhBaMyLOpkUrYsqDOIuswA/suAPGQyIFVt lVyvSZ09H+ZQ0ReW6UX5zOV4G2cES+xBTkVEAENV1YYNd/RpSxatbwdj1DUtLUNcyzEj kDwA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=ilI2v4mb; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 85-20020a630058000000b0053fe392ca3esi2523866pga.509.2023.06.22.03.55.38; Thu, 22 Jun 2023 03:56:04 -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=ilI2v4mb; 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 S231591AbjFVKVe (ORCPT <rfc822;maxin.john@gmail.com> + 99 others); Thu, 22 Jun 2023 06:21:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41380 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231480AbjFVKVK (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 22 Jun 2023 06:21:10 -0400 Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9F7331BFA; Thu, 22 Jun 2023 03:20:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1687429260; x=1718965260; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=n9z5G10dFEpvSF9s/7DggC7dqDZF2o/8gaNO2uyYJ5k=; b=ilI2v4mbJns+prEp1eWu4qOZM+yntxQi92RzNyK4P2MtEAb6rakYsKXZ 8nVcIxkxUdY6XMKbK8nQLG94yYE5MIIxL8xub1Mo9XwxfHyFMbZcUrg1j eRyZz/Bt9h8yhZOAEfBQWHw7rXJvAOmhkWj2DzVrRA6OD00Nt3IIxP2QO K3FTVdGwIkWgYBRYz9qFvXiHHb3oVXYOPVByw6DzJDRL3wwW5FP8JP66Q vm8JgGi4m4nB7Wv6IjEn3JQcxJ/iyl7qmaH5sWtuZTk/ZW9RioMcgCWuq 3A6U8ftJBpBxHwyplccG9Rlquy7+I9HFnXUCnxaHHvzc1OOl/HQeb8QDm A==; X-IronPort-AV: E=McAfee;i="6600,9927,10748"; a="345182362" X-IronPort-AV: E=Sophos;i="6.00,263,1681196400"; d="scan'208";a="345182362" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Jun 2023 03:15:02 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10748"; a="692194358" X-IronPort-AV: E=Sophos;i="6.00,263,1681196400"; d="scan'208";a="692194358" Received: from shari19x-mobl1.gar.corp.intel.com (HELO thellstr-mobl1.intel.com) ([10.249.254.173]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Jun 2023 03:14:59 -0700 From: =?utf-8?q?Thomas_Hellstr=C3=B6m?= <thomas.hellstrom@linux.intel.com> To: intel-xe@lists.freedesktop.org Cc: =?utf-8?q?Thomas_Hellstr=C3=B6m?= <thomas.hellstrom@linux.intel.com>, Andrey Grodzovsky <andrey.grodzovsky@amd.com>, =?utf-8?q?Christian_K=C3=B6n?= =?utf-8?q?ig?= <christian.koenig@amd.com>, Huang Rui <ray.huang@amd.com>, dri-devel@lists.freedesktop.org, stable@vger.kernel.org, intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org, =?utf-8?q?Ch?= =?utf-8?q?ristian_K=C3=B6nig?= <ckoenig.leichtzumerken@gmail.com> Subject: [PATCH 3/4] drm/ttm: Don't leak a resource on eviction error Date: Thu, 22 Jun 2023 12:14:11 +0200 Message-Id: <20230622101412.78426-4-thomas.hellstrom@linux.intel.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230622101412.78426-1-thomas.hellstrom@linux.intel.com> References: <20230622101412.78426-1-thomas.hellstrom@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1769400030809047570?= X-GMAIL-MSGID: =?utf-8?q?1769400030809047570?= |
Series |
drm/ttm: Fixes around resources and bulk moves
|
|
Commit Message
Thomas Hellström
June 22, 2023, 10:14 a.m. UTC
On eviction errors other than -EMULTIHOP we were leaking a resource.
Fix.
Fixes: 403797925768 ("drm/ttm: Fix multihop assert on eviction.")
Cc: Andrey Grodzovsky <andrey.grodzovsky@amd.com>
Cc: Christian König <christian.koenig@amd.com>
Cc: Christian Koenig <christian.koenig@amd.com>
Cc: Huang Rui <ray.huang@amd.com>
Cc: dri-devel@lists.freedesktop.org
Cc: <stable@vger.kernel.org> # v5.15+
Signed-off-by: Thomas Hellström <thomas.hellstrom@linux.intel.com>
---
drivers/gpu/drm/ttm/ttm_bo.c | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
Comments
On 6/22/2023 12:14 PM, Thomas Hellström wrote: > On eviction errors other than -EMULTIHOP we were leaking a resource. > Fix. > > Fixes: 403797925768 ("drm/ttm: Fix multihop assert on eviction.") > Cc: Andrey Grodzovsky <andrey.grodzovsky@amd.com> > Cc: Christian König <christian.koenig@amd.com> > Cc: Christian Koenig <christian.koenig@amd.com> > Cc: Huang Rui <ray.huang@amd.com> > Cc: dri-devel@lists.freedesktop.org > Cc: <stable@vger.kernel.org> # v5.15+ > Signed-off-by: Thomas Hellström <thomas.hellstrom@linux.intel.com> Reviewed-by: Nirmoy Das <nirmoy.das@intel.com> > --- > drivers/gpu/drm/ttm/ttm_bo.c | 16 ++++++++-------- > 1 file changed, 8 insertions(+), 8 deletions(-) > > diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c > index 615d30c4262d..89530f2a027f 100644 > --- a/drivers/gpu/drm/ttm/ttm_bo.c > +++ b/drivers/gpu/drm/ttm/ttm_bo.c > @@ -462,14 +462,14 @@ static int ttm_bo_evict(struct ttm_buffer_object *bo, > ret = ttm_bo_handle_move_mem(bo, evict_mem, true, ctx, &hop); > if (ret == -EMULTIHOP) { > ret = ttm_bo_bounce_temp_buffer(bo, &evict_mem, ctx, &hop); > - if (ret) { > - if (ret != -ERESTARTSYS && ret != -EINTR) > - pr_err("Buffer eviction failed\n"); > - ttm_resource_free(bo, &evict_mem); > - goto out; > - } > - /* try and move to final place now. */ > - goto bounce; > + if (!ret) > + /* try and move to final place now. */ > + goto bounce; > + } > + if (ret) { > + ttm_resource_free(bo, &evict_mem); > + if (ret != -ERESTARTSYS && ret != -EINTR) > + pr_err("Buffer eviction failed\n"); > } > out: > return ret;
Hi Thomas, On Thu, Jun 22, 2023 at 12:14:11PM +0200, Thomas Hellström wrote: > On eviction errors other than -EMULTIHOP we were leaking a resource. > Fix. > > Fixes: 403797925768 ("drm/ttm: Fix multihop assert on eviction.") > Cc: Andrey Grodzovsky <andrey.grodzovsky@amd.com> > Cc: Christian König <christian.koenig@amd.com> > Cc: Christian Koenig <christian.koenig@amd.com> > Cc: Huang Rui <ray.huang@amd.com> > Cc: dri-devel@lists.freedesktop.org > Cc: <stable@vger.kernel.org> # v5.15+ > Signed-off-by: Thomas Hellström <thomas.hellstrom@linux.intel.com> > --- > drivers/gpu/drm/ttm/ttm_bo.c | 16 ++++++++-------- > 1 file changed, 8 insertions(+), 8 deletions(-) > > diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c > index 615d30c4262d..89530f2a027f 100644 > --- a/drivers/gpu/drm/ttm/ttm_bo.c > +++ b/drivers/gpu/drm/ttm/ttm_bo.c > @@ -462,14 +462,14 @@ static int ttm_bo_evict(struct ttm_buffer_object *bo, > ret = ttm_bo_handle_move_mem(bo, evict_mem, true, ctx, &hop); > if (ret == -EMULTIHOP) { > ret = ttm_bo_bounce_temp_buffer(bo, &evict_mem, ctx, &hop); > - if (ret) { > - if (ret != -ERESTARTSYS && ret != -EINTR) > - pr_err("Buffer eviction failed\n"); > - ttm_resource_free(bo, &evict_mem); > - goto out; > - } > - /* try and move to final place now. */ > - goto bounce; > + if (!ret) > + /* try and move to final place now. */ > + goto bounce; As we are at this, can't we replace this with a while()? Goto's used instead of a while loop are a fist in the eye... It looks even better: while (1) { ret = ttm_bo_handle_move_mem(bo, evict_mem, true, ctx, &hop); if (!ret) break; if (ret == -EMULTIHOP) ret = ttm_bo_bounce_temp_buffer(bo, &evict_mem, ctx, &hop); /* try again */ if (!ret) continue; ttm_resource_free(bo, &evict_mem); if (ret != -ERESTARTSYS && ret != -EINTR) pr_err("Buffer eviction failed\n"); break; } Andi > + } > + if (ret) { > + ttm_resource_free(bo, &evict_mem); > + if (ret != -ERESTARTSYS && ret != -EINTR) > + pr_err("Buffer eviction failed\n"); > } > out: > return ret; > -- > 2.40.1
On 6/22/23 15:55, Andi Shyti wrote: > Hi Thomas, > > On Thu, Jun 22, 2023 at 12:14:11PM +0200, Thomas Hellström wrote: >> On eviction errors other than -EMULTIHOP we were leaking a resource. >> Fix. >> >> Fixes: 403797925768 ("drm/ttm: Fix multihop assert on eviction.") >> Cc: Andrey Grodzovsky <andrey.grodzovsky@amd.com> >> Cc: Christian König <christian.koenig@amd.com> >> Cc: Christian Koenig <christian.koenig@amd.com> >> Cc: Huang Rui <ray.huang@amd.com> >> Cc: dri-devel@lists.freedesktop.org >> Cc: <stable@vger.kernel.org> # v5.15+ >> Signed-off-by: Thomas Hellström <thomas.hellstrom@linux.intel.com> >> --- >> drivers/gpu/drm/ttm/ttm_bo.c | 16 ++++++++-------- >> 1 file changed, 8 insertions(+), 8 deletions(-) >> >> diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c >> index 615d30c4262d..89530f2a027f 100644 >> --- a/drivers/gpu/drm/ttm/ttm_bo.c >> +++ b/drivers/gpu/drm/ttm/ttm_bo.c >> @@ -462,14 +462,14 @@ static int ttm_bo_evict(struct ttm_buffer_object *bo, >> ret = ttm_bo_handle_move_mem(bo, evict_mem, true, ctx, &hop); >> if (ret == -EMULTIHOP) { >> ret = ttm_bo_bounce_temp_buffer(bo, &evict_mem, ctx, &hop); >> - if (ret) { >> - if (ret != -ERESTARTSYS && ret != -EINTR) >> - pr_err("Buffer eviction failed\n"); >> - ttm_resource_free(bo, &evict_mem); >> - goto out; >> - } >> - /* try and move to final place now. */ >> - goto bounce; >> + if (!ret) >> + /* try and move to final place now. */ >> + goto bounce; > As we are at this, can't we replace this with a while()? Goto's > used instead of a while loop are a fist in the eye... I'm completely OK with that. this patch already did away with one of them. Let's hear Christian's opinion first, though. Thanks, Thomas > > It looks even better: > > while (1) { > ret = ttm_bo_handle_move_mem(bo, evict_mem, true, ctx, &hop); > if (!ret) > break; > > if (ret == -EMULTIHOP) > ret = ttm_bo_bounce_temp_buffer(bo, &evict_mem, > ctx, &hop); > > /* try again */ > if (!ret) > continue; > > ttm_resource_free(bo, &evict_mem); > if (ret != -ERESTARTSYS && ret != -EINTR) > pr_err("Buffer eviction failed\n"); > > break; > } > > Andi > >> + } >> + if (ret) { >> + ttm_resource_free(bo, &evict_mem); >> + if (ret != -ERESTARTSYS && ret != -EINTR) >> + pr_err("Buffer eviction failed\n"); >> } >> out: >> return ret; >> -- >> 2.40.1
Am 22.06.23 um 16:08 schrieb Thomas Hellström: > > On 6/22/23 15:55, Andi Shyti wrote: >> Hi Thomas, >> >> On Thu, Jun 22, 2023 at 12:14:11PM +0200, Thomas Hellström wrote: >>> On eviction errors other than -EMULTIHOP we were leaking a resource. >>> Fix. >>> >>> Fixes: 403797925768 ("drm/ttm: Fix multihop assert on eviction.") >>> Cc: Andrey Grodzovsky <andrey.grodzovsky@amd.com> >>> Cc: Christian König <christian.koenig@amd.com> >>> Cc: Christian Koenig <christian.koenig@amd.com> >>> Cc: Huang Rui <ray.huang@amd.com> >>> Cc: dri-devel@lists.freedesktop.org >>> Cc: <stable@vger.kernel.org> # v5.15+ >>> Signed-off-by: Thomas Hellström <thomas.hellstrom@linux.intel.com> >>> --- >>> drivers/gpu/drm/ttm/ttm_bo.c | 16 ++++++++-------- >>> 1 file changed, 8 insertions(+), 8 deletions(-) >>> >>> diff --git a/drivers/gpu/drm/ttm/ttm_bo.c >>> b/drivers/gpu/drm/ttm/ttm_bo.c >>> index 615d30c4262d..89530f2a027f 100644 >>> --- a/drivers/gpu/drm/ttm/ttm_bo.c >>> +++ b/drivers/gpu/drm/ttm/ttm_bo.c >>> @@ -462,14 +462,14 @@ static int ttm_bo_evict(struct >>> ttm_buffer_object *bo, >>> ret = ttm_bo_handle_move_mem(bo, evict_mem, true, ctx, &hop); >>> if (ret == -EMULTIHOP) { >>> ret = ttm_bo_bounce_temp_buffer(bo, &evict_mem, ctx, &hop); >>> - if (ret) { >>> - if (ret != -ERESTARTSYS && ret != -EINTR) >>> - pr_err("Buffer eviction failed\n"); >>> - ttm_resource_free(bo, &evict_mem); >>> - goto out; >>> - } >>> - /* try and move to final place now. */ >>> - goto bounce; >>> + if (!ret) >>> + /* try and move to final place now. */ >>> + goto bounce; >> As we are at this, can't we replace this with a while()? Goto's >> used instead of a while loop are a fist in the eye... > > I'm completely OK with that. this patch already did away with one of > them. Let's hear Christian's opinion first, though. I'm not a fan of that goto either, but could we somehow avoid the while(1) ? E.g. something like do { } while (!ret) after handling the multihop? Christian. > > Thanks, > > Thomas > > > > > >> >> It looks even better: >> >> while (1) { >> ret = ttm_bo_handle_move_mem(bo, evict_mem, true, ctx, &hop); >> if (!ret) >> break; >> >> if (ret == -EMULTIHOP) >> ret = ttm_bo_bounce_temp_buffer(bo, &evict_mem, >> ctx, &hop); >> >> /* try again */ >> if (!ret) >> continue; >> >> ttm_resource_free(bo, &evict_mem); >> if (ret != -ERESTARTSYS && ret != -EINTR) >> pr_err("Buffer eviction failed\n"); >> >> break; >> } >> >> Andi >> >>> + } >>> + if (ret) { >>> + ttm_resource_free(bo, &evict_mem); >>> + if (ret != -ERESTARTSYS && ret != -EINTR) >>> + pr_err("Buffer eviction failed\n"); >>> } >>> out: >>> return ret; >>> -- >>> 2.40.1
On 6/22/23 16:48, Christian König wrote: > > > Am 22.06.23 um 16:08 schrieb Thomas Hellström: >> >> On 6/22/23 15:55, Andi Shyti wrote: >>> Hi Thomas, >>> >>> On Thu, Jun 22, 2023 at 12:14:11PM +0200, Thomas Hellström wrote: >>>> On eviction errors other than -EMULTIHOP we were leaking a resource. >>>> Fix. >>>> >>>> Fixes: 403797925768 ("drm/ttm: Fix multihop assert on eviction.") >>>> Cc: Andrey Grodzovsky <andrey.grodzovsky@amd.com> >>>> Cc: Christian König <christian.koenig@amd.com> >>>> Cc: Christian Koenig <christian.koenig@amd.com> >>>> Cc: Huang Rui <ray.huang@amd.com> >>>> Cc: dri-devel@lists.freedesktop.org >>>> Cc: <stable@vger.kernel.org> # v5.15+ >>>> Signed-off-by: Thomas Hellström <thomas.hellstrom@linux.intel.com> >>>> --- >>>> drivers/gpu/drm/ttm/ttm_bo.c | 16 ++++++++-------- >>>> 1 file changed, 8 insertions(+), 8 deletions(-) >>>> >>>> diff --git a/drivers/gpu/drm/ttm/ttm_bo.c >>>> b/drivers/gpu/drm/ttm/ttm_bo.c >>>> index 615d30c4262d..89530f2a027f 100644 >>>> --- a/drivers/gpu/drm/ttm/ttm_bo.c >>>> +++ b/drivers/gpu/drm/ttm/ttm_bo.c >>>> @@ -462,14 +462,14 @@ static int ttm_bo_evict(struct >>>> ttm_buffer_object *bo, >>>> ret = ttm_bo_handle_move_mem(bo, evict_mem, true, ctx, &hop); >>>> if (ret == -EMULTIHOP) { >>>> ret = ttm_bo_bounce_temp_buffer(bo, &evict_mem, ctx, &hop); >>>> - if (ret) { >>>> - if (ret != -ERESTARTSYS && ret != -EINTR) >>>> - pr_err("Buffer eviction failed\n"); >>>> - ttm_resource_free(bo, &evict_mem); >>>> - goto out; >>>> - } >>>> - /* try and move to final place now. */ >>>> - goto bounce; >>>> + if (!ret) >>>> + /* try and move to final place now. */ >>>> + goto bounce; >>> As we are at this, can't we replace this with a while()? Goto's >>> used instead of a while loop are a fist in the eye... >> >> I'm completely OK with that. this patch already did away with one of >> them. Let's hear Christian's opinion first, though. > > I'm not a fan of that goto either, but could we somehow avoid the > while(1) ? E.g. something like do { } while (!ret) after handling the > multihop? I think the construct that makes it most obvious what's happening, although it needs two tests for -EMULTIHOP is something like do { .... if (ret != -EMULTIHOP) break; .... } while (ret ==-EMULTIHOP); Will be out tomorrow, though, so I don't have time to respin before Monday. /Thomas > > Christian. > >> >> Thanks, >> >> Thomas >> >> >> >> >> >>> >>> It looks even better: >>> >>> while (1) { >>> ret = ttm_bo_handle_move_mem(bo, evict_mem, true, ctx, &hop); >>> if (!ret) >>> break; >>> >>> if (ret == -EMULTIHOP) >>> ret = ttm_bo_bounce_temp_buffer(bo, &evict_mem, >>> ctx, &hop); >>> >>> /* try again */ >>> if (!ret) >>> continue; >>> >>> ttm_resource_free(bo, &evict_mem); >>> if (ret != -ERESTARTSYS && ret != -EINTR) >>> pr_err("Buffer eviction failed\n"); >>> >>> break; >>> } >>> >>> Andi >>> >>>> + } >>>> + if (ret) { >>>> + ttm_resource_free(bo, &evict_mem); >>>> + if (ret != -ERESTARTSYS && ret != -EINTR) >>>> + pr_err("Buffer eviction failed\n"); >>>> } >>>> out: >>>> return ret; >>>> -- >>>> 2.40.1 >
Hi Christian and Thomas, > > > > > diff --git a/drivers/gpu/drm/ttm/ttm_bo.c > > > > > b/drivers/gpu/drm/ttm/ttm_bo.c > > > > > index 615d30c4262d..89530f2a027f 100644 > > > > > --- a/drivers/gpu/drm/ttm/ttm_bo.c > > > > > +++ b/drivers/gpu/drm/ttm/ttm_bo.c > > > > > @@ -462,14 +462,14 @@ static int ttm_bo_evict(struct > > > > > ttm_buffer_object *bo, > > > > > ret = ttm_bo_handle_move_mem(bo, evict_mem, true, ctx, &hop); > > > > > if (ret == -EMULTIHOP) { > > > > > ret = ttm_bo_bounce_temp_buffer(bo, &evict_mem, ctx, &hop); > > > > > - if (ret) { > > > > > - if (ret != -ERESTARTSYS && ret != -EINTR) > > > > > - pr_err("Buffer eviction failed\n"); > > > > > - ttm_resource_free(bo, &evict_mem); > > > > > - goto out; > > > > > - } > > > > > - /* try and move to final place now. */ > > > > > - goto bounce; > > > > > + if (!ret) > > > > > + /* try and move to final place now. */ > > > > > + goto bounce; > > > > As we are at this, can't we replace this with a while()? Goto's > > > > used instead of a while loop are a fist in the eye... > > > > > > I'm completely OK with that. this patch already did away with one of > > > them. Let's hear Christian's opinion first, though. > > > > I'm not a fan of that goto either, but could we somehow avoid the > > while(1) ? E.g. something like do { } while (!ret) after handling the > > multihop? > > I think the construct that makes it most obvious what's happening, although > it needs two tests for -EMULTIHOP is something like > > do { > .... > if (ret != -EMULTIHOP) > break; > .... > } while (ret ==-EMULTIHOP); even better :) Thank you! Andi
diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c index 615d30c4262d..89530f2a027f 100644 --- a/drivers/gpu/drm/ttm/ttm_bo.c +++ b/drivers/gpu/drm/ttm/ttm_bo.c @@ -462,14 +462,14 @@ static int ttm_bo_evict(struct ttm_buffer_object *bo, ret = ttm_bo_handle_move_mem(bo, evict_mem, true, ctx, &hop); if (ret == -EMULTIHOP) { ret = ttm_bo_bounce_temp_buffer(bo, &evict_mem, ctx, &hop); - if (ret) { - if (ret != -ERESTARTSYS && ret != -EINTR) - pr_err("Buffer eviction failed\n"); - ttm_resource_free(bo, &evict_mem); - goto out; - } - /* try and move to final place now. */ - goto bounce; + if (!ret) + /* try and move to final place now. */ + goto bounce; + } + if (ret) { + ttm_resource_free(bo, &evict_mem); + if (ret != -ERESTARTSYS && ret != -EINTR) + pr_err("Buffer eviction failed\n"); } out: return ret;