From patchwork Thu Jun 20 10:21:54 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vinod Koul X-Patchwork-Id: 167315 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp1884201ilk; Thu, 20 Jun 2019 03:25:37 -0700 (PDT) X-Google-Smtp-Source: APXvYqwjSu93FbWZGoohbWxlj0M9DpODb0RRpmTe33mA9Ihe64AgFwrwCJ5PH40u2E9Zk3y64A4Q X-Received: by 2002:a63:6883:: with SMTP id d125mr12414124pgc.281.1561026337039; Thu, 20 Jun 2019 03:25:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561026337; cv=none; d=google.com; s=arc-20160816; b=z+rIMFFRUCwCFinH5Fg3GaxdNjXJOH3pCiAC3HcXg6xNEX0c0mF4xxKhn2KOZDQqiC b2QbsSpiZXVRCZjzrpV7l9MHWb6aSjuT42jHTRXVVQ7UjdBOd8DNC6tJa6/WZ0nbrMt/ vprgzp5Ps+iOE0jPKz9SdJqmE8Q/wkWlairqLJprCelbUd5gMewmDypeQ0id7eky81A+ gSkxFwc3IdXLGvYNchsetP1uPgb6ca0Wr2RBU7K3swevLeRVTu6sla7pAErsqWYc1o5P HCgjUqECWq4iS6tiIUfY9HL+SyvZ9QI5STQS5Z9tbA4RW2CAmDMO3HlXairGFy9jPFau foIw== 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=tf7FhBB3Zzh6UMrdfLuU1/x5SPVTtcn1BH3VAZKCYFo=; b=opuBk70A5DXjA+V9cO9WinXAye0Hh6ObJWNy1IME1iUI0kIU6Y3fLInzdmWV6GkXf1 PMrmvfiQ23VyNzcZ5l4cKwo67hwi+MThRCBQtpx73hkoUiaFU5fsNF+SCzo4awAvWZyr kxnSx5MbaQI8CBk404uMAM71czLCnH92syfdrfKcr14PJ1FD2wHoJFnWmCvoTiL5dOrJ /MefMsk78iAuxex5IV5iU7gkxpPLdSQIi+EqaptPakIn9j/Q6GNfrQj/FyKyHuqiQ8+z 4cL9kb8jX+sMPfxKvAHv/n2OBAsUu+WiOu5SCn78N8wxjniXxaSszerBT+0L0U9yRfGp al8g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=zNC8vD1D; spf=pass (google.com: best guess record for domain of linux-usb-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-usb-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 g24si5394640pgj.197.2019.06.20.03.25.36; Thu, 20 Jun 2019 03:25:37 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-usb-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=zNC8vD1D; spf=pass (google.com: best guess record for domain of linux-usb-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-usb-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 S1731511AbfFTKZf (ORCPT + 5 others); Thu, 20 Jun 2019 06:25:35 -0400 Received: from mail.kernel.org ([198.145.29.99]:50048 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731491AbfFTKZe (ORCPT ); Thu, 20 Jun 2019 06:25:34 -0400 Received: from localhost.localdomain (unknown [106.201.116.189]) (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 91C7E206BA; Thu, 20 Jun 2019 10:25:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1561026333; bh=wDwRd0hEpSkvmEKJfBABhPciAsp8oGwr7W3yIBEHFAQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zNC8vD1Dn7oboJiVKACw/UYh/Fc4TiqQG/Vf5XOuVjiKc7FNv0AVEC/0bWOrcdeJY BV9vV8bhqA9n61R8/GD2QyJxAXagQflKF/lZVRjJBOWw4rnV8i9YFYcCQ/wtrX6Apt HH/4CMv1S488q0egYKrgyxQQQ055FC73DgPk7F/Y= From: Vinod Koul To: Mathias Nyman , Greg Kroah-Hartman Cc: linux-arm-msm@vger.kernel.org, Bjorn Andersson , Vinod Koul , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Yoshihiro Shimoda , Christian Lamparter Subject: [PATCH 5/5] usb: xhci: allow multiple firmware versions Date: Thu, 20 Jun 2019 15:51:54 +0530 Message-Id: <20190620102154.20805-6-vkoul@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190620102154.20805-1-vkoul@kernel.org> References: <20190620102154.20805-1-vkoul@kernel.org> MIME-Version: 1.0 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@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.c | 39 +++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) -- 2.20.1 diff --git a/drivers/usb/host/xhci-pci.c b/drivers/usb/host/xhci-pci.c index 3574afac44c5..2ee9e6bbabcb 100644 --- a/drivers/usb/host/xhci-pci.c +++ b/drivers/usb/host/xhci-pci.c @@ -333,9 +333,12 @@ 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 increasing order */ { "K2013080.mem", 0x0014, 0x02, 0x2013 }, { "K2013080.mem", 0x0014, 0x03, 0x2013 }, + { "K2026090.mem", 0x0014, 0x03, 0x2026 }, { "K2013080.mem", 0x0015, 0x02, 0x2013 }, }; @@ -358,6 +361,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) @@ -723,6 +744,7 @@ struct renesas_fw_ctx { struct pci_dev *pdev; const struct pci_device_id *id; bool resume; + const struct renesas_fw_entry *entry; }; static int xhci_pci_probe(struct pci_dev *pdev, @@ -982,6 +1004,7 @@ 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 = -ENOENT; @@ -1035,6 +1058,21 @@ static void renesas_fw_callback(const struct firmware *fw, } } else { dev_err(&pdev->dev, "firmware failed to load (%d).", err); + /* + * 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; + } } dev_info(&pdev->dev, "Unloading driver"); @@ -1096,6 +1134,7 @@ static int renesas_fw_download_to_hw(struct pci_dev *pdev, ctx->pdev = pdev; ctx->resume = do_resume; ctx->id = id; + ctx->entry = entry; pci_dev_get(pdev); err = request_firmware_nowait(THIS_MODULE, 1, entry->firmware_name,