[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <6236d3cb-fbf2-4a41-a84a-276aa8079b9a@arm.com>
Date: Fri, 2 May 2025 14:36:50 +0100
From: Robin Murphy <robin.murphy@....com>
To: Jens Wiklander <jens.wiklander@...aro.org>, linux-kernel@...r.kernel.org,
linux-media@...r.kernel.org, dri-devel@...ts.freedesktop.org,
linaro-mm-sig@...ts.linaro.org, op-tee@...ts.trustedfirmware.org,
linux-arm-kernel@...ts.infradead.org
Cc: Olivier Masse <olivier.masse@....com>,
Thierry Reding <thierry.reding@...il.com>, Yong Wu <yong.wu@...iatek.com>,
Sumit Semwal <sumit.semwal@...aro.org>,
Benjamin Gaignard <benjamin.gaignard@...labora.com>,
Brian Starkey <Brian.Starkey@....com>, John Stultz <jstultz@...gle.com>,
"T . J . Mercier" <tjmercier@...gle.com>,
Christian König <christian.koenig@....com>,
Sumit Garg <sumit.garg@...nel.org>, Matthias Brugger
<matthias.bgg@...il.com>,
AngeloGioacchino Del Regno <angelogioacchino.delregno@...labora.com>,
azarrabi@....qualcomm.com, Simona Vetter <simona.vetter@...ll.ch>,
Daniel Stone <daniel@...ishbar.org>,
Rouven Czerwinski <rouven.czerwinski@...aro.org>
Subject: Re: [PATCH v8 01/14] tee: tee_device_alloc(): copy dma_mask from
parent device
On 02/05/2025 10:59 am, Jens Wiklander wrote:
> If a parent device is supplied to tee_device_alloc(), copy the dma_mask
> field into the new device. This avoids future warnings when mapping a
> DMA-buf for the device.
That also sounds dodgy. If the parent device is the hardware device
physically performing the DMA, then that is the device which should be
passed to the DMA API. Trying to copy random bits of one device's
configuration to another device and hoping it will work is not robust -
not only is DMA-relevant information all over the place, including in
archdata and/or bus/IOMMU driver-private data, but it can also opens up
a whole can of subtle lifecycle issues...
> Signed-off-by: Jens Wiklander <jens.wiklander@...aro.org>
> Reviewed-by: Sumit Garg <sumit.garg@...nel.org>
> ---
> drivers/tee/tee_core.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/tee/tee_core.c b/drivers/tee/tee_core.c
> index d113679b1e2d..685afcaa3ea1 100644
> --- a/drivers/tee/tee_core.c
> +++ b/drivers/tee/tee_core.c
> @@ -922,6 +922,8 @@ struct tee_device *tee_device_alloc(const struct tee_desc *teedesc,
> teedev->dev.class = &tee_class;
> teedev->dev.release = tee_release_device;
> teedev->dev.parent = dev;
> + if (dev)
> + teedev->dev.dma_mask = dev->dma_mask;
...for instance, I don't see any obvious guarantee that "dev" can't go
away during the lifetime of "teedev" and leave this pointer dangling.
Thanks,
Robin.
>
> teedev->dev.devt = MKDEV(MAJOR(tee_devt), teedev->id);
>
Powered by blists - more mailing lists