Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S938579AbcLOPqN (ORCPT ); Thu, 15 Dec 2016 10:46:13 -0500 Received: from mail-co1nam03on0074.outbound.protection.outlook.com ([104.47.40.74]:42998 "EHLO NAM03-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S938553AbcLOPqI (ORCPT ); Thu, 15 Dec 2016 10:46:08 -0500 Authentication-Results: spf=pass (sender IP is 149.199.60.100) smtp.mailfrom=xilinx.com; vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=bestguesspass action=none header.from=xilinx.com; X-IncomingTopHeaderMarker: OriginalChecksum:;UpperCasedChecksum:;SizeAsReceived:2491;Count:27 From: Appana Durga Kedareswara Rao To: Jose Abreu , "dmaengine@vger.kernel.org" CC: Carlos Palminha , Vinod Koul , Dan Williams , "Laurent Pinchart" , "linux-arm-kernel@lists.infradead.org" , "linux-kernel@vger.kernel.org" Subject: RE: [PATCH] dmaengine: xilinx_dma: Add support for multiple buffers Thread-Topic: [PATCH] dmaengine: xilinx_dma: Add support for multiple buffers Thread-Index: AQHSVuB3HZlrbhH/n06PoiH2X9+446EJGUYQ Date: Thu, 15 Dec 2016 15:11:53 +0000 Message-ID: References: <40ba7c24927eeffdcc66425f8ca1203589276c08.1481812291.git.joabreu@synopsys.com> In-Reply-To: <40ba7c24927eeffdcc66425f8ca1203589276c08.1481812291.git.joabreu@synopsys.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [172.23.94.60] Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 X-RCIS-Action: ALLOW X-TM-AS-Product-Ver: IMSS-7.1.0.1224-8.0.0.1202-22762.006 X-TM-AS-User-Approved-Sender: Yes;Yes X-IncomingHeaderCount: 27 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:149.199.60.100;IPV:NLI;CTRY:US;EFV:NLI;SFV:NSPM;SFS:(10009020)(6009001)(7916002)(39840400002)(39450400003)(39410400002)(39850400002)(39860400002)(2980300002)(438002)(199003)(189002)(51914003)(92566002)(8676002)(106466001)(2920100001)(5001770100001)(356003)(106116001)(5660300001)(3846002)(8746002)(76176999)(102836003)(7736002)(63266004)(50466002)(55846006)(626004)(2900100001)(33656002)(47776003)(54356999)(6116002)(97756001)(189998001)(50986999)(81166006)(2501003)(46406003)(305945005)(229853002)(5250100002)(38730400001)(81156014)(551934003)(4326007)(7696004)(2906002)(8936002)(23726003)(2950100002)(107986001)(5001870100001);DIR:OUT;SFP:1101;SCL:1;SRVR:BN3PR0201MB0883;H:xsj-pvapsmtpgw02;FPR:;SPF:Pass;PTR:xapps1.xilinx.com,unknown-60-100.xilinx.com;A:1;MX:1;LANG:en; X-Microsoft-Exchange-Diagnostics: 1;SN1NAM02FT037;1:gatoF3F+SGt/jW+axK9ymV4LcWHDyv5SpmXper4o3xyoVradpL/nrej60IZlBts86rDhW08AkRkHk37AnTdJtnpzwUWQVTG+zeuHjT6E9Sn2DKJH6fJuDu+841ET4kcXcxZs9lHSG5ObsxoT22wRepXSSkGfgDUsO4T9T03/GHtF+mBgB1rS4Nypz75aRKiaoEUHQ5vz7g4sdSLXUqUrrmL+eDm5biHsgPMBOMeHV2WJfUIWBDY4aoP9tLTT4ddaqbk97zzZxjNtolANPMhwHn6nOt1UcAAveJZ1xUUNGImCMMby3jBOwGWpycTFvFqjFw6v2z8JoK6wpqiQxrgi9TIU+NArLbbE1nn65g6iYqKM0/vq8XlGnslm9zkejK5WnGlnycqhzeIGMxSWBKIrguhFrykq1bNGfjxmYhslDf7jmJF5Zq6obEvA7FuTqD8HrfOi9bSCtJ9oVmnmScwGy+N3AUCOlLTcadove7EQrp+mwmEUrx/Y56E+5yRN46rFmCh0F1kyXgriRSqYFujf5iEp1d4gj4Z8w4WjUXp5KAhVlcSc8NVXCH2HMoSmaSPWGdqMJRp3Yz+KUCBnedDZ7CnRZbcymnQ6OPWo5oPadqxhBP0YjFNLKK5SwcJjy8pCIoXm+7d4Xvi1HyPW6sU83g== X-MS-Office365-Filtering-Correlation-Id: fe1846ab-2bff-46fb-cf40-08d424fcb79d X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001)(8251501002);SRVR:BN3PR0201MB0883; X-Microsoft-Exchange-Diagnostics: 1;BN3PR0201MB0883;3:pE2LzdJ9vyHLbxUhko8fFaUMZhNmN3xLih7R2HNAKq79LvESPw2aaNLi5eQXkXP3Oa675dx68XRovfeB2FXCcDK3HaQPOPFeRiPfP6mvJf9HtQK4YI6cZVAqACIPgTpyTsSdhNaG9YtHHDTl5iZOKbfY72YoPvao7g4Ka7wp/I1AUQNAgwoHqP9/hC2bevKo0N/atrv+iWWGLexAGDafbmxtDSDbflYj4a9fRZICB8rxwgeN2Te5YkuIVy6R+vTpNbObFmLwwZG+1qv5UghKP5u0oxvSpJw+xF3BoY9BkYYqRmxbfjK62UESl1Xi2a+0d/carMKnnwe2eOrzFL67blRpuAYveBpliwNOUV2Y5ubZcocFOyfTu0bYHE4QSTTt/A+91wI8sTvfO14eD6OjrQ== X-Microsoft-Exchange-Diagnostics: 1;BN3PR0201MB0883;25:Axv9ekXQ5qTaamp78Drba5aPJ7YPBXV1P5e1MRv2CwHhirS6Ui2tupHvOqWALBRlGtUYkKyq+Pr0MXqD6X/RO3acZGm/KZtu6CnhZf4nd2fr8M17PlVkmGs3h6Dn89Chq1Nl/YYIY1MHo4JcCk9m8oY8BUS/gvQFC44KC/STjVqRMrD342CaZk6TKZn+umlkJO06s0zM46uTCP25CVrG6UiQv4HWbThav51Foinj9iXca/HZjfObQ1+zQiUre66wnqpIcVz0hkJMlSgxcJ5CX6jJ5H7PTi6bvfE6mqRlqKU2ZW2xX3jpLkYsLp/LXNHkcH+TrNn9HxxpDxCdp6NDWwWPv3lsmP91EsReN2BxoD7ska+Nmu5Q6xKkjhVqP99s2aZ44mAh69UO7WY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blHtk3Le5OR1Cypz46Fae8PN0nwX1qvGtEqqTd6lIJyAMP+IUCcLR+49GHrZZ14lg+xugHd6Eb6QlfsxYX2FBM8SnmQaPMN5VYF3VMFnDEYnMdfLdGgTNGKp+Yz9kjgjHvUPG68f5fbnPUTMorLbVs12w0r767WvSdPz7YbJcvAhzoMcyKy2sxWK1JtLDYbXtPl7v+KoXZ0Ny9t/+gGSBkrCk+UnbLIs1Ahzl X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(192374486261705)(9452136761055)(258649278758335)(192813158149592)(228905959029699); X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6040375)(601004)(2401047)(5005006)(8121501046)(13018025)(13023025)(13024025)(13015025)(13017025)(10201501046)(3002001)(6055026)(6041248)(20161123562025)(20161123564025)(20161123560025)(20161123555025)(6072148);SRVR:BN3PR0201MB0883;BCL:0;PCL:0;RULEID:;SRVR:BN3PR0201MB0883; X-Microsoft-Exchange-Diagnostics: 1;BN3PR0201MB0883;4:Lzb49mXdgmHI7LafA3Ssaa7RLzAp1LWDdoLfQjiTBzJjOx6ToWad38qZ50HHlpOJUnwWgX8CtyDkGVUauQe8VaKgn9itMFnsju3KilN0cKTx9mF1Mz1fe/aBOBKEXb2GFLtJ3LBEUZR03TiZFCMnwo0rVL0rWaosOUjWcVVvM1FWJpSBKx8mQqOXBMxCWb+R6jpMDfU6hl6xzdaAKX9vO9JtZRya2gQIZyevl9H3vN10/yQOq1/VRjaAbynb8xZ6kx2T8JMn1eFVaWPolnXrtZfKcsa3HKBJw6bDknUP0LI0Y4te4FvGXoVbgbSX6bQDrRONkEcu+Ivw5tLhwoG0HJk+VXcsOXnODMssfHUwAbLSmCKwhjiCy1gpkpkb/GtYUhNlJ8xLmtRg1vD1PyV/d/S7cOwIJCjCoyrK5/68KzzsVDSFxf/MH0AKfrYa6LiU0bYHx4WLOlgu0xzu8fcrjaChX8oLD6WG6eEEM2ATjZS+fo8CzkN/zpta2jbfNJHXS39UKSeX0qTraJoMnlFUGjF1S8x7vKAPjT9SGH062NhKGeI/CVRJ33vT1Xv9WGFQRAehMAb6knLm4P3oL2CPv9Dzv97pjB9M6dQhc0CQYMqTw5q+41Y7CtbJtfSofP3OcacgGTccYKeT0O5YPqrRjMr1dDP0e88m7VAPO99uRptt7HJpF0iM/WDRB/SXZTr5hyMsXuq8FlFvignREdyjN2nVZCQmeNQuNibn907l6M4iRF2gK304Tc9VQzquEC6RSgCVWQrBauZ7GkH+9Im7518e+GJnI5ZfjCTAorFfuwYoHe8m8vyfAa5rds48oE1Iu/XdqMJeNj+YE2joIYgdH++RHlbv6uGcsvdeIZme5ws= X-Forefront-PRVS: 0157DEB61B X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;BN3PR0201MB0883;23:HsCqF/oBLqByBGLpfJJkACXsmcptPnfIMYpVmfU?= =?us-ascii?Q?ABlibBlaufw2Mnb0DQb81/gp5Iqzu06XwVSdtIiLt2YE4hISCy6QZVVnEmcC?= =?us-ascii?Q?P3wjws/ByBAbAMLPbHUGpht1BiwAGpn1djKLqzb70r1xCF48iYajF0XMgBOv?= =?us-ascii?Q?qgl5w9s3r5XNVVVYMBQDh/MbxIsR6fj7tVpkbT4j+QOs/6hyvf+EqbpS1zx9?= =?us-ascii?Q?k5S1fFaNGQKpQoD39bnyJXHOKChiwzx4XIf9atybQBD/hOeWdYnsXd2YG9X4?= =?us-ascii?Q?N916TnhmMvJcKjbI6ikubCDpeV5VGBydCcTcMtpoPzM/ca8EAaIuv5rd8aF4?= =?us-ascii?Q?jBa6Cv252AQ1fKTu1cW9MaJ1UF9/sOD5ka8RTA1Xh3Ps7YlSNfv9L+PZbN5M?= =?us-ascii?Q?fW9nerdYXjt0DzTpaDHCzujtHVYSXdRtIEaERGAL4STFcbdMEuSQwMA2epwV?= =?us-ascii?Q?bkS2GEIngF5Tua3/0X3xjslbNTbS8dkd6lYXu5jCzTdgym6bR6AQrMiUvzKF?= =?us-ascii?Q?AfYDLpvm2sGhvmGHldUyCzPp9DWfgo8FtyB4uH3g+jnzVZEWleTyNQ2uC4tF?= =?us-ascii?Q?w+lFMTGj755f1f5mt8/pL3g0+OB2toshqJAHcTgTnYeyibMFJjekB3S2tCMC?= =?us-ascii?Q?oD1lIaxxCqIm8AGpcUQ6n/QSQUbVDwF7Mmjvs9N48kyQIUdFTtTt6CGczlUq?= =?us-ascii?Q?8HECUOl/G7RU49Tar/vhzxp1Wuey/UVn/8qqsdd0/m//jnHciLV6mTalpiIS?= =?us-ascii?Q?wFORN2asBKbsGJraXR06DHk2dLXxaudPPx/9aYEA0/FOKuGuBxaPc4zTiHA1?= =?us-ascii?Q?SdD1mho+6Wnfgwzyld2XPM6AZH66NokYQvLu7Br9rPiggv3xdXjiHugoCz47?= =?us-ascii?Q?3FDBWDeAXlhMQbtxLTEGuSqlE17IgDJFwqvx5ttTaGaq01QTGL8FOePiIN5+?= =?us-ascii?Q?h5KUqo/Aigpuk1D4fVTa0p8b5W2caFtMqqyKSBZe1BwAjxcV5vevDMDyc3EW?= =?us-ascii?Q?veCYr/N+F4Ru750pQ2kTUGoP218CsHtJFQb/2koqPrWsN4klo+DemH9OFwAD?= =?us-ascii?Q?zbRyjaWdiQBlHcG+oIgPit6RYWVxPDHL3d6ZoiBckmoAnJjY15jCYQSyEVkS?= =?us-ascii?Q?+E1XaiKhbOIfgImBdoqUMdbbyHhToyhYq4MFs5fEYQx0N2dEXUGR2ROYjq+W?= =?us-ascii?Q?/DG7fzLVUxbNH8azo48BXaQPYgUoqQqpjON2cI0mUVZ/fK+TRNM8XpRYvvSW?= =?us-ascii?Q?dm7/gkny3icY3WkbZQRNwyETGjAlXhfJtvI22mL++hks7kyBRx5bjfAFibPe?= =?us-ascii?Q?Abxxg8YBu73O6UwyATV/TV7g=3D?= X-Microsoft-Exchange-Diagnostics: 1;BN3PR0201MB0883;6:z5SbPuX0YW9Qf8wl3UMKV+UK5uC/+y88UjEBd2kB4ThtppYI/GaobFsUoFWCJ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KPCsAMh+8iKpQdrCIKEQ7mKVpY/TdT1GBISicEGw22ihFqiOzIW1udrxmnB+Lea84yKsCg4WaqZZ0u764J3AV85vJCQ1L+HwvA64AmsU9wBpqSIULRCpmKCWqWcBQ7uQpnAMsWtR6XASUIVXw== X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Dec 2016 15:11:59.2951 (UTC) X-MS-Exchange-CrossTenant-Id: 657af505-d5df-48d0-8300-c31994686c5c X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=657af505-d5df-48d0-8300-c31994686c5c;Ip=[149.199.60.100];Helo=[xsj-pvapsmtpgw02] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN3PR0201MB0883 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by mail.home.local id uBFFkSkk023682 Content-Length: 7284 Lines: 235 Hi Jose Abreu, Thanks for the patch... I have just posted different patch series for fixing these issues just now... Please take a look into it... Regards, Kedar. > Subject: [PATCH] dmaengine: xilinx_dma: Add support for multiple buffers > > Xilinx VDMA supports multiple framebuffers. This patch adds correct handling for > the scenario where multiple framebuffers are available in the HW and parking > mode is not set. > > We corrected these situations: > 1) Do not start VDMA until all the framebuffers > have been programmed with a valid address. > 2) Restart variables when VDMA halts/resets. > 3) Halt channel when all the framebuffers have > finished and there is not anymore segments > pending. > 4) Do not try to overlap framebuffers until they > are completed. > > All these situations, without this patch, can lead to data corruption and even > system memory corruption. If, for example, user has a VDMA with 3 > framebuffers, with direction DMA_DEV_TO_MEM and user only submits one > segment, VDMA will write first to the segment the user submitted BUT if the > user doesn't submit another segment in a timelly manner then VDMA will write > to position 0 of system mem in the following VSYNC. > > Signed-off-by: Jose Abreu > Cc: Carlos Palminha > Cc: Vinod Koul > Cc: Dan Williams > Cc: Kedareswara rao Appana > Cc: Laurent Pinchart > Cc: dmaengine@vger.kernel.org > Cc: linux-arm-kernel@lists.infradead.org > Cc: linux-kernel@vger.kernel.org > --- > drivers/dma/xilinx/xilinx_dma.c | 80 ++++++++++++++++++++++++++++++++++- > ------ > 1 file changed, 68 insertions(+), 12 deletions(-) > > diff --git a/drivers/dma/xilinx/xilinx_dma.c b/drivers/dma/xilinx/xilinx_dma.c > index 8288fe4..30eec5a 100644 > --- a/drivers/dma/xilinx/xilinx_dma.c > +++ b/drivers/dma/xilinx/xilinx_dma.c > @@ -351,10 +351,12 @@ struct xilinx_dma_chan { > bool cyclic; > bool genlock; > bool err; > + bool running; > struct tasklet_struct tasklet; > struct xilinx_vdma_config config; > bool flush_on_fsync; > u32 desc_pendingcount; > + u32 seg_pendingcount; > bool ext_addr; > u32 desc_submitcount; > u32 residue; > @@ -946,6 +948,17 @@ static bool xilinx_dma_is_idle(struct xilinx_dma_chan > *chan) } > > /** > + * xilinx_vdma_is_multi_buffer - Check if VDMA has multiple > +framebuffers > + * @chan: Driver specific DMA channel > + * > + * Return: '1' if is multi buffer, '0' if not. > + */ > +static bool xilinx_vdma_is_multi_buffer(struct xilinx_dma_chan *chan) { > + return chan->num_frms > 1; > +} > + > +/** > * xilinx_dma_halt - Halt DMA channel > * @chan: Driver specific DMA channel > */ > @@ -966,6 +979,10 @@ static void xilinx_dma_halt(struct xilinx_dma_chan > *chan) > chan, dma_ctrl_read(chan, > XILINX_DMA_REG_DMASR)); > chan->err = true; > } > + > + chan->seg_pendingcount = 0; > + chan->desc_submitcount = 0; > + chan->running = false; > } > > /** > @@ -1002,14 +1019,35 @@ static void xilinx_vdma_start_transfer(struct > xilinx_dma_chan *chan) > struct xilinx_dma_tx_descriptor *desc, *tail_desc; > u32 reg; > struct xilinx_vdma_tx_segment *tail_segment; > + bool mbf = xilinx_vdma_is_multi_buffer(chan) && !config->park; > > /* This function was invoked with lock held */ > if (chan->err) > return; > > - if (list_empty(&chan->pending_list)) > + /* > + * Can't continue if we have already consumed all the available > + * framebuffers and they are not done yet. > + */ > + if (mbf && (chan->seg_pendingcount >= chan->num_frms)) > return; > > + if (list_empty(&chan->pending_list)) { > + /* > + * Can't keep running if there are no pending segments. Halt > + * the channel as security measure. Notice that this will not > + * corrupt current transactions because this function is > + * called after the pendingcount is decreased and after the > + * current transaction has finished. > + */ > + if (mbf && chan->running && !chan->seg_pendingcount) { > + dev_dbg(chan->dev, "pending list empty: halting\n"); > + xilinx_dma_halt(chan); > + } > + > + return; > + } > + > desc = list_first_entry(&chan->pending_list, > struct xilinx_dma_tx_descriptor, node); > tail_desc = list_last_entry(&chan->pending_list, > @@ -1079,6 +1117,8 @@ static void xilinx_vdma_start_transfer(struct > xilinx_dma_chan *chan) > if (chan->has_sg) { > dma_ctrl_write(chan, XILINX_DMA_REG_TAILDESC, > tail_segment->phys); > + list_splice_tail_init(&chan->pending_list, &chan->active_list); > + chan->desc_pendingcount = 0; > } else { > struct xilinx_vdma_tx_segment *segment, *last = NULL; > int i = 0; > @@ -1097,29 +1137,34 @@ static void xilinx_vdma_start_transfer(struct > xilinx_dma_chan *chan) > > XILINX_VDMA_REG_START_ADDRESS(i++), > segment->hw.buf_addr); > > + chan->seg_pendingcount++; > last = segment; > } > > if (!last) > return; > > - /* HW expects these parameters to be same for one > transaction */ > - vdma_desc_write(chan, XILINX_DMA_REG_HSIZE, last- > >hw.hsize); > - vdma_desc_write(chan, XILINX_DMA_REG_FRMDLY_STRIDE, > - last->hw.stride); > - vdma_desc_write(chan, XILINX_DMA_REG_VSIZE, last- > >hw.vsize); > - } > - > - if (!chan->has_sg) { > list_del(&desc->node); > list_add_tail(&desc->node, &chan->active_list); > chan->desc_submitcount++; > chan->desc_pendingcount--; > if (chan->desc_submitcount == chan->num_frms) > chan->desc_submitcount = 0; > - } else { > - list_splice_tail_init(&chan->pending_list, &chan->active_list); > - chan->desc_pendingcount = 0; > + > + /* > + * Can't start until all the framebuffers have been programmed > + * or else corruption can occur. > + */ > + if (mbf && !chan->running && > + (chan->seg_pendingcount < chan->num_frms)) > + return; > + > + /* HW expects these parameters to be same for one > transaction */ > + vdma_desc_write(chan, XILINX_DMA_REG_HSIZE, last- > >hw.hsize); > + vdma_desc_write(chan, XILINX_DMA_REG_FRMDLY_STRIDE, > + last->hw.stride); > + vdma_desc_write(chan, XILINX_DMA_REG_VSIZE, last- > >hw.vsize); > + chan->running = true; > } > } > > @@ -1327,12 +1372,20 @@ static void xilinx_dma_issue_pending(struct > dma_chan *dchan) static void xilinx_dma_complete_descriptor(struct > xilinx_dma_chan *chan) { > struct xilinx_dma_tx_descriptor *desc, *next; > + struct xilinx_vdma_tx_segment *segment; > > /* This function was invoked with lock held */ > if (list_empty(&chan->active_list)) > return; > > list_for_each_entry_safe(desc, next, &chan->active_list, node) { > + if (chan->xdev->dma_config->dmatype == XDMA_TYPE_VDMA) > { > + list_for_each_entry(segment, &desc->segments, node) > { > + if (chan->seg_pendingcount > 0) > + chan->seg_pendingcount--; > + } > + } > + > list_del(&desc->node); > if (!desc->cyclic) > dma_cookie_complete(&desc->async_tx); > @@ -1366,6 +1419,9 @@ static int xilinx_dma_reset(struct xilinx_dma_chan > *chan) > } > > chan->err = false; > + chan->seg_pendingcount = 0; > + chan->desc_submitcount = 0; > + chan->running = false; > > return err; > } > -- > 1.9.1 >