From nobody Mon Feb 9 10:24:16 2026 Received: from mail-pl1-f169.google.com (mail-pl1-f169.google.com [209.85.214.169]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2DD5EBA42 for ; Sun, 26 Jan 2025 09:33:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737883985; cv=none; b=LPFoxkymP5L3uKdM5v0+/kLaMi3WnvjEQc9f01O8fz0qRggXdf3mg3GiMfSbn0vCpElXfUWhCzxYGIPdqRHJyjp/SITpiVy/BRikZ20iVdjFyOeXcwLWJWSWHsN2dC85Po5uyioJ66RQQvovNoPlmVPbNJFtwvS19nQd8TM9OpA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737883985; c=relaxed/simple; bh=8FU14YJJR2ylwvKK/6ZG7RhQ5Guq4/AjVkgIo2wxLIo=; h=Date:From:To:Cc:Subject:Message-ID:MIME-Version:Content-Type: Content-Disposition; b=u0SEUgau322uotPVJlqL1DagaT6pIGidCTMn/L9Mx1gY+VxoQab8tV1xQSoC5q1paaGRfZU5+OYIjXLbezqqkuySkXAK/pL3tK5BsJmXO4vNEgejAYvMkeL+Qpl1s40RyJHVbbtHwxa2BNYARO3TQnz6dQxNjxftfBmKGiUlpP4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=bytedance.com; spf=pass smtp.mailfrom=bytedance.com; dkim=pass (2048-bit key) header.d=bytedance.com header.i=@bytedance.com header.b=FMoOLW2d; arc=none smtp.client-ip=209.85.214.169 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=bytedance.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bytedance.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bytedance.com header.i=@bytedance.com header.b="FMoOLW2d" Received: by mail-pl1-f169.google.com with SMTP id d9443c01a7336-2165448243fso75837745ad.1 for ; Sun, 26 Jan 2025 01:33:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1737883983; x=1738488783; darn=vger.kernel.org; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :from:to:cc:subject:date:message-id:reply-to; bh=Vb1mFO06Fp5J7u5+sDtga+BgWpigWXQ6nR/UywDM244=; b=FMoOLW2dCS+12R2lC/4sHDVWHwpEgMmZwwj5m6URmYhhU7ULKeIsEblc8B8YuwR+LZ qpuwjtAXPKWnJNbSQ3aCEah1ikXuEbbFUQKA4C8u9596rYCkjqcA7lvsWlyLD64qDIvW eoxTsTmOmi+0Awap6G+7D7asVwQ4VEGZwVAdsF3te1EqHxGcKDHSixX/AoHsbkY/vTYl Vr99PzBfnCFh0vpDWmPYkcUfHCJGnhnofNFAuDoVrqLqGOlwxgH5H4GL/vwWZmMl7Jj8 mbtbNrqCcniemDBFiVhHyMfAtJt6GFwSLigYUn86BgA4/2mz2z8cbTWK9yhEhRKsQkqw iEdg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737883983; x=1738488783; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Vb1mFO06Fp5J7u5+sDtga+BgWpigWXQ6nR/UywDM244=; b=sVE4b7b2X5bsmZBvJkKxT8bvdjqtfK9oTG4jLdzq8v+p7MwNZIjzSPr5QeZ2lScaxi zFsXMnXh5fpMMhO9qQWhlQw6e9iL1i6afKw/zIeF3TrPXDOHaYUe6EJD9w+LHVsbQgre kKhc3LXuZXYk6cZVR1y1GOeNS1Nm/p/RzEvKPkvQQ5xP0vRLciAmu45Dk+syeVbkYB/k TgjfNB/uPU6Pw+dXaSCKZooGKUPOTrCbk13PMfcKTN0vBuOENrx4Z3ZeCDRqRUddioQB s8w4D1MnjHv9SR424UeqPq2bAGoZnkrTZipbn9fEUcQV+aodbnrkJfleVkmsC9lyvzNI InDw== X-Forwarded-Encrypted: i=1; AJvYcCVWDrR5Ql11IT9jMfpapYzZugW63h2y/LNf0V5IoQTWUfvNVdc3CTE0U3MA7s4XYoUdsbe4dXlz2fdTbuw=@vger.kernel.org X-Gm-Message-State: AOJu0Yzc8moFPQizOTWNqFIvPh4wwicXgRUVLPzn6QEhnFCa8gTzkr+/ ciIluFk6YPNPbhgtpyepOhQU6La+a5yqzxSoSoxO+kx6qfdc2Qowa30bi00gVos= X-Gm-Gg: ASbGncuHgxFhrxZmXVW9mHDeZyjgawXHbpPK1xHvI9BpLV+sRhZiObtq8+WIMs6D5ua jBIQvPTIr8r6jiQRSSRFszcZngbeVHXAgKIEXEtrIFH1MzHvGgLEv0+WzB0njTW4l527sejhnbL Zdp9raoE/KbSxwf+aIGwr6RK6K2DKMxG7/TgRIejxTbBpMs3wQk7KSOMDn9EWdQ1863ypqLOSqb 5fb7oFBfSV8hfEd95lP5rEdcKj2O4ncjI2CGCcTZE9ipQ7LyGfaSHQg00kLLniPJ0cCyMvauDhx SucbjJofBBZTr9Ae X-Google-Smtp-Source: AGHT+IETqSTdsrEKC3E5A6snESLR+5atJTMds0J4jTsDRBV9zfXa9/kpzMOWIdyPy6bUYM9RXTHCFg== X-Received: by 2002:a05:6a00:4fd3:b0:728:e1e3:3d88 with SMTP id d2e1a72fcca58-72daf9bec6amr53444587b3a.7.1737883983310; Sun, 26 Jan 2025 01:33:03 -0800 (PST) Received: from bytedance ([61.213.176.10]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72f8a6b3f86sm5123548b3a.67.2025.01.26.01.32.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Jan 2025 01:33:02 -0800 (PST) Date: Sun, 26 Jan 2025 17:32:56 +0800 From: Zhaoyu Liu To: christian.koenig@amd.com, ray.huang@amd.com, maarten.lankhorst@linux.intel.com, mripard@kernel.org, tzimmermann@suse.de, airlied@gmail.com, simona@ffwll.ch Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: [PATCH] drm/ttm: use ttm_resource_unevictable() to replace pin_count and swapped Message-ID: <20250126093256.GA688734@bytedance> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" TTM always uses pin_count and ttm_resource_is_swapped() together to determine whether a BO is unevictable. Now use ttm_resource_unevictable() to replace them. Signed-off-by: Zhaoyu Liu Reviewed-by: Christian K=C3=B6nig --- drivers/gpu/drm/ttm/ttm_resource.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/ttm/ttm_resource.c b/drivers/gpu/drm/ttm/ttm_r= esource.c index cc29bbf3eabb..a8f9f7ed6c6e 100644 --- a/drivers/gpu/drm/ttm/ttm_resource.c +++ b/drivers/gpu/drm/ttm/ttm_resource.c @@ -252,11 +252,16 @@ static bool ttm_resource_is_swapped(struct ttm_resour= ce *res, struct ttm_buffer_ return ttm_tt_is_swapped(bo->ttm); } =20 +static bool ttm_resource_unevictable(struct ttm_resource *res, struct ttm_= buffer_object *bo) +{ + return bo->pin_count || ttm_resource_is_swapped(res, bo); +} + /* Add the resource to a bulk move if the BO is configured for it */ void ttm_resource_add_bulk_move(struct ttm_resource *res, struct ttm_buffer_object *bo) { - if (bo->bulk_move && !bo->pin_count && !ttm_resource_is_swapped(res, bo)) + if (bo->bulk_move && !ttm_resource_unevictable(res, bo)) ttm_lru_bulk_move_add(bo->bulk_move, res); } =20 @@ -264,7 +269,7 @@ void ttm_resource_add_bulk_move(struct ttm_resource *re= s, void ttm_resource_del_bulk_move(struct ttm_resource *res, struct ttm_buffer_object *bo) { - if (bo->bulk_move && !bo->pin_count && !ttm_resource_is_swapped(res, bo)) + if (bo->bulk_move && !ttm_resource_unevictable(res, bo)) ttm_lru_bulk_move_del(bo->bulk_move, res); } =20 @@ -276,10 +281,10 @@ void ttm_resource_move_to_lru_tail(struct ttm_resourc= e *res) =20 lockdep_assert_held(&bo->bdev->lru_lock); =20 - if (bo->pin_count || ttm_resource_is_swapped(res, bo)) { + if (ttm_resource_unevictable(res, bo)) { list_move_tail(&res->lru.link, &bdev->unevictable); =20 - } else if (bo->bulk_move) { + } else if (bo->bulk_move) { struct ttm_lru_bulk_move_pos *pos =3D ttm_lru_bulk_move_pos(bo->bulk_move, res); =20 @@ -318,7 +323,7 @@ void ttm_resource_init(struct ttm_buffer_object *bo, =20 man =3D ttm_manager_type(bo->bdev, place->mem_type); spin_lock(&bo->bdev->lru_lock); - if (bo->pin_count || ttm_resource_is_swapped(res, bo)) + if (ttm_resource_unevictable(res, bo)) list_add_tail(&res->lru.link, &bo->bdev->unevictable); else list_add_tail(&res->lru.link, &man->lru[bo->priority]); --=20 2.25.1