From patchwork Tue Dec 24 04:58:37 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilija Hadzic X-Patchwork-Id: 3400171 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id B4EEB9F314 for ; Tue, 24 Dec 2013 04:54:47 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 935A12041E for ; Tue, 24 Dec 2013 04:54:46 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 2A2B120304 for ; Tue, 24 Dec 2013 04:54:45 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 87DFDFBD62; Mon, 23 Dec 2013 20:54:40 -0800 (PST) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-qe0-f41.google.com (mail-qe0-f41.google.com [209.85.128.41]) by gabe.freedesktop.org (Postfix) with ESMTP id 771D1FBD62 for ; Mon, 23 Dec 2013 20:54:38 -0800 (PST) Received: by mail-qe0-f41.google.com with SMTP id gh4so6143430qeb.0 for ; Mon, 23 Dec 2013 20:54:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=Y2OGUBZLou//uH5I9Smc1Lkmp56eOb9akntsQTNBCs4=; b=h035L0OEybEkw4Hx3xEa/LJgii6BEMuHnp0qUiw6FScDIB/XZ6Qou1OLGSVHOlArrg IAsPcP1fWAqu4lCt0W2SH8bBoUJOwCTAqiGpi9DRspfYYF+wl3pEPH1d/QBuzjkAs741 5xH7eGbaRriUye2DcFHMQyRP0uF4bqLiqK8WWAsLx2OkcmoptupSefd/40lyLpl/+ESC UVB7InYPM80lzhv2jfl7/f0A7mK5TfbSHVm3F+LI/wAzLe9GwS6nwvmtYvNcSiX/EBRl mDc+xoZjw/AYi2fLzfjjyeb0bAODfHphMN7Oz29e+G3T4VHHM9UxPNxAwWggb9XZLVFS t7Qg== X-Received: by 10.224.55.197 with SMTP id v5mr49663863qag.9.1387860878026; Mon, 23 Dec 2013 20:54:38 -0800 (PST) Received: from caterpillar.hsd1.nj.comcast.net. (c-98-221-32-44.hsd1.nj.comcast.net. [98.221.32.44]) by mx.google.com with ESMTPSA id c10sm25321619qaq.16.2013.12.23.20.54.36 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Dec 2013 20:54:37 -0800 (PST) From: Ilija Hadzic To: dri-devel@lists.freedesktop.org Subject: [PATCH] drm/radeon: fix ttm debugfs for multiple devices Date: Mon, 23 Dec 2013 23:58:37 -0500 Message-Id: <1387861117-3244-1-git-send-email-ihadzic@research.bell-labs.com> X-Mailer: git-send-email 1.8.2.1 Cc: Ilija Hadzic X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dri-devel-bounces@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org X-Spam-Status: No, score=-4.6 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP debugfs files created in radeon_ttm_debugfs_init are broken when there are multiple devices in the system. Namely, static declaration of radeon_mem_types_list causes the function to overwrite the values when the executed for subsequent devices. Consequently, the debugfs access functions can get .data field that belongs to wrong device. This patch fixes the problem by moving the mem_types list into the radeon_device structure instead of using static declarations. Signed-off-by: Ilija Hadzic --- drivers/gpu/drm/radeon/radeon.h | 6 ++++++ drivers/gpu/drm/radeon/radeon_ttm.c | 43 +++++++++++++++++-------------------- 2 files changed, 26 insertions(+), 23 deletions(-) diff --git a/drivers/gpu/drm/radeon/radeon.h b/drivers/gpu/drm/radeon/radeon.h index b1f990d..bcb173a 100644 --- a/drivers/gpu/drm/radeon/radeon.h +++ b/drivers/gpu/drm/radeon/radeon.h @@ -2098,6 +2098,10 @@ struct radeon_atcs { typedef uint32_t (*radeon_rreg_t)(struct radeon_device*, uint32_t); typedef void (*radeon_wreg_t)(struct radeon_device*, uint32_t, uint32_t); +#define RADEON_DEBUGFS_MEM_TYPES 2 +#define RADEON_TTM_DEBUGFS_MEM_TYPES 2 +#define RADEON_DEBUGFS_TOTAL_MEM_TYPES (RADEON_DEBUGFS_MEM_TYPES + RADEON_TTM_DEBUGFS_MEM_TYPES) + struct radeon_device { struct device *dev; struct drm_device *ddev; @@ -2213,6 +2217,8 @@ struct radeon_device { /* debugfs */ struct radeon_debugfs debugfs[RADEON_DEBUGFS_MAX_COMPONENTS]; unsigned debugfs_count; + struct drm_info_list mem_types_list[RADEON_DEBUGFS_TOTAL_MEM_TYPES]; + char mem_types_names[RADEON_DEBUGFS_TOTAL_MEM_TYPES][32]; /* virtual memory */ struct radeon_vm_manager vm_manager; struct mutex gpu_clock_mutex; diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c b/drivers/gpu/drm/radeon/radeon_ttm.c index 051fa87..0de413b 100644 --- a/drivers/gpu/drm/radeon/radeon_ttm.c +++ b/drivers/gpu/drm/radeon/radeon_ttm.c @@ -832,9 +832,6 @@ int radeon_mmap(struct file *filp, struct vm_area_struct *vma) return 0; } - -#define RADEON_DEBUGFS_MEM_TYPES 2 - #if defined(CONFIG_DEBUG_FS) static int radeon_mm_dump_table(struct seq_file *m, void *data) { @@ -855,40 +852,40 @@ static int radeon_mm_dump_table(struct seq_file *m, void *data) static int radeon_ttm_debugfs_init(struct radeon_device *rdev) { #if defined(CONFIG_DEBUG_FS) - static struct drm_info_list radeon_mem_types_list[RADEON_DEBUGFS_MEM_TYPES+2]; - static char radeon_mem_types_names[RADEON_DEBUGFS_MEM_TYPES+2][32]; unsigned i; for (i = 0; i < RADEON_DEBUGFS_MEM_TYPES; i++) { if (i == 0) - sprintf(radeon_mem_types_names[i], "radeon_vram_mm"); + sprintf(rdev->mem_types_names[i], "radeon_vram_mm"); else - sprintf(radeon_mem_types_names[i], "radeon_gtt_mm"); - radeon_mem_types_list[i].name = radeon_mem_types_names[i]; - radeon_mem_types_list[i].show = &radeon_mm_dump_table; - radeon_mem_types_list[i].driver_features = 0; + sprintf(rdev->mem_types_names[i], "radeon_gtt_mm"); + rdev->mem_types_list[i].name = rdev->mem_types_names[i]; + rdev->mem_types_list[i].show = &radeon_mm_dump_table; + rdev->mem_types_list[i].driver_features = 0; if (i == 0) - radeon_mem_types_list[i].data = rdev->mman.bdev.man[TTM_PL_VRAM].priv; + rdev->mem_types_list[i].data = + rdev->mman.bdev.man[TTM_PL_VRAM].priv; else - radeon_mem_types_list[i].data = rdev->mman.bdev.man[TTM_PL_TT].priv; + rdev->mem_types_list[i].data = + rdev->mman.bdev.man[TTM_PL_TT].priv; } /* Add ttm page pool to debugfs */ - sprintf(radeon_mem_types_names[i], "ttm_page_pool"); - radeon_mem_types_list[i].name = radeon_mem_types_names[i]; - radeon_mem_types_list[i].show = &ttm_page_alloc_debugfs; - radeon_mem_types_list[i].driver_features = 0; - radeon_mem_types_list[i++].data = NULL; + sprintf(rdev->mem_types_names[i], "ttm_page_pool"); + rdev->mem_types_list[i].name = rdev->mem_types_names[i]; + rdev->mem_types_list[i].show = &ttm_page_alloc_debugfs; + rdev->mem_types_list[i].driver_features = 0; + rdev->mem_types_list[i++].data = NULL; #ifdef CONFIG_SWIOTLB if (swiotlb_nr_tbl()) { - sprintf(radeon_mem_types_names[i], "ttm_dma_page_pool"); - radeon_mem_types_list[i].name = radeon_mem_types_names[i]; - radeon_mem_types_list[i].show = &ttm_dma_page_alloc_debugfs; - radeon_mem_types_list[i].driver_features = 0; - radeon_mem_types_list[i++].data = NULL; + sprintf(rdev->mem_types_names[i], "ttm_dma_page_pool"); + rdev->mem_types_list[i].name = rdev->mem_types_names[i]; + rdev->mem_types_list[i].show = &ttm_dma_page_alloc_debugfs; + rdev->mem_types_list[i].driver_features = 0; + rdev->mem_types_list[i++].data = NULL; } #endif - return radeon_debugfs_add_files(rdev, radeon_mem_types_list, i); + return radeon_debugfs_add_files(rdev, rdev->mem_types_list, i); #endif return 0;