Re: [char-misc-next V3] mei: send OS type to the FW

From: Greg Kroah-Hartman
Date: Thu Nov 10 2016 - 10:32:26 EST


On Thu, Nov 10, 2016 at 06:07:36PM +0200, Tomas Winkler wrote:
> From: Alexander Usyskin <alexander.usyskin@xxxxxxxxx>
>
> Tell the FW that we are running a sane OS and TPM2_ChangeEPS()
> is supported. This workaround was added to support other broken OS
> and we need to follow here. The command is sent just once at the boot time.
>
> Signed-off-by: Tomas Winkler <tomas.winkler@xxxxxxxxx>
> Signed-off-by: Alexander Usyskin <alexander.usyskin@xxxxxxxxx>
> ---
> V2: 1. Use endain annotation
> 2. Drop bitfields
> 3. Drop trace dev_dbg out from the hook function
> 4. Add error code to failure info message
> V3: mkhi header structure should be __packed
>
> drivers/misc/mei/bus-fixup.c | 95 ++++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 95 insertions(+)
>
> diff --git a/drivers/misc/mei/bus-fixup.c b/drivers/misc/mei/bus-fixup.c
> index 9e10d86e3887..a9226d809b17 100644
> --- a/drivers/misc/mei/bus-fixup.c
> +++ b/drivers/misc/mei/bus-fixup.c
> @@ -38,6 +38,9 @@ static const uuid_le mei_nfc_info_guid = MEI_UUID_NFC_INFO;
> #define MEI_UUID_WD UUID_LE(0x05B79A6F, 0x4628, 0x4D7F, \
> 0x89, 0x9D, 0xA9, 0x15, 0x14, 0xCB, 0x32, 0xAB)
>
> +#define MEI_UUID_MKHIF_FIX UUID_LE(0x55213584, 0x9a29, 0x4916, \
> + 0xba, 0xdf, 0xf, 0xb7, 0xed, 0x68, 0x2a, 0xeb)
> +
> #define MEI_UUID_ANY NULL_UUID_LE
>
> /**
> @@ -69,6 +72,97 @@ static void blacklist(struct mei_cl_device *cldev)
> cldev->do_match = 0;
> }
>
> +#define OSTYPE_LINUX 2
> +struct mei_os_ver {
> + __le16 build;
> + __le16 reserved1;
> + u8 os_type;
> + u8 major;
> + u8 minor;
> + u8 reserved2;
> +} __packed;
> +
> +#define MKHI_FEATURE_PTT 0x10
> +
> +struct mkhi_rule_id {
> + __le16 rule_type;
> + u8 feature_id;
> + u8 reserved;
> +} __packed;
> +
> +struct mkhi_fwcaps {
> + struct mkhi_rule_id id;
> + u8 len;
> + u8 data[0];
> +} __packed;
> +
> +#define MKHI_FWCAPS_GROUP_ID 0x3
> +#define MKHI_FWCAPS_SET_OS_VER_APP_RULE_CMD 6
> +struct mkhi_msg_hdr {
> + u8 group_id;
> + u8 command;
> + u8 reserved;
> + u8 result;
> +} __packed;
> +
> +struct mkhi_msg {
> + struct mkhi_msg_hdr hdr;
> + u8 data[0];
> +} __packed;
> +
> +static int mei_osver(struct mei_cl_device *cldev)
> +{
> + int ret;
> + const size_t size = sizeof(struct mkhi_msg_hdr) +
> + sizeof(struct mkhi_fwcaps) +
> + sizeof(struct mei_os_ver);
> + size_t length = 8;
> + char buf[size];
> + struct mkhi_msg *req;
> + struct mkhi_fwcaps *fwcaps;
> + struct mei_os_ver *os_ver;
> + unsigned int mode = MEI_CL_IO_TX_BLOCKING | MEI_CL_IO_TX_INTERNAL;
> +
> + memset(buf, 0, size);
> +
> + req = (struct mkhi_msg *)buf;
> + req->hdr.group_id = MKHI_FWCAPS_GROUP_ID;
> + req->hdr.command = MKHI_FWCAPS_SET_OS_VER_APP_RULE_CMD;
> +
> + fwcaps = (struct mkhi_fwcaps *)req->data;
> +
> + fwcaps->id.rule_type = 0x0;
> + fwcaps->id.feature_id = MKHI_FEATURE_PTT;
> + fwcaps->len = sizeof(*os_ver);
> + os_ver = (struct mei_os_ver *)fwcaps->data;
> + os_ver->os_type = OSTYPE_LINUX;
> +
> + ret = __mei_cl_send(cldev->cl, buf, size, mode);
> + if (ret < 0)
> + return ret;
> +
> + ret = __mei_cl_recv(cldev->cl, buf, length);
> + if (ret < 0)
> + return ret;
> +
> + return 0;
> +}
> +
> +static void mei_mkhi_fix(struct mei_cl_device *cldev)
> +{
> + int ret;
> +
> + ret = mei_cldev_enable(cldev);
> + if (ret)
> + return;
> +
> + ret = mei_osver(cldev);
> + if (ret)
> + dev_info(&cldev->dev, "OS version command failed %d\n", ret);

It's an error, make it dev_err() please.