lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <YZIk6cVb7XibrMjf@pendragon.ideasonboard.com>
Date:   Mon, 15 Nov 2021 11:14:17 +0200
From:   Laurent Pinchart <laurent.pinchart@...asonboard.com>
To:     Arnd Bergmann <arnd@...nel.org>
Cc:     Vinod Koul <vkoul@...nel.org>, Arnd Bergmann <arnd@...db.de>,
        Andy Gross <agross@...nel.org>,
        Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
        Baolin Wang <baolin.wang7@...il.com>,
        Bjorn Andersson <bjorn.andersson@...aro.org>,
        Chunyan Zhang <zhang.lyra@...il.com>,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        Hyun Kwon <hyun.kwon@...inx.com>,
        Jaroslav Kysela <perex@...ex.cz>,
        Jon Hunter <jonathanh@...dia.com>,
        Lars-Peter Clausen <lars@...afoo.de>,
        Laxman Dewangan <ldewangan@...dia.com>,
        Manivannan Sadhasivam <mani@...nel.org>,
        Mark Brown <broonie@...nel.org>,
        Michal Simek <michal.simek@...inx.com>,
        Nicolas Saenz Julienne <nsaenz@...nel.org>,
        Orson Zhai <orsonzhai@...il.com>,
        Robert Jarzmik <robert.jarzmik@...e.fr>,
        Scott Branden <sbranden@...adcom.com>,
        Takashi Iwai <tiwai@...e.com>,
        Thierry Reding <thierry.reding@...il.com>,
        alsa-devel@...a-project.org, bcm-kernel-feedback-list@...adcom.com,
        dmaengine@...r.kernel.org, dri-devel@...ts.freedesktop.org,
        linux-arm-kernel@...ts.infradead.org,
        linux-arm-msm@...r.kernel.org, linux-kernel@...r.kernel.org,
        linux-mmc@...r.kernel.org, linux-mtd@...ts.infradead.org,
        linux-rpi-kernel@...ts.infradead.org, linux-serial@...r.kernel.org,
        linux-spi@...r.kernel.org, linux-staging@...ts.linux.dev,
        linux-tegra@...r.kernel.org
Subject: Re: [PATCH 08/11] dmaengine: xilinx_dpdma: stop using slave_id field

Hi Arnd,

Thank you for the patch.

