From: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
To: Robert Schlabbach <robert_s@gmx.net>
Cc: linux-media@vger.kernel.org
Subject: Re: [PATCH 2/2] media: si2157: Add optional firmware download
Date: Wed, 8 Dec 2021 09:52:00 +0100 [thread overview]
Message-ID: <20211208095200.6dfe2610@coco.lan> (raw)
In-Reply-To: <trinity-42d6e25d-b5bb-425c-a25a-ef6e758e216c-1638918425561@3c-app-gmx-bap19>
Em Wed, 8 Dec 2021 00:07:05 +0100
Robert Schlabbach <robert_s@gmx.net> escreveu:
> Von: "Mauro Carvalho Chehab" <mchehab+huawei@kernel.org>
> > This patch seems too risky. While I don't know the specifics of this
> > specific chipset, usually the ROM is on a separate chip that may or
> > may not be present. It may even have an unusable or problematic
> > firmware, depending on when the firmware was flashed.
>
> Hi Mauro, thanks for your review. Could you help me understand what
> risk you mean?
>
> Before this change _all_ users of this driver had to rely on the ROM
> firmware, because the driver simply never downloaded any firmware
> patches into it.
>
> With my change, the following scenarios are possible:
>
> 1. The user has no si2157 firmware patch file in /lib/firmware. That
> will probably be the case for the vast majority of users, as this
> file is not found e.g. in linux-firmware.git.
> In this case the device will continue to work just as it did before,
> no regressions, no improvements.
>
> 2. The user has a valid si2157 firmware patch file in /lib/firmware,
> which is downloaded into the si2157. Should the user experience any
> issues with the updated firmware (which I think is rather unlikely,
> as I would expect SiLabs to have revoked it otherwise), simply
> deleting the firmware patch file from /lib/firmware will cure it
> and revert to scenario 1 above.
>
> 3. The user has an invalid si2157 firmware patch file in /lib/firmware,
> which looks "right" (to the file size check that's already been in
> the driver), but does not fit the si2157. I found that in this case,
> the si2157 will just operate with the original ROM firmware, i.e.
> also yield the same result as scenario 1 above.
>
> I have tested all 3 scenarios on my Hauppauge WinTV-QuadHD, and the
> result was a fully functional tuner in all cases. I haven't managed to
> produce a scenario where things broke.
>
> Could you sketch what risk you still see of things breaking/regressing
> with my patch?
The issue is that you tested it only on Hauppauge WinTV-QuadHD,
which seems to have an eeprom where the firmware is stored, based on
your report.
See, while the technical docs for this device are not publicity
available, the block diagram for this device on its "advertising"
datasheet:
https://media.digikey.com/pdf/Data%20Sheets/Silicon%20Laboratories%20PDFs/Si2157.pdf
Doesn't show any internal ROM/eeprom. So, it sounds to me that
either some external rom chip is needed or its firmware should
load via I2C.
While I'm not concerned about Hauppauge devices, there are a lot of
others manufacturers that won't add any optional eeproms, in order
to save a couple of bucks.
So, my main concern here is with regards to other devices that
are using si2157 driver. Among those:
- Some may have no eeproms;
- Some may have an eeprom with compatible firmware;
- Some may have an eeprom with a too old firmware.
The above scenarios don't have any relationship with the chip_id.
They actually depend on the device's release date and if the
manufacturer spent an extra money to have a device with an eeprom
and/or cared enough to update the firmware on its manufacturing
process.
Also, if I remember well, with some versions of the firmware,
DVB-C won't work, due to incompatibility between the Linux driver
and the firmware version.
On other words, the only way to ensure that the device will
be in sane state and be fully supported by the driver is to
load a known-to work firmware.
---
Back to your patch...
Do you have access to all the technical datasheet and
application notes for all chips supported by this driver?
If you have, could you please describe why only SI2157_A30
is safe with regards to firmware?
If not, then checking for chip_id == SI2157_A30 makes no
sense.
The logic should, instead, do something similar to this:
#define FIRMWARE_MIN_VERSION 0x123456 // FIXME: add something here
unsigned int firmware_version;
ret = request_firmware(&fw, fw_name, &client->dev);
if (ret) {
/* Perhaps something else is needed before querying firmware version */
/* query firmware version */
memcpy(cmd.args, "\x11", 1);
cmd.wlen = 1;
cmd.rlen = 10;
ret = si2157_cmd_execute(client, &cmd);
if (ret) {
dev_err(&client->dev,
"firmware file '%s' not found and no firmware at eeprom\n",
fw_name);
}
firmware_version = cmd.args[6] << 16 + cmd.args[7] << 8 + cmd.args[8];
if (firmware_version < FIRMWARE_MIN_VERSION) {
dev_err(&client->dev,
"firmware file '%s' not found and eeprom firmware version %c.%c.%c is too old\n",
cmd.args[6], cmd.args[7], cmd.args[8], fw_name);
goto err;
}
dev_err(&client->dev,
"firmware file '%s' not found, using firmware version %c.%c.%c from EEPROM.\n",
cmd.args[6], cmd.args[7], cmd.args[8], fw_name);
}
Thanks,
Mauro
next prev parent reply other threads:[~2021-12-08 8:52 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-01 21:10 [PATCH 2/2] media: si2157: Add optional firmware download Robert Schlabbach
2021-12-06 14:00 ` Mauro Carvalho Chehab
2021-12-07 23:07 ` Aw: " Robert Schlabbach
2021-12-08 8:52 ` Mauro Carvalho Chehab [this message]
2021-12-08 15:42 ` Robert Schlabbach
2021-12-08 10:13 ` [PATCH 0/3] media: si2157: rework firmware load logic Mauro Carvalho Chehab
2021-12-08 10:13 ` [PATCH 1/3] media: si2157: move firmware load to a separate function Mauro Carvalho Chehab
2021-12-08 16:40 ` Robert Schlabbach
2021-12-08 17:03 ` Mauro Carvalho Chehab
2021-12-08 10:13 ` [PATCH 2/3] media: si2157: Add optional firmware download Mauro Carvalho Chehab
2021-12-08 16:45 ` Robert Schlabbach
2021-12-08 17:09 ` Mauro Carvalho Chehab
2021-12-08 10:13 ` [PATCH 3/3] media: si2157: rework the firmware load logic Mauro Carvalho Chehab
2021-12-08 22:37 ` Robert Schlabbach
2021-12-09 11:34 ` Mauro Carvalho Chehab
2021-12-09 19:37 ` Robert Schlabbach
2021-12-10 6:45 ` Mauro Carvalho Chehab
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20211208095200.6dfe2610@coco.lan \
--to=mchehab+huawei@kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=robert_s@gmx.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).