Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754386AbbGJJHl (ORCPT ); Fri, 10 Jul 2015 05:07:41 -0400 Received: from mail-bn1bon0140.outbound.protection.outlook.com ([157.56.111.140]:42240 "EHLO na01-bn1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754304AbbGJJHb (ORCPT ); Fri, 10 Jul 2015 05:07:31 -0400 Authentication-Results: spf=fail (sender IP is 192.88.158.2) smtp.mailfrom=freescale.com; vger.kernel.org; dkim=none (message not signed) header.d=none; Date: Fri, 10 Jul 2015 15:58:38 +0800 From: Shengjiu Wang To: Vinod Koul CC: , , Subject: Re: [PATCH V2] dmaengine: imx-sdma: Add device to device support Message-ID: <20150710075836.GB14762@shlinux2> References: <20150710075807.GB836@localhost> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <20150710075807.GB836@localhost> User-Agent: Mutt/1.5.21 (2010-09-15) X-EOPAttributedMessage: 0 X-Microsoft-Exchange-Diagnostics: 1;BY2FFO11FD048;1:9ZJrja7k8rhV+KNb9cL8ltyJpTSAc1kc1QhyHquOqtgeOnOeqo0YhT0703Rq83IIamuAZKkI222pLuJkTi2N7S2PFqxE6/KjoHe8ArNaAOrlfmrSep95LRGxJ7PmbvwJa0u8SG14bC3Gs41wklXG8tqr5gcaUhuuKehRP30jGkEIVCUkymCy3FoEVqGpa7OTCZ9ojOLyvTqIpRAL+31s+U2bRwF2rdrWJ2CnN8nelLJCpKXxNlGGukF896p4wnbp25APg0MYT9EHiqtHIZqQWcuseY1b080bUEZrcLgh/yBshoCKHDPiChAu8xTIXvQoog83FPNuGzkbFOboH3lA1w== X-Forefront-Antispam-Report: CIP:192.88.158.2;CTRY:US;IPV:NLI;EFV:NLI;SFV:NSPM;SFS:(10019020)(6009001)(2980300002)(339900001)(24454002)(199003)(51704005)(189002)(110136002)(33656002)(6806004)(105606002)(47776003)(97756001)(189998001)(5001960100002)(76176999)(50986999)(54356999)(33716001)(87936001)(46102003)(86362001)(85426001)(106466001)(46406003)(2950100001)(77096005)(92566002)(62966003)(23726002)(77156002)(83506001)(104016003)(50466002)(4001350100001);DIR:OUT;SFP:1102;SCL:1;SRVR:BLUPR03MB280;H:az84smr01.freescale.net;FPR:;SPF:Fail;MLV:sfv;A:1;MX:1;LANG:en; X-Microsoft-Exchange-Diagnostics: 1;BLUPR03MB280;2:0rBvGhTbR6gRJe4HA5PZ4ojctUvbv0ihaE11zsmHH42okDO84GbexVn8asDiZvZB;3:EzjlJMjPCr7xV7YH5GeDYhMIcKajQ2DsGU3COtzHIgJF/HlOnNFHIYpzHMkby2ey865xrls7QJc1/U5GHP1DgFf18kQRppaTeMCE0/qcXlS40nYsoSy9dPYDo8v53+sN9uFDSEBaVL5jFZ4f/WgCRfRwvsHx/qDUjw/7C1G5UMYAHsfveXEHn9Q8SmPEXOXcygq63RzE5AeUdccux2812wUSe+UEG9GBg9qujYb7+aM=;25:PTE6wkv25QNVcuDYhHNUqqDxlBKSMlofL5HSS3thb+q2ZYvUrD6r2yLBXtflPD+2y1BDv5p/A1WLcH7tDmm+OnMqqEcjNWbD835gk2uXcKWqEqtDBQAFpmeBLNS6BaZYb7RkaEmXAtr72pNc7Mi2clgvb+r3JQP47ZINr5nhD4+S0Gal5oXErnvQSCIJ/Xp+N+Xb41oGB2xSxAAOqePmr+9hN1UsWWSEebEpmZN8SNQbUgpyFtiGnbEliSveiRo7FJzF8bGYL+6yZAGuBFvVBQ==;20:S21scEdOrWpLVuhrie+PmGn0OhM5UqWO03kKTj03N67MccbTWMkM3lFGA/lgZq9ZQ+4WPWgOruTCcHRpWvZSRFGrCykxh3F2gTaDfD9cZ3myMWTnDu1qFsSE0jzN/uFqBLOoCCl3+QS0WMBrp9iTRpXu7XW7ANR00zJdMRgmviwLvORDrTOBkSfEV+UeUgoU922ZUVG3gow3sJJ83TeipO7uNkPx6bIpYzBvoeRf1BdBc2K4wrPLjvsa794Gtmxpdlz6AKbXRkJu7zDQXudHAAxPWOo300D8r/IcjjyIdwy9X7dDchsi2iuU8JeNBYRO8O8AherOz5XEqKZ/A7vXRMrZxjkAHO5T9viseflUm7I= X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BLUPR03MB280; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(601004)(5005006)(3002001);SRVR:BLUPR03MB280;BCL:0;PCL:0;RULEID:;SRVR:BLUPR03MB280; X-Microsoft-Exchange-Diagnostics: 1;BLUPR03MB280;4:W5sjfwuFPX/BpgtFxqg3Uy6OLwceKh+fbfnhT2Cq6Bhr9LNzhQMX+5Exmc0XEwQpVd87SQ1JnsOcvL6x19FD04/LFlijpKK4kGOvPOV5y5zX3IJAZ6atU7LKs//+O2QiKTUAc/SjKqu7x8A2SCPKebQq2TEnz3rEtBWGFS17jryqTjwclRfQEfNVVC1C2igcTdMtbP+Y4q01PzIZuXWItsPjmMmXY0okzlmqyPkWimzDaigYGiDAmhuRXj+yIf7AZ2ZdHABhpwd1PJnT9d3oKbub2xkzBrUUKLCd+4iPbus= X-Forefront-PRVS: 06339BAE63 X-Microsoft-Exchange-Diagnostics: 1;BLUPR03MB280;23:HddT32bKYNKUT959JLG3/7rQCAfTcF5J18xa77LiK7nTPGxsbAbRg/PxcnYFnnAAfH4lO2TN/MNi7ZDVGSBxt5KMqbLojBh2Q7aIvk19etjr/EdHuxtxLyy65hky9XY7eZ8LasB3VKS+ipPV/G/UdgoP+x1Byln+ZCE9v/y76RRfkQQdcRyAHWgkAgRUx5fv2+XzNIaJqOHLIfePq0O9TRlwiw78JJmAMG43hGRr8uyIGu5rh4+3k/LMYaMgJ1VaHltK2tE6j6IREc1EWkjNY7fKbgNPm6//eSrdtX/UmOOfU716ehYHbP15lhCz7CIkm+ZYJOEibDOpxD1wfoOSYr5ef9yk520FIQabGzixIg3eFP384d4vFSPfYV/7OqDAzgD9Hzbf+cepKOkw87FeHNsGFqWZmln1uQ4YzT0zacM+J5/+LmXiIM78h3HX6ffSlGjmWAmToCk7c3gC/8YY3unA/3HIcjhLbyKJ8wjuCxT26TW+E0CYoxtbzBV6/tOQSFUYr2typ+YhNSWJ1323dsWAK5A8sh9/HeUAEFsd3GFIHVXdsS1Z5V+J6HpWUqTw+Erewvb0hPH38czGVYoEZK62bH0AMc/02hY1DVbwMase8Tr6bqbhOqh5vugoTEvAar1ZmxM738zpbPuiGiBuv2NfDoe7brUliLfgI9LqWUoNO+w3HIwEFnEoik2GsXVWOdN8LmxxyWGkGZVkMWdycU50ssSGB4qkFSKxhlrX7SlTY4VCiCw26rpK/nPXs+fLFG1MdOJ163iyeyo2nmOsowVVl7dKEO97KPAMLPOgru5qcMVHvL/IgD/qsttuOUH3eF7W6Pk2gHTtXmSGt6SJ9Kyc5mACgJJz/fKbCoQaTalVz59UkhaJBiakDG/NkWqgqUWCnCIaKq0+c8/0TiGH0IFOFkacj+q2OAs4Z2B5Y1M= X-Microsoft-Exchange-Diagnostics: 1;BLUPR03MB280;5:6rKeJxn9H9FPl7TDCGn65992WJG8YUZfWff5IeyrMGU4VQy9fvPb1+D+YRKpWjprHJPH/ZRXwU6FSqarpnFWjk2vgUWSHnJcWx0Y7vFH0Zx3lYVt7kR3rggQaGjojTyjrOujKF2T+/GAe2TTGBvwwQ==;24:G6Bl0T++XKW0HaFw2mTwpAbM7W0wqwiDE3SeG3ILrGumt49fGB50rF21rN7BRzapQ0YrOmjqkAri5PUVkSJ6NFho0DgYy+eXnNr/eCZ95JM=;20:ix5zDdqJ0F/cUcqgGAmFkf6mBZK1ucjWQmDmMippc9ZkVzF19tld09c6xLTeP5524PE3qQgMj+tINfJk7hZlyg== X-OriginatorOrg: freescale.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Jul 2015 09:07:29.3819 (UTC) X-MS-Exchange-CrossTenant-Id: 710a03f5-10f6-4d38-9ff4-a80b81da590d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=710a03f5-10f6-4d38-9ff4-a80b81da590d;Ip=[192.88.158.2];Helo=[az84smr01.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLUPR03MB280 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 4350 Lines: 117 On Fri, Jul 10, 2015 at 01:28:07PM +0530, Vinod Koul wrote: > On Tue, Jul 07, 2015 at 05:20:04PM +0800, Shengjiu Wang wrote: > > > +/* > > + * p_2_p watermark_level description > > + * Bits Name Description > > + * 0-7 Lower WML Lower watermark level > > + * 8 PS 1: Pad Swallowing > > + * 0: No Pad Swallowing > > + * 9 PA 1: Pad Adding > > + * 0: No Pad Adding > > + * 10 SPDIF If this bit is set both source > > + * and destination are on SPBA > > + * 11 Source Bit(SP) 1: Source on SPBA > > + * 0: Source on AIPS > > + * 12 Destination Bit(DP) 1: Destination on SPBA > > + * 0: Destination on AIPS > > + * 13-15 --------- MUST BE 0 > > + * 16-23 Higher WML HWML > > + * 24-27 N Total number of samples after > > + * which Pad adding/Swallowing > > + * must be done. It must be odd. > > + * 28 Lower WML Event(LWE) SDMA events reg to check for > > + * LWML event mask > > + * 0: LWE in EVENTS register > > + * 1: LWE in EVENTS2 register > > + * 29 Higher WML Event(HWE) SDMA events reg to check for > > + * HWML event mask > > + * 0: HWE in EVENTS register > > + * 1: HWE in EVENTS2 register > > + * 30 --------- MUST BE 0 > > + * 31 CONT 1: Amount of samples to be > > + * transferred is unknown and > > + * script will keep on > > + * transferring samples as long as > > + * both events are detected and > > + * script must be manually stopped > > + * by the application > > + * 0: The amount of samples to be > > + * transferred is equal to the > > + * count field of mode word > > + */ > > +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; > > + > > + __set_bit(sdmac->event_id0 % 32, &sdmac->event_mask[1]); > > + __set_bit(sdmac->event_id1 % 32, &sdmac->event_mask[0]); > > + > > + if (sdmac->event_id0 > 31) > > + __set_bit(28, &sdmac->watermark_level); > > + > > + if (sdmac->event_id1 > 31) > > + __set_bit(29, &sdmac->watermark_level); > > + > > + /* > > + * 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; > > + sdmac->watermark_level |= hwml; > > + sdmac->watermark_level |= lwml << 16; > > + swap(sdmac->event_mask[0], sdmac->event_mask[1]); > so typical practice is to define macros for these. For example above can be > defined as > #define SDMA_WATERMARK_LWML BIT(X) > #define SDMA_WATERMARK_PA BIT(Y) > > Then here you can say > sdmac->watermark_level &= SDMA_WATERMARK_PA | .... > > That way it is easier to read, review and maintain > > > > + } > > + > > + if (sdmac->per_address2 >= sdma->spba_start_addr && > > + sdmac->per_address2 <= sdma->spba_end_addr) > > + __set_bit(11, &sdmac->watermark_level); > > + > > + if (sdmac->per_address >= sdma->spba_start_addr && > > + sdmac->per_address <= sdma->spba_end_addr) > > + __set_bit(12, &sdmac->watermark_level); > > + > > + __set_bit(31, &sdmac->watermark_level); > All these and few more below will look much better by have defines above > > > @@ -1221,6 +1311,14 @@ static int sdma_config(struct dma_chan *chan, > > sdmac->watermark_level = dmaengine_cfg->src_maxburst * > > dmaengine_cfg->src_addr_width; > > sdmac->word_size = dmaengine_cfg->src_addr_width; > > + } else if (dmaengine_cfg->direction == DMA_DEV_TO_DEV) { > > + sdmac->per_address2 = dmaengine_cfg->src_addr; > > + sdmac->per_address = dmaengine_cfg->dst_addr; > > + sdmac->watermark_level = > > + dmaengine_cfg->src_maxburst & 0xff; > > + sdmac->watermark_level |= > > + (dmaengine_cfg->dst_maxburst & 0xff) << 16; > > + sdmac->word_size = dmaengine_cfg->dst_addr_width; > Please fix this as well > I will refine this patch and send V3 for review. Thanks best regards wang shengjiu > -- > ~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/