From patchwork Fri Feb 9 01:04:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 198711 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp559508dyd; Thu, 8 Feb 2024 17:13:50 -0800 (PST) X-Google-Smtp-Source: AGHT+IHQ6kSQdHqVHJ78rSqpH68WmhypT0P5/1iusFyfF5ChOaEZ9e44xzGI89kcLHG9kAbUJzjt X-Received: by 2002:a9d:3e12:0:b0:6e2:c45b:f403 with SMTP id a18-20020a9d3e12000000b006e2c45bf403mr36569otd.37.1707441230168; Thu, 08 Feb 2024 17:13:50 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWCIOAQZhFroiQ7Bo1/RFUqHm2TLaMSHsMwdQxp1Im60bve5lEP1/A4VeGzwuMiyxxiqdAT6QTlwvRcu2VDZSqg3IAHqw== Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id dq22-20020a056a020f9600b005cec90b9a98si687180pgb.835.2024.02.08.17.13.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Feb 2024 17:13:50 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-58912-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b="d/Qo9e+c"; arc=fail (signature failed); spf=pass (google.com: domain of linux-kernel+bounces-58912-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-58912-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id EADC2B2262C for ; Fri, 9 Feb 2024 01:05:21 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1F05029CA; Fri, 9 Feb 2024 01:05:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="d/Qo9e+c" Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-he1eur04on2083.outbound.protection.outlook.com [40.107.7.83]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 41D24634; Fri, 9 Feb 2024 01:04:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.7.83 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707440700; cv=fail; b=UMM1JKvOYJykj0IhUmDLeUWSvOuUyAWusGuju+zW13ryZk6lVoY4e06LGWdzCacrnwhs/+PnSpPf0JUkzQmhs/2DYd8BLA7JapMB2Az7llIlBWkTSk8gba2CAYymcnPN2Q9EpltR89btMgPhGZtCh2dHR0FLczBC8uWVpXv8x9o= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707440700; c=relaxed/simple; bh=qxQHYPj7E7f1TTgAVbrbHCfdJpdOq8D88t/Ncyq8qbA=; h=From:To:Subject:Date:Message-Id:Content-Type:MIME-Version; b=JEeRdqrmwUdRrVK6SMvaKvld5Y96oqne6xFPRRxAKV3WhuCv6LS4h4AN7mWruKRGYMJF+UdstvxnXO6QxXMXcx1laN01ZGuWbt0nXIBxSOBZVCnvKOe5Fpeu0LIAMww1MSnbb1tt/o+ECuL/N+RNGWfOCSy5InQOT4aaYpXp22E= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b=d/Qo9e+c; arc=fail smtp.client-ip=40.107.7.83 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=n8071Og5qURqk48CX4eyyg8QdAH+3PdmsHQ7nssMQkyj51cBKYo6n6WkspyBVV2ihhnN0AR5EqlLD8igNz6rjgqHyQFM/JrpcDi9FC1QlU7BnZCQqlhmVd1l6FYvF0Su0FBD1KfX0i0IaHvid8MgTIr2zxGwsnQnllHi/Ml0oqsWi9cuR7wW2Iw8wUi13QhhBR8aDEUgmazKO6jY/sPTmDh9fkVfGursLLbDoLAZ3l3/GMiaTF/K5LmcmZJQIBuVPNXrHsDhwxPWqwQEn8WlSq5nWoEiI74lpQEmaAEcJbpn9PH7ICjMs1g1Hs9idpJh1X6/VDgeOVzBusdJ9BDK2A== 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=NCgQT+iu7zN/lWq2++cYqvoF3yQ2hWfYWC5WoP3CT1Y=; b=Jqu4XiGnAy0C0JeRUXMHsl9b7CYyiFdidjf6eKAaEThcLBAu3fuV95e5r9uY+NJoIBoGBCVTEir39dCZXgZkEdq7WblC28KswJSJ1jNG1k7++yLa4bMUTMlMj8OdcJ5HJQx9x1c2GKaaB1+XJsQr4HKDZ7t7/XUQdgMrgbBilXLvvIYmYeO4lNGkMlN+0RmO4LZ7IzU/J8E//oFR/Q4H/MAeAKkGn70mfJSK+GglcapgoFwbGjjSulIYMMaOAR6XNfLurQolLgmot1LC2tG7w/8gByNtvan7jDaJ/U0Gv3tibyDu+I02GEl9X8snmceQqhMUU06mBXD8Ingl77u3Gg== 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=NCgQT+iu7zN/lWq2++cYqvoF3yQ2hWfYWC5WoP3CT1Y=; b=d/Qo9e+ckGxHPLlZTP2hNfdSHPi2Fdx1G9u22u2BUT4VmSwAIeYAXdl9YMxTvU90mHA3NcoGak8sFsXws6pZd9OAGMZ4k0pt/i5pFpGdwScsuzHsSxSanm0sQ4kWzECBjRSb1U71iraRnFNFBWRGW9eeCv8mS6hf5NShpRajNhg= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from PAXPR04MB9642.eurprd04.prod.outlook.com (2603:10a6:102:240::14) by VI1PR04MB9764.eurprd04.prod.outlook.com (2603:10a6:800:1d2::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7249.43; Fri, 9 Feb 2024 01:04:55 +0000 Received: from PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::c8b4:5648:8948:e85c]) by PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::c8b4:5648:8948:e85c%3]) with mapi id 15.20.7270.025; Fri, 9 Feb 2024 01:04:54 +0000 From: Frank Li To: Vinod Koul , linux-kernel@vger.kernel.org (open list), dmaengine@vger.kernel.org (open list:DMA GENERIC OFFLOAD ENGINE SUBSYSTEM), imx@lists.linux.dev (open list:FREESCALE eDMA DRIVER) Subject: [PATCH 1/2] dmaengine: fsl-edma: add trace event support Date: Thu, 8 Feb 2024 20:04:22 -0500 Message-Id: <20240209010425.2001891-1-Frank.Li@nxp.com> X-Mailer: git-send-email 2.34.1 X-ClientProxiedBy: SA9PR13CA0148.namprd13.prod.outlook.com (2603:10b6:806:27::33) To PAXPR04MB9642.eurprd04.prod.outlook.com (2603:10a6:102:240::14) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB9642:EE_|VI1PR04MB9764:EE_ X-MS-Office365-Filtering-Correlation-Id: 9d68ea22-c712-4d11-f064-08dc290b2084 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: AiQ9slAhjZcCj6ANpyinUvK5YaeFBsqWO/Mj2yoDllS8YUW67FR4xbBPxn0a8acIxaq9W2YVjsBqksQo+YZOLzLPd1VTpG4JlJbtltfFaxaAy7z4M7nEm2sA0EJ4pdbkRWG3omasuthU+ksh/tvkg6uTB39HjrP6e4buwaurVJOz03JQhWvRzykQdzeC0hlhKLweCRT6JUqISDwZ/KOdzeXJT8k5W9urcazfJ6aOMwmu9BDYpMxcqf4D08J2vF+DoaFb1WWiSQ1LeietKnU3IyCN6Uj4jVNznOjBws7od6kF3YTTAFWe1vlcrtnfSOLzgIaau9CqJneLnRpcHZnpFZehWzePrnBfJAKxAXgW8E0aGm+0HISqi+PpKXKzswWM+2nYsne3SmmKmMUeCxR8Tk4g8tz/E/8LfMWg4DM6gMB9IfxZw1PJTRUl/xc2MUWqpFX2wkYbBoZ/ArBNzasejASk5DKAyLjuhKvKjLE72mkTsX7RPBBMIZvdko7Joy88bsXQFQp+6MPM10fiN1O8MFqtWxePGqqsGgXN5TPo+9WmZ5oKsoRjsIFe5QYyriLmqTSGbSNVkrx6maFeQn0PPpJ0AjayjQZ12gsfq6EGEE4rZD/WqG0f8e+5UoSj9y/f X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR04MB9642.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(136003)(346002)(39860400002)(396003)(376002)(366004)(230922051799003)(64100799003)(186009)(451199024)(1800799012)(2906002)(8676002)(8936002)(5660300002)(83380400001)(2616005)(26005)(38100700002)(1076003)(36756003)(86362001)(38350700005)(66946007)(66476007)(66556008)(316002)(6666004)(52116002)(6506007)(6512007)(6486002)(478600001)(41300700001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 4njL0Uim1k6xw+bgqjtoPEtXnYWAv2Ie/bAVZrULo3bfEoz/g/S6Ks0PuQfjVG3aWj2lXRD5zNc/JMx4gVKzDEcx9I2KCVCKvSvnOcfY7LeQ1FgQ0uevhI2VD97C7ZVfjZt7QSXi0K0YrPSZQE0/S5dsV1M3kK4+B4OYEwpU57C07kC3FqjY2DBMYI+Mjo/vQDpiqTZitdWJHUVNMJX0d9uVXCSLzsnHfZbYh0qv/JAKjoKVeDW94oRf2bj9WIBypzvYHiDBj+bsv1Hbuz+qb0ULG87TQ13ptgLkuRspNpJLtPf8pl4RHyVjTLJxALzX0z0yRj3elrw4ggHIYK9IeqzAELyetADuD3bcUyvqVSoqfqaOr6Xp6PQ961HAovroy9PNKUgsQu3bzMYwNJrtNwcCK978dbMi4zLSREjPmIJpioo7bGB8PNm88MPl4VCakvuzMmXwJFJkA6W0f9+A02z4l7k51XDKe6qkQdh/3U9/pAaRcx+Q/5PsecMwvdtA62TxJLD/Ri+Lczs+htSC96Sb06wahmzHXHQ/aBUlMqQH6eYSMKI7swx2O0QpDfL5ILrs0a7WN6Q/UOYx4d1dZUh6vEZgSL4QrnSUM5A73jZLuMbY/6pqv1QnCOjpHMk070+ED5mksmOmlRikf834LZneuGqONZ65WLrWiy5pUFEamToA6S6rzRyTXZt8EpO6a2XUNzg6+f2nKEjKW9PlHD3oIqdrVRqJXPmV3qzPGQLH7j5xnmQgxPqVbnG42uxDWfEsX6Lg8H3ocRJGQ6hpd5Tt1wc4umY3JL5fG4hXkBbO3L0hr5hQXxpBAs0/yNtP2I1IlflQUITvam+X2UuKtLpfFfa2mUKVTzrKiRH5EX6DFr9pvvL5vISkibtcgoPo8XLgZtIRgMPjnKVt0N1SwNne8YpZrRrTrth02RRnBAAOXLv2jHdzSbOGKwrMbUMje+r7qtuSa/ublVTKrk63kVSGbv+fepDDAIejBGr/PCSPAq3XCKBn3stoxtWxeSO0X/E6wOolI4cYxnNmz/RSw43BoJSDBRQWmFb6qWOyjuwavm2T3gu9VmPJ5S7KcYshP3I6dSqqLFFuYduqPrgk4b/uC9rElNSX89Yk8XyqWRwKxlSUjk6O1+GSCDPRyuVo0oy8dBRdUaiKPQvds74KRSlHVrY6r+LY8SFDfP+CwvryafGv2ELluINAxGuSTRs934NMJJPvSxUFuINdf4U+fDCR+hnqUlgBEeP4M1NMTC8FmxsI08wmVMFbQ1G7XZfpzNXmip757Enrrrpd9blsGYJRRLhdtppewjhM/33zSm91cqj6Y7PPzdAkQgh9wZ2cIqcxvWeKIwowRdQlFxdUP2Eo0o2vrLQGJ6zBT7RqOFds1TqlAHuSn92FrcfRjD7TR9sCwioQGVQ5QHdJ6cfyi54ju4TPnO7QSOWEVFQF+QnXuVOQ1ulgUffhzVcE1mrkl2S/2A2YFHEZA2WHuTZ3gIa8aj0ZQ/NJ9zlf0WjyeLtdYgbApD3C63vvzg6PmB4qei+hVdrNSTZxdqVnC54yubJREstUUPd+rQDTl/ZMa5YW3MqQxUcCNAo2ELMYGoil X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9d68ea22-c712-4d11-f064-08dc290b2084 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Feb 2024 01:04:54.8787 (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: 2BW2tFADSydd5/955axrQ8wftyNOQBAvvQl2IpJ64HMEqKj1dbvEjA82azOkCKPlIGXdvVXpPUQrKakKErU0bQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB9764 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790381895300255199 X-GMAIL-MSGID: 1790381895300255199 Implement trace event support to enhance logging functionality for register access and the transfer control descriptor (TCD) context. This will enable more comprehensive monitoring and analysis of system activities Signed-off-by: Frank Li --- drivers/dma/Makefile | 6 +- drivers/dma/fsl-edma-common.c | 2 + drivers/dma/fsl-edma-common.h | 45 +++++++++--- drivers/dma/fsl-edma-trace.c | 4 ++ drivers/dma/fsl-edma-trace.h | 132 ++++++++++++++++++++++++++++++++++ 5 files changed, 178 insertions(+), 11 deletions(-) create mode 100644 drivers/dma/fsl-edma-trace.c create mode 100644 drivers/dma/fsl-edma-trace.h diff --git a/drivers/dma/Makefile b/drivers/dma/Makefile index dfd40d14e4089..802ca916f05f5 100644 --- a/drivers/dma/Makefile +++ b/drivers/dma/Makefile @@ -31,10 +31,12 @@ obj-$(CONFIG_DW_AXI_DMAC) += dw-axi-dmac/ obj-$(CONFIG_DW_DMAC_CORE) += dw/ obj-$(CONFIG_DW_EDMA) += dw-edma/ obj-$(CONFIG_EP93XX_DMA) += ep93xx_dma.o +fsl-edma-trace-$(CONFIG_TRACING) := fsl-edma-trace.o +CFLAGS_fsl-edma-trace.o := -I$(src) obj-$(CONFIG_FSL_DMA) += fsldma.o -fsl-edma-objs := fsl-edma-main.o fsl-edma-common.o +fsl-edma-objs := fsl-edma-main.o fsl-edma-common.o ${fsl-edma-trace-y} obj-$(CONFIG_FSL_EDMA) += fsl-edma.o -mcf-edma-objs := mcf-edma-main.o fsl-edma-common.o +mcf-edma-objs := mcf-edma-main.o fsl-edma-common.o ${fsl-edma-trace-y} obj-$(CONFIG_MCF_EDMA) += mcf-edma.o obj-$(CONFIG_FSL_QDMA) += fsl-qdma.o obj-$(CONFIG_FSL_RAID) += fsl_raid.o diff --git a/drivers/dma/fsl-edma-common.c b/drivers/dma/fsl-edma-common.c index b18faa7cfedb9..ebd9647671c9f 100644 --- a/drivers/dma/fsl-edma-common.c +++ b/drivers/dma/fsl-edma-common.c @@ -546,6 +546,8 @@ void fsl_edma_fill_tcd(struct fsl_edma_chan *fsl_chan, csr |= EDMA_TCD_CSR_START; fsl_edma_set_tcd_to_le(fsl_chan, tcd, csr, csr); + + trace_edma_fill_tcd(fsl_chan, tcd); } static struct fsl_edma_desc *fsl_edma_alloc_desc(struct fsl_edma_chan *fsl_chan, diff --git a/drivers/dma/fsl-edma-common.h b/drivers/dma/fsl-edma-common.h index a05a1f283ece2..365affd5b0764 100644 --- a/drivers/dma/fsl-edma-common.h +++ b/drivers/dma/fsl-edma-common.h @@ -249,6 +249,11 @@ struct fsl_edma_engine { struct fsl_edma_chan chans[] __counted_by(n_chans); }; +static inline u32 fsl_edma_drvflags(struct fsl_edma_chan *fsl_chan) +{ + return fsl_chan->edma->drvdata->flags; +} + #define edma_read_tcdreg_c(chan, _tcd, __name) \ (sizeof((_tcd)->__name) == sizeof(u64) ? \ edma_readq(chan->edma, &(_tcd)->__name) : \ @@ -352,6 +357,9 @@ do { \ fsl_edma_set_tcd_to_le_c((struct fsl_edma_hw_tcd *)_tcd, _val, _field); \ } while (0) +/* Need after struct defination */ +#include "fsl-edma-trace.h" + /* * R/W functions for big- or little-endian registers: * The eDMA controller's endian is independent of the CPU core's endian. @@ -370,23 +378,38 @@ static inline u64 edma_readq(struct fsl_edma_engine *edma, void __iomem *addr) h = ioread32(addr + 4); } + trace_edma_readl(edma, addr, l); + trace_edma_readl(edma, addr + 4, h); + return (h << 32) | l; } static inline u32 edma_readl(struct fsl_edma_engine *edma, void __iomem *addr) { + u32 val; + if (edma->big_endian) - return ioread32be(addr); + val = ioread32be(addr); else - return ioread32(addr); + val = ioread32(addr); + + trace_edma_readl(edma, addr, val); + + return val; } static inline u16 edma_readw(struct fsl_edma_engine *edma, void __iomem *addr) { + u16 val; + if (edma->big_endian) - return ioread16be(addr); + val = ioread16be(addr); else - return ioread16(addr); + val = ioread16(addr); + + trace_edma_readw(edma, addr, val); + + return val; } static inline void edma_writeb(struct fsl_edma_engine *edma, @@ -397,6 +420,8 @@ static inline void edma_writeb(struct fsl_edma_engine *edma, iowrite8(val, (void __iomem *)((unsigned long)addr ^ 0x3)); else iowrite8(val, addr); + + trace_edma_writeb(edma, addr, val); } static inline void edma_writew(struct fsl_edma_engine *edma, @@ -407,6 +432,8 @@ static inline void edma_writew(struct fsl_edma_engine *edma, iowrite16be(val, (void __iomem *)((unsigned long)addr ^ 0x2)); else iowrite16(val, addr); + + trace_edma_writew(edma, addr, val); } static inline void edma_writel(struct fsl_edma_engine *edma, @@ -416,6 +443,8 @@ static inline void edma_writel(struct fsl_edma_engine *edma, iowrite32be(val, addr); else iowrite32(val, addr); + + trace_edma_writel(edma, addr, val); } static inline void edma_writeq(struct fsl_edma_engine *edma, @@ -428,6 +457,9 @@ static inline void edma_writeq(struct fsl_edma_engine *edma, iowrite32(val & 0xFFFFFFFF, addr); iowrite32(val >> 32, addr + 4); } + + trace_edma_writel(edma, addr, val & 0xFFFFFFFF); + trace_edma_writel(edma, addr + 4, val >> 32); } static inline struct fsl_edma_chan *to_fsl_edma_chan(struct dma_chan *chan) @@ -435,11 +467,6 @@ static inline struct fsl_edma_chan *to_fsl_edma_chan(struct dma_chan *chan) return container_of(chan, struct fsl_edma_chan, vchan.chan); } -static inline u32 fsl_edma_drvflags(struct fsl_edma_chan *fsl_chan) -{ - return fsl_chan->edma->drvdata->flags; -} - static inline struct fsl_edma_desc *to_fsl_edma_desc(struct virt_dma_desc *vd) { return container_of(vd, struct fsl_edma_desc, vdesc); diff --git a/drivers/dma/fsl-edma-trace.c b/drivers/dma/fsl-edma-trace.c new file mode 100644 index 0000000000000..28300ad80bb75 --- /dev/null +++ b/drivers/dma/fsl-edma-trace.c @@ -0,0 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0 + +#define CREATE_TRACE_POINTS +#include "fsl-edma-common.h" diff --git a/drivers/dma/fsl-edma-trace.h b/drivers/dma/fsl-edma-trace.h new file mode 100644 index 0000000000000..d3541301a2470 --- /dev/null +++ b/drivers/dma/fsl-edma-trace.h @@ -0,0 +1,132 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * Copyright 2023 NXP. + */ + +#undef TRACE_SYSTEM +#define TRACE_SYSTEM fsl_edma + +#if !defined(__LINUX_FSL_EDMA_TRACE) || defined(TRACE_HEADER_MULTI_READ) +#define __LINUX_FSL_EDMA_TRACE + +#include +#include + +DECLARE_EVENT_CLASS(edma_log_io, + TP_PROTO(struct fsl_edma_engine *edma, void __iomem *addr, u32 value), + TP_ARGS(edma, addr, value), + TP_STRUCT__entry( + __field(struct fsl_edma_engine *, edma) + __field(void __iomem *, addr) + __field(u32, value) + ), + TP_fast_assign( + __entry->edma = edma; + __entry->addr = addr; + __entry->value = value; + ), + TP_printk("offset %08x: value %08x", + (u32)(__entry->addr - __entry->edma->membase), __entry->value) +); + +DEFINE_EVENT(edma_log_io, edma_readl, + TP_PROTO(struct fsl_edma_engine *edma, void __iomem *addr, u32 value), + TP_ARGS(edma, addr, value) +); + +DEFINE_EVENT(edma_log_io, edma_writel, + TP_PROTO(struct fsl_edma_engine *edma, void __iomem *addr, u32 value), + TP_ARGS(edma, addr, value) +); + +DEFINE_EVENT(edma_log_io, edma_readw, + TP_PROTO(struct fsl_edma_engine *edma, void __iomem *addr, u32 value), + TP_ARGS(edma, addr, value) +); + +DEFINE_EVENT(edma_log_io, edma_writew, + TP_PROTO(struct fsl_edma_engine *edma, void __iomem *addr, u32 value), + TP_ARGS(edma, addr, value) +); + +DEFINE_EVENT(edma_log_io, edma_readb, + TP_PROTO(struct fsl_edma_engine *edma, void __iomem *addr, u32 value), + TP_ARGS(edma, addr, value) +); + +DEFINE_EVENT(edma_log_io, edma_writeb, + TP_PROTO(struct fsl_edma_engine *edma, void __iomem *addr, u32 value), + TP_ARGS(edma, addr, value) +); + +DECLARE_EVENT_CLASS(edma_log_tcd, + TP_PROTO(struct fsl_edma_chan *chan, void *tcd), + TP_ARGS(chan, tcd), + TP_STRUCT__entry( + __field(u64, saddr) + __field(u16, soff) + __field(u16, attr) + __field(u32, nbytes) + __field(u64, slast) + __field(u64, daddr) + __field(u16, doff) + __field(u16, citer) + __field(u64, dlast_sga) + __field(u16, csr) + __field(u16, biter) + + ), + TP_fast_assign( + __entry->saddr = fsl_edma_get_tcd_to_cpu(chan, tcd, saddr), + __entry->soff = fsl_edma_get_tcd_to_cpu(chan, tcd, soff), + __entry->attr = fsl_edma_get_tcd_to_cpu(chan, tcd, attr), + __entry->nbytes = fsl_edma_get_tcd_to_cpu(chan, tcd, nbytes), + __entry->slast = fsl_edma_get_tcd_to_cpu(chan, tcd, slast), + __entry->daddr = fsl_edma_get_tcd_to_cpu(chan, tcd, daddr), + __entry->doff = fsl_edma_get_tcd_to_cpu(chan, tcd, doff), + __entry->citer = fsl_edma_get_tcd_to_cpu(chan, tcd, citer), + __entry->dlast_sga = fsl_edma_get_tcd_to_cpu(chan, tcd, dlast_sga), + __entry->csr = fsl_edma_get_tcd_to_cpu(chan, tcd, csr), + __entry->biter = fsl_edma_get_tcd_to_cpu(chan, tcd, biter); + ), + TP_printk("\n==== TCD =====\n" + " saddr: 0x%016llx\n" + " soff: 0x%04x\n" + " attr: 0x%04x\n" + " nbytes: 0x%08x\n" + " slast: 0x%016llx\n" + " daddr: 0x%016llx\n" + " doff: 0x%04x\n" + " citer: 0x%04x\n" + " dlast: 0x%016llx\n" + " csr: 0x%04x\n" + " biter: 0x%04x\n", + __entry->saddr, + __entry->soff, + __entry->attr, + __entry->nbytes, + __entry->slast, + __entry->daddr, + __entry->doff, + __entry->citer, + __entry->dlast_sga, + __entry->csr, + __entry->biter) +); + +DEFINE_EVENT(edma_log_tcd, edma_fill_tcd, + TP_PROTO(struct fsl_edma_chan *chan, void *tcd), + TP_ARGS(chan, tcd) +); + +#endif + +/* this part must be outside header guard */ + +#undef TRACE_INCLUDE_PATH +#define TRACE_INCLUDE_PATH . + +#undef TRACE_INCLUDE_FILE +#define TRACE_INCLUDE_FILE fsl-edma-trace + +#include From patchwork Fri Feb 9 01:04:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 198712 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp559571dyd; Thu, 8 Feb 2024 17:14:00 -0800 (PST) X-Google-Smtp-Source: AGHT+IHnn70CgaM18zWgxAxCwkygmhrHI3qdkbaAlDjXu03D1eaJE6kU0u4vYkobG712ZTlaWwnf X-Received: by 2002:a05:6808:3208:b0:3bf:e4ed:c8dd with SMTP id cb8-20020a056808320800b003bfe4edc8ddmr290401oib.18.1707441239704; Thu, 08 Feb 2024 17:13:59 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVsRn5yNCXCRkcdptWWsJu3EyjhRjbS7H64d6KUjSf6FFSjVMndIA/FmBF9Aas+A9UIkyJ8IDghyiablhqq2hflPUnyGg== Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id q10-20020a056a00084a00b006dfed2328a1si675093pfk.382.2024.02.08.17.13.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Feb 2024 17:13:59 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-58913-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=Z1wBiHvc; arc=fail (signature failed); spf=pass (google.com: domain of linux-kernel+bounces-58913-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-58913-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id D8645B22AF5 for ; Fri, 9 Feb 2024 01:05:32 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DF40A1879; Fri, 9 Feb 2024 01:05:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="Z1wBiHvc" Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-he1eur04on2083.outbound.protection.outlook.com [40.107.7.83]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 210C0A34; Fri, 9 Feb 2024 01:05:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.7.83 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707440703; cv=fail; b=N4tBUwzgt6zslth5rPTjeGAPoWXRTdLQDqvsOytx5Qin2Zhhgq3escdpPztnTm2ynxzi6kvTKv/7onjIL8WtMJBVFzC4xnj9/k7747BaeLO+A1QHp3FZZqHnLB60fM3aBEIKoM06OKF8PjHG0oLvJrk+3N+uDjYdnPTtbgn6Hy4= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707440703; c=relaxed/simple; bh=dRfOZuqRUtFaArT6hOmglas/LsidRqw/YQI6KbBnLt8=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=bbO+6c0caopcnDRk3urI7OYT3AEBxlnGjzgwW5ulhR4LxZO8YSkaWsBtVVjeYPitGU9U8dQnRbGE2fiRn4e9rvHJ8vsLfLRnOVqaNAq+N1mJQ8685bITbvsVMwV5Qxsc1/dCpMZGOVXDsufLXwc4HhgEjQW3upMZLeKaxVywUGo= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b=Z1wBiHvc; arc=fail smtp.client-ip=40.107.7.83 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fvj9CGkRDAbb3xNMA2h8FiP2B/1xQ3UFrmAlDAGC42AAb1riQM8pNeJh/20ZL1Z2N/5pfwPBcr5soH6gN4X5mmibdjWa7+o2epqqIGebjXjafLPmTU/mchxVx0p48YnOKV7QICYuBtcGg3F43GLaASGqQNVu04YkHAQ5NLVEIFKtLcdlzKimkE7U9RVOsgxb6g9lHehI4k9XtkwPXEV2EFrKsndqXmw2lJAsO8SJfRsjRAwcfv0nF+4h+2eU8qBO1Xpi98ynDnfHQSFuA448aDGcJwsgrHvES/3InSOBiadCT5f/R5YPLqpcz28NdSdUJ53HYZyuip4gASDVD7VLvw== 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=XUees2+CYuNSMnVFfpburGEEfa/Pi0zJJBFblNMWZYQ=; b=oRxvDrHoLxbB4/z8j/jCVvfG/ijXY7gZj3MQQJzXS2wum/unV2VD4ATvYgcA3SQpjp4V0wZUHcbwpNZKeusIdCHR9no63yitnrbWWn1AubHCl+F/dCsE9Fa60SN8Ft14uibXvOJDpWHKmcM8c1THYP0rHpQGjuwgerwQs3XfK7Rp09hLLNwx6enfdN/llVUZ2BvUPchoqFV8KrUPxuY0BCu3wiERxjTHB2v5rUWX3iKQaTaIYV3mM3lK4XuwoBRFh78+rp/bmSwFe2KiNF/tcsPIUKWDVtULKJUQy37Mq/acbBo3ykADNkcZlT9grSNVZDjRdiJnC4zgVocJoo8M+A== 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=XUees2+CYuNSMnVFfpburGEEfa/Pi0zJJBFblNMWZYQ=; b=Z1wBiHvcwsLD16rSokdQ9PSKwkJYpjkqAklfF8LicRoCczWUbfu3OifJZESYW4taBMpXDC5cM7fqNcs3+GTpso332nYYmpyNeDwMiS+uI2EfEC2oEc/cxhw7QYn+uEUnWtdi9xL3mKGjUbtrZLHfPaXBZVNHL5WNWO/YUKO1qHc= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from PAXPR04MB9642.eurprd04.prod.outlook.com (2603:10a6:102:240::14) by VI1PR04MB9764.eurprd04.prod.outlook.com (2603:10a6:800:1d2::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7249.43; Fri, 9 Feb 2024 01:04:56 +0000 Received: from PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::c8b4:5648:8948:e85c]) by PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::c8b4:5648:8948:e85c%3]) with mapi id 15.20.7270.025; Fri, 9 Feb 2024 01:04:56 +0000 From: Frank Li To: Vinod Koul , imx@lists.linux.dev (open list:FREESCALE eDMA DRIVER), dmaengine@vger.kernel.org (open list:FREESCALE eDMA DRIVER), linux-kernel@vger.kernel.org (open list) Subject: [PATCH 2/2] dmaengine: fsl-edma: use _Generic to handle difference type Date: Thu, 8 Feb 2024 20:04:23 -0500 Message-Id: <20240209010425.2001891-2-Frank.Li@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240209010425.2001891-1-Frank.Li@nxp.com> References: <20240209010425.2001891-1-Frank.Li@nxp.com> X-ClientProxiedBy: SA9PR13CA0148.namprd13.prod.outlook.com (2603:10b6:806:27::33) To PAXPR04MB9642.eurprd04.prod.outlook.com (2603:10a6:102:240::14) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB9642:EE_|VI1PR04MB9764:EE_ X-MS-Office365-Filtering-Correlation-Id: ad5c4360-eff5-42de-217b-08dc290b217a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: KoQN9Y8MB2e2G2GMRMEij+W1u6gjT4qhG44RZ9PVbWih8eyG6Q6nWWIm5t3vhXmes2Xwbxq0szJlASSZs+rCDX1UuhRxD/E0QBIrIhj8XHGq5EdAY4bGXWecGqMztHpcVFy7riZOZHemm90tz1JQy+PZFhfY99vqBPG3VuSULW2ZXa47KeAucl6w9Ue1f6F+s9Gr4IR5VvLg6aDYoMZsYxZ4oavNU5v1Wqji0Fdgf2toXGlijUmDbbSb8hoqhqYaXT0qAVkEyl6heYK8bCv43bJBDXGukLLidf2jR9QC5DWw6FVtFO9S2vQ8gPnXv4x2smGcyCGqxdvM9hI1zBPA6fSO7ABc8ldRH1vY8FB7glFq6Z5ehEQRuFvRTyldC98wlKpxo5CrP1BxpaIIyn2OrXIg0nQvZ8ToW766MatsmfFXwBKFNj8T2qf7ie6JndMAobRhuGdUoERsJyINGd0W0nIerrBjMNtYFpE0e0hsR2BfX+lbpu2alb/PIfAZFXxW3oDMBI5qn1ibcIpKlZDDpD2kQgEX7UIGYPo4m9iT77LOgDz3w+sUhZprnOfBX0T9mPAi+U8bQ3a4VwUusM8qysCRcB85flhqD353r01xh9r6rXpMex5ntS7PuypZkjpd X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR04MB9642.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(136003)(346002)(39860400002)(396003)(376002)(366004)(230922051799003)(64100799003)(186009)(451199024)(1800799012)(2906002)(8676002)(8936002)(5660300002)(83380400001)(2616005)(26005)(38100700002)(1076003)(36756003)(86362001)(38350700005)(66946007)(66476007)(66556008)(316002)(6666004)(52116002)(6506007)(6512007)(6486002)(478600001)(41300700001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: uSEaH78ZxhL58gMIuUhY5Bdqx5sBXhaLkybXflR+Oy4O+G1qA7YOR6DFqXfwHQifxrq6AjLxfEZVdZ36WZfcObid2ewI4NwA+lKftONRk/IrRatmbUp/r7AG3A0p1UA7ljFwcdPfPYyg7KmIDW3t4/du+cgZJPirJiX0I0IYlUwXHuGAROIVcYHv6dfJY64O2+TMBi4tH62aLJOfWdGmRZCbI/hGeJ8wFlTtFqeRKB+60E4o7ec/OO+YvxpX72N1Pokh6a3uAQ9aAMofjHFyehLWf3fn75guI+TxqZyGAc7AtqET43QFYEyd1+aApZWE+06FPEtkkPNQ8DQLxgfQvHvEuyjjiCD4K/fDZK7iOriPPX2kXlInZ37jb4J35CpMoi8b/gQxFq63LOdczTcH8oY6sIIsS5oHuAeNl4Z1mhDUfqcrCF05QEsPxAD6jvraEvUWsv6B9QtAn7e8K+0i1Tathv5H/OvEKNSPQbMtZCggtBMrUwE4+JnsNlPJiCifxrJlEQHASzfNP05rjEcAosAp/bYbtTFshJkumxtjCO44YGykBNQzdNk/i/59ERBS9Tezv8LZiaId0YOTBUrtlgkZfrpO/l7TVSd/IB6OZuEr6dCUbmug6EYka0YYcVimzAx9uXSSrmgvXkNbIddpML+RucjQAbBxW6h/o5FvX4qOn9JN81jGkbnUhzRUjwRpVOqbSWBPejd2VcGLR6pdTJEU0fkMGbRePmxpHNqznlfdZR4PyrL5hwAXHfmyqAIY+q5g7aBh48n8rYW+CFzj1xSKdtVHHBRmcvgcIXjsLnDm0hnLBH4iAXuhHBKdmLKjIoCHyCsqGSb0ppfEoPdmvvesGW8z1zCPEg/3VuEjn1FBHOG57wvfdMwFtz3zpLnX1gGwXB5EANVf1ZhHzmwvrm3TA3w/sUTHF41DNxm2h+yY8oxf22MANDFhH7vVpvrJdIn061PQudjbmnTGSyWJW7M2CwvVA3bJIloI9qVigTOysb5VjRCFxVK1hU8HU5nLZ2WU6IRuLvnVxc3RIJ8t39B+shqhVN+dyV6EfWo6HyclU/eSeM5APZ6Fu+/3KRQEErE3qX2eyOrOw8ZhPqtR6rKAqRNcNf+cZnO+z9tFf+l9yTinya96mXKdaSkhyt27DNvqIN+fOLS3k68VQM/ZTtce9Kl65NjtVUIPK9hLyGbpA7fzPenuyi5oqt3JFzpUWhGNbWCWXFOQXdtf1ZtRFNACFBqe2QH9t0jOi1jWLGOmk1NZG3QB1l80oJFDaVkRw6mF8U2z3hSwMVqG3xo9joW+JdE49sWpTKECnSY/8Fzbb3wFAUY6+o4sOdEBRBcc4MknO1qOAP/CQ2HT2U0XmQ+cf3568c3Ot27/vcJWx3DxncCiLm0rOL6FfzMM2dZZno7Ood5qrMRYooKADIMZ8R8LhFK24M7uyZMFFgLBh/OxREdqpqKP0gMpvIVXP8MeVapxph/OylfsZ23z2E16ZhUwv2onsjDcyWTKN7t1HNgoswJLw1lovc9wVEqrPipJgE7l28NDvhgfsdIcddtxVW3gZxlPhLDqoFh8Ecra3CQAb04Ir4RTd2IEk9EC20eg X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: ad5c4360-eff5-42de-217b-08dc290b217a X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Feb 2024 01:04:56.4240 (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: JUlFVrWy2PYa7M78ZL3vhTCAIOdpZwNj0XbxypjylgQPatf/F2hqVGRwz5XokRxu8tUQ4KDKxd5j2vmZfVsgXg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB9764 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790381905306499705 X-GMAIL-MSGID: 1790381905306499705 Introduce the use of C11 standard _Generic in the fsl-edma driver for handling different TCD field types. Improve code clarity and help compiler optimization. Signed-off-by: Frank Li --- drivers/dma/fsl-edma-common.h | 59 +++++++++++++---------------------- 1 file changed, 21 insertions(+), 38 deletions(-) diff --git a/drivers/dma/fsl-edma-common.h b/drivers/dma/fsl-edma-common.h index 365affd5b0764..fabd2d73a7c22 100644 --- a/drivers/dma/fsl-edma-common.h +++ b/drivers/dma/fsl-edma-common.h @@ -255,12 +255,11 @@ static inline u32 fsl_edma_drvflags(struct fsl_edma_chan *fsl_chan) } #define edma_read_tcdreg_c(chan, _tcd, __name) \ -(sizeof((_tcd)->__name) == sizeof(u64) ? \ - edma_readq(chan->edma, &(_tcd)->__name) : \ - ((sizeof((_tcd)->__name) == sizeof(u32)) ? \ - edma_readl(chan->edma, &(_tcd)->__name) : \ - edma_readw(chan->edma, &(_tcd)->__name) \ - )) +_Generic(((_tcd)->__name), \ + __le64 : edma_readq(chan->edma, &(_tcd)->__name), \ + __le32 : edma_readl(chan->edma, &(_tcd)->__name), \ + __le16 : edma_readw(chan->edma, &(_tcd)->__name) \ + ) #define edma_read_tcdreg(chan, __name) \ ((fsl_edma_drvflags(chan) & FSL_EDMA_DRV_TCD64) ? \ @@ -269,22 +268,12 @@ static inline u32 fsl_edma_drvflags(struct fsl_edma_chan *fsl_chan) ) #define edma_write_tcdreg_c(chan, _tcd, _val, __name) \ -do { \ - switch (sizeof(_tcd->__name)) { \ - case sizeof(u64): \ - edma_writeq(chan->edma, (u64 __force)_val, &_tcd->__name); \ - break; \ - case sizeof(u32): \ - edma_writel(chan->edma, (u32 __force)_val, &_tcd->__name); \ - break; \ - case sizeof(u16): \ - edma_writew(chan->edma, (u16 __force)_val, &_tcd->__name); \ - break; \ - case sizeof(u8): \ - edma_writeb(chan->edma, (u8 __force)_val, &_tcd->__name); \ - break; \ - } \ -} while (0) +_Generic((_tcd->__name), \ + __le64 : edma_writeq(chan->edma, _val, &_tcd->__name), \ + __le32 : edma_writel(chan->edma, _val, &_tcd->__name), \ + __le16 : edma_writew(chan->edma, _val, &_tcd->__name), \ + u8 : edma_writeb(chan->edma, _val, &_tcd->__name) \ + ) #define edma_write_tcdreg(chan, val, __name) \ do { \ @@ -325,9 +314,11 @@ do { \ (((struct fsl_edma_hw_tcd *)_tcd)->_field)) #define fsl_edma_le_to_cpu(x) \ -(sizeof(x) == sizeof(u64) ? le64_to_cpu((__force __le64)(x)) : \ - (sizeof(x) == sizeof(u32) ? le32_to_cpu((__force __le32)(x)) : \ - le16_to_cpu((__force __le16)(x)))) +_Generic((x), \ + __le64 : le64_to_cpu((x)), \ + __le32 : le32_to_cpu((x)), \ + __le16 : le16_to_cpu((x)) \ +) #define fsl_edma_get_tcd_to_cpu(_chan, _tcd, _field) \ (fsl_edma_drvflags(_chan) & FSL_EDMA_DRV_TCD64 ? \ @@ -335,19 +326,11 @@ do { \ fsl_edma_le_to_cpu(((struct fsl_edma_hw_tcd *)_tcd)->_field)) #define fsl_edma_set_tcd_to_le_c(_tcd, _val, _field) \ -do { \ - switch (sizeof((_tcd)->_field)) { \ - case sizeof(u64): \ - *(__force __le64 *)(&((_tcd)->_field)) = cpu_to_le64(_val); \ - break; \ - case sizeof(u32): \ - *(__force __le32 *)(&((_tcd)->_field)) = cpu_to_le32(_val); \ - break; \ - case sizeof(u16): \ - *(__force __le16 *)(&((_tcd)->_field)) = cpu_to_le16(_val); \ - break; \ - } \ -} while (0) +_Generic(((_tcd)->_field), \ + u64 : (_tcd)->_field = cpu_to_le64(_val), \ + u32 : (_tcd)->_field = cpu_to_le32(_val), \ + u16 : (_tcd)->_field = cpu_to_le16(_val) \ +) #define fsl_edma_set_tcd_to_le(_chan, _tcd, _val, _field) \ do { \