From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754689Ab3AWKU4 (ORCPT ); Wed, 23 Jan 2013 05:20:56 -0500 Received: from mail-lb0-f178.google.com ([209.85.217.178]:56637 "EHLO mail-lb0-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754312Ab3AWKUy (ORCPT ); Wed, 23 Jan 2013 05:20:54 -0500 MIME-Version: 1.0 In-Reply-To: References: <1358758844-24711-1-git-send-email-andriy.shevchenko@linux.intel.com> <1358758844-24711-2-git-send-email-andriy.shevchenko@linux.intel.com> <1358846546.12502.57.camel@smile> <1358932355.12502.68.camel@smile> Date: Wed, 23 Jan 2013 12:20:52 +0200 Message-ID: Subject: Re: [PATCH 2/2] dw_dmac: return proper residue value From: Andy Shevchenko To: Viresh Kumar Cc: Andy Shevchenko , Vinod Koul , linux-kernel@vger.kernel.org, spear-devel Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jan 23, 2013 at 11:51 AM, Viresh Kumar wrote: > On 23 January 2013 15:06, Andy Shevchenko wrote: >> On Wed, Jan 23, 2013 at 11:22 AM, Viresh Kumar wrote: >>> Second to solve your problem, you can add another field here: total_len. >>> I know it will consume 4 bytes per desc but i think that's the drawback we need >>> to accept. >> >> I found already better solution I guess. > > Wow!! > >> I introduced two functions to get amount of sent bytes like >> >> u32 calc_sent(u32 ctlhi, u32 ctllo) >> { >> return f1(ctlhi) * f2(ctllo); >> } >> >> u32 get_sent(dwc) >> { >> return calc_sent(read(CTL_HI), read(CTL_LO)); >> } >> >> And usage like >> >> /* initial residue */ >> desc->len - calc_sent(desc->lli.ctlhi, desc->lli.ctllo). >> >> What do you think? > > You plan to use it for > - the first descriptor in a list as others already have length embedded in them? > - And the descriptor currently getting used, by reading its ctlhi/lo > from registers > instead of lli.*** ? Roughly, yes. > Looks good. but still keeping len of individual descriptors in all > descriptors leaving > the first one is not the code i would like to keep :) What about to calc len every time from lli.* instead of keeping it in the len field of the descriptor? It's logically looks better, but requires more resources. -- With Best Regards, Andy Shevchenko