Received: by 10.213.65.68 with SMTP id h4csp2119804imn; Sun, 8 Apr 2018 20:11:41 -0700 (PDT) X-Google-Smtp-Source: AIpwx4922kYzZxklmKKAlpXJBroy49n2pUEesVEPpruqyn4kRsapDKSJLZbw3u0vFjrIixv6cLzb X-Received: by 10.167.128.141 with SMTP id v13mr27782428pff.147.1523243420436; Sun, 08 Apr 2018 20:10:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523243420; cv=none; d=google.com; s=arc-20160816; b=00kFVDPHJcKLy81TzGvGOegwtX7L2hzbLJsVDTgZo+H4oAW2H4EEelm5awshqDcmlv ZM9RhI//sMwwYKsRMezQ9Ith+p75HPDF995MxgbJipiUC+Gz7Up1dv17LilEocJ5un33 FvIuQyvhIAgmE5b0GJg7Hawqi+wlBlDa2oQ7E52/xMKBwf24RgiT3v8reHc23KRAGQAt 5bWw/thhyWGaAnnqzxKpMHgDril29MJkLOSUQBtd9BqL3yp+0ICepE+ytuPBhkPNdSEP UZlGD27yJra37RJ3vGaQhgkkTKpuh4xQECIRP/GmKRAoz3uJSkOcSzcHCxZALfXj3Ood SHsQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :spamdiagnosticmetadata:spamdiagnosticoutput:content-language :accept-language:in-reply-to:references:message-id:date:thread-index :thread-topic:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=2FLSf+V37WlOVLvSHr2ISBcV5YDtvv5Fyljmg3ZO77I=; b=z5fd+ueomV1g6c2MCZGNqauq3yA58c8VgnxJ3MYRPQJWDwNlPA8FqdCXUHZCpWTYhk kZBM3QEMdNS4VKWMDUy94PPvUC97i3FI+CQ11hmymmJIfYKdGaM7CD8U7NIInNcWdtBa GTT3H21CFLthqYpZZClWEPssm1IfHZFdeEsTnM74UP4N3HyfV+gCcEcei2TaB6NezQQs mPpD596SXb8q484V3yKDAAZhAgFKEsTTbQrGNcOdO5psQsy4l9+2RxKVEjsg8HQrZSlM 4dVUY6PW/bp5gT6HejWAUCzKw3qgXJ8rKkDmszBIs+Y2DRYcqO4MkvlRzGAKE/XXtYeC 7qSg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=VsWUGN8X; 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=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u8-v6si13671959plh.469.2018.04.08.20.09.44; Sun, 08 Apr 2018 20:10:20 -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=@microsoft.com header.s=selector1 header.b=VsWUGN8X; 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=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932298AbeDICCy (ORCPT + 98 others); Sun, 8 Apr 2018 22:02:54 -0400 Received: from mail-sn1nam01on0103.outbound.protection.outlook.com ([104.47.32.103]:45281 "EHLO NAM01-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1756418AbeDIAcI (ORCPT ); Sun, 8 Apr 2018 20:32:08 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=2FLSf+V37WlOVLvSHr2ISBcV5YDtvv5Fyljmg3ZO77I=; b=VsWUGN8XC4v0uT4ir47mmlWe3z6MWFBZspZXV/17Bn99tSzZgBuV8Mfzx+vicu8oCU9eRpYdWzujne+FOGZEMoqYak+MFRsVq8RGqJQwz5U+y6IDs4vTwHRroY322zqk+prLbn2Enjv5Ar7jSFztxsD5BwOHFgaPQrLMABglFdI= Received: from DM5PR2101MB1032.namprd21.prod.outlook.com (52.132.128.13) by DM5PR2101MB0870.namprd21.prod.outlook.com (10.167.110.165) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.696.0; Mon, 9 Apr 2018 00:32:05 +0000 Received: from DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::8109:aef0:a777:7059]) by DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::8109:aef0:a777:7059%2]) with mapi id 15.20.0696.003; Mon, 9 Apr 2018 00:32:05 +0000 From: Sasha Levin To: "stable@vger.kernel.org" , "linux-kernel@vger.kernel.org" CC: Sinan Kaya , Vinod Koul , Sasha Levin Subject: [PATCH AUTOSEL for 4.9 196/293] dmaengine: qcom_hidma: correct API violation for submit Thread-Topic: [PATCH AUTOSEL for 4.9 196/293] dmaengine: qcom_hidma: correct API violation for submit Thread-Index: AQHTz5lCLrROEPgki0OtEAEhkDT9mw== Date: Mon, 9 Apr 2018 00:25:27 +0000 Message-ID: <20180409002239.163177-196-alexander.levin@microsoft.com> References: <20180409002239.163177-1-alexander.levin@microsoft.com> In-Reply-To: <20180409002239.163177-1-alexander.levin@microsoft.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [52.168.54.252] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;DM5PR2101MB0870;7:zgulnKALxB0RjZ1dxZzSGbIYjN+5kVvIM1gOso8dSCVoAgMqYcyhSwejgRN8BmzQXp6UytNMT84sjCMEP28797d55ZZNjHP/QGxzqqtyFthfkhYSQWMF2Ub6EOfE2MAS+3+aYvkXlT7CLOHI/vxjDM+N2m38i26EJRYAjFXIHQfrPmYOWYJ/B3mQ7zh+wAb4+MwRJ1R/bWiUHkU10pHxM+BIue4dxKDz5SgodAjra1mJ8oWKXJGRjsMoHxPlWy/j;20:3SfR5Jsugjk5tF9ISdw4rPhRcs8NqgiQPDaFlNA1S3doA7rro8swIUXi3/KMj7EgVN/8uTpqlK798M43LpmPoU7CfWfeznnMcfi/hEI7uwkPvO10kST6HNWaQv3u1YBvHZoHYn+r5/YOR/V4fCDlB7cOHkFatqRAzKafi+YGY14= x-ms-office365-filtering-ht: Tenant X-MS-Office365-Filtering-Correlation-Id: 581e725b-5165-4b58-7804-08d59db151fe x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(3008032)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7193020);SRVR:DM5PR2101MB0870; x-ms-traffictypediagnostic: DM5PR2101MB0870: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alexander.Levin@microsoft.com; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(28532068793085)(89211679590171)(228905959029699); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(8211001083)(61425038)(6040522)(2401047)(8121501046)(5005006)(3002001)(10201501046)(3231221)(944501327)(52105095)(93006095)(93001095)(6055026)(61426038)(61427038)(6041310)(20161123558120)(20161123560045)(20161123564045)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011);SRVR:DM5PR2101MB0870;BCL:0;PCL:0;RULEID:;SRVR:DM5PR2101MB0870; x-forefront-prvs: 0637FCE711 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(346002)(39860400002)(366004)(396003)(39380400002)(376002)(199004)(189003)(53936002)(2906002)(6512007)(102836004)(2616005)(76176011)(14454004)(446003)(10090500001)(11346002)(476003)(486006)(107886003)(59450400001)(2900100001)(97736004)(66066001)(6506007)(6436002)(106356001)(99286004)(105586002)(3660700001)(6116002)(86612001)(3280700002)(6666003)(2501003)(10290500003)(26005)(8676002)(8936002)(478600001)(68736007)(5250100002)(5660300001)(316002)(4326008)(72206003)(186003)(110136005)(6486002)(7736002)(25786009)(3846002)(86362001)(36756003)(22452003)(81156014)(81166006)(575784001)(305945005)(54906003)(1076002)(22906009)(217873001);DIR:OUT;SFP:1102;SCL:1;SRVR:DM5PR2101MB0870;H:DM5PR2101MB1032.namprd21.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: EJKwfbHqbI4l3ieknahsHbcGEE3gXh5ZCxEM8I4Cm2h535YzpfD8N6r5eoITvg39Crmrgf1BFzLwF8ko2H3yK4XZuvosrTA3fMropTUIi/0/oXkArK0eberTayDTRRZcONqEZltYnS6VFnh/mjoFNVtpP9jPPgHHwtAXCy/f1VXqRfEfzrVHlJfOypqZz+mRp1IbWXycbv4XyZ5KGQn/9OugpAniLRt+rshrqqqYgQJz/uiIFj386NcDfxJJGHGsZFvjvReZ+IzMcFdJvHQsJPmCd4LD/rkirYe20dSakG9F2uUFUKrAC7NkGaEJ0sitetvQ39SR7Q5GN+p5lH9KOzZTmser9iAD7YjJ9Q/7860+qlHR3wFLAZENFhnIZlFQ8WbZTSj+0Idr/tBtcjwvr+P4arN5fs0SILUrRZTqhYM= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: 581e725b-5165-4b58-7804-08d59db151fe X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Apr 2018 00:25:27.3471 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR2101MB0870 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Sinan Kaya [ Upstream commit 99efdb3e48fb2fa84addb3102946d3eca341192b ] Current code is violating the DMA Engine API by putting the submitted requests directly into the HW queue. This causes queued transactions to be started by another thread as soon as the first one finishes. The DMA Engine document clearly states this. "dmaengine_submit() will not start the DMA operation". Move HW queuing of the requests into the issue_pending() routine to comply with API requirements also create a new queued state for temporarily holding the requests. A descriptor goes through these transitions now. free->prepared->queued->active->completed->free as opposed to free->prepared->active->completed->free Signed-off-by: Sinan Kaya Signed-off-by: Vinod Koul Signed-off-by: Sasha Levin --- drivers/dma/qcom/hidma.c | 15 ++++++++++++--- drivers/dma/qcom/hidma.h | 1 + 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/drivers/dma/qcom/hidma.c b/drivers/dma/qcom/hidma.c index e244e10a94b5..d38a2ceaa0dc 100644 --- a/drivers/dma/qcom/hidma.c +++ b/drivers/dma/qcom/hidma.c @@ -208,6 +208,7 @@ static int hidma_chan_init(struct hidma_dev *dmadev, u3= 2 dma_sig) INIT_LIST_HEAD(&mchan->prepared); INIT_LIST_HEAD(&mchan->active); INIT_LIST_HEAD(&mchan->completed); + INIT_LIST_HEAD(&mchan->queued); =20 spin_lock_init(&mchan->lock); list_add_tail(&mchan->chan.device_node, &ddev->channels); @@ -228,9 +229,15 @@ static void hidma_issue_pending(struct dma_chan *dmach= ) struct hidma_chan *mchan =3D to_hidma_chan(dmach); struct hidma_dev *dmadev =3D mchan->dmadev; unsigned long flags; + struct hidma_desc *qdesc, *next; int status; =20 spin_lock_irqsave(&mchan->lock, flags); + list_for_each_entry_safe(qdesc, next, &mchan->queued, node) { + hidma_ll_queue_request(dmadev->lldev, qdesc->tre_ch); + list_move_tail(&qdesc->node, &mchan->active); + } + if (!mchan->running) { struct hidma_desc *desc =3D list_first_entry(&mchan->active, struct hidma_desc, @@ -313,17 +320,18 @@ static dma_cookie_t hidma_tx_submit(struct dma_async_= tx_descriptor *txd) pm_runtime_put_autosuspend(dmadev->ddev.dev); return -ENODEV; } + pm_runtime_mark_last_busy(dmadev->ddev.dev); + pm_runtime_put_autosuspend(dmadev->ddev.dev); =20 mdesc =3D container_of(txd, struct hidma_desc, desc); spin_lock_irqsave(&mchan->lock, irqflags); =20 - /* Move descriptor to active */ - list_move_tail(&mdesc->node, &mchan->active); + /* Move descriptor to queued */ + list_move_tail(&mdesc->node, &mchan->queued); =20 /* Update cookie */ cookie =3D dma_cookie_assign(txd); =20 - hidma_ll_queue_request(dmadev->lldev, mdesc->tre_ch); spin_unlock_irqrestore(&mchan->lock, irqflags); =20 return cookie; @@ -429,6 +437,7 @@ static int hidma_terminate_channel(struct dma_chan *cha= n) list_splice_init(&mchan->active, &list); list_splice_init(&mchan->prepared, &list); list_splice_init(&mchan->completed, &list); + list_splice_init(&mchan->queued, &list); spin_unlock_irqrestore(&mchan->lock, irqflags); =20 /* this suspends the existing transfer */ diff --git a/drivers/dma/qcom/hidma.h b/drivers/dma/qcom/hidma.h index e52e20716303..03775ca940e2 100644 --- a/drivers/dma/qcom/hidma.h +++ b/drivers/dma/qcom/hidma.h @@ -103,6 +103,7 @@ struct hidma_chan { struct dma_chan chan; struct list_head free; struct list_head prepared; + struct list_head queued; struct list_head active; struct list_head completed; =20 --=20 2.15.1