From patchwork Wed Apr 6 15:23:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 12803846 X-Patchwork-Delegate: lorenzo.pieralisi@arm.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8F178C43217 for ; Wed, 6 Apr 2022 17:23:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238946AbiDFRZm (ORCPT ); Wed, 6 Apr 2022 13:25:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59588 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238763AbiDFRZe (ORCPT ); Wed, 6 Apr 2022 13:25:34 -0400 Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2066.outbound.protection.outlook.com [40.107.20.66]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 729C24B6D25; Wed, 6 Apr 2022 08:24:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=G0zXKHnFb8iDkNmJ7YH31ILgUk3NCBPZTfTskekm9iipxyo4nU4GIPD1RHYJGqF7akuXEEaHsDKQAR8CkAqzo7hmfnULl2woOiQOKY4agkTn8By37QeC6GYAmej+ca0D8KOFHHPbku6nm9IxB315xp++m/kK6bmw6yiaN0/92YUXC85IrU0wdUwHdaJ4r5RYbffZDlzu5SuzbWTNa08owJAGZOEzYN45jO035Nq8hMgOGpy+vpgLibxNYXBfM9UYnnNCsTnIugHwchdm/ch7tocQbdNIH4H/ffoewrotQ5vVnfk5Y98/eTpqPvi09U/4hOdkvi48so32I8FSOXGn5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=EvG200B2DQKfRAiAHiJjN/toZ+TUwgxsOPDXaKwIH8M=; b=Gc+tXw2iwNRfHvaby8TXgxdB9AzAnLRCG+1QSrizVsTwDqc4me6Rs5wUuwuLerqMOrChwNCyJ5mg5UNF33ZLfQJLVc6RrvKsbp+AqXn56cRhXwIEF7p+JBZ42YppXF9gJg+8ZH2rMFt/mXG0dU3oX+u/qzFxUPfJWevtpR6/iwscQcDtyzU8PBAMsMaUk8kLF8XYxhfJmJmNjVoL2xPFUd06ZBl0CPshzrzx0vKirTEIRzx+pJLoBy3vztPoo3Nt7D03EgDahDy3tp2oML13aTJuUv9iZv/jB3yzhMre37+NLliC0BhA6SUFcNVDedHnHkvSgFZMzScMsHhx+cIzCg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=EvG200B2DQKfRAiAHiJjN/toZ+TUwgxsOPDXaKwIH8M=; b=cPY2DOZrGYDRERo8TRwC+0B8m4wFbgB3O6DFsJvPSdMmeQK8MUlp2WNTDtaPPjQ9My/pNT54CGmWPiIWwprr9beFh0IVwG6PsfCQqdp3XbRvgO6mHi04xzWGaepumxcky4TpOS2PmfZ1z0OcOALoLXaV4bN4gc97Pq3al63zceY= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from PAXPR04MB9186.eurprd04.prod.outlook.com (2603:10a6:102:232::18) by VE1PR04MB7343.eurprd04.prod.outlook.com (2603:10a6:800:1a2::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5123.31; Wed, 6 Apr 2022 15:24:23 +0000 Received: from PAXPR04MB9186.eurprd04.prod.outlook.com ([fe80::ade4:ad15:823b:7e2b]) by PAXPR04MB9186.eurprd04.prod.outlook.com ([fe80::ade4:ad15:823b:7e2b%7]) with mapi id 15.20.5123.031; Wed, 6 Apr 2022 15:24:23 +0000 From: Frank Li To: gustavo.pimentel@synopsys.com, hongxing.zhu@nxp.com, l.stach@pengutronix.de, linux-imx@nxp.com, linux-pci@vger.kernel.org, dmaengine@vger.kernel.org, fancer.lancer@gmail.com, lznuaa@gmail.com, helgaas@kernel.org Cc: vkoul@kernel.org, lorenzo.pieralisi@arm.com, robh@kernel.org, kw@linux.com, bhelgaas@google.com, manivannan.sadhasivam@linaro.org, Sergey.Semin@baikalelectronics.ru Subject: [PATCH v6 1/9] dmaengine: dw-edma: Detach the private data and chip info structures Date: Wed, 6 Apr 2022 10:23:39 -0500 Message-Id: <20220406152347.85908-2-Frank.Li@nxp.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220406152347.85908-1-Frank.Li@nxp.com> References: <20220406152347.85908-1-Frank.Li@nxp.com> X-ClientProxiedBy: BYAPR11CA0046.namprd11.prod.outlook.com (2603:10b6:a03:80::23) To PAXPR04MB9186.eurprd04.prod.outlook.com (2603:10a6:102:232::18) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: d62fa652-f2f1-4a11-ed12-08da17e18776 X-MS-TrafficTypeDiagnostic: VE1PR04MB7343:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: SQ8KakNePZZ0eNL4RaAPBF0I6MUCQtskoNL73cKyTyNGXVu3Nhmqd2CTiyMonDKbeHK9aYuHKXaIPdN0loL/2G8gj1w2wL8mhxtKlR2GKSNsDIWbNJtWhT7/a4dWAUnpqMpOdfyk4RLWs3ao6YI0amHMzIqZfk81h58hLPYEH++2ja8zJci4boxF3UX3RHhN0hqcST6IB0XSrowP7CTGdRsMbzApU0DgdMwB31m6gDMB7dhQIa6fr3H7feP5ALOueVGEuBEFOPgt/jWCd/A0OvOP2WVRhhhMPZD8rVkLJLd8uCV49/si9io0tAi32/jZttbgLQf8U3oAVakA4BfOuDb3G6l+ibQu7Tb8EYpqHgCVhSpuMPEYvcmrW9Szxz6r+tK5Czqw+AP82eXEAx8MXEfjwK0lkDr3IEbgrmLuBgPHNorRFGXy1G/VY4yhsavA1zNAwNIqJJEEmswSLiiE/72vtM79/E9h6+HaNj7ZMdgNY0eG9R4OKmdPQ6WZeJE018NB+joX0yDE5MStFAw56/RO8KzZEhp2z90tmuDTlzJZxntLzLF92FGi7beYY/QHMdRPYFLP2K24pR0LiegLEzq1P+Muk4e0MXRzZu6ze5Xa4EVDzlxcvAkuE/lkEXGvX7TWsVx+G4D7d8xNppDWmT8eakfD1CI4+fuFoy8r/4kIawf9l31/TfdPMMqSRRsKcErPkuxhLH6/o5OZrNv3hA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR04MB9186.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(4636009)(366004)(508600001)(6512007)(7416002)(6666004)(36756003)(66476007)(30864003)(66946007)(66556008)(8676002)(86362001)(83380400001)(4326008)(52116002)(8936002)(26005)(5660300002)(186003)(2906002)(316002)(38350700002)(2616005)(38100700002)(1076003)(6486002)(6506007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 9IX3TczX5SNDRrWx4eeQEE+6vUkHanBBWIoxteyx2ZQrmD2yhCpTKYy5hp5CGnKkAkiVMYqp3SMF5OgIvpzdkYb4PEyBEqc26hjiebR+iGsSChQrzHOP+im2Ly2j07jKCIoQhTTtFEQZx/iB1EN5apQaDVSFQ4Gh/NsTx/lD6bY+Ie2SowvbA+h9Jfp8TK8hlFpz2tUediuRAjq2Y+hvaa+bczEqdBMdhaHyt367Fmhmk8H86dee3OEVCYVDdOt6oxatHjP9174++9cyZX4kgkIn74dL+QZSTMuW2dv4pc43ZWZhdiWFcSPA+JXl9zQueT1HvrV3/uN6+c5BX448COjk/46x24p61P/GGUBwaOmKUPvoY1Yl2t4jXpbJUxjVAxNiwiADMVUtS7KPzDuBbkEcpaOp8QOpYjCB0SntRc880mfP7Ez8ce8cbTqRTac/+Pmbo4is4Lx3ZYIlwF1+GjxZF9DigYpe3/dhcGWlpQd15vtdxLqvFmmFW+YBR2bAPyQj43tdaLmBmw+jMLg9NvQUEndzwrdoXmFbd5a2FOB0AMRdUC07Sb6VCt7xU0A5yd+072R0s/vPU0kIZrWEfbSXYI4/ba2wEAucO8qdZmC/6mDBgU6lQbbi4+EEq6b/EgVwDGDcIr3CuS6GTKfB9Wx1LIIyanQmQMENO3W8buQqPaIib5Lg1w4uy9QEeos96Lm0g4BNXOM+GyS6I9G9mGlw0mtRyciB/EqndlIhNGIvhS1cZ7GxNsP4UyXySden1EShxDER+HdH3Cw8yvBvatW3pOSXOd/vBxhxBLjPeX9eKoskU1dIq7l5c7BgZtVMAUCkTMuXzEZXymCgLhKkvTsyjkqPrgSiPRQKlNu9RaNxbZB01tYNFW4sCnqHacnN+lNPEiT7SqSZLZ583YHqOdjUlOQZ/UwrggWePk/Y18q8WFMspqQ0f9xRgoa2bh/JLAmaNc3Y4uoty0rmea6kVsBIikE71tc7kdv8Gx5PTaJ5dPMUqrF+FeSrbV/dewzy1+bzSd7pFk6eIZoEBDPiunNUO55Cmj6WY5pR0TzdiFfewHqL3Ek2/FRlFOcvaHJ1fZXXE6hKWD614JGHi5Ma5JKWGt3pp3nl3rZSh8TdWyeQGmhqcK3sVxHyQvr/Biy1QxoOKTzCRJ3PA4O+Y3kH14I3eFdwgSvcVDn2imu4saNbJLWs6xn+ve7p8JPbrku8ws+hV4cn9S4gv2fMXTgi3Bkzm6Sn522JRGjK6pvaFjCo4tEPqn4AjmCPkCJqvwZrT+Ox0+WaYsgM7U81HXyppZuRZasgQVOajbSqf4kB8ynkt/irk1PPG6D2KUOxnR0k6/1wTlids3TnWqBlIRxL72u305SItPyvtcMa8iis/CnZJFxJ8Qs94UR1H8pPgpAoTvdESF0jTjU1PSp7A8ub2THT2vjRMOsqXIi71WV2TRwZOPgSCbpZHSEfeI6fTK8W1JyqZke4/NZ3Infc/1S80oB8P7EzQVv2oIYLbqekfDPl2YmoNxoYi5V5LOqvQ4gWdrCp0HaG+FzxUOkaGVxQDKJZtFS1lbn4MocysVJxMGhHwHEpbcdHA/YNosRsO/h1TjNN/mUOkRtBJwUz1qYwLCQ/jiVM5wGrl2oJF3yhEONptMTlr4tb2iEMaTGkVYlKLFGCB5tOYT/Z+f3cDXfzTLakO/tNZPY8t4lHn1+HTfZQJYmkfbkBnsdoZ80QtCCnUlimQWhb/7bL5Cnrn5KzGQ== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: d62fa652-f2f1-4a11-ed12-08da17e18776 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9186.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Apr 2022 15:24:23.7751 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: fIsQNycY3HupMYMF3s3V7vDbfBk66q6JAS4koA/pWdxAYs47rtLR+gZTdtyjIWkiGxjIg+9lSA3ZCOCiho5C9g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR04MB7343 Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org "struct dw_edma_chip" contains an internal structure "struct dw_edma" that is used by the eDMA core internally. This structure should not be touched by the eDMA controller drivers themselves. But currently, the eDMA controller drivers like "dw-edma-pci" allocates and populates this internal structure then passes it on to eDMA core. The eDMA core further populates the structure and uses it. This is wrong! Hence, move all the "struct dw_edma" specifics from controller drivers to the eDMA core. Signed-off-by: Frank Li --- Change from v5 to v6 - Don't touch chip->nr_irqs - Don't set chip->dw utill everything is okay - dw_edma_channel_setup() and dw_edma_v0_core_debugfs_on/off() methods take dw_edma structure pointer as a parameter Change from v4 to v5 - Move chip->nr_irqs before allocate dw_edma Change from v3 to v4 - Accept most suggestions of Serge Semin Change from v2 to v3 - none Change from v1 to v2 - rework commit message - remove duplicate field in struct dw_edma drivers/dma/dw-edma/dw-edma-core.c | 86 +++++++++++++----------- drivers/dma/dw-edma/dw-edma-core.h | 31 +-------- drivers/dma/dw-edma/dw-edma-pcie.c | 82 ++++++++++------------ drivers/dma/dw-edma/dw-edma-v0-core.c | 32 ++++----- drivers/dma/dw-edma/dw-edma-v0-core.h | 4 +- drivers/dma/dw-edma/dw-edma-v0-debugfs.c | 10 +-- include/linux/dma/edma.h | 44 ++++++++++++ 7 files changed, 151 insertions(+), 138 deletions(-) diff --git a/drivers/dma/dw-edma/dw-edma-core.c b/drivers/dma/dw-edma/dw-edma-core.c index 53289927dd0d6..9e88797916268 100644 --- a/drivers/dma/dw-edma/dw-edma-core.c +++ b/drivers/dma/dw-edma/dw-edma-core.c @@ -65,7 +65,7 @@ static struct dw_edma_burst *dw_edma_alloc_burst(struct dw_edma_chunk *chunk) static struct dw_edma_chunk *dw_edma_alloc_chunk(struct dw_edma_desc *desc) { struct dw_edma_chan *chan = desc->chan; - struct dw_edma *dw = chan->chip->dw; + struct dw_edma_chip *chip = chan->dw->chip; struct dw_edma_chunk *chunk; chunk = kzalloc(sizeof(*chunk), GFP_NOWAIT); @@ -82,11 +82,11 @@ static struct dw_edma_chunk *dw_edma_alloc_chunk(struct dw_edma_desc *desc) */ chunk->cb = !(desc->chunks_alloc % 2); if (chan->dir == EDMA_DIR_WRITE) { - chunk->ll_region.paddr = dw->ll_region_wr[chan->id].paddr; - chunk->ll_region.vaddr = dw->ll_region_wr[chan->id].vaddr; + chunk->ll_region.paddr = chip->ll_region_wr[chan->id].paddr; + chunk->ll_region.vaddr = chip->ll_region_wr[chan->id].vaddr; } else { - chunk->ll_region.paddr = dw->ll_region_rd[chan->id].paddr; - chunk->ll_region.vaddr = dw->ll_region_rd[chan->id].vaddr; + chunk->ll_region.paddr = chip->ll_region_rd[chan->id].paddr; + chunk->ll_region.vaddr = chip->ll_region_rd[chan->id].vaddr; } if (desc->chunk) { @@ -664,7 +664,7 @@ static int dw_edma_alloc_chan_resources(struct dma_chan *dchan) if (chan->status != EDMA_ST_IDLE) return -EBUSY; - pm_runtime_get(chan->chip->dev); + pm_runtime_get(chan->dw->chip->dev); return 0; } @@ -686,15 +686,15 @@ static void dw_edma_free_chan_resources(struct dma_chan *dchan) cpu_relax(); } - pm_runtime_put(chan->chip->dev); + pm_runtime_put(chan->dw->chip->dev); } -static int dw_edma_channel_setup(struct dw_edma_chip *chip, bool write, +static int dw_edma_channel_setup(struct dw_edma *dw, bool write, u32 wr_alloc, u32 rd_alloc) { + struct dw_edma_chip *chip = dw->chip; struct dw_edma_region *dt_region; struct device *dev = chip->dev; - struct dw_edma *dw = chip->dw; struct dw_edma_chan *chan; struct dw_edma_irq *irq; struct dma_device *dma; @@ -727,7 +727,7 @@ static int dw_edma_channel_setup(struct dw_edma_chip *chip, bool write, chan->vc.chan.private = dt_region; - chan->chip = chip; + chan->dw = dw; chan->id = j; chan->dir = write ? EDMA_DIR_WRITE : EDMA_DIR_READ; chan->configured = false; @@ -735,9 +735,9 @@ static int dw_edma_channel_setup(struct dw_edma_chip *chip, bool write, chan->status = EDMA_ST_IDLE; if (write) - chan->ll_max = (dw->ll_region_wr[j].sz / EDMA_LL_SZ); + chan->ll_max = (chip->ll_region_wr[j].sz / EDMA_LL_SZ); else - chan->ll_max = (dw->ll_region_rd[j].sz / EDMA_LL_SZ); + chan->ll_max = (chip->ll_region_rd[j].sz / EDMA_LL_SZ); chan->ll_max -= 1; dev_vdbg(dev, "L. List:\tChannel %s[%u] max_cnt=%u\n", @@ -767,13 +767,13 @@ static int dw_edma_channel_setup(struct dw_edma_chip *chip, bool write, vchan_init(&chan->vc, dma); if (write) { - dt_region->paddr = dw->dt_region_wr[j].paddr; - dt_region->vaddr = dw->dt_region_wr[j].vaddr; - dt_region->sz = dw->dt_region_wr[j].sz; + dt_region->paddr = chip->dt_region_wr[j].paddr; + dt_region->vaddr = chip->dt_region_wr[j].vaddr; + dt_region->sz = chip->dt_region_wr[j].sz; } else { - dt_region->paddr = dw->dt_region_rd[j].paddr; - dt_region->vaddr = dw->dt_region_rd[j].vaddr; - dt_region->sz = dw->dt_region_rd[j].sz; + dt_region->paddr = chip->dt_region_rd[j].paddr; + dt_region->vaddr = chip->dt_region_rd[j].vaddr; + dt_region->sz = chip->dt_region_rd[j].sz; } dw_edma_v0_core_device_config(chan); @@ -827,11 +827,10 @@ static inline void dw_edma_add_irq_mask(u32 *mask, u32 alloc, u16 cnt) (*mask)++; } -static int dw_edma_irq_request(struct dw_edma_chip *chip, +static int dw_edma_irq_request(struct dw_edma *dw, u32 *wr_alloc, u32 *rd_alloc) { - struct device *dev = chip->dev; - struct dw_edma *dw = chip->dw; + struct device *dev = dw->chip->dev; u32 wr_mask = 1; u32 rd_mask = 1; int i, err = 0; @@ -845,7 +844,7 @@ static int dw_edma_irq_request(struct dw_edma_chip *chip, if (dw->nr_irqs == 1) { /* Common IRQ shared among all channels */ - irq = dw->ops->irq_vector(dev, 0); + irq = dw->chip->ops->irq_vector(dev, 0); err = request_irq(irq, dw_edma_interrupt_common, IRQF_SHARED, dw->name, &dw->irq[0]); if (err) { @@ -868,7 +867,7 @@ static int dw_edma_irq_request(struct dw_edma_chip *chip, dw_edma_add_irq_mask(&rd_mask, *rd_alloc, dw->rd_ch_cnt); for (i = 0; i < (*wr_alloc + *rd_alloc); i++) { - irq = dw->ops->irq_vector(dev, i); + irq = dw->chip->ops->irq_vector(dev, i); err = request_irq(irq, i < *wr_alloc ? dw_edma_interrupt_write : @@ -902,20 +901,23 @@ int dw_edma_probe(struct dw_edma_chip *chip) return -EINVAL; dev = chip->dev; - if (!dev) + if (!dev || !chip->nr_irqs || !chip->ops) return -EINVAL; - dw = chip->dw; - if (!dw || !dw->irq || !dw->ops || !dw->ops->irq_vector) - return -EINVAL; + dw = devm_kzalloc(dev, sizeof(*dw), GFP_KERNEL); + if (!dw) + return -ENOMEM; + + dw->chip = chip; + dw->nr_irqs = nr_irqs; raw_spin_lock_init(&dw->lock); - dw->wr_ch_cnt = min_t(u16, dw->wr_ch_cnt, + dw->wr_ch_cnt = min_t(u16, chip->wr_ch_cnt, dw_edma_v0_core_ch_count(dw, EDMA_DIR_WRITE)); dw->wr_ch_cnt = min_t(u16, dw->wr_ch_cnt, EDMA_MAX_WR_CH); - dw->rd_ch_cnt = min_t(u16, dw->rd_ch_cnt, + dw->rd_ch_cnt = min_t(u16, chip->rd_ch_cnt, dw_edma_v0_core_ch_count(dw, EDMA_DIR_READ)); dw->rd_ch_cnt = min_t(u16, dw->rd_ch_cnt, EDMA_MAX_RD_CH); @@ -936,18 +938,22 @@ int dw_edma_probe(struct dw_edma_chip *chip) /* Disable eDMA, only to establish the ideal initial conditions */ dw_edma_v0_core_off(dw); + dw->irq = devm_kcalloc(dev, chip->nr_irqs, sizeof(*dw->irq), GFP_KERNEL); + if (!dw->irq) + return -ENOMEM; + /* Request IRQs */ - err = dw_edma_irq_request(chip, &wr_alloc, &rd_alloc); + err = dw_edma_irq_request(dw, &wr_alloc, &rd_alloc); if (err) return err; /* Setup write channels */ - err = dw_edma_channel_setup(chip, true, wr_alloc, rd_alloc); + err = dw_edma_channel_setup(dw, true, wr_alloc, rd_alloc); if (err) goto err_irq_free; /* Setup read channels */ - err = dw_edma_channel_setup(chip, false, wr_alloc, rd_alloc); + err = dw_edma_channel_setup(dw, false, wr_alloc, rd_alloc); if (err) goto err_irq_free; @@ -955,15 +961,17 @@ int dw_edma_probe(struct dw_edma_chip *chip) pm_runtime_enable(dev); /* Turn debugfs on */ - dw_edma_v0_core_debugfs_on(chip); + dw_edma_v0_core_debugfs_on(dw); + + chip->dw = dw; return 0; err_irq_free: - for (i = (dw->nr_irqs - 1); i >= 0; i--) - free_irq(dw->ops->irq_vector(dev, i), &dw->irq[i]); + for (i = (chip->nr_irqs - 1); i >= 0; i--) + free_irq(chip->ops->irq_vector(dev, i), &dw->irq[i]); - dw->nr_irqs = 0; + chip->nr_irqs = 0; return err; } @@ -980,8 +988,8 @@ int dw_edma_remove(struct dw_edma_chip *chip) dw_edma_v0_core_off(dw); /* Free irqs */ - for (i = (dw->nr_irqs - 1); i >= 0; i--) - free_irq(dw->ops->irq_vector(dev, i), &dw->irq[i]); + for (i = (chip->nr_irqs - 1); i >= 0; i--) + free_irq(chip->ops->irq_vector(dev, i), &dw->irq[i]); /* Power management */ pm_runtime_disable(dev); @@ -1002,7 +1010,7 @@ int dw_edma_remove(struct dw_edma_chip *chip) } /* Turn debugfs off */ - dw_edma_v0_core_debugfs_off(chip); + dw_edma_v0_core_debugfs_off(dw); return 0; } diff --git a/drivers/dma/dw-edma/dw-edma-core.h b/drivers/dma/dw-edma/dw-edma-core.h index 60316d408c3e0..85df2d511907b 100644 --- a/drivers/dma/dw-edma/dw-edma-core.h +++ b/drivers/dma/dw-edma/dw-edma-core.h @@ -15,20 +15,12 @@ #include "../virt-dma.h" #define EDMA_LL_SZ 24 -#define EDMA_MAX_WR_CH 8 -#define EDMA_MAX_RD_CH 8 enum dw_edma_dir { EDMA_DIR_WRITE = 0, EDMA_DIR_READ }; -enum dw_edma_map_format { - EDMA_MF_EDMA_LEGACY = 0x0, - EDMA_MF_EDMA_UNROLL = 0x1, - EDMA_MF_HDMA_COMPAT = 0x5 -}; - enum dw_edma_request { EDMA_REQ_NONE = 0, EDMA_REQ_STOP, @@ -57,12 +49,6 @@ struct dw_edma_burst { u32 sz; }; -struct dw_edma_region { - phys_addr_t paddr; - void __iomem *vaddr; - size_t sz; -}; - struct dw_edma_chunk { struct list_head list; struct dw_edma_chan *chan; @@ -87,7 +73,7 @@ struct dw_edma_desc { struct dw_edma_chan { struct virt_dma_chan vc; - struct dw_edma_chip *chip; + struct dw_edma *dw; int id; enum dw_edma_dir dir; @@ -109,10 +95,6 @@ struct dw_edma_irq { struct dw_edma *dw; }; -struct dw_edma_core_ops { - int (*irq_vector)(struct device *dev, unsigned int nr); -}; - struct dw_edma { char name[20]; @@ -122,21 +104,14 @@ struct dw_edma { struct dma_device rd_edma; u16 rd_ch_cnt; - struct dw_edma_region rg_region; /* Registers */ - struct dw_edma_region ll_region_wr[EDMA_MAX_WR_CH]; - struct dw_edma_region ll_region_rd[EDMA_MAX_RD_CH]; - struct dw_edma_region dt_region_wr[EDMA_MAX_WR_CH]; - struct dw_edma_region dt_region_rd[EDMA_MAX_RD_CH]; - struct dw_edma_irq *irq; int nr_irqs; - enum dw_edma_map_format mf; - struct dw_edma_chan *chan; - const struct dw_edma_core_ops *ops; raw_spinlock_t lock; /* Only for legacy */ + + struct dw_edma_chip *chip; #ifdef CONFIG_DEBUG_FS struct dentry *debugfs; #endif /* CONFIG_DEBUG_FS */ diff --git a/drivers/dma/dw-edma/dw-edma-pcie.c b/drivers/dma/dw-edma/dw-edma-pcie.c index 44f6e09bdb531..21c8c59e09c23 100644 --- a/drivers/dma/dw-edma/dw-edma-pcie.c +++ b/drivers/dma/dw-edma/dw-edma-pcie.c @@ -148,7 +148,6 @@ static int dw_edma_pcie_probe(struct pci_dev *pdev, struct dw_edma_pcie_data vsec_data; struct device *dev = &pdev->dev; struct dw_edma_chip *chip; - struct dw_edma *dw; int err, nr_irqs; int i, mask; @@ -214,10 +213,6 @@ static int dw_edma_pcie_probe(struct pci_dev *pdev, if (!chip) return -ENOMEM; - dw = devm_kzalloc(dev, sizeof(*dw), GFP_KERNEL); - if (!dw) - return -ENOMEM; - /* IRQs allocation */ nr_irqs = pci_alloc_irq_vectors(pdev, 1, vsec_data.irqs, PCI_IRQ_MSI | PCI_IRQ_MSIX); @@ -228,29 +223,24 @@ static int dw_edma_pcie_probe(struct pci_dev *pdev, } /* Data structure initialization */ - chip->dw = dw; chip->dev = dev; chip->id = pdev->devfn; chip->irq = pdev->irq; - dw->mf = vsec_data.mf; - dw->nr_irqs = nr_irqs; - dw->ops = &dw_edma_pcie_core_ops; - dw->wr_ch_cnt = vsec_data.wr_ch_cnt; - dw->rd_ch_cnt = vsec_data.rd_ch_cnt; + chip->mf = vsec_data.mf; + chip->nr_irqs = nr_irqs; + chip->ops = &dw_edma_pcie_core_ops; - dw->rg_region.vaddr = pcim_iomap_table(pdev)[vsec_data.rg.bar]; - if (!dw->rg_region.vaddr) - return -ENOMEM; + chip->wr_ch_cnt = vsec_data.wr_ch_cnt; + chip->rd_ch_cnt = vsec_data.rd_ch_cnt; - dw->rg_region.vaddr += vsec_data.rg.off; - dw->rg_region.paddr = pdev->resource[vsec_data.rg.bar].start; - dw->rg_region.paddr += vsec_data.rg.off; - dw->rg_region.sz = vsec_data.rg.sz; + chip->rg_region.vaddr = pcim_iomap_table(pdev)[vsec_data.rg.bar]; + if (!chip->rg_region.vaddr) + return -ENOMEM; - for (i = 0; i < dw->wr_ch_cnt; i++) { - struct dw_edma_region *ll_region = &dw->ll_region_wr[i]; - struct dw_edma_region *dt_region = &dw->dt_region_wr[i]; + for (i = 0; i < chip->wr_ch_cnt; i++) { + struct dw_edma_region *ll_region = &chip->ll_region_wr[i]; + struct dw_edma_region *dt_region = &chip->dt_region_wr[i]; struct dw_edma_block *ll_block = &vsec_data.ll_wr[i]; struct dw_edma_block *dt_block = &vsec_data.dt_wr[i]; @@ -273,9 +263,9 @@ static int dw_edma_pcie_probe(struct pci_dev *pdev, dt_region->sz = dt_block->sz; } - for (i = 0; i < dw->rd_ch_cnt; i++) { - struct dw_edma_region *ll_region = &dw->ll_region_rd[i]; - struct dw_edma_region *dt_region = &dw->dt_region_rd[i]; + for (i = 0; i < chip->rd_ch_cnt; i++) { + struct dw_edma_region *ll_region = &chip->ll_region_rd[i]; + struct dw_edma_region *dt_region = &chip->dt_region_rd[i]; struct dw_edma_block *ll_block = &vsec_data.ll_rd[i]; struct dw_edma_block *dt_block = &vsec_data.dt_rd[i]; @@ -299,45 +289,45 @@ static int dw_edma_pcie_probe(struct pci_dev *pdev, } /* Debug info */ - if (dw->mf == EDMA_MF_EDMA_LEGACY) - pci_dbg(pdev, "Version:\teDMA Port Logic (0x%x)\n", dw->mf); - else if (dw->mf == EDMA_MF_EDMA_UNROLL) - pci_dbg(pdev, "Version:\teDMA Unroll (0x%x)\n", dw->mf); - else if (dw->mf == EDMA_MF_HDMA_COMPAT) - pci_dbg(pdev, "Version:\tHDMA Compatible (0x%x)\n", dw->mf); + if (chip->mf == EDMA_MF_EDMA_LEGACY) + pci_dbg(pdev, "Version:\teDMA Port Logic (0x%x)\n", chip->mf); + else if (chip->mf == EDMA_MF_EDMA_UNROLL) + pci_dbg(pdev, "Version:\teDMA Unroll (0x%x)\n", chip->mf); + else if (chip->mf == EDMA_MF_HDMA_COMPAT) + pci_dbg(pdev, "Version:\tHDMA Compatible (0x%x)\n", chip->mf); else - pci_dbg(pdev, "Version:\tUnknown (0x%x)\n", dw->mf); + pci_dbg(pdev, "Version:\tUnknown (0x%x)\n", chip->mf); - pci_dbg(pdev, "Registers:\tBAR=%u, off=0x%.8lx, sz=0x%zx bytes, addr(v=%p, p=%pa)\n", + pci_dbg(pdev, "Registers:\tBAR=%u, off=0x%.8lx, sz=0x%zx bytes, addr(v=%p)\n", vsec_data.rg.bar, vsec_data.rg.off, vsec_data.rg.sz, - dw->rg_region.vaddr, &dw->rg_region.paddr); + chip->rg_region.vaddr); - for (i = 0; i < dw->wr_ch_cnt; i++) { + for (i = 0; i < chip->wr_ch_cnt; i++) { pci_dbg(pdev, "L. List:\tWRITE CH%.2u, BAR=%u, off=0x%.8lx, sz=0x%zx bytes, addr(v=%p, p=%pa)\n", i, vsec_data.ll_wr[i].bar, - vsec_data.ll_wr[i].off, dw->ll_region_wr[i].sz, - dw->ll_region_wr[i].vaddr, &dw->ll_region_wr[i].paddr); + vsec_data.ll_wr[i].off, chip->ll_region_wr[i].sz, + chip->ll_region_wr[i].vaddr, &chip->ll_region_wr[i].paddr); pci_dbg(pdev, "Data:\tWRITE CH%.2u, BAR=%u, off=0x%.8lx, sz=0x%zx bytes, addr(v=%p, p=%pa)\n", i, vsec_data.dt_wr[i].bar, - vsec_data.dt_wr[i].off, dw->dt_region_wr[i].sz, - dw->dt_region_wr[i].vaddr, &dw->dt_region_wr[i].paddr); + vsec_data.dt_wr[i].off, chip->dt_region_wr[i].sz, + chip->dt_region_wr[i].vaddr, &chip->dt_region_wr[i].paddr); } - for (i = 0; i < dw->rd_ch_cnt; i++) { + for (i = 0; i < chip->rd_ch_cnt; i++) { pci_dbg(pdev, "L. List:\tREAD CH%.2u, BAR=%u, off=0x%.8lx, sz=0x%zx bytes, addr(v=%p, p=%pa)\n", i, vsec_data.ll_rd[i].bar, - vsec_data.ll_rd[i].off, dw->ll_region_rd[i].sz, - dw->ll_region_rd[i].vaddr, &dw->ll_region_rd[i].paddr); + vsec_data.ll_rd[i].off, chip->ll_region_rd[i].sz, + chip->ll_region_rd[i].vaddr, &chip->ll_region_rd[i].paddr); pci_dbg(pdev, "Data:\tREAD CH%.2u, BAR=%u, off=0x%.8lx, sz=0x%zx bytes, addr(v=%p, p=%pa)\n", i, vsec_data.dt_rd[i].bar, - vsec_data.dt_rd[i].off, dw->dt_region_rd[i].sz, - dw->dt_region_rd[i].vaddr, &dw->dt_region_rd[i].paddr); + vsec_data.dt_rd[i].off, chip->dt_region_rd[i].sz, + chip->dt_region_rd[i].vaddr, &chip->dt_region_rd[i].paddr); } - pci_dbg(pdev, "Nr. IRQs:\t%u\n", dw->nr_irqs); + pci_dbg(pdev, "Nr. IRQs:\t%u\n", chip->nr_irqs); /* Validating if PCI interrupts were enabled */ if (!pci_dev_msi_enabled(pdev)) { @@ -345,10 +335,6 @@ static int dw_edma_pcie_probe(struct pci_dev *pdev, return -EPERM; } - dw->irq = devm_kcalloc(dev, nr_irqs, sizeof(*dw->irq), GFP_KERNEL); - if (!dw->irq) - return -ENOMEM; - /* Starting eDMA driver */ err = dw_edma_probe(chip); if (err) { diff --git a/drivers/dma/dw-edma/dw-edma-v0-core.c b/drivers/dma/dw-edma/dw-edma-v0-core.c index 329fc2e57b703..082049d53ca73 100644 --- a/drivers/dma/dw-edma/dw-edma-v0-core.c +++ b/drivers/dma/dw-edma/dw-edma-v0-core.c @@ -25,7 +25,7 @@ enum dw_edma_control { static inline struct dw_edma_v0_regs __iomem *__dw_regs(struct dw_edma *dw) { - return dw->rg_region.vaddr; + return dw->chip->rg_region.vaddr; } #define SET_32(dw, name, value) \ @@ -96,7 +96,7 @@ static inline struct dw_edma_v0_regs __iomem *__dw_regs(struct dw_edma *dw) static inline struct dw_edma_v0_ch_regs __iomem * __dw_ch_regs(struct dw_edma *dw, enum dw_edma_dir dir, u16 ch) { - if (dw->mf == EDMA_MF_EDMA_LEGACY) + if (dw->chip->mf == EDMA_MF_EDMA_LEGACY) return &(__dw_regs(dw)->type.legacy.ch); if (dir == EDMA_DIR_WRITE) @@ -108,7 +108,7 @@ __dw_ch_regs(struct dw_edma *dw, enum dw_edma_dir dir, u16 ch) static inline void writel_ch(struct dw_edma *dw, enum dw_edma_dir dir, u16 ch, u32 value, void __iomem *addr) { - if (dw->mf == EDMA_MF_EDMA_LEGACY) { + if (dw->chip->mf == EDMA_MF_EDMA_LEGACY) { u32 viewport_sel; unsigned long flags; @@ -133,7 +133,7 @@ static inline u32 readl_ch(struct dw_edma *dw, enum dw_edma_dir dir, u16 ch, { u32 value; - if (dw->mf == EDMA_MF_EDMA_LEGACY) { + if (dw->chip->mf == EDMA_MF_EDMA_LEGACY) { u32 viewport_sel; unsigned long flags; @@ -169,7 +169,7 @@ static inline u32 readl_ch(struct dw_edma *dw, enum dw_edma_dir dir, u16 ch, static inline void writeq_ch(struct dw_edma *dw, enum dw_edma_dir dir, u16 ch, u64 value, void __iomem *addr) { - if (dw->mf == EDMA_MF_EDMA_LEGACY) { + if (dw->chip->mf == EDMA_MF_EDMA_LEGACY) { u32 viewport_sel; unsigned long flags; @@ -194,7 +194,7 @@ static inline u64 readq_ch(struct dw_edma *dw, enum dw_edma_dir dir, u16 ch, { u32 value; - if (dw->mf == EDMA_MF_EDMA_LEGACY) { + if (dw->chip->mf == EDMA_MF_EDMA_LEGACY) { u32 viewport_sel; unsigned long flags; @@ -256,7 +256,7 @@ u16 dw_edma_v0_core_ch_count(struct dw_edma *dw, enum dw_edma_dir dir) enum dma_status dw_edma_v0_core_ch_status(struct dw_edma_chan *chan) { - struct dw_edma *dw = chan->chip->dw; + struct dw_edma *dw = chan->dw; u32 tmp; tmp = FIELD_GET(EDMA_V0_CH_STATUS_MASK, @@ -272,7 +272,7 @@ enum dma_status dw_edma_v0_core_ch_status(struct dw_edma_chan *chan) void dw_edma_v0_core_clear_done_int(struct dw_edma_chan *chan) { - struct dw_edma *dw = chan->chip->dw; + struct dw_edma *dw = chan->dw; SET_RW_32(dw, chan->dir, int_clear, FIELD_PREP(EDMA_V0_DONE_INT_MASK, BIT(chan->id))); @@ -280,7 +280,7 @@ void dw_edma_v0_core_clear_done_int(struct dw_edma_chan *chan) void dw_edma_v0_core_clear_abort_int(struct dw_edma_chan *chan) { - struct dw_edma *dw = chan->chip->dw; + struct dw_edma *dw = chan->dw; SET_RW_32(dw, chan->dir, int_clear, FIELD_PREP(EDMA_V0_ABORT_INT_MASK, BIT(chan->id))); @@ -357,7 +357,7 @@ static void dw_edma_v0_core_write_chunk(struct dw_edma_chunk *chunk) void dw_edma_v0_core_start(struct dw_edma_chunk *chunk, bool first) { struct dw_edma_chan *chan = chunk->chan; - struct dw_edma *dw = chan->chip->dw; + struct dw_edma *dw = chan->dw; u32 tmp; dw_edma_v0_core_write_chunk(chunk); @@ -365,7 +365,7 @@ void dw_edma_v0_core_start(struct dw_edma_chunk *chunk, bool first) if (first) { /* Enable engine */ SET_RW_32(dw, chan->dir, engine_en, BIT(0)); - if (dw->mf == EDMA_MF_HDMA_COMPAT) { + if (dw->chip->mf == EDMA_MF_HDMA_COMPAT) { switch (chan->id) { case 0: SET_RW_COMPAT(dw, chan->dir, ch0_pwr_en, @@ -431,7 +431,7 @@ void dw_edma_v0_core_start(struct dw_edma_chunk *chunk, bool first) int dw_edma_v0_core_device_config(struct dw_edma_chan *chan) { - struct dw_edma *dw = chan->chip->dw; + struct dw_edma *dw = chan->dw; u32 tmp = 0; /* MSI done addr - low, high */ @@ -501,12 +501,12 @@ int dw_edma_v0_core_device_config(struct dw_edma_chan *chan) } /* eDMA debugfs callbacks */ -void dw_edma_v0_core_debugfs_on(struct dw_edma_chip *chip) +void dw_edma_v0_core_debugfs_on(struct dw_edma *dw) { - dw_edma_v0_debugfs_on(chip); + dw_edma_v0_debugfs_on(dw->chip); } -void dw_edma_v0_core_debugfs_off(struct dw_edma_chip *chip) +void dw_edma_v0_core_debugfs_off(struct dw_edma *dw) { - dw_edma_v0_debugfs_off(chip); + dw_edma_v0_debugfs_off(dw->chip); } diff --git a/drivers/dma/dw-edma/dw-edma-v0-core.h b/drivers/dma/dw-edma/dw-edma-v0-core.h index 2afa626b8300c..75aec6d31b210 100644 --- a/drivers/dma/dw-edma/dw-edma-v0-core.h +++ b/drivers/dma/dw-edma/dw-edma-v0-core.h @@ -22,7 +22,7 @@ u32 dw_edma_v0_core_status_abort_int(struct dw_edma *chan, enum dw_edma_dir dir) void dw_edma_v0_core_start(struct dw_edma_chunk *chunk, bool first); int dw_edma_v0_core_device_config(struct dw_edma_chan *chan); /* eDMA debug fs callbacks */ -void dw_edma_v0_core_debugfs_on(struct dw_edma_chip *chip); -void dw_edma_v0_core_debugfs_off(struct dw_edma_chip *chip); +void dw_edma_v0_core_debugfs_on(struct dw_edma *dw); +void dw_edma_v0_core_debugfs_off(struct dw_edma *dw); #endif /* _DW_EDMA_V0_CORE_H */ diff --git a/drivers/dma/dw-edma/dw-edma-v0-debugfs.c b/drivers/dma/dw-edma/dw-edma-v0-debugfs.c index 4b3bcffd15ef1..edb7e137cb35a 100644 --- a/drivers/dma/dw-edma/dw-edma-v0-debugfs.c +++ b/drivers/dma/dw-edma/dw-edma-v0-debugfs.c @@ -54,7 +54,7 @@ struct debugfs_entries { static int dw_edma_debugfs_u32_get(void *data, u64 *val) { void __iomem *reg = (void __force __iomem *)data; - if (dw->mf == EDMA_MF_EDMA_LEGACY && + if (dw->chip->mf == EDMA_MF_EDMA_LEGACY && reg >= (void __iomem *)®s->type.legacy.ch) { void __iomem *ptr = ®s->type.legacy.ch; u32 viewport_sel = 0; @@ -173,7 +173,7 @@ static void dw_edma_debugfs_regs_wr(struct dentry *dir) nr_entries = ARRAY_SIZE(debugfs_regs); dw_edma_debugfs_create_x32(debugfs_regs, nr_entries, regs_dir); - if (dw->mf == EDMA_MF_HDMA_COMPAT) { + if (dw->chip->mf == EDMA_MF_HDMA_COMPAT) { nr_entries = ARRAY_SIZE(debugfs_unroll_regs); dw_edma_debugfs_create_x32(debugfs_unroll_regs, nr_entries, regs_dir); @@ -242,7 +242,7 @@ static void dw_edma_debugfs_regs_rd(struct dentry *dir) nr_entries = ARRAY_SIZE(debugfs_regs); dw_edma_debugfs_create_x32(debugfs_regs, nr_entries, regs_dir); - if (dw->mf == EDMA_MF_HDMA_COMPAT) { + if (dw->chip->mf == EDMA_MF_HDMA_COMPAT) { nr_entries = ARRAY_SIZE(debugfs_unroll_regs); dw_edma_debugfs_create_x32(debugfs_unroll_regs, nr_entries, regs_dir); @@ -288,7 +288,7 @@ void dw_edma_v0_debugfs_on(struct dw_edma_chip *chip) if (!dw) return; - regs = dw->rg_region.vaddr; + regs = dw->chip->rg_region.vaddr; if (!regs) return; @@ -296,7 +296,7 @@ void dw_edma_v0_debugfs_on(struct dw_edma_chip *chip) if (!dw->debugfs) return; - debugfs_create_u32("mf", 0444, dw->debugfs, &dw->mf); + debugfs_create_u32("mf", 0444, dw->debugfs, &dw->chip->mf); debugfs_create_u16("wr_ch_cnt", 0444, dw->debugfs, &dw->wr_ch_cnt); debugfs_create_u16("rd_ch_cnt", 0444, dw->debugfs, &dw->rd_ch_cnt); diff --git a/include/linux/dma/edma.h b/include/linux/dma/edma.h index cab6e18773dad..a9bee4aeb2eee 100644 --- a/include/linux/dma/edma.h +++ b/include/linux/dma/edma.h @@ -12,19 +12,63 @@ #include #include +#define EDMA_MAX_WR_CH 8 +#define EDMA_MAX_RD_CH 8 + struct dw_edma; +struct dw_edma_region { + phys_addr_t paddr; + void __iomem *vaddr; + size_t sz; +}; + +struct dw_edma_core_ops { + int (*irq_vector)(struct device *dev, unsigned int nr); +}; + +enum dw_edma_map_format { + EDMA_MF_EDMA_LEGACY = 0x0, + EDMA_MF_EDMA_UNROLL = 0x1, + EDMA_MF_HDMA_COMPAT = 0x5 +}; + /** * struct dw_edma_chip - representation of DesignWare eDMA controller hardware * @dev: struct device of the eDMA controller * @id: instance ID * @irq: irq line + * @nr_irqs: total dma irq number + * @ops DMA channel to IRQ number mapping + * @wr_ch_cnt DMA write channel number + * @rd_ch_cnt DMA read channel number + * @rg_region DMA register region + * @ll_region_wr DMA descriptor link list memory for write channel + * @ll_region_rd DMA descriptor link list memory for read channel + * @mf DMA register map format * @dw: struct dw_edma that is filed by dw_edma_probe() */ struct dw_edma_chip { struct device *dev; int id; int irq; + int nr_irqs; + const struct dw_edma_core_ops *ops; + + struct dw_edma_region rg_region; + + u16 wr_ch_cnt; + u16 rd_ch_cnt; + /* link list address */ + struct dw_edma_region ll_region_wr[EDMA_MAX_WR_CH]; + struct dw_edma_region ll_region_rd[EDMA_MAX_RD_CH]; + + /* data region */ + struct dw_edma_region dt_region_wr[EDMA_MAX_WR_CH]; + struct dw_edma_region dt_region_rd[EDMA_MAX_RD_CH]; + + enum dw_edma_map_format mf; + struct dw_edma *dw; }; From patchwork Wed Apr 6 15:23:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 12803845 X-Patchwork-Delegate: lorenzo.pieralisi@arm.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 83112C433F5 for ; Wed, 6 Apr 2022 17:23:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238974AbiDFRZn (ORCPT ); Wed, 6 Apr 2022 13:25:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57220 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238883AbiDFRZg (ORCPT ); Wed, 6 Apr 2022 13:25:36 -0400 Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2066.outbound.protection.outlook.com [40.107.20.66]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 784144B75A0; Wed, 6 Apr 2022 08:24:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IoXfTyIgIL3oZi9g2aNvvbC1C1iXphc/HMqkp5/Kl4Gbotw4b4JiOnJxC/lOn9A/wui+xNh5E0S46tZe+Q2q5Xffc/sBC9fVuhHjM869WGhhpr5DgZAunBDTInpLcyu61gHL67T93ZIKQ9Duh35WKIkarcSZF2ik7su7rSU/ROzllXBQXyk9xxXj5XfMnDl9EmghPcZuYR7q8nWVacYwLBpJvV3Ao+Glg9fa/KHtqXtlO8t8EydtGFys9+FIgZuw0NgUQ/FItLQyGFKo6R0/Bdx0xEM41kBnOCvOUtRJKDCOz+wYtqOfIV5AAm/nyGebVXRn+WbaVdqg50QYCu1wqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=XvWqMA9Fh+L27kw3wJYb6ONpAd4/NiB7Xov+3L1mw1A=; b=EBkkq4nTkTjnSJRGfRunjCOySuYMkHb4FkRXdb9aczKOH2+i4GvGqI1qwA3Wr34QQzW5LVNg6c6XeOh/vn23uF3+ZuCINKadq4dAGIBMc13maZIoFJZnXY17QlnN2UIgIyH1woL/V/T1ijCvgB//Z4oZpnZpkPlcBnyEKt7cpqLxRIaxUqWyOFUfZdKkg6TWXC6+nPkJw4luoR2aYIVG8jvlzhPm9Q1Fg2JFQrlmhHCxWpnWe1KhMrSYVJ1zlVMiemWqCFVUAhtjxrkLro+9LxJhi2S4DaoKNa4wIkXQHwYJIusYMXp5mg16ohQe6slTLa+VlMrDKb57MY4PR1FLcw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=XvWqMA9Fh+L27kw3wJYb6ONpAd4/NiB7Xov+3L1mw1A=; b=AlXTWBF6xRLHvap0/++cOq8DdPb6liP35sms/bkS9Q8HbtlPuY88Ek3i6mzNK0mljluir/dGQL+v/iFk67+TMVU98BKJ0rYxV2A9DYbDue+9JRc4cbNRv+nNP23+syAAlDuCqZT2NU9gnHMwJpS230sJh48lUmrmHOQ0oQREw/8= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from PAXPR04MB9186.eurprd04.prod.outlook.com (2603:10a6:102:232::18) by VE1PR04MB7343.eurprd04.prod.outlook.com (2603:10a6:800:1a2::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5123.31; Wed, 6 Apr 2022 15:24:28 +0000 Received: from PAXPR04MB9186.eurprd04.prod.outlook.com ([fe80::ade4:ad15:823b:7e2b]) by PAXPR04MB9186.eurprd04.prod.outlook.com ([fe80::ade4:ad15:823b:7e2b%7]) with mapi id 15.20.5123.031; Wed, 6 Apr 2022 15:24:28 +0000 From: Frank Li To: gustavo.pimentel@synopsys.com, hongxing.zhu@nxp.com, l.stach@pengutronix.de, linux-imx@nxp.com, linux-pci@vger.kernel.org, dmaengine@vger.kernel.org, fancer.lancer@gmail.com, lznuaa@gmail.com, helgaas@kernel.org Cc: vkoul@kernel.org, lorenzo.pieralisi@arm.com, robh@kernel.org, kw@linux.com, bhelgaas@google.com, manivannan.sadhasivam@linaro.org, Sergey.Semin@baikalelectronics.ru Subject: [PATCH v6 2/9] dmaengine: dw-edma: Remove unused field irq in struct dw_edma_chip Date: Wed, 6 Apr 2022 10:23:40 -0500 Message-Id: <20220406152347.85908-3-Frank.Li@nxp.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220406152347.85908-1-Frank.Li@nxp.com> References: <20220406152347.85908-1-Frank.Li@nxp.com> X-ClientProxiedBy: BYAPR11CA0046.namprd11.prod.outlook.com (2603:10b6:a03:80::23) To PAXPR04MB9186.eurprd04.prod.outlook.com (2603:10a6:102:232::18) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 3637e0b5-fb37-4be3-7fd7-08da17e18a28 X-MS-TrafficTypeDiagnostic: VE1PR04MB7343:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: a1Zt5Sa3QAXS1CRabj4/p2vVIEAAaejKGhCqRHYRjhvOq49pQnVwOLva28zSXRDu82uWvNZJyYW48yNmUT+FXqH+Nhd6RyQ/lLq74XguP6GM7hb5InMqjVXiAd0efhSlIDiveQRTUaOlPNyCLh3W783FfjPmsCIJc/bJ2tAkLCsc79wCkSeT2mw7Pjb3WDNzrJivwXapU/OWrcxsrs139SKv5Z5iAWeLkt0w3Lx1YsR11rX2kODHG/F3r/VC0LZD3Qq2Sqik677v3ljDbLe+Dcc8tlFxvYahA7WvQ8egV0AtddLFPU/f0J9dj6TGyQ5pbMF8vl4su6PQYQcbeP6jkIeHRVZXVQYGwOzAjquJRocUF+hhVF9UY0CUGkGrC096ue4HMOMW6g/gqmcpj40SbNPHlhT/ZAKkjSNLh3bWELLLszHn7Fs3zlBpBn3QiZz3uyN5NJnjvCxa2eih4c+nDhRD244a8RXOj17cBtphAcZwjd/avy/LPnsT2IbhXYfkDTBSYe4rMZYqt9+gpLcHx/dGwfIot8jnL7r5bKwwJevnA0Ny1s7iqQTDP5AMXJTuXF6KaYKtpnHdRGusSaXJuOAOIh9kQ9dy6Zjb/py6DvMG9UcVz+/+1ongAoufAe9Nes8wDoaoctx2CUZiRyRMwfpHXJp7KXmLagAwjmdSj1PCqyfDVC1KnTcxboo2xKrRQZ8JHf8Ec8wurOpOynO3uw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR04MB9186.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(4636009)(366004)(508600001)(6512007)(7416002)(6666004)(36756003)(66476007)(66946007)(66556008)(8676002)(86362001)(83380400001)(4326008)(52116002)(8936002)(26005)(5660300002)(186003)(2906002)(316002)(38350700002)(2616005)(38100700002)(1076003)(6486002)(6506007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 1IbTtz5PlqMMvXSRFqATS/97zPDimTZFu6oNjh567JIgQHEQOgD2TlR2ylVpH+X+0825NdP38muvzEK9xfQkQbhBJ9rHq4KdZtWYOpYcXAzRyK9xngGsS2ssFyi55zSURYI4X8Rac6OTfXxEDHCQ1z4ZSXkNEk0q1ZxReiBEg234iOASCGWhIycXaUj+CRmNYqyhSIMzEjSEZMfWu5VtbH/ryamJx65VCbZfLw4ncX0yy9hs1ycItZ/sk1q8Go/+7pNYFPk+3f5XOrRP2pIZU9+EnNIM6QZcpWJRhjKFcdiH220LIHGSFiqn7dfloo1tSXsDxue9QJpiRasjSlhwOOFpcDxmHpnZLB3t+dwXEjysQm5jv4NCjOJ6+ct35LIx7Lj0qNKXE0GP8nDx5XV3qI3ucXnrkkkkH53GkE5Gt80M1WRFkWoTrRfjFNFa0rl26UbXjZwhEQlUwO3eb7R3Rsu7+uDdjX+RJnEoveXVDiD6C52RAa082FO6nGYqCBOByn12lriPACqe4A5r951PWbTYc/Ih/0oqTbfpyXZPUXwq9EG0cBu/pp2PdDtRZJrzSbkdq8qJ9Vhis6f2PGc9pYCvDMleVLpEyQVAjADClzdsOjhiMz/0qBI7Rb7uotkJSFA9MLubHmbpM8zzEQE5yrG1XjonCjX8DqqiJb5qqdCTzs8ThrnIfCHhUQIl5bbNgYmn6Hy3tE3sbJeyGV/IbnU1AEA+dSYfn6YFT7RnupSsodGlrA/Cwzjh6x38OjGDVHz71Ihj92rfEthn1fV10Dex92/Jxi5kJIDVa3KGXnBnjlMV1kE7vqA8ON1sjZdQG9eNMQXtrT7mwYwp0usTXZWBxK4VNVy+LEFlchd+qY3tEnAS2SZPyhTxxkGym+FOs5kpkfaZm/BD+Jy2iS+5+zI+nJMbOF3LdLiTjoXArJt2F0Gm0qxQoJDWPxjKbXtXxs2R1Ltl8and1rI0/aEqrzsV2fAkXYEFDMzBULd0hJ74exz5p6x0GnW3+RQI1J6HAkleX3V1dhaxEbNxe2F0k+B5D6nU6C03VgPmWT3gbfLKV4FJ/eaOUKPB1L6mpb0+SnCoiZJhCCJDenbTzHgCnr8cEpJW8tJ4aLPaH2l5ntR8tBQ8Qs3sK4ZTS0KWUdu6n0qEyFyvtty+Ys3vLWkQbjI8Df9qPTxHRozKeOFiKOr769Z7GU/IfLx1r0zFS5xsKzOPDnJCgbcUW2pgpXz0sNuznb3wwQoHXpVtzQrAVLwxVLJXSjYofsSbqLFhMqTJ1bosGH5cvIwKErRQInSmeWG410Hfziy1CzEf5+oRlDppYrYd7ARRRdTHeOIRUfoBd96ghbnUO0CQKpaHxGhUnhBdQpFZxqufQaAEJDdqjgqz61efyTLoQ6NkNco2MmqmvMjveSZNgSeQjfEt/GotkDE9HXIbpF7da5hxhMZdnqViwizn1U+yf7TxLv9VmIBNeFAbJz+o8XE7Qq8qboD37pr0OxXqBCo8LcMYRCyT0N3I0Ci1FJoHe3jiWaVg5MjYDDDgt1uCxPq/meLp4/RsTeRJHCVebeWCXgcAL1zKzjVE2TIEgwMU6DTXvJ/5BZZTShBVyZwo0t3nt8vLKO3WUzVU8SBZMJLQcjZVSxKuR+sFQ2NrTBy6D7USsrBLwhGzqzgViqdb4FsgNCq9MaK3pKatpTdASmu3YCNuhar6lAsmqHRwhnHZaVVL2ZvRD0+3VQtEsPVFXCNwW0PjdwyjDA== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3637e0b5-fb37-4be3-7fd7-08da17e18a28 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9186.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Apr 2022 15:24:28.0586 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 0TSnGEJSf6E3sUl+cdSFWx6siIQ4wVtRztAFwbTjzjeiuhmZkexCyf4h81LXSABsx3ERoXZvHWLqfLr+0+3tTQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR04MB7343 Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org irq of struct dw_edma_chip was never used. It can be removed safely. Signed-off-by: Frank Li --- Change from v5 to v6 - s/remove/Remove/ at subject Change from v4 to v5 - none new patch at v4 drivers/dma/dw-edma/dw-edma-pcie.c | 1 - include/linux/dma/edma.h | 2 -- 2 files changed, 3 deletions(-) diff --git a/drivers/dma/dw-edma/dw-edma-pcie.c b/drivers/dma/dw-edma/dw-edma-pcie.c index 21c8c59e09c23..2c1c5fa4e9f28 100644 --- a/drivers/dma/dw-edma/dw-edma-pcie.c +++ b/drivers/dma/dw-edma/dw-edma-pcie.c @@ -225,7 +225,6 @@ static int dw_edma_pcie_probe(struct pci_dev *pdev, /* Data structure initialization */ chip->dev = dev; chip->id = pdev->devfn; - chip->irq = pdev->irq; chip->mf = vsec_data.mf; chip->nr_irqs = nr_irqs; diff --git a/include/linux/dma/edma.h b/include/linux/dma/edma.h index a9bee4aeb2eee..6fd374cc72c8e 100644 --- a/include/linux/dma/edma.h +++ b/include/linux/dma/edma.h @@ -37,7 +37,6 @@ enum dw_edma_map_format { * struct dw_edma_chip - representation of DesignWare eDMA controller hardware * @dev: struct device of the eDMA controller * @id: instance ID - * @irq: irq line * @nr_irqs: total dma irq number * @ops DMA channel to IRQ number mapping * @wr_ch_cnt DMA write channel number @@ -51,7 +50,6 @@ enum dw_edma_map_format { struct dw_edma_chip { struct device *dev; int id; - int irq; int nr_irqs; const struct dw_edma_core_ops *ops; From patchwork Wed Apr 6 15:23:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 12803847 X-Patchwork-Delegate: lorenzo.pieralisi@arm.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3C9B5C433F5 for ; Wed, 6 Apr 2022 17:23:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238596AbiDFRZs (ORCPT ); Wed, 6 Apr 2022 13:25:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46026 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238714AbiDFRZi (ORCPT ); Wed, 6 Apr 2022 13:25:38 -0400 Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2053.outbound.protection.outlook.com [40.107.20.53]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8290C4B891B; Wed, 6 Apr 2022 08:24:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=H5mcwxWwaacr1v0hS9mB+Xkp5OQdQn1Eh+Em/NPtixvIxzVPw8HRgWXEYD/0+2nbtb87GZVs45StnuV8u0pPNPHU4YlqTqJXXr+V3+hsJ46b89pSb+BaYw5PdRZtxmxzoc320zeriTLCUd62aTQWZlMhL9avw6WWQJwY3E6eCU90jeKwX/pSfvQ50XeM6i1GHSnXnNz+aYTqPzkSHE7ZFog1hFac0EtiDzvkKcUepwj1/jy5gJ8LkvtBmCsyc03G/QBEfpzXV49avNxJxOtrJks+G/789SoPFddXxMVhKJDAwRHeR/tQ7/Q0kAk2hd4zvFEeC8+Pol7Y3SfXu7yCvw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=9SCNm6g7OCnem5Ndg2a/x5LnrvhrCmHwnEad0Xypc8M=; b=GmvjmUz6AR1cITpni94zkTvpvtSMfGb2v8i8QQuHcrq+20apmZg4xWyYE2k2TR69g0YfvnYB/hu/dRWG6nUIZDCFQsy8GSMgF5R8q6TYyBnvNj9DanX3sWO+pa7iug9qWb8kIiH1jHvh2Q3tpw0weSybKdjtjeOz9+HvPAMW+/ZgIkB2jtm0t/S2/YeTLAMn1lIxS6kSvJumMtzzKpxQlY92s22DyKtYIDHndqUOLxyI4xlKLP4rubliDYfPwpI7gfDUklFhZWe3BUUH1tIGl1Pi7fak/HuW9oYy6HGru7mTJBw5XcMwL2E+zvbsTEHCURCC/xufcXfBmNFhvmprwQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=9SCNm6g7OCnem5Ndg2a/x5LnrvhrCmHwnEad0Xypc8M=; b=EAJR0dVpy27p/PQcsTBPlGTwuXdhtkJ4MJSt2zoNksyKLX3+V9+80C3FytEVpWAccGZVQxG76MrkHRL1sK7zdKIY31b+i3MWjsbVnGAdeTP9URS7B/EpsQ9+dl0Au7uCGMLByFeWe7ecX78br9svqYrNlYt4/ofQxSry0HDIQx0= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from PAXPR04MB9186.eurprd04.prod.outlook.com (2603:10a6:102:232::18) by VE1PR04MB7343.eurprd04.prod.outlook.com (2603:10a6:800:1a2::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5123.31; Wed, 6 Apr 2022 15:24:32 +0000 Received: from PAXPR04MB9186.eurprd04.prod.outlook.com ([fe80::ade4:ad15:823b:7e2b]) by PAXPR04MB9186.eurprd04.prod.outlook.com ([fe80::ade4:ad15:823b:7e2b%7]) with mapi id 15.20.5123.031; Wed, 6 Apr 2022 15:24:32 +0000 From: Frank Li To: gustavo.pimentel@synopsys.com, hongxing.zhu@nxp.com, l.stach@pengutronix.de, linux-imx@nxp.com, linux-pci@vger.kernel.org, dmaengine@vger.kernel.org, fancer.lancer@gmail.com, lznuaa@gmail.com, helgaas@kernel.org Cc: vkoul@kernel.org, lorenzo.pieralisi@arm.com, robh@kernel.org, kw@linux.com, bhelgaas@google.com, manivannan.sadhasivam@linaro.org, Sergey.Semin@baikalelectronics.ru Subject: [PATCH v6 3/9] dmaengine: dw-edma: Change rg_region to reg_base in struct dw_edma_chip Date: Wed, 6 Apr 2022 10:23:41 -0500 Message-Id: <20220406152347.85908-4-Frank.Li@nxp.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220406152347.85908-1-Frank.Li@nxp.com> References: <20220406152347.85908-1-Frank.Li@nxp.com> X-ClientProxiedBy: BYAPR11CA0046.namprd11.prod.outlook.com (2603:10b6:a03:80::23) To PAXPR04MB9186.eurprd04.prod.outlook.com (2603:10a6:102:232::18) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 3f8a24e0-d7f3-4ab6-6f7c-08da17e18c8d X-MS-TrafficTypeDiagnostic: VE1PR04MB7343:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: qEfOENnN6McUUN0ToMVcLEVuM+7ZRpxWkHWYktWKbccW1Nn44Ek5Y6u2mCzk2zAWcJCmycLAAjNCp4J1MSqY0cdF2L1+fikBkxaEu5trfAeZ62jLUvpIc36g1wt9BbaASU125G++8/QBZS91/62rOylnaNDEnGcV6Tp1mmveIQpc8xCucr86DvESIS/UlNz+/gYb9dfL8wv0sOhA4HuS8JagVcg11FV40fb48Zvo+GWup0uRyNrgRpcHP33d+oqdfu80phPq/0O2R8x8C7AvUy1+rY07XXhfG9+UGzTJounrUYQxHIc+Rsnamz6oyoTSIGXmeBSz6GpLR4lhNlHCarN+BpWBgheWsBBae7kCsp/VhAR0f7hpOij2U6r1cE1esgJDw2eoH4MVIgUjehSqXfcAcMIFsTX5y44TCV7TzRNVqti0LZ0vAxhLk3w7ir5NWxoSrjePyx7+wEcjnvZIlklC2mhlM9n+m29AGigQBWm04lb0BgrsVmqrjuxq8T4l6UYLXMV5pw0UzcB64gfSobY2rcMo6m9vtDLKW2kVyEacRak9KzqR7nVseJiARQJGsugbhwy4ZzlQU8RKY6gxlPKOXhC9OzAPOg9PCiDkraD7IrmCVTUboxTck1TE7dYVbf+e3CzxFnk7SW7/NfmjqjykMwlSaYj2FTwSuf382O/EU4kYR7GZyeZFid3gpCHPo6G5VN6sHEBOtYE+RQ0JMg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR04MB9186.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(4636009)(366004)(508600001)(6512007)(7416002)(6666004)(36756003)(66476007)(66946007)(66556008)(8676002)(86362001)(83380400001)(4326008)(52116002)(8936002)(26005)(5660300002)(186003)(2906002)(316002)(38350700002)(2616005)(38100700002)(1076003)(6486002)(6506007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: wOR0od0x28XAicMuIHirmQyzqd5CVHJOmO9GgA5lX9/6SLoqch4uN1gol8h0gWTvh/9DkjHPADwjx3NmIWonvVQXV6dJJaHAN8A9fbJisqdf30IEmVAp2RkH620s6bXzNSQGhY5QA2C+cPScJlGY3DWNlY6NHWDdNhIYtS+uhW5O/YdXBPVrC9o50Q2rEj4a3rhE11ag6P1mu3WzHm8pkOX19FnigUDJTzG0oGOQvNA8T1ozpy2pITyY/SwlKAqo/3wBYS/+MDD7Kn9BC7meveRJvKxhhk9bxh9AMorDpJUCYlV58tJUhjv0TpoDySQ+z1Bo/OnDZaQS5epfPb7UTLwYbZ3uc4eOn9LZtT3iJP1SRXf8qBiEJNRzzumtuDtzpY7QlUImhD3eyQLTqbvPhQlZG4s6xWOXKe/kuhWUYhmJjsb7Vl/HfxIwoDGp2fuW/oOcDXHwb03w0svHJZpFqcy9OPFakzooaZVfCHR1T6bPm02LWVdgkJifiRiwh+5V76iU78Twj8sjDEVHdy10/de863u4XVia6xzS4hRFyl7pmIIlNZJG4dmPka3z5bCrWgeVUZ6oslQZBYgQkhKxymYp06sc2oopgE4RzVItYLNlx3cyxLcfR2j6n/9yV/lBdWtpnahIxav5Be0WfRUlC6QTixHgELJ4v1nysgNpUUCsrBWoxiT/JNOh11hHh9hdmu9zViu8f51O4BahK1ZdtYXpJUCl2zsUHP5bRU5GT8EfZOMI4+mP6AGYrJhUVDa2aWEbtdymz1uGkJ00OXjwn09RazD3k8qIQl27UJyxzfSoOBL4VerKh34s+YCoUqHaFFFshsLnF0k8UDez3i3nsyujlsJ0OOGk1mN8ZL1rjTYLZhXoRHGCf/eTCujrqpm3r9IL/MGrXB6Zvd8e1YS3v7IZXah2n2Adu5XMx+83BA10/Yq85UP0vxoApvaakHiIr76HtbQ5fIicQsicHtO1QYVwMb3Sk1X49IsxOFgumvtDRUxPzBQ8YauUCoyT6Si1VnA9kB3KnasbrR0bmoO4ielCYCtBKKdgN9o7KNgwISEK3e3bbU0EHfL9vfJC+Xmion88ZaSwr8tGza/v2FZGVZEmi8QOHWLklxUXMTJfvZQj9+bPyUICdLBPZvi58Qh+gRQbgMwmVJLmVqnegWgsFKOBgr67UH/Z2YsvXKl9ZIEcFAK2H26b8YPwepD9cqr8wBPxwLIyc4FGcXZIoJeOiHMdL40x+6UafLhVzcoDZtmJq7Yaza8vxEoTMs9LDU5g+YlRqyU/YIAvByAl616iBXhTppalczEKiEttl+3PKFxzbzoDHYN/FsrpUU3QVxTFbBmNDQNOLEZ7Wak5j5DMGEcra7LCvnDEgw8kSYXkVgT+KXLP326zgxvnuu+TPw/CIkB3usqVWWsZ32KRBkr05kv6Uz5s/VwmjP/jaWKRC4/HZL5CDM9RyZ79wt1qoNN4P1HRKaDhAuAzLZL4V5QW8O7yUyFehHQlVZ/CymlXHR2b01931sg9ef4t2sKychCGSsY0QSrvc2K3rZeILWgZOfXUMf0RnvL8QEXP7zxoTkJrEwJx4LYL+ACme1w2S6druEuNpF/QtD5BpSV0p+BEy00X2mF17VkVJYleaWq+K8wdmEJQpoqaFYa61BGGAnNdQ+d8CicoqNERa2wooOw0cL0A/teVqfLxANzk92RTPaNDAdgCuWfq2OVJzMAhw/1LNICNckRincS/NrdAgLpIlQ== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3f8a24e0-d7f3-4ab6-6f7c-08da17e18c8d X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9186.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Apr 2022 15:24:32.1849 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: A97qUiYfEkjm26fcY9k0lzOZyUvxLuj0gV4Ic3SmHcZXvZtI5SqOj5oLeufclb3KA/IFvsfcOnX1u771Eil8xQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR04MB7343 Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org struct dw_edma_region rg_region included virtual address, physical address and size informaiton. But only virtual address is used by EDMA driver. Change it to void __iomem *reg_base to clean up code. Signed-off-by: Frank Li Reviewed-by: Serge Semin --- Change from v5 to v6: -s/change/Change at subject New patch at v4 drivers/dma/dw-edma/dw-edma-pcie.c | 6 +++--- drivers/dma/dw-edma/dw-edma-v0-core.c | 2 +- drivers/dma/dw-edma/dw-edma-v0-debugfs.c | 2 +- include/linux/dma/edma.h | 3 ++- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/drivers/dma/dw-edma/dw-edma-pcie.c b/drivers/dma/dw-edma/dw-edma-pcie.c index 2c1c5fa4e9f28..ae42bad24dd5a 100644 --- a/drivers/dma/dw-edma/dw-edma-pcie.c +++ b/drivers/dma/dw-edma/dw-edma-pcie.c @@ -233,8 +233,8 @@ static int dw_edma_pcie_probe(struct pci_dev *pdev, chip->wr_ch_cnt = vsec_data.wr_ch_cnt; chip->rd_ch_cnt = vsec_data.rd_ch_cnt; - chip->rg_region.vaddr = pcim_iomap_table(pdev)[vsec_data.rg.bar]; - if (!chip->rg_region.vaddr) + chip->reg_base = pcim_iomap_table(pdev)[vsec_data.rg.bar]; + if (!chip->reg_base) return -ENOMEM; for (i = 0; i < chip->wr_ch_cnt; i++) { @@ -299,7 +299,7 @@ static int dw_edma_pcie_probe(struct pci_dev *pdev, pci_dbg(pdev, "Registers:\tBAR=%u, off=0x%.8lx, sz=0x%zx bytes, addr(v=%p)\n", vsec_data.rg.bar, vsec_data.rg.off, vsec_data.rg.sz, - chip->rg_region.vaddr); + chip->reg_base); for (i = 0; i < chip->wr_ch_cnt; i++) { diff --git a/drivers/dma/dw-edma/dw-edma-v0-core.c b/drivers/dma/dw-edma/dw-edma-v0-core.c index 082049d53ca73..8ddc537d11fd6 100644 --- a/drivers/dma/dw-edma/dw-edma-v0-core.c +++ b/drivers/dma/dw-edma/dw-edma-v0-core.c @@ -25,7 +25,7 @@ enum dw_edma_control { static inline struct dw_edma_v0_regs __iomem *__dw_regs(struct dw_edma *dw) { - return dw->chip->rg_region.vaddr; + return dw->chip->reg_base; } #define SET_32(dw, name, value) \ diff --git a/drivers/dma/dw-edma/dw-edma-v0-debugfs.c b/drivers/dma/dw-edma/dw-edma-v0-debugfs.c index edb7e137cb35a..3a899f7f4e8d8 100644 --- a/drivers/dma/dw-edma/dw-edma-v0-debugfs.c +++ b/drivers/dma/dw-edma/dw-edma-v0-debugfs.c @@ -288,7 +288,7 @@ void dw_edma_v0_debugfs_on(struct dw_edma_chip *chip) if (!dw) return; - regs = dw->chip->rg_region.vaddr; + regs = dw->chip->reg_base; if (!regs) return; diff --git a/include/linux/dma/edma.h b/include/linux/dma/edma.h index 6fd374cc72c8e..e9ce652b88233 100644 --- a/include/linux/dma/edma.h +++ b/include/linux/dma/edma.h @@ -39,6 +39,7 @@ enum dw_edma_map_format { * @id: instance ID * @nr_irqs: total dma irq number * @ops DMA channel to IRQ number mapping + * @reg_base DMA register base address * @wr_ch_cnt DMA write channel number * @rd_ch_cnt DMA read channel number * @rg_region DMA register region @@ -53,7 +54,7 @@ struct dw_edma_chip { int nr_irqs; const struct dw_edma_core_ops *ops; - struct dw_edma_region rg_region; + void __iomem *reg_base; u16 wr_ch_cnt; u16 rd_ch_cnt; From patchwork Wed Apr 6 15:23:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 12803848 X-Patchwork-Delegate: lorenzo.pieralisi@arm.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D6322C433F5 for ; Wed, 6 Apr 2022 17:23:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238831AbiDFRZy (ORCPT ); Wed, 6 Apr 2022 13:25:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58924 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238814AbiDFRZn (ORCPT ); Wed, 6 Apr 2022 13:25:43 -0400 Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2043.outbound.protection.outlook.com [40.107.20.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6D72926367C; Wed, 6 Apr 2022 08:24:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WGdxmZyxmQF5FJLX72Oy2j17ilS0sqoEQXOjQQTrnjI+TXoxba4wetCn7DGIIFizRLcc3lzmJ4pT9w/aiRH/X1gSqbfYd7IItRSj4w27Kj/78LLVByov4BX/i5Y1taKOEAfPX5kTeMJfsCgDaJjF5Goa2H/aNlo+hmZk1+T00lZRa9nZE85v5uGlbqoYkQRLC705oxhKmnBiLQMPsiSCzQq3pyRH/SgH++lvD/YAAO7o1qxpLoBXL1Csz1vRp7JvNNP3QE34qjFSGqyZuXXQyniMSaY23Oq9EaJRjPVj4etv74UhBlyTCe2pDxSZnUukEtGPQCF0ZvhjJEvlD8Piiw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=2nCi4p4m7POLJTd2ebfAdGlzBYu3wFkr0iWssfe2aME=; b=VdoFKarloAD+tNJLXBvAYZmb9fJ1Wrz9X70WsRqYec4wAeVH1a3uTdAGObbTtPYXF7+9MqlhlFDkRh3eZPsyLtHD6OblxUI6rvHnzcx7auZfanPdt0hjLufW2SRnvR4Z2eBNcQu0gDPVRrOnQTfqqlR/15AZG2KlRD5PM+sm7Sy0N89I2UGdg9Q99GcEmWBoJFqLIOGnA8qwspm8Ud62pqtgeQKJ7/CjeJyILQn7yMjXhLvApcSeLtJy7b00rOzzJ+9VI4SXnGKg/YSFY/TmYe4gNGLWPb6aePCzgGsQDVZndX8fxPLpKNSMDniswUeVFbiLfFOSlDySJ9REfDGT8g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=2nCi4p4m7POLJTd2ebfAdGlzBYu3wFkr0iWssfe2aME=; b=eysTRaufgBZZ/WSwoxrO9DP7eau+odzCkAYoIxNnWXX08ot63q422FkrOX2ybiT5ab/2GGShkcF4AxQVDR5CcvxCBXbQm0xtqOnkIDkkuD3xLCI0nIQh6rFI+qVjZreKIAruYI2TwnfOGnWpzffZhmmMxlwDARDZD8qR6EYvwlQ= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from PAXPR04MB9186.eurprd04.prod.outlook.com (2603:10a6:102:232::18) by VE1PR04MB7343.eurprd04.prod.outlook.com (2603:10a6:800:1a2::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5123.31; Wed, 6 Apr 2022 15:24:36 +0000 Received: from PAXPR04MB9186.eurprd04.prod.outlook.com ([fe80::ade4:ad15:823b:7e2b]) by PAXPR04MB9186.eurprd04.prod.outlook.com ([fe80::ade4:ad15:823b:7e2b%7]) with mapi id 15.20.5123.031; Wed, 6 Apr 2022 15:24:36 +0000 From: Frank Li To: gustavo.pimentel@synopsys.com, hongxing.zhu@nxp.com, l.stach@pengutronix.de, linux-imx@nxp.com, linux-pci@vger.kernel.org, dmaengine@vger.kernel.org, fancer.lancer@gmail.com, lznuaa@gmail.com, helgaas@kernel.org Cc: vkoul@kernel.org, lorenzo.pieralisi@arm.com, robh@kernel.org, kw@linux.com, bhelgaas@google.com, manivannan.sadhasivam@linaro.org, Sergey.Semin@baikalelectronics.ru Subject: [PATCH v6 4/9] dmaengine: dw-edma: Rename wr(rd)_ch_cnt to ll_wr(rd)_cnt in struct dw_edma_chip Date: Wed, 6 Apr 2022 10:23:42 -0500 Message-Id: <20220406152347.85908-5-Frank.Li@nxp.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220406152347.85908-1-Frank.Li@nxp.com> References: <20220406152347.85908-1-Frank.Li@nxp.com> X-ClientProxiedBy: BYAPR11CA0046.namprd11.prod.outlook.com (2603:10b6:a03:80::23) To PAXPR04MB9186.eurprd04.prod.outlook.com (2603:10a6:102:232::18) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 7565c8cd-4463-414e-935f-08da17e18f05 X-MS-TrafficTypeDiagnostic: VE1PR04MB7343:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 1rvSyKPImxIkilCrETYpIBDFBBkNhrxw0o5HwBJIKsvL6olJAAOloyQUupIm093Z6CcMiOFh4BrsppVYobxiP1m/lgZgT84TAGITtf6M2AcFjyPVrhGljERn1m3hT0GBWB7iq3tB/VzqbT9WNY5iUbr/6Kg/6Tg+xmkA2djzxyAasRxXVOLBevNjftzhMylXUgYpEpWD3kCtRXNi4IOE11l3l1kB9lQyBJ5eLP4Pbt86x10aIymnXSgqaeBmGmq+k130p4fRZtYoZTpuzW875P3ZlOwuKq53gLyhPz/QhUQPol1RlP7FqLKq+egOTxLotfy2MQNGzRWDXNYdTGBaqE5BNSEld0feYvtFQp86vIyk6Tndw9JEWErFwUe+43pqKUlxErpNKCN6Wp6r0CystJFzsaQ9MDjSqsuoEuumAVGvmQiDZyrdhDJlkZdIfqYLeaQyhK3nWA6XmbrQVxlWYzNmbVdnDPKjQsNeX6ZIUIovVUBqWL6XHlCWEHSIxpXHYMYeaRBsWTZPM92oFi4Gxbo+EPBCBux8qcbixKCODr4jEGVR/UTS4EUftuwrOtuH8J0D+WtAB/SrcAEO/vLX/dIOqN5pILUaNVoXKuA3otsym6S90fEMeIKj3VPXM8u3iyxvaL6XjrgdTT/n95+7etwD8VOaMJvwSqTO/RbSVNYIydhVH1WOHlbkS/6c0Rz4O0USQzLNle+OnWOBaXhu5A== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR04MB9186.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(4636009)(366004)(508600001)(6512007)(7416002)(6666004)(36756003)(66476007)(66946007)(66556008)(8676002)(86362001)(83380400001)(4326008)(52116002)(8936002)(26005)(5660300002)(186003)(2906002)(316002)(38350700002)(2616005)(38100700002)(1076003)(6486002)(6506007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 0coxEEXZh1efmm+ODB21X5oaq2Wj720SwxxMOpqsUDvT0LsShOPBcGSEraDKVPDTx7Yd/fxOCVuVuDCr2WWsX2EnY68DA9xX6Y93hDn7yZBaXVjgVxOzmA6SgCCFjeTm7wK006RAoZFO/3vtj3yXwLq7A8kotPnGG7QtyAVsyNGjnBn/k1AAEuFeSv8mO+lGADL0Fg8FKzsW6b38z5GPdkT08bzDkGGSwAhui2yUCN/B6qFiXHiOpUSeI4/N9OG7ZVUJ8TIecUuGUnztmomqX1SwNl4KljNkv2LnS5+ACVLgIdDFdsDxOCAXbNICPDWOs9LOzCyATcJJ/9xGMVc9EhjpmT022R0BVj6kHeHHvMUkb8adZF9AQ739lfSgoafuZUmMEmsdmfu8HVKDzbTE3Kfr/elRL4+UhufTMTHpZzdAMbQJTCwpL49/GSKyBM3X2Gk56wHsrRe1jiUcK1lf8d51EGn4NemM0Cf2jiN3JrcV4s9TxLTnkaTDHSdgWxysAjMtbsICo08oLF2DG8E31ykyt8TrXogq0NBVXTa9XNfpON0Dw6krSRVSqMDtJJHvRhqcLW2rhwhH1VuUSaYHRiZ0Eh3hpQCquhFtnSznsY3N7Y5RuHzfqh0pWNmVVkzVFe3QRKugzvuVzwsXPg2QU/Po1vDJJ9pCgLzljwKKblXmjRIOyPT3bVMpgvurXYDKe+L8icHSF1m/BuMZ79Qwj5jSlxlisqRVRMbCfXlvDBR5cyXd9WSMeYbRfPrMoqBo9oHORbtrPoR2qR5eG1uk1AWzy25ssymGTpCIM0gKldGripF79pkBWYiQ7R1WhXz1I7aUsJa/cO3AWzqEwwHcf7hgZUrLKcazL6p1nmJXxIWfZY/sGTAdMdgMLI9dROXpYdd7129ysH1IYiPGBgb1FoYbx+ZtheAzRApY+dYqf+Ld50bMAT43MjfHveInBaNSpQniiijHIbGUCm7zykIRtgu4kjOSyIG3qSJl/mVXle7oKcUlHwTLLcSGZcuJ5n7HO0nrxjYfZ3qkLvVqWyxhOdncjxAiDgZJmr4vAFqmn+qF6pZEsBq4pBcyB5x/xD5gAjjgmJrXc3mz//9TwU1ivw9jLw6qJpzMqjQBnsspOqk2Z9g17RPA9fCGrFPkpPxcO9c9HTSivQ4LdKhcFPiVejxNXPU2VOJCgdjjQQ3047LfOr9zkiivFan34teYVmfp4fPocgKbPXCdwLKvUnJos1JtASF8/PyXgh2+FHXpUqme+KEgzsNmLfntMr1qqv+Pes44U8/GihTm3VdN3tSSm4LiRWB9ndKmSi4Zt11Fx1mEoZ598RiIxx+cMR3ptH73UPWY0YG4QHstcQMmya1azsRFF+PCNvFqtslTREK/CLpyAB5QERcUsGdqkHDcJitlGsdJPDXhFBS00qig6tb0Y4xPy1Tm3nfcblTjSplJGEMclILDyCoZONaAVG4QDO4NqZSQuln6bGgxFPM72UKVrxEtML9UXoP72p1TyE5OB61zDm4fGNszpkFo+9i/MBLaULZUQLJwuyeWliMRur8aTwhvMX9lfjCoticPshPOLaL7b5CDYPteqaeS/pVEtl7OT3n6crI4/YZq7CPnbMovKwbPg3Abp3PP4pnqu4mZ0qZkjPLE71/WC+D9nMGC8FfCRv2//7GFWkxdN0bmU9MCdiycaDkLOHnEaZ1kBBevm9BQisqWWminLGuAAjoOVZNjxtNlX23VWRrDll4YnpO6qA== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7565c8cd-4463-414e-935f-08da17e18f05 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9186.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Apr 2022 15:24:36.2496 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: W3YM6y4WaAZrC71WL9YvK9BADek0ERM4qImxXYXjLKsLs86+/+eQ4NmWXEb3IifV30zmT5ocFGawytUhyhQoSA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR04MB7343 Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org There are same name wr(rd)_ch_cnt in struct dw_edma. EDMA driver get write(read) channel number from register, then save these into dw_edma. Old wr(rd)_ch_cnt in dw_edma_chip actuall means how many link list memory are available in ll_region_wr(rd)[EDMA_MAX_WR_CH]. So rename it to ll_wr(rd)_cnt to indicate actual usage. Signed-off-by: Frank Li Reviewed-by: Serge Semin --- Change from v5 to v6 - s/rename/Rename/ at subject new patch at v4 drivers/dma/dw-edma/dw-edma-core.c | 4 ++-- drivers/dma/dw-edma/dw-edma-pcie.c | 12 ++++++------ include/linux/dma/edma.h | 8 ++++---- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/drivers/dma/dw-edma/dw-edma-core.c b/drivers/dma/dw-edma/dw-edma-core.c index 9e88797916268..cfd1cdaa4c1db 100644 --- a/drivers/dma/dw-edma/dw-edma-core.c +++ b/drivers/dma/dw-edma/dw-edma-core.c @@ -913,11 +913,11 @@ int dw_edma_probe(struct dw_edma_chip *chip) raw_spin_lock_init(&dw->lock); - dw->wr_ch_cnt = min_t(u16, chip->wr_ch_cnt, + dw->wr_ch_cnt = min_t(u16, chip->ll_wr_cnt, dw_edma_v0_core_ch_count(dw, EDMA_DIR_WRITE)); dw->wr_ch_cnt = min_t(u16, dw->wr_ch_cnt, EDMA_MAX_WR_CH); - dw->rd_ch_cnt = min_t(u16, chip->rd_ch_cnt, + dw->rd_ch_cnt = min_t(u16, chip->ll_rd_cnt, dw_edma_v0_core_ch_count(dw, EDMA_DIR_READ)); dw->rd_ch_cnt = min_t(u16, dw->rd_ch_cnt, EDMA_MAX_RD_CH); diff --git a/drivers/dma/dw-edma/dw-edma-pcie.c b/drivers/dma/dw-edma/dw-edma-pcie.c index ae42bad24dd5a..7732537f96086 100644 --- a/drivers/dma/dw-edma/dw-edma-pcie.c +++ b/drivers/dma/dw-edma/dw-edma-pcie.c @@ -230,14 +230,14 @@ static int dw_edma_pcie_probe(struct pci_dev *pdev, chip->nr_irqs = nr_irqs; chip->ops = &dw_edma_pcie_core_ops; - chip->wr_ch_cnt = vsec_data.wr_ch_cnt; - chip->rd_ch_cnt = vsec_data.rd_ch_cnt; + chip->ll_wr_cnt = vsec_data.wr_ch_cnt; + chip->ll_rd_cnt = vsec_data.rd_ch_cnt; chip->reg_base = pcim_iomap_table(pdev)[vsec_data.rg.bar]; if (!chip->reg_base) return -ENOMEM; - for (i = 0; i < chip->wr_ch_cnt; i++) { + for (i = 0; i < chip->ll_wr_cnt; i++) { struct dw_edma_region *ll_region = &chip->ll_region_wr[i]; struct dw_edma_region *dt_region = &chip->dt_region_wr[i]; struct dw_edma_block *ll_block = &vsec_data.ll_wr[i]; @@ -262,7 +262,7 @@ static int dw_edma_pcie_probe(struct pci_dev *pdev, dt_region->sz = dt_block->sz; } - for (i = 0; i < chip->rd_ch_cnt; i++) { + for (i = 0; i < chip->ll_rd_cnt; i++) { struct dw_edma_region *ll_region = &chip->ll_region_rd[i]; struct dw_edma_region *dt_region = &chip->dt_region_rd[i]; struct dw_edma_block *ll_block = &vsec_data.ll_rd[i]; @@ -302,7 +302,7 @@ static int dw_edma_pcie_probe(struct pci_dev *pdev, chip->reg_base); - for (i = 0; i < chip->wr_ch_cnt; i++) { + for (i = 0; i < chip->ll_wr_cnt; i++) { pci_dbg(pdev, "L. List:\tWRITE CH%.2u, BAR=%u, off=0x%.8lx, sz=0x%zx bytes, addr(v=%p, p=%pa)\n", i, vsec_data.ll_wr[i].bar, vsec_data.ll_wr[i].off, chip->ll_region_wr[i].sz, @@ -314,7 +314,7 @@ static int dw_edma_pcie_probe(struct pci_dev *pdev, chip->dt_region_wr[i].vaddr, &chip->dt_region_wr[i].paddr); } - for (i = 0; i < chip->rd_ch_cnt; i++) { + for (i = 0; i < chip->ll_rd_cnt; i++) { pci_dbg(pdev, "L. List:\tREAD CH%.2u, BAR=%u, off=0x%.8lx, sz=0x%zx bytes, addr(v=%p, p=%pa)\n", i, vsec_data.ll_rd[i].bar, vsec_data.ll_rd[i].off, chip->ll_region_rd[i].sz, diff --git a/include/linux/dma/edma.h b/include/linux/dma/edma.h index e9ce652b88233..c2039246fc08c 100644 --- a/include/linux/dma/edma.h +++ b/include/linux/dma/edma.h @@ -40,8 +40,8 @@ enum dw_edma_map_format { * @nr_irqs: total dma irq number * @ops DMA channel to IRQ number mapping * @reg_base DMA register base address - * @wr_ch_cnt DMA write channel number - * @rd_ch_cnt DMA read channel number + * @ll_wr_cnt DMA write link list number + * @ll_rd_cnt DMA read link list number * @rg_region DMA register region * @ll_region_wr DMA descriptor link list memory for write channel * @ll_region_rd DMA descriptor link list memory for read channel @@ -56,8 +56,8 @@ struct dw_edma_chip { void __iomem *reg_base; - u16 wr_ch_cnt; - u16 rd_ch_cnt; + u16 ll_wr_cnt; + u16 ll_rd_cnt; /* link list address */ struct dw_edma_region ll_region_wr[EDMA_MAX_WR_CH]; struct dw_edma_region ll_region_rd[EDMA_MAX_RD_CH]; From patchwork Wed Apr 6 15:23:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 12803849 X-Patchwork-Delegate: lorenzo.pieralisi@arm.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 37713C433EF for ; Wed, 6 Apr 2022 17:24:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238945AbiDFRZ6 (ORCPT ); Wed, 6 Apr 2022 13:25:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51364 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239005AbiDFRZp (ORCPT ); Wed, 6 Apr 2022 13:25:45 -0400 Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2062.outbound.protection.outlook.com [40.107.20.62]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6C4C34B93DB; Wed, 6 Apr 2022 08:24:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=C8b+1lhmlY+k3A4ptugkFgzFvRwBwhBVdsCC08NgbQH0ZG6am3UWkRog1Caal9/Qzsjcyx5N+XtmMvYp5NOksWLytu0F+Smt+hSHzWUApVlVT2TrEWnwIwaKK9uSYrGNw6oUDiODpN0r6VWpiUE6egk0Vvj85SQ2TeYW2u2TcT7R6o0ckXWHFfUqtDxzd8gAUZneDcMNUZ8MRfzdVaFE9mvbXAAqassif1YmQbj2+sFWcD/7Yu82QNclL+cusG4PM139Y/DGx8a8Q6bGW7zIE/gTKN3+TWbski4Z2+DTfiOFHO2hHVm5a3vw0DsWYdCd7tZgPvTjkQbryd5JPocHQg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=yX0USS3VtZeQCeosliAIqV7fezsnsaGbgypc9QxMwQ0=; b=afH7c05zaxRa2WFPOcflaaP36FWskVt3uuUXCc+RxHJvZKErKKXTPt/8z3Um7sZmUpQyha/vOajEey/yw4kEz18DHh11MwElMUEioHfKjU04moKI9Te4U5w1WIng5jb9xUNrE3a6twSmjRq54Czzv+ac2umE4LH87r8kcDVmxUJt0OjSmtyaBg3neYf0+v363H8J0IxICn2xa42ikWdMRNrpOLoEDwhvG5F5GjHukHHfSnkPwceEvWkc8R7TJkPy+AXu1zwJhgWcTmLxXTHu+RiOVeYuRkCa+uNSP5vxiktgI9B5L4B4+UVLCt1W8GD/snPLH97YJVc697KyzAH+hw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=yX0USS3VtZeQCeosliAIqV7fezsnsaGbgypc9QxMwQ0=; b=kS5KN0GaivcFYS/3yz/MUCZmRuF4ffivY6pXmO4tjufAmBW1eEyS5Zs8PZaiuZoBzRpzTvrA0CgZeRx6CiXa8lTrYrAU9KEwoDziHS1D8+iDQZwAzKCIUepH2xrodW18t6d+7m81P4/+uy/2J1arU7tgnGel9Momrx7xfhtZJIg= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from PAXPR04MB9186.eurprd04.prod.outlook.com (2603:10a6:102:232::18) by AM0PR04MB4033.eurprd04.prod.outlook.com (2603:10a6:208:5b::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5144.19; Wed, 6 Apr 2022 15:24:40 +0000 Received: from PAXPR04MB9186.eurprd04.prod.outlook.com ([fe80::ade4:ad15:823b:7e2b]) by PAXPR04MB9186.eurprd04.prod.outlook.com ([fe80::ade4:ad15:823b:7e2b%7]) with mapi id 15.20.5123.031; Wed, 6 Apr 2022 15:24:40 +0000 From: Frank Li To: gustavo.pimentel@synopsys.com, hongxing.zhu@nxp.com, l.stach@pengutronix.de, linux-imx@nxp.com, linux-pci@vger.kernel.org, dmaengine@vger.kernel.org, fancer.lancer@gmail.com, lznuaa@gmail.com, helgaas@kernel.org Cc: vkoul@kernel.org, lorenzo.pieralisi@arm.com, robh@kernel.org, kw@linux.com, bhelgaas@google.com, manivannan.sadhasivam@linaro.org, Sergey.Semin@baikalelectronics.ru Subject: [PATCH v6 5/9] dmaengine: dw-edma: Drop dma_slave_config.direction field usage Date: Wed, 6 Apr 2022 10:23:43 -0500 Message-Id: <20220406152347.85908-6-Frank.Li@nxp.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220406152347.85908-1-Frank.Li@nxp.com> References: <20220406152347.85908-1-Frank.Li@nxp.com> X-ClientProxiedBy: BYAPR11CA0046.namprd11.prod.outlook.com (2603:10b6:a03:80::23) To PAXPR04MB9186.eurprd04.prod.outlook.com (2603:10a6:102:232::18) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: d07abb2e-7943-482a-4968-08da17e19182 X-MS-TrafficTypeDiagnostic: AM0PR04MB4033:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: +IdjCWz58wQE7rF4uC+lYZPxgWb4cgGgFvVlt9cOyePdm8VXCi2dpxjN1Lbag2VuEiXxl4dhiwL5rblKW3vCxOiqZmnub9589sRZ7hQXYj1s9l28hWl0HtxEFS67PdVj55xqobNaTN3oi8DE3MyXfuF3loEzDZlXmKTs9EFDuN20JQbcR+di0a18GAE+VnCbr6Kxj37q7pE/+3nneMP1xzGgf+3sYwVqcWhAuirMVnUb8ZZvPBZQiyeLi7h120wM42tY8mmhvGv4T3fEt5qjcOob2SVuPAEbydDWBr3fa9Rp6R1jhwV+hksGLdhczYQ+GBNWY7qhxBEKcQesQVy9ooUyVrUAaEDaUKF/n5/PpZC5LyXHZ+e3OXlUNCAOrwOq17LG4kKcOHMrmBGuOgml8n10wkR6KvyYawbM8Ed5Ybf1bYrr508AGGgKlp9kHL78admzueXyi0SLy4v3OJlX2sWyjxK4LV1TTl3N1XDPAyxbVrEM1EgqExiTSMGfSqITPIaC6xs+hMrkcEUPI4lB+KTe48i6no2U4Pzo9Ni7qwcPqknncSu2JbcxSxKoyzt50a89j5VBxxjPFAz5D1BSDIlhxU3tQ9XlS2M6DcDPhYzgQFpUmO9xpEIBmmoPMZ3FN0g2eSjDb3TB15CenanDIAElx89axir3+obDawyQEC7FDWLJ380ckrg2tMnkWzaiQKKFNAWjL2oWph4QQ/o6Gw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR04MB9186.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(4636009)(366004)(7416002)(26005)(1076003)(2906002)(2616005)(36756003)(83380400001)(186003)(8936002)(8676002)(66476007)(6506007)(66556008)(86362001)(66946007)(4326008)(5660300002)(6512007)(316002)(508600001)(52116002)(38350700002)(6486002)(38100700002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: uVzGXJStMbvl2A37kMD0pdmrnnEe+7yJvJSHwTqkuFzLdq7ROjyokMu8/4MFn14S/BWap8DbfTBf9h3nMHoiPuoN7CGUDUYdrodv2Li9Mbbu50HIGEFbPz6G5J8UWAhzexkbeCARjLOEip5W04VZAe/hWBnR2WNYL6LRkXoQ2TsLZnG9IzyCOQ0384i7M0/Mw39kVfCogWskatSegkhPIAZhpnhWHhW+ppujSAcaYNCMH1ssVYEYffX5h9p+hqiY96fDX9xgqevwsr/FXRg1Zyq41Cnwga7XCu88ybxWFjTi4bqjqX9Z29xU5uiJNgtooN60meQlXp1YcBkE0v95WxmoRZutIjjnqN6SEeBD7mKAYyiz/1hrzv+leQKh7cHb1K+iUYhQprVZWaMtF0qqMzHVv9B4YdKUL0TbAFJ0czhbhJpg3Nk0wNwM3N+ChlHLkiLASTIsk2+cuvHB/7dYAdEe2KPiLbqe9EsvJPDUVxBibyWPRzsZZ4kt5YczyZoCFDHK/WIDmQ89HFEy/fk1tKIg1c1TtXLpcDVnFjtBFeC4//Zf3z1YR8VXyhsGzT61Pvr/hhZpwdAx1b+SLTZe1uquZJfBW2a7S4TWai3OYDaHNq4WydKjMx/PZvtTfQYBbSGtCE/LRVWS1Rh3c1m5EKdQ4Utm3+gAl/O95SG0WFQSdzOFKesSpRuxqaYNozaUqNy1ntz4ySqPWNlZl92ZjWZSnAS41DDF7n1lKlt90iQhrg6lkzUjXuOonZWEbX9VbVIR5Rr7oV4Za9IvDOL4qq/QuoO+3qiEoI8GeZe8h/hcsD6OUS9G8I8cXMMdRLx8Bb3Qjipzhi7MYrBi/M2qEr/FKIGydVugKKoECO9abBYXgCODEJPu7tE2zayYxlWVUVkbJwaqS1Uyo2lg8haPKL4K9cp6E/AcMW0N0Gz6NDBMK5LDgcmRF4LL89cTlk8qK5nsnZHsCxnczbG1W2icO37pY4CiA24A/tepSi7HXCvMU3CBF5Z8OLowGgVn+1M46lfRG4EhEj+4yad6+zQbwQaDCWd4kIJk3fcwZnJMowXQXFQpr4J8H8+ofTANuYa9IDMeZS0X5RHdnAtlwWqXi0Rs2Hyxweu10ZNlOv/cZhC6AjhZaFPYWS5rb44G7SikEwE/gUCjnCAVdp8Zznfa4eslb/pq1w49EZT5R7S0CK5UXluo/x/YhlqMf/8UpWVrm4UeGLc22mcdFm7yPb5pxDNWezyTOh+fr0OQFO5IkhkjAGVe1rlMoiIL8kbnq9CovVpQjEZ8jM4xZ5quCZk6x1VzWRRWuBKDL6idNKLHPE63zqHC0rSIzpvZQUPnWcUbUgkgH0rgO5zfwA+SO8WQuibKi5XSZWaErm8Qh/T4cRPHwuZP46HYJTwBDgdtqaT8Qybw6JuIyM9105wd+vVYpZ0e2nY2cGFWtPfRkA69oUxynYdwRh7cVV/31PcR9zJSHpX2zSMqvMjGr+FUGZq00CVWDY0vwlRhuyUpvY/jg1RDUrrwT1t+9M5KMlRHa74HrGpplcd9SsUm3h/iJ/0MmRYvOOfUknps/trsLeRmrzzUhq/osfEH2j5+NZAeHtI4HmaFPqtqCFGX6eUdAlulCAw/rxSNLknEZJNp5uSIiF8y5ID4lO+0cLZ1K3BWpg1srydv/f1hsCgSxCml6zaQC+ohScVyutdpOPH86AJvfTHmI5WamTIWo9/f/XW1iS0Fs+PWWhq8Ag/LFHAvUnX1aw== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: d07abb2e-7943-482a-4968-08da17e19182 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9186.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Apr 2022 15:24:40.4380 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: a557j6fqm6Nzx0ZQYoPH3jxNEwBAh4F04DJAOeNQ4C03ThnhkJci3kaWjzXoktuGno65ZnzUCRb1ZOm6LZZdQA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB4033 Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org From: Serge Semin The dma_slave_config.direction field usage in the DW eDMA driver has been introduced in the commit bd96f1b2f43a ("dmaengine: dw-edma: support local dma device transfer semantics"). Mainly the change introduced there was correct (indeed DEV_TO_MEM means using RD-channel and MEM_TO_DEV - WR-channel for the case of having eDMA accessed locally from CPU/Application side), but providing an additional MEM_TO_MEM/DEV_TO_DEV-based semantics was quite redundant if not to say potentially harmful (when it comes to removing the denoted field). First of all since the dma_slave_config.direction field has been marked as obsolete (see [1] and the structure dc [2]) and will be discarded in future, using it especially in a non-standard way is discouraged. Secondly in accordance with the commit denoted above the default dw_edma_device_transfer() semantics has been changed despite what it's message said. So claiming that the method was left backward compatible was wrong. Anyway let's fix the problems denoted above and simplify the dw_edma_device_transfer() method by dropping the parsing of the DMA-channel direction field. Instead of having that implicit dma_slave_config.direction field semantic we can use the recently added DW_EDMA_CHIP_LOCAL flag to distinguish between the local and remote DW eDMA setups thus preserving both cases support. In addition to that an ASCII-figure has been added to clarify the complication out. [1] Documentation/driver-api/dmaengine/provider.rst [2] include/linux/dmaengine.h: dma_slave_config.direction Co-developed-by: Manivannan Sadhasivam Signed-off-by: Manivannan Sadhasivam Signed-off-by: Serge Semin Signed-off-by: Frank Li --- drivers/dma/dw-edma/dw-edma-core.c | 49 +++++++++++++++++++++--------- 1 file changed, 34 insertions(+), 15 deletions(-) diff --git a/drivers/dma/dw-edma/dw-edma-core.c b/drivers/dma/dw-edma/dw-edma-core.c index cfd1cdaa4c1db..e321f36c1bfb6 100644 --- a/drivers/dma/dw-edma/dw-edma-core.c +++ b/drivers/dma/dw-edma/dw-edma-core.c @@ -340,21 +340,40 @@ dw_edma_device_transfer(struct dw_edma_transfer *xfer) if (!chan->configured) return NULL; - switch (chan->config.direction) { - case DMA_DEV_TO_MEM: /* local DMA */ - if (dir == DMA_DEV_TO_MEM && chan->dir == EDMA_DIR_READ) - break; - return NULL; - case DMA_MEM_TO_DEV: /* local DMA */ - if (dir == DMA_MEM_TO_DEV && chan->dir == EDMA_DIR_WRITE) - break; - return NULL; - default: /* remote DMA */ - if (dir == DMA_MEM_TO_DEV && chan->dir == EDMA_DIR_READ) - break; - if (dir == DMA_DEV_TO_MEM && chan->dir == EDMA_DIR_WRITE) - break; - return NULL; + /* + * Local Root Port/End-point Remote End-point + * +-----------------------+ PCIe bus +----------------------+ + * | | +-+ | | + * | DEV_TO_MEM Rx Ch <----+ +---+ Tx Ch DEV_TO_MEM | + * | | | | | | + * | MEM_TO_DEV Tx Ch +----+ +---> Rx Ch MEM_TO_DEV | + * | | +-+ | | + * +-----------------------+ +----------------------+ + * + * 1. Normal logic: + * If eDMA is embedded into the DW PCIe RP/EP and controlled from the + * CPU/Application side, the Rx channel (EDMA_DIR_READ) will be used + * for the device read operations (DEV_TO_MEM) and the Tx channel + * (EDMA_DIR_WRITE) - for the write operations (MEM_TO_DEV). + * + * 2. Inverted logic: + * If eDMA is embedded into a Remote PCIe EP and is controlled by the + * MWr/MRd TLPs sent from the CPU's PCIe host controller, the Tx + * channel (EDMA_DIR_WRITE) will be used for the device read operations + * (DEV_TO_MEM) and the Rx channel (EDMA_DIR_READ) - for the write + * operations (MEM_TO_DEV). + * + * It is the client driver responsibility to choose a proper channel + * for the DMA transfers. + */ + if (chan->dw->chip->flags & DW_EDMA_CHIP_LOCAL) { + if ((chan->dir == EDMA_DIR_READ && dir != DMA_DEV_TO_MEM) || + (chan->dir == EDMA_DIR_WRITE && dir != DMA_MEM_TO_DEV)) + return NULL; + } else { + if ((chan->dir == EDMA_DIR_WRITE && dir != DMA_DEV_TO_MEM) || + (chan->dir == EDMA_DIR_READ && dir != DMA_MEM_TO_DEV)) + return NULL; } if (xfer->type == EDMA_XFER_CYCLIC) { From patchwork Wed Apr 6 15:23:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 12803850 X-Patchwork-Delegate: lorenzo.pieralisi@arm.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E8652C43217 for ; Wed, 6 Apr 2022 17:24:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238823AbiDFR0K (ORCPT ); Wed, 6 Apr 2022 13:26:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51256 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238669AbiDFRZs (ORCPT ); Wed, 6 Apr 2022 13:25:48 -0400 Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2040.outbound.protection.outlook.com [40.107.20.40]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C9B3C3B7460; Wed, 6 Apr 2022 08:24:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KUyjOZTnzI+TMMew+KA/0EyFdnbP0dSp+Bo/3tNjKqRQppcQM1UfS1oGTKaBvrR+519ozdhvqUGVMe4GSBMp0saGUSHmsfBMt3BHUPvauOwwFJmB8SBbmA1Stg0aFvcKegA60OxhhbEtIl5j4tY8puIjF8dofw2xcCQn9vpV1rVUGsQiT798Sc0bvdkmj5X1O8BN5KYBKKXxjqZVCHv29CYge5/hyk7/x1QyLJk42bnjFF+t7w96oaRHnzt4yMHgom+H07oGGhBcg8d7N8OTgP1xG6RlS85mKwAgczblzN09ldiy0n72e+YSBS+hP5tR49gTmMcGuZF+aACUctfGGQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=xczDOrlcjB12yihCHeMDFTh2nwF//4VIGQk4i0BewOM=; b=bvuJXH8TzHMvK+a9E1BsIFHaaAVlQgh5actAWxi3aRN32mC3BQrIMpsRbDOqrxYUT0An4JJ6OOtYG1pFmDB5ZwKivZv8vZhNuLASC6fIH4zv8C5JwYMBY7IEo/usLQYYtdlDn0EHJ8oYgxQPy/a+V4kk846bySoXLk1YMUl0/tHK0K9evZ7easAsew5ZDFPuEIZ/nRcFrsLFatbseRD9eS6gmxKHcQh274yx3PdHJIuemAX08HoxLsASULifQpfNjYxmVqPmL9uxgWmSRWw2oOaeq5WzOu4O/Zg5hRup379LD35+cPG7mZyHZUVC/B8HGRpoy5iT3va8Lv2W3gqi7g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=xczDOrlcjB12yihCHeMDFTh2nwF//4VIGQk4i0BewOM=; b=Wg+TRHCQu796Le22AWmaJCi1PRuJb9lzlWgvS9y4u4/eGStvUMq5DHSDZXFlMpQuiYWp6a7AVM4oauFjFBZUvFUweFMFpOc/KFKiyvnKa6xiZvp5dgFXbVAbrMQulO93A00UHlYmGFuKxswaCP1dp5FAGe9u1Yr9ZXh9KBooF90= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from PAXPR04MB9186.eurprd04.prod.outlook.com (2603:10a6:102:232::18) by VE1PR04MB7343.eurprd04.prod.outlook.com (2603:10a6:800:1a2::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5123.31; Wed, 6 Apr 2022 15:24:44 +0000 Received: from PAXPR04MB9186.eurprd04.prod.outlook.com ([fe80::ade4:ad15:823b:7e2b]) by PAXPR04MB9186.eurprd04.prod.outlook.com ([fe80::ade4:ad15:823b:7e2b%7]) with mapi id 15.20.5123.031; Wed, 6 Apr 2022 15:24:44 +0000 From: Frank Li To: gustavo.pimentel@synopsys.com, hongxing.zhu@nxp.com, l.stach@pengutronix.de, linux-imx@nxp.com, linux-pci@vger.kernel.org, dmaengine@vger.kernel.org, fancer.lancer@gmail.com, lznuaa@gmail.com, helgaas@kernel.org Cc: vkoul@kernel.org, lorenzo.pieralisi@arm.com, robh@kernel.org, kw@linux.com, bhelgaas@google.com, manivannan.sadhasivam@linaro.org, Sergey.Semin@baikalelectronics.ru Subject: [PATCH v6 6/9] dmaengine: dw-edma: Fix eDMA Rd/Wr-channels and DMA-direction semantics Date: Wed, 6 Apr 2022 10:23:44 -0500 Message-Id: <20220406152347.85908-7-Frank.Li@nxp.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220406152347.85908-1-Frank.Li@nxp.com> References: <20220406152347.85908-1-Frank.Li@nxp.com> X-ClientProxiedBy: BYAPR11CA0046.namprd11.prod.outlook.com (2603:10b6:a03:80::23) To PAXPR04MB9186.eurprd04.prod.outlook.com (2603:10a6:102:232::18) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 454f20a6-b48c-4b18-0ffc-08da17e193ec X-MS-TrafficTypeDiagnostic: VE1PR04MB7343:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: OjVQT8i2Eg2roV2VeGCkEmRjLPfdAaf9NcOGNywHmjfu1TD/T4+j3eBlzUet8edPZRhntmaWT//wt5cap5srTEEsOxBYBA2YC3/RBpNR2z4qQBrbqq7ruWKiu5QRz7ya5gRa0YY0wPbrVYnIZpdpYCvBvdi23nCB9kO1ZAfQ3rSgArJH0g1wpjHcBiKpsC/pMkN/+xrO8uUxJ5P11vsdQEMG1k/cGlFn2XM2MTCLJ2gVfyjUpFWGV9YiKCZhvOXCbo662bGrLhQp1ER9t0wWJuN73YGkTuFZos21uAJj1mAte2zuX1fEugoACKEu2jN/9mlRGlUDjk8rxhB6jyZ9e+lRwuVGapKcGqOCA4ZmxeSER4KDvaCsFhJocTWc7Ku7MbbDvjrkBFVCjuUsSxaAtdtkk1qffn4/JPUe8CHyrRVWmxc16DYmXTUZ95sjsEL7zfoR4hYQzxvI9kzAu6+md6PeA1sH+bOQlxeBdQQ89Bw9CbNm2teN1o/DeN3kCqhBsSDx9+9FuWcNYh27PaoK0iJSxgqy/wRmpoh0ehZlhhZuxPlBtfCFB5R2GX7aCXnsmZWgNrLRq01XgHfvfMKcvcsyK+knb+6LaZ8Fa6v5YzZHsd3ELFk425V9YtrEZONoJhP14WmmassJViSgwIg1+URRreRzmPhHbZ+23K0vzE4Ou3V/tnAWnbAyCvZWq5r6gzJNhxo5XJ2oWpKCXbzF3A== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR04MB9186.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(4636009)(366004)(508600001)(6512007)(7416002)(36756003)(66476007)(66946007)(66556008)(8676002)(86362001)(83380400001)(4326008)(52116002)(8936002)(26005)(5660300002)(186003)(2906002)(316002)(38350700002)(2616005)(38100700002)(1076003)(6486002)(6506007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: OFXGJluCejqGoXJpIx/tKlykbT4YQABRcqDQakaixtV9SWQ/yzISO7n7M9LYCJbI7KZLjBeP2wUsQMcNka4GmL+ObtA4HJimifTDWbe8e5Ae8DaYwewm/ifi09N2fgVXAPw0ofucucD8pMdKyC8n3ud5rZaTFsXlsC9vwPIhosPi5h3f7Bs6hF87D6Bhn9waW+5In7HCsHGlkKhDpZdIn/JW9meqKO1ZVJXnIbZWwMtqwqSkZ25EruZUhw6ZTHaMPXwoFCSwVD1IOSpjqcnEDknEbV2kw3W/9C2HPHvizN9hlxQGluRBKlLEpZLpjVoRAWCcR8ItwkNjcEEuih3CvEgTlRtGv459f5rGMnNpn7FQffKHX5L56F60zi4tk08tXSdwueWZKf023CHpqYanMjYzivrFF88LYi6pHLFNfspdLCSFAwt4h+dKHsXeGr5HIg4bGu2T06thdLwPnKnjnbyaqkCMVur5Vw+n/mFAm9ERxh6WHjPcSPO+B+/OtacGazbVOGShgW+9389oHbZdqdBVH2cKl6P/lANCRTwtRCY7GIC4V/Nqubk0L5zf6vMvVAnY/AaY56JgJMC6RtlgcJXTxTj58ofjJq7oVguSH3sy3cNj7NUpYIwvOCGIilClkdaU9XVfzU5LpM1JWysU+/SyRgRPm4O1N8xN2GwnPVl8QiHQMmQzyR7VmSyXZ4kpWtE8Uh7Upn7KdnMsFd2wkl4drQZncby9beCflqid9ovHPSgI3Zn5nP4uqCY4Lhyfsx8GLjV71cBLDeBSV1FgMwj0AsPxB1dvJPXruRziEUj2xpB0gYLTGMGRXtX6gbn5oyb3vj89NpVMexxd9oAGN39om7KqZvhb/JzAYT2xDORb49cIifthgZ2AMWtiVxjfdOVsqHqmYw5Dq7+4MTnV4o7OnnQTwqBHzsocQtyWddDpMW+Pjz2N5CQfvtcehLCo5Y0TXO0nevMEZk5wdPrlhQo2CBVb4gerrjYMbBXQaq6Gc4c8gT0S5tRnHX8hMgxRyOWWmzdOYx/SOjPcZkM/TmG+wFkjcN7uwZwpN7lBu2INOiqCo3mEKo80WgIJazEJ1hhX1nzmnPn39tHCKBN5Aoy0l+SKZMC0IxHXrBSWjhnQfK/v8yhxVzgffVjy4Jnr1nnjszH/0OtOThvyS9KIf7JQnfJxxNVt8bl/GCVyTUWauKYlnruSgcUY1zxI3Eh+D9Z3V8pf1iBZ/ADCKzLWpTJetuF7Q+GHvVeHMGiv9CkFqG4OLBC/qtcvwHOHvdNDYeUmqKPRQ2HFrgFa+f7EOlEc1DOuHhy6lxFYIlIrTuiv7oTz3ah8jWPLwgFI2ZW8QhDx3CZUcy/l8+68+gkfvDh1aJqIHUP4czBRLF7mUEwlzBwcV/1n4B4ERjyTxofWTdVtOdb/wayvSCeGvKC1w+JAwxI6aiMY8FXEJSM4vJHen2szTyoq1K9tWSQ6rBzevZXUBs2h1JRZ/qoNiSrO7Uzj9DOzHVZczmGDM1ve2H3sUcDPI+pTrKuR+d5/3gEkYpusPzI8bBGg5+mRydg/f0wJIUUOo+RVu3qygPbJGo7AL3YFVYZ+jg7nJmn4VyoipKtDIDvIjhEBuXsqRzHoQGutAaqv4uDI3zhwTBGwpG77imB3E+nd4DKytUBvWf4sJ6IVlhzLhZwlM0vQoV/yPX/LAG2OHt3d+fyVXeqOOonSqni1q3UjKqPRSoKc3pm16CK16MONDZFxuDTAs0sPRA== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 454f20a6-b48c-4b18-0ffc-08da17e193ec X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9186.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Apr 2022 15:24:44.4866 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: t9cqlC/Zan4ZXn9fy/pipq0jR7lCd7A68d+5jUcLTY2eUAWvBspl9KQpHtIQsGj267k6KyZKCzIe4rnAp56toA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR04MB7343 Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org From: Serge Semin In accordance with [1, 2] the DW eDMA controller has been created to be part of the DW PCIe Root Port and DW PCIe End-point controllers and to offload the transferring of large blocks of data between application and remote PCIe domains leaving the system CPU free for other tasks. In the first case (eDMA being part of DW PCIe Root Port) the eDMA controller is always accessible via the CPU DBI interface and never over the PCIe wire. The later case is more complex. Depending on the DW PCIe End-Point IP-core synthesize parameters it's possible to have the eDMA registers accessible not only from the application CPU side, but also via mapping the eDMA CSRs over a dedicated end-point BAR. So based on the specifics denoted above the eDMA driver is supposed to support two types of the DMA controller setups: 1) eDMA embedded into the DW PCIe Root Port/End-point and accessible over the local CPU from the application side. 2) eDMA embedded into the DW PCIe End-point and accessible via the PCIe wire with MWr/MRd TLPs generated by the CPU PCIe host controller. Since the CPU memory resides different sides in these cases the semantics of the MEM_TO_DEV and DEV_TO_MEM operations is flipped with respect to the Tx and Rx DMA channels. So MEM_TO_DEV/DEV_TO_MEM corresponds to the Tx/Rx channels in setup 1) and to the Rx/Tx channels in case of setup 2). The DW eDMA driver has supported the case 2) since the initial commit e63d79d1ffcd ("dmaengine: Add Synopsys eDMA IP core driver") in the framework of the drivers/dma/dw-edma/dw-edma-pcie.c driver. The case 1) support was added a bit later in commit bd96f1b2f43a ("dmaengine: dw-edma: support local dma device transfer semantics"). Afterwards the driver was supposed to cover the both possible eDMA setups, but the later commit turned to be not fully correct. The problem was that the commit together with the new functionality support also changed the channel direction semantics in a way so the eDMA Read-channel (corresponding to the DMA_DEV_TO_MEM direction for the case 1.) now uses the sgl/cyclic base addresses as the Source addresses of the DMA-transfers and dma_slave_config.dst_addr as the Destination address of the DMA-transfers. Similarly the eDMA Write-channel (corresponding to the DMA_MEM_TO_DEV direction for case 1.) now utilizes dma_slave_config.src_addr as a source address of the DMA-transfers and sgl/cyclic base address as the Destination address of the DMA-transfers. This contradicts to the logic of the DMA-interface, which implies that DEV side is supposed to belong to the PCIe device memory and MEM - to the CPU/Application memory. Indeed it seems irrational to have the SG-list defined in the PCIe bus space, while expecting a contiguous buffer allocated in the CPU memory. Moreover the passed SG-list and cyclic DMA buffers are supposed to be mapped in a way so to be seen by the DW eDMA Application (CPU) interface. So in order to have the correct DW eDMA interface we need to invert the eDMA Rd/Wr-channels and DMA-slave directions semantics by selecting the src/dst addresses based on the DMA transfer direction instead of using the channel direction capability. [1] DesignWare Cores PCI Express Controller Databook - DWC PCIe Root Port, v.5.40a, March 2019, p.1092 [2] DesignWare Cores PCI Express Controller Databook - DWC PCIe Endpoint, v.5.40a, March 2019, p.1189 Fixes: bd96f1b2f43a ("dmaengine: dw-edma: support local dma device transfer semantics") Co-developed-by: Manivannan Sadhasivam Signed-off-by: Manivannan Sadhasivam Signed-off-by: Serge Semin Signed-off-by: Frank Li --- drivers/dma/dw-edma/dw-edma-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/dma/dw-edma/dw-edma-core.c b/drivers/dma/dw-edma/dw-edma-core.c index e321f36c1bfb6..90a353bb5fb49 100644 --- a/drivers/dma/dw-edma/dw-edma-core.c +++ b/drivers/dma/dw-edma/dw-edma-core.c @@ -443,7 +443,7 @@ dw_edma_device_transfer(struct dw_edma_transfer *xfer) chunk->ll_region.sz += burst->sz; desc->alloc_sz += burst->sz; - if (chan->dir == EDMA_DIR_WRITE) { + if (dir == DMA_DEV_TO_MEM) { burst->sar = src_addr; if (xfer->type == EDMA_XFER_CYCLIC) { burst->dar = xfer->xfer.cyclic.paddr; From patchwork Wed Apr 6 15:23:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 12803851 X-Patchwork-Delegate: lorenzo.pieralisi@arm.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A3E84C433FE for ; Wed, 6 Apr 2022 17:24:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238757AbiDFR0V (ORCPT ); Wed, 6 Apr 2022 13:26:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46548 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238849AbiDFRZz (ORCPT ); Wed, 6 Apr 2022 13:25:55 -0400 Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2050.outbound.protection.outlook.com [40.107.20.50]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BF4273E1482; Wed, 6 Apr 2022 08:24:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=S6mhALYqv/vWgQDDaSBy7Dw+4yHRwufdvO2VYMtT9NatY6kpH50gJ7dfKXQ5GNRGaALjLXbaC80opfVntf19qjhO4d0LGlSynv3mUGWyRSPYKa/KeZBalAukPjmjOAqd9SNU9ITm6KrBRi04xOXPMWFSNknB+vGjYA0/2qKW/Z3Ap8cZ26ujVLY/DpPAza+2vKExZ3mbssGa+zCKgq24JLaTbSM5SxaibNnJsOfVMhonysjAGKVJOgCH9K5MQ6MVhvIq6otrVMxr0sjWqdHrcxlcq8/RhvtSKn7uMxrYymsBWpePhvgQRAmuT63FvOiBCE6tNhDrS8MhZrjVwGvPuQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=ZyjQwQHvzM2CQhoUU9+2mxa7LiZrdjp6OmFw70z6ejk=; b=XO9P8yVfKV7uNdHbPiFJjbaauwxhjmKfVm3CrhStVw2UeSJ6lR9ybEt2bZhrUJaQnHISexTt5OsBGAyzEc1X1nGmmWvvrJ+Pbbc4jIY3ewPCEftNF8G35SmCmNGWhKpi4fyXXNeka+rwlR+vHdvtADFJwFpdICUsLlRJf7snF4DC2juB8Nj8IoQBksWRRNCqGv1LeQOks4jOAgXPGCDgNOoeMzyF2bC1VBsDq01NGR7IIQVq2FqUVAPPrHknpnLouXL3lBR1hwzDQM5vnvXsyOSjRDQPqF3YgdgY6TKAqCz9TNescgrOJaSDuDRppSCM6ISY8Xw3bf55OcQnSLk5XQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ZyjQwQHvzM2CQhoUU9+2mxa7LiZrdjp6OmFw70z6ejk=; b=FvC3qhNJhdg+zVPigAnmNlMKeAenDGZAs6gvje4PwBAIGMv5od/x7t9ZHJk+9tl0NsAAFSAVR1b1j8G1BlbCakh1LqmJe5O/rMnASbQ5r4lMYZTNn5gy2RrIby5Tz4S5lldkv7RrOcYBVGvDmiOBXHmfjwzerq+nyfXp4Sp2+88= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from PAXPR04MB9186.eurprd04.prod.outlook.com (2603:10a6:102:232::18) by AM0PR04MB4033.eurprd04.prod.outlook.com (2603:10a6:208:5b::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5144.19; Wed, 6 Apr 2022 15:24:48 +0000 Received: from PAXPR04MB9186.eurprd04.prod.outlook.com ([fe80::ade4:ad15:823b:7e2b]) by PAXPR04MB9186.eurprd04.prod.outlook.com ([fe80::ade4:ad15:823b:7e2b%7]) with mapi id 15.20.5123.031; Wed, 6 Apr 2022 15:24:48 +0000 From: Frank Li To: gustavo.pimentel@synopsys.com, hongxing.zhu@nxp.com, l.stach@pengutronix.de, linux-imx@nxp.com, linux-pci@vger.kernel.org, dmaengine@vger.kernel.org, fancer.lancer@gmail.com, lznuaa@gmail.com, helgaas@kernel.org Cc: vkoul@kernel.org, lorenzo.pieralisi@arm.com, robh@kernel.org, kw@linux.com, bhelgaas@google.com, manivannan.sadhasivam@linaro.org, Sergey.Semin@baikalelectronics.ru Subject: [PATCH v6 7/9] dmaengine: dw-edma: Add support for chip specific flags Date: Wed, 6 Apr 2022 10:23:45 -0500 Message-Id: <20220406152347.85908-8-Frank.Li@nxp.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220406152347.85908-1-Frank.Li@nxp.com> References: <20220406152347.85908-1-Frank.Li@nxp.com> X-ClientProxiedBy: BYAPR11CA0046.namprd11.prod.outlook.com (2603:10b6:a03:80::23) To PAXPR04MB9186.eurprd04.prod.outlook.com (2603:10a6:102:232::18) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: d0a4429c-d5cf-4778-3889-08da17e19658 X-MS-TrafficTypeDiagnostic: AM0PR04MB4033:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 5SxbjHIwURMoNrBmQKzPFT6v9Ge+j07CzUmi2z8KRUT4gQngPRTiLQpCPrwYjqbjr9oIyrQfqX8J9pTGgkNQ8xRktyQvV5uWiJXnLHfkWLjaDx/vKaOYx2lBVaJko00lsOnsjaBUfV/UYeGKdZU6GxZ3CrxyvyHHUEbCxA2LiRtRh/iubqfeoFu27Ox/lYw2jWUyvxs1gYWeKr62eHETyoCwRZoAKqtC8S95D73tcADpV7hucHkVW7j9+QGqiIKcqRK9m0QN3evJqFRdldupM/Hr4ChqbE1/BhRHg5nmndbyrQiUnnsoCa37AWWh+1e3Rq0SO+VHFWkJKnFsViXGOzUjSjirv+p0xchZ9mlrhnwzDxq3dCSUm8Bl84qbZqslBNhaeQ+1gbJiGatu8XQagofelsr8sUzJNC1m33hef+XFcPB0vAoRJjG/h5gKbsefkySGOviHKWzs2m5U0+ZNeHSEZmG/7Rgibil8x80/4MM5+UXpT1NnVO5CY4fE33DrmUadOl7/ycAqucinsalpEsH30Wjs2TGixTmFlgaHejidNo2pZ1/VvRBB4ULoOA2EYAw2GLSYhwLLbxquTpd9TSxM17JQawJjn1y5ghVsoVAIUu0jZvlv3iou3GYT0i/+CyQe//t4a5BV6MfWvYC8kNFYxLBTLmILfjeklB8TV1fLJ4JptceA+CZf6t13XiLIzZCKOxqGuMlaWTyQUnjAnw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR04MB9186.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(4636009)(366004)(7416002)(26005)(1076003)(2906002)(2616005)(36756003)(83380400001)(186003)(8936002)(8676002)(6666004)(66476007)(6506007)(66556008)(86362001)(66946007)(4326008)(5660300002)(6512007)(316002)(508600001)(52116002)(38350700002)(6486002)(38100700002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: I34iP3/x4GcPhATKqocpvAlKgNPEXVSqSPDtDmM73btSgSLAmcEfA3LhCBBFygzK4eU6QK1gUgsy7VA+XP4nUCAqc7KkcpL7LP0fbhpeOp/3XUvdSjuE4c0OTslEPSGdCs11qEnrp3jCr8ONzwIGlaHLZJCeDMpauWSFc92aCEnC8OCS/jyNdzgfW0+TJ+TMrFg72m41aiVyh8/yqa0cCAMGdiHPwEhh6GcbTfgFdWobd/ZisR9dj0Gvpyg+ei3HFNdMC4qc1R2YZMhuxrSir/xHj48PVqs737eWw87NPPoMrHiCJ144jlKIcx3ba0OBKhoUzvSFvbMXed1IBKhkmL3/CQz8IQNz7k2Sn8IEyEfld+KuVhNNhs8l1CqxLCZByC3mByDRBVfslq1Z/duRc3GowZrCxzhY+U9fdCsWDV/SdFliexO/KT0tzNvZ1Wjy6P4V92KU7CvD9wZEzhGJ4JguZkH6T0ynpzm3+1Yg2Xnr6RgklohFxt0z2kl0c22JXNTr25r83pfJ1q/AP79eP02zyLNbREt7Ga7wEoi2v5f5vk49iWavEloX5CGU6NoUKkVsK0/vVs9YdXUSxGFpbdyZ1PYbijn6e4bkeHgzz0mmTTt+OJWysvzsWwtskM87AjD2v4hd7E2wXHMl8OZNoOlZpwUAt0EUbu8AlS8/qmKBvt7OEVdfQ36tXtlju8ZnYXHzUOIRsgvYSJ3ooCvWp2kVYJXJAQjeNKKC9guJnKDZEdB5Kaf04/hR4s8psfWS5bPuMikNXLfhVOVNJIMq05PdtgGyDalP7mxgmcjIno2g2D53eSVJJEn6Ujzudbon6Jpievl5ehFMrhN5vmAzE2e/kSEvDI5w1xcKDj5My5nhd4LBsa6tekKp8SJbEQAPiSf2dwTO7yiPLK496n6PK1xbW7fgOAYUME2TNvrYyBU02wE50HLNv+MIbrGUGEMVDzoy/07HgjzD4P12hp2sUIeCkN9iKQo9KA/gCpTiXa89C3bz1s+CUGnr5o0PyzzVCy0A024ZGlBnbaoDUyV8emQdol3ppWQb94S8S5hWqPf9P7FExgxKsrhEKfg0FHe1LVGdFgNOe1qljy/S+2F02aLZZ8x7q6k9a5jBw91cK9HcJj/tzOMOIPQ+dKIolTLMHOh45D4jHzwPxbkDXTRqibapfy7OFcmGeErbZjb7LyEjncr9Wz8QRwgQdR6klOJwO5bZ48YmMk96pugldZVam8DX/KxY5xdN7w8Avv1rleSKSZp4q8iarDd1LO4hQjhlS4zu8qcvOhnGUX2KubprwjIzcHDMxDQj3pAmU/w+vKIX9WoyYQqhj174knh2m/B0kDUOB2pLswUecvKwLsaBDvAauYEqvFlVgDxPbljSgOBAs/Ycg5MOzgdGJ7zrtd2fcCbgCv3MD3neT+LvriAz0z5QucIVmlrVONr+QQXrFdSOTvFygX+J7mNbyTJ2y0kyYq7urC2os0h2RbSj4CuJNIsf3dufZ6YliAQto4L7/bnZA+y1X7Lxg6OXbNuaLTzRCGk2S9u+w5zzRUMo9igvsV3O2+iVW4lECyJ88UxbyxjaIacqumK1MCmKDktyrhRMwdVmAMm2l8Y8Gxfr2kjbFmKNqIeCPtxQy4pk8DVq+0aoRxLKzGpf2/2I2RTN+D4VBqE9/ZvvWKxeIv0H6tWSl8yVncQez9cxOP0KM8OhJUAkXb4k27ZM3ZkoEjp81ekZsZ81ToRV5X7NmNb4C+Q2mw== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: d0a4429c-d5cf-4778-3889-08da17e19658 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9186.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Apr 2022 15:24:48.5353 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: vYnHiWdiUtOKSKSPXlthCU6CUpfGo6uc9uuFB8/Jlfa1RwIswu2eYdlr6Cq2TflD/w8byTzAzSd1U3c7NhAaMg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB4033 Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Add a "flags" field to the "struct dw_edma_chip" so that the controller drivers can pass flags that are relevant to the platform. DW_EDMA_CHIP_LOCAL - Used by the controller drivers accessing eDMA locally. Local eDMA access doesn't require generating MSIs to the remote. Signed-off-by: Frank Li --- Change from v5 to v6 - use enum instead of define Change from v4 to v5 - split two two patch - rework commit message Change from v3 to v4 none Change from v2 to v3 - rework commit message - Change to DW_EDMA_CHIP_32BIT_DBI - using DW_EDMA_CHIP_LOCAL control msi - Apply Bjorn's comments, if (!j) { control |= DW_EDMA_V0_LIE; if (!(chan->chip->flags & DW_EDMA_CHIP_LOCAL)) control |= DW_EDMA_V0_RIE; } if ((chan->chip->flags & DW_EDMA_CHIP_REG32BIT) || !IS_ENABLED(CONFIG_64BIT)) { SET_CH_32(...); SET_CH_32(...); } else { SET_CH_64(...); } Change from v1 to v2 - none drivers/dma/dw-edma/dw-edma-v0-core.c | 9 ++++++--- include/linux/dma/edma.h | 9 +++++++++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/drivers/dma/dw-edma/dw-edma-v0-core.c b/drivers/dma/dw-edma/dw-edma-v0-core.c index 8ddc537d11fd6..30f8bfe6e5712 100644 --- a/drivers/dma/dw-edma/dw-edma-v0-core.c +++ b/drivers/dma/dw-edma/dw-edma-v0-core.c @@ -301,6 +301,7 @@ u32 dw_edma_v0_core_status_abort_int(struct dw_edma *dw, enum dw_edma_dir dir) static void dw_edma_v0_core_write_chunk(struct dw_edma_chunk *chunk) { struct dw_edma_burst *child; + struct dw_edma_chan *chan = chunk->chan; struct dw_edma_v0_lli __iomem *lli; struct dw_edma_v0_llp __iomem *llp; u32 control = 0, i = 0; @@ -314,9 +315,11 @@ static void dw_edma_v0_core_write_chunk(struct dw_edma_chunk *chunk) j = chunk->bursts_alloc; list_for_each_entry(child, &chunk->burst->list, list) { j--; - if (!j) - control |= (DW_EDMA_V0_LIE | DW_EDMA_V0_RIE); - + if (!j) { + control |= DW_EDMA_V0_LIE; + if (!(chan->dw->chip->flags & DW_EDMA_CHIP_LOCAL)) + control |= DW_EDMA_V0_RIE; + } /* Channel control */ SET_LL_32(&lli[i].control, control); /* Transfer size */ diff --git a/include/linux/dma/edma.h b/include/linux/dma/edma.h index c2039246fc08c..bec444e2939b2 100644 --- a/include/linux/dma/edma.h +++ b/include/linux/dma/edma.h @@ -33,6 +33,14 @@ enum dw_edma_map_format { EDMA_MF_HDMA_COMPAT = 0x5 }; +/** + * enum dw_edma_chip_flags - Flags specific to an eDMA chip + * @DW_EDMA_CHIP_LOCAL: eDMA is used locally by an endpoint + */ +enum dw_edma_chip_flags { + DW_EDMA_CHIP_LOCAL = BIT(0), +}; + /** * struct dw_edma_chip - representation of DesignWare eDMA controller hardware * @dev: struct device of the eDMA controller @@ -53,6 +61,7 @@ struct dw_edma_chip { int id; int nr_irqs; const struct dw_edma_core_ops *ops; + enum dw_edma_chip_flags flags; void __iomem *reg_base; From patchwork Wed Apr 6 15:23:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 12803852 X-Patchwork-Delegate: lorenzo.pieralisi@arm.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 226F6C4332F for ; Wed, 6 Apr 2022 17:24:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238824AbiDFR0Y (ORCPT ); Wed, 6 Apr 2022 13:26:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47584 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238867AbiDFRZ5 (ORCPT ); Wed, 6 Apr 2022 13:25:57 -0400 Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2049.outbound.protection.outlook.com [40.107.20.49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3672D48858E; Wed, 6 Apr 2022 08:24:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YN+lbMBNyviym4wTgZY+bV3SYZ9ViQQBIt5CAEFgkRKvrXmK1qrbs9FbtxxPbwHXhJvgVJQrS6FbNc6kNP6OVCxfJgdXe+YRYIga+FjepfiYJLOi0H5xTNEc4f4AtHJm2HRV7yQbqR1dh0D5zw+X2k7dyjpRYOD7HJq2gaQgVMDXa+UPCya/6Fy538ugOboExJUUo6U2HKk4BXxNp9MOScyUa3O7XdOqf9inJXV3mkgzUyyr3pSu20YnHhphpd0etlZvG2Gsr40VBtZlyNnQmjhLeed25Rlmrj29EHobHipiF9Sqd6Z26vZM01OUwYJzUHmTkNfWPbnrj5mwuIXt7A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=2yt8poeLQlw8HSzLf+nrRh8ixTw+HA6ON3PCHO477EE=; b=EYo4UxnBBY9U2dgIFHWfHIq7C5KY7+IBaXFeySiSUC4WgxkUFjQytiRPz5jy5O5ZpvCtHoA0vpwHJUTfbSqq1lZGJh12l907b5nEGUUg3QBOwwj8xHKyAtY+DawvcoBtRsqxceAe1w9cca+PHkxQvMGE3hQKfdFKfc4Xy69Hcu9teAx+bP7avpB7VvyOodV4L1iO8r2vzIoPqFAAUOH3jg3NDq1SLr+vacre/gBPCVsJDrG7qACRyB3PTA2GkS6ZVf4VxgmYA0I9SPdYmG/1myGI2yQQWOzTapz1TgBblu7Iwxuyt0O8+lJIJY779uKuGcKb6P5GA/zeZ4MH7XH+Dg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=2yt8poeLQlw8HSzLf+nrRh8ixTw+HA6ON3PCHO477EE=; b=kLBGzhgCfKPO8U1zhmX1cS2l4To+GWqXoVYXfoHWGn/R/ik9AWV4CJ1F0F2shhcsNLfCFdm3JtO+QZY4PJgavuR7HcrV7uzH/sV34WmC6cWd05NSIiCH2XYKqcOfVgkwndo2204f8pke2DjQUufj9qcCiUDYy7b3lrV4FC0QQbg= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from PAXPR04MB9186.eurprd04.prod.outlook.com (2603:10a6:102:232::18) by AM0PR04MB4033.eurprd04.prod.outlook.com (2603:10a6:208:5b::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5144.19; Wed, 6 Apr 2022 15:24:52 +0000 Received: from PAXPR04MB9186.eurprd04.prod.outlook.com ([fe80::ade4:ad15:823b:7e2b]) by PAXPR04MB9186.eurprd04.prod.outlook.com ([fe80::ade4:ad15:823b:7e2b%7]) with mapi id 15.20.5123.031; Wed, 6 Apr 2022 15:24:52 +0000 From: Frank Li To: gustavo.pimentel@synopsys.com, hongxing.zhu@nxp.com, l.stach@pengutronix.de, linux-imx@nxp.com, linux-pci@vger.kernel.org, dmaengine@vger.kernel.org, fancer.lancer@gmail.com, lznuaa@gmail.com, helgaas@kernel.org Cc: vkoul@kernel.org, lorenzo.pieralisi@arm.com, robh@kernel.org, kw@linux.com, bhelgaas@google.com, manivannan.sadhasivam@linaro.org, Sergey.Semin@baikalelectronics.ru Subject: [PATCH v6 8/9] dmaengine: dw-edma: Add DW_EDMA_CHIP_32BIT_DBI for chip specific flags Date: Wed, 6 Apr 2022 10:23:46 -0500 Message-Id: <20220406152347.85908-9-Frank.Li@nxp.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220406152347.85908-1-Frank.Li@nxp.com> References: <20220406152347.85908-1-Frank.Li@nxp.com> X-ClientProxiedBy: BYAPR11CA0046.namprd11.prod.outlook.com (2603:10b6:a03:80::23) To PAXPR04MB9186.eurprd04.prod.outlook.com (2603:10a6:102:232::18) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b94cf588-ec6f-43e6-5edc-08da17e198d7 X-MS-TrafficTypeDiagnostic: AM0PR04MB4033:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: EOllJiWUsOYdySwn5iAHa74g38dZ+Jb0/QXPs73dT6oo9mX2PcqjAjN9Bu/3mm9yogddaTmyynl0IZblB0UH0AsVxhr1nlRJSGe573leBau5AGV/4zQgTFLljcM6o90NAxZGYFz/41Kd9ygsh8FOLGfdcFMEc9OP6LTwbSilb0oDBhI+rBF/dnZQ4psGpzfhYhdd0B3/QGruOj8wLDWftA3O0t965maq5lHYhS+6wXr2Cah+DztRqOx70OfrTkjQ6lESESHPq7+zcYrlWaZefC7IAzqJ60nvFTR1m3z+vw7A3izhM+wGEC2xDQDCySRFsMu503ewoSq4ztlOHiyK0eLovUPHg2JqnqD24wHPH5zQzR549EucwWvXVJIFDf8Q1OGK/Fuy/qiJsBQd9tnT7PVXuoOHez/ETEuR/F7ulDhXT+6mq0K85tVsPiU/eNKB7kRxOWgj1/hS6POrOM41ErnhkfSYAo9mJ89wN5BzljRreSmw0C52TbZBC3zb/6YLAjeuKVUibMWrpcvsXA77iWsuYIABMdym/6wg8zh2UTm1LUNjoc+heI75MyEJ1f8nLqVyd09mt6LjvJl4iwvy2xgNVEFa7c4fIfs1hHNEFJTiEJ9JnAAN3iR9Uue2uXiV5fmrs+4+Mn6pfezOk9r9+LLmkoL2P0BiQ9wlbrC0Z092MOkCijdVxbs7jdDQcvMgph1UY2QIEa5GvJDF9x/Vzw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR04MB9186.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(4636009)(366004)(7416002)(26005)(1076003)(2906002)(2616005)(36756003)(83380400001)(186003)(8936002)(8676002)(6666004)(66476007)(6506007)(66556008)(86362001)(66946007)(4326008)(5660300002)(6512007)(316002)(508600001)(52116002)(38350700002)(6486002)(38100700002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: crYz96TO3woanGKO4EkBTrVTW1YSxa0DXzoeXx24HEUPaoVgpSgCAYL8ollTDvlNQhd5iG2UkmYe6H9U6wPKnQ0aFBjuHBUckvfQxt2KRzectpqXS8zRwQmHL8TBtA/oKZIL6bylK//VVItlVsbn+LcVOaPbkvZwLhRPH059UKcqw1jng+yvuaOulPsyWn7d+HbjX+JVh7XY0Yd4M4Zg0sIxUxnuEaxyFS4bSdWyJd7Qy+K0E+ooVYazN/UPIlVPM0Cpr9Iubivz26qaGs4fM+Ecp1ahrfZSzaM0bNnm2cx4A78TivDqlh/FSA7Zb3Ns5BL/nY5ktzHozcZFT5o8g8Wl0FG2uI+PWYr7bXLClFW2OzjQztOZqC8pwdc4n1bRvp2w0Am6EgSmTVzkq8l+F2dkQS0HwRuR2aqcjE2SWmNeeyUpu8bOwDqfHUjtEMmPU4no8mcAqyWaGIwqV9TS6IDYVSqAOPRm1RLNTjF152GJpT0IN3lamF6LR13R9jZ8kKOhgcbyPnhCnLAClKiBn3F/K1UH3Azwq/N86HrZeiqsAbmJ+DID1TDaUQFfJTs5BD9mGTqkqRWMZ6AGnkg503GNI/kRx2eKMW+bYx5wH0ohRXRC0NqrzZ5W8U3Eo7YoBQdgdNZPUxL/FMYS39uSZUlncJJvPMuSc31CB6M5BefoQ0rF/RZeo1A7S2zqfGQ3qow4kxf8ZPClwmLWVQMOk0lsq4bynliBVdX0IW6iRGbSQJB+Ee8XIAX6lCUg8jycP9N0oydR+RJ9LFoKmibzUcEycec+sSTa3hLcyrgwQMzmrqvTRk9hIwm8CrIpssZYy0o9bAWwiL6xdDoJbiXLzPBXf1gZq9KE+Bjvbjh60POTBNPmeafNXd2eXE6507k3fMh2KKKddyOCOqxY3QDwb6gym+02wZMdUGpzZndqmf/8R4NOHJ129vlhx8PP2rW9JKQcEcgsA11cAv+TESzWu3blFK0L8pwcBNKnw087lFnGfMpmAkMDO/OxZjwQd8LdXI9jCjs4K4qS9VDCrj4jsldR1J2fH8mccG2qutNintPO6khbFpPDzl7EQkvy3dxaPJ4V3tdsam6thQfY0BOXguMOhVsyWM5bewOH5+Xxpv5KK79PV+QLHhD1/qhsEWWWblwzP/uYKHpvQTLR/QVH4QLLEosg6QHaW4b50qpyXeGU8JfOUCtDF//IHDaXICHPQkmg+aZ9oArVqtvtGGleNvPKfO4zoaVSTEkounb+8Uc/MVugmrVOYsFebqtz8fRv+7ZepaflxVwRSDyJkgNWBTsrUx0VRUBlyqIht1lBWwuXbVli59TSWz4SEt6KTSuZAbiIR9TcqCxA4G9E03B2Ej3T2YxSIblL1DSvgs3yn/Y3CsJnMF01Ash6pqZZpTe6mpM3UzwMxabcr8Pb4YlaIMaV/s01qEN2ibo1fuzlqFtnNeX85q5G/r73jfEvhOql2XTt5bruObZjGfBUCttgBbduNY9BGamgCb6Beeg/qvxcZdnNEG4fXt+MIobb4o2GaEpvBOuiq5HEloZvA47DPvOEjbS0MtRkswYt1GuZt7EFdHRFfMy9x7qo18FRwZJf92sZm3PJm1zANzxw2Fdb60L1M1OTXjQXSdLJUq8pxTIhZvCSSOCVjWyjGlpyf7gITKWvk3m/CkTjQpHLyhLkot22/MOLzN8ORQkjQW6zrt5YxTWKEGGtPUccL0JFfzaWm+yj5PQjiqYMTJ6q3JkN/Q== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: b94cf588-ec6f-43e6-5edc-08da17e198d7 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9186.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Apr 2022 15:24:52.7552 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: xKjGgHapievtcAZHN9hTPWj7QJFxOGPDyVANIs4mNrpugtXVZS7H+rqI5nDqCU0gvuKikyKgGb1DSoW+fMNafA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB4033 Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org DW_EDMA_CHIP_32BIT_DBI was used by the controller drivers like i.MX8 that allows only 32bit access to the DBI region. Signed-off-by: Frank Li --- Change from v5 to v6 - use enum instead of define New patch at v5 - fix kernel test robot build error drivers/dma/dw-edma/dw-edma-v0-core.c | 13 ++++++++----- include/linux/dma/edma.h | 2 ++ 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/drivers/dma/dw-edma/dw-edma-v0-core.c b/drivers/dma/dw-edma/dw-edma-v0-core.c index 30f8bfe6e5712..b2b2cbe75fe4f 100644 --- a/drivers/dma/dw-edma/dw-edma-v0-core.c +++ b/drivers/dma/dw-edma/dw-edma-v0-core.c @@ -417,15 +417,18 @@ void dw_edma_v0_core_start(struct dw_edma_chunk *chunk, bool first) SET_CH_32(dw, chan->dir, chan->id, ch_control1, (DW_EDMA_V0_CCS | DW_EDMA_V0_LLE)); /* Linked list */ - #ifdef CONFIG_64BIT - SET_CH_64(dw, chan->dir, chan->id, llp.reg, - chunk->ll_region.paddr); - #else /* CONFIG_64BIT */ + if ((chan->dw->chip->flags & DW_EDMA_CHIP_32BIT_DBI) || + !IS_ENABLED(CONFIG_64BIT)) { SET_CH_32(dw, chan->dir, chan->id, llp.lsb, lower_32_bits(chunk->ll_region.paddr)); SET_CH_32(dw, chan->dir, chan->id, llp.msb, upper_32_bits(chunk->ll_region.paddr)); - #endif /* CONFIG_64BIT */ + } else { + #ifdef CONFIG_64BIT + SET_CH_64(dw, chan->dir, chan->id, llp.reg, + chunk->ll_region.paddr); + #endif + } } /* Doorbell */ SET_RW_32(dw, chan->dir, doorbell, diff --git a/include/linux/dma/edma.h b/include/linux/dma/edma.h index bec444e2939b2..dc353a33a4a25 100644 --- a/include/linux/dma/edma.h +++ b/include/linux/dma/edma.h @@ -36,9 +36,11 @@ enum dw_edma_map_format { /** * enum dw_edma_chip_flags - Flags specific to an eDMA chip * @DW_EDMA_CHIP_LOCAL: eDMA is used locally by an endpoint + * @DW_EDMA_CHIP_32BIT_DBI Only support 32bit DBI register access */ enum dw_edma_chip_flags { DW_EDMA_CHIP_LOCAL = BIT(0), + DW_EDMA_CHIP_32BIT_DBI = BIT(1), }; /** From patchwork Wed Apr 6 15:23:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 12803853 X-Patchwork-Delegate: lorenzo.pieralisi@arm.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B0E69C433EF for ; Wed, 6 Apr 2022 17:24:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238916AbiDFR0Y (ORCPT ); Wed, 6 Apr 2022 13:26:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51364 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238942AbiDFRZ6 (ORCPT ); Wed, 6 Apr 2022 13:25:58 -0400 Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2049.outbound.protection.outlook.com [40.107.20.49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AF94C4BA29B; Wed, 6 Apr 2022 08:24:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=m4oQyBBlLgR9JHSftdchT2ctJMJFFe3UGq8yND/d8YblwfDfzwkri3Fv0R18pBY42gO8mTGhme5b93nn/+Z/nMMMu6dHFQ6ND6jKXTBGQ0D/BZ8s/VgvFz0KNb153155VbxZexJ+BI8IobfUYWfyUvh5ld5S4xQxJ4IwV0dgxFf+uCVZJlqE3p3odEMNKHTY2SIUllkt5e0KwwmqcCD7AbgC1LXyF/hIs82pl7yGQNlI0zzjlyko7wnnMi9sisJzZORk1wHhH1pb3imyjnnBnF2Maewito7jtWUcPP8Dd6bHOP9QqcBscClDhrhjvJon+SLbUCLvH/fctw7wbaP6pA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=iJtXm+zNJZQy6tHmSCx01cwTZurxDWNk+J06aO/kHt4=; b=Mz4gUJCm+h3HrGN7nIaVoEg53XSEAVzNolBhrtVrmcvJb1UP71JFcOanEHs8ynXQ8uQWnd4MdM744bXMGP3Mdh1vcF9jDRGNaQt7kHCt3XwUjPZslBhuMF3Xufl2P3MkYxxyIWqtH9375Fn27QicX67dO3u5Z/F9eP3zVvJIvhE3CaRnj4HhQhamXYv9qspEf4eA8RXEaa7C66UbX8FLlldNNw0vA7kPL+IfP/4hYwUyITz9j3/UtVHGQbMZJ+URIVXM8Pb2dhf2Q/cTsJ+qj0EbkFbKG+yZJ632dzAE0eOM90mN5TxohEpdKKMBT7WucV5uiX+/DeicmcCFbOthxw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=iJtXm+zNJZQy6tHmSCx01cwTZurxDWNk+J06aO/kHt4=; b=jGsFr0KcUys4jDlFrm0+QrQdcByWcMGSGieXirQNwcwq4xjTY/tPXQO/aqySmF0Fy/Nxd+XZVGQ2c7SPxAXUqRdgRJyhAkj9KybwsZ8KtiePdErmvUqYq3QfpcqTggOAgriIntmtkDBIyrsiDsbQ4+FG50EpXo9FVhgKPAHo/XI= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from PAXPR04MB9186.eurprd04.prod.outlook.com (2603:10a6:102:232::18) by AM0PR04MB4033.eurprd04.prod.outlook.com (2603:10a6:208:5b::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5144.19; Wed, 6 Apr 2022 15:24:57 +0000 Received: from PAXPR04MB9186.eurprd04.prod.outlook.com ([fe80::ade4:ad15:823b:7e2b]) by PAXPR04MB9186.eurprd04.prod.outlook.com ([fe80::ade4:ad15:823b:7e2b%7]) with mapi id 15.20.5123.031; Wed, 6 Apr 2022 15:24:56 +0000 From: Frank Li To: gustavo.pimentel@synopsys.com, hongxing.zhu@nxp.com, l.stach@pengutronix.de, linux-imx@nxp.com, linux-pci@vger.kernel.org, dmaengine@vger.kernel.org, fancer.lancer@gmail.com, lznuaa@gmail.com, helgaas@kernel.org Cc: vkoul@kernel.org, lorenzo.pieralisi@arm.com, robh@kernel.org, kw@linux.com, bhelgaas@google.com, manivannan.sadhasivam@linaro.org, Sergey.Semin@baikalelectronics.ru Subject: [PATCH v6 9/9] PCI: endpoint: Add embedded DMA controller test Date: Wed, 6 Apr 2022 10:23:47 -0500 Message-Id: <20220406152347.85908-10-Frank.Li@nxp.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220406152347.85908-1-Frank.Li@nxp.com> References: <20220406152347.85908-1-Frank.Li@nxp.com> X-ClientProxiedBy: BYAPR11CA0046.namprd11.prod.outlook.com (2603:10b6:a03:80::23) To PAXPR04MB9186.eurprd04.prod.outlook.com (2603:10a6:102:232::18) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 1c5b422e-4e10-44e6-9072-08da17e19b4a X-MS-TrafficTypeDiagnostic: AM0PR04MB4033:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ITfGYiky0Df9sEHcHD9Iqye9LZfHfcPghHMyS7CcRgu99zdpTTPaG1xx8QuQSeeax09vZpbZaFieoWTzul4+c1yFyB9amQqSXC7qULFeGlSzqEj/xudE91lZnXmOngtMIFpb/0kbayf1UXE2KKf4hRkdbmNrHpLQHKqEIrhbd7JKnP8G7gvWFgbZjtbx0zY1mzW1zYFVxFa0oqBFZwUJTaepzFd0BrD72zGTFJ1XResghUX3qb5eXMTg3/7CLsNvobWqoMKNQ9i9Ha6Gn8ZJlGGNMNrHrYBenvaGia24wVINg4G9xqXSm70noD89gQcGqFbiNtVgOg3o/Zp5ivtZlGkU4KcLStCyuvvEQji+GRjqEukKOmBrNZ/jPkP2w/hB+VVVoqcfw4IlxIOPYnQmkMfKkKgV5wjlSslvK56QG32ASqukP9gT08zrTp2QJEUVzjyFv6zipFODpFlYrk9lInijIRkwvcpayBwkpzofIrvIhEskC8Awhbla4gDt7wRVva/GvwhoYHEAfgqdmf/mfND5thmeOQwj8wB1FrL9LWLouKhUsXVCe1hWtA7TqNipPkxZ4dCHWUJwS3rYk3vqqLeRUpp15KUJ0nUqdazv2uF760Ojf4sTYjeP4zOaFNowBV7eJbm8bZVxNfCMOP/IskoDMavir4GKAvhvWFPhbBQzrD7N4OGR1RE2dBxn2q8yLxHAosmkyAExW2g2qe2CMA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR04MB9186.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(4636009)(366004)(7416002)(26005)(1076003)(2906002)(2616005)(36756003)(83380400001)(186003)(8936002)(8676002)(6666004)(66476007)(6506007)(66556008)(86362001)(66946007)(4326008)(5660300002)(6512007)(316002)(508600001)(52116002)(38350700002)(6486002)(38100700002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Bw2YUmzZk+K9JEiZIQ5jNCNe2ByinhYqRiaYsa7jtlyKAtLqjnfMj22eKvi/KskJyYrp82ZHMzwxa7tlQ3dVijTrotRJoKZ8CPzq12ScNUcWGpgZ2bpL11T0RI0yHBCx3qKB8I3hSEaXaKlXipGwM8KCbOU5doXPNu3+iaAQXrpY4jE1PkH99QwWypdT336ks7fY5/XWHEiX/426krZa7urOxPTWKvE+Frsra60Gt6FpRMIllOoO/jQrYjryQlH0w7a60ay5s2Memvtq5NFwti6BtjpxEd4bO0Jj+DHp9t7mlG2sfCIEdIz+reyimVVvS8YJMHVdurmXW4kQfnMW/dPnARDbYIp9hbGvpshJeE+HOuPRFO5r6rbenAVTtHhTyAQXLST2/6cWC7EzEUiEv7IrFp5Iw0nbV6HUryw/VguygBGGLxBxvEaAhtil/oQGgnu0bsDEd8WHIi82cFir8JdXBqJaGSRZ6CatmMaUqG7765J20Jz4ITexTmy1F67FsiRxwAnfalX0EsVNmYrb9VzKP1C5RMtExaOGLuFCvd+mPljkT7aVrFAeTst3qBBqdVGXiNwRWXnJWg2Yl3TuiSkky+e958zm8ljuiPfRokTwtgnrgbvgee5X6DfZVl2TrYq+O3iimxmDSRAYRPTH73zl0VLE2wOoL1ujA6IQl3qiCC0eztbsyR3gBMlvSHEUaX+NcWSWceo7AEWcZJnWSvJfYIl9s4lqJEoJC7akDmwN0vLLkprZ0yFCL7DhGh4gkiqW9q0E1ThwQA+v/aT+y0OTPr6M5acOqgBa7ee4IEjOTrbBUu7vhR4DR+PonqNvKnYIc4sohHFfZG0bxRFpNWaPuQLGdHf5WShXftdiq0t0AbdIZ9pyGxHhJanlwwDylOygd9VsnPMhjdTMJGQkk5v5Aki/wQknKkhwO5MJroKGowM80Xn/59cllpSWsZhYdtcayyYJUb8FxCSdLg+VTjd+tfAOIhQhQmtVfUSQQKWgDE02NvQL3yQEUmA6GWUQEHE/vCvn5sevdHMNEsbY3VrGivAZWhj7DsLA4V5qbceQXKJ9rdYlec7nrTbLBr/KL/hzp2+hSAGoTfP2yGD+aypltxHcfNglW8N9RSxmaH1ZwHkRylAEcBnHHEDf4IN+dOtolm8bmlVvY2kHt7CGmTLUrRqICIQyRY2h5pzpSoEghq0CAYTHxc/R7GZjdjd6Ks/Ztqm0Qrl/MEOrlNtZAswhyeSI9Hkv4uTUahyCbVDKcx3etRmUfwQNvaUrTR4BrGmC26uJ8rhKgOfOOb62DV3mBeLnaYLbuoTf+YmD6shSUqXKpO+pCwZb+vitoGnY5Ldb1nV//9L1m6zpKmiTU6rMCdAayPX6Lv+9nTpVPZZ0rmH7VteqfiMnFGB/MgXyle+ExNJ1Cj12zKXtnwyDyEkbTPOgpd7rjJmHaemst4R9I91Ts4cK6I+9/8F1MSia5pNtjMA9AkijXvFHBQVfkqIp6qqGSiwwyKq9QCfVPxAx2To1F3DzXRbr03seFSKpUzmduk/DiyXDcF7s/WKwOu9cm4NayZd4q3NkOPknTf5h7sQIIkQqksrca44FJM24CPjW8WTzwK/F/xATSFdWsPSTFMB720Lbtaov3VS8gFaF6rUJB0ew3naRWUHrRSf6fxUl49LeLfR7oX4rTrsQUhs+L+xB4zAyF3T0DR2omSOuMSnbaIuJP5JxIPHg61wmQJvdI+c2Y7CeloDGuaFVDQ== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1c5b422e-4e10-44e6-9072-08da17e19b4a X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9186.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Apr 2022 15:24:56.8812 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 7Pr5QoAMnyJzh1IDaJ/cyIIXYvBihDPXEJ4yIchAKLEVHrdfjj1NbezM/BZ3bn1ifUXMPKqngDBPkbzbayR8lQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB4033 Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Designware provided eDMA support in controller. This enabled use this eDMA controller to transfer data. The whole flow align with standard DMA usage module 1. Using dma_request_channel() and filter function to find correct RX and TX Channel. 2. dmaengine_slave_config() config remote side physcial address. 3. using dmaengine_prep_slave_single() create transfer descriptor 4. tx_submit(); 5. dma_async_issue_pending(); Tested at i.MX8DXL platform. root@imx8qmmek:~# /usr/bin/pcitest -d -w WRITE ( 102400 bytes): OKAY root@imx8qmmek:~# /usr/bin/pcitest -d -r READ ( 102400 bytes): OKAY WRITE => Size: 102400 bytes DMA: YES Time: 0.000180145 seconds Rate: 555108 KB/s READ => Size: 102400 bytes DMA: YES Time: 0.000194397 seconds Rate: 514411 KB/s READ => Size: 102400 bytes DMA: NO Time: 0.013532597 seconds Rate: 7389 KB/s WRITE => Size: 102400 bytes DMA: NO Time: 0.000857090 seconds Rate: 116673 KB/s Signed-off-by: Frank Li --- Change from v5 to v6: - change subject Change from v4 to v5: - none Change from v3 to v4: - reverse Xmas tree order - local -> dma_local - change error message - IS_ERR -> IS_ERR_OR_NULL - check return value of dmaengine_slave_config() Change from v1 to v2: - none drivers/pci/endpoint/functions/pci-epf-test.c | 108 ++++++++++++++++-- 1 file changed, 98 insertions(+), 10 deletions(-) diff --git a/drivers/pci/endpoint/functions/pci-epf-test.c b/drivers/pci/endpoint/functions/pci-epf-test.c index 90d84d3bc868f..f26afd02f3a86 100644 --- a/drivers/pci/endpoint/functions/pci-epf-test.c +++ b/drivers/pci/endpoint/functions/pci-epf-test.c @@ -52,9 +52,11 @@ struct pci_epf_test { enum pci_barno test_reg_bar; size_t msix_table_offset; struct delayed_work cmd_handler; - struct dma_chan *dma_chan; + struct dma_chan *dma_chan_tx; + struct dma_chan *dma_chan_rx; struct completion transfer_complete; bool dma_supported; + bool dma_private; const struct pci_epc_features *epc_features; }; @@ -105,12 +107,15 @@ static void pci_epf_test_dma_callback(void *param) */ static int pci_epf_test_data_transfer(struct pci_epf_test *epf_test, dma_addr_t dma_dst, dma_addr_t dma_src, - size_t len) + size_t len, dma_addr_t dma_remote, + enum dma_transfer_direction dir) { + struct dma_chan *chan = (dir == DMA_DEV_TO_MEM) ? epf_test->dma_chan_tx : epf_test->dma_chan_rx; + dma_addr_t dma_local = (dir == DMA_MEM_TO_DEV) ? dma_src : dma_dst; enum dma_ctrl_flags flags = DMA_CTRL_ACK | DMA_PREP_INTERRUPT; - struct dma_chan *chan = epf_test->dma_chan; struct pci_epf *epf = epf_test->epf; struct dma_async_tx_descriptor *tx; + struct dma_slave_config sconf = {}; struct device *dev = &epf->dev; dma_cookie_t cookie; int ret; @@ -120,7 +125,22 @@ static int pci_epf_test_data_transfer(struct pci_epf_test *epf_test, return -EINVAL; } - tx = dmaengine_prep_dma_memcpy(chan, dma_dst, dma_src, len, flags); + if (epf_test->dma_private) { + sconf.direction = dir; + if (dir == DMA_MEM_TO_DEV) + sconf.dst_addr = dma_remote; + else + sconf.src_addr = dma_remote; + + if (dmaengine_slave_config(chan, &sconf)) { + dev_err(dev, "DMA slave config fail\n"); + return -EIO; + } + tx = dmaengine_prep_slave_single(chan, dma_local, len, dir, flags); + } else { + tx = dmaengine_prep_dma_memcpy(chan, dma_dst, dma_src, len, flags); + } + if (!tx) { dev_err(dev, "Failed to prepare DMA memcpy\n"); return -EIO; @@ -148,6 +168,23 @@ static int pci_epf_test_data_transfer(struct pci_epf_test *epf_test, return 0; } +struct epf_dma_filter { + struct device *dev; + u32 dma_mask; +}; + +static bool epf_dma_filter_fn(struct dma_chan *chan, void *node) +{ + struct epf_dma_filter *filter = node; + struct dma_slave_caps caps; + + memset(&caps, 0, sizeof(caps)); + dma_get_slave_caps(chan, &caps); + + return chan->device->dev == filter->dev + && (filter->dma_mask & caps.directions); +} + /** * pci_epf_test_init_dma_chan() - Function to initialize EPF test DMA channel * @epf_test: the EPF test device that performs data transfer operation @@ -158,10 +195,44 @@ static int pci_epf_test_init_dma_chan(struct pci_epf_test *epf_test) { struct pci_epf *epf = epf_test->epf; struct device *dev = &epf->dev; + struct epf_dma_filter filter; struct dma_chan *dma_chan; dma_cap_mask_t mask; int ret; + filter.dev = epf->epc->dev.parent; + filter.dma_mask = BIT(DMA_DEV_TO_MEM); + + dma_cap_zero(mask); + dma_cap_set(DMA_SLAVE, mask); + dma_chan = dma_request_channel(mask, epf_dma_filter_fn, &filter); + if (IS_ERR_OR_NULL(dma_chan)) { + dev_info(dev, "Failed to get private DMA channel. Falling back to generic one\n"); + goto fail_back_tx; + } + + epf_test->dma_chan_rx = dma_chan; + + filter.dma_mask = BIT(DMA_MEM_TO_DEV); + dma_chan = dma_request_channel(mask, epf_dma_filter_fn, &filter); + + if (IS_ERR(dma_chan)) { + dev_info(dev, "Failed to get private DMA channel. Falling back to generic one\n"); + goto fail_back_rx; + } + + epf_test->dma_chan_tx = dma_chan; + epf_test->dma_private = true; + + init_completion(&epf_test->transfer_complete); + + return 0; + +fail_back_rx: + dma_release_channel(epf_test->dma_chan_rx); + epf_test->dma_chan_tx = NULL; + +fail_back_tx: dma_cap_zero(mask); dma_cap_set(DMA_MEMCPY, mask); @@ -174,7 +245,7 @@ static int pci_epf_test_init_dma_chan(struct pci_epf_test *epf_test) } init_completion(&epf_test->transfer_complete); - epf_test->dma_chan = dma_chan; + epf_test->dma_chan_tx = epf_test->dma_chan_rx = dma_chan; return 0; } @@ -190,8 +261,17 @@ static void pci_epf_test_clean_dma_chan(struct pci_epf_test *epf_test) if (!epf_test->dma_supported) return; - dma_release_channel(epf_test->dma_chan); - epf_test->dma_chan = NULL; + dma_release_channel(epf_test->dma_chan_tx); + if (epf_test->dma_chan_tx == epf_test->dma_chan_rx) { + epf_test->dma_chan_tx = NULL; + epf_test->dma_chan_rx = NULL; + return; + } + + dma_release_channel(epf_test->dma_chan_rx); + epf_test->dma_chan_rx = NULL; + + return; } static void pci_epf_test_print_rate(const char *ops, u64 size, @@ -280,8 +360,14 @@ static int pci_epf_test_copy(struct pci_epf_test *epf_test) goto err_map_addr; } + if (epf_test->dma_private) { + dev_err(dev, "Cannot transfer data using DMA\n"); + ret = -EINVAL; + goto err_map_addr; + } + ret = pci_epf_test_data_transfer(epf_test, dst_phys_addr, - src_phys_addr, reg->size); + src_phys_addr, reg->size, 0, DMA_MEM_TO_MEM); if (ret) dev_err(dev, "Data transfer failed\n"); } else { @@ -363,7 +449,8 @@ static int pci_epf_test_read(struct pci_epf_test *epf_test) ktime_get_ts64(&start); ret = pci_epf_test_data_transfer(epf_test, dst_phys_addr, - phys_addr, reg->size); + phys_addr, reg->size, + reg->src_addr, DMA_DEV_TO_MEM); if (ret) dev_err(dev, "Data transfer failed\n"); ktime_get_ts64(&end); @@ -453,8 +540,9 @@ static int pci_epf_test_write(struct pci_epf_test *epf_test) } ktime_get_ts64(&start); + ret = pci_epf_test_data_transfer(epf_test, phys_addr, - src_phys_addr, reg->size); + src_phys_addr, reg->size, reg->dst_addr, DMA_MEM_TO_DEV); if (ret) dev_err(dev, "Data transfer failed\n"); ktime_get_ts64(&end);