From patchwork Wed Dec 11 13:24:46 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Vetter X-Patchwork-Id: 3326451 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 96819C0D4A for ; Wed, 11 Dec 2013 13:24:14 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C2E61207A5 for ; Wed, 11 Dec 2013 13:24:09 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 5EFBA20793 for ; Wed, 11 Dec 2013 13:24:08 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8CAD6FA953; Wed, 11 Dec 2013 05:24:04 -0800 (PST) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-ea0-f176.google.com (mail-ea0-f176.google.com [209.85.215.176]) by gabe.freedesktop.org (Postfix) with ESMTP id AEAA7FA953 for ; Wed, 11 Dec 2013 05:24:02 -0800 (PST) Received: by mail-ea0-f176.google.com with SMTP id h14so2920348eaj.7 for ; Wed, 11 Dec 2013 05:24:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=y78ez6/cOUS5pK3zY7bHfVo/YIZXlHwua/J/JNMdIrg=; b=lJcjU0Yr3s+3zqgbPqPHYzCA0YCeJDVpGGfUoFh5FqkmVfcwl1/lcnkgZakmf5PrOo lwDKnsgCUFhSbojC1SJE7ptBt6bv4XvUJKGpqj5QiDOahUPxHNe/kWhpc+GWzEwjlm6P r1AuwhhxpMpjslDMn5kZifLPkVxQ7xYeE1wFs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=y78ez6/cOUS5pK3zY7bHfVo/YIZXlHwua/J/JNMdIrg=; b=ILeSp5VRiR0IL+xwbWo4MKBrMLFXT3UqSlUZMAO0hUtQsFiZ2H1MPe55nVstXuy7AY EvdpBrA+hzyrPUKBc7NviPoyjcY6NDDrHlWT8260YzkTEdyU74Wlm2pIhjV6l7f8AbUB vxUiXxZ/FuezrgcXTsULHaJNQto1JOL2pxuxtVbTUnB/KqaskB6QL2fk0rmgW5JKrhyX 98ug9TphsaA2kuAhf79gm4zPbNppRoGgJsisspsiYR/umiUZtCXx8Kib53i/MuIyNFWJ an1e2Xr0srZE9yUk7+YGDyGN0NgT667VPibZ3UgIf/td4MdOKIJc5Txf1rqmaBE3jCEJ qRSA== X-Gm-Message-State: ALoCoQkLuyYEwbVrCHP1CYMYy0FdKc6sA5KajwdSGc9xsvDnscaGGDXd6kVUUghIyN0UIRgOXKh6 X-Received: by 10.15.54.130 with SMTP id t2mr1917387eew.72.1386768241904; Wed, 11 Dec 2013 05:24:01 -0800 (PST) Received: from phenom.ffwll.local (178-83-130-250.dynamic.hispeed.ch. [178.83.130.250]) by mx.google.com with ESMTPSA id j46sm53596660eew.18.2013.12.11.05.24.00 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 11 Dec 2013 05:24:00 -0800 (PST) From: Daniel Vetter To: DRI Development Subject: [PATCH 1/2] drm: store the gem vma offset manager in a typed pointer Date: Wed, 11 Dec 2013 14:24:46 +0100 Message-Id: <1386768287-30353-1-git-send-email-daniel.vetter@ffwll.ch> X-Mailer: git-send-email 1.8.4.3 In-Reply-To: References: Cc: Daniel Vetter 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.3 required=5.0 tests=BAYES_00,DKIM_SIGNED, 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 This was hidden in a generic void * dev->mm_private. But only ever used for gem. But thanks to this fake generic pretension no one noticed that Rob's drm drivers are now all broken. So just give the offset manager a type pointer and fix up msm, omapdrm and tilcdc. v2: Fixup compile fail. v3: Fixup rebase fail that David spotted. Cc: David Herrmann Cc: Rob Clark Signed-off-by: Daniel Vetter Signed-off-by: Rob Clark --- drivers/gpu/drm/drm_gem.c | 27 ++++++++++++--------------- drivers/gpu/drm/msm/msm_drv.c | 2 +- drivers/gpu/drm/omapdrm/omap_debugfs.c | 2 +- drivers/gpu/drm/tilcdc/tilcdc_drv.c | 2 +- include/drm/drmP.h | 9 +-------- 5 files changed, 16 insertions(+), 26 deletions(-) diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c index 4761adedad2a..32525b0a473a 100644 --- a/drivers/gpu/drm/drm_gem.c +++ b/drivers/gpu/drm/drm_gem.c @@ -91,19 +91,19 @@ int drm_gem_init(struct drm_device *dev) { - struct drm_gem_mm *mm; + struct drm_vma_offset_manager *vma_offset_manager; mutex_init(&dev->object_name_lock); idr_init(&dev->object_name_idr); - mm = kzalloc(sizeof(struct drm_gem_mm), GFP_KERNEL); - if (!mm) { + vma_offset_manager = kzalloc(sizeof(*vma_offset_manager), GFP_KERNEL); + if (!vma_offset_manager) { DRM_ERROR("out of memory\n"); return -ENOMEM; } - dev->mm_private = mm; - drm_vma_offset_manager_init(&mm->vma_manager, + dev->vma_offset_manager = vma_offset_manager; + drm_vma_offset_manager_init(vma_offset_manager, DRM_FILE_PAGE_OFFSET_START, DRM_FILE_PAGE_OFFSET_SIZE); @@ -113,11 +113,10 @@ drm_gem_init(struct drm_device *dev) void drm_gem_destroy(struct drm_device *dev) { - struct drm_gem_mm *mm = dev->mm_private; - drm_vma_offset_manager_destroy(&mm->vma_manager); - kfree(mm); - dev->mm_private = NULL; + drm_vma_offset_manager_destroy(dev->vma_offset_manager); + kfree(dev->vma_offset_manager); + dev->vma_offset_manager = NULL; } /** @@ -374,9 +373,8 @@ void drm_gem_free_mmap_offset(struct drm_gem_object *obj) { struct drm_device *dev = obj->dev; - struct drm_gem_mm *mm = dev->mm_private; - drm_vma_offset_remove(&mm->vma_manager, &obj->vma_node); + drm_vma_offset_remove(dev->vma_offset_manager, &obj->vma_node); } EXPORT_SYMBOL(drm_gem_free_mmap_offset); @@ -398,9 +396,8 @@ int drm_gem_create_mmap_offset_size(struct drm_gem_object *obj, size_t size) { struct drm_device *dev = obj->dev; - struct drm_gem_mm *mm = dev->mm_private; - return drm_vma_offset_add(&mm->vma_manager, &obj->vma_node, + return drm_vma_offset_add(dev->vma_offset_manager, &obj->vma_node, size / PAGE_SIZE); } EXPORT_SYMBOL(drm_gem_create_mmap_offset_size); @@ -833,7 +830,6 @@ int drm_gem_mmap(struct file *filp, struct vm_area_struct *vma) { struct drm_file *priv = filp->private_data; struct drm_device *dev = priv->minor->dev; - struct drm_gem_mm *mm = dev->mm_private; struct drm_gem_object *obj; struct drm_vma_offset_node *node; int ret = 0; @@ -843,7 +839,8 @@ int drm_gem_mmap(struct file *filp, struct vm_area_struct *vma) mutex_lock(&dev->struct_mutex); - node = drm_vma_offset_exact_lookup(&mm->vma_manager, vma->vm_pgoff, + node = drm_vma_offset_exact_lookup(dev->vma_offset_manager, + vma->vm_pgoff, vma_pages(vma)); if (!node) { mutex_unlock(&dev->struct_mutex); diff --git a/drivers/gpu/drm/msm/msm_drv.c b/drivers/gpu/drm/msm/msm_drv.c index 233246641ae9..177169ce01f0 100644 --- a/drivers/gpu/drm/msm/msm_drv.c +++ b/drivers/gpu/drm/msm/msm_drv.c @@ -415,7 +415,7 @@ static int msm_gem_show(struct drm_device *dev, struct seq_file *m) static int msm_mm_show(struct drm_device *dev, struct seq_file *m) { - return drm_mm_dump_table(m, dev->mm_private); + return drm_mm_dump_table(m, &dev->vma_offset_manager->vm_addr_space_mm); } static int msm_fb_show(struct drm_device *dev, struct seq_file *m) diff --git a/drivers/gpu/drm/omapdrm/omap_debugfs.c b/drivers/gpu/drm/omapdrm/omap_debugfs.c index c27f59da7f29..d4c04d69fc4d 100644 --- a/drivers/gpu/drm/omapdrm/omap_debugfs.c +++ b/drivers/gpu/drm/omapdrm/omap_debugfs.c @@ -48,7 +48,7 @@ static int mm_show(struct seq_file *m, void *arg) { struct drm_info_node *node = (struct drm_info_node *) m->private; struct drm_device *dev = node->minor->dev; - return drm_mm_dump_table(m, dev->mm_private); + return drm_mm_dump_table(m, &dev->vma_offset_manager->vm_addr_space_mm); } static int fb_show(struct seq_file *m, void *arg) diff --git a/drivers/gpu/drm/tilcdc/tilcdc_drv.c b/drivers/gpu/drm/tilcdc/tilcdc_drv.c index 4fad1efbce03..b20b69488dc9 100644 --- a/drivers/gpu/drm/tilcdc/tilcdc_drv.c +++ b/drivers/gpu/drm/tilcdc/tilcdc_drv.c @@ -444,7 +444,7 @@ static int tilcdc_mm_show(struct seq_file *m, void *arg) { struct drm_info_node *node = (struct drm_info_node *) m->private; struct drm_device *dev = node->minor->dev; - return drm_mm_dump_table(m, dev->mm_private); + return drm_mm_dump_table(m, &dev->vma_offset_manager->vm_addr_space_mm); } static struct drm_info_list tilcdc_debugfs_list[] = { diff --git a/include/drm/drmP.h b/include/drm/drmP.h index 3b946beba2e0..79208fc135cc 100644 --- a/include/drm/drmP.h +++ b/include/drm/drmP.h @@ -601,13 +601,6 @@ struct drm_ati_pcigart_info { }; /** - * GEM specific mm private for tracking GEM objects - */ -struct drm_gem_mm { - struct drm_vma_offset_manager vma_manager; -}; - -/** * This structure defines the drm_mm memory object, which will be used by the * DRM for its buffer objects. */ @@ -1156,7 +1149,6 @@ struct drm_device { struct drm_sg_mem *sg; /**< Scatter gather memory */ unsigned int num_crtcs; /**< Number of CRTCs on this device */ void *dev_private; /**< device private data */ - void *mm_private; struct address_space *dev_mapping; struct drm_sigdata sigdata; /**< For block_all_signals */ sigset_t sigmask; @@ -1174,6 +1166,7 @@ struct drm_device { /*@{ */ struct mutex object_name_lock; struct idr object_name_idr; + struct drm_vma_offset_manager *vma_offset_manager; /*@} */ int switch_power_state;