From patchwork Wed Apr 6 09:12:06 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Christian_K=C3=B6nig?= X-Patchwork-Id: 8759651 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id E3FB4C0553 for ; Wed, 6 Apr 2016 09:12:25 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id BC294201E4 for ; Wed, 6 Apr 2016 09:12:24 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id E6037201D3 for ; Wed, 6 Apr 2016 09:12:23 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 1969B6E8B0; Wed, 6 Apr 2016 09:12:22 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from pegasos-out.vodafone.de (pegasos-out.vodafone.de [80.84.1.38]) by gabe.freedesktop.org (Postfix) with ESMTP id E7F336E8B0 for ; Wed, 6 Apr 2016 09:12:20 +0000 (UTC) Received: from localhost (localhost.localdomain [127.0.0.1]) by pegasos-out.vodafone.de (Rohrpostix2 Daemon) with ESMTP id 562115C2B7D for ; Wed, 6 Apr 2016 11:12:20 +0200 (CEST) X-Virus-Scanned: amavisd-new at vodafone.de X-Spam-Score: 0.2 X-Spam-Level: X-Spam-Status: No, score=-5.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, FREEMAIL_FROM,RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD,T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Authentication-Results: rohrpostix2.prod.vfnet.de (amavisd-new); dkim=pass header.i=@vodafone.de Received: from pegasos-out.vodafone.de ([127.0.0.1]) by localhost (rohrpostix2.prod.vfnet.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id GRaU7cspZP70 for ; Wed, 6 Apr 2016 11:12:13 +0200 (CEST) Received: from smtp-04.vodafone.de (xsmail-dmz10.prod.vfnet.de [10.215.254.41]) by pegasos-out.vodafone.de (Rohrpostix2 Daemon) with ESMTP id A59155C2BBC for ; Wed, 6 Apr 2016 11:12:13 +0200 (CEST) X-DKIM: OpenDKIM Filter v2.6.8 pegasos-out.vodafone.de A59155C2BBC DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vodafone.de; s=mail; t=1459933933; bh=IjX3AwHv9oeUeYJvXg/Z+fP4t6b0unoOM867SdmRHJ4=; h=From:To:Subject:Date:In-Reply-To:References; b=hcsYVcPCZO3EYUIeYLlw9fMcgOWv428Py2ozFpZS0bpmUT3h5axK9gN46kDIuHkIK eNnRDlEANt29tpgmiCp54prBiLtrhoc5xnDDcBKH7ZmNNXq1Bb70AJ5191CRtOISFz IyzJIqTB068osEs3flM95yGYhJwa2+attfrECccQ= X-Virus-Scanned: amavisd-new at vodafone.de Received: from smtp-04.vodafone.de ([127.0.0.1]) by localhost (xsmail-dmz10.prod.vfnet.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id sKL1O0OPMMzI for ; Wed, 6 Apr 2016 11:12:12 +0200 (CEST) From: =?UTF-8?q?Christian=20K=C3=B6nig?= To: dri-devel@lists.freedesktop.org Subject: [PATCH 5/7] drm/ttm: add optional LRU removal callback v2 Date: Wed, 6 Apr 2016 11:12:06 +0200 Message-Id: <1459933928-4663-6-git-send-email-deathsimple@vodafone.de> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1459933928-4663-1-git-send-email-deathsimple@vodafone.de> References: <1459933928-4663-1-git-send-email-deathsimple@vodafone.de> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Christian König Useful for driver specific LRU handling. v2: fix typo in comment Signed-off-by: Christian König Reviewed-by: Alex Deucher --- drivers/gpu/drm/ttm/ttm_bo.c | 12 +++++++----- include/drm/ttm/ttm_bo_driver.h | 6 ++++++ 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c index dbb0bb7..84ad992 100644 --- a/drivers/gpu/drm/ttm/ttm_bo.c +++ b/drivers/gpu/drm/ttm/ttm_bo.c @@ -186,8 +186,12 @@ EXPORT_SYMBOL(ttm_bo_add_to_lru); int ttm_bo_del_from_lru(struct ttm_buffer_object *bo) { + struct ttm_bo_device *bdev = bo->bdev; int put_count = 0; + if (bdev->driver->lru_removal) + bdev->driver->lru_removal(bo); + if (!list_empty(&bo->swap)) { list_del_init(&bo->swap); ++put_count; @@ -197,11 +201,6 @@ int ttm_bo_del_from_lru(struct ttm_buffer_object *bo) ++put_count; } - /* - * TODO: Add a driver hook to delete from - * driver-specific LRU's here. - */ - return put_count; } @@ -235,6 +234,9 @@ void ttm_bo_move_to_lru_tail(struct ttm_buffer_object *bo) lockdep_assert_held(&bo->resv->lock.base); + if (bdev->driver->lru_removal) + bdev->driver->lru_removal(bo); + if (bo->mem.placement & TTM_PL_FLAG_NO_EVICT) { list_del_init(&bo->swap); list_del_init(&bo->lru); diff --git a/include/drm/ttm/ttm_bo_driver.h b/include/drm/ttm/ttm_bo_driver.h index 391ef04..23a30b3 100644 --- a/include/drm/ttm/ttm_bo_driver.h +++ b/include/drm/ttm/ttm_bo_driver.h @@ -434,6 +434,12 @@ struct ttm_bo_driver { */ int (*io_mem_reserve)(struct ttm_bo_device *bdev, struct ttm_mem_reg *mem); void (*io_mem_free)(struct ttm_bo_device *bdev, struct ttm_mem_reg *mem); + + /** + * Optional driver callback for when BO is removed from the LRU. + * Called with LRU lock held immediately before the removal. + */ + void (*lru_removal)(struct ttm_buffer_object *bo); }; /**