Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp13484321rwl; Wed, 4 Jan 2023 08:45:16 -0800 (PST) X-Google-Smtp-Source: AMrXdXvkqpoLYSr4pMI3+NzoDF5louiZp1gzM14/kPAE5kKDeZw0d6YPYlb7dpg8QszWW+bE9+1T X-Received: by 2002:a05:6a20:8c1d:b0:b0:4706:2eaf with SMTP id j29-20020a056a208c1d00b000b047062eafmr47079303pzh.7.1672850716492; Wed, 04 Jan 2023 08:45:16 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1672850716; cv=pass; d=google.com; s=arc-20160816; b=U1yNRxhVuS6W1cbugoR+07SHSXGUT1xkpQ/NeGxKOzklFimExjjeOnm7G7OIMuqEq6 kAUw65lfaGKUjLShQTBsLKeJY5k94jhuOHGQ0wyvgQi+VekgjW3DlBYw+wuDItwDi0hW pHtqiximvep1u6lz1UuUkWVXYQzgnEYZQuPlLkub67uKbbSThlqfpJvFtKkGZ9SfAUU8 MwcmxzEDsfjhHKe41WyJHB7voQZOx0O5qBmEwR3xwpDoy+y/iORYAPZBIf3vUyqPWxrU a565ImJhmk4PKO8vi4Rn3QegoqJJitZfegizJmM6EFC6qFBLNVi3plmtopu9gXWKTSdG iriQ== 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=qAzsiTpdL0SBjzJLE5CDWwht36IIvxDx+Yrel2ix04A=; b=c2RcGLtQ/t0T1YHk6sg00RL1hSCFUTGNpgL9zORAu90WLNNIgnDYBwEQ4lUdVxYojC 6P8q0kVt8bDsZo1lhPC0/H69cynkV0W/0tUu3tkC0/EmJKnoF4PVUmKD4dqyXa2XUbJT ZNydqhFGD5r57bxd8cNAvchTVLpoqd7gWVY+gG5d9O96yrjxKHljvfC7EIwEbmPhcT/X 6G0cqw7+Y1u7tJ/kMaLBB85fpR1b88qMa9xCbc+m250RWRuTTCy2pnSXu5ga7o75t+co tQMdnMZ7y5Gg/5S1/X0v7HwqfVKz6FL8pG849X+YY6+6n2/Kq4vuIrpVVKTkd9rAt039 aqUg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=n6ZVRy6C; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o23-20020a63fb17000000b0049b926fa4basi16941321pgh.345.2023.01.04.08.44.45; Wed, 04 Jan 2023 08:45:16 -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=n6ZVRy6C; 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 S239765AbjADQmh (ORCPT + 57 others); Wed, 4 Jan 2023 11:42:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34518 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239545AbjADQlx (ORCPT ); Wed, 4 Jan 2023 11:41:53 -0500 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2044.outbound.protection.outlook.com [40.107.94.44]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 294561DF0A; Wed, 4 Jan 2023 08:41:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=muxosYOQpyO51kzx6v1BXEPLfylsiXqefWUF/kZSeaxFXG+0pl9UJrFG8AqKm4OcqfaitJKyELDpDrKaVfq5xqoNlRe5kKbizG48e75e4/N1pOtiCLIQOwsZqhwv2Du1UU1enpve4jS0u3ZQyc0OQAsP0N5b5ZmmLuumxPTWoTZIGWpuPwzl3BXSOn9dn3MrgC4ePXyHyyUxPiHkkzmItfkZanwwsEN59FSkdYUGkXTGjUhnXLtSnhUoJeNTVAgEC25RQsOXI0Ssi6v3piJsGkGavaAuViezjl7rE+WS6RTp8TdPinCi2B86oZ5MpOHvDx1mxHj5etNcstScsEwR/Q== 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=qAzsiTpdL0SBjzJLE5CDWwht36IIvxDx+Yrel2ix04A=; b=MpgFniHSpHlQSytaxy4VodjNqtgYE6s/NngephVQ3JkAEpKyK1Rdw7KA6dsynKWFKU6DclPow2Q6sOHbbw9XJEBACUZXuoHfkCLtqw9MrO6y3udUDBcnJYpCpnFobGV0PzuNNSndikgr3azU4hhMIua9+B4lU9HZptYeoVmJYyhsDhRo9E05PrrDBIXdEq8DCv5PNKqFpH29fuy66VL+j5sbis0DVRY1rTj/7BDD3KXPNJ/ZsutB95eqeNgkFyyEfrxjeSa/ke2kuTNTEF0b2I3+sC5CY00ZkBZj9A14wxH2qjcygqzevBBjYcqSVZyQmwq10vSoP+G8CnKGlAKcIw== 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=qAzsiTpdL0SBjzJLE5CDWwht36IIvxDx+Yrel2ix04A=; b=n6ZVRy6CncUx0TyH/GbFT/YJ0k8O1KTXDMQaItCP+C3mT9GNJvw2OR9r2opI67HUZmqJgysqjH7okGQ8EZBAoIamdVitl6X/R5lDM3xBCwY0Wtoajow1rC7XyDIpY91WnS85cB6KwOf5AbKwb1bGPQ4xkAQeE4UPByASSGYtHdQ= Received: from DS7PR03CA0312.namprd03.prod.outlook.com (2603:10b6:8:2b::21) by DS0PR12MB7680.namprd12.prod.outlook.com (2603:10b6:8:136::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5944.19; Wed, 4 Jan 2023 16:41:50 +0000 Received: from DS1PEPF0000E644.namprd02.prod.outlook.com (2603:10b6:8:2b:cafe::dd) by DS7PR03CA0312.outlook.office365.com (2603:10b6:8:2b::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5986.14 via Frontend Transport; Wed, 4 Jan 2023 16:41:50 +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 DS1PEPF0000E644.mail.protection.outlook.com (10.167.17.200) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5944.8 via Frontend Transport; Wed, 4 Jan 2023 16:41:50 +0000 Received: from SATLEXMB06.amd.com (10.181.40.147) 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; Wed, 4 Jan 2023 10:41:46 -0600 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB06.amd.com (10.181.40.147) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Wed, 4 Jan 2023 10:41:45 -0600 Received: from xsjlizhih40.xilinx.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2375.34 via Frontend Transport; Wed, 4 Jan 2023 10:41:45 -0600 From: Lizhi Hou To: , , CC: Lizhi Hou , , , , , Subject: [RESEND PATCH V11 XDMA 2/2] dmaengine: xilinx: xdma: Add user logic interrupt support Date: Wed, 4 Jan 2023 08:40:41 -0800 Message-ID: <1672850441-51944-3-git-send-email-lizhi.hou@amd.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1672850441-51944-1-git-send-email-lizhi.hou@amd.com> References: <1672850441-51944-1-git-send-email-lizhi.hou@amd.com> MIME-Version: 1.0 Content-Type: text/plain X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS1PEPF0000E644:EE_|DS0PR12MB7680:EE_ X-MS-Office365-Filtering-Correlation-Id: 9331bac8-dfff-4b70-bcbe-08daee7293f5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: KfCIjP0ICbhor57Vr0ZnEiLvXqHN2CDsmo3XDHzx/T5SNeHupl5sbQMn/NX3HVBCpgIScefKqY/JqyenEgm9A044+OegXh1teJ0+llg0iwh06SS/+fDBgBZsY7BiYW/qq95QkE9mZDX2roZXoaaqdUSilbFwLz8jzpplw5r/y1iA/BpzXQ6pX/pmPdvAfklrzlCW0zVfZaZeNZyk1999tF+c/uZViN3j8sSXLF/9FTH/nlZ/EIWXkb811jMNE7hWs1ByNOGRBNA8JG4pWhAXaQPT8ovPNW9GmUcfYYckbkkHK/9lqcOP9h1IM2hvDJXLSreRcd7/6Pndz1IrY33FqaqywK8jGqlIfVmgHAZcscdgP6FxNP+lTtBsxwGDos3uA7h6dArOuuEyyhtjPmBEFvJIIvBnAPKHM8LewNcl50eeDvsebMJdJmpbUwpu31vBbAIBqHUg6GxUMi5cZ0fWIjUX+FSMvUxCDhzMWYTQ+hcz6zfB8fBZmENr/HP7AGSv0UjZ4JmOrCZzNpUC4yVrnZESZI55TnoX95xffeXvVYSsjmbko2reo7LlxJtX1bdQz14C9nswa8BJz9cqVxqN4AJiuIdWs7emAZEl61pMfG3Ezljoi5GD+v2+4NcJGJB6kaXE7Irp1fKma2giHLu/2DH5u/Rp56PkLcmBMGtcUFCwEglJ9sZ2QOeVgcJeOeFFU/hhUmIvibT1SJlOmp8labEEIH4S/I3R+eT+F3gkTpQ= 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)(376002)(39860400002)(396003)(346002)(136003)(451199015)(40470700004)(46966006)(36840700001)(82310400005)(82740400003)(8676002)(41300700001)(36860700001)(8936002)(4326008)(70206006)(70586007)(5660300002)(86362001)(81166007)(356005)(2616005)(44832011)(316002)(83380400001)(2906002)(110136005)(54906003)(336012)(40480700001)(40460700003)(26005)(36756003)(186003)(47076005)(6666004)(478600001)(426003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Jan 2023 16:41:50.1603 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9331bac8-dfff-4b70-bcbe-08daee7293f5 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: DS1PEPF0000E644.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB7680 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 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 Tested-by: Martin Tuma --- 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 */ -- 2.27.0