From patchwork Fri Feb 9 21:36:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 199126 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp1154409dyd; Fri, 9 Feb 2024 14:02:11 -0800 (PST) X-Google-Smtp-Source: AGHT+IEbUD4trGlY+5RWKzUx2oxYd8rR38/6n6B+8X438YG/zpvP21Iazwr/1h/JlmM7MYxAtrMR X-Received: by 2002:a17:90a:17af:b0:296:2f5c:61f6 with SMTP id q44-20020a17090a17af00b002962f5c61f6mr379210pja.38.1707516130838; Fri, 09 Feb 2024 14:02:10 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWGkGVbwbhxUDxgwxcVSrWpYD3QcBe17hJBSYWDDwFKp06w9CEyaYuzjt09DqwC1nlDO4dlcLZ/355hRN05mY2AOSL3AA== Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id qe5-20020a17090b4f8500b00295dc06ddb6si2343232pjb.129.2024.02.09.14.02.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Feb 2024 14:02:10 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-60039-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=CO+83cQr; arc=fail (signature failed); spf=pass (google.com: domain of linux-kernel+bounces-60039-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-60039-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 25450B281D0 for ; Fri, 9 Feb 2024 21:36:52 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 64ACD22619; Fri, 9 Feb 2024 21:36:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="CO+83cQr" Received: from EUR03-DBA-obe.outbound.protection.outlook.com (mail-dbaeur03on2047.outbound.protection.outlook.com [40.107.104.47]) (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 36C04168A7; Fri, 9 Feb 2024 21:36:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.104.47 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707514585; cv=fail; b=a9Wk29TZyf0hL5ySUdc3wB3SwczrNNwKXIuVxCnklhx7SYLHCo+w6IRLpozL7DdYQ+Et7SDPg69yIscZM9lYX/UBerdRgwsRPQ8xHyLmEkJ7FAMCkpWwLSWdphiG8X4g6dBWnERmXlhT8FEpKF6ebJmiyRtes6mSnqyuT57Qzng= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707514585; c=relaxed/simple; bh=qxQHYPj7E7f1TTgAVbrbHCfdJpdOq8D88t/Ncyq8qbA=; h=From:To:Subject:Date:Message-Id:Content-Type:MIME-Version; b=NJt3v5RdDdfakeyIKqcwOGaxMTnjoL55Q74G0kxmhwYkEhZrMNx969ZqTurzpn6DtOJ607rBTpBn3dugalw8JJyIfZffF0g9CAbfZIQhj9uJoj4QaS5T6MZQfChJgi1M4eQOZL1+rq8ELCR1zkFGlvbPuAVy0iyzf5etG1d9aMY= 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=CO+83cQr; arc=fail smtp.client-ip=40.107.104.47 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=SWUXwxC0cZNBWavGIqZt5hDR/l5S1qcMIq7Q9JSAwaKgoAZQlJfSyjPw1xSemj9WxwdOeLYf4BdzgkW03VCY7sp/IEx9G5nkwgs5TX7ClSERKtaFzVIMRY1127uBTmXryqmR9pFcDgUS7afVMjur2FE2HP4Ts50Bx4fy5HhuBOfAnhuG4RHIaxG54FWe0TDAvPe+KUmskVjPQmyoknjr8OuH3jTxkp+VhQa8yP/HlFqyGAv4XTG02DJ8PeeZaDTQniICs1Zv25kHlFtJERGhbgHK1NxtG+AJY7UfPguKN3vxXviH0ftRdg9ftiEZ5xOXPN87T3ltjcW7+w4mMTStRg== 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=UzRzNodc/JzqZ6d1EDYnhaM+zHw8lDr/c/NJZvxJvRgbep4uDWkuqdecCL01gze+UHQsP6hqGpy+zVsAYt7r+FPV7gQrH0dqUvmDCIuJ3pF7r9l3uKUeBjgoAWxbFeDTrL19udDXQ8yKZ4LSvO2PQKfai5K+H61SRavURJ2CfUB/8AuaidGTldj3cPCSyPKPv3fCZxUg0qW8MlWmfa21Ep84yGKhcj8tNAkL6whU1rWZfEqhk6ioVjS6jJmLFgOFRgqshtosEDZfazvshn9SbXLQ0jjllWpzNtYWVe4Xs2k9a1CoWk9hOuTjqHK0faIIq07GEgIWMoHAwiipGH6ttQ== 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=CO+83cQrQ4DuyVWU9mgYLgTQ0WnQgZYUsRlusCZgrbDGUJ5Xh6PXwc3ld08Mt9qp/in83Zv9dYSHRnVjGVbbHIgxXVVbvyZHUvGlKcJXAKb8zG/K8BgJI3L3IKV5k0971psnirNdI0rzYoI1Ha+NC1XX3Xhax2mlHOFfy42wepk= 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 PAXPR04MB8800.eurprd04.prod.outlook.com (2603:10a6:102:20f::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7270.27; Fri, 9 Feb 2024 21:36:20 +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 21:36:20 +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 v2 1/2] dmaengine: fsl-edma: add trace event support Date: Fri, 9 Feb 2024 16:36:03 -0500 Message-Id: <20240209213606.367025-1-Frank.Li@nxp.com> X-Mailer: git-send-email 2.34.1 X-ClientProxiedBy: SJ0P220CA0021.NAMP220.PROD.OUTLOOK.COM (2603:10b6:a03:41b::8) 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_|PAXPR04MB8800:EE_ X-MS-Office365-Filtering-Correlation-Id: 1bb04aa9-eb9e-4b10-c121-08dc29b72777 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: pwhIFm5f//HROANjmYllesTkITSUR8E2rrvMw23iy+Z77E6aXVxaYou1qhb7HRwo5pJ+t6LRrFQkzsMF1gczfJwh92zcqwr/X7M/NdnJhAeGfe7bNUeNiFZYliew3uKIkVUlDA8siiilQ0GjpzHwld5ts45pFuRgO/K2694L8FjJ2UugCqe2Gi6I41nhzE/e58wcXCL4YI61l1Vt7e6bYYz5iyF06Fb3xWh2PFAOsWGjt+zVRGisb25QeDt/z9uVbfxDpBcaG7YueLucXEH9tQDObk+HVM2bksKtARQQ0yB9XoO5dbN6JkL6BuFBmwO6xeXYIZimKibzHIWnz5hS0emjBij261C3spG60BBywoPhDe8g0WiZz17A/1Gm0lxoxeK7gVY4p16DYvkYQGGgnWkOKaazswPC70TdOp4niMIOt0d0Hp1Etq4BSKv9I4FBb3P1D+qi/M05R6o/jhTGVfD/VDW2QXjXLsag08W1ztVQejmv6MKU9kyonwJOuEa0GCmEMYik0a4CMlSdqoo4oHq1VFh4qlBjH5ieUQzeVEChNPOxj37xRJj1M4nJh28mIrkihtUx38MtYJ0jocmguomxVPMvRwYNiuASHef0A7ufCpo9YodPMPFylKev6/Rm 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)(376002)(346002)(396003)(366004)(39860400002)(136003)(230922051799003)(451199024)(1800799012)(186009)(64100799003)(5660300002)(2906002)(41300700001)(38100700002)(86362001)(478600001)(38350700005)(6512007)(6506007)(6486002)(83380400001)(1076003)(66556008)(26005)(66946007)(66476007)(316002)(36756003)(8936002)(8676002)(2616005)(6666004)(52116002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: zIvQEe7XVBlFvDlF1REafip2mtP7xlkE2nf9xH0ROpv5QHhgp8A34qVK14X7RBg/dmmTU9tHtBHtCa1h+uUfXJ7S0ABPfQHCSoVTefMnARdX6tccSNipL1qff4nsyZxPnMiKAZEEZfuTjDfaF3wGtkXnly89UL7bC6zsDIk7u14+6BvXdjXtH0AeZ7wu5u12rcGhT/inI/1rGUY/K1Jz3eUR0T431birOvezx70uyEAeo0sy/xvwdUQuLodsqXv1/8apmT6GIolEJ8TndWtIkBw8zRyXUX0oSC2PHOcZQlSsE+ciyI3v51Tt3Bz4wOboyaM951blft03T7+Q+xvJZBS46IjptqVG7hV9krYQkvIQrm09E8fHYN3t5P8LB0Ppyjn+ixfM81SNr/+MwnCYKwRKvv6KTckPYCJZQclb5MlWuXQsOl9+ODOEc5wVfDkyVEDdxQfsWeCFkeSsrog5O818j/zAjm95y/4/I/pffzbrJymxcw/92UIIJD0ByAXvY9ksSluYvKsiPiJaJGIkDitbY3wjDd/7LAHeX/uzE5KCi/u2E2Q1RiVaL4PcrSV3qQ3OEwn/cnEJY4lDJBjoNY9XYVzawfJmrcG065ikunie6NfCcIHvAicY3PzgscnlvHMoiHwR5V6CfjNw+3j0bqWO89TGT3JfoC3VErFH/1VF8TgF3129+Gq6jcusX3ywAeIiTxCh+es47MGrnrW+SVA/Yt3neNn6fKffSfupeTFGVIkpro4EBTuNJKTokAosURNyCaE3GYvPQl5JsEg5SSz6ukSJt6JowcsFodbr1yvADAgVz7L68pJEXtNSFbtQdggLOAkzE4qYyp81peAVeLxxuEUfbK6jvw1LGgT261/YBf79qgqhoE7z7ZTZCAzoz2FIqrVerrJszzUHtxS5sO1x0JE97cuLQA+V5DZu2nRJl2u7yYYLhgQLz4DZzBjoCaqSFu177e5spcdKuZugDGQ0rId/3XmbBKuDetI2r7BYoqY5mgtcQhnwnURJO/Pp3txDehcJKW2M58Fh9olafWBcF4vmIxMaVRjJ2YWLQv9+UIN5bF6CJoAuAe+UR7SAB0TMbhSxf4/Qx1AZvC1AVU4D5ZllSdJGxjPYP03qi9P1GnnUArsdZQuITuiDnkhr/hvwQDv9S0DTQrl/gS94R408urGQSOwa01WFvCGZYLYYW8KHQmX+XFfPpsgUePzBWXPsxh1e19HYdFnFSP6bMhJMH4tfzZoEyjF4Nz9XIE+xewJYL320vNeaHnOT9oIvOkynR5I+qbyatK3Siu2fom1tbWxJNEMySNNsnKFG1WSJ6kKRJkPvWshTIcmhcTszP+u1UYqnYmzyhZQoHPl0LgK3if8NfrlJUURs0yqrMZzTafrXOEqGE4KvEhGzDj62++6QT4LpBWFD5TVQUniMW69JU4zkK1tySE5Y9rEi9SZi69qJWbLzT2nYc3KAmudSavYUUuko1d8LASDulGTUWAoe8hX9EYrRPYY/clSgoQSzpXRLjbYduzVD7gRh6nY87+XiKZUATMhhkfzea79MhS1cxczYWbjQAnD/vbm9Nn0= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1bb04aa9-eb9e-4b10-c121-08dc29b72777 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Feb 2024 21:36:20.0332 (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: 5Hq/eWsgk5TyJmTTkEsbpWWfD7hEoII8k+4InkoX6tohQLvkEzwh8RgIpfBgR+KZ9ByAz3LmxxVcG0sa+9NB2A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB8800 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790460434702223137 X-GMAIL-MSGID: 1790460434702223137 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 21:36:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 199122 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp1144430dyd; Fri, 9 Feb 2024 13:37:15 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCU5RJkPyZ1COEfQQ22evUDiynpFFf/TBZiBczMMpX8LFZEoH+QgRuz3oA8UZjJgI/LCqEDHbeqqcTr0+6WL+tOWF44Xog== X-Google-Smtp-Source: AGHT+IEUAECs9GvGdQWL+hEiqrxpK6f6mUkyogfgRsQbTwhMVEnCLhDWt1KcWEoGkKCoLC1kzGbn X-Received: by 2002:a17:906:2988:b0:a2e:ad24:da8 with SMTP id x8-20020a170906298800b00a2ead240da8mr234891eje.19.1707514635518; Fri, 09 Feb 2024 13:37:15 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWKVhsINit5oWRAvgqJSP1G868clAhiKcGFH/o4/x22cuC6e1gNyv4kOgRj4EQApYIC+nOeKEp+hphRavZ6k3RhV7ggRA== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id kf23-20020a17090776d700b00a3ba6fe0851si1192289ejc.867.2024.02.09.13.37.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Feb 2024 13:37:15 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-60040-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=HcbP1jmY; arc=fail (signature failed); spf=pass (google.com: domain of linux-kernel+bounces-60040-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-60040-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 am.mirrors.kernel.org (Postfix) with ESMTPS id F15A01F23229 for ; Fri, 9 Feb 2024 21:37:14 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 49BDE36135; Fri, 9 Feb 2024 21:36:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="HcbP1jmY" Received: from EUR03-DBA-obe.outbound.protection.outlook.com (mail-dbaeur03on2061.outbound.protection.outlook.com [40.107.104.61]) (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 699EB1B268; Fri, 9 Feb 2024 21:36:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.104.61 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707514589; cv=fail; b=Uq0EuL7W1Hdcj8QAH9oypCcSz/JujuuThgmnvjZlh7icCzCb1oYiCJZDLTBQlUZmoekrj1DUzlvYMX95IlJiHnBF8Vn1oRy+FCzz5uI9adg+XKgpAQePCG3vJVyjvcq6zuiUvZE6pPFbEdtWdi4O3qNpYCE+f39ZOxdyp8w46WA= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707514589; c=relaxed/simple; bh=GbaRWCp2XVRkw+90MR10wsdT8RAC20inXAGjN/iPJ00=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=t0lVwhnjXLAFw2unDKEWJd/jeuGb0C8HeUoTLjFLoUvtdToKXis1+mdIGoKo9dL/wVVFa/nlqBNanUX8m2X+YW6B23XNX4V+S0kwEdxbDoOott3+GBmGPn8MR0VSqjJy8U3IpokTFfFxj4e55YCWM0dW132gmn2EUDjVXWM0ReM= 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=HcbP1jmY; arc=fail smtp.client-ip=40.107.104.61 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=g8JUdxa9rNo2/ZEdbUGOfHIDHjzmpVm2/Zrv41YIgQVbNnTofJ4yK4cquc88M5veHQuOCE6Z4ieDJoBuplc+059WSmiU6cdIoIFoDPW4Ycv+FbGW0HK4zJeFN7Ml4chERaRB/vaNmDzQNHgFVB1lPE8tmg6smpuyrW57ksr8qOWLzzElGgONaHE3+9NQJzlzOYbg5N8WHVoOiKzYczGj8g8zbVX3kZxx3Ka6/AzIqbq02o9vzkNRchkiGHlaThEUFxyC5lgXTwRR9RYXmrNkUiLCy6aHqfGDMqfx9hxX/7DEjxbmZ3NmAaTvcx8l5ffPHGeYmhHPHXqQchloV4c9OA== 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=YrP2/nQTL0M7B4BZ7DGiXO1mITOdYQ+1nQszWsa05pg=; b=j5T0CWIayPaUJv1a5/uAMnzOhSsYwWNHCs8azneL3lS3IA/Egye4cD4zQeDjYsGu/Tk+0zK5icJxjvL7/QOGVwxzj4EwyJ/oSmnLB2nekZnC0CQO8GIU5as6MnWreLLAg7GQkozesXJzeX6zqIT5t28M+FqKExqUNEb9nBveD894JN2lwcKjpt24x+AaSpAYLbolASgVEUuWSyMHGBju2JbqL1WUD6oGuNT7FzbMJP0GEqGgpo/TNxN1L7gajRRepl9iVPVuYcQolfgeH+BSglmcEE+r+RGQk8s3evTvCW1OSHXDeBBQ/snC9g41dJCBk94qxdEhRNK/4Ji5o1Sxdw== 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=YrP2/nQTL0M7B4BZ7DGiXO1mITOdYQ+1nQszWsa05pg=; b=HcbP1jmYkjZ7lZLtc0eoPhGmKf4pxBSR755zkHh4NMsQJ3C1DAi4xz0/5E7YZC5TDgirS2OB2068yNZ3toJWmsl+ZFVZ6YsanQZZ6p4AdVKljdYiY2TKsd0boRx1AiJSC35G3rT2ZRGykEE1tsddGJjZNlHTWGLxPhlW9/8V1Y8= 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 PAXPR04MB8800.eurprd04.prod.outlook.com (2603:10a6:102:20f::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7270.27; Fri, 9 Feb 2024 21:36:21 +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 21:36:21 +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 v2 2/2] dmaengine: fsl-edma: use _Generic to handle difference type Date: Fri, 9 Feb 2024 16:36:04 -0500 Message-Id: <20240209213606.367025-2-Frank.Li@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240209213606.367025-1-Frank.Li@nxp.com> References: <20240209213606.367025-1-Frank.Li@nxp.com> X-ClientProxiedBy: SJ0P220CA0021.NAMP220.PROD.OUTLOOK.COM (2603:10b6:a03:41b::8) 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_|PAXPR04MB8800:EE_ X-MS-Office365-Filtering-Correlation-Id: ad64102a-d4e1-43f3-3795-08dc29b728a3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: PPWZmHxlLSBktIlsC+IqZZUcKzORpXIEYj9s93+PqvfXyyZBq8z4MoOvA09QRLD0oPcLqHR5fm1luQCpsCSpm3ivx/EDq79aynYhNN7AEV6tfq52mtuT6M6cW8BCaRSDaBbKvB15rJ1tb3A6vuKM99DIx5j1y6TF/zYi0g9E7kqyqpZN7Nw4IXBCZoam726oQ7qDR5mZUo1EMEGXQZAel4kwDV1myJC1HWHFS9T2Cgf4Y2XuzLQ1FQvfxgv+FHRT88XssI+1xAYOdwQxeI7DmiWj74zaMw9NkfJR+Lfr90aknB/j4UrxVoiVO7Son6nCovqYy6fpG7rP7D+18BIWk81JmbeIj3sM+HzqpRQfSh9+hslm022Yfpx/6jm8Ue+UhsPPAlvQd1SURrqOExzm2uqbPL6cfArc4sqpCAQVEpNoggKcl4CFOZf3v+OFjfOFupoHHgzOeKSn1HvSwskLRdPVFNmqXOQ4Cj5Sph/g0hyOte12bNEVd7f28BZtdPVucIflgaRrefzbdNO5h6Hp0b/4bqYvfz+IkxfHPeh2BkBRfPgXyPvpZ2sKQl/74d3ZS59wawygnsLEZVKxdJ0/vJvqpe3ORrSE3bw/B1MWe2iDJgBPHUML536Fz7pQn5Ic 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)(376002)(346002)(396003)(366004)(39860400002)(136003)(230273577357003)(230922051799003)(451199024)(1800799012)(186009)(64100799003)(5660300002)(2906002)(41300700001)(38100700002)(86362001)(478600001)(38350700005)(6512007)(6506007)(6486002)(83380400001)(1076003)(66556008)(26005)(66946007)(66476007)(316002)(36756003)(8936002)(8676002)(2616005)(6666004)(52116002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: dxZVB4l0K7L0+DbAHWT2veJIeeIpBKevvTJdnJ3EGv28aP58LXV0X68JhPoAlSA5nIgL2PhfYVPEbmJqw7/dIi9fZwJu36sMjm2Ww4b3GIs+Ct5uJSMEA9hts1cxlcECGzOq6n84bt2HxCkpm3fARegpfyOpahZRT5SUsUU8O+0Ss3J2YOURQG6H7gf4nhqwtHm9tR28DiupsdbibeNCb8kJeUEKyc3aaWXvF+nhzQ7/QxIkx0T01lwvMSej+cRKpmnodGsbcasCGWKAaLETuHjnjrAGOF/c3bZNmZ9eklNBMz2monyvl5JqhSz57/J9UxcatoTHvDi55UH/jxqMe7feKZrsi6TNzlP/sIu6qzlvEDnbYfgiCyHoQgMmX/+MixU/JzP2cIwiLC7aGOjWz+ItBXliuCAF3pFUhRaBdGMfvnEZEr9NoD9KkiRiFf/fVm585Ct2rlE7VvGQaWGc7k2zzREKVDN6/FLcVD7lAW6omeiHlGqHG/DbZs9mN7l0682GzlSFTP07qBuy2A5/0qio34uVbraAvy98TTACp3Gua01ptsr5z+ggyg1S2ZvbTK1G+bu900Qo/oHkqioJEJYwem51uVnLY0GzYV5mxdh17daO4ZyG7ujKkPe7mawjh3O4wFDM89yf8VqonH9uEc5Zcnpn/Q/dbIVflUxrfgol6bkV/n/3Z6iWXhQDGkqi/HkCTBQ1wB+vwAv3xvvN3AkDwx+1bhDcxjK2M7KSDgZkgRDA5icvQuoYEvYx+X0ieK4aTDIDAKvIacPxNZv/9M//HFvaTlcxs5a4iVaMDkjJd/KKJPMPMNzI8/Sz9xzy1aI25kU7bz85f410f4KX0j9DsXNvbsR172CF8D9cFzxAl8xiN3oQffOKS8f0IqVaRTZtNk2Q1oaTzlSw98muMEsZnU/3VjPJ/OfdkL5fI5Mq35IyJzhPOKueUPhtnqrrTilvJchMiVnQUN4CoTgmRhyHHSRYQAsVcGb50UZXWXuRM0PngwFwV5mUMqggNIR0Xvhj8iv8/J9u8y8BtPeCOYUlxLTqzWHfQrYd51YY17byA2ky/iHhv4zOWmAx2rLvS1H/go4f33IjBbwiBzCgsmJnd5abFUwSWqG2liJzzRiKioIKE4mrQMNQpdTGQzCA8Do1rh52ZzyQIROFAZGhfEWZe7ce7v20wFCv54guFzGasMXG4+Zc3T2JWsQxM5wDDAQJIo8GKEDNEnMXjHvL4sOV6Yo7SRaTOts8VrBGuGhhA1/8+dfZMKg69XATEk7t9vE2XNV1p2a2+7pFoUeoTkb6TkYBEKcR4Q133pJTU5fJORoNDFBqFZMVrDZ98zscZqlfoXMgKlkDpEPTntbLsI9+rnZsLh/FKTjvu6uqtq7oVxIZM35P0yk+xk6Ofi9Bp2yADQ8cCvHpoJ8vRNf19RdnOTKF4Aie8VhSoLlruPcpN+UFZegxe8en81veazpgpiE4eOD9fQOLxRylXCjBbusR/brNx1V2MCEV0FKGgRHqiDP/3S2ImstixN6HGKGBeVK0fdnO/e30o5gsFG0M/Ug8Aw83ATbWPpj+4rhzqVY= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: ad64102a-d4e1-43f3-3795-08dc29b728a3 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Feb 2024 21:36:21.8865 (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: WyQrTJVvmTA2hqiSTvitVtZFD6nLytG/2Ze9aUCFVCbYUvTiwGPiMMfmerwSBIjsCJE0Yn35TM4eOXfh/Chnqg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB8800 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790458866482040699 X-GMAIL-MSGID: 1790458866482040699 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 --- Notes: Change from v1 to v2 - Fixed sparse build warnings drivers/dma/fsl-edma-common.h | 61 +++++++++++++---------------------- 1 file changed, 22 insertions(+), 39 deletions(-) diff --git a/drivers/dma/fsl-edma-common.h b/drivers/dma/fsl-edma-common.h index 365affd5b0764..cb3e0f00c80eb 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), \ + __iomem __le64 : edma_readq(chan->edma, &(_tcd)->__name), \ + __iomem __le32 : edma_readl(chan->edma, &(_tcd)->__name), \ + __iomem __le16 : edma_readw(chan->edma, &(_tcd)->__name) \ + ) #define edma_read_tcdreg(chan, __name) \ ((fsl_edma_drvflags(chan) & FSL_EDMA_DRV_TCD64) ? \ @@ -268,23 +267,13 @@ static inline u32 fsl_edma_drvflags(struct fsl_edma_chan *fsl_chan) edma_read_tcdreg_c(chan, ((struct fsl_edma_hw_tcd __iomem *)chan->tcd), __name) \ ) -#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) +#define edma_write_tcdreg_c(chan, _tcd, _val, __name) \ +_Generic((_tcd->__name), \ + __iomem __le64 : edma_writeq(chan->edma, (u64 __force)(_val), &_tcd->__name), \ + __iomem __le32 : edma_writel(chan->edma, (u32 __force)(_val), &_tcd->__name), \ + __iomem __le16 : edma_writew(chan->edma, (u16 __force)(_val), &_tcd->__name), \ + __iomem 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), \ + __le64 : (_tcd)->_field = cpu_to_le64(_val), \ + __le32 : (_tcd)->_field = cpu_to_le32(_val), \ + __le16 : (_tcd)->_field = cpu_to_le16(_val) \ +) #define fsl_edma_set_tcd_to_le(_chan, _tcd, _val, _field) \ do { \