mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: songqiang <songqiang@uniontech.com>
To: christian.koenig@amd.com, ray.huang@amd.com, airlied@linux.ie,
	daniel@ffwll.ch
Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org,
	songqiang <songqiang@uniontech.com>
Subject: [PATCH] drivers/gpu/drm/ttm/ttm_page_allo.c: adjust ttm pages refcount fix the bug: Feb  6 17:13:13 aaa-PC kernel: [  466.271034] BUG: Bad page state in process blur_image  pfn:7aee2 Feb  6 17:13:13 aaa-PC kernel: [  466.271037] page:980000025fca4170 count:0 mapcount:0 mapping:980000025a0dca60 index:0x0 Feb  6 17:13:13 aaa-PC kernel: [  466.271039] flags: 0x1e01fff000000() Feb  6 17:13:13 aaa-PC kernel: [  466.271042] raw: 0001e01fff000000 0000000000000100 0000000000000200 980000025a0dca60 Feb  6 17:13:13 aaa-PC kernel: [  466.271044] raw: 0000000000000000 0000000000000000 00000000ffffffff Feb  6 17:13:13 aaa-PC kernel: [  466.271046] page dumped because: non-NULL mapping Feb  6 17:13:13 aaa-PC kernel: [  466.271047] Modules linked in: bnep fuse bluetooth ecdh_generic sha256_generic cfg80211 rfkill vfat fat serio_raw uio_pdrv_genirq binfmt_misc ip_tables amdgpu chash radeon r8168 loongson gpu_sched Feb  6 17:13:13 aaa-PC kernel: [  466.271059] CPU: 3 PID: 9554 Comm:  blur_image Tainted: G    B             4.19.0-loongson-3-desktop #3036 Feb  6 17:13:13 aaa-PC kernel: [  466.271061] Hardware name: Haier Kunlun-LS3A4000-LS7A-desktop/Kunlun-LS3A4000-LS7A-desktop, BIOS Kunlun-V4.0.12V4.0 LS3A4000 03/19/2020 Feb  6 17:13:13 aaa-PC kernel: [  466.271063] Stack : 000000000000007b 000000007400cce0 0000000000000000 0000000000000007 Feb  6 17:13:13 aaa-PC kernel: [  466.271067]         0000000000000000 0000000000000000 0000000000002a82 ffffffff8202c910 Feb  6 17:13:13 aaa-PC kernel: [  466.271070]         0000000000000000 0000000000002a82 0000000000000000 ffffffff81e20000 Feb  6 17:13:13 aaa-PC kernel: [  466.271074]         0000000000000000 ffffffff8021301c ffffffff82040000 6e754b20534f4942 Feb  6 17:13:13 aaa-PC kernel: [  466.271078]         ffff000000000000 0000000000000000 000000007400cce0 0000000000000000 Feb  6 17:13:13 aaa-PC kernel: [  466.271082]         9800000007155d40 ffffffff81cc5470 0000000000000005 6db6db6db6db0000 Feb  6 17:13:13  aaa-PC kernel: [  466.271086]         0000000000000003 fffffffffffffffb 0000000000006000 98000002559f4000 Feb  6 17:13:13 aaa-PC kernel: [  466.271090]         980000024a448000 980000024a44b7f0 9800000007155d50 ffffffff819f5158 Feb  6 17:13:13 aaa-PC kernel: [  466.271094]         0000000000000000 0000000000000000 0000000000000000 0000000000000000 Feb  6 17:13:13 aaa-PC kernel: [  466.271097]         9800000007155d40 ffffffff802310c4 ffffffff81e70000 ffffffff819f5158 Feb  6 17:13:13 aaa-PC kernel: [  466.271101]         ... Feb  6 17:13:13 aaa-PC kernel: [  466.271103] Call Trace: Feb  6 17:13:13 aaa-PC kernel: [  466.271107] [<ffffffff802310c4>] show_stack+0x44/0x1c0 Feb  6 17:13:13 aaa-PC kernel: [  466.271110] [<ffffffff819f5158>] dump_stack+0x1d8/0x240 Feb  6 17:13:13 aaa-PC kernel: [  466.271113] [<ffffffff80491c10>] bad_page+0x210/0x2c0 Feb  6 17:13:13 aaa-PC kernel: [  466.271116] [<ffffffff804931c8>] free_pcppages_bulk+0x708/0x900 Feb  6 17:13:13 aaa-PC kernel: [  46 6.271119] [<ffffffff804980cc>] free_unref_page_list+0x1cc/0x2c0 Feb  6 17:13:13 aaa-PC kernel: [  466.271122] [<ffffffff804ad2c8>] release_pages+0x648/0x900 Feb  6 17:13:13 aaa-PC kernel: [  466.271125] [<ffffffff804f3b48>] tlb_flush_mmu_free+0x88/0x100 Feb  6 17:13:13 aaa-PC kernel: [  466.271128] [<ffffffff804f8a24>] zap_pte_range+0xa24/0x1480 Feb  6 17:13:13 aaa-PC kernel: [  466.271132] [<ffffffff804f98b0>] unmap_page_range+0x1f0/0x500 Feb  6 17:13:13 aaa-PC kernel: [  466.271135] [<ffffffff804fa054>] unmap_vmas+0x154/0x200 Feb  6 17:13:13 aaa-PC kernel: [  466.271138] [<ffffffff8051190c>] exit_mmap+0x20c/0x380 Feb  6 17:13:13 aaa-PC kernel: [  466.271142] [<ffffffff802bb9c8>] mmput+0x148/0x300 Feb  6 17:13:13 aaa-PC kernel: [  466.271145] [<ffffffff802c80d8>] do_exit+0x6d8/0x1900 Feb  6 17:13:13 aaa-PC kernel: [  466.271148] [<ffffffff802cb288>] do_group_exit+0x88/0x1c0 Feb  6 17:13:13 aaa-PC kernel: [  466.271151] [<ffffffff802cb3d8>] sys_exit_group+0x18/0x40 Feb  6 17 :13:13 aaa-PC kernel: [  466.271155] [<ffffffff8023f954>] syscall_common+0x34/0xa4
Date: Wed,  7 Apr 2021 09:27:46 +0800	[thread overview]
Message-ID: <20210407012746.16082-1-songqiang@uniontech.com> (raw)

