From patchwork Sun Jul 10 20:01:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 12912640 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7202AC433EF for ; Sun, 10 Jul 2022 20:01:56 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id DB9CE18B27F; Sun, 10 Jul 2022 20:01:55 +0000 (UTC) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by gabe.freedesktop.org (Postfix) with ESMTPS id BD32818B27F for ; Sun, 10 Jul 2022 20:01:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1657483313; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type; bh=3wkh8sBPpAJoWNAudjBg1h1XOpekcxqk1T+FC7QtDxc=; b=U2iA1Cx7vUO4rUgvbbak4wBzSuQ1KZzhVLK3099DeWXc0wCJEgMkslmSNERtW5M8n05bko 9bFQ+gMGZF7ogzn0Fl0CZZQTpTtrw/8Yp4/gq6uLx/RY6s4YJQIyReLZL4q/EnXfAeEA/7 PWrnuUuOTttyF7PuNMDtgSF8dDlDx4U= Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-612-I2HvKvT8Nae49TmWpKC-Lg-1; Sun, 10 Jul 2022 16:01:51 -0400 X-MC-Unique: I2HvKvT8Nae49TmWpKC-Lg-1 Received: by mail-ed1-f72.google.com with SMTP id o13-20020a056402438d00b0043aa846b2d2so2900017edc.8 for ; Sun, 10 Jul 2022 13:01:51 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent :content-language:to:from:subject; bh=zra+mQ4ykEcn6OM8oY5gZo2+Ft+xLPxuaIVVQKaYf7I=; b=4VMkF1ymQSsZOCNJW0Og2Qvv4yDh3HhrIPdaFcg9X8cUBuhjiQpNlrv6ES5NZSbCuc K+8zN+/r7JN3X47ZfQcc7MFp2GpchEZpLXAuK/JvvHj4HkRcDOATUMBjMdIjZL1bPtW3 lp9MjrdX5aDqK1VfFlA7CiVhjLoxyi+Y09jw3LrvwggMa2Mb3/rAuDIYBzwh4sRmKTaC v/vb8ZcyDiwNpDLbN7U/SCAS3qFdufyRA7iYBPCWyK+AkRmwyPOo5FZqNRiuYWe76c6y /igUfYHdK9fj55DFzbwvnti4lPpwsi1qcx4G6a8umUDF7nLS99QgItlVhdd/qAIB01z/ s2yA== X-Gm-Message-State: AJIora+oYh2xitZQ04ldWlI1AZ/npP1kdgMcJDOGhtJMnsXRf3/E3Jdw EfWX57ENMlZ5wO9F4i2aSu1k/I2z14EH0sV89BRcfEYkb+phTf23AS57BqqZ8TCk2O3CKXbXdhO qCrJ1c5g1ghveaYXm/IcBKmabXwCWdwurWRLkLJlUDFWUrhvlDwd9lfJavpB63bTq2JNArQo+5a 5wpziy X-Received: by 2002:a05:6402:d05:b0:425:b7ab:776e with SMTP id eb5-20020a0564020d0500b00425b7ab776emr20999121edb.142.1657483310616; Sun, 10 Jul 2022 13:01:50 -0700 (PDT) X-Google-Smtp-Source: AGRyM1u1PEh3xBSaTMmMgDhFmXzr5817qpvCTmND0TEesTJ/A9k4PwCUd7mQGSdrANcsuP0Sfirmvg== X-Received: by 2002:a05:6402:d05:b0:425:b7ab:776e with SMTP id eb5-20020a0564020d0500b00425b7ab776emr20999093edb.142.1657483310329; Sun, 10 Jul 2022 13:01:50 -0700 (PDT) Received: from ?IPV6:2001:1c00:c1e:bf00:d69d:5353:dba5:ee81? (2001-1c00-0c1e-bf00-d69d-5353-dba5-ee81.cable.dynamic.v6.ziggo.nl. [2001:1c00:c1e:bf00:d69d:5353:dba5:ee81]) by smtp.gmail.com with ESMTPSA id dm3-20020a05640222c300b0043acddee068sm1432578edb.83.2022.07.10.13.01.49 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 10 Jul 2022 13:01:49 -0700 (PDT) Message-ID: <0f6dcf69-9709-047c-9a06-bb3b3c507fad@redhat.com> Date: Sun, 10 Jul 2022 22:01:48 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.8.0 To: "dri-devel@lists.freedesktop.org" From: Hans de Goede Subject: drm-tip amdgpu not compiling, possible fix attached Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=hdegoede@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 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" Hi All, I've been rebasing my backlight refactor on top of drm-tip to submit a new version upstream and I noticed that drm-tip does not compile. This is caused by a mismerge of: commit 925b6e59138cefa47275c67891c65d48d3266d57 (drm-misc/for-linux-next-fixes, drm-misc/drm-misc-fixes, drm-misc-fixes)Selvam Date: Fri Jul 8 02:30:47 2022 -0700 Revert "drm/amdgpu: add drm buddy support to amdgpu" This reverts commit c9cad937c0c58618fe5b0310fd539a854dc1ae95. This is part of a revert of the following commits: commit 708d19d9f362 ("drm/amdgpu: move internal vram_mgr function into the C file") commit 5e3f1e7729ec ("drm/amdgpu: fix start calculation in amdgpu_vram_mgr_new") commit c9cad937c0c5 ("drm/amdgpu: add drm buddy support to amdgpu") [WHY] Few users reported garbaged graphics as soon as x starts, reverting until this can be resolved. Signed-off-by: Arunpravin Paneer Selvam From drm-misc/for-linux-next-fixes / drm-misc-fixes The attached patch on top of drm-tip fixes the mismerge. Note compile-tested only! If someone with more rerere experience then me can use this to fix things that would be great. Regards, Hans From 49aacb8d7b29c8d448ce469e66ddb33f8a19e552 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Sun, 10 Jul 2022 21:27:41 +0200 Subject: [PATCH] fix amdpgu mismerge --- drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c | 84 +------------------- drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.h | 62 --------------- 2 files changed, 2 insertions(+), 144 deletions(-) delete mode 100644 drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.h diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c index 254954aa983c..0a7611648573 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c @@ -48,35 +48,6 @@ to_amdgpu_device(struct amdgpu_vram_mgr *mgr) return container_of(mgr, struct amdgpu_device, mman.vram_mgr); } -static inline struct drm_buddy_block * -amdgpu_vram_mgr_first_block(struct list_head *list) -{ - return list_first_entry_or_null(list, struct drm_buddy_block, link); -} - -static inline bool amdgpu_is_vram_mgr_blocks_contiguous(struct list_head *head) -{ - struct drm_buddy_block *block; - u64 start, size; - - block = amdgpu_vram_mgr_first_block(head); - if (!block) - return false; - - while (head != block->link.next) { - start = amdgpu_vram_mgr_block_start(block); - size = amdgpu_vram_mgr_block_size(block); - - block = list_entry(block->link.next, struct drm_buddy_block, link); - if (start + size != amdgpu_vram_mgr_block_start(block)) - return false; - } - - return true; -} - - - /** * DOC: mem_info_vram_total * @@ -485,59 +456,8 @@ static int amdgpu_vram_mgr_new(struct ttm_resource_manager *man, } spin_unlock(&mgr->lock); - if (cur_size != size) { - struct drm_buddy_block *block; - struct list_head *trim_list; - u64 original_size; - LIST_HEAD(temp); - - trim_list = &vres->blocks; - original_size = vres->base.num_pages << PAGE_SHIFT; - - /* - * If size value is rounded up to min_block_size, trim the last - * block to the required size - */ - if (!list_is_singular(&vres->blocks)) { - block = list_last_entry(&vres->blocks, typeof(*block), link); - list_move_tail(&block->link, &temp); - trim_list = &temp; - /* - * Compute the original_size value by subtracting the - * last block size with (aligned size - original size) - */ - original_size = amdgpu_vram_mgr_block_size(block) - (size - cur_size); - } - - mutex_lock(&mgr->lock); - drm_buddy_block_trim(mm, - original_size, - trim_list); - mutex_unlock(&mgr->lock); - - if (!list_empty(&temp)) - list_splice_tail(trim_list, &vres->blocks); - } - - vres->base.start = 0; - list_for_each_entry(block, &vres->blocks, link) { - unsigned long start; - - start = amdgpu_vram_mgr_block_start(block) + - amdgpu_vram_mgr_block_size(block); - start >>= PAGE_SHIFT; - - if (start > vres->base.num_pages) - start -= vres->base.num_pages; - else - start = 0; - vres->base.start = max(vres->base.start, start); - - vis_usage += amdgpu_vram_mgr_vis_size(adev, block); - } - - if (amdgpu_is_vram_mgr_blocks_contiguous(&vres->blocks)) - vres->base.placement |= TTM_PL_FLAG_CONTIGUOUS; + if (i == 1) + node->base.placement |= TTM_PL_FLAG_CONTIGUOUS; if (adev->gmc.xgmi.connected_to_cpu) node->base.bus.caching = ttm_cached; diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.h deleted file mode 100644 index 4b267bf1c5db..000000000000 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.h +++ /dev/null @@ -1,62 +0,0 @@ -/* SPDX-License-Identifier: MIT - * Copyright 2021 Advanced Micro Devices, Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR - * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, - * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR - * OTHER DEALINGS IN THE SOFTWARE. - * - */ - -#ifndef __AMDGPU_VRAM_MGR_H__ -#define __AMDGPU_VRAM_MGR_H__ - -#include - -struct amdgpu_vram_mgr { - struct ttm_resource_manager manager; - struct drm_buddy mm; - /* protects access to buffer objects */ - struct mutex lock; - struct list_head reservations_pending; - struct list_head reserved_pages; - atomic64_t vis_usage; - u64 default_page_size; -}; - -struct amdgpu_vram_mgr_resource { - struct ttm_resource base; - struct list_head blocks; - unsigned long flags; -}; - -static inline u64 amdgpu_vram_mgr_block_start(struct drm_buddy_block *block) -{ - return drm_buddy_block_offset(block); -} - -static inline u64 amdgpu_vram_mgr_block_size(struct drm_buddy_block *block) -{ - return PAGE_SIZE << drm_buddy_block_order(block); -} - -static inline struct amdgpu_vram_mgr_resource * -to_amdgpu_vram_mgr_resource(struct ttm_resource *res) -{ - return container_of(res, struct amdgpu_vram_mgr_resource, base); -} - -#endif -- 2.36.0