lkml.org 
[lkml]   [2019]   [Jun]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
SubjectRe: [PATCH v2 5/5] usb: xhci: allow multiple firmware versions
Date
On Friday, June 21, 2019 10:59:13 AM CEST Vinod Koul wrote:
> 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 <vkoul@kernel.org>
> Cc: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
> Cc: Christian Lamparter <chunkeey@googlemail.com>
> ---
> drivers/usb/host/xhci-pci.c | 46 +++++++++++++++++++++++++++++++++++--
> 1 file changed, 44 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/usb/host/xhci-pci.c b/drivers/usb/host/xhci-pci.c
> index 771948ce3d38..1fb890984d6d 100644
> --- a/drivers/usb/host/xhci-pci.c
> +++ b/drivers/usb/host/xhci-pci.c
> @@ -336,13 +336,19 @@ 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 for a
> + * chip, so that driver will pick first version and if that fails
> + * then next one will be picked

Wouldn't it be better to do that in reverse order and try the latest
firmware first? And then fall back to the older ones?

> */
> { "K2013080.mem", 0x0014, 0x02, 0x2013 },
> { "K2013080.mem", 0x0014, 0x03, 0x2013 },
> + { "K2026090.mem", 0x0014, 0x03, 0x2026 },
> { "K2013080.mem", 0x0015, 0x02, 0x2013 },
The uPD720202 (ProductID 0x0015 with rev 0x02) also
works with the K2026090.mem I found online.

so,

+ { "K2026090.mem", 0x0015, 0x02, 0x2026 },

> };
>
> MODULE_FIRMWARE("K2013080.mem");
> +MODULE_FIRMWARE("K2026090.mem");
>
> static const struct renesas_fw_entry *renesas_needs_fw_dl(struct pci_dev *dev)
> {
> @@ -363,6 +369,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)
> @@ -709,6 +733,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,
> @@ -968,13 +993,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);
> @@ -1072,6 +1113,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,
>




\
 
 \ /
  Last update: 2019-06-21 21:47    [W:0.084 / U:0.456 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site