From patchwork Tue Jun 13 21:31:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 107556 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp838893vqr; Tue, 13 Jun 2023 14:39:09 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5j/3zjC0ib8kztCYHhJNW2o6FcIpsW1E7eOW7pq897ylgqO2uhraUOTl+1NfCYlbAJbB6l X-Received: by 2002:aa7:cd95:0:b0:514:a0a7:7e7d with SMTP id x21-20020aa7cd95000000b00514a0a77e7dmr8113615edv.1.1686692349141; Tue, 13 Jun 2023 14:39:09 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1686692349; cv=pass; d=google.com; s=arc-20160816; b=JHqzSknmxIJzb4qNbK3+j1NhyNeH7kRnuP/74Ztl694/O+j8fuDQKGEBVAvK+Y0V/4 X2woGEAGqfzACAAUdXH3w3aAT1h+s3ISWaPtwHlHWKm87t+PzuSPWFDc4PnxqIul0tsR 63/d+ZnHwn8PdIQY6ImLEIlnMGlm12fCKwfcwuV2fqg6sED6QRiW/Fmmqfn2+tb1wfVC DMwNc2qhsqQW8EZd/Dhx0yrRW+odi099kOcMpr6VWm4V25pJxz/RHt4Uss39CtIVpL+8 qEkhf7chRwQFNygkUMHfpUYXyuhR32FD+uHFGXdqiLEl76jbU/4OQuk3g7DRDiO5TnOE +3ZA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=s1+6nOaISVZ89Qy4+Cr3cnXLzqMpnDganBMJUwxpjWY=; b=ohbJ9hFDUYdz99J5UQmcoF6AS/uMO32rVmKzZVI81xcrlLZBNSiTTjOEz0VI0EvM1G 27jvTG8vwXAvMwfqzDSWcYaViOXSneCzjjwOmw7UQ95iB0QeiCAcMkAVfuJhoQ9oiZSx Sk2r+Amkgay7bs921uhhn0yxK4LnTnLMUaeLM1ezFycMlm9rKI8rmA65ro81MLs/N4WM C1L4t0ns/He+s3dS9FGJF9KGa9VhuFThTyuhBIlmiyXc5KGyKk4tur2X1Mj7u64aRCTW PNnSEAH37aQ89Zs4VTDHH/KGhbmmosmdEdfLyQflhqcg7sMS4l+uXr89QFkaWQCzl5Ld 67hQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=JIgA5PXi; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k22-20020a056402049600b005182dc07707si4772981edv.10.2023.06.13.14.38.44; Tue, 13 Jun 2023 14:39:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=JIgA5PXi; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240740AbjFMVcq (ORCPT + 99 others); Tue, 13 Jun 2023 17:32:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37868 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240543AbjFMVcc (ORCPT ); Tue, 13 Jun 2023 17:32:32 -0400 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2045.outbound.protection.outlook.com [40.107.22.45]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 803131BDA; Tue, 13 Jun 2023 14:32:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aCy2tEHFLj+40uHRvdyPPIih71WIBv6MjNaxhSyGn//WqlhChloCDCfZ2yufghezPgl1a5epfm6nJcb2kGC2SrI5rJtaD+M79WrZ8QbcSxlewCjXOrWY4P3ZST8NwJTERQmThGqRyMbtyGD6ga0irdiXPXiHzt67nNeLPEHzRpwasXpTE7z0NzOAqKyk/nsQThGKeqfJ4qntWWuitzORnXYVlzrFBUvVZsF4ozrRnG5yAkx9pZlo27Pt3dZ/XCbAOIXhcNcyvXYWH74BybmRNqGl3ffZvE5xLBJO2aB4Z/acWsjlXrCLSqjwPe0C1Rjqc0ukp4uif2IOYfBTkMoJZg== 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=s1+6nOaISVZ89Qy4+Cr3cnXLzqMpnDganBMJUwxpjWY=; b=k/SLl93AyEpw0Zk7npZXBqPedscSpXs8oQvKlldYrEYamUiiySRsKNzwdffk609gp1K8HD2heBDVOP7PY5JNCvlJ1G/3YAzg6RO07yE4/lBIeSa6/99uuYNx1He83zN3GXkCfkg6M9YtxsISm9bLaf20fNM3ySpqwm198Z2sQa97/PIA5r/jDR0gfg2vtfPOsdBmlPuBrmYWbAzD62dEfo2pKOVUlYB3fdJ65jaOiMyc8BcV+ZVN+mLDgO6XgLk59lWw4PdWkc3o5Z1/CivqMbpvYLu1wARI/qErkda4+TpzT+IF9tRP1K0gkccB3pxxZe6GZSG7yx6RePuUoX5U5g== 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=s1+6nOaISVZ89Qy4+Cr3cnXLzqMpnDganBMJUwxpjWY=; b=JIgA5PXicYADmHeKOhGiLCcHdrfgqI2plzTxfdJoyocTng7hRkJIVVHtHp35uFk4QZdh6pjpTQLKqTYjPJrMmk/XZ3JfoqokIyoHWO0bGtb+XR+JJlCcIPGF8zZFTXiS6kCBp0aQ/Dq+v87dCce1Zks/jR2xSf/hTD5BmDCFesw= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AM6PR04MB4838.eurprd04.prod.outlook.com (2603:10a6:20b:4::16) by AS1PR04MB9479.eurprd04.prod.outlook.com (2603:10a6:20b:4d7::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.32; Tue, 13 Jun 2023 21:32:23 +0000 Received: from AM6PR04MB4838.eurprd04.prod.outlook.com ([fe80::4a2a:262e:415f:e41c]) by AM6PR04MB4838.eurprd04.prod.outlook.com ([fe80::4a2a:262e:415f:e41c%7]) with mapi id 15.20.6477.035; Tue, 13 Jun 2023 21:32:23 +0000 From: Frank Li To: vkoul@kernel.org, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, dmaengine@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, peng.fan@nxp.com, joy.zou@nxp.com, shenwei.wang@nxp.com, imx@lists.linux.dev Subject: [PATCH v5 06/12] dmaengine: fsl-edma: simply ATTR_DSIZE and ATTR_SSIZE by using ffs() Date: Tue, 13 Jun 2023 17:31:43 -0400 Message-Id: <20230613213149.2076358-7-Frank.Li@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230613213149.2076358-1-Frank.Li@nxp.com> References: <20230613213149.2076358-1-Frank.Li@nxp.com> X-ClientProxiedBy: BY3PR04CA0003.namprd04.prod.outlook.com (2603:10b6:a03:217::8) To AM6PR04MB4838.eurprd04.prod.outlook.com (2603:10a6:20b:4::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM6PR04MB4838:EE_|AS1PR04MB9479:EE_ X-MS-Office365-Filtering-Correlation-Id: d1f709bf-0787-47e5-2a0f-08db6c55ad37 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: cFMz0K7jMGVoTDP55L4l2G45vmlO5fTUmSEzVkwno+Gd+avXSGEnG+dDAmFOG3FSZxhutc1z/3sQm8J7G+mdEiH/7PBeBKoGTJ4rbEbvkOHFsG1Z62rWXfGvF/nSFEXvIXQDFXE9GI2T2ui1IoBFhyTMtCfvQJpU/0kPtZ4yKfqbKwkFE73DmswPR0qTQQHeQIRUAgsIy/g/L+WQoXbiW95R4rXbqKn17wW6RmQxcPGlZFeCMA53DzB7f4LO5IaPSG3QGhvliJBxv9oDm/qPU8vVwcLdNZgKcoPK+KwlwkX5f7mFzJD8Is85/XJyvDVh5M9L0lIArCXy+BBLpZxm1NzRLu474WRwaMEPY82dCs8yMIaZFIZPXILbZz2o6VmZ/fpzb+8KznDLcl9X2k/1XzQaTGA7LW722SNLA4KwqgNV3AjBufurieBlDhZIKT+5ZPH5sz8W3vL6FOsWNyd/Y3f7iGUYVFQQpK3yY1NeZCwAJskCAociqsjwV2vn2i5m4vyYJSUAqwBF07py+nTAFfOtO2VNZKEjNPC2rheZktdRuBCbZaXPa2T8iPkJAcxlNgAiob9dUK9VmQjCsk+WkctRN5On0rhys/ohV9r97AnPmPW9Otn/tA/pN23nExce X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM6PR04MB4838.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(39860400002)(136003)(366004)(346002)(376002)(396003)(451199021)(2616005)(36756003)(86362001)(66556008)(478600001)(66946007)(6666004)(66476007)(316002)(6486002)(52116002)(8676002)(41300700001)(2906002)(8936002)(5660300002)(921005)(38100700002)(38350700002)(186003)(83380400001)(26005)(1076003)(6506007)(6512007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: rIDKMIKIlGWH9S4kvPvvrrfq+Tlh1Kuk+L4gOh9SPAcsYiUfwN51GbRXeiSjKLAx+xIUwvYO6hFJBUbi20DB6syBXzruGWHO0k+iA8OTtAIZnnLuQkYGiuqNkO11Ozc/sQmhlJaek6VxZqIzJkaagHShkA0DOQWvNkbNK39eHJxoTiJAAiPwzbEev+lnEicYh2wnbB6QcIVpljZb248psc2EPdrJ+HF8pFSP5gnCuOUSjzzMxPe7bV0WrmT0b8Fdn5gNav4do03+zHsM5gvCNQ4OLlnF9ccZ6vEHrhfqxHQ5ZPUFyV5hXXEC6riTwBpJoCqjwgomWEQCPkbe3loIWk5+z7APPEBP0JLnJOD7kJNIxgwHBj8KFAnG6tiUy4ykL1btFuZ+OFnQ8DhQtaIc3gb8q6FQLYedrhWqsSHEv6xH+TysKB/mPapazGvio7pfmtcv6zqLhmboLuUPExakdvUTfbcolRAmiLbiFYeaKQth3117Vss1qsb/oR93zuH8hBQ+n6yxUcYtoECWCV1nmTsOgA0onjQ9K1mEenzj8CgNuDUrr8PS4J8oOpJ5/jpvYqPLb3H6K4J0USkRl0RqHERvgZ5cQuMRySsNQUtwhBjc2TAxXl+MPRXl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AM6PR04MB4838.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Jun 2023 21:32:23.8442 (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: wAqWH6VmpRbU/EHhKoQo/tVGPvyQMuqF4s1t/BU9rW6rzsEkRl8IZfe+Eyp2i0+DhKoqvV++eTsC6ol/XLxLoQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS1PR04MB9479 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768625116550673088?= X-GMAIL-MSGID: =?utf-8?q?1768625116550673088?= Removes all ATTR_DSIZE_*BIT(BYTE) and ATTR_SSIZE_*BIT(BYTE) definitions in edma. Uses ffs() instead, as it gives identical results. This simplifies the code and avoids adding more similar definitions in future V3 version. Signed-off-by: Frank Li --- drivers/dma/fsl-edma-common.c | 21 ++++++++------------- drivers/dma/fsl-edma-common.h | 10 ---------- 2 files changed, 8 insertions(+), 23 deletions(-) diff --git a/drivers/dma/fsl-edma-common.c b/drivers/dma/fsl-edma-common.c index a9d17cf142fc..51fbd7531c74 100644 --- a/drivers/dma/fsl-edma-common.c +++ b/drivers/dma/fsl-edma-common.c @@ -154,18 +154,13 @@ void fsl_edma_chan_mux(struct fsl_edma_chan *fsl_chan, static unsigned int fsl_edma_get_tcd_attr(enum dma_slave_buswidth addr_width) { - switch (addr_width) { - case 1: - return EDMA_TCD_ATTR_SSIZE_8BIT | EDMA_TCD_ATTR_DSIZE_8BIT; - case 2: - return EDMA_TCD_ATTR_SSIZE_16BIT | EDMA_TCD_ATTR_DSIZE_16BIT; - case 4: - return EDMA_TCD_ATTR_SSIZE_32BIT | EDMA_TCD_ATTR_DSIZE_32BIT; - case 8: - return EDMA_TCD_ATTR_SSIZE_64BIT | EDMA_TCD_ATTR_DSIZE_64BIT; - default: - return EDMA_TCD_ATTR_SSIZE_32BIT | EDMA_TCD_ATTR_DSIZE_32BIT; - } + u32 val; + + if (addr_width == DMA_SLAVE_BUSWIDTH_UNDEFINED) + addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES; + + val = ffs(addr_width) - 1; + return val | (val << 8); } void fsl_edma_free_desc(struct virt_dma_desc *vdesc) @@ -623,7 +618,7 @@ struct dma_async_tx_descriptor *fsl_edma_prep_memcpy(struct dma_chan *chan, /* To match with copy_align and max_seg_size so 1 tcd is enough */ fsl_edma_fill_tcd(fsl_desc->tcd[0].vtcd, dma_src, dma_dst, - EDMA_TCD_ATTR_SSIZE_32BYTE | EDMA_TCD_ATTR_DSIZE_32BYTE, + fsl_edma_get_tcd_attr(DMA_SLAVE_BUSWIDTH_32_BYTES), 32, len, 0, 1, 1, 32, 0, true, true, false); return vchan_tx_prep(&fsl_chan->vchan, &fsl_desc->vdesc, flags); diff --git a/drivers/dma/fsl-edma-common.h b/drivers/dma/fsl-edma-common.h index 242ab7df8993..521b79fc3828 100644 --- a/drivers/dma/fsl-edma-common.h +++ b/drivers/dma/fsl-edma-common.h @@ -29,16 +29,6 @@ #define EDMA_TCD_ATTR_DMOD(x) (((x) & GENMASK(4, 0)) << 3) #define EDMA_TCD_ATTR_SSIZE(x) (((x) & GENMASK(2, 0)) << 8) #define EDMA_TCD_ATTR_SMOD(x) (((x) & GENMASK(4, 0)) << 11) -#define EDMA_TCD_ATTR_DSIZE_8BIT 0 -#define EDMA_TCD_ATTR_DSIZE_16BIT BIT(0) -#define EDMA_TCD_ATTR_DSIZE_32BIT BIT(1) -#define EDMA_TCD_ATTR_DSIZE_64BIT (BIT(0) | BIT(1)) -#define EDMA_TCD_ATTR_DSIZE_32BYTE (BIT(2) | BIT(0)) -#define EDMA_TCD_ATTR_SSIZE_8BIT 0 -#define EDMA_TCD_ATTR_SSIZE_16BIT (EDMA_TCD_ATTR_DSIZE_16BIT << 8) -#define EDMA_TCD_ATTR_SSIZE_32BIT (EDMA_TCD_ATTR_DSIZE_32BIT << 8) -#define EDMA_TCD_ATTR_SSIZE_64BIT (EDMA_TCD_ATTR_DSIZE_64BIT << 8) -#define EDMA_TCD_ATTR_SSIZE_32BYTE (EDMA_TCD_ATTR_DSIZE_32BYTE << 8) #define EDMA_TCD_CITER_CITER(x) ((x) & GENMASK(14, 0)) #define EDMA_TCD_BITER_BITER(x) ((x) & GENMASK(14, 0))