On Mon, Nov 15, 2021 at 09:54:00AM +0100, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@...db.de>
> 
> The display driver wants to pass a custom flag to the DMA engine driver,
> which it started doing by using the slave_id field that was traditionally
> used for a different purpose.
> 
> As there is no longer a correct use for the slave_id field, it should
> really be removed, and the remaining users changed over to something
> different.
> 
> The new mechanism for passing nonstandard settings is using the
> .peripheral_config field, so use that to pass a newly defined structure
> here, making it clear that this will not work in portable drivers.
> 
> Signed-off-by: Arnd Bergmann <arnd@...db.de>
> ---
>  drivers/dma/xilinx/xilinx_dpdma.c  | 12 ++++++++----
>  drivers/gpu/drm/xlnx/zynqmp_disp.c |  9 +++++++--
>  include/linux/dma/xilinx_dpdma.h   | 11 +++++++++++
>  3 files changed, 26 insertions(+), 6 deletions(-)
>  create mode 100644 include/linux/dma/xilinx_dpdma.h
> 
> diff --git a/drivers/dma/xilinx/xilinx_dpdma.c b/drivers/dma/xilinx/xilinx_dpdma.c
> index ce5c66e6897d..e2c1ef7a659c 100644
> --- a/drivers/dma/xilinx/xilinx_dpdma.c
> +++ b/drivers/dma/xilinx/xilinx_dpdma.c
> @@ -12,6 +12,7 @@
>  #include <linux/clk.h>
>  #include <linux/debugfs.h>
>  #include <linux/delay.h>
> +#include <linux/dma/xilinx_dpdma.h>
>  #include <linux/dmaengine.h>
>  #include <linux/dmapool.h>
>  #include <linux/interrupt.h>
> @@ -1273,6 +1274,7 @@ static int xilinx_dpdma_config(struct dma_chan *dchan,
>  			       struct dma_slave_config *config)
>  {
>  	struct xilinx_dpdma_chan *chan = to_xilinx_chan(dchan);
> +	struct xilinx_dpdma_peripheral_config *pconfig;
>  	unsigned long flags;
>  
>  	/*
> @@ -1285,11 +1287,13 @@ static int xilinx_dpdma_config(struct dma_chan *dchan,
>  	spin_lock_irqsave(&chan->lock, flags);
>  
>  	/*
> -	 * Abuse the slave_id to indicate that the channel is part of a video
> -	 * group.
> +	 * Abuse the peripheral_config to indicate that the channel is part

Is it still an abuse, or is this now the right way to pass custom data
to the DMA engine driver ?

> +	 * of a video group.
>  	 */
> -	if (chan->id <= ZYNQMP_DPDMA_VIDEO2)
> -		chan->video_group = config->slave_id != 0;
> +	pconfig = config->peripheral_config;

This could be moved to the variable declaration above, up to you.

> +	if (chan->id <= ZYNQMP_DPDMA_VIDEO2 &&
> +	    config->peripheral_size == sizeof(*pconfig))

Silently ignoring a size mismatch isn't nice. Could we validate the size
at the beginning of the function and return an error ?

With these issues addressed,

Reviewed-by: Laurent Pinchart <laurent.pinchart@...asonboard.com>

> +		chan->video_group = pconfig->video_group;
>  
>  	spin_unlock_irqrestore(&chan->lock, flags);
>  
> diff --git a/drivers/gpu/drm/xlnx/zynqmp_disp.c b/drivers/gpu/drm/xlnx/zynqmp_disp.c
> index ff2b308d8651..11c409cbc88e 100644
> --- a/drivers/gpu/drm/xlnx/zynqmp_disp.c
> +++ b/drivers/gpu/drm/xlnx/zynqmp_disp.c
> @@ -24,6 +24,7 @@
>  
>  #include <linux/clk.h>
>  #include <linux/delay.h>
> +#include <linux/dma/xilinx_dpdma.h>
>  #include <linux/dma-mapping.h>
>  #include <linux/dmaengine.h>
>  #include <linux/module.h>
> @@ -1058,14 +1059,18 @@ static void zynqmp_disp_layer_set_format(struct zynqmp_disp_layer *layer,
>  	zynqmp_disp_avbuf_set_format(layer->disp, layer, layer->disp_fmt);
>  
>  	/*
> -	 * Set slave_id for each DMA channel to indicate they're part of a
> +	 * Set pconfig for each DMA channel to indicate they're part of a
>  	 * video group.
>  	 */
>  	for (i = 0; i < info->num_planes; i++) {
>  		struct zynqmp_disp_layer_dma *dma = &layer->dmas[i];
> +		struct xilinx_dpdma_peripheral_config pconfig = {
> +			.video_group = true,
> +		};
>  		struct dma_slave_config config = {
>  			.direction = DMA_MEM_TO_DEV,
> -			.slave_id = 1,
> +			.peripheral_config = &pconfig,
> +			.peripheral_size = sizeof(pconfig),
>  		};
>  
>  		dmaengine_slave_config(dma->chan, &config);
> diff --git a/include/linux/dma/xilinx_dpdma.h b/include/linux/dma/xilinx_dpdma.h
> new file mode 100644
> index 000000000000..83a1377f03f8
> --- /dev/null
> +++ b/include/linux/dma/xilinx_dpdma.h
> @@ -0,0 +1,11 @@
> +// SPDX-License-Identifier: GPL-2.0
> +#ifndef __LINUX_DMA_XILINX_DPDMA_H
> +#define __LINUX_DMA_XILINX_DPDMA_H
> +
> +#include <linux/types.h>
> +
> +struct xilinx_dpdma_peripheral_config {
> +	bool video_group;
> +};
> +
> +#endif /* __LINUX_DMA_XILINX_DPDMA_H */

-- 
Regards,

Laurent Pinchart

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