From patchwork Mon May 6 07:28:28 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "\(Exiting\) Baolin Wang" X-Patchwork-Id: 163384 Delivered-To: patch@linaro.org Received: by 2002:a92:3d95:0:0:0:0:0 with SMTP id k21csp1538780ilf; Mon, 6 May 2019 00:28:56 -0700 (PDT) X-Google-Smtp-Source: APXvYqwXuf4iMMQzmlF99fm0sTnGdDZOLduJ9FYaVJXGKZ832gwcgewHHnBcbzisSDrVwJ1zZAIP X-Received: by 2002:a17:902:822:: with SMTP id 31mr30095939plk.41.1557127736205; Mon, 06 May 2019 00:28:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557127736; cv=none; d=google.com; s=arc-20160816; b=Vbs4qa03cKKLerhUQUFHOECg09Ny6vG3Mhx1ssHoLexkyaXUdGrFR1MBg3M3lwhMEw I+1Dda/QspqYjOmR1j4OKhxHwc7uivs99FA3Nk7IFv1fvntnnoj8NzpTS45kogilpONQ 05m1Gh+2M5WaICR2DRLM/K2ZnGtfui/29m8UPfi901bgd2SW9Q24fZw4FeT8nrE3BPZk jArmZbFpPpCIqlxzgR6Y/rP/+xzOdSuTK0zSDHA2KxegknpSJJt1BQoKkUwJdz449qhZ X/+0W7GuAdyCPHCoSpHSyJgAH7VG18Yy46gklzv+ObuMijakLI9tLXlosp2M8NL4XSRp 4Vjw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature; bh=yZiVOrjB2GkVNwkAlHEh8RFkK/dk9IRsTM24Q28H3wk=; b=fKxuH1CVjBFI/NPtCwOKSjuLfbP/v4768YLhEx8HQFKvTM81CMZTS+LjW6g/wHoCME 4bSanNz+yhrXvQVSbcrePN20qeC1DGugnyEDkoMvVbFnk9C9sNqO15luoeNcceEIzHuA h1muMm6EVuhhltsmva1oryu6I2oCyLJEj+c/Vf0VtwDOUSYOD3x190zXr1LkbYohsi9P svuE+9AnAANZdaAjSSs2KKGjir29jQgbtqirh/cLVrL3AkYvoURFoLbDihLvANm+EuY7 oj6IyNaFVBqlaAPfopjsrDBIYzK2zjUHU1zly/MQv1868sheidsMNd5q11ILWf4xVF9j GpEw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=BIbUM15m; 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 j5si13850512pfa.63.2019.05.06.00.28.55; Mon, 06 May 2019 00:28:56 -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=BIbUM15m; 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 S1726327AbfEFH2y (ORCPT + 30 others); Mon, 6 May 2019 03:28:54 -0400 Received: from mail-pg1-f196.google.com ([209.85.215.196]:40431 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726255AbfEFH2x (ORCPT ); Mon, 6 May 2019 03:28:53 -0400 Received: by mail-pg1-f196.google.com with SMTP id d31so6029222pgl.7 for ; Mon, 06 May 2019 00:28:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=yZiVOrjB2GkVNwkAlHEh8RFkK/dk9IRsTM24Q28H3wk=; b=BIbUM15mdf5AnhdYErzvP660w8KBiAQdvle7iP059JvrT4k+uzyqvT//ZxuanToIjD 1Kb9X+z0JegAGTabVvBbhp740j9+Izw32tIaWryq1OWoDktcb7SFTJXvkSBBS7XIy5BS w/TZVda78BdDeIrOpWMJpPJlAeW2kdDO0hhjnbpr4wjtjYlJEebf+aTL7fDHI9F84eWI b+hqqNP3fOdVK/ZGwIf6/bOjKzgQR1ABGO4qaoTi/1KjD7SJ2JO9i/V7XHK+JE2/5OOZ sqZ+h030Cbc/0UU7plh6j9v/Vf5ktuW4KK9cnoS69oR0f4KFJGhBgsbgaYtwMB8gc300 CBPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=yZiVOrjB2GkVNwkAlHEh8RFkK/dk9IRsTM24Q28H3wk=; b=O398iFE2ZC5p7Jwjwr/JHvtpt2axRFtsCaLLYA6mWy6ngoCO6dzx2T/oPKQe43OBr9 87Pe4FwEwOuriJcAwJcRYXvsvay2cReAD/yd8hTPL4scFtYWlbujRBu3nx3Z1KKH82RY Rc2Tqopm0DgiF1pmJsUtbPgh+2oQvO4kYtv+SZ5Kbj+3iCDZmRxP8i62rSVIid9U4g9H ORYU3S+7xGwlINJi2tLfvVtR4+2Y5+7hedUPMH2Q8e5iIVx5oCxIeEJxc+aQtiJNNs+V mQX+n/ADp9ueJV/SZ2ySiHOcHxpJAvpyduWNaBkRHVzFmesfQ+gcnUZtIeU+zt8uzlSQ A3fA== X-Gm-Message-State: APjAAAUW0nK7RGmfozyAfL9yWxR2RzZtzw12r5jfjIBn2YIrb+sCgArD Pbg1I+FwZawZd+Aad2g2bdPbJg== X-Received: by 2002:a63:5c24:: with SMTP id q36mr30268665pgb.314.1557127732915; Mon, 06 May 2019 00:28:52 -0700 (PDT) Received: from baolinwangubtpc.spreadtrum.com ([117.18.48.102]) by smtp.gmail.com with ESMTPSA id w38sm21700894pgk.90.2019.05.06.00.28.49 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 06 May 2019 00:28:52 -0700 (PDT) From: Baolin Wang To: dan.j.williams@intel.com, vkoul@kernel.org Cc: eric.long@unisoc.com, orsonzhai@gmail.com, zhang.lyra@gmail.com, vincent.guittot@linaro.org, baolin.wang@linaro.org, dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 1/6] dmaengine: sprd: Fix the possible crash when getting descriptor status Date: Mon, 6 May 2019 15:28:28 +0800 Message-Id: X-Mailer: git-send-email 1.7.9.5 In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 descriptor status. In this case, since the descriptor has been submitted to process, but it is not completed now, which means the descriptor is listed into the 'vc->desc_submitted' list now. So we can not get current processing descriptor by vchan_find_desc(), but the pointer 'schan->cur_desc' will point to the current processing descriptor, then we can use 'schan->cur_desc' to get current processing descriptor's status to avoid this issue. Signed-off-by: Baolin Wang --- drivers/dma/sprd-dma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 1.7.9.5 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); From patchwork Mon May 6 07:28:29 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "\(Exiting\) Baolin Wang" X-Patchwork-Id: 163385 Delivered-To: patch@linaro.org Received: by 2002:a92:3d95:0:0:0:0:0 with SMTP id k21csp1538820ilf; Mon, 6 May 2019 00:28:59 -0700 (PDT) X-Google-Smtp-Source: APXvYqxaYkUwmGcAJraLqg4G+vOsNu/706UAcZzSgFXwGMIX6nC9bIaAYw2Ot3hqIjBushb5V6Ae X-Received: by 2002:a63:2cc9:: with SMTP id s192mr26372809pgs.24.1557127739158; Mon, 06 May 2019 00:28:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557127739; cv=none; d=google.com; s=arc-20160816; b=e5xyK1xubMmEiE9AEsEAralfe+aD6Wu14O3xxd7od75Vbzxki2807eGWgiDJSBJ3A7 nkVX46Bsy4j/xDoFNKOnrBZPWbbDndxfJLorEc5hy+H4klO8ArzfBRQNG//f/OLkRpPY N0gLr3m0sD6VvfsfJ9gLOcS69L+IS4bINUJvS/dqAWCj/1A8ToYuEPbnILcssnArmakv oqWLzhcppKdDe/CrxMLdA5f9hScQ+daoQsLQlIXkbJxAWAT4BLHwbXIWDYDKQPZkT8ZN tDuPCvEDPdzcFQMgsRMaUryI6MBT+6Z+sZfo/s/qjSxc0kt68+szGyRu14mPd/NB8CU/ UdDg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature; bh=XiE8oaht+rMtBmlWqUkyAiRGtKqurxER2iPBNv/AZyQ=; b=1JYE+vvWUo9rKU9LKblFoJMsXufqYpPND9WJXb8Qfx4CyDrzxM5w/X9eN3ZOWmS3E0 i7tX1Zq+xL1V6qbkrbKTOqZQ+vhMjdVAXKQPQ9lIXFZ0k8M67yGn18lHRjlFmvOR17Ng xJmYoqslKJMuKX3naNtKyYJC9r8gIUsUQA3rZnJf63WkaX0oVxP2IZVg1Kt6EwVMufyz gaQVx6y/p0YvHEDgVGxHUfbE6N32mzw469h0Rx2Zj0P1C5zuRwhHxJQLTRFXbRImXwah bSkMtxFfyHY5IKSa0feG65I4lKwvESqomqADUbtbV/TEJBrocdmCEaks88PoSjQbPo1V BsMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="QM6C/+Cx"; 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 j5si13850512pfa.63.2019.05.06.00.28.58; Mon, 06 May 2019 00:28:59 -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="QM6C/+Cx"; 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 S1726401AbfEFH26 (ORCPT + 30 others); Mon, 6 May 2019 03:28:58 -0400 Received: from mail-pl1-f195.google.com ([209.85.214.195]:39865 "EHLO mail-pl1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726255AbfEFH25 (ORCPT ); Mon, 6 May 2019 03:28:57 -0400 Received: by mail-pl1-f195.google.com with SMTP id e92so5926469plb.6 for ; Mon, 06 May 2019 00:28:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=XiE8oaht+rMtBmlWqUkyAiRGtKqurxER2iPBNv/AZyQ=; b=QM6C/+CxMNKnMh006FzIBzR75xV6ddm6r2gjuSGSnBTOuDfQ0qvMZAiep9jBsBelyX teqGh33rlt74rnloK7VIXqKkie8/XG90UQlY9PEUqS5i6oYPFe1u9h3hNCHny+nnwi01 sqd4g8X8ILX5QLXgsR+H16BiiIRX3xekPo/+zeuPEtWO8CBbs1UhDfu7RtPcFiwhRs+s xl5tF5Punv/vtUbqy/LiKvRqzGspIdKQN8b6+bHCzCbWHN+D+1W4fnyPKnGz1w98WLXf AXbuaK9LrIvC7nQKLYh/0PJxEvCq+BkYvRi/lRTtC5YWoagquPmnnPC/pTgi4/ky7SnV p3cQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=XiE8oaht+rMtBmlWqUkyAiRGtKqurxER2iPBNv/AZyQ=; b=fuHF05LvWzE6kl92x9PB61GsiHksmrZuSilyy5xuQtI3aS5JLWDIa0omM4Gz1HLd+e O26yRJuY1Bes6Wu44YHa+UuFUyJpWq1iSptxth1pPyNlXwsciiZyijAa+bPCrb44Bolu SsqjaU/gD57OjOSbu9ll+msDDbsp3fZuAUbph2+6lH96vR43jxNtyj4bm0tkqUY9LvdF uQ7dFfCWSLk9DCFNF3vGGJvMI+0npQ6VrlQ26YVvPOxTs/6RS8sGKGaBpHynx+Yolhnu 5QEvVGXcx1dFs9V1uf1+06yGv7XMDCyk1jvjAVZIkfQXLxN/VMYRYRQvxTIh1pDNBo+x iR8g== X-Gm-Message-State: APjAAAV/9yISIiZwpGM6TGOkdSYp3airrqkHc8pJYR50DKDF+wRJrhDt Q0NJxXZ5x2CxDW/6aLIcmZewOw== X-Received: by 2002:a17:902:7883:: with SMTP id q3mr30341452pll.60.1557127736687; Mon, 06 May 2019 00:28:56 -0700 (PDT) Received: from baolinwangubtpc.spreadtrum.com ([117.18.48.102]) by smtp.gmail.com with ESMTPSA id w38sm21700894pgk.90.2019.05.06.00.28.53 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 06 May 2019 00:28:56 -0700 (PDT) From: Baolin Wang To: dan.j.williams@intel.com, vkoul@kernel.org Cc: eric.long@unisoc.com, orsonzhai@gmail.com, zhang.lyra@gmail.com, vincent.guittot@linaro.org, baolin.wang@linaro.org, dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 2/6] dmaengine: sprd: Add validation of current descriptor in irq handler Date: Mon, 6 May 2019 15:28:29 +0800 Message-Id: <6eee7d5ad68d60ebedf443e24678e5b467fcf0e6.1557127239.git.baolin.wang@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When user terminates one DMA channel to free all its descriptors, but at the same time one transaction interrupt was triggered possibly, now we should not handle this interrupt by validating if the 'schan->cur_desc' was set as NULL to avoid crashing the kernel. Signed-off-by: Baolin Wang --- drivers/dma/sprd-dma.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) -- 1.7.9.5 diff --git a/drivers/dma/sprd-dma.c b/drivers/dma/sprd-dma.c index e29342a..431e289 100644 --- a/drivers/dma/sprd-dma.c +++ b/drivers/dma/sprd-dma.c @@ -552,12 +552,17 @@ static irqreturn_t dma_irq_handle(int irq, void *dev_id) schan = &sdev->channels[i]; spin_lock(&schan->vc.lock); + + sdesc = schan->cur_desc; + if (!sdesc) { + spin_unlock(&schan->vc.lock); + return IRQ_HANDLED; + } + int_type = sprd_dma_get_int_type(schan); req_type = sprd_dma_get_req_type(schan); sprd_dma_clear_int(schan); - sdesc = schan->cur_desc; - /* cyclic mode schedule callback */ cyclic = schan->linklist.phy_addr ? true : false; if (cyclic == true) { From patchwork Mon May 6 07:28:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "\(Exiting\) Baolin Wang" X-Patchwork-Id: 163386 Delivered-To: patch@linaro.org Received: by 2002:a92:3d95:0:0:0:0:0 with SMTP id k21csp1538869ilf; Mon, 6 May 2019 00:29:03 -0700 (PDT) X-Google-Smtp-Source: APXvYqyK+xCVax1IhgSD/9FUc4+Wgv2Wo2XaqtGkuU0Je4SB9ATvlcFnbTR0ibASaBthqXMwi16I X-Received: by 2002:a63:17:: with SMTP id 23mr30023953pga.206.1557127743703; Mon, 06 May 2019 00:29:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557127743; cv=none; d=google.com; s=arc-20160816; b=wJqEYsaHCzSc61SQkapRyYuWSVCW+5JAyDrmih1VVrXqLt6u0GbOHSAj/z4H+7bp4h QaR+v3DvjXp4lOUiEzeIuJ55Sw7cOv1m0MEuAAh9axcWv7PvfnojyqB3i7HHdG5xcO4F 205YxDpEBTRUGICRIQNK3iPnp7MqtdwBeONWWR+Iq7RVIXKEK9By3bEa7HQmPUVaBXKW Bvf4ESQ2J+i5/WjzDTv2SaIFb80kjRmGMf9xBEIVg/j4P7IELjqs9ne/W3TWlHupKQWW ZRud9a7u8eyt02seJAvoVM3hVpIUPeJk43ft0crgUCvnJ6Wu3frvKivWvSFVmbIwnPrk B7pg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature; bh=l9ir60nNJwBbII3Z7YfygeQjey9MNonvD8+mCs5l+c4=; b=Sb2jz7xurIpb6wFR/j5MB+P7ui5CS5cAmU91tCxSG5ya8VqkJG+BeIZ29eZUA7t+Ko 1N9IudEKnhI9jexaFqFlL8EcZ59UX0jc6ntvRSINdVJrHQeeYcMohpQQojUbABcYqizo D8W1knfOTbqKKRo5ISuD5KFaUJzHH0IxbemICjTsEmyqdJlXOE+doaAsd0sSbiGDw3Yz 3Ki9hprQO8ZceRXkMbxf7+PS3dH5WD1g1EDC3NyJXbxekUr0c6KfSiMtLormSCPTbgNv 4zGQYROBvNxK3pxB23cqKcF5k/IySI22ZkTPP6FUm5Fof4gYbZkPiVFnQz8H7lYJ05xf Uqzg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=n2PSKrwd; 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 g6si15245332pgi.21.2019.05.06.00.29.03; Mon, 06 May 2019 00:29:03 -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=n2PSKrwd; 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 S1726425AbfEFH3B (ORCPT + 30 others); Mon, 6 May 2019 03:29:01 -0400 Received: from mail-pl1-f193.google.com ([209.85.214.193]:40274 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726255AbfEFH3A (ORCPT ); Mon, 6 May 2019 03:29:00 -0400 Received: by mail-pl1-f193.google.com with SMTP id b3so5917306plr.7 for ; Mon, 06 May 2019 00:29:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=l9ir60nNJwBbII3Z7YfygeQjey9MNonvD8+mCs5l+c4=; b=n2PSKrwdQj4XW6hHAVV1KikTlODEKZzE2pd01SXQRpdWNe17PsxQpsoO8+rpMrDU4+ gjX+fvva0GM0YwQOAlkH3bQ0L3gN6CvjXX8LKTjcLnJ8JfIYMAaJMJ0Rt/HGr9KwWi3q sno8NGTlrG+7pdn6+ZSh+MtYL71LgwDH70MupbV4iBGbY+dgGqLU2A9QmIc30OtJC3eJ SJhoBXHge6hQ8fZ34sSO0YDLThB5T70SfFYgmEPtROCObtK38067TZ1Y6vyWKBJCgwfe vOc7avrYdgMQdfGTpjGs7b/OBoQXeMno7vWPv2+VHoI3Vw5np1I8CNc5t2EOAR9dYB59 a1xQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=l9ir60nNJwBbII3Z7YfygeQjey9MNonvD8+mCs5l+c4=; b=U0h3uh6vYhADB9F9pN9kliDfpeoGsjR4h1S64wHeSNNlDmurk9vSj4KVgHvf4zMyAN 1gdRGy8mLUXYGPevY/cGq17LQmkc+C7NdugurZj/ts46VV/h0CCSvBmou+OZI/AbFArT IBhCiNitWW5U1Oln1gCSGPa0zYIX1iFf0++BS9zf5hIILXghr99kDaN2YeL36kiNk0QR X1o01us2w8xjbADTFvx/dnCu4NqhSW/Hgscij+xXSfKgxiyFAtV8pll+5aG4vcVNcxir K95JptAtXlXQNL7qtYKGKF4+LbhtGq6lqFWDj9vqpeBEQiGYvTziYzTKM2hKbSOGVgLU g8vg== X-Gm-Message-State: APjAAAWyVuPkKliqabYa8dDQza1ffyBhIwyJmoZoQxFNiwx8eqJHhw2J h3uai7zaINhkNxQ8mIJvuu+kQQ== X-Received: by 2002:a17:902:141:: with SMTP id 59mr30356662plb.132.1557127740096; Mon, 06 May 2019 00:29:00 -0700 (PDT) Received: from baolinwangubtpc.spreadtrum.com ([117.18.48.102]) by smtp.gmail.com with ESMTPSA id w38sm21700894pgk.90.2019.05.06.00.28.56 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 06 May 2019 00:28:59 -0700 (PDT) From: Baolin Wang To: dan.j.williams@intel.com, vkoul@kernel.org Cc: eric.long@unisoc.com, orsonzhai@gmail.com, zhang.lyra@gmail.com, vincent.guittot@linaro.org, baolin.wang@linaro.org, dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 3/6] dmaengine: sprd: Fix the incorrect start for 2-stage destination channels Date: Mon, 6 May 2019 15:28:30 +0800 Message-Id: X-Mailer: git-send-email 1.7.9.5 In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Eric Long The 2-stage destination channel will be triggered by source channel automatically, which means we should not trigger it by software request. Signed-off-by: Eric Long Signed-off-by: Baolin Wang --- drivers/dma/sprd-dma.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) -- 1.7.9.5 diff --git a/drivers/dma/sprd-dma.c b/drivers/dma/sprd-dma.c index 431e289..0f92e60 100644 --- a/drivers/dma/sprd-dma.c +++ b/drivers/dma/sprd-dma.c @@ -510,7 +510,9 @@ static void sprd_dma_start(struct sprd_dma_chn *schan) sprd_dma_set_uid(schan); sprd_dma_enable_chn(schan); - if (schan->dev_id == SPRD_DMA_SOFTWARE_UID) + if (schan->dev_id == SPRD_DMA_SOFTWARE_UID && + schan->chn_mode != SPRD_DMA_DST_CHN0 && + schan->chn_mode != SPRD_DMA_DST_CHN1) sprd_dma_soft_request(schan); } From patchwork Mon May 6 07:28:31 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "\(Exiting\) Baolin Wang" X-Patchwork-Id: 163387 Delivered-To: patch@linaro.org Received: by 2002:a92:3d95:0:0:0:0:0 with SMTP id k21csp1538901ilf; Mon, 6 May 2019 00:29:06 -0700 (PDT) X-Google-Smtp-Source: APXvYqytvtHeX8OLNvbspH6jC5ylazClypA1/JRnu0kAmMOstkd+atZ9S3IOAZflz1bvSVpGljAQ X-Received: by 2002:aa7:810e:: with SMTP id b14mr32225940pfi.112.1557127746363; Mon, 06 May 2019 00:29:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557127746; cv=none; d=google.com; s=arc-20160816; b=AcOTLnpL/Vj4EqXIKYd6/Bb1Iyk/OasjW+SwB8YRhCXxBxFtZYAAN914NqOdjZlTqs L33353nAoHGxAez9YavuNHCgYghLg56lxEo2+4AWlnVwf6rTbX0Dft960Owik5Wj4y9F vhhIkOpkqHgvkBBjXDKADm0S1AJcA8CC8EDAV9lh0bsUZOz6CsaJghr4AKLf34aTM3yL PvoLkwdByAB/mBfwJi0pPiKfQ47C1PPFAC78JvO18f3ZEdo4TughmpOc40cBm8HtH4sp XOq3TDV/1hhVM6X8CVDFySORXSDQe7MFhSe07AvJzi1PPJMPh7rtkpkx3LwsDjgpDMcl kxOA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature; bh=+ZQ7qGOLCohxzfhci4Colal/Wo1QqAxCtZ4JkQsFwsU=; b=XPTldiIiyw8vfhB6XURknIbuPzgn5uC3zH8fN9yqP22c/SlDnVSwvs9sXx6//7Jmli sLyWNbCVh5BgV3JPZd1U2z2gXDBYFuPYQF8RkG0cjd7nD+8mhb5NjUW3BK1YycP6Hehn +6zcczkBdE5dH5+J0aeo7JuuEbkiXttdH4W1E3ev6URB/3tWq7vlidSPK9cgxjF9KN6d SIhpmuE5fYRoYVBWQI754gD+iqhPFOpoxvhKSZ6xg4+P1zqsF9MSwfLN7a9mfW4ypkxy uhO45WTV2DCQTf0c+xFPwv/l5BLLID+gkkhq2Mt8uJsOkzGpoCRMGI1WI7M7+87kO+EN uLjg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=m2MNCVwU; 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 g6si15245332pgi.21.2019.05.06.00.29.06; Mon, 06 May 2019 00:29:06 -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=m2MNCVwU; 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 S1726447AbfEFH3F (ORCPT + 30 others); Mon, 6 May 2019 03:29:05 -0400 Received: from mail-pg1-f193.google.com ([209.85.215.193]:32993 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725836AbfEFH3E (ORCPT ); Mon, 6 May 2019 03:29:04 -0400 Received: by mail-pg1-f193.google.com with SMTP id h17so56214pgv.0 for ; Mon, 06 May 2019 00:29:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=+ZQ7qGOLCohxzfhci4Colal/Wo1QqAxCtZ4JkQsFwsU=; b=m2MNCVwUhd8v/6Vi+YLmIm4RORKUiK2+BdHKTpNvCPAn0wxJbDla+fHvLPcWFxF24t T84EOuE6HFY1fWHQmAWxAqsqCJE28N/Q0G7KNTmeQMle8HgYrJSPmR5KWP3wr/cLnM1j /c0f7R2vJZshddyoxk2SyPRQECINjDxmV9fqQncGVl/QA9GvfeiJszqIDU4dgDaaIQaI WQrX8pw24wULbhMr1vlYfJW2Et9TjSTQaAOJsfn6a/mZ/NWRPupVVl3sEhHeRAs3cufW Ifjyz6nHqboVfhQov7y4HniXpqwS8tdMWA3pnpWPwTtmvsy43maQ5kGmZOYGwavkSJLB ta6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=+ZQ7qGOLCohxzfhci4Colal/Wo1QqAxCtZ4JkQsFwsU=; b=U2775Aa8A4E920TzqnnttAfbMQmQn6aIwWzYWdqgCYPnltOJEiXRpLphnu0iuny1u2 91H9ttAzUYttqo1qJoqmh7YVm6V7eXF0S+wTvtOax9xAgStfbvMQWN0EON0xQ7VUdfj7 eG+4VAxhoT2l66HxKOI686Vx8XzdHQpRQNR7dqM7DLFdzVDc4eVEd/YmPQ0I9PXUwzuF 73MQ7z5aMU4sxVQyJQ+RdePiN1f/ioL65jqwJLmpiMQbsGPiKLxgnXfkYZ6f/ABFAY80 5tb/TJaAk2NhzgauAJMKGi0m5zv2sAD6AcdbVx306D62mjMrpqcWpA6L878C3GliPBiM mfXg== X-Gm-Message-State: APjAAAXjQcPv7jh/JKFDQMQkFfODCTiAd24l76RdjmVeKdM9uqLAtVPj YbCSfqAI1oCp+EgfBzbLcRqffu220nLgMA== X-Received: by 2002:a63:1a03:: with SMTP id a3mr1369341pga.412.1557127743650; Mon, 06 May 2019 00:29:03 -0700 (PDT) Received: from baolinwangubtpc.spreadtrum.com ([117.18.48.102]) by smtp.gmail.com with ESMTPSA id w38sm21700894pgk.90.2019.05.06.00.29.00 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 06 May 2019 00:29:03 -0700 (PDT) From: Baolin Wang To: dan.j.williams@intel.com, vkoul@kernel.org Cc: eric.long@unisoc.com, orsonzhai@gmail.com, zhang.lyra@gmail.com, vincent.guittot@linaro.org, baolin.wang@linaro.org, dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 4/6] dmaengine: sprd: Fix block length overflow Date: Mon, 6 May 2019 15:28:31 +0800 Message-Id: <8f9a1748488e9d890995c158375482285253cc46.1557127239.git.baolin.wang@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Eric Long The maximum value of block length is 0xffff, so if the configured transfer length is more than 0xffff, that will cause block length overflow to lead a configuration error. Thus we can set block length as the maximum burst length to avoid this issue, since the maximum burst length will not be a big value which is more than 0xffff. Signed-off-by: Eric Long Signed-off-by: Baolin Wang --- drivers/dma/sprd-dma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 1.7.9.5 diff --git a/drivers/dma/sprd-dma.c b/drivers/dma/sprd-dma.c index 0f92e60..a01c232 100644 --- a/drivers/dma/sprd-dma.c +++ b/drivers/dma/sprd-dma.c @@ -778,7 +778,7 @@ static int sprd_dma_fill_desc(struct dma_chan *chan, temp |= slave_cfg->src_maxburst & SPRD_DMA_FRG_LEN_MASK; hw->frg_len = temp; - hw->blk_len = len & SPRD_DMA_BLK_LEN_MASK; + hw->blk_len = slave_cfg->src_maxburst & SPRD_DMA_BLK_LEN_MASK; hw->trsc_len = len & SPRD_DMA_TRSC_LEN_MASK; temp = (dst_step & SPRD_DMA_TRSF_STEP_MASK) << SPRD_DMA_DEST_TRSF_STEP_OFFSET; From patchwork Mon May 6 07:28:32 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "\(Exiting\) Baolin Wang" X-Patchwork-Id: 163388 Delivered-To: patch@linaro.org Received: by 2002:a92:3d95:0:0:0:0:0 with SMTP id k21csp1538933ilf; Mon, 6 May 2019 00:29:10 -0700 (PDT) X-Google-Smtp-Source: APXvYqz74ywC85ntRQQ3u3XDkHkNtZhsgxUqe3Gc9uHBuX4wUmyt35vd1/PBnjePGNQ+PCw9kFol X-Received: by 2002:a62:544:: with SMTP id 65mr31184628pff.46.1557127750336; Mon, 06 May 2019 00:29:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557127750; cv=none; d=google.com; s=arc-20160816; b=LvJcEny4bijcVwd9NaK8C6m3RtP+6z0nF16MvDnchE8EqX9Sq9YTCOpnwhuMxGgZlt Ih10VaN+ipXr31/x2Z57PGy+/63LBY/9r0g5YKZhLYUAr2Mbu0w2fe5cOo/zVExJGmVp l9BLgnKR21wr7pXsKVkjrOthjAKqe9YLnsQczOgzF0nGwB3IxnXI2Bo37XXcfGU80C39 71+XHpuoLG6v+K3NK6b2zBgUsPifTL6RqCFyFHmxE5Cv1klFc/wVrBlO+HNXeZi1yF/B iGLDZmpczOghC7Cq/qUUMHvWZkE1ViF+YWaEI1SD8pyJwcYp9fpol7hFWzX62qlgu6Vt EjeA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature; bh=f7WxjUUjnOPlZM9+bRj5MrZBRrYrZS5QSjQsKajsB4c=; b=tbCOTLgA1WtX5PD6eifjkCbebbvEknNCq4d8dyTaxg5j8Pd+zzuH5opLyFsl8KZ8au cegI5Fzvak69OZNyNouTYx/QqHHE8LZwM8GJ/PAzaOe1i+r5Vz6i9lizb9+MCYRQKT40 2JmWKo+R3ZqPDhDQmK4G1KE3XReDQ2EwXbmV0S2eaV6pnBBwQtHS6RnLQiDl2q+ZKoY/ MVtpWTs0ItJ2ieJlbGiPykt4N7GsiqfshFpTVedJd9ZjjIE45uMxv9yH+YsO5bzTe1I/ cerM9IERxHMDyqpKorajl1ueTuYH0RWDgfJfUsjbkFkUxXTfZuMM8lmokCRUyleDb//t wxmg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=fczeMukF; 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 a128si7261539pgc.242.2019.05.06.00.29.09; Mon, 06 May 2019 00:29:10 -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=fczeMukF; 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 S1726466AbfEFH3I (ORCPT + 30 others); Mon, 6 May 2019 03:29:08 -0400 Received: from mail-pg1-f193.google.com ([209.85.215.193]:39814 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726448AbfEFH3H (ORCPT ); Mon, 6 May 2019 03:29:07 -0400 Received: by mail-pg1-f193.google.com with SMTP id w22so4718156pgi.6 for ; Mon, 06 May 2019 00:29:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=f7WxjUUjnOPlZM9+bRj5MrZBRrYrZS5QSjQsKajsB4c=; b=fczeMukFRjRRR+1aDX01a1Sr2mHi7DtR4Gtz1E36ZgvfNGRxI7VHRp63sJWk5xuUVd o0Wb7seFcinpcZpharAZaaHr5ZZGvvzOMV9ME0H6FOdjrsnB9mbgM93u5eeuFSKsbI6j NYjZlaRe0WtRif1binGpkerwbW13qWMjK1tvAo/3YmkGInyZMpD9Y32gNvCyAB646HIy Z6vrWTbuSTDgmZ2BDBFp/TwHbNsDAHuQJYFoyyKd2YCECrvm4levP/dICyXtI8vJfDDQ OxWW8Ms0qtuB4MaRHjZs4uGlgrQRnwXpWURKM/IG96X4PBlpNiPvTTlbvE622E9RtDPk X/YA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=f7WxjUUjnOPlZM9+bRj5MrZBRrYrZS5QSjQsKajsB4c=; b=k26I4U2tXB1suramoQWErCbLUfshV3CYBXE25RL0rvyMG+wiScIo1rK8BcelGItKCg bJNyI/oKM6q3VxRH2siw//k15YMbJf6VquzpoOEAJgHei1iIz6ikTezKgyiXL1N4OgVS lk2+B38zqOyLCz8JLWZnSxiNj0eYTsAJUEYT7OgRJWj3OEa6FMUBNbFCao5BQto78vN9 gCkYn715b8rtL+QxblRtcXigJFjPl4KzaYYImCMv3c+zbTOLTyWiBIhkvLRy7gKymixW 1pWsRfGPRuBgVs/dwdy+5e+BOn5JKbIqQhLhe5j97HjC8O6BmWhOIMuM22PZyycmBOm8 uvSA== X-Gm-Message-State: APjAAAXLR2vLfuCR4vci86WDa/BZ9UluY+JMzUV6k4JgLpeDZVliaBEo j9xK361G/EHswL0CbhcWlIC+2g/6hb62ww== X-Received: by 2002:a63:e451:: with SMTP id i17mr30530636pgk.312.1557127746838; Mon, 06 May 2019 00:29:06 -0700 (PDT) Received: from baolinwangubtpc.spreadtrum.com ([117.18.48.102]) by smtp.gmail.com with ESMTPSA id w38sm21700894pgk.90.2019.05.06.00.29.03 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 06 May 2019 00:29:06 -0700 (PDT) From: Baolin Wang To: dan.j.williams@intel.com, vkoul@kernel.org Cc: eric.long@unisoc.com, orsonzhai@gmail.com, zhang.lyra@gmail.com, vincent.guittot@linaro.org, baolin.wang@linaro.org, dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 5/6] dmaengine: sprd: Fix the right place to configure 2-stage transfer Date: Mon, 6 May 2019 15:28:32 +0800 Message-Id: <7eb64b3319cfa1859f2912398700d4204553c028.1557127239.git.baolin.wang@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Eric Long Move the 2-stage configuration before configuring the link-list mode, since we will use some 2-stage configuration to fill the link-list configuration. Signed-off-by: Eric Long Signed-off-by: Baolin Wang --- drivers/dma/sprd-dma.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) -- 1.7.9.5 diff --git a/drivers/dma/sprd-dma.c b/drivers/dma/sprd-dma.c index a01c232..01abed5 100644 --- a/drivers/dma/sprd-dma.c +++ b/drivers/dma/sprd-dma.c @@ -911,6 +911,12 @@ static int sprd_dma_fill_linklist_desc(struct dma_chan *chan, schan->linklist.virt_addr = 0; } + /* Set channel mode and trigger mode for 2-stage transfer */ + schan->chn_mode = + (flags >> SPRD_DMA_CHN_MODE_SHIFT) & SPRD_DMA_CHN_MODE_MASK; + schan->trg_mode = + (flags >> SPRD_DMA_TRG_MODE_SHIFT) & SPRD_DMA_TRG_MODE_MASK; + sdesc = kzalloc(sizeof(*sdesc), GFP_NOWAIT); if (!sdesc) return NULL; @@ -944,12 +950,6 @@ static int sprd_dma_fill_linklist_desc(struct dma_chan *chan, } } - /* Set channel mode and trigger mode for 2-stage transfer */ - schan->chn_mode = - (flags >> SPRD_DMA_CHN_MODE_SHIFT) & SPRD_DMA_CHN_MODE_MASK; - schan->trg_mode = - (flags >> SPRD_DMA_TRG_MODE_SHIFT) & SPRD_DMA_TRG_MODE_MASK; - ret = sprd_dma_fill_desc(chan, &sdesc->chn_hw, 0, 0, src, dst, len, dir, flags, slave_cfg); if (ret) { From patchwork Mon May 6 07:28:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "\(Exiting\) Baolin Wang" X-Patchwork-Id: 163389 Delivered-To: patch@linaro.org Received: by 2002:a92:3d95:0:0:0:0:0 with SMTP id k21csp1538973ilf; Mon, 6 May 2019 00:29:13 -0700 (PDT) X-Google-Smtp-Source: APXvYqxr4bFz30XuJ4+RiMYj7cYamt2DA624ktbgBYS+8VEob0tDgKr6P6/HBNKqfpCYA7SRE76T X-Received: by 2002:a62:bd03:: with SMTP id a3mr31085694pff.81.1557127753794; Mon, 06 May 2019 00:29:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557127753; cv=none; d=google.com; s=arc-20160816; b=qKy4WFp+rrr3NpMvvASHBattYvFSfyEUSX8C13DwqMZwGMbdii6J7Oyg1a0xwVxSFD 5ysWdD+Res6+d6OvsnAUiZhbcfHKLqtUdXbUMbbTQNMcStxCQH3P8POnXiYiGg5/zCJj uTTZBT5ZO6wS8jmRAPpdvhIZL7RIDnC4hoejDAazFwhDps6FZ4Dp/a3lKkXyLYNBp/FW C8p3tcyfUxo9ZxXIh2WrGXI2C/dmQGDUjP9lgOzQadRfXWDgbUh23YVdyA2ktyOVwTI9 jsrnuldehay+dpYf/uIgQ2J742CFHKP6vjNLkYBrLLUD9CCcMwRbOHZvzWpl3yjmAhrA F/OQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature; bh=211d8ZTQI3btAur7YnSUlr/RUpH4zvR8vL+Saj1rS5o=; b=Lso8DUiy4Q/qTg41eD3pLFFh4Ug6YdYEB9dyasy/7vgtSbE1d/eGjsRPZpf5cwroRh qhn0CabixpN3dwoXtZUFjsv76hAAgu2/K0Ud4W6QRU2e++GPKcXWLpsvqhllB6Wmb+Or 5r+3zVaVBaEPBp7JlsHK56992U88eWk66O7K7CiVwKWLiu8QpluiiHyetf+CxlJt1V6Y 9rTh4uWGwMI4ufDtvV7IswQfQoXG8btWWAtDps9PV1JH8qKS2LsV4BWSIjxiiIrlfASc JU1xTLDQAkW8G2qG6q1Gn0bhDRmqvAo+9XqejnR0QH1inF8u2t+B4cuiSEDdu5Q7pPbr Yb+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jo3K4Scd; 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 a128si7261539pgc.242.2019.05.06.00.29.13; Mon, 06 May 2019 00:29:13 -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=jo3K4Scd; 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 S1726484AbfEFH3M (ORCPT + 30 others); Mon, 6 May 2019 03:29:12 -0400 Received: from mail-pg1-f195.google.com ([209.85.215.195]:45583 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726448AbfEFH3K (ORCPT ); Mon, 6 May 2019 03:29:10 -0400 Received: by mail-pg1-f195.google.com with SMTP id i21so6017173pgi.12 for ; Mon, 06 May 2019 00:29:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=211d8ZTQI3btAur7YnSUlr/RUpH4zvR8vL+Saj1rS5o=; b=jo3K4Scdrs1k7OvhlUC3Vu6KN+wS+aF0U3qudxCeN/Ts9VlRxCjFMr46/su1MGI9mX B0I01reNOOD0ZaHGwco7gr4FJEycBmyHjrgjB07y+GEf+NVM1lLsbzAl3Qr5gulmikdj uXIBABZq+91UQZ8NFVIO/bkfFlr7jv0PgZvAemLVWFjoH+9+a3KT7mH1nQuyqXXcZ4w6 zie4wrpqjqHhXytnykFQHis0Y/66Wq3JVD0ZIiRXGfxkWnCKzWH00MK5kQA4RQ6LQu6t 8Gj30YLpIu1qPXyFyhtZWQ/cgOeplpaBP5FvMx6XM4wIqI9yM91uhnJjppwLhjkU/a0q 5bCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=211d8ZTQI3btAur7YnSUlr/RUpH4zvR8vL+Saj1rS5o=; b=K1tfJfUWvubFvylHdJPRlm65qMHiXEEb/Dgz0U1EGPnigF2Lsq52dS/mcPXPTiHFk+ qM2R3AhMZI4ls0sOEiNyqtxSOs0gx2/Tu9d4WAr2rCf+HovZgL6lsV6nt665pesz+Fr6 hkqC6JCrUvm/fOmoR4ERI9ro0zgqQlR6GCj0s+S0KzEpbXcfHk1hMxKH8udrxNTpIAFt ySw8dLzlJ+Wi+wIc7xxwo2G5Kr0QXhaOgOleVBD38upWMx9GUuRF6i2zubPobAAEIq9E NEMM4zjMswWD1P3Vqx73FK/RVHobFeYk/1L4oXGbSXgwDzjkh5ZxRlIz47kutD16PMDU HJdA== X-Gm-Message-State: APjAAAUbU1aADWBisrM+Arzs5DQEu8CjhOfaMjMAD7g9nrZ0NHrF5KGi WDXtqrBPERk7sREggyksPKB86g== X-Received: by 2002:a63:1cf:: with SMTP id 198mr22124192pgb.155.1557127750187; Mon, 06 May 2019 00:29:10 -0700 (PDT) Received: from baolinwangubtpc.spreadtrum.com ([117.18.48.102]) by smtp.gmail.com with ESMTPSA id w38sm21700894pgk.90.2019.05.06.00.29.07 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 06 May 2019 00:29:09 -0700 (PDT) From: Baolin Wang To: dan.j.williams@intel.com, vkoul@kernel.org Cc: eric.long@unisoc.com, orsonzhai@gmail.com, zhang.lyra@gmail.com, vincent.guittot@linaro.org, baolin.wang@linaro.org, dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 6/6] dmaengine: sprd: Add interrupt support for 2-stage transfer Date: Mon, 6 May 2019 15:28:33 +0800 Message-Id: <23f960d05bc30a93fb128cde53ad798cc6c7c19d.1557127239.git.baolin.wang@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org For 2-stage transfer, some users like Audio still need transaction interrupt to notify when the 2-stage transfer is completed. Thus we should enable 2-stage transfer interrupt to support this feature. Signed-off-by: Baolin Wang --- drivers/dma/sprd-dma.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) -- 1.7.9.5 diff --git a/drivers/dma/sprd-dma.c b/drivers/dma/sprd-dma.c index 01abed5..baac476 100644 --- a/drivers/dma/sprd-dma.c +++ b/drivers/dma/sprd-dma.c @@ -62,6 +62,8 @@ /* SPRD_DMA_GLB_2STAGE_GRP register definition */ #define SPRD_DMA_GLB_2STAGE_EN BIT(24) #define SPRD_DMA_GLB_CHN_INT_MASK GENMASK(23, 20) +#define SPRD_DMA_GLB_DEST_INT BIT(22) +#define SPRD_DMA_GLB_SRC_INT BIT(20) #define SPRD_DMA_GLB_LIST_DONE_TRG BIT(19) #define SPRD_DMA_GLB_TRANS_DONE_TRG BIT(18) #define SPRD_DMA_GLB_BLOCK_DONE_TRG BIT(17) @@ -135,6 +137,7 @@ /* define DMA channel mode & trigger mode mask */ #define SPRD_DMA_CHN_MODE_MASK GENMASK(7, 0) #define SPRD_DMA_TRG_MODE_MASK GENMASK(7, 0) +#define SPRD_DMA_INT_TYPE_MASK GENMASK(7, 0) /* define the DMA transfer step type */ #define SPRD_DMA_NONE_STEP 0 @@ -190,6 +193,7 @@ struct sprd_dma_chn { u32 dev_id; enum sprd_dma_chn_mode chn_mode; enum sprd_dma_trg_mode trg_mode; + enum sprd_dma_int_type int_type; struct sprd_dma_desc *cur_desc; }; @@ -429,6 +433,9 @@ static int sprd_dma_set_2stage_config(struct sprd_dma_chn *schan) val = chn & SPRD_DMA_GLB_SRC_CHN_MASK; val |= BIT(schan->trg_mode - 1) << SPRD_DMA_GLB_TRG_OFFSET; val |= SPRD_DMA_GLB_2STAGE_EN; + if (schan->int_type != SPRD_DMA_NO_INT) + val |= SPRD_DMA_GLB_SRC_INT; + sprd_dma_glb_update(sdev, SPRD_DMA_GLB_2STAGE_GRP1, val, val); break; @@ -436,6 +443,9 @@ static int sprd_dma_set_2stage_config(struct sprd_dma_chn *schan) val = chn & SPRD_DMA_GLB_SRC_CHN_MASK; val |= BIT(schan->trg_mode - 1) << SPRD_DMA_GLB_TRG_OFFSET; val |= SPRD_DMA_GLB_2STAGE_EN; + if (schan->int_type != SPRD_DMA_NO_INT) + val |= SPRD_DMA_GLB_SRC_INT; + sprd_dma_glb_update(sdev, SPRD_DMA_GLB_2STAGE_GRP2, val, val); break; @@ -443,6 +453,9 @@ static int sprd_dma_set_2stage_config(struct sprd_dma_chn *schan) val = (chn << SPRD_DMA_GLB_DEST_CHN_OFFSET) & SPRD_DMA_GLB_DEST_CHN_MASK; val |= SPRD_DMA_GLB_2STAGE_EN; + if (schan->int_type != SPRD_DMA_NO_INT) + val |= SPRD_DMA_GLB_DEST_INT; + sprd_dma_glb_update(sdev, SPRD_DMA_GLB_2STAGE_GRP1, val, val); break; @@ -450,6 +463,9 @@ static int sprd_dma_set_2stage_config(struct sprd_dma_chn *schan) val = (chn << SPRD_DMA_GLB_DEST_CHN_OFFSET) & SPRD_DMA_GLB_DEST_CHN_MASK; val |= SPRD_DMA_GLB_2STAGE_EN; + if (schan->int_type != SPRD_DMA_NO_INT) + val |= SPRD_DMA_GLB_DEST_INT; + sprd_dma_glb_update(sdev, SPRD_DMA_GLB_2STAGE_GRP2, val, val); break; @@ -911,11 +927,15 @@ static int sprd_dma_fill_linklist_desc(struct dma_chan *chan, schan->linklist.virt_addr = 0; } - /* Set channel mode and trigger mode for 2-stage transfer */ + /* + * Set channel mode, interrupt mode and trigger mode for 2-stage + * transfer. + */ schan->chn_mode = (flags >> SPRD_DMA_CHN_MODE_SHIFT) & SPRD_DMA_CHN_MODE_MASK; schan->trg_mode = (flags >> SPRD_DMA_TRG_MODE_SHIFT) & SPRD_DMA_TRG_MODE_MASK; + schan->int_type = flags & SPRD_DMA_INT_TYPE_MASK; sdesc = kzalloc(sizeof(*sdesc), GFP_NOWAIT); if (!sdesc)