From patchwork Tue Nov 22 17:21:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lizhi Hou X-Patchwork-Id: 24472 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2345850wrr; Tue, 22 Nov 2022 09:31:09 -0800 (PST) X-Google-Smtp-Source: AA0mqf6kTl0w9VSBF+iPcs2YTLY2sm3D3QOCuvG9VNhrQ6JzNGOAC3rIiBCki/VLXFw+oj9FcBHw X-Received: by 2002:a17:907:98d9:b0:7b7:90e0:da54 with SMTP id kd25-20020a17090798d900b007b790e0da54mr6487237ejc.298.1669138269074; Tue, 22 Nov 2022 09:31:09 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1669138269; cv=pass; d=google.com; s=arc-20160816; b=yXj8CZPpAznUApAb9FwfH2oKSQNC6a3witEaILy+p8rii+QgLxC2Bik/cMDfeohYvf SDxb59GUzAn+my4B5jdzDhs8/hWe4fiETGggcMaa7rQSLpDa2ofPTThmLlKhSKXLxo5y CheKQ3awM92ZqQMqk1gJYQ34l4/IBc+ejgWYA2i6gicO9JF9RSgAxW0fcoBjnunNhugD WS0ouLBvpgEGgf1ToTt5WXOhe1OXzS7exIIvQdKXvkFdalS8I4BeWSzwX0tok9CRIUL6 VgLFAeNNqBqty52m8TxyUDQBS7PNWiJMWTyMduh8zHgLxmvYvsjKRZ42d1+zKkOJtbiI f0UQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=IeDdJSJEF3gYwnHHfex6ipJ59QrEbcoDhj/sCah0PHM=; b=wgWVmVLPhJd+Ucv8PZbV8wFvoJTB1v0yryrjZ64+eyMwoCEMdwkaVAIDGz7bnKpatx SDPvfSINxctF6m/Hadu/QKQHB4thHNtWEaRaAoef+n43Iu3unQKc4+Z//a78NFP5RWnc yZr/uyvrKEzlQEDQOTEpCWhNyg78YUWWC3M2oJ0cv+pU6VIjze51UWFPvRfi1rZUk688 juqvjrhgPoXOoTiONyODi5gRZ4iQMcU0dYyv5abWYcbo6ZX08XdbqXBDQRkJINHDfMVj T0Jfwgconkzv/76F0VL2+OsZvd5xrxxkjCyjZwx0NaGCRF6GS3b33V9UXcKK8GMfGofx 1llA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=0ETvMk6j; arc=pass (i=1 spf=pass spfdomain=amd.com dmarc=pass fromdomain=amd.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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id nc7-20020a1709071c0700b0078266dc4b8csi13786922ejc.719.2022.11.22.09.30.43; Tue, 22 Nov 2022 09:31:09 -0800 (PST) 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=@amd.com header.s=selector1 header.b=0ETvMk6j; arc=pass (i=1 spf=pass spfdomain=amd.com dmarc=pass fromdomain=amd.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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234483AbiKVRWO (ORCPT + 99 others); Tue, 22 Nov 2022 12:22:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41336 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234482AbiKVRV6 (ORCPT ); Tue, 22 Nov 2022 12:21:58 -0500 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2041.outbound.protection.outlook.com [40.107.236.41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 523BD7993D; Tue, 22 Nov 2022 09:21:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jcnamv/qgQLkhmjJ9YVtsVV6whSZ79ZjyomY3tGrlmgREUbpjZuDC/dojxZ2AcNgYeBWXIRU7YC8Dz7HEgw6BNy0goHymfPdaCaJ+YRDklnmZ0qxdMZgOKP3PG8Err9AyKAuTAs+W4hqwzEynzflf1DWGPiLEPbIU5SCljFHWHdNzE99w468xKpQfEOxB3fQKzNDV+Vkc2MnBAlQh3I1AGxUjeObaoGSw0E+bd2IBmTHHghdCief5YnTVEZa5WiE5ovkjdFP8GGTJUMCb6IL3YJKEe9PgZTNMFXmMn0dE0LVu4lir3USTdfKqT54stARBdVlhtuolEmtmpGRkAe6FQ== 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=IeDdJSJEF3gYwnHHfex6ipJ59QrEbcoDhj/sCah0PHM=; b=MJhIv3pFssOe0ybGmhDgIt/KfUyn4xcByoNjNuLzezhBZ8o2xAc29GQaS+RzaH8llZTyo7lDAiel9qIrpXQku4CX86b3uB5b4v0Bg9KCjCi4L+Ir+PmYJszcucp5SKasMTPkSrceHLZsghUq6+/2TRzFKSktpX4d0gC4gNhpQ0kDCND3I7vI/xlMshFGpAHz5haz4JI3Q8Ns3kaj2LR5hJCUrY1pVy9aAlkWpkOpqn1f/By4b/Xe2wTyMruFzqXKp1XyO7oT/Ez2AqZP+eW6jMBgiYIbGP97R6Vd7f/0Uer+VjLCi2dYbQkPntbkMRfoHjwvCKVxRLW/8TaoH73wHw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=kernel.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=IeDdJSJEF3gYwnHHfex6ipJ59QrEbcoDhj/sCah0PHM=; b=0ETvMk6jGwVG2S/saxtHEEpFQSzEHsIm45tXL9MRq5uiRHXsJSpMZ0svomEll7swEOkMYdApKz/ytD+eN5TazpbqrAgKBcfTGuHsodssXOpojAon1dPOS1R7IBEOsKvkqeT2QSGR8oiVKDeDVd633yj8P3JtacMMH6alY3/yrro= Received: from DS7PR03CA0309.namprd03.prod.outlook.com (2603:10b6:8:2b::7) by BY5PR12MB4322.namprd12.prod.outlook.com (2603:10b6:a03:20a::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5834.15; Tue, 22 Nov 2022 17:21:55 +0000 Received: from DM6NAM11FT069.eop-nam11.prod.protection.outlook.com (2603:10b6:8:2b:cafe::3f) by DS7PR03CA0309.outlook.office365.com (2603:10b6:8:2b::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5834.15 via Frontend Transport; Tue, 22 Nov 2022 17:21:55 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by DM6NAM11FT069.mail.protection.outlook.com (10.13.173.202) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5834.8 via Frontend Transport; Tue, 22 Nov 2022 17:21:54 +0000 Received: from SATLEXMB08.amd.com (10.181.40.132) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Tue, 22 Nov 2022 11:21:54 -0600 Received: from SATLEXMB04.amd.com (10.181.40.145) by SATLEXMB08.amd.com (10.181.40.132) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Tue, 22 Nov 2022 09:21:54 -0800 Received: from xsjlizhih40.xilinx.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server id 15.1.2375.34 via Frontend Transport; Tue, 22 Nov 2022 11:21:53 -0600 From: Lizhi Hou To: , , CC: Lizhi Hou , , , , , Subject: [RESEND PATCH V10 XDMA 2/2] dmaengine: xilinx: xdma: Add user logic interrupt support Date: Tue, 22 Nov 2022 09:21:49 -0800 Message-ID: <1669137709-22028-3-git-send-email-lizhi.hou@amd.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1669137709-22028-1-git-send-email-lizhi.hou@amd.com> References: <1669137709-22028-1-git-send-email-lizhi.hou@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6NAM11FT069:EE_|BY5PR12MB4322:EE_ X-MS-Office365-Filtering-Correlation-Id: cf37abad-bb09-4cbb-6c08-08daccae0d81 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Os+Fz6w6enUS8bGNyh5LLuCUWrtOZ2VndY16vZBQPu4cNhUGKGm6vCOW/9JKXqn1btPCEvHlIiJ8d6QJhkeaRQA5ssUfDEQM8c7k4X3D0k1Xeyp6NaJU4XvMl5qkYo0BwhJOXbLTG/sx9VmJzQCxpxmMBeEKACeL30WtZzkxIGCAeRUH8T8CxrdpOkvHPmv8pr8V3kY1wpTBn4oW40wV/0SFpK2aOiX/+DZD4bn7jMAWKjrlKvPrrYh5AaY4vLJqmvXSGq11sHEl9RRsmZsFC4YZ2CLxGhPQa8Aoa00KT1UQBmaZYAsOUTNVBpD72rY368t3is6NWiduaAGRxdGX7Vz0Gfoq1CTG9P/h19df/iWBjxB25KJ+vMjjZzwFiHZYZmyRJJOtuHIesPEKMu9bsEu1NlbTEdUWWVsid7lNY4x3wsxFeCGRLbIAfn++Rp8JvzKvcfZBbSyiJeGu2CU5OthT6J6pJGLwKqXW5p6OxREwZPIKQ5uY4+ujFf+OMApSv8L3asHB1byCVEFWWgrSSxT1OlkPChAskt3AKIElyowc3OHyW503C692ZbFugm9zyOS0tZWePDSYBIk+AH5cv6/tgAt07mYyW6h4x4k5N0kQsbEzZVNkJJDQwpOW4I5sNsMUDuvh/+dKx3hA6jJjgczGa4Gr4iwB4r+bhB3YOI5EbusXEHJCT8b9+Dd9IGazzyRR05i2S6a85gTzoaJnccWaywUR+Dk3J6fysNBNapw= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230022)(4636009)(396003)(376002)(136003)(39860400002)(346002)(451199015)(40470700004)(36840700001)(46966006)(26005)(356005)(82740400003)(36860700001)(82310400005)(81166007)(86362001)(6666004)(478600001)(70586007)(70206006)(4326008)(8676002)(41300700001)(316002)(5660300002)(426003)(83380400001)(110136005)(336012)(2616005)(186003)(54906003)(8936002)(2906002)(44832011)(40460700003)(47076005)(40480700001)(36756003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Nov 2022 17:21:54.8682 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: cf37abad-bb09-4cbb-6c08-08daccae0d81 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT069.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR12MB4322 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 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?1750218329700194806?= X-GMAIL-MSGID: =?utf-8?q?1750218329700194806?= The Xilinx DMA/Bridge Subsystem for PCIe (XDMA) provides up to 16 user interrupt wires to user logic that generate interrupts to the host. This patch adds APIs to enable/disable user logic interrupt for a given interrupt wire index. Signed-off-by: Lizhi Hou Signed-off-by: Sonal Santan Signed-off-by: Max Zhen Signed-off-by: Brian Xu --- MAINTAINERS | 1 + drivers/dma/xilinx/xdma.c | 85 ++++++++++++++++++++++++++++++++++++ include/linux/dma/amd_xdma.h | 16 +++++++ 3 files changed, 102 insertions(+) create mode 100644 include/linux/dma/amd_xdma.h diff --git a/MAINTAINERS b/MAINTAINERS index d598c4e23901..eaf6590dda19 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -22583,6 +22583,7 @@ L: dmaengine@vger.kernel.org S: Supported F: drivers/dma/xilinx/xdma-regs.h F: drivers/dma/xilinx/xdma.c +F: include/linux/dma/amd_xdma.h F: include/linux/platform_data/amd_xdma.h XILINX ZYNQMP DPDMA DRIVER diff --git a/drivers/dma/xilinx/xdma.c b/drivers/dma/xilinx/xdma.c index 118528295fb7..846f10317bba 100644 --- a/drivers/dma/xilinx/xdma.c +++ b/drivers/dma/xilinx/xdma.c @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include @@ -713,6 +714,7 @@ static int xdma_set_vector_reg(struct xdma_device *xdev, u32 vec_tbl_start, static int xdma_irq_init(struct xdma_device *xdev) { u32 irq = xdev->irq_start; + u32 user_irq_start; int i, j, ret; /* return failure if there are not enough IRQs */ @@ -755,6 +757,18 @@ static int xdma_irq_init(struct xdma_device *xdev) goto failed_init_c2h; } + /* config user IRQ registers if needed */ + user_irq_start = XDMA_CHAN_NUM(xdev); + if (xdev->irq_num > user_irq_start) { + ret = xdma_set_vector_reg(xdev, XDMA_IRQ_USER_VEC_NUM, + user_irq_start, + xdev->irq_num - user_irq_start); + if (ret) { + xdma_err(xdev, "failed to set user vectors: %d", ret); + goto failed_init_c2h; + } + } + /* enable interrupt */ ret = xdma_write_reg(xdev, XDMA_IRQ_BASE, XDMA_IRQ_CHAN_INT_EN_W1S, ~0); if (ret) @@ -780,6 +794,77 @@ static bool xdma_filter_fn(struct dma_chan *chan, void *param) return chan_info->dir == xdma_chan->dir; } +/** + * xdma_disable_user_irq - Disable user interrupt + * @pdev: Pointer to the platform_device structure + * @irq_num: System IRQ number + */ +void xdma_disable_user_irq(struct platform_device *pdev, u32 irq_num) +{ + struct xdma_device *xdev = platform_get_drvdata(pdev); + u32 user_irq_index; + + user_irq_index = irq_num - xdev->irq_start; + if (user_irq_index < XDMA_CHAN_NUM(xdev) || + user_irq_index >= xdev->irq_num) { + xdma_err(xdev, "invalid user irq number"); + return; + } + user_irq_index -= XDMA_CHAN_NUM(xdev); + + xdma_write_reg(xdev, XDMA_IRQ_BASE, XDMA_IRQ_USER_INT_EN_W1C, + (1 << user_irq_index)); +} +EXPORT_SYMBOL(xdma_disable_user_irq); + +/** + * xdma_enable_user_irq - Enable user logic interrupt + * @pdev: Pointer to the platform_device structure + * @irq_num: System IRQ number + */ +int xdma_enable_user_irq(struct platform_device *pdev, u32 irq_num) +{ + struct xdma_device *xdev = platform_get_drvdata(pdev); + u32 user_irq_index; + int ret; + + user_irq_index = irq_num - xdev->irq_start; + if (user_irq_index < XDMA_CHAN_NUM(xdev) || + user_irq_index >= xdev->irq_num) { + xdma_err(xdev, "invalid user irq number"); + return -EINVAL; + } + user_irq_index -= XDMA_CHAN_NUM(xdev); + + ret = xdma_write_reg(xdev, XDMA_IRQ_BASE, XDMA_IRQ_USER_INT_EN_W1S, + (1 << user_irq_index)); + if (ret) + return ret; + + return 0; +} +EXPORT_SYMBOL(xdma_enable_user_irq); + +/** + * xdma_get_user_irq - Get system IRQ number + * @pdev: Pointer to the platform_device structure + * @user_irq_index: User logic IRQ wire index + * + * Return: The system IRQ number allocated for the given wire index. + */ +int xdma_get_user_irq(struct platform_device *pdev, u32 user_irq_index) +{ + struct xdma_device *xdev = platform_get_drvdata(pdev); + + if (XDMA_CHAN_NUM(xdev) + user_irq_index >= xdev->irq_num) { + xdma_err(xdev, "invalid user irq index"); + return -EINVAL; + } + + return xdev->irq_start + XDMA_CHAN_NUM(xdev) + user_irq_index; +} +EXPORT_SYMBOL(xdma_get_user_irq); + /** * xdma_remove - Driver remove function * @pdev: Pointer to the platform_device structure diff --git a/include/linux/dma/amd_xdma.h b/include/linux/dma/amd_xdma.h new file mode 100644 index 000000000000..ceba69ed7cb4 --- /dev/null +++ b/include/linux/dma/amd_xdma.h @@ -0,0 +1,16 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* + * Copyright (C) 2022, Advanced Micro Devices, Inc. + */ + +#ifndef _DMAENGINE_AMD_XDMA_H +#define _DMAENGINE_AMD_XDMA_H + +#include +#include + +int xdma_enable_user_irq(struct platform_device *pdev, u32 irq_num); +void xdma_disable_user_irq(struct platform_device *pdev, u32 irq_num); +int xdma_get_user_irq(struct platform_device *pdev, u32 user_irq_index); + +#endif /* _DMAENGINE_AMD_XDMA_H */