From patchwork Sun Mar 21 15:19:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tong Zhang X-Patchwork-Id: 12153101 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.5 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 19B17C433DB for ; Sun, 21 Mar 2021 15:19:30 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id B0FBB61601 for ; Sun, 21 Mar 2021 15:19:29 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B0FBB61601 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E6BCB89D46; Sun, 21 Mar 2021 15:19:28 +0000 (UTC) Received: from mail-qt1-x829.google.com (mail-qt1-x829.google.com [IPv6:2607:f8b0:4864:20::829]) by gabe.freedesktop.org (Postfix) with ESMTPS id 936CE89D46; Sun, 21 Mar 2021 15:19:28 +0000 (UTC) Received: by mail-qt1-x829.google.com with SMTP id c6so10565451qtc.1; Sun, 21 Mar 2021 08:19:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=au6yAq/994byN5B0Bwhkok5fWOyRbkNX7zhhajSq4Aw=; b=ns/uAHPvUjy2iZEKZoWbTS1sMcHu1FX5sa2+Z8yxjXxcwinwoh1oyHO4mBzFoz+fpP t9AdkaaVSj7Eu1xya6LHJaVIUcqswAx5v08y5I3BTb63tMUuXPyS3K84hMb0T+/eeKmc KaILdnSQt58/asDO3bjCrWZKNH5Mzbq3fDfqxwI+NkV3hn8wE3dPl0S/DJMWPcbTe4Tu uD5keox3ZMAS2sxZHl/Up9oKtEb10DorYYXPFnzVIjrNqccO+E1qLWfQKSBbfZdjt6Ap Ub4nMpKgmMjAYI1tXWC60AfBnDUUfg36l+ZcbzeesjUYFx4iHaOJjHSQ7KrEw/wRAW0h 7RGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=au6yAq/994byN5B0Bwhkok5fWOyRbkNX7zhhajSq4Aw=; b=X7Xnmnr5oWl7E822qGwbNvYRV2+qLZzGRIov2dl8EOMDFQYO596uLeIvC4zxtib2KA iirEAUAYTr0hlHtU574VIlbeU6y6daLCH9E0h6cLHFBrt2iuQ06yJKuphLOPjLfD3xab lllRC8ppsPHihjQxXyANUA5Qu+Mm/D71PYRR0a8AAdiYwut+E2aZ0CJgZM4n8hzdsr9i lplMiPvFC3NivKolJ4fX+fmjxxYIpR5c+/puMVz6lHWfne6fZsPUHB0RUlxFhr/d9qk4 QefahM9zyV88qSiUFEY2nMELS397pfCXarOIrD1VIJKKB9fm7IaFJa6b4kqduw8UsLMR jqMw== X-Gm-Message-State: AOAM532SzVu5aERtnx+F4UihP9ClRmf5qdWolE80F1IElIoskKRaKMQ4 VtQn04DT072C4B7n9Ry1jswQaix+YdoasQ== X-Google-Smtp-Source: ABdhPJwXT1ZITQY67+/yUvJVHD5s+98+2llrDVCVzJ7MdJbYm/lFiBOlr2ncZVUhSRoWxxr7oUHCsA== X-Received: by 2002:ac8:1094:: with SMTP id a20mr6296117qtj.248.1616339967589; Sun, 21 Mar 2021 08:19:27 -0700 (PDT) Received: from tong-desktop.local ([2601:5c0:c200:27c6:f925:bb4b:54d2:533]) by smtp.googlemail.com with ESMTPSA id 84sm9302704qkg.8.2021.03.21.08.19.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Mar 2021 08:19:26 -0700 (PDT) From: Tong Zhang To: Alex Deucher , =?utf-8?q?Christian_K=C3=B6nig?= , David Airlie , Daniel Vetter , amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: [PATCH v2] drm/radeon: don't evict if not initialized Date: Sun, 21 Mar 2021 11:19:07 -0400 Message-Id: <20210321151907.367586-1-ztong0001@gmail.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 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: , Cc: Tong Zhang Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" TTM_PL_VRAM may not initialized at all when calling radeon_bo_evict_vram(). We need to check before doing eviction. [ 2.160837] BUG: kernel NULL pointer dereference, address: 0000000000000020 [ 2.161212] #PF: supervisor read access in kernel mode [ 2.161490] #PF: error_code(0x0000) - not-present page [ 2.161767] PGD 0 P4D 0 [ 2.163088] RIP: 0010:ttm_resource_manager_evict_all+0x70/0x1c0 [ttm] [ 2.168506] Call Trace: [ 2.168641] radeon_bo_evict_vram+0x1c/0x20 [radeon] [ 2.168936] radeon_device_fini+0x28/0xf9 [radeon] [ 2.169224] radeon_driver_unload_kms+0x44/0xa0 [radeon] [ 2.169534] radeon_driver_load_kms+0x174/0x210 [radeon] [ 2.169843] drm_dev_register+0xd9/0x1c0 [drm] [ 2.170104] radeon_pci_probe+0x117/0x1a0 [radeon] Suggested-by: Christian König Signed-off-by: Tong Zhang Reviewed-by: Christian König --- v2: coding style fix drivers/gpu/drm/radeon/radeon_object.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/gpu/drm/radeon/radeon_object.c b/drivers/gpu/drm/radeon/radeon_object.c index 9b81786782de..499ce55e34cc 100644 --- a/drivers/gpu/drm/radeon/radeon_object.c +++ b/drivers/gpu/drm/radeon/radeon_object.c @@ -384,6 +384,8 @@ int radeon_bo_evict_vram(struct radeon_device *rdev) } #endif man = ttm_manager_type(bdev, TTM_PL_VRAM); + if (!man) + return 0; return ttm_resource_manager_evict_all(bdev, man); }