[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <2FCD4AA0-9376-4238-995C-9C287A3FDF8D@live.com>
Date: Thu, 20 Feb 2025 17:23:51 +0000
From: Aditya Garg <gargaditya08@...e.com>
To: Thomas Zimmermann <tzimmermann@...e.de>
CC: "maarten.lankhorst@...ux.intel.com" <maarten.lankhorst@...ux.intel.com>,
"mripard@...nel.org" <mripard@...nel.org>, "airlied@...il.com"
<airlied@...il.com>, "simona@...ll.ch" <simona@...ll.ch>, Kerem Karabay
<kekrby@...il.com>, Atharva Tiwari <evepolonium@...il.com>, Linux Kernel
Mailing List <linux-kernel@...r.kernel.org>,
"dri-devel@...ts.freedesktop.org" <dri-devel@...ts.freedesktop.org>
Subject: Re: [PATCH 2/2] drm/tiny: add driver for Apple Touch Bars in x86 Macs
Hi
> On 19 Feb 2025, at 1:27 PM, Thomas Zimmermann <tzimmermann@...e.de> wrote:
>
> Hi
>
> Am 18.02.25 um 21:12 schrieb Aditya Garg:
>> Hi
>>
>> In continuation to my previous mail.
>>
>>>> +
>>>> +static int appletbdrm_send_msg(struct appletbdrm_device *adev, u32 msg)
>>>> +{
>>>> + struct appletbdrm_msg_simple_request *request;
>>>> + int ret;
>>>> +
>>>> + request = kzalloc(sizeof(*request), GFP_KERNEL);
>>>> + if (!request)
>>>> + return -ENOMEM;
>>>> +
>>>> + request->header.unk_00 = cpu_to_le16(2);
>>>> + request->header.unk_02 = cpu_to_le16(0x1512);
>>>> + request->header.size = cpu_to_le32(sizeof(*request) - sizeof(request->header));
>>>> + request->msg = msg;
>>>> + request->size = request->header.size;
>>>> +
>>>> + ret = appletbdrm_send_request(adev, &request->header, sizeof(*request));
>>>> +
>>>> + kfree(request);
>>> This is temporary data for the send operation and save to free here?
>> Probably yes. If I understand correctly, it’s needed to make the touchbar go into the display mode, from the hid keyboard mode.
>>
>> We here are doing the same as the Windows driver [1] for this does.
>>
>> [1] https://github.com/imbushuo/DFRDisplayKm/blob/master/src/DFRDisplayKm/include/Dfr.h#L3
>
> Yeah. My concern was that request is being freed while the USB send operation is still using it. But in the USB code, it doesn't look like that.
>
For this, we are using usb_bulk_msg [1] which is a synchronous function, so it only returns once the data is completely sent.
So IMO its safe to kfree(request); here.
[1] https://manpages.debian.org/jessie-backports/linux-manual-4.8/usb_bulk_msg.9
Powered by blists - more mailing lists