From patchwork Sun Sep 6 11:29:18 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierre Moreau X-Patchwork-Id: 7131501 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.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 375259F1CD for ; Sun, 6 Sep 2015 11:39:07 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 46249206B8 for ; Sun, 6 Sep 2015 11:39:06 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 1DC7C206B2 for ; Sun, 6 Sep 2015 11:39:05 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 4CB576E46B; Sun, 6 Sep 2015 04:39:03 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org X-Greylist: delayed 568 seconds by postgrey-1.34 at gabe; Sun, 06 Sep 2015 04:39:01 PDT Received: from mail.pmoreau.org (pmoreau.org [37.187.98.141]) by gabe.freedesktop.org (Postfix) with ESMTP id DF53D6E3D3; Sun, 6 Sep 2015 04:39:01 -0700 (PDT) Received: from testlinux.localdomain (c83-254-147-111.bredband.comhem.se [83.254.147.111]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (Client did not present a certificate) (Authenticated sender: eiquom6u@pmoreau.org) by mail.pmoreau.org (Postfix) with ESMTPSA id 34A76A403CB; Sun, 6 Sep 2015 13:30:35 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=pmoreau.org; s=default; t=1441539035; bh=2tcw+Q6GkadbHwZmlqos5gnt0KzEPfXwqnwqiL0rW+E=; h=From:To:Cc:Subject:Date; b=Y/3tvYl81ZG67fcgtzOMp4anfkbSQn/sYiHOxFyCXbyctqF7ZmKmpGZHCnUiYJIoS eXaCeJso6h3IFOHf9md5zo4j6wBKcEwL4X1tfWKms0FM1fLujvId1t+7AD/v32NX+T LLFwErT88rdD6neb/4S/vE6sQR0UKF+WbVDHs7bw= From: Pierre Moreau To: nouveau@lists.freedesktop.org Subject: [PATCH] pci: Handle 5-bit and 8-bit tag field Date: Sun, 6 Sep 2015 13:29:18 +0200 Message-Id: <1441538958-15119-1-git-send-email-dev@pmoreau.org> X-Mailer: git-send-email 2.5.1 Cc: bskeggs@redhat.com, dri-devel@lists.freedesktop.org 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.3 required=5.0 tests=BAYES_00,DKIM_ADSP_ALL, DKIM_SIGNED,RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD,T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham 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 If the hardware supports extended tag field (8-bit ones), then enabled it. This is usually done by the VBIOS, but not on some MBPs (see fdo#86537). In case extended tag field is not supported, 5-bit tag field is used which limits the possible values to 32. Apparently bits 7:0 of 0x8841c stores some number of outstanding requests, so cap it to 32 if extended tag is unsupported. Fixes: fdo#86537 Signed-off-by: Pierre Moreau --- drm/nouveau/nvkm/subdev/pci/base.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/drm/nouveau/nvkm/subdev/pci/base.c b/drm/nouveau/nvkm/subdev/pci/base.c index d1c148e..70631b3 100644 --- a/drm/nouveau/nvkm/subdev/pci/base.c +++ b/drm/nouveau/nvkm/subdev/pci/base.c @@ -46,6 +46,14 @@ nvkm_pci_wr32(struct nvkm_pci *pci, u16 addr, u32 data) pci->func->wr32(pci, addr, data); } +u32 +nvkm_pci_mask(struct nvkm_pci *pci, u16 addr, u32 mask, u32 add) +{ + u32 data = pci->func->rd32(pci, addr); + pci->func->wr32(pci, addr, (data & ~mask) | add); + return data; +} + void nvkm_pci_rom_shadow(struct nvkm_pci *pci, bool shadow) { @@ -115,6 +123,23 @@ nvkm_pci_init(struct nvkm_subdev *subdev) if (ret) return ret; + if (pci_is_pcie(pdev)) { + /* Tag field is 8-bit long, regardless of EXT_TAG. + * However, if EXT_TAG is disabled, only the lower 5 bits of the tag + * field should be used, limiting the number of request to 32. + * + * Apparently, 0x041c stores some limit on the number of requests + * possible, so if EXT_TAG is disabled, limit that requests number to + * 32 + * + * Fixes fdo#86537 + */ + if (nvkm_pci_rd32(pci, 0x007c) & 0x00000020) + nvkm_pci_mask(pci, 0x0080, 0x00000000, 0x00000100); + else + nvkm_pci_mask(pci, 0x041c, 0x00000060, 0x00000000); + } + pci->irq = pdev->irq; return ret; }