From patchwork Thu Jun 18 14:47:47 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Courbot X-Patchwork-Id: 6638631 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.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id F2CA7C0020 for ; Thu, 18 Jun 2015 14:48:30 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 13B9920827 for ; Thu, 18 Jun 2015 14:48:30 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id ACDAC205ED for ; Thu, 18 Jun 2015 14:48:28 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E76F56ED10; Thu, 18 Jun 2015 07:48:27 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pd0-f178.google.com (mail-pd0-f178.google.com [209.85.192.178]) by gabe.freedesktop.org (Postfix) with ESMTP id B1CC96ED10; Thu, 18 Jun 2015 07:48:26 -0700 (PDT) Received: by pdbci14 with SMTP id ci14so9706258pdb.2; Thu, 18 Jun 2015 07:48:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=ViWcede/+/BmNwyCQp/f0UKMQFGyfo3qeGa3KeWtW+Q=; b=Q84P9lTb6Rv7lxGLGzMHfMNzqtdkEzIo2Kre7dqzN0pEmmbbM3Qkgjslh4XwQjWC1k w5yO2yfjcp4wORoPUYGTtmI8f9XfSWxHfEtOjzVNieK3R/ytO6nvLNneD8G0o7WaNBD6 EK5JzM6/0dmoRwDo7FlgpL/QtWAKuPHFHWtLrkyj1N8MB0BssYjgft/Zs/O1puYRV3T4 y1AKzvKWmpTzin41m2KJfdNMQVr1no1IjtaDyQ8ZZEd74uaKXXxVtEy4SjAwa0aYLW6U bnV/7/HmCi4H0wHlHe/Cw4RK1dA6iC3/ruSs+UsAy0MHIHdmpHhpTZxAGyUgfpK5eL1v XtMg== X-Received: by 10.68.200.69 with SMTP id jq5mr21838999pbc.111.1434638906595; Thu, 18 Jun 2015 07:48:26 -0700 (PDT) Received: from aramis.localdomain (softbank126227184005.bbtec.net. [126.227.184.5]) by mx.google.com with ESMTPSA id af1sm8396374pad.34.2015.06.18.07.48.23 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 18 Jun 2015 07:48:25 -0700 (PDT) From: Alexandre Courbot X-Google-Original-From: Alexandre Courbot To: Ben Skeggs , nouveau@lists.freedesktop.org, Andy Ritger , Aaron Plattner , Allen Martin , Ken Adams , Terje Bergstrom Subject: [PATCH 1/6] gr: support for NVIDIA-provided firmwares Date: Thu, 18 Jun 2015 23:47:47 +0900 Message-Id: <1434638872-29061-2-git-send-email-acourbot@nvidia.com> X-Mailer: git-send-email 2.4.3 In-Reply-To: <1434638872-29061-1-git-send-email-acourbot@nvidia.com> References: <1434638872-29061-1-git-send-email-acourbot@nvidia.com> Cc: linux-tegra@vger.kernel.org, gnurou@gmail.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.4 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 NVIDIA will officially start providing signed firmwares through linux-firmware. Change the GR firmware lookup function to look them up in addition to the extracted firmwares. Signed-off-by: Alexandre Courbot --- drm/nouveau/nvkm/engine/gr/gf100.c | 66 +++++++++++++++++++++++++++++--------- 1 file changed, 51 insertions(+), 15 deletions(-) diff --git a/drm/nouveau/nvkm/engine/gr/gf100.c b/drm/nouveau/nvkm/engine/gr/gf100.c index ca11ddb..39d482f 100644 --- a/drm/nouveau/nvkm/engine/gr/gf100.c +++ b/drm/nouveau/nvkm/engine/gr/gf100.c @@ -1544,26 +1544,62 @@ gf100_gr_dtor_fw(struct gf100_gr_fuc *fuc) fuc->data = NULL; } +/** + * gf100_gr_ctor_fw - helper for loading external GR firmwares + * + * A firmware can either be officially provided by NVIDIA (in which case it will + * use a "NVIDIA name", or be extracted from the binary blob (and use a + * "Nouveau name". The fwname and nvfwname are to be given the Nouveau and + * NVIDIA names of a given firmware, respectively. This function will then + * try to load the NVIDIA firmware, then the extracted one, in that order. + * + */ int gf100_gr_ctor_fw(struct gf100_gr_priv *priv, const char *fwname, - struct gf100_gr_fuc *fuc) + const char *nvfwname, struct gf100_gr_fuc *fuc) { struct nvkm_device *device = nv_device(priv); const struct firmware *fw; - char f[32]; - int ret; + char f[64]; + int ret = -EINVAL; + int i; - snprintf(f, sizeof(f), "nouveau/nv%02x_%s", device->chipset, fwname); - ret = request_firmware(&fw, f, nv_device_base(device)); - if (ret) { - snprintf(f, sizeof(f), "nouveau/%s", fwname); - ret = request_firmware(&fw, f, nv_device_base(device)); - if (ret) { - nv_error(priv, "failed to load %s\n", fwname); - return ret; + /* + * NVIDIA firmware name provided - try to load it + * We try this first since most chips that require external firmware + * are supported by NVIDIA + */ + if (nvfwname) { + snprintf(f, sizeof(f), "nvidia/%s/%s.bin", device->cname, + nvfwname); + i = strlen(f); + while (i) { + --i; + f[i] = tolower(f[i]); } + ret = request_firmware_direct(&fw, f, nv_device_base(device)); + if (!ret) + goto found; + } + + /* Nouveau firmware name provided - try to load it */ + if (fwname) { + snprintf(f, sizeof(f), "nouveau/nv%02x_%s", device->chipset, + fwname); + ret = request_firmware_direct(&fw, f, nv_device_base(device)); + if (!ret) + goto found; + + snprintf(f, sizeof(f), "nouveau/%s", fwname); + ret = request_firmware_direct(&fw, f, nv_device_base(device)); + if (!ret) + goto found; } + nv_error(priv, "failed to load %s / %s\n", fwname, nvfwname); + return ret; + +found: fuc->size = fw->size; fuc->data = kmemdup(fw->data, fuc->size, GFP_KERNEL); release_firmware(fw); @@ -1615,10 +1651,10 @@ gf100_gr_ctor(struct nvkm_object *parent, struct nvkm_object *engine, if (use_ext_fw) { nv_info(priv, "using external firmware\n"); - if (gf100_gr_ctor_fw(priv, "fuc409c", &priv->fuc409c) || - gf100_gr_ctor_fw(priv, "fuc409d", &priv->fuc409d) || - gf100_gr_ctor_fw(priv, "fuc41ac", &priv->fuc41ac) || - gf100_gr_ctor_fw(priv, "fuc41ad", &priv->fuc41ad)) + if (gf100_gr_ctor_fw(priv, "fuc409c", "fecs_inst", &priv->fuc409c) || + gf100_gr_ctor_fw(priv, "fuc409d", "fecs_data", &priv->fuc409d) || + gf100_gr_ctor_fw(priv, "fuc41ac", "gpccs_inst", &priv->fuc41ac) || + gf100_gr_ctor_fw(priv, "fuc41ad", "gpccs_data", &priv->fuc41ad)) return -ENODEV; priv->firmware = true; }