Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp6866690imm; Tue, 24 Jul 2018 04:38:47 -0700 (PDT) X-Google-Smtp-Source: AAOMgpf5uQt0amLPGGIQOdkoKiiAbCyRbuKwG0KzBiYHsVBNfBROiFIWYYnnpb3Ly5GJDIxxOCd2 X-Received: by 2002:a17:902:7106:: with SMTP id a6-v6mr17070727pll.28.1532432327330; Tue, 24 Jul 2018 04:38:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532432327; cv=none; d=google.com; s=arc-20160816; b=nfahsEvZsYEIFCIyp473Kzy7IAL2GghKchy1cs5wBNGKdQ1PEW5r8W2e34/9blLrzw RNb1jUQ9SI5r/+Fd/HDYYGnjtzhbol0IGSHQCeN6wvCGaWhD7yNcMZnt5+2hPBa9eSfe DUNQny+/bPxArA4XaaDSQygamwW5W+VHnWTIdTNTLYjONbfywomdcpyR17RTa4wQR8FW Tj+4MhK64pCHXwgMxQoMBxTv2+b9LlXuNcvz0zRvBwHJT9aWiY21t7sWhPjMxWl2JA3O +Mp9JWNsqB2qIN3wBth3rPrR4v1+Dfo+vx/hvrYZSoQkurojhgGAZkZZtty66HXjY2Fi ULkA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature :arc-authentication-results; bh=QeeM71aeEdeHqsIApKbxvYSLkWypZV4f3jtXqqmGzz4=; b=hkP29wtokvyF3QrGPyIOmKvqTka3I13j4PsGllSDrA+cFqqjESNi9gvdAYY2CbeNS/ GVOLOS576XjvGnDSr8G86kQ6g1kEkYdYQ59nMFby6eDngC0Zzx9XjsUIwKb2uO/FxDMn xDKDTQ81W17GMP/MG+JNPvwxjYHttYTF+I4MXiJAMBc1d6zH4mNdlaqodR0j8R3cZrD4 draJWbBLc0fw56X0exOF1ctOAjGoJMphV+soI6Qgx9bqcqTCC1exLx0l2zVJABF6TZR5 C0NFdtPPpA1O/h3dRv4GJ6ogA92l0LONAlW+v9RAP7ap+wSAT7b+C8SDHl+P7CmAdhoS 5wcw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=iSbMzF9i; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d20-v6si7366477pls.477.2018.07.24.04.38.32; Tue, 24 Jul 2018 04:38:47 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=iSbMzF9i; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388329AbeGXMm7 (ORCPT + 99 others); Tue, 24 Jul 2018 08:42:59 -0400 Received: from mail-pg1-f193.google.com ([209.85.215.193]:33764 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388289AbeGXMm7 (ORCPT ); Tue, 24 Jul 2018 08:42:59 -0400 Received: by mail-pg1-f193.google.com with SMTP id r5-v6so2722529pgv.0 for ; Tue, 24 Jul 2018 04:36:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=QeeM71aeEdeHqsIApKbxvYSLkWypZV4f3jtXqqmGzz4=; b=iSbMzF9iItrsoS+XJ0AOdwgdobMkSU2vZYGFQMMrIII2kctyerpgHHNlhvZG6brBSb khxPt03VOLKNP4vUktV72uKA3mPUaG4MRhUgkY+fFAo2i0sLssKDOlzqxP85/Kf+mibX 9DaeWtUchaaX2CABP+3X9QtwJCC0v6+2rdqrc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to:user-agent; bh=QeeM71aeEdeHqsIApKbxvYSLkWypZV4f3jtXqqmGzz4=; b=bjcjrnBsIeC8jEWESENCpE1k02tY2QLKHYJzelmnM2AnwsNxyygvaI8Oso3I7gN6kz CbPdy35oCOEgGdajR9f5oMmAeyIdmAWcnQ5wsrtHvfWW5lq3b4Hb6mJCDoNSdHwVWVKy +WGwexy/o3LgXKc55WHw0Q/K6EhRbsJVSQ5/jWbgS9ScN43SiXIi4nJyTelyZOc3O99g 4/6Ei+dhwsoXZ2bYq/qJUlyBpc0Bg0LMQukbjRRfsKnyQHI/fnEJBkoHQL/ayeYHBwyZ nE5U1XPsoCqrpax6+sRGX9VlFjViVWPoet4ZroX+AJQ8OuQGRL+quKalvunfcIwGbSYf sX/g== X-Gm-Message-State: AOUpUlGtyVTT+VKA7IeZVIW2LBlh5L4KIBvcaYVBgzstwv/j/n8af6Es o/XOQ+bev43G0gzxjiv+F3VVP+hAk5Q= X-Received: by 2002:a62:3001:: with SMTP id w1-v6mr17318574pfw.19.1532432216869; Tue, 24 Jul 2018 04:36:56 -0700 (PDT) Received: from localhost ([106.201.120.141]) by smtp.gmail.com with ESMTPSA id h69-v6sm33359751pfh.13.2018.07.24.04.36.55 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 24 Jul 2018 04:36:56 -0700 (PDT) Date: Tue, 24 Jul 2018 17:06:54 +0530 From: Vinod Koul To: Andreas =?iso-8859-1?Q?F=E4rber?= Cc: linux-mips@linux-mips.org, Ralf Baechle , Paul Burton , James Hogan , linux-kernel@vger.kernel.org, Damien Horsley , Dan Williams , dmaengine@vger.kernel.org Subject: Re: [PATCH 09/15] dmaengine: img-mdc: Handle early status read Message-ID: <20180724113654.GL3219@vkoul-mobl> References: <20180722212010.3979-1-afaerber@suse.de> <20180722212010.3979-10-afaerber@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20180722212010.3979-10-afaerber@suse.de> User-Agent: Mutt/1.9.2 (2017-12-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 22-07-18, 23:20, Andreas F?rber wrote: > From: Damien Horsley > > It is possible that mdc_tx_status may be called before the first > node has been read from memory. > > In this case, the residue value stored in the register is undefined. > Return the transfer size instead. > > Signed-off-by: Damien Horsley > Signed-off-by: Andreas F?rber > --- > drivers/dma/img-mdc-dma.c | 40 ++++++++++++++++++++++++---------------- > 1 file changed, 24 insertions(+), 16 deletions(-) > > diff --git a/drivers/dma/img-mdc-dma.c b/drivers/dma/img-mdc-dma.c > index 25cec9c243e1..0f2f0f52d83a 100644 > --- a/drivers/dma/img-mdc-dma.c > +++ b/drivers/dma/img-mdc-dma.c > @@ -621,25 +621,33 @@ static enum dma_status mdc_tx_status(struct dma_chan *chan, > (MDC_CMDS_PROCESSED_CMDS_DONE_MASK + 1); > > /* > - * If the command loaded event hasn't been processed yet, then > - * the difference above includes an extra command. > + * If the first node has not yet been read from memory, > + * the residue register value is undefined so is this the case when transfer is not started ? > */ > - if (!mdesc->cmd_loaded) > - cmds--; > - else > - cmds += mdesc->list_cmds_done; > - > - bytes = mdesc->list_xfer_size; > - ldesc = mdesc->list; > - for (i = 0; i < cmds; i++) { > - bytes -= ldesc->xfer_size + 1; > - ldesc = ldesc->next_desc; > - } > - if (ldesc) { > - if (residue != MDC_TRANSFER_SIZE_MASK) > - bytes -= ldesc->xfer_size - residue; > + if (!mdesc->cmd_loaded && !cmds) { > + bytes = mdesc->list_xfer_size; > + } else { > + /* > + * If the command loaded event hasn't been processed yet, then > + * the difference above includes an extra command. > + */ > + if (!mdesc->cmd_loaded) > + cmds--; > else > + cmds += mdesc->list_cmds_done; > + > + bytes = mdesc->list_xfer_size; > + ldesc = mdesc->list; > + for (i = 0; i < cmds; i++) { > bytes -= ldesc->xfer_size + 1; > + ldesc = ldesc->next_desc; > + } > + if (ldesc) { > + if (residue != MDC_TRANSFER_SIZE_MASK) > + bytes -= ldesc->xfer_size - residue; > + else > + bytes -= ldesc->xfer_size + 1; > + } > } > } > spin_unlock_irqrestore(&mchan->vc.lock, flags); > -- > 2.16.4 -- ~Vinod