Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp3563062yba; Mon, 29 Apr 2019 04:50:25 -0700 (PDT) X-Google-Smtp-Source: APXvYqwaQwDAS6ddapNzHh9CxVsSonfiQZ17YmTJGTUulGWpHcwjt7gEEglsoz5Oj7bRsbRjaN0c X-Received: by 2002:a17:902:bc82:: with SMTP id bb2mr6511565plb.143.1556538625687; Mon, 29 Apr 2019 04:50:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556538625; cv=none; d=google.com; s=arc-20160816; b=RFXNBOPhYb7rGRYFQZEpKDKGU5QBAInuuB5bw9qg3EzzkzQMxZbFBZJ1OtJz32Onz5 EDe3G0l2B6PsIpWIfMK2oX5AK3YbKhobP3f5SaODeXQKbuxKOc+nd1z+XfKs+0s2YiWK QJ87jkpiQbVVABXJUvOz1oKS6dRJDfLzh/941IE4iH3PYYvfTvQbWx0hKGwpQllweQm5 MFsEnXgPFUZ3Mc05tJkpPZb0wXwgIFaQpXwxdmO3fIJ94ENJCQ5LKNO1lkKxIW/RFMzw DrccEIs2dMj7IsSMW3ltZb2iVu5OBzBwKBoU/haPDgY3l0G7Ek1p8uS93PMwi1rHtmMU yNXA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=YYDvYsD7vm9de86thItX5OqkUb2XqGh4QsUmBR6DvzQ=; b=k07vARf2Xefcwrh5V32L0vwLMAlXjPSorlTR0SzRNIlh1al7esNtfhDyGCz8Jvlsur sNQCq/rGRVf+6JQCyNGxJ1W7lN+3BfntfV5mSfoViwfbX64ksSQJ4S+DRVyz6PTFRlQq cFoDOHtBiSgkFcdg+wpkpWWuZpIyBuF+zjx8U4dG6iCWhzHz/C1zMiEFMTqNWprpiy7j RxuAr6g1E9noVwPT2Maxq0e6lXz06CHic4D40V1bRBhzTjwg4lBXtkXp1egThZ1Fk529 dV+ZeGnQU3ZXFsv4mOdMrdn7V5UTxD2d1VRjWbMak6d7nhbEoV4EkOcRp14+BH9Um8PH hj/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=eE78Xoup; 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 p4si30729244pgh.526.2019.04.29.04.50.09; Mon, 29 Apr 2019 04:50:25 -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=eE78Xoup; 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 S1727973AbfD2LtR (ORCPT + 99 others); Mon, 29 Apr 2019 07:49:17 -0400 Received: from mail-ot1-f68.google.com ([209.85.210.68]:40913 "EHLO mail-ot1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727868AbfD2LtR (ORCPT ); Mon, 29 Apr 2019 07:49:17 -0400 Received: by mail-ot1-f68.google.com with SMTP id w6so8298844otl.7 for ; Mon, 29 Apr 2019 04:49:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=YYDvYsD7vm9de86thItX5OqkUb2XqGh4QsUmBR6DvzQ=; b=eE78XoupObinxdP2tF2TRd372B+Ugnx1YhJQQ7sa3QK5Bri8moF6Ouu45b7sCRFDW2 X4ZSKXhGYeDuO8UsZUxi/5IDlSKD2H8AXspi6EHQAelo+d/+uHOn8OPwcJvQLcF0xm20 +ldumwxYB6h/2+D7h1iMukTpyubDZuhWwrjg8T+HrlLwYtfCizpmHiuD1vobez/DKYkp Cn1A08OkAjt/Z8aVydIFWx13REL10X44PgohhXRcN5dhLptJcRelPTi9+szc+TG/Zle8 W5pY/BamAXqf/Y6WpFFqHRa7DAQ4qjzM6mXaAgh7FzmRQwysNLQfR3l7MqMhZQl+RvD2 5Y4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=YYDvYsD7vm9de86thItX5OqkUb2XqGh4QsUmBR6DvzQ=; b=pqb07VqGDqPC41Ri+xnNfNPsSvmeRoZ/Q8ytR5LtBiOSA7uMnrzxn8NItz8Fjei9Rl Od6CtHWfzGOvJrWgLThgSmm2xUXYUC+FTZYTkTNfyjJR/HjjZezbHRi4vgS2Y3TSCP2K mgdhRPFv22p1TumWJUDlrfitrtp5KHFyi/3ffW56UBzI7mJaVLos5mLJ/yiAtzKonV2l Pk/+gPnc/R4I4HlJ2NnVmG0sMF+bAXjWYW3WS2E6T3t1JQHtwAbBiaQC3fgd+sde+YFd QTQPrsNID6HEDX+DetA8EpuawEX3sEcZtqPUQckHPXzb5B5ICaJMcoYaolGTfE/lttUv c4jg== X-Gm-Message-State: APjAAAUbojWp3/fbUsx6pVmRtp9lTszuuqOvXm9rxFdwItB2O0zLTXJf RdAwu51Y370te/8QLGjzvQSO/8r3nS7EoRkgSQXGZA== X-Received: by 2002:a9d:76c7:: with SMTP id p7mr18399492otl.191.1556538555961; Mon, 29 Apr 2019 04:49:15 -0700 (PDT) MIME-Version: 1.0 References: <2eecd528e85377f03e6fbc5e7d6544b9c9f59cb1.1555330115.git.baolin.wang@linaro.org> <20190429113555.GI3845@vkoul-mobl.Dlink> In-Reply-To: <20190429113555.GI3845@vkoul-mobl.Dlink> From: Baolin Wang Date: Mon, 29 Apr 2019 19:49:04 +0800 Message-ID: Subject: Re: [PATCH 1/7] dmaengine: sprd: Fix the possible crash when getting engine status To: Vinod Koul Cc: Dan Williams , eric.long@unisoc.com, Orson Zhai , Chunyan Zhang , Mark Brown , dmaengine@vger.kernel.org, LKML Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Vinod, On Mon, 29 Apr 2019 at 19:36, Vinod Koul wrote: > > On 15-04-19, 20:14, Baolin Wang wrote: > > We will get a NULL virtual descriptor by vchan_find_desc() when the descriptor > > has been submitted, that will crash the kernel when getting the engine status. > > No that is wrong, status is for descriptor and not engine! Sure, will fix the commit message. > > > In this case, since the descriptor has been submitted, which means the pointer > > 'schan->cur_desc' will point to the current descriptor, then we can use > > 'schan->cur_desc' to get the engine status to avoid this issue. > > Nope, since the descriptor is completed, you return with residue as 0 > and DMA_COMPLETE status! No, the descriptor is not completed now. If it is completed, we will return 0 with DMA_COMPLETE status. But now the descriptor is on progress, we should get the descriptor to return current residue. Sorry for confusing description. > > > > > Signed-off-by: Baolin Wang > > --- > > drivers/dma/sprd-dma.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/drivers/dma/sprd-dma.c b/drivers/dma/sprd-dma.c > > index 48431e2..e29342a 100644 > > --- a/drivers/dma/sprd-dma.c > > +++ b/drivers/dma/sprd-dma.c > > @@ -625,7 +625,7 @@ static enum dma_status sprd_dma_tx_status(struct dma_chan *chan, > > else > > pos = 0; > > } else if (schan->cur_desc && schan->cur_desc->vd.tx.cookie == cookie) { > > - struct sprd_dma_desc *sdesc = to_sprd_dma_desc(vd); > > + struct sprd_dma_desc *sdesc = schan->cur_desc; > > > > if (sdesc->dir == DMA_DEV_TO_MEM) > > pos = sprd_dma_get_dst_addr(schan); > > -- > > 1.7.9.5 > > -- > ~Vinod -- Baolin Wang Best Regards