Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp2854155pxf; Sun, 21 Mar 2021 09:08:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJygM1RUQUsRK5jX6UfRHodoIA6HdBzcKNVNvERVK0wVMnCoVWUI7XUdoEzeLFW9Uk1XFEcy X-Received: by 2002:a17:906:3d62:: with SMTP id r2mr14778832ejf.488.1616342912095; Sun, 21 Mar 2021 09:08:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616342912; cv=none; d=google.com; s=arc-20160816; b=TpFOiYlsob/hN3CCntpgC7CPz7ioYQgkTNymkR+xP3Il1IbFcVPBAj2B7Mt63xcfLq dipQmKNCwMjtXjgWICiktYOFonRgwQ2yhx3PJSgOVV5yXuarGk9sR0hjT/LNULweTsLd c1u3vTWxFotCj+0Nb0shVt9Ba5v7IRJFCwlzUreUe7giwIi9lArgHDEwFf4ISwBPAMiu Hi4EbpBoGni5WT+FiKX0OmuIF1EWHtgcViSzN/cHHkeTjZLTfxsniMAmhdVdU/E6EEwA eSNJa3rJslgCifZsJLU3ZScPAY05gh/aIiwHWcEbkUxsh52zGzeuZft0AdXMUNhrcX7P oO6A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=au6yAq/994byN5B0Bwhkok5fWOyRbkNX7zhhajSq4Aw=; b=FMG5E98VOdsEaVbt4CBM5BZidKKG+kE7sjmFZlszKywIlK1+BaRZdsCl9oEDKib/QE LKUlUvwYfOLAKQX9sdIgc6fSPW4RNo4DLddGtco9zYDE0+/8jxSVLt7gGSRN4e7KOSrq n4Zl/bI26ofj8Zmv42EayMOCF4uJAML0OQPMhITtkOu5uC+StnRmG3W4OXOnh6Vhcc0A R+BpIp37qvLYGXIecnQMcm3xu2+/1W7ESjb3krxB4N7++WUM3pSYjHmLR/+YdJyT594O 6bJ5AGs8pf42pxaOzI+kxuVxM4m51VoN3t3n6SycQC8nQ39KL5fj2AZeIWqyvrfLCi8L CWvg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="ns/uAHPv"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dm15si9888306ejc.270.2021.03.21.09.08.09; Sun, 21 Mar 2021 09:08:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="ns/uAHPv"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230229AbhCUPTi (ORCPT + 99 others); Sun, 21 Mar 2021 11:19:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59730 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229784AbhCUPTa (ORCPT ); Sun, 21 Mar 2021 11:19:30 -0400 Received: from mail-qt1-x82a.google.com (mail-qt1-x82a.google.com [IPv6:2607:f8b0:4864:20::82a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8B1EEC061574 for ; Sun, 21 Mar 2021 08:19:29 -0700 (PDT) Received: by mail-qt1-x82a.google.com with SMTP id l13so10523416qtu.9 for ; Sun, 21 Mar 2021 08:19:29 -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=hWZnQazKWn+M7O1c0Y54ntMhsytEh34VCduXJmcoIEaj5lu/M3X9ZmrYvJIihgxPVh ysxtiaix/L7Z5MAdQ0Z6SKWy/LV27ynp5+JF+pWlw9Brj9Z2hsT+l/2ZUwWxhoTgCuyI 6u81nhZcQRMnO7BG3np8XYhiaxtza8y492f8IJ09Rc3Jl1mEjtUWc8365TYYPs1Ts7UR vWKwPQ8X0+4HSALfq4gw8eLPGJ6Ie9849+y6jGdgIXY2PIXsjv6YQukG/6PnzZmohej3 4sIfe/TwBN3SU6y+vFtR5k4v3LCmjuo5cIxWcQRquTCWtF4rgwzJazvSZqCHH/0Yz+03 B4/A== X-Gm-Message-State: AOAM533W7nbWDFeZTGVJIHoW8aHTn/Q/6V6lkhrJHHRqZD+itxrDf0mZ rPhTDCrewO4A3KtGTItX01w= 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=20K=C3=B6nig?= , David Airlie , Daniel Vetter , amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Cc: Tong Zhang 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 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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); } -- 2.25.1