From patchwork Mon Jul 23 17:46:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robin Gong X-Patchwork-Id: 10539819 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5E0FC91E for ; Mon, 23 Jul 2018 09:46:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4BF24285A6 for ; Mon, 23 Jul 2018 09:46:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 40584285AA; Mon, 23 Jul 2018 09:46:00 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DATE_IN_FUTURE_06_12,DKIM_SIGNED,DKIM_VALID,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id C30EB285AD for ; Mon, 23 Jul 2018 09:45:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=JD10sbTYTNY/vNp29g1GQFz21Uy+idy1EU5AaO4g2iE=; b=W11rPRaVOSrpIh kJMzM8wz3r2mar59o0LdzUbcEmKYEjX2rMHv16RDz80D3KtKAw9MaC+D5gDvZbdvW2FCPKaru8PEe bkVC51J0uq2bK5JABOddEFHY0Jj9TZ/XYvW1odDMnl7PR8rMn4ziSwaYxPhxO7fCK+urHDDlQJu+o 0HJvDAKPvGGnZnahfa28Y7Md3q+gBqxzVgwtYAyvO+6fnmENByrFpCW3vAZLX5ZNFGhMD7Nnb6Quc 875coHRIGpRpqmHzORJaPpf+muenSFWE6BbqRFaGB8u7Tie3m6yygGlXni6hib6YCdfE4SafeDJlC CIisW0chGGlVIzaY2nGQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fhXPe-0005lk-6a; Mon, 23 Jul 2018 09:45:54 +0000 Received: from mail-eopbgr10061.outbound.protection.outlook.com ([40.107.1.61] helo=EUR02-HE1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fhXPQ-0005UL-6S for linux-arm-kernel@lists.infradead.org; Mon, 23 Jul 2018 09:45:41 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=2dGpd66jhEso6apISiQaFJu5TVvSKsEqdowif2s3tEk=; b=hyMRQBcZIzSUC5d4p3yoeJJTaxQ82a/uBFoQRWx2/1eZ67I2CN5/OSonS77+VypsRwbwR8o0gejO4GiUhfZIxohpip+Pe+BN6JKjHr+Nw1NL3nTJj2NwHirQaW3nqUvjXQiJQY9jlPywfCv4YWktt0OSn/c3giBmqCLuAf+kMxY= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=yibin.gong@nxp.com; Received: from robin-OptiPlex-790.ap.freescale.net (119.31.174.66) by VI1PR04MB3232.eurprd04.prod.outlook.com (2603:10a6:802:6::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.973.21; Mon, 23 Jul 2018 09:45:28 +0000 From: Robin Gong To: vkoul@kernel.org, dan.j.williams@intel.com, s.hauer@pengutronix.de, linux@armlinux.org.uk Subject: [PATCH v3 1/3] dmaengine: imx-sdma: add SDMA_BD_MAX_CNT to replace '0xffff' Date: Tue, 24 Jul 2018 01:46:10 +0800 Message-Id: <1532367972-29707-2-git-send-email-yibin.gong@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1532367972-29707-1-git-send-email-yibin.gong@nxp.com> References: <1532367972-29707-1-git-send-email-yibin.gong@nxp.com> MIME-Version: 1.0 X-Originating-IP: [119.31.174.66] X-ClientProxiedBy: HK0PR03CA0086.apcprd03.prod.outlook.com (2603:1096:203:72::26) To VI1PR04MB3232.eurprd04.prod.outlook.com (2603:10a6:802:6::29) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 41066a21-8e42-4dc7-6677-08d5f0810806 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989117)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(5600073)(711020)(4618075)(2017052603328)(7153060)(7193020); SRVR:VI1PR04MB3232; X-Microsoft-Exchange-Diagnostics: 1; VI1PR04MB3232; 3:AHspo+dY4FZmazc4LuR96dz8nGB6sAt4U3zvV1e3Q8NDZ0xrowjU+6WzFhVWO4/WWLc9O//nY18XryN/dOn95RwqAKhKjDVVh66jzboG3SBCIs1KibaNe1elMODQqA8ly1NWf0ljW5+HuKuY+BLkQTxzwdqVtNDat9kS7r0ixHovYSfTodhbU68ArDwickxm5uL0Z0jd48Gl9rDlB4Torl+7eSew5NjQu20CZj206xITujMHaFEHEd2tmfaZZhZW; 25:+k5SAX6nrp19OAITcr3VnTDoapgNzmjx9dfjCI5T208uV1tCi+ZAWG0nXr6khFzRYmRflfofNzzaCo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; 4:LqZrayEuk2WYN+/yePv3MJbYD+G/J2Rr1mNhCww9KJDj4/vogMA8o7Q8K8GuLvNAEDlFCEtA5PFWcLzEOG7hisRp/CBM9PRAAW0XelRrbHb1ZzVW2Rf+++8Ee7wbdo8KRnPhJDc2xpEAp9vLVGoql3sYOkiOIcDlKzlvJOwVMDjWRN9dmzk3zzrnteDTmVl3VbfC2AuAk3tvM2XvgbTFqRpQC3h5VP0/pxxBH7qzLwrZvXQLAFBLmG+6NN2FfYrvobe475v5WSAOsVIVByDo6Jvzsml45g2RUzpOYtNp1fkEqlbpp4+gx8B6Bocnex3txtoBRHPdz8TmX8QMLeVfQLs/e+w8QUWYGpIzkC7EpjM= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(185117386973197)(788757137089); X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(3002001)(10201501046)(93006095)(93001095)(3231311)(944501410)(52105095)(6055026)(149027)(150027)(6041310)(20161123562045)(20161123558120)(20161123564045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011)(7699016); SRVR:VI1PR04MB3232; BCL:0; PCL:0; RULEID:; SRVR:VI1PR04MB3232; X-Forefront-PRVS: 0742443479 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(396003)(366004)(346002)(136003)(39860400002)(376002)(199004)(189003)(16526019)(6116002)(3846002)(956004)(8936002)(66066001)(47776003)(53936002)(478600001)(305945005)(26005)(50466002)(48376002)(476003)(2616005)(6512007)(25786009)(7736002)(4326008)(11346002)(6506007)(386003)(14444005)(36756003)(50226002)(106356001)(97736004)(446003)(5660300001)(68736007)(6666003)(105586002)(2906002)(486006)(81166006)(8676002)(52116002)(81156014)(186003)(86362001)(51416003)(16586007)(6486002)(316002)(76176011); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR04MB3232; H:robin-OptiPlex-790.ap.freescale.net; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; Received-SPF: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; VI1PR04MB3232; 23:MjA+KuMUAYRdOwmdMdnKTlvTw76sETVA/8P5aT5Kh?= s3yrCnlDcqFrqZxwo0mMfhqnMLpV90Vx96edNmjHIjTq01403fqUfMSnco9JorkG+ldqjmMkygU+NELwTO8cRrTMA3bsSBMjFY6IcgRZI5gwgTsper8Jfld+TzGWMqocywK2zJyOHnAih528GXfTw9Ux3DHy/bqfT27ZIDnfUz82QVPHpNgWJaIxyzRuDwOijq8OU5GmOM7FAFrq86FiPujKUrBPAjnwrE5lTrKTh9c+1aZcs2PmFIDG2RLpOtFtR8lESR15etmPZUzruRLwnOHBC5l51hRNILvf6hLEea+2gaXgg44sPDe5uDM4MLs/9CD4JhfsaMI7IAQ7KQPQ1QqgIq9VxYvN5Tj17dhpw8Bdq93reS50t6ds6t4n4eh6ab8hIdFHaFc8mPFi3HzPt+usmPBYsFzu06d+5gcH5BbqYZIRsmm3QHbF2gmbqLEfucwuygP92MLMKrjnqtUXiUpFEJXxZ2sKjUMsxBG2+Mcg1bSATJgHoAm7UhF8DK1bHZJPx8UpiWk8d+5MlcDg1hEbWdSsiqX44NQmAQVBOBxeoGD2mFgTWmgBj6jTtHd3xj+/mpIXJstIOqa6n+12eLsEGd5MoqOytwX7I4tl4L7fvsJyKq7GjQ5jCW7qWASw2PnXzM+6lItpEo2VHR3nOHG6M28dpLBVGHeCEZG21MAiABsWZIwQa4+HJTAwoH77mQNXLXfObVYNrsCc3y9sOPC/A8vUk6xvS3NmJqKJZ1z48xSFSXR6jtePB063deCQRN4JnUi1LH2nEVs3X7X+03GksDIqfPdvm0qBcLtNSjZjod1Bqp6GVX5CSUw/oxpPzrkwFLsE+MTXGuZz6VCCKMrq4plJjKvCQE3gmDA8rfJw+uiaswnqMUBO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VDKTLzXVMvBbiQO+gPLC2uxDacejzbXuuwtKoToutQuDskDFB6rvsg==; 5:HuXSZjOBmgOD1Ldp9ibNS7VmIwkb+gm2Ws4yldoFFgYvsOjnJVUrTSYk1zqR6ogIRsRv69xvV/+y7fXT08BMjfXaQVncjm//Upzn7FLTckF1wAhzmf5UMIARvjOqieOlX94Sl2utK4//9jqtAvwfnADqfYlqpJsaLowr2JJEt6A=; 7:0mpMEANkwuzCYr4Gysz+NnCWg1XkkSQNuI6I50uTgEEbX4fXKeKZOgkXc+ZJYiMYWvNgOCqhdKB4DgL4X+4vXhbDsiVckcKlHpBeou3rpWaFvUlt98GqMHcl+C43nDPMYhbTgYK0b+33deTtCRCWdnhZyoXFmFjii45brV4fU5aZah6GpYi5ZPRvnGP/ahSk7dz+gNpnk5etRs0hBNMb1fRkgqNwDUcfXJ12fd1fmGMJBpwbC9emySmD3vjYTVYa SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Jul 2018 09:45:28.6533 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 41066a21-8e42-4dc7-6677-08d5f0810806 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB3232 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180723_024540_235767_2BACA266 X-CRM114-Status: GOOD ( 13.16 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: dmaengine@vger.kernel.org, linux-imx@nxp.com, kernel@pengutronix.de, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Add macro SDMA_BD_MAX_CNT to replace '0xffff'. Signed-off-by: Robin Gong --- drivers/dma/imx-sdma.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/drivers/dma/imx-sdma.c b/drivers/dma/imx-sdma.c index 3b622d6..e3d5e73 100644 --- a/drivers/dma/imx-sdma.c +++ b/drivers/dma/imx-sdma.c @@ -185,6 +185,7 @@ * Mode/Count of data node descriptors - IPCv2 */ struct sdma_mode_count { +#define SDMA_BD_MAX_CNT 0xffff u32 count : 16; /* size of the buffer pointed by this BD */ u32 status : 8; /* E,R,I,C,W,D status bits stored here */ u32 command : 8; /* command mostly used for channel 0 */ @@ -1344,9 +1345,9 @@ static struct dma_async_tx_descriptor *sdma_prep_slave_sg( count = sg_dma_len(sg); - if (count > 0xffff) { + if (count > SDMA_BD_MAX_CNT) { dev_err(sdma->dev, "SDMA channel %d: maximum bytes for sg entry exceeded: %d > %d\n", - channel, count, 0xffff); + channel, count, SDMA_BD_MAX_CNT); goto err_bd_out; } @@ -1421,9 +1422,9 @@ static struct dma_async_tx_descriptor *sdma_prep_dma_cyclic( sdmac->flags |= IMX_DMA_SG_LOOP; - if (period_len > 0xffff) { + if (period_len > SDMA_BD_MAX_CNT) { dev_err(sdma->dev, "SDMA channel %d: maximum period size exceeded: %zu > %d\n", - channel, period_len, 0xffff); + channel, period_len, SDMA_BD_MAX_CNT); goto err_bd_out; } @@ -1970,7 +1971,7 @@ static int sdma_probe(struct platform_device *pdev) sdma->dma_device.residue_granularity = DMA_RESIDUE_GRANULARITY_SEGMENT; sdma->dma_device.device_issue_pending = sdma_issue_pending; sdma->dma_device.dev->dma_parms = &sdma->dma_parms; - dma_set_max_seg_size(sdma->dma_device.dev, 65535); + dma_set_max_seg_size(sdma->dma_device.dev, SDMA_BD_MAX_CNT); platform_set_drvdata(pdev, sdma); From patchwork Mon Jul 23 17:46:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robin Gong X-Patchwork-Id: 10539821 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1BFB4112B for ; Mon, 23 Jul 2018 09:46:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 081EA285A6 for ; Mon, 23 Jul 2018 09:46:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EE723285AD; Mon, 23 Jul 2018 09:46:19 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DATE_IN_FUTURE_06_12,DKIM_SIGNED,DKIM_VALID,MAILING_LIST_MULTI autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 6D25A285A6 for ; Mon, 23 Jul 2018 09:46:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=yZBTCVfs6QBNmU3QDtKS7XX7UhAm+/ZSqldcwJebQrk=; b=E6tR1mnPzp81O1 s+K8XDKDYfqu+aoxvCs1y30RXdD/siJRJ1yGGo3No3VCr3aFf7enU0U7i1AUyCUgB7FdEkiWtb9HJ aaEc3s9jTMlUGuOdlSTA2oL7+z7Hm/HlmUFjzDjg0HQTWHfGxAYfJEa4E+A8CniZt1OMF+/YZTZb3 Ruo2pXhPHCmJBsuR7mDDICgtAO0/k0yybrt8n7UAZTOoZDGHSB+iWjjYXCoUefavIuEM3nqWjNyi0 dtGTjDJM6Mp08KdLmS8vxfhW02KMu9Iivg0WgNyjFMlysU0vl3Vme5a+Qoqseh7yRX6EYlMW0qacD 7ua6kZr/5TIH1tR8iGRA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fhXPz-000662-Fh; Mon, 23 Jul 2018 09:46:15 +0000 Received: from mail-db5eur01on0064.outbound.protection.outlook.com ([104.47.2.64] helo=EUR01-DB5-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fhXPh-0005cV-7R for linux-arm-kernel@lists.infradead.org; Mon, 23 Jul 2018 09:46:01 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=T+KUX/LnsNOoYwClt0oD6H+70sZkZFYLzHfKPzszaMw=; b=gfxKqRxLbbfWZpQNBL77o1ixQiRabPnyWkwFWpnyEhhWzkXECzcyJ10ICdgupk/WxYS2F+CEdWl99jf7OQN9ioDOfcZOGfdU5Rk2qc90dSVRtmNbvwGsEIPKQ6oGSNgXIS4jdSl1WCqZhKqQj8CAYJmsBPYn5i7ogMDt/6Eqfn4= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=yibin.gong@nxp.com; Received: from robin-OptiPlex-790.ap.freescale.net (119.31.174.66) by VI1PR04MB3232.eurprd04.prod.outlook.com (2603:10a6:802:6::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.973.21; Mon, 23 Jul 2018 09:45:40 +0000 From: Robin Gong To: vkoul@kernel.org, dan.j.williams@intel.com, s.hauer@pengutronix.de, linux@armlinux.org.uk Subject: [PATCH v3 2/3] dmaengine: imx-sdma: add memcpy interface Date: Tue, 24 Jul 2018 01:46:11 +0800 Message-Id: <1532367972-29707-3-git-send-email-yibin.gong@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1532367972-29707-1-git-send-email-yibin.gong@nxp.com> References: <1532367972-29707-1-git-send-email-yibin.gong@nxp.com> MIME-Version: 1.0 X-Originating-IP: [119.31.174.66] X-ClientProxiedBy: HK0PR03CA0086.apcprd03.prod.outlook.com (2603:1096:203:72::26) To VI1PR04MB3232.eurprd04.prod.outlook.com (2603:10a6:802:6::29) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 11c2b6e4-a819-4045-5921-08d5f0810f26 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989117)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(5600073)(711020)(4618075)(2017052603328)(7153060)(7193020); SRVR:VI1PR04MB3232; X-Microsoft-Exchange-Diagnostics: 1; VI1PR04MB3232; 3:o+ML0ypgFdO8c3D0rLyutQSMSXMxyJPTqBRCTzOJaqoW6sLquOcH55pd4K/Usgsb0+sDuDpmidlRmxZdhBwXwPXG5keJxXgOJKq1EZ8atph3YmwlCEy7qRaVm4AKeHos7QiS3fL9+zv3RTfsTffKi8aRh0hbItgKnT1ht4lIv2g5BEa7AEY+5lK7+263NfZHT7bIrWsjwu1ocPeNtGBQsT+1NphxTTsab0EpaC/0cnVNakahgsPrQdUCLugavZT9; 25:UYO+4Hr/+pON4d/7tHW/94H6r2YjnATVy4p9tqFrIM/owyTTpo3v5MCj3W+o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wlbuzIDyD0ih/OrrjJd4B0; 4:uPwedbte2uqVARRpAclzkE+SVSlCgzjI4rVqLXrhQIP+ApJl3Ea+WTKZxAIM23VGGbx2n+Y8/dJ9dw2PNuXlIrUjt3jlpJCQMPJWlmVN9KS+5Hrl9zVHDBRVYbdhoraldHp5svxELRqpqCpkJr+nMj9R3dGnY4H42/qloAeIoBM0QJlQRG0hPMT7aZugUmuS4e9WtgVDeL5eBbQGjXUgmWQH9L5MCZ+aJRqEyvG/ekTgbHg/C9Pj1J8U3RWFOKUIUBWHmzj7/BTkbEDBe71m3LRCjmIA1gN+hIWeqgJz8wkX1mOyYxG/xYoddZVxMbDc X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(185117386973197); X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(3002001)(10201501046)(93006095)(93001095)(3231311)(944501410)(52105095)(6055026)(149027)(150027)(6041310)(20161123562045)(20161123558120)(20161123564045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011)(7699016); SRVR:VI1PR04MB3232; BCL:0; PCL:0; RULEID:; SRVR:VI1PR04MB3232; X-Forefront-PRVS: 0742443479 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(396003)(366004)(346002)(136003)(39860400002)(376002)(199004)(189003)(16526019)(6116002)(3846002)(956004)(8936002)(66066001)(47776003)(53936002)(478600001)(305945005)(26005)(50466002)(48376002)(476003)(2616005)(6512007)(25786009)(7736002)(4326008)(11346002)(6506007)(386003)(14444005)(36756003)(50226002)(106356001)(97736004)(446003)(5660300001)(68736007)(6666003)(105586002)(2906002)(486006)(81166006)(8676002)(52116002)(81156014)(186003)(86362001)(51416003)(16586007)(6486002)(316002)(76176011); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR04MB3232; H:robin-OptiPlex-790.ap.freescale.net; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; Received-SPF: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; VI1PR04MB3232; 23:/zGjJn+o5OFuOOt50bod4GTyt17TRfxBAvhgrkoBF?= LoYYYv4z0f0M4hl7RTSqY+T3JklRI+NaQmjsA7cIB1jn2ZcdH9FTMRuRzDIIpzkLXusGpzg7c9OgenUzQ/uCgE/m95FzI9zERyW4vHPGyznbZp2K692eViesnBVbdrIuK7Xl6xIbBmvgYWZpIOcE7Z6ZgtC4AaIWmPLqJ47uYFxSQj+Qpil7Is4D5vMkbDBnbnXm/fLdGn81tnC+TeXOu+JLWtT+Ua2D2m7H/7FVlzxlHxEVeTUP2jwMta+LATF+SouG+yN4P/qmTn3Qmw6mzO7TYFP38GJZfONZqXIuA6/U9GnaIpOqXOVY7OrGiPWLxmz0Zn42KTfsdJ5cZxvBogm0oCa69dfD9XEvles088yt943yk515HyU5/cRXwdiZS7/GOtY2KCcSyqOt1dhRVR8zuQHEx75CL9DYeV59EhqyxuQwR6nowoVNGBdTcLpeECpoXy3BcWBe290OpLLKUfRD1HFEXfSvx85zdAHx5ERYW6oGDQZWgJXYlt/KVDUTB02CfC6xngOVYUPGBMZ+i1Ila+KYaptd6qMYTKYL74gZDBxWRgreuoFTWuBnCl+IL7A/1Eyxuo170iVAg8FeO9cdS+hD9fKgYtU8QJlcPUWLo+sldtBNy6K2DfY+Fp1u+EUOzdLM/JKX5GiXswMWqNJWNsn86GUltzvLkBtv90bFnHxY2gEyRFhskb9A1OvjzAhn7tD50fIKcldOkPOQfT081M6kY5Ktzcn7C/CYKiEepPyv3qHGu4scIs5i0ZR9yeOKceYgvPIXoKQ8sxuxd7FVVjKBADtWjdzaxJ5IUinQoVljXNViUPHssAId7tHfYAQVUYWx6Dw26JGA5SrX8ioe5w10sClDUFvrXsmOo0wSEJpXZe7Bf/m22VYH0b/mKDdKn6Fl4i2wQA2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P3Ro5FNc4xQvyc8ndW6l6OzFGE6mRKs3hxxyfoMQ==; 5:+PK7FG07ZozJ7CjOSoE7xBms8Ebz5IgU4gtmvzkTyxPgN7ZfRUk/NUO2+4SMVqr5rIRERoAmiCFgDOYSF7OIhlchy4jv+h/lePYgEm5orEiLdD8Bmzpg79YzjzUEOVARPDxIvzAGsDAgTblF70eVDXtVKLi4+cU5XkDKxaQ66OE=; 7:bhItgMfPhnT0eOnuLyLtd+6BccEp+pSti76pOMEUbWnzh+1W9i2GhCrCkr9+WLJbxPJRhAMC/v+DvE1AGBJqO6OB4ZvrPKaamWEeJdtlg0nYb4Pt/x1KOm5XlB3uOnw55S5e5LmjG+AFiIejLyY7UeA8/UPpdDheAJNGn6nRjcC03lUiophxVPLECcFyE3xlm7RVKlE0hGQSrEmND+RrRVfxB3lAITA8dCHFn8ob2jRFCLoXYMtTQS8TkFq4iuSD SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Jul 2018 09:45:40.9192 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 11c2b6e4-a819-4045-5921-08d5f0810f26 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB3232 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180723_024557_664194_C218C449 X-CRM114-Status: GOOD ( 16.77 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: dmaengine@vger.kernel.org, linux-imx@nxp.com, kernel@pengutronix.de, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Add MEMCPY capability for imx-sdma driver. Signed-off-by: Robin Gong --- drivers/dma/imx-sdma.c | 93 ++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 90 insertions(+), 3 deletions(-) diff --git a/drivers/dma/imx-sdma.c b/drivers/dma/imx-sdma.c index e3d5e73..b4ec2d2 100644 --- a/drivers/dma/imx-sdma.c +++ b/drivers/dma/imx-sdma.c @@ -342,6 +342,7 @@ struct sdma_desc { * @pc_from_device: script address for those device_2_memory * @pc_to_device: script address for those memory_2_device * @device_to_device: script address for those device_2_device + * @pc_to_pc: script address for those memory_2_memory * @flags: loop mode or not * @per_address: peripheral source or destination address in common case * destination address in p_2_p case @@ -367,6 +368,7 @@ struct sdma_channel { enum dma_slave_buswidth word_size; unsigned int pc_from_device, pc_to_device; unsigned int device_to_device; + unsigned int pc_to_pc; unsigned long flags; dma_addr_t per_address, per_address2; unsigned long event_mask[2]; @@ -869,14 +871,16 @@ static void sdma_get_pc(struct sdma_channel *sdmac, * These are needed once we start to support transfers between * two peripherals or memory-to-memory transfers */ - int per_2_per = 0; + int per_2_per = 0, emi_2_emi = 0; sdmac->pc_from_device = 0; sdmac->pc_to_device = 0; sdmac->device_to_device = 0; + sdmac->pc_to_pc = 0; switch (peripheral_type) { case IMX_DMATYPE_MEMORY: + emi_2_emi = sdma->script_addrs->ap_2_ap_addr; break; case IMX_DMATYPE_DSP: emi_2_per = sdma->script_addrs->bp_2_ap_addr; @@ -949,6 +953,7 @@ static void sdma_get_pc(struct sdma_channel *sdmac, sdmac->pc_from_device = per_2_emi; sdmac->pc_to_device = emi_2_per; sdmac->device_to_device = per_2_per; + sdmac->pc_to_pc = emi_2_emi; } static int sdma_load_context(struct sdma_channel *sdmac) @@ -965,6 +970,8 @@ static int sdma_load_context(struct sdma_channel *sdmac) load_address = sdmac->pc_from_device; else if (sdmac->direction == DMA_DEV_TO_DEV) load_address = sdmac->device_to_device; + else if (sdmac->direction == DMA_MEM_TO_MEM) + load_address = sdmac->pc_to_pc; else load_address = sdmac->pc_to_device; @@ -1214,10 +1221,28 @@ static int sdma_alloc_chan_resources(struct dma_chan *chan) { struct sdma_channel *sdmac = to_sdma_chan(chan); struct imx_dma_data *data = chan->private; + struct imx_dma_data mem_data; int prio, ret; - if (!data) - return -EINVAL; + /* + * MEMCPY may never setup chan->private by filter function such as + * dmatest, thus create 'struct imx_dma_data mem_data' for this case. + * Please note in any other slave case, you have to setup chan->private + * with 'struct imx_dma_data' in your own filter function if you want to + * request dma channel by dma_request_channel() rather than + * dma_request_slave_channel(). Othwise, 'MEMCPY in case?' will appear + * to warn you to correct your filter function. + */ + if (!data) { + dev_dbg(sdmac->sdma->dev, "MEMCPY in case?\n"); + mem_data.priority = 2; + mem_data.peripheral_type = IMX_DMATYPE_MEMORY; + mem_data.dma_request = 0; + mem_data.dma_request2 = 0; + data = &mem_data; + + sdma_get_pc(sdmac, IMX_DMATYPE_MEMORY); + } switch (data->priority) { case DMA_PRIO_HIGH: @@ -1307,6 +1332,10 @@ static struct sdma_desc *sdma_transfer_init(struct sdma_channel *sdmac, if (sdma_alloc_bd(desc)) goto err_desc_out; + /* No slave_config called in MEMCPY case, so do here */ + if (direction == DMA_MEM_TO_MEM) + sdma_config_ownership(sdmac, false, true, false); + if (sdma_load_context(sdmac)) goto err_desc_out; @@ -1318,6 +1347,62 @@ static struct sdma_desc *sdma_transfer_init(struct sdma_channel *sdmac, return NULL; } +static struct dma_async_tx_descriptor *sdma_prep_memcpy( + struct dma_chan *chan, dma_addr_t dma_dst, + dma_addr_t dma_src, size_t len, unsigned long flags) +{ + struct sdma_channel *sdmac = to_sdma_chan(chan); + struct sdma_engine *sdma = sdmac->sdma; + int channel = sdmac->channel; + size_t count; + int i = 0, param; + struct sdma_buffer_descriptor *bd; + struct sdma_desc *desc; + + if (!chan || !len) + return NULL; + + dev_dbg(sdma->dev, "memcpy: %pad->%pad, len=%zu, channel=%d.\n", + &dma_src, &dma_dst, len, channel); + + desc = sdma_transfer_init(sdmac, DMA_MEM_TO_MEM, + len / SDMA_BD_MAX_CNT + 1); + if (!desc) + return NULL; + + do { + count = min_t(size_t, len, SDMA_BD_MAX_CNT); + bd = &desc->bd[i]; + bd->buffer_addr = dma_src; + bd->ext_buffer_addr = dma_dst; + bd->mode.count = count; + desc->chn_count += count; + bd->mode.command = 0; + + dma_src += count; + dma_dst += count; + len -= count; + i++; + + param = BD_DONE | BD_EXTD | BD_CONT; + /* last bd */ + if (!len) { + param |= BD_INTR; + param |= BD_LAST; + param &= ~BD_CONT; + } + + dev_dbg(sdma->dev, "entry %d: count: %zd dma: 0x%x %s%s\n", + i, count, bd->buffer_addr, + param & BD_WRAP ? "wrap" : "", + param & BD_INTR ? " intr" : ""); + + bd->mode.status = param; + } while (len); + + return vchan_tx_prep(&sdmac->vc, &desc->vd, flags); +} + static struct dma_async_tx_descriptor *sdma_prep_slave_sg( struct dma_chan *chan, struct scatterlist *sgl, unsigned int sg_len, enum dma_transfer_direction direction, @@ -1903,6 +1988,7 @@ static int sdma_probe(struct platform_device *pdev) dma_cap_set(DMA_SLAVE, sdma->dma_device.cap_mask); dma_cap_set(DMA_CYCLIC, sdma->dma_device.cap_mask); + dma_cap_set(DMA_MEMCPY, sdma->dma_device.cap_mask); INIT_LIST_HEAD(&sdma->dma_device.channels); /* Initialize channel parameters */ @@ -1969,6 +2055,7 @@ static int sdma_probe(struct platform_device *pdev) sdma->dma_device.dst_addr_widths = SDMA_DMA_BUSWIDTHS; sdma->dma_device.directions = SDMA_DMA_DIRECTIONS; sdma->dma_device.residue_granularity = DMA_RESIDUE_GRANULARITY_SEGMENT; + sdma->dma_device.device_prep_dma_memcpy = sdma_prep_memcpy; sdma->dma_device.device_issue_pending = sdma_issue_pending; sdma->dma_device.dev->dma_parms = &sdma->dma_parms; dma_set_max_seg_size(sdma->dma_device.dev, SDMA_BD_MAX_CNT); From patchwork Mon Jul 23 17:46:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robin Gong X-Patchwork-Id: 10539823 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 12F19112B for ; Mon, 23 Jul 2018 09:46:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0083D285AD for ; Mon, 23 Jul 2018 09:46:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E87FE285B3; Mon, 23 Jul 2018 09:46:30 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DATE_IN_FUTURE_06_12,DKIM_SIGNED,DKIM_VALID,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 7B6DD285AD for ; Mon, 23 Jul 2018 09:46:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=pQOxKOmKpEU+vJSEwSt1uIkVPK/LvYuXD27SJG07Rqw=; b=uviwOqv+eMOovB +fe8dTVwyRGB4KUS0y9LHWSCnzGhtwr7IsriU9ejjICFfdO7q6uF6YLHC2YkI9GjA+w/fjD3BI7/k dh6/XD2/dQ8tMhfxny0nem8fWU9BNi47famprJEkqW29DjghOFuKoTo/yoIRVluzaUlLXogRoLBEf quaZ8xDBeZYCZFyl34FnXKUnJdQTDLIQd0SWQSVxKKP2G9iaXt2KcL6y/wF8sDA+wYnjbVC1Y2Mjq GKSmlu6N5A64k+ZF6p9eSn7P6IVCAd6CxptMMBxPFFb1V3zhk3wEQ/wTxHDIzz+CE1ZJmJ8K9AM3X oP/QlmamTBBfkvtzSubg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fhXQ9-0006GP-DT; Mon, 23 Jul 2018 09:46:25 +0000 Received: from mail-db5eur01on0064.outbound.protection.outlook.com ([104.47.2.64] helo=EUR01-DB5-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fhXPm-0005cV-Al for linux-arm-kernel@lists.infradead.org; Mon, 23 Jul 2018 09:46:06 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=cYR6WX+u6+d3vL7+0QkiTo0t2BvjvxQpYEVGrjfuRMs=; b=BlqzJF8vzOCso+EA6B2odlpel+HQslk8AkpeGqVIPNuRH9xnqWjFHdmWX00Olc3gMqTygj0Lf1v/aQgmUJF6q8rRVTzsucn1bN46o8KpbArp2oFCnpvwIv6zL0jJTnKu0GgFt1FjGm0VoW947DTKu040MBHxSm2MPqJ2KSyv0yw= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=yibin.gong@nxp.com; Received: from robin-OptiPlex-790.ap.freescale.net (119.31.174.66) by VI1PR04MB3232.eurprd04.prod.outlook.com (2603:10a6:802:6::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.973.21; Mon, 23 Jul 2018 09:45:46 +0000 From: Robin Gong To: vkoul@kernel.org, dan.j.williams@intel.com, s.hauer@pengutronix.de, linux@armlinux.org.uk Subject: [PATCH v3 3/3] dmaengine: imx-sdma: allocate max 20 bds for one transfer Date: Tue, 24 Jul 2018 01:46:12 +0800 Message-Id: <1532367972-29707-4-git-send-email-yibin.gong@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1532367972-29707-1-git-send-email-yibin.gong@nxp.com> References: <1532367972-29707-1-git-send-email-yibin.gong@nxp.com> MIME-Version: 1.0 X-Originating-IP: [119.31.174.66] X-ClientProxiedBy: HK0PR03CA0086.apcprd03.prod.outlook.com (2603:1096:203:72::26) To VI1PR04MB3232.eurprd04.prod.outlook.com (2603:10a6:802:6::29) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 02b5ecce-293b-437b-c0e2-08d5f0811274 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989117)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(5600073)(711020)(4618075)(2017052603328)(7153060)(7193020); SRVR:VI1PR04MB3232; X-Microsoft-Exchange-Diagnostics: 1; VI1PR04MB3232; 3:fhZdM9gJOXXep4ktaAyzpxY8SghKgwWhfeoOitYPNeYuUisjSoQhcf3kYD2zeFMTmTrEWIR0N9lMsG0TpUWCIzHZP0X5IwPO0mbmtsfbbB8i03xwXmlzad21LiTBkR2cCg8qnnm0nO8lRvYjzfyfl9uEGNIVgqu/Ut6WTQqreUC6dzsPy9vEggpsIgpdEMWvtvku/Ur9MG5HRoo2lyHLODoXeKFtGUu95DFSGkei+oqhcYjfJakIBsc3RVJs8CAp; 25:DY+DG6fqCFTHhnuXRz4iT5Fc+DEEOKhehdqSJZcWIj2oXw8RymfOn+SIrYkP3sMdZSMUwKqxitwi4LHrTZmk4zjdhZvg+zfWE+DsO02yFP7SrmLRA1ZWbdCmPNOGffsPKe9x9voYRmiVjjB/Y/rr/rfBI9QC3NTEAQ+AcyjelDrB37RErA0WRVTk451qZub2mGjqjd1IYeK8dFg+Fhm8cEYtkysIILOZmXdn40apMufPwqcIEmUbLMWeuVqjKyTQmrcE3tNA++L2/Ilevg7TEksUboIu1zRR4q83ZY8hSjZMc+W3pLFqtfIzOHW95u8QitPKWn2XktSgv4acc2mh2g==; 31:bPp6DembvxEByuiQDig2nFICjh6A4M3FngR9qD+UsUwncecfbDZe45uW7oh14xDOg5WSzbwH03ilnARrsDaDJyazSDFjOzedR2jZac2Aq5NTqd09P/RV6t5TU0qJGy37ju+45J17lz4uZ6zMfojDStYLi1kyJtjKamvfZJaIHnIQvrHkAKDzApaoL7FIxiW3yXVynz0D+qAXh/Th3deav1didXZL4c1uJYob07hfNvA= X-MS-TrafficTypeDiagnostic: VI1PR04MB3232: X-Microsoft-Exchange-Diagnostics: 1; VI1PR04MB3232; 20:ulhu/s5j/Q3EYveHYGeM2+NYZxLXFxF9yjL6bSIrXzs5qX93sye83Mp++KKlO8JE5ls7D1ojNiQwURYPTNrdc8PuXwp2cDCI6uOw0V4GBuzIdmDDlBHgoawTTEC6gUABMzei4s4zIPiq5Oko6yPXzn+1Bxi9rZguwkqf8N/Uw5Qxsb81XQwFoOqnJm1bjfmz279P8qgpzeAMjxd7oEkMiBi4MfCI7HXrPg4n4WJLD1raZBwqPzxjOoY6F/BlTfM8Zgm5MemkfilSFJe6yvVD8yo96eLIzD7xGAuvV+jFDrdFaQDno+vYQyKxqPSpJqmK0I+MTdNFLUtLDsCpjpd7vqWJHhBxXaboFbJhZjAAJfhZoi8qtfk3IzTU8K+j74jxe4miPpQudLzyxusZD3Q3wgYs10p4apXzEXj22CMDThz1mvku+BkbIeQe2DIAbT3M+gGHup4uUU++ovg4P3ss+/jwngJdCG40rhfueqwUTLpvmwWjS42U3fJkizbIrln/; 4:HCROHq7sRPUMjltbI7O27ffrFFrCOOn4aLNs1WT/2ndnn95DCUMDY5yXHIioYQLjSxvMwgIveC6J1yDKmCyz0pn5F6Qn1c8ujokfe5JW80uCbHO4dp5sUraDfGXZx/JU1xgoJvIVzq/EnbqWAKX/2Df9fsTr+/ym0rDDWyZjg4hEp4HnvRGMXF9yRo2ats5BuIX2NsMT3eXat574vcXhCgJtb6I4d15/qYKK67LwbOvt8qRmJK0b2XoTeTQ1rzg/u/EC5yX/gAGaqNCbzwpB4bD5FkZWtVgKlTmtmIrxWgcWmp1DqwOWSVU2cbei24w8 X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(185117386973197); X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(3002001)(10201501046)(93006095)(93001095)(3231311)(944501410)(52105095)(6055026)(149027)(150027)(6041310)(20161123562045)(20161123558120)(20161123564045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011)(7699016); SRVR:VI1PR04MB3232; BCL:0; PCL:0; RULEID:; SRVR:VI1PR04MB3232; X-Forefront-PRVS: 0742443479 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(396003)(366004)(346002)(136003)(39860400002)(376002)(199004)(189003)(16526019)(6116002)(3846002)(956004)(8936002)(66066001)(47776003)(53936002)(478600001)(305945005)(26005)(50466002)(48376002)(476003)(2616005)(6512007)(25786009)(7736002)(4326008)(11346002)(6506007)(386003)(14444005)(36756003)(50226002)(106356001)(97736004)(446003)(5660300001)(68736007)(6666003)(105586002)(2906002)(486006)(81166006)(8676002)(52116002)(81156014)(186003)(86362001)(51416003)(16586007)(6486002)(316002)(76176011); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR04MB3232; H:robin-OptiPlex-790.ap.freescale.net; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; Received-SPF: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; VI1PR04MB3232; 23:f9mYoH6F34CQFEt0o0BF3pKiBOtZLfutgZBlO7eaG?= In3e9Qif2JiHct9KVMvLtiK2LGrEshVrA/cu1GZrBAQJZpE+LfVZIHQz2xD3FeVAYjUUeVzeZsvnt7dpy1XlNs3gvndm/iYPp2kkAXRYU0BGBFr7BoBxIB6vAtmclTHj5rc5tq/3+OGGmtAksjw7WVC6TdHsaVA6KkfHCmXaQw1FzColjDWbRZfGC46hfUw3jeF0owsKcMqM5GwHeUmQG6UeV2yVnaih8YDTV5c+vd+/gdUb+bnBzEeWpsCdUzjL/FPauowr37CBvJOvDxTKFchK2XBMWLsAn4fRU3r11PuPVicf0f7earQhkunmAabf0BOOQE2qTj8S5G6yT89A/UeCSgYglctFrLdM6BWg3JVXH/KvsQJ4YeERSRKLOllKZCj2mO3LljSx4AN6vAZoutIoHOgmk5HPcUFryQYGrICNrF3lbHp/RbDacMb+9StGpldxNUWG6Wrjc05hiPsOVFamQBcKM4IiLUedJbca29uDXKDrk5UAs9+z+PBWMneOCel261mMBSFEfsYkL/rWjveMeDtc7GK5mgYfSva6E0k1EnLgQuPH/Or4jEKN63R8zez4GussPuqY4xoYTDqN3zHmjF/4iF/Q0YWytAQ1b2NeLLNhxad8cOp1GzX5X4iAbHAXLgLVNlc/LkI6WouZY7RGwQuCtgIjRbbBoQSMQkl1OKo8fLdXxOOz3cE+SDq8v+pzcnTZAZoqFBqpdtlyJIN2ATLbx+eoKx++yVIrCJPQ62VNVLo1odo4PhAxuuHCuBfdH/NnVrJEAAJ4Sw9ven2HArevWx/SeGHWPJG4rIzdD0qilOGNg39Mh+mw4EtCACXkaPpsJeU7Cmk6rCWKtxOvKd/YlMMcSVWuQv9EkXLOUzlTyzX9YUd2EsK3O52NYPa1BuRyqt92zJEVImh5iUjC7JbdUQx+Bpbh4D+XrYZ6lExLD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ioWggyw==; 5:Auo8fmFTVQHaVOl5anYZKQ5gIiEMgYWCmG6NGUlTzgNGvOMniVuyq4CWF3DwqM4/lkJ5n1Nr/HLVTYAmXmJcvMVg6O2JcSDCdDo1A+poI7Z7k/g4LxvFg+JgM/2Q6a2ALkmqU3ri6apKqNkSLnDVXX+0v/i5nkm4ItwnBnhP2Ks=; 7:DkGpiZljAioVXCmklDDLA8fVITozE6K2K6RmY94NF3lR7HAu0hxR1U+saLOWDx3/3wwwjFJbVBdiC9Mx5yvQtCmw2hz8ZyaCO/wk59zWKYn2OskRVRdEcRpuhun+vLt3ym0x7jiOBsnRkxb3OEzOm7RA/TtB6mOAKbteTdo669kwg7t2eGaSXL5ZdOfMZTsvzLEpZHeGNaP+gtaHR2SXJqWBlNH0nyMujhfyBRG1uIcJYW+L2kvawl0rHh2RT/9o SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Jul 2018 09:45:46.4662 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 02b5ecce-293b-437b-c0e2-08d5f0811274 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB3232 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180723_024602_763184_502C005A X-CRM114-Status: GOOD ( 15.03 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: dmaengine@vger.kernel.org, linux-imx@nxp.com, kernel@pengutronix.de, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP If multi-bds used in one transfer, all bds should be consisten memory.To easily follow it, enlarge the dma pool size into 20 bds, and it will report error if the number of bds is over than 20. For dmatest, the max count for single transfer is NUM_BD * SDMA_BD_MAX_CNT = 20 * 65535 = ~1.28MB. Signed-off-by: Robin Gong --- drivers/dma/imx-sdma.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/drivers/dma/imx-sdma.c b/drivers/dma/imx-sdma.c index b4ec2d2..5973489 100644 --- a/drivers/dma/imx-sdma.c +++ b/drivers/dma/imx-sdma.c @@ -298,6 +298,15 @@ struct sdma_context_data { u32 scratch7; } __attribute__ ((packed)); +/* + * All bds in one transfer should be consitent on SDMA. To easily follow it,just + * set the dma pool size as the enough bds. For example, in dmatest case, the + * max 20 bds means the max for single transfer is NUM_BD * SDMA_BD_MAX_CNT = 20 + * * 65535 = ~1.28MB. 20 bds supposed to be enough basically.If it's still not + * enough in some specific cases, enlarge it here.Warning message would also + * appear if the bd numbers is over than 20. + */ +#define NUM_BD 20 struct sdma_engine; @@ -1273,7 +1282,7 @@ static int sdma_alloc_chan_resources(struct dma_chan *chan) goto disable_clk_ahb; sdmac->bd_pool = dma_pool_create("bd_pool", chan->device->dev, - sizeof(struct sdma_buffer_descriptor), + NUM_BD * sizeof(struct sdma_buffer_descriptor), 32, 0); return 0; @@ -1314,6 +1323,12 @@ static struct sdma_desc *sdma_transfer_init(struct sdma_channel *sdmac, { struct sdma_desc *desc; + if (bds > NUM_BD) { + dev_err(sdmac->sdma->dev, "%d bds exceed the max %d\n", + bds, NUM_BD); + goto err_out; + } + desc = kzalloc((sizeof(*desc)), GFP_NOWAIT); if (!desc) goto err_out;