From patchwork Tue Jan 14 05:07:39 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Skeggs X-Patchwork-Id: 3484001 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 BD03BC02DC for ; Tue, 14 Jan 2014 05:08:28 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D8CD42017E for ; Tue, 14 Jan 2014 05:08:27 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 962BD20179 for ; Tue, 14 Jan 2014 05:08:26 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 389A987509; Mon, 13 Jan 2014 21:08:05 -0800 (PST) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-qa0-f49.google.com (mail-qa0-f49.google.com [209.85.216.49]) by gabe.freedesktop.org (Postfix) with ESMTP id 9CF77106543; Mon, 13 Jan 2014 21:07:40 -0800 (PST) Received: by mail-qa0-f49.google.com with SMTP id w8so5816387qac.22 for ; Mon, 13 Jan 2014 21:07:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=xZYzcjzV2oiNbAWr7DEcRv/uT02AiipS1WiOuc66Csg=; b=MUN4l+R2f1YdLYQ8YrKJlV+ZbA15oVw2aPQiHdEZDyq8dk3PMVkiGEBQ5CjiLGDrLL Y1/0jALi1zdFoJCH0VkRzHrt7ULkjoZhqPPuKJLCopdxPhh5Ik2bnDDhPT4OnUyIyQr+ AeyHyAUOIHt3mXoA+6tmNChsOOS+6OyeVFZWh2S9DYq6bch2EJDg8NEywvfrHhpIQiBd SmPL+hnvorl0lfyyFRWcPljrEpdWDF6ISPRZEQ2wIdjhh7goqEJR6hsHnJTuGU2DeYs4 qeZhrQ9lu2/qwyXGGY+aiMa0A9KIrAYKQNXM1/M3s3koXwUvKFBX/IsncfkeI+npotOD DoMA== MIME-Version: 1.0 X-Received: by 10.224.124.74 with SMTP id t10mr46677373qar.40.1389676059322; Mon, 13 Jan 2014 21:07:39 -0800 (PST) Received: by 10.229.117.4 with HTTP; Mon, 13 Jan 2014 21:07:39 -0800 (PST) In-Reply-To: <1389669776.1320.5.camel@s2895bg> References: <1389669776.1320.5.camel@s2895bg> Date: Tue, 14 Jan 2014 15:07:39 +1000 Message-ID: Subject: Re: [Nouveau] [Fwd: [PATCH] Fix null dereference oopses for nv40 cards] kernel 3.13.0-rc8 From: Ben Skeggs To: Bob Gleitsmann Cc: "nouveau@lists.freedesktop.org" , Ben Skeggs , "dri-devel@lists.freedesktop.org" 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@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org X-Spam-Status: No, score=-4.2 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 On Tue, Jan 14, 2014 at 1:22 PM, Bob Gleitsmann wrote: > I should have mentioned that this applies to Linus' 3.13.0-rc7 and rc8 > git. Maybe it's obvious. Hey Bob, Thanks for reporting this. Can you try the attached patch instead and report if it helps you? Ben. > > Sorry about that. > > Bob > -------- Forwarded Message -------- > From: Bob Gleitsmann > To: bskeggs@redhat.com > Cc: nouveau@lists.freedesktop.org, dri-devel@lists.freedesktop.org > Subject: [PATCH] Fix null dereference oopses for nv40 cards > Date: Mon, 13 Jan 2014 01:45:36 -0500 > > The problem affects nv40 cards during booting. It comes from there being > two places where subdev arrays are maintained. A commit was recently > added to make the two equal. However, the struct nouveau_device version > ends up being referenced before it is initialized. The problem arises > during the creation of the INSTMEM and THERM subdevs. ' > > Signed off by: Bob Gleitsmann rjgleits@bellsouth.net > > diff --git a/drivers/gpu/drm/nouveau/core/subdev/instmem/nv40.c b/drivers/gpu/drm/nouveau/core/subdev/instmem/nv40.c > index b10a143..0f494ca 100644 > --- a/drivers/gpu/drm/nouveau/core/subdev/instmem/nv40.c > +++ b/drivers/gpu/drm/nouveau/core/subdev/instmem/nv40.c > @@ -23,6 +23,7 @@ > */ > > #include > +#include > > #include "nv04.h" > > @@ -38,6 +39,7 @@ nv40_instmem_ctor(struct nouveau_object *parent, struct nouveau_object *engine, > > ret = nouveau_instmem_create(parent, engine, oclass, &priv); > *pobject = nv_object(priv); > + device->subdev[NVDEV_SUBDEV_INSTMEM] = *pobject; > if (ret) > return ret; > > diff --git a/drivers/gpu/drm/nouveau/core/subdev/therm/nv40.c b/drivers/gpu/drm/nouveau/core/subdev/therm/nv40.c > index 002e51b..59b25be 100644 > --- a/drivers/gpu/drm/nouveau/core/subdev/therm/nv40.c > +++ b/drivers/gpu/drm/nouveau/core/subdev/therm/nv40.c > @@ -187,9 +187,11 @@ nv40_therm_ctor(struct nouveau_object *parent, > { > struct nv40_therm_priv *priv; > int ret; > + struct nouveau_device *device = nv_device(parent); > > ret = nouveau_therm_create(parent, engine, oclass, &priv); > *pobject = nv_object(priv); > + device->subdev[NVDEV_SUBDEV_THERM] = *pobject; > if (ret) > return ret; > > > > > _______________________________________________ > Nouveau mailing list > Nouveau@lists.freedesktop.org > http://lists.freedesktop.org/mailman/listinfo/nouveau From a79811f15925281dc7fe1797430e51063707c72d Mon Sep 17 00:00:00 2001 From: Ben Skeggs Date: Tue, 14 Jan 2014 14:56:22 +1000 Subject: [PATCH] fix null ptr dereferences on some boards Regression from "device: populate master subdev pointer only when fully constructed" Reported-by: Bob Gleitsmann Signed-off-by: Ben Skeggs --- nvkm/include/subdev/instmem.h | 7 +++++++ nvkm/subdev/therm/ic.c | 3 ++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/nvkm/include/subdev/instmem.h b/nvkm/include/subdev/instmem.h index e40b26c..c1df26f 100644 --- a/nvkm/include/subdev/instmem.h +++ b/nvkm/include/subdev/instmem.h @@ -35,6 +35,13 @@ struct nouveau_instmem { static inline struct nouveau_instmem * nouveau_instmem(void *obj) { + /* nv04/nv40 impls need to create objects in their constructor, + * which is before the subdev pointer is valid + */ + if (nv_iclass(obj, NV_SUBDEV_CLASS) && + nv_subidx(obj) == NVDEV_SUBDEV_INSTMEM) + return obj; + return (void *)nv_device(obj)->subdev[NVDEV_SUBDEV_INSTMEM]; } diff --git a/nvkm/subdev/therm/ic.c b/nvkm/subdev/therm/ic.c index e44ed7b..8c26ff1 100644 --- a/nvkm/subdev/therm/ic.c +++ b/nvkm/subdev/therm/ic.c @@ -31,7 +31,8 @@ static bool probe_monitoring_device(struct nouveau_i2c_port *i2c, struct i2c_board_info *info) { - struct nouveau_therm_priv *priv = (void *)nouveau_therm(i2c); + struct nouveau_therm_priv *priv = + (void *)nv_pclass(i2c, NV_SUBDEV_CLASS); struct nvbios_therm_sensor *sensor = &priv->bios_sensor; struct i2c_client *client; -- 1.8.5.2