Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753288AbbGGETU (ORCPT ); Tue, 7 Jul 2015 00:19:20 -0400 Received: from mga03.intel.com ([134.134.136.65]:3125 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750716AbbGGETM (ORCPT ); Tue, 7 Jul 2015 00:19:12 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.15,420,1432623600"; d="scan'208";a="519945485" Date: Tue, 7 Jul 2015 09:50:57 +0530 From: Vinod Koul To: Shengjiu Wang Cc: dan.j.williams@intel.com, dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] dmaengine: imx-sdma: Add device to device support Message-ID: <20150707042057.GH11002@localhost> References: <1435048974-23700-1-git-send-email-shengjiu.wang@freescale.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1435048974-23700-1-git-send-email-shengjiu.wang@freescale.com> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3291 Lines: 99 On Tue, Jun 23, 2015 at 04:42:54PM +0800, Shengjiu Wang wrote: > +static void sdma_set_watermarklevel_for_p2p(struct sdma_channel *sdmac) > +{ > + struct sdma_engine *sdma = sdmac->sdma; > + > + int lwml = sdmac->watermark_level & 0xff; > + int hwml = (sdmac->watermark_level >> 16) & 0xff; > + > + if (sdmac->event_id0 > 31) { > + sdmac->event_mask[0] |= 0; > + __set_bit(28, &sdmac->watermark_level); why not use set_bit(), you are modifying driver memory > + sdmac->event_mask[1] |= > + BIT(sdmac->event_id0 % 32); and then why not use set_bit() here too? > + } else { > + sdmac->event_mask[0] |= 0; > + sdmac->event_mask[1] |= > + BIT(sdmac->event_id0 % 32); > + } > + if (sdmac->event_id1 > 31) { > + sdmac->event_mask[1] |= 0; > + __set_bit(29, &sdmac->watermark_level); > + sdmac->event_mask[0] |= > + BIT(sdmac->event_id1 % 32); > + } else { > + sdmac->event_mask[1] |= 0; > + sdmac->event_mask[0] |= > + BIT(sdmac->event_id1 % 32); > + } pattern for eventidX is repeated, also in that we can make generic macro to handle and reduce code size > + > + /* > + * If LWML(src_maxburst) > HWML(dst_maxburst), we need > + * swap LWML and HWML of INFO(A.3.2.5.1), also need swap > + * r0(event_mask[1]) and r1(event_mask[0]). > + */ > + if (lwml > hwml) { > + sdmac->watermark_level &= ~0xff00ff; Magic number? > static int sdma_config_channel(struct dma_chan *chan) > { > struct sdma_channel *sdmac = to_sdma_chan(chan); > @@ -869,6 +945,12 @@ static int sdma_config_channel(struct dma_chan *chan) > sdma_event_enable(sdmac, sdmac->event_id0); > } > > + if (sdmac->event_id1) { > + if (sdmac->event_id1 >= sdmac->sdma->drvdata->num_events) > + return -EINVAL; > + sdma_event_enable(sdmac, sdmac->event_id1); > + } > + > switch (sdmac->peripheral_type) { > case IMX_DMATYPE_DSP: > sdma_config_ownership(sdmac, false, true, true); > @@ -887,19 +969,21 @@ static int sdma_config_channel(struct dma_chan *chan) > (sdmac->peripheral_type != IMX_DMATYPE_DSP)) { > /* Handle multiple event channels differently */ > if (sdmac->event_id1) { > - sdmac->event_mask[1] = BIT(sdmac->event_id1 % 32); > - if (sdmac->event_id1 > 31) > - __set_bit(31, &sdmac->watermark_level); > - sdmac->event_mask[0] = BIT(sdmac->event_id0 % 32); > - if (sdmac->event_id0 > 31) > - __set_bit(30, &sdmac->watermark_level); > - } else { > + if (sdmac->peripheral_type == IMX_DMATYPE_ASRC_SP || > + sdmac->peripheral_type == IMX_DMATYPE_ASRC) > + sdma_set_watermarklevel_for_p2p(sdmac); > + } else > __set_bit(sdmac->event_id0, sdmac->event_mask); > - } > + > /* Watermark Level */ > sdmac->watermark_level |= sdmac->watermark_level; > /* Address */ > - sdmac->shp_addr = sdmac->per_address; > + if (sdmac->direction == DMA_DEV_TO_DEV) { Okay the direction is depreciated, so can you store both source and destination and use them based on direction in prepare() Also I see driver is not doing this, so while at it, can you fix this is current code as well -- ~Vinod -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/