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: <ZmCP6o+NgCtINEW4@lizhi-Precision-Tower-5810>
Date: Wed, 5 Jun 2024 12:18:50 -0400
From: Frank Li <Frank.li@....com>
To: Dave Stevenson <dave.stevenson@...pberrypi.com>
Cc: Rob Herring <robh@...nel.org>, Krzysztof Kozlowski <krzk+dt@...nel.org>,
	Conor Dooley <conor+dt@...nel.org>,
	Florian Fainelli <florian.fainelli@...adcom.com>,
	Broadcom internal kernel review list <bcm-kernel-feedback-list@...adcom.com>,
	Ray Jui <rjui@...adcom.com>, Scott Branden <sbranden@...adcom.com>,
	Vinod Koul <vkoul@...nel.org>, Maxime Ripard <mripard@...nel.org>,
	Maarten Lankhorst <maarten.lankhorst@...ux.intel.com>,
	Thomas Zimmermann <tzimmermann@...e.de>,
	David Airlie <airlied@...il.com>, Daniel Vetter <daniel@...ll.ch>,
	Ulf Hansson <ulf.hansson@...aro.org>,
	Mark Brown <broonie@...nel.org>, Christoph Hellwig <hch@....de>,
	Marek Szyprowski <m.szyprowski@...sung.com>,
	Robin Murphy <robin.murphy@....com>,
	Liam Girdwood <lgirdwood@...il.com>,
	Jaroslav Kysela <perex@...ex.cz>, Takashi Iwai <tiwai@...e.com>,
	Vladimir Murzin <vladimir.murzin@....com>,
	Phil Elwell <phil@...pberrypi.com>,
	Stefan Wahren <wahrenst@....net>,
	Serge Semin <Sergey.Semin@...kalelectronics.ru>,
	devicetree@...r.kernel.org, linux-rpi-kernel@...ts.infradead.org,
	linux-arm-kernel@...ts.infradead.org, linux-kernel@...r.kernel.org,
	dmaengine@...r.kernel.org, dri-devel@...ts.freedesktop.org,
	linux-mmc@...r.kernel.org, linux-spi@...r.kernel.org,
	iommu@...ts.linux.dev, linux-sound@...r.kernel.org,
	Stefan Wahren <stefan.wahren@...e.com>
Subject: Re: [PATCH 05/18] dmaengine: bcm2835: move CB final extra info
 generation into function

On Fri, May 24, 2024 at 07:26:49PM +0100, Dave Stevenson wrote:
> From: Stefan Wahren <stefan.wahren@...e.com>
> 
> Similar to the info generation, generate the final extra info with a
> separate function. This is necessary to introduce other platforms
> with different info bits.

Each patch commit is independent. 

Introduce common help function to generate the final extra info to reduce
duplicate codes in each DMA operation.


> 
> Signed-off-by: Stefan Wahren <wahrenst@....net>
> Signed-off-by: Dave Stevenson <dave.stevenson@...pberrypi.com>
> ---
>  drivers/dma/bcm2835-dma.c | 34 ++++++++++++++++++++++++++++------
>  1 file changed, 28 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/dma/bcm2835-dma.c b/drivers/dma/bcm2835-dma.c
> index 7cef7ff89575..ef452ebb3c15 100644
> --- a/drivers/dma/bcm2835-dma.c
> +++ b/drivers/dma/bcm2835-dma.c
> @@ -229,6 +229,29 @@ static u32 bcm2835_dma_prepare_cb_info(struct bcm2835_chan *c,
>  	return result;
>  }
>  
> +static u32 bcm2835_dma_prepare_cb_extra(struct bcm2835_chan *c,
> +					enum dma_transfer_direction direction,
> +					bool cyclic, bool final,
> +					unsigned long flags)
> +{
> +	u32 result = 0;
> +
> +	if (cyclic) {
> +		if (flags & DMA_PREP_INTERRUPT)
> +			result |= BCM2835_DMA_INT_EN;
> +	} else {
> +		if (!final)
> +			return 0;
> +
> +		result |= BCM2835_DMA_INT_EN;
> +
> +		if (direction == DMA_MEM_TO_MEM)
> +			result |= BCM2835_DMA_WAIT_RESP;
> +	}


move if (direction == DMA_MEM_TO_MEM) outof else branch. 
DMA_MEM_TO_MEM is impossible for cyclic. Reduce if level can help
easy to follow up.


	if (cyclic)
		...
	else
		...

	if (direction == DMA_MEM_TO_MEM)
		result |= BCM2835_DMA_WAIT_RESP; 



> +
> +	return result;
> +}
> +
>  static void bcm2835_dma_free_cb_chain(struct bcm2835_desc *desc)
>  {
>  	size_t i;
> @@ -644,7 +667,8 @@ static struct dma_async_tx_descriptor *bcm2835_dma_prep_dma_memcpy(
>  	struct bcm2835_chan *c = to_bcm2835_dma_chan(chan);
>  	struct bcm2835_desc *d;
>  	u32 info = bcm2835_dma_prepare_cb_info(c, DMA_MEM_TO_MEM, false);
> -	u32 extra = BCM2835_DMA_INT_EN | BCM2835_DMA_WAIT_RESP;
> +	u32 extra = bcm2835_dma_prepare_cb_extra(c, DMA_MEM_TO_MEM, false,
> +						 true, 0);
>  	size_t max_len = bcm2835_dma_max_frame_length(c);
>  	size_t frames;
>  
> @@ -675,7 +699,7 @@ static struct dma_async_tx_descriptor *bcm2835_dma_prep_slave_sg(
>  	struct bcm2835_desc *d;
>  	dma_addr_t src = 0, dst = 0;
>  	u32 info = bcm2835_dma_prepare_cb_info(c, direction, false);
> -	u32 extra = BCM2835_DMA_INT_EN;
> +	u32 extra = bcm2835_dma_prepare_cb_extra(c, direction, false, true, 0);
>  	size_t frames;
>  
>  	if (!is_slave_direction(direction)) {
> @@ -723,7 +747,7 @@ static struct dma_async_tx_descriptor *bcm2835_dma_prep_dma_cyclic(
>  	dma_addr_t src, dst;
>  	u32 info = bcm2835_dma_prepare_cb_info(c, direction,
>  					       buf_addr == od->zero_page);
> -	u32 extra = 0;
> +	u32 extra = bcm2835_dma_prepare_cb_extra(c, direction, true, true, 0);
>  	size_t max_len = bcm2835_dma_max_frame_length(c);
>  	size_t frames;
>  
> @@ -739,9 +763,7 @@ static struct dma_async_tx_descriptor *bcm2835_dma_prep_dma_cyclic(
>  		return NULL;
>  	}
>  
> -	if (flags & DMA_PREP_INTERRUPT)
> -		extra |= BCM2835_DMA_INT_EN;
> -	else
> +	if (!(flags & DMA_PREP_INTERRUPT))
>  		period_len = buf_len;
>  
>  	/*
> -- 
> 2.34.1
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