Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp3696385ybl; Mon, 13 Jan 2020 00:41:55 -0800 (PST) X-Google-Smtp-Source: APXvYqyQTX/+Z18NNB5dozY4OjY5BQ+GSB0gNP/UIptlbCq9CsxUTjTSjhvUUFgX7tTuu99oUIni X-Received: by 2002:a9d:6a54:: with SMTP id h20mr9585889otn.208.1578904915923; Mon, 13 Jan 2020 00:41:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578904915; cv=none; d=google.com; s=arc-20160816; b=TX5xF0Vb7fmf8sa5Yn2AmUVFZhaerUrraDFnHlIukpMfcsfGEwSmtM9wHYhkzZniYx Dksr8n+Pb2BWHYvmw1Qile8Nrs4sgFeyatrwCp0Bf9vVwj8JTzSd15SbEYnoYLzhzH93 vduAH6I3qqdqw+iRjwb6PiYWR5aowqoJaO5MrHCaMUAg9b/oqBPgR7rfsOiu46Lo9M1A 39wvLued9jPwtWniqcLMNAZLUVK2/OtU/3pYS09gjimQvT44SZ7anDi7P9SxPk0AspU9 37bClaDrDOQG0mfig1CVrRQJHg1HP+Vucyi8028iyLZCn8p1WOri3Gsq7H9EHue0irlP ThQA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=CDwqrvZhAjKLcEz+XRcmWVcUp5JwzuxmgiSvvdNhuYg=; b=sydfRE59Q0W2B0Xhh0smkib1CaojiMwpOER6uEPInAe9mGRljobLO7/9VbvBxRLJ2g L2CfbHdNnEWBms719kWI1BMpdslU0dXXu4ijoncBkoeWfqgRrylf3Jfv3C5CO17KWFfg 6uZowx7Tned/qW1QNXfpjUCZbsV9rTNN/XyulCaLJ0UCXm29S4NrRgCJyi8eKJq9hU4b Huk47cDwbARq10Wd3uAxOcyaugu+4qZDf7gdPiLI6r7f5RhWB4XNw1nLDIWEcD0+wdJC 4e9Isq0vHAJvYsXa2yS3jVO3RAq5lGS3FF9seFBUYVOA7UsajmZipZ7Et6kZu670c5UE JACQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=LE2FTxi8; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e13si6749272otp.164.2020.01.13.00.41.43; Mon, 13 Jan 2020 00:41:55 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=LE2FTxi8; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728949AbgAMIkk (ORCPT + 99 others); Mon, 13 Jan 2020 03:40:40 -0500 Received: from mail.kernel.org ([198.145.29.99]:43482 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727231AbgAMIki (ORCPT ); Mon, 13 Jan 2020 03:40:38 -0500 Received: from localhost.localdomain (unknown [106.200.247.255]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A4C5D207E0; Mon, 13 Jan 2020 08:40:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1578904837; bh=1qv/uiqU+lvGy4vNbaTZDSE+L9LCBmyo2jSjlXzCaFY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LE2FTxi8KP8KWNCs7FOLql20SYThhwNY5bp18tlM/U2vFrjt3J882AzBQsZdewcQK GF7hDywxp2IdeiIK8yO1BgSwVCSJ8FV7uyFGkurQ52xbxrdZsY1h9ac5BEYfXAhSV/ N3XywRwbmQ64mcf2vuAXcRfJ9viEPIEI8zd1GYNY= From: Vinod Koul To: Mathias Nyman , Greg Kroah-Hartman Cc: linux-arm-msm@vger.kernel.org, Bjorn Andersson , Vinod Koul , Yoshihiro Shimoda , Christian Lamparter , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v6 4/5] usb: renesas-xhci: allow multiple firmware versions Date: Mon, 13 Jan 2020 14:10:04 +0530 Message-Id: <20200113084005.849071-5-vkoul@kernel.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200113084005.849071-1-vkoul@kernel.org> References: <20200113084005.849071-1-vkoul@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Allow multiple firmware file versions in table and load them in increasing order as we find them in the file system. Signed-off-by: Vinod Koul Cc: Yoshihiro Shimoda Cc: Christian Lamparter --- drivers/usb/host/xhci-pci-renesas.c | 45 +++++++++++++++++++++++++++-- 1 file changed, 43 insertions(+), 2 deletions(-) diff --git a/drivers/usb/host/xhci-pci-renesas.c b/drivers/usb/host/xhci-pci-renesas.c index 1d073c5637c4..fe95487ca888 100644 --- a/drivers/usb/host/xhci-pci-renesas.c +++ b/drivers/usb/host/xhci-pci-renesas.c @@ -73,13 +73,20 @@ static const struct renesas_fw_entry { * - uPD720201 ES 2.0 sample whose revision ID is 2. * - uPD720201 ES 2.1 sample & CS sample & Mass product, ID is 3. * - uPD720202 ES 2.0 sample & CS sample & Mass product, ID is 2. + * + * Entry expected_version should be kept in decreasing order for a + * chip, so that driver will pick latest version and if that fails + * then next one will be picked */ { "K2013080.mem", 0x0014, 0x02, 0x2013 }, + { "K2026090.mem", 0x0014, 0x03, 0x2026 }, { "K2013080.mem", 0x0014, 0x03, 0x2013 }, + { "K2026090.mem", 0x0015, 0x02, 0x2026 }, { "K2013080.mem", 0x0015, 0x02, 0x2013 }, }; MODULE_FIRMWARE("K2013080.mem"); +MODULE_FIRMWARE("K2026090.mem"); static const struct renesas_fw_entry *renesas_needs_fw_dl(struct pci_dev *dev) { @@ -100,6 +107,24 @@ static const struct renesas_fw_entry *renesas_needs_fw_dl(struct pci_dev *dev) return NULL; } +static const struct +renesas_fw_entry *renesas_get_next_entry(struct pci_dev *dev, + const struct renesas_fw_entry *entry) +{ + const struct renesas_fw_entry *next_entry; + size_t i; + + for (i = 0; i < ARRAY_SIZE(renesas_fw_table); i++) { + next_entry = &renesas_fw_table[i]; + if (next_entry->device == dev->device && + next_entry->revision == dev->revision && + next_entry->expected_version < entry->expected_version) + return next_entry; + } + + return NULL; +} + static int renesas_fw_download_image(struct pci_dev *dev, const u32 *fw, size_t step) @@ -700,13 +725,29 @@ static void renesas_fw_callback(const struct firmware *fw, struct renesas_fw_ctx *ctx = context; struct pci_dev *pdev = ctx->pdev; struct device *parent = pdev->dev.parent; + const struct renesas_fw_entry *next_entry; bool rom; int err; if (!fw) { dev_err(&pdev->dev, "firmware failed to load\n"); - - goto cleanup; + /* + * we didn't find firmware, check if we have another + * entry for this device + */ + next_entry = renesas_get_next_entry(ctx->pdev, ctx->entry); + if (next_entry) { + ctx->entry = next_entry; + dev_dbg(&pdev->dev, "Found next entry, requesting: %s\n", + next_entry->firmware_name); + request_firmware_nowait(THIS_MODULE, 1, + next_entry->firmware_name, + &pdev->dev, GFP_KERNEL, + ctx, renesas_fw_callback); + return; + } else { + goto cleanup; + } } err = renesas_fw_verify(pdev, fw->data, fw->size); -- 2.24.1