All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3] drm/ttm: fix error handling if no BO can be swapped out
@ 2021-04-22 10:25 Shiwu Zhang
  2021-04-22 11:10 ` Christian König
  0 siblings, 1 reply; 3+ messages in thread
From: Shiwu Zhang @ 2021-04-22 10:25 UTC (permalink / raw)
  To: dri-devel; +Cc: christian.koenig

In case that all pre-allocated BOs are busy, just continue to populate
BOs since likely half of system memory in total is still free.

Signed-off-by: Shiwu Zhang <shiwu.zhang@amd.com>
---
 drivers/gpu/drm/ttm/ttm_device.c | 2 +-
 drivers/gpu/drm/ttm/ttm_tt.c     | 2 ++
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/ttm/ttm_device.c b/drivers/gpu/drm/ttm/ttm_device.c
index 1f2024164d72..a48fe4dccd61 100644
--- a/drivers/gpu/drm/ttm/ttm_device.c
+++ b/drivers/gpu/drm/ttm/ttm_device.c
@@ -112,7 +112,7 @@ int ttm_global_swapout(struct ttm_operation_ctx *ctx, gfp_t gfp_flags)
 {
 	struct ttm_global *glob = &ttm_glob;
 	struct ttm_device *bdev;
-	int ret = -EBUSY;
+	int ret;
 
 	mutex_lock(&ttm_global_mutex);
 	list_for_each_entry(bdev, &glob->device_list, device_list) {
diff --git a/drivers/gpu/drm/ttm/ttm_tt.c b/drivers/gpu/drm/ttm/ttm_tt.c
index 48c407cff112..539e0232cb3b 100644
--- a/drivers/gpu/drm/ttm/ttm_tt.c
+++ b/drivers/gpu/drm/ttm/ttm_tt.c
@@ -329,6 +329,8 @@ int ttm_tt_populate(struct ttm_device *bdev,
 	       ttm_dma32_pages_limit) {
 
 		ret = ttm_global_swapout(ctx, GFP_KERNEL);
+		if (ret == 0)
+			break;
 		if (ret < 0)
 			goto error;
 	}
-- 
2.17.1

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 3+ messages in thread
* Re: [PATCH v3] drm/ttm: fix error handling if no BO can be swapped out
@ 2021-04-22 21:34 kernel test robot
  0 siblings, 0 replies; 3+ messages in thread
From: kernel test robot @ 2021-04-22 21:34 UTC (permalink / raw)
  To: kbuild

[-- Attachment #1: Type: text/plain, Size: 3491 bytes --]

CC: kbuild-all(a)lists.01.org
In-Reply-To: <20210422102521.22580-1-shiwu.zhang@amd.com>
References: <20210422102521.22580-1-shiwu.zhang@amd.com>
TO: Shiwu Zhang <shiwu.zhang@amd.com>
TO: dri-devel(a)lists.freedesktop.org
CC: christian.koenig(a)amd.com

Hi Shiwu,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on drm-tip/drm-tip]
[also build test WARNING on next-20210422]
[cannot apply to drm-intel/for-linux-next drm-exynos/exynos-drm-next tegra-drm/drm/tegra/for-next linus/master drm/drm-next v5.12-rc8]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Shiwu-Zhang/drm-ttm-fix-error-handling-if-no-BO-can-be-swapped-out/20210422-182800
base:   git://anongit.freedesktop.org/drm/drm-tip drm-tip
:::::: branch date: 11 hours ago
:::::: commit date: 11 hours ago
config: x86_64-randconfig-m001-20210421 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-22) 9.3.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>

New smatch warnings:
drivers/gpu/drm/ttm/ttm_device.c:126 ttm_global_swapout() error: uninitialized symbol 'ret'.

Old smatch warnings:
drivers/gpu/drm/ttm/ttm_device.c:164 ttm_device_swapout() warn: inconsistent returns '&bdev->lru_lock'.

vim +/ret +126 drivers/gpu/drm/ttm/ttm_device.c

8af8a109b34fa8 Christian König 2020-10-01  106  
ebd59851c796c2 Christian König 2020-10-06  107  /**
ebd59851c796c2 Christian König 2020-10-06  108   * A buffer object shrink method that tries to swap out the first
ebd59851c796c2 Christian König 2020-10-06  109   * buffer object on the global::swap_lru list.
ebd59851c796c2 Christian König 2020-10-06  110   */
ebd59851c796c2 Christian König 2020-10-06  111  int ttm_global_swapout(struct ttm_operation_ctx *ctx, gfp_t gfp_flags)
ebd59851c796c2 Christian König 2020-10-06  112  {
ebd59851c796c2 Christian König 2020-10-06  113  	struct ttm_global *glob = &ttm_glob;
f9e2a03e110ad0 Christian König 2020-10-06  114  	struct ttm_device *bdev;
5ac121e880c745 Shiwu Zhang     2021-04-22  115  	int ret;
f9e2a03e110ad0 Christian König 2020-10-06  116  
f9e2a03e110ad0 Christian König 2020-10-06  117  	mutex_lock(&ttm_global_mutex);
f9e2a03e110ad0 Christian König 2020-10-06  118  	list_for_each_entry(bdev, &glob->device_list, device_list) {
f9e2a03e110ad0 Christian König 2020-10-06  119  		ret = ttm_device_swapout(bdev, ctx, gfp_flags);
f9e2a03e110ad0 Christian König 2020-10-06  120  		if (ret > 0) {
f9e2a03e110ad0 Christian König 2020-10-06  121  			list_move_tail(&bdev->device_list, &glob->device_list);
f9e2a03e110ad0 Christian König 2020-10-06  122  			break;
f9e2a03e110ad0 Christian König 2020-10-06  123  		}
f9e2a03e110ad0 Christian König 2020-10-06  124  	}
f9e2a03e110ad0 Christian König 2020-10-06  125  	mutex_unlock(&ttm_global_mutex);
f9e2a03e110ad0 Christian König 2020-10-06 @126  	return ret;
f9e2a03e110ad0 Christian König 2020-10-06  127  }
f9e2a03e110ad0 Christian König 2020-10-06  128  EXPORT_SYMBOL(ttm_global_swapout);
f9e2a03e110ad0 Christian König 2020-10-06  129  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 33143 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-04-22 21:34 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-22 10:25 [PATCH v3] drm/ttm: fix error handling if no BO can be swapped out Shiwu Zhang
2021-04-22 11:10 ` Christian König
2021-04-22 21:34 kernel test robot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.