From patchwork Thu Dec 13 23:04:02 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lucas Kannebley Tavares X-Patchwork-Id: 1877721 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by patchwork1.kernel.org (Postfix) with ESMTP id 7D9923FC64 for ; Fri, 14 Dec 2012 07:58:50 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 6693DE686C for ; Thu, 13 Dec 2012 23:58:50 -0800 (PST) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from e24smtp04.br.ibm.com (e24smtp04.br.ibm.com [32.104.18.25]) by gabe.freedesktop.org (Postfix) with ESMTP id 5F48EE5C14 for ; Thu, 13 Dec 2012 15:04:10 -0800 (PST) Received: from /spool/local by e24smtp04.br.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 13 Dec 2012 21:04:08 -0200 Received: from d24dlp02.br.ibm.com (9.18.248.206) by e24smtp04.br.ibm.com (10.172.0.140) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 13 Dec 2012 21:04:05 -0200 Received: from d24relay02.br.ibm.com (d24relay02.br.ibm.com [9.13.184.26]) by d24dlp02.br.ibm.com (Postfix) with ESMTP id CD9D01DC0028 for ; Thu, 13 Dec 2012 18:04:04 -0500 (EST) Received: from d24av03.br.ibm.com (d24av03.br.ibm.com [9.8.31.95]) by d24relay02.br.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id qBDN3kS734210030 for ; Thu, 13 Dec 2012 21:03:46 -0200 Received: from d24av03.br.ibm.com (loopback [127.0.0.1]) by d24av03.br.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id qBDL4QuC017468 for ; Thu, 13 Dec 2012 19:04:27 -0200 Received: from oc4135502304.ibm.com ([9.78.131.18]) by d24av03.br.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id qBDL4PZQ017464; Thu, 13 Dec 2012 19:04:26 -0200 Message-ID: <50CA5EE2.30206@linux.vnet.ibm.com> Date: Thu, 13 Dec 2012 21:04:02 -0200 From: Lucas Kannebley Tavares User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.24) Gecko/20111108 Fedora/3.1.16-1.fc14 Thunderbird/3.1.16 MIME-Version: 1.0 To: dri-devel@lists.freedesktop.org Subject: drm: Added ppc64 root device getter X-Content-Scanned: Fidelis XPS MAILER x-cbid: 12121323-8936-0000-0000-000008D0D560 X-Mailman-Approved-At: Thu, 13 Dec 2012 23:57:41 -0800 Cc: benh@au1.ibm.com, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, brking@linux.vnet.ibm.com, bhelgaas@google.com 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: , Sender: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org Errors-To: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org On architectures such as ppc64, there is no root bus device (it belongs to the hypervisor). DRM attempted to get one, causing a null-pointer dereference. Signed-off-by: Lucas Kannebley Tavares --- { struct pci_dev *root; @@ -479,7 +483,7 @@ int drm_pcie_get_speed_cap_mask(struct drm_device *dev, u32 *mask) return -EINVAL; // find PCI device for capabilities - root = dev->pdev->bus->self; + root = drm_get_parent_device(dev); // some architectures might not have host bridges as PCI devices if (root == NULL) diff --git a/arch/powerpc/platforms/pseries/Makefile b/arch/powerpc/platforms/pseries/Makefile index 890622b..ddfdda8 100644 --- a/arch/powerpc/platforms/pseries/Makefile +++ b/arch/powerpc/platforms/pseries/Makefile @@ -1,6 +1,8 @@ ccflags-$(CONFIG_PPC64) := -mno-minimal-toc ccflags-$(CONFIG_PPC_PSERIES_DEBUG) += -DDEBUG +drm-y += drm_pci.o + obj-y := lpar.o hvCall.o nvram.o reconfig.o \ setup.o iommu.o event_sources.o ras.o \ firmware.o power.o dlpar.o mobility.o diff --git a/arch/powerpc/platforms/pseries/drm_pci.c b/arch/powerpc/platforms/pseries/drm_pci.c new file mode 100644 index 0000000..da6675e --- /dev/null +++ b/arch/powerpc/platforms/pseries/drm_pci.c @@ -0,0 +1,24 @@ +/* + * Copyright (C) 2012 Lucas Kannebley Tavares, IBM Corporation + * + * pSeries specific routines for DRM. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +inline struct pci_device *drm_get_parent_device(struct drm_device *dev) { + return (dev->pdev->bus->self == NULL) ? dev->pdev : dev->pdev->bus->self; +} + diff --git a/drivers/gpu/drm/drm_pci.c b/drivers/gpu/drm/drm_pci.c index eb37466..5a8a4f5 100644 --- a/drivers/gpu/drm/drm_pci.c +++ b/drivers/gpu/drm/drm_pci.c @@ -466,6 +466,10 @@ void drm_pci_exit(struct drm_driver *driver, struct pci_driver *pdriver) } EXPORT_SYMBOL(drm_pci_exit); +inline __weak struct pci_device *drm_get_parent_device(struct drm_device *dev) { + return dev->pdev->bus->self; +} + int drm_pcie_get_speed_cap_mask(struct drm_device *dev, u32 *mask)