From patchwork Wed Dec 20 10:34:55 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "He, Hongbo" X-Patchwork-Id: 10125413 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id CA4296019C for ; Wed, 20 Dec 2017 10:35:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B4D972922F for ; Wed, 20 Dec 2017 10:35:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A97F3296CA; Wed, 20 Dec 2017 10:35:16 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 997172922F for ; Wed, 20 Dec 2017 10:35:15 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id AD45A6E3BB; Wed, 20 Dec 2017 10:35:14 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from NAM03-DM3-obe.outbound.protection.outlook.com (mail-dm3nam03on0076.outbound.protection.outlook.com [104.47.41.76]) by gabe.freedesktop.org (Postfix) with ESMTPS id 976686E3BB; Wed, 20 Dec 2017 10:35:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector1-amd-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=LRzBTLffeqzwXyDIcLgApnOP6avPMr1RdQ5Jg4I4+94=; b=qwq9M6WG8/YM5dXwSCXc+PJNNkfKoiWtdtUyOiQMXrt7zS0hk8SlqIFZiJLCDeMTicdSt/DQdS2+2n8EwQq1Rjk6KBSs7Ea4Kbd1JgLJPWcholGg/irbPWVrlb9N5/DJLLX7SZG7aSEkyMZAhHYL/ia/L5tQWbWbSo0eI4ZQIhY= Received: from MWHPR1201CA0015.namprd12.prod.outlook.com (10.174.253.25) by MWHPR12MB1454.namprd12.prod.outlook.com (10.172.55.135) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.323.15; Wed, 20 Dec 2017 10:35:08 +0000 Received: from CO1NAM03FT045.eop-NAM03.prod.protection.outlook.com (2a01:111:f400:7e48::200) by MWHPR1201CA0015.outlook.office365.com (2603:10b6:301:4a::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.345.14 via Frontend Transport; Wed, 20 Dec 2017 10:35:07 +0000 Authentication-Results: spf=none (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; lists.freedesktop.org; dkim=none (message not signed) header.d=none;lists.freedesktop.org; dmarc=permerror action=none header.from=amd.com; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) Received: from SATLEXCHOV01.amd.com (165.204.84.17) by CO1NAM03FT045.mail.protection.outlook.com (10.152.81.214) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.20.302.6 via Frontend Transport; Wed, 20 Dec 2017 10:35:07 +0000 Received: from roger-build-server.amd.com (10.34.1.3) by SATLEXCHOV01.amd.com (10.181.40.71) with Microsoft SMTP Server id 14.3.361.1; Wed, 20 Dec 2017 04:35:05 -0600 From: Roger He To: , Subject: [PATCH 1/7] drm/ttm: call ttm_bo_swapout directly when ttm shrink Date: Wed, 20 Dec 2017 18:34:55 +0800 Message-ID: <1513766101-15993-1-git-send-email-Hongbo.He@amd.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:165.204.84.17; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(39860400002)(376002)(39380400002)(346002)(396003)(2980300002)(428003)(189003)(199004)(4326008)(77096006)(478600001)(316002)(575784001)(5660300001)(8936002)(72206003)(53416004)(97736004)(104016004)(106466001)(51416003)(53936002)(86362001)(59450400001)(47776003)(68736007)(8676002)(7696005)(110136005)(50466002)(48376002)(16586007)(50226002)(6666003)(81156014)(105586002)(356003)(81166006)(2906002)(450100002)(36756003)(305945005); DIR:OUT; SFP:1101; SCL:1; SRVR:MWHPR12MB1454; H:SATLEXCHOV01.amd.com; FPR:; SPF:None; PTR:InfoDomainNonexistent; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; CO1NAM03FT045; 1:KgHvfcrOFcoFLPdler2w4FF7vCORUn2FgZdaA+n+ZEbN9Gder7JYK6O+gTDW+5gfnL5BLqQxWhL6hXAyaMXDoeGS0k2U7RZUrrqLth1c+cgzNBC7jUg/e+TLwV7ySFAe X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 15e6eacd-81e3-4ffc-d647-08d5479556dd X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(5600026)(4604075)(4534020)(4602075)(4627115)(201703031133081)(201702281549075)(2017052603307)(7153060); SRVR:MWHPR12MB1454; X-Microsoft-Exchange-Diagnostics: 1; MWHPR12MB1454; 3:YpfCAHZ99Ot9n7e7nDjCUGwpd+HY6YOkrNFfvr22fBvpwuCD+eOtmCwB79Z5DmuZErySZmvcmTGAAkM5Ya+YE5IhFYDl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Cwr6Oa8UL7Bb8GY7QpdFNow8COfGZ6oDAmsNO2+Wm0Jt+r16lLXZCxzzThedppQKc2L18IIVZfBTGYTg6YkFySNNy+TxxJgw2SeiKPsSSv39r2N2W+yvZkdtEG4bRdQIlNOKoSkIDbJUfSBfc3CMWfw2uKooLTri19cMLIx7l7iP847l2lcsYkw7UbVTuIa0083kGC3oRz0xiMc9yELGu/QyugvckkDqbfyWOy+sZKrEkexLXnTUUyL18qu4BH4ccOBiHV4ouErm36TM6IbSUNveCO45SIGQHSFYQVcu88ZqLnHZHLESHBdaPABtcc0xysvcVmJRgpfELjPaR++DRRMhIYNCia X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(767451399110); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040470)(2401047)(5005006)(8121501046)(3002001)(10201501046)(3231023)(93006095)(93003095)(6055026)(6041268)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123562045)(20161123564045)(20161123560045)(6072148)(201708071742011); SRVR:MWHPR12MB1454; BCL:0; PCL:0; RULEID:(100000803101)(100110400095); SRVR:MWHPR12MB1454; X-Microsoft-Exchange-Diagnostics: 1; MWHPR12MB1454; 4:UP6B/9NmTnx3v6a7646+ScWATy5j4/lzhWPRzmlsQ3d0Lr9niqbJVn6XLaJgXhtwEkkTAax7q4UAu1TwFXtIRXcrIaGMHoAXKsY4YLgjItki+uRafwXbH77yuBFZyNmWqqiTVwv/ekD/uRqNqDKz/4QEDtUTSrjW76ee3cSRaKyuY+BwWALd0e9dcIxSr7I6LKiEb4muMhBNQj3RVTIu426vj//f2Ez0i5drafZ16l86PYhIi//DMG6WPNohI7MP7Jn46/kfzYN6qaTWGWnUbFD/8r/t27i/N7zl1YvY7n+x3NiwWgYo3EiA1ql2h/sj X-Forefront-PRVS: 0527DFA348 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; MWHPR12MB1454; 23:/rSYUIrIhg1oKtf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6XI6Hm6Z1jG6AXzxarkK/NB1opj0UlWAMiDZ8RuTKr3FRqDARjwYFxx SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; MWHPR12MB1454; 20:4YYkT597pE1jUBHCPvU1pO2TXfWN5DC0O6F8mFCgJPu7TxaELzo9XmEp5QIZcorEiHB6jrIFWo0Tu84AKRZIPOEWtAMYOBKiMdzgICxLArEHTvUR+wlPwaJWLKO+qJfIMQqdaiT4VLemmU/WPIWvip4zf35tHfTvAv/G/unq9b/LtLCLu9Y5Bg6FnadSqytJi8FKB98XIkoc6z1ShLr27s29PnvRIsgFLSnQdwi38tuSfUje3tpTlydsbcooBkgN X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Dec 2017 10:35:07.3683 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 15e6eacd-81e3-4ffc-d647-08d5479556dd X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXCHOV01.amd.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR12MB1454 Cc: Roger He 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-Virus-Scanned: ClamAV using ClamSMTP then remove superfluous functions Change-Id: Iea020f0e30a239e0265e7a1500168c7d7f819bd9 Signed-off-by: Roger He --- drivers/gpu/drm/ttm/ttm_bo.c | 21 +++--------- drivers/gpu/drm/ttm/ttm_memory.c | 12 ++----- include/drm/ttm/ttm_bo_api.h | 1 + include/drm/ttm/ttm_bo_driver.h | 1 - include/drm/ttm/ttm_memory.h | 69 +--------------------------------------- 5 files changed, 9 insertions(+), 95 deletions(-) diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c index 60bb5c1..fa57aa8 100644 --- a/drivers/gpu/drm/ttm/ttm_bo.c +++ b/drivers/gpu/drm/ttm/ttm_bo.c @@ -42,7 +42,6 @@ #include #include -static int ttm_bo_swapout(struct ttm_mem_shrink *shrink); static void ttm_bo_global_kobj_release(struct kobject *kobj); static struct attribute ttm_bo_count = { @@ -1454,7 +1453,6 @@ static void ttm_bo_global_kobj_release(struct kobject *kobj) struct ttm_bo_global *glob = container_of(kobj, struct ttm_bo_global, kobj); - ttm_mem_unregister_shrink(glob->mem_glob, &glob->shrink); __free_page(glob->dummy_read_page); kfree(glob); } @@ -1479,6 +1477,7 @@ int ttm_bo_global_init(struct drm_global_reference *ref) mutex_init(&glob->device_list_mutex); spin_lock_init(&glob->lru_lock); glob->mem_glob = bo_ref->mem_glob; + glob->mem_glob->bo_glob = glob; glob->dummy_read_page = alloc_page(__GFP_ZERO | GFP_DMA32); if (unlikely(glob->dummy_read_page == NULL)) { @@ -1489,14 +1488,6 @@ int ttm_bo_global_init(struct drm_global_reference *ref) for (i = 0; i < TTM_MAX_BO_PRIORITY; ++i) INIT_LIST_HEAD(&glob->swap_lru[i]); INIT_LIST_HEAD(&glob->device_list); - - ttm_mem_init_shrink(&glob->shrink, ttm_bo_swapout); - ret = ttm_mem_register_shrink(glob->mem_glob, &glob->shrink); - if (unlikely(ret != 0)) { - pr_err("Could not register buffer object swapout\n"); - goto out_no_shrink; - } - atomic_set(&glob->bo_count, 0); ret = kobject_init_and_add( @@ -1504,8 +1495,6 @@ int ttm_bo_global_init(struct drm_global_reference *ref) if (unlikely(ret != 0)) kobject_put(&glob->kobj); return ret; -out_no_shrink: - __free_page(glob->dummy_read_page); out_no_drp: kfree(glob); return ret; @@ -1688,11 +1677,8 @@ EXPORT_SYMBOL(ttm_bo_synccpu_write_release); * A buffer object shrink method that tries to swap out the first * buffer object on the bo_global::swap_lru list. */ - -static int ttm_bo_swapout(struct ttm_mem_shrink *shrink) +int ttm_bo_swapout(struct ttm_bo_global *glob) { - struct ttm_bo_global *glob = - container_of(shrink, struct ttm_bo_global, shrink); struct ttm_buffer_object *bo; int ret = -EBUSY; unsigned i; @@ -1774,10 +1760,11 @@ static int ttm_bo_swapout(struct ttm_mem_shrink *shrink) kref_put(&bo->list_kref, ttm_bo_release_list); return ret; } +EXPORT_SYMBOL(ttm_bo_swapout); void ttm_bo_swapout_all(struct ttm_bo_device *bdev) { - while (ttm_bo_swapout(&bdev->glob->shrink) == 0) + while (ttm_bo_swapout(bdev->glob) == 0) ; } EXPORT_SYMBOL(ttm_bo_swapout_all); diff --git a/drivers/gpu/drm/ttm/ttm_memory.c b/drivers/gpu/drm/ttm/ttm_memory.c index e963749..9130bdf 100644 --- a/drivers/gpu/drm/ttm/ttm_memory.c +++ b/drivers/gpu/drm/ttm/ttm_memory.c @@ -214,26 +214,20 @@ static void ttm_shrink(struct ttm_mem_global *glob, bool from_wq, uint64_t extra) { int ret; - struct ttm_mem_shrink *shrink; spin_lock(&glob->lock); - if (glob->shrink == NULL) - goto out; while (ttm_zones_above_swap_target(glob, from_wq, extra)) { - shrink = glob->shrink; spin_unlock(&glob->lock); - ret = shrink->do_shrink(shrink); + ret = ttm_bo_swapout(glob->bo_glob); spin_lock(&glob->lock); if (unlikely(ret != 0)) - goto out; + break; } -out: + spin_unlock(&glob->lock); } - - static void ttm_shrink_work(struct work_struct *work) { struct ttm_mem_global *glob = diff --git a/include/drm/ttm/ttm_bo_api.h b/include/drm/ttm/ttm_bo_api.h index c126330..24a8db7 100644 --- a/include/drm/ttm/ttm_bo_api.h +++ b/include/drm/ttm/ttm_bo_api.h @@ -752,6 +752,7 @@ ssize_t ttm_bo_io(struct ttm_bo_device *bdev, struct file *filp, const char __user *wbuf, char __user *rbuf, size_t count, loff_t *f_pos, bool write); +int ttm_bo_swapout(struct ttm_bo_global *glob); void ttm_bo_swapout_all(struct ttm_bo_device *bdev); int ttm_bo_wait_unreserved(struct ttm_buffer_object *bo); #endif diff --git a/include/drm/ttm/ttm_bo_driver.h b/include/drm/ttm/ttm_bo_driver.h index 5115718..934fecf 100644 --- a/include/drm/ttm/ttm_bo_driver.h +++ b/include/drm/ttm/ttm_bo_driver.h @@ -522,7 +522,6 @@ struct ttm_bo_global { struct kobject kobj; struct ttm_mem_global *mem_glob; struct page *dummy_read_page; - struct ttm_mem_shrink shrink; struct mutex device_list_mutex; spinlock_t lru_lock; diff --git a/include/drm/ttm/ttm_memory.h b/include/drm/ttm/ttm_memory.h index 2c1e359..85f3ad6 100644 --- a/include/drm/ttm/ttm_memory.h +++ b/include/drm/ttm/ttm_memory.h @@ -37,20 +37,6 @@ #include /** - * struct ttm_mem_shrink - callback to shrink TTM memory usage. - * - * @do_shrink: The callback function. - * - * Arguments to the do_shrink functions are intended to be passed using - * inheritance. That is, the argument class derives from struct ttm_mem_shrink, - * and can be accessed using container_of(). - */ - -struct ttm_mem_shrink { - int (*do_shrink) (struct ttm_mem_shrink *); -}; - -/** * struct ttm_mem_global - Global memory accounting structure. * * @shrink: A single callback to shrink TTM memory usage. Extend this @@ -76,7 +62,7 @@ struct ttm_mem_shrink { struct ttm_mem_zone; struct ttm_mem_global { struct kobject kobj; - struct ttm_mem_shrink *shrink; + struct ttm_bo_global *bo_glob; struct workqueue_struct *swap_queue; struct work_struct work; spinlock_t lock; @@ -90,59 +76,6 @@ struct ttm_mem_global { #endif }; -/** - * ttm_mem_init_shrink - initialize a struct ttm_mem_shrink object - * - * @shrink: The object to initialize. - * @func: The callback function. - */ - -static inline void ttm_mem_init_shrink(struct ttm_mem_shrink *shrink, - int (*func) (struct ttm_mem_shrink *)) -{ - shrink->do_shrink = func; -} - -/** - * ttm_mem_register_shrink - register a struct ttm_mem_shrink object. - * - * @glob: The struct ttm_mem_global object to register with. - * @shrink: An initialized struct ttm_mem_shrink object to register. - * - * Returns: - * -EBUSY: There's already a callback registered. (May change). - */ - -static inline int ttm_mem_register_shrink(struct ttm_mem_global *glob, - struct ttm_mem_shrink *shrink) -{ - spin_lock(&glob->lock); - if (glob->shrink != NULL) { - spin_unlock(&glob->lock); - return -EBUSY; - } - glob->shrink = shrink; - spin_unlock(&glob->lock); - return 0; -} - -/** - * ttm_mem_unregister_shrink - unregister a struct ttm_mem_shrink object. - * - * @glob: The struct ttm_mem_global object to unregister from. - * @shrink: A previously registert struct ttm_mem_shrink object. - * - */ - -static inline void ttm_mem_unregister_shrink(struct ttm_mem_global *glob, - struct ttm_mem_shrink *shrink) -{ - spin_lock(&glob->lock); - BUG_ON(glob->shrink != shrink); - glob->shrink = NULL; - spin_unlock(&glob->lock); -} - extern int ttm_mem_global_init(struct ttm_mem_global *glob); extern void ttm_mem_global_release(struct ttm_mem_global *glob); extern int ttm_mem_global_alloc(struct ttm_mem_global *glob, uint64_t memory,