Signed-off-by: songqiang <songqiang@uniontech.com>
---
 drivers/gpu/drm/ttm/ttm_page_alloc.c | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/ttm/ttm_page_alloc.c b/drivers/gpu/drm/ttm/ttm_page_alloc.c
index 14660f723f71..f3698f0ad4d7 100644
--- a/drivers/gpu/drm/ttm/ttm_page_alloc.c
+++ b/drivers/gpu/drm/ttm/ttm_page_alloc.c
@@ -736,8 +736,16 @@ static void ttm_put_pages(struct page **pages, unsigned npages, int flags,
 					if (++p != pages[i + j])
 					    break;
 
-				if (j == HPAGE_PMD_NR)
+				if (j == HPAGE_PMD_NR) {
 					order = HPAGE_PMD_ORDER;
+					for (j = 1; j < HPAGE_PMD_NR; ++j)
+						page_ref_dec(pages[i+j]);
+				}
 			}
 #endif
 
@@ -868,10 +876,12 @@ static int ttm_get_pages(struct page **pages, unsigned npages, int flags,
 				p = alloc_pages(huge_flags, HPAGE_PMD_ORDER);
 				if (!p)
 					break;
-
-				for (j = 0; j < HPAGE_PMD_NR; ++j)
+				for (j = 0; j < HPAGE_PMD_NR; ++j) {
 					pages[i++] = p++;
-
+					if (j > 0)
+						page_ref_inc(pages[i-1]);
+				}
 				npages -= HPAGE_PMD_NR;
 			}
 		}




             reply	other threads:[~2021-04-07  1:28 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-07  1:27 songqiang [this message]
2021-04-07  8:25 ` your mail Huang Rui
2021-04-07  9:25   ` Christian König

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210407012746.16082-1-songqiang@uniontech.com \
    --to=songqiang@uniontech.com \
    --cc=airlied@linux.ie \
    --cc=christian.koenig@amd.com \
    --cc=daniel@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ray.huang@amd.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®