Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp1765711ybi; Thu, 20 Jun 2019 03:27:09 -0700 (PDT) X-Google-Smtp-Source: APXvYqworkka1FiGdygaRTILQR0nEWw/fAEJuzFiuKJiAlE1cLFfpd36jR1eWE68WqNx18hKCbCR X-Received: by 2002:a17:902:bc83:: with SMTP id bb3mr103383174plb.56.1561026429663; Thu, 20 Jun 2019 03:27:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561026429; cv=none; d=google.com; s=arc-20160816; b=xEeyXTaEeL1h2Odqi6hE46HiqQaUFRmBh8m8pAkOHNnGMX186QtWovVCy35uQoMIqt ZKSzvAXyNIS5Xp2B/Q/hL1jFt6zP59gtBdKlOP8uz406jyQx5fWxs8pCqMavzaGVPlaQ WKSKT+OAgFFkf3QgNANqElxxHazv+ZXizGZkikM9mAuorNk8Yft3Gqiw5iYWxkSfkPrn mQ4lbogD5qHImKsTriNJmCDd2bVdR3YXIAK255EwamCO4LMHOjkL74XcZ5So8zW8jDAk GydASX9+1y6yh+pDifdYlpgG2j28F6quTTVJ+7vltP4wBSy4sZ99tHxHkBpxnbm4Rc56 1a7w== 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=uCEUR0kVP8IR+zHdqhFnR9uGbmm71wKvhD4LeXnNpqDoo/hn5+JC1xSsLdvR3iQkNB zwbS1Jc2dZYGzcVNtpi7Q2+gm4L7JDVTTfmcCLttbpxyrgLLNW9mOikzyfN9MaLr0eSZ FQXq2uO2cDx1vUZ4w++bfvztDGJjcs8AyvOKlJ8st9MHVIjrRZ8VevVwoHk+o70QN0W/ OKAbBcuibytIuwwOwqDsLcvDrxdIql3ZM2dnnQQTmezh1LfM1TAVhCsA+xxxXBZnwnTV Q9HkN21q7rEcFTZb4O0t9TCeCJXB+nFFDaZwM6hzss0nNVDUHdHcC057TeY9U7GnhuTi QNVw== 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-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 65si9444196pfg.241.2019.06.20.03.26.53; Thu, 20 Jun 2019 03:27:09 -0700 (PDT) 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=zNC8vD1D; 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 S1731532AbfFTKZg (ORCPT + 99 others); Thu, 20 Jun 2019 06:25:36 -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 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.c | 39 +++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) 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, -- 2.20.1