From patchwork Wed Dec 10 07:53:43 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierre Moreau X-Patchwork-Id: 5467071 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 DFEF39F1D4 for ; Wed, 10 Dec 2014 07:54:06 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id EE54A2011D for ; Wed, 10 Dec 2014 07:54:05 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id E43CD200F3 for ; Wed, 10 Dec 2014 07:54:04 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 67D3A6E0EB; Tue, 9 Dec 2014 23:54:03 -0800 (PST) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from smtp6-g21.free.fr (smtp6-g21.free.fr [212.27.42.6]) by gabe.freedesktop.org (Postfix) with ESMTP id 008BA6E0EB; Tue, 9 Dec 2014 23:54:01 -0800 (PST) Received: from Normandy.eduroam.u-bordeaux.fr (unknown [147.210.245.180]) (Authenticated sender: pierre.morrow) by smtp6-g21.free.fr (Postfix) with ESMTPSA id 6D8BD82318; Wed, 10 Dec 2014 08:53:30 +0100 (CET) From: Pierre Moreau To: Nouveau List , DRI List , Ben Skeggs Subject: [PATCH v3 2/2] fb/nvaa: Enable non-isometric poller on NVAA/NVAC Date: Wed, 10 Dec 2014 08:53:43 +0100 Message-Id: <1418198023-14225-2-git-send-email-pierre.morrow@free.fr> X-Mailer: git-send-email 2.1.3 In-Reply-To: <1418198023-14225-1-git-send-email-pierre.morrow@free.fr> References: <1418198023-14225-1-git-send-email-pierre.morrow@free.fr> X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, 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 is a v3 of patch "drm/nouveau/fb/nv50: Add PFB writes") This fix a GPU lockup on 9400M (NVAC) when using acceleration, see https://bugs.freedesktop.org/show_bug.cgi?id=27501 v2: - Move code to subdev/fb/nv50.c as suggested by Roy Spliet; - Remove arbitrary writes to 100c18/100c24 - Replace write to 100c1c of arbitrary value by the address of a scratch page as proposed by Ilia Mirkin; - Remove enabling of bits 16 and 0 as they don't yield in any changes. v3: - Move code to subdev/fb/nvaa.c as suggested by Ilia Mirkin. The following changes were made thanks to information provided by Robert Morell from NVidia: - Allocate a dma page for use by the pollers; - Re-enable pollers at bits 16 and 0; - Set pollers address to a proper value. Signed-off-by: Pierre Moreau --- drm/core/subdev/fb/nvaa.h | 1 + nvkm/subdev/fb/nv50.h | 4 +++ nvkm/subdev/fb/nvaa.c | 74 ++++++++++++++++++++++++++++++++++++++++++++--- nvkm/subdev/fb/nvaa.h | 19 ++++++++++++ 4 files changed, 94 insertions(+), 4 deletions(-) create mode 120000 drm/core/subdev/fb/nvaa.h create mode 100644 nvkm/subdev/fb/nvaa.h diff --git a/drm/core/subdev/fb/nvaa.h b/drm/core/subdev/fb/nvaa.h new file mode 120000 index 0000000..b450e8c --- /dev/null +++ b/drm/core/subdev/fb/nvaa.h @@ -0,0 +1 @@ +../../../../nvkm/subdev/fb/nvaa.h \ No newline at end of file diff --git a/nvkm/subdev/fb/nv50.h b/nvkm/subdev/fb/nv50.h index c5e5a88..0b20975 100644 --- a/nvkm/subdev/fb/nv50.h +++ b/nvkm/subdev/fb/nv50.h @@ -9,6 +9,10 @@ struct nv50_fb_priv { dma_addr_t r100c08; }; +#define nv50_fb_create(p,e,c,d,o) \ + nv50_fb_ctor((p), (e), (c), (d), sizeof(**o), \ + (struct nouveau_object **)o) + int nv50_fb_ctor(struct nouveau_object *, struct nouveau_object *, struct nouveau_oclass *, void *, u32, struct nouveau_object **); diff --git a/nvkm/subdev/fb/nvaa.c b/nvkm/subdev/fb/nvaa.c index cba8e68..b70ab2f 100644 --- a/nvkm/subdev/fb/nvaa.c +++ b/nvkm/subdev/fb/nvaa.c @@ -22,15 +22,81 @@ * Authors: Ben Skeggs */ -#include "nv50.h" +#include "nvaa.h" + +int +nvaa_fb_ctor(struct nouveau_object *parent, struct nouveau_object *engine, + struct nouveau_oclass *oclass, void *data, u32 size, + struct nouveau_object **pobject) +{ + struct nouveau_device *device = nv_device(parent); + struct nvaa_fb_priv *priv; + int ret; + + ret = nv50_fb_create(parent, engine, oclass, data, &priv); + *pobject = nv_object(priv); + if (ret) + return ret; + + priv = (struct nvaa_fb_priv *)(*pobject); + + priv->r100c18_page = alloc_page(GFP_KERNEL | __GFP_ZERO); + if (priv->r100c18_page) { + priv->r100c18 = dma_map_page(nv_device_base(device), + priv->r100c18_page, 0, PAGE_SIZE, + DMA_BIDIRECTIONAL); + if (dma_mapping_error(nv_device_base(device), priv->r100c18)) + return -EFAULT; + } else { + nv_warn(priv, "failed 0x100c18 page alloc\n"); + } + return 0; +} + +void +nvaa_fb_dtor(struct nouveau_object *object) +{ + struct nouveau_device *device = nv_device(object); + struct nvaa_fb_priv *priv = (void *)object; + + if (priv->r100c18_page) { + dma_unmap_page(nv_device_base(device), priv->r100c18, PAGE_SIZE, + DMA_BIDIRECTIONAL); + __free_page(priv->r100c18_page); + } + + nv50_fb_dtor(object); +} + +int +nvaa_fb_init(struct nouveau_object *object) +{ + struct nvaa_fb_priv *priv = (void *)object; + int ret; + + ret = nv50_fb_init(object); + if (ret) + return ret; + + /* Enable NISO poller for various clients and set their associated + * read address, only for MCP77/78 and MCP79/7A. (fd#25701) + */ + nv_wr32(priv, 0x100c18, priv->r100c18 >> 8); + nv_mask(priv, 0x100c14, 0x00000000, 0x00000001); + nv_wr32(priv, 0x100c1c, (priv->r100c18 >> 8) + 1); + nv_mask(priv, 0x100c14, 0x00000000, 0x00000002); + nv_wr32(priv, 0x100c24, (priv->r100c18 >> 8) + 2); + nv_mask(priv, 0x100c14, 0x00000000, 0x00010000); + return 0; +} struct nouveau_oclass * nvaa_fb_oclass = &(struct nv50_fb_impl) { .base.base.handle = NV_SUBDEV(FB, 0xaa), .base.base.ofuncs = &(struct nouveau_ofuncs) { - .ctor = nv50_fb_ctor, - .dtor = nv50_fb_dtor, - .init = nv50_fb_init, + .ctor = nvaa_fb_ctor, + .dtor = nvaa_fb_dtor, + .init = nvaa_fb_init, .fini = _nouveau_fb_fini, }, .base.memtype = nv50_fb_memtype_valid, diff --git a/nvkm/subdev/fb/nvaa.h b/nvkm/subdev/fb/nvaa.h new file mode 100644 index 0000000..84e1eca --- /dev/null +++ b/nvkm/subdev/fb/nvaa.h @@ -0,0 +1,19 @@ +#ifndef __NVKM_FB_NVAA_H__ +#define __NVKM_FB_NVAA_H__ + +#include "nv50.h" + +struct nvaa_fb_priv { + struct nv50_fb_priv base; + struct page *r100c18_page; + dma_addr_t r100c18; +}; + +int nvaa_fb_ctor(struct nouveau_object *, struct nouveau_object *, + struct nouveau_oclass *, void *, u32, + struct nouveau_object **); +void nvaa_fb_dtor(struct nouveau_object *); +int nvaa_fb_init(struct nouveau_object *); + + +#endif