Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp6651869rwd; Mon, 5 Jun 2023 23:18:55 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7ThurAlR3W/9CvKKCnVBSIl1N5+b99vuWdpRGtSRTGHHogixisSDnAw2Njf5i8wSeC2SS9 X-Received: by 2002:a05:622a:14d:b0:3f6:9b4e:512a with SMTP id v13-20020a05622a014d00b003f69b4e512amr894261qtw.54.1686032335446; Mon, 05 Jun 2023 23:18:55 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1686032335; cv=pass; d=google.com; s=arc-20160816; b=akLzaGPbgFUgBcMjHKEPQrpXqxqunwau1mBtd9o/2VZt0FBJzq0hyjoG3bUFdmPX7C GvJi7/TpR7J19ASgwiTFToEHLTiapaM77XPTB/IujC6VQ7lrh9RIx0nYpb3FmOb1CMWi eLZQg9dJ/3AbW6H5ebZCV2CZvBnpvyoRkKxRz8ZhVy5zOfsiJCs6AgTNBkIPBX1CXa46 MtUleXCnlCZIqO7RnRVr9CwHA+cYTMyArTHBS0jHEUZu1dWYQYLA1fGOsfjd2aEi1TIx nLum0S+DWnxW8RlA4nt4FEDFh6huMVeP7DB3v88qBcPyhg+wRhMswC14VIpkNj/YnIWJ N1Ng== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=zmmvwEK/xoq+OsitOkqTddADQxU14caofIr76SBsY1Y=; b=0fyyQlmk/2zbDXDtvZsTnWl6IjbqDYMU6UqHI0KHV5Ym28k7kV0K9Xw/vR5tN7eFAA zed5+eG5iaWi8eU7KEbhb34QFEwf1sZkCAhBrClfAD7Rudq5j0UafmJzuVk2rawTEYTF FXQJGiAda2jXdV8N4W+AjL+/HgenVcybvSOlR9oInYkYnURaOXRqFe4p2340UKW6HDlx Vx8hx7tKu0dxJ3PSy5Gd6wvJN6LAQnanRkInEzXoB5mTp6wrLCSo74/QqoyNVNTwgWsP T/Fdx0/wJZU1lgTRABOLnamrkJpZnKFsShZrr2Lu54XFQagZg8tqRoUsNTcJlOav1lko 5pkQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=h5tkuRSI; 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 u16-20020ac858d0000000b003ef2c3afaa7si5875077qta.338.2023.06.05.23.18.41; Mon, 05 Jun 2023 23:18:55 -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=@amd.com header.s=selector1 header.b=h5tkuRSI; 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 S233988AbjFFGD6 (ORCPT + 99 others); Tue, 6 Jun 2023 02:03:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53122 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234281AbjFFGDh (ORCPT ); Tue, 6 Jun 2023 02:03:37 -0400 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2069.outbound.protection.outlook.com [40.107.237.69]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7BF87E43 for ; Mon, 5 Jun 2023 23:03:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jXxzhMq6QCQ2kiykVZg9kv7TWVcBoeUK12PCxeFP1qDLtCTyDnfOUpEBYE9wo8EnvVzchKEAxUrzTdaWcDaRSX4Nq/P/281WfMgjwFIwWyqcoRyrYoyUMTw1uecyk/qv/FU4H2VIz1jmA6KBYaMct6Cyt7BqvaFrLOPh0pgkxndWkphEALdEpVfORBbj1Y1Gj62bkZ01Xv2zhpSgYWqd/+jUTwUhkyCZ/ZliWDzIRDEybR96jmk6GxzT5NKpj1OJ+vEQVRnI4Me/V3DfKy8lSxAdNCGcDgneD903R7sYDEcTmUaL5xy4IcEueemp2BoKkeS5C804IWIU3nBP7F8tpg== 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=zmmvwEK/xoq+OsitOkqTddADQxU14caofIr76SBsY1Y=; b=EBF5Y2C51OsxorZx3Bgbm2e89pCVgkWW4ZrYbVcI+Tqpy3haHy052ya74ll7dvkZmL8/zTcVbFuRME9sjfo2iaqgYVX7kwuQndGhDfBvvIFM2KLiVuBdsSAScjNHxBxqiJhpTy15PK6vtpbEZcP8ARkZzTPwsL399l53EMAKZ39+SXh2HcGvD11qAp/LiPqGVOkgxZLitsMUiX2pujeA4SVgZn/x72YQSa2OS3AqT+IvutRPIyqssrwsIDiqudhtzBki87TMmQISxgdza9vgguBotbn4J0qlf7hXb2ahRlVFni9ppcEG71SKwYGCW5cRm0/Cz3PwTwY1ui/Jx9zV1Q== 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=zmmvwEK/xoq+OsitOkqTddADQxU14caofIr76SBsY1Y=; b=h5tkuRSIPF43Sao4UxwRko22VUB8Mi96i13dgEJn5uPsaK7Pc0qsf1Aksp+rUZPYSRO6paQ7jahwViRVEoexnXjWjUzG+AjqC8Tb6mUirOJDYxAeH51VNhmu+20vRr0AL/de0gm6TFijWW8ogVZqNm8wQbnr91WFjIV3UNQEyUE= Received: from DM6PR07CA0087.namprd07.prod.outlook.com (2603:10b6:5:337::20) by CH3PR12MB9026.namprd12.prod.outlook.com (2603:10b6:610:125::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.33; Tue, 6 Jun 2023 06:03:25 +0000 Received: from CY4PEPF0000EDD3.namprd03.prod.outlook.com (2603:10b6:5:337:cafe::ab) by DM6PR07CA0087.outlook.office365.com (2603:10b6:5:337::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.33 via Frontend Transport; Tue, 6 Jun 2023 06:03:25 +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 CY4PEPF0000EDD3.mail.protection.outlook.com (10.167.241.207) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6477.13 via Frontend Transport; Tue, 6 Jun 2023 06:03:25 +0000 Received: from SATLEXMB03.amd.com (10.181.40.144) 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, 6 Jun 2023 01:03:16 -0500 Received: from vijendar-X570-GAMING-X.amd.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; Tue, 6 Jun 2023 01:03:12 -0500 From: Vijendar Mukunda To: CC: , , , , , , , Vijendar Mukunda , Liam Girdwood , Jaroslav Kysela , Takashi Iwai , Syed Saba Kareem , open list Subject: [PATCH V3 5/9] ASoC: amd: ps: add support for SoundWire DMA interrupts Date: Tue, 6 Jun 2023 11:37:20 +0530 Message-ID: <20230606060724.2038680-6-Vijendar.Mukunda@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230606060724.2038680-1-Vijendar.Mukunda@amd.com> References: <20230606060724.2038680-1-Vijendar.Mukunda@amd.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EDD3:EE_|CH3PR12MB9026:EE_ X-MS-Office365-Filtering-Correlation-Id: fe712fde-6723-4b92-ab6a-08db6653bdd4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 7eiZFvfR4WXVR/SEiYde8cKdBOZICIIYLc6b4tU50LCq8C0x8SujCfN0kmzT6coUcOYD/RmlG5ZRQ1vyckjr3c64uphjTezGD3pGvpwQzbehTgOdO5ngP844QVAt820pxKyJRmd5zl+o6TFDoy6NqvmKttad2HN80ClHdFMfpXJC3yEdKZY3drQMywFnjWfpPYUOQY7bVzO9Tb1ohFo6JcJXEa1GMo608WiAjDllfw95/R6TjaDk8fA9lm4wV4rbAtGhHaz4LCm0FIwDnZ9Zd1AsGIV9QcgmLkc55d4OIDSxx2LbAo21lH2iVzZogpMm5yfDMovlocq3B5NQHenXyLvRQh4q2IPHzQZRx6EV5tb6p5/T51RKTGKErwBePsSrwif7fK5xtPkLFD//sGRle4eaYurdpORmVogo4vYNILjhyv5rgEMnIt9xHyjU2hLhIkT8bGiLUYB3KtTM7nZg9+DJUbQXT1qgjn4bfwAng4wAzqIGcnxgGq5ERMkE/vlNqEmNQoND4rtCaF3+ueGl2rwpnlgQKe43bP5U0+s9nH197XHN5p+gVAC0q13k+nAjmMWJgBFIEEcVRN/RoX6wU8ov4xV+xpvYtuoZaZZ5UGdgzZg1OPHXRScmKRZS45zdnIH/tUm1k8N9qUMeGtEX5LgEfsquDnPcZSc7CDh3H9zCRo5inKgdcmcH+EIYCK9JQY+LBjFGylhSuAN68CXg5MBgNXDidfBdT9rzzuZkNCqYhN5A0uU6mClapo07xG4ZXgWXH4/RN6ecFL67Q6rbDg== 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:(13230028)(4636009)(346002)(396003)(39860400002)(376002)(136003)(451199021)(46966006)(40470700004)(36840700001)(1076003)(40460700003)(26005)(36860700001)(36756003)(81166007)(47076005)(426003)(336012)(83380400001)(86362001)(82310400005)(82740400003)(356005)(186003)(2616005)(40480700001)(8676002)(4326008)(41300700001)(54906003)(2906002)(478600001)(70586007)(6916009)(8936002)(316002)(70206006)(5660300002)(7696005)(6666004)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Jun 2023 06:03:25.5269 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: fe712fde-6723-4b92-ab6a-08db6653bdd4 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: CY4PEPF0000EDD3.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB9026 X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=no 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 Move to request_threaded_irq and use thread for handling SoundWire DMA interrupts. Whenever audio data equal to the SoundWire FIFO watermark level are produced/consumed, interrupt is generated. Acknowledge the interrupt and wake up the irq thread. Signed-off-by: Vijendar Mukunda --- sound/soc/amd/ps/acp63.h | 18 +++++++++ sound/soc/amd/ps/pci-ps.c | 84 ++++++++++++++++++++++++++++++++++++++- 2 files changed, 100 insertions(+), 2 deletions(-) diff --git a/sound/soc/amd/ps/acp63.h b/sound/soc/amd/ps/acp63.h index 5779afdc8f02..c8ba0195846b 100644 --- a/sound/soc/amd/ps/acp63.h +++ b/sound/soc/amd/ps/acp63.h @@ -175,6 +175,20 @@ enum acp_pdev_mask { ACP63_SDW_PDM_DEV_MASK, }; +enum amd_sdw0_channel { + ACP_SDW0_AUDIO0_TX = 0, + ACP_SDW0_AUDIO1_TX, + ACP_SDW0_AUDIO2_TX, + ACP_SDW0_AUDIO0_RX, + ACP_SDW0_AUDIO1_RX, + ACP_SDW0_AUDIO2_RX, +}; + +enum amd_sdw1_channel { + ACP_SDW1_AUDIO1_TX, + ACP_SDW1_AUDIO1_RX, +}; + struct pdm_stream_instance { u16 num_pages; u16 channels; @@ -239,6 +253,8 @@ struct sdw_dma_ring_buf_reg { * @sdw0_dev_index: SoundWire Manager-0 platform device index * @sdw1_dev_index: SoundWire Manager-1 platform device index * @sdw_dma_dev_index: SoundWire DMA controller platform device index + * @sdw0-dma_intr_stat: DMA interrupt status array for SoundWire manager-SW0 instance + * @sdw_dma_intr_stat: DMA interrupt status array for SoundWire manager-SW1 instance * @acp_reset: flag set to true when bus reset is applied across all * the active SoundWire manager instances */ @@ -256,6 +272,8 @@ struct acp63_dev_data { u16 sdw0_dev_index; u16 sdw1_dev_index; u16 sdw_dma_dev_index; + u16 sdw0_dma_intr_stat[ACP63_SDW0_DMA_MAX_STREAMS]; + u16 sdw1_dma_intr_stat[ACP63_SDW1_DMA_MAX_STREAMS]; bool acp_reset; }; diff --git a/sound/soc/amd/ps/pci-ps.c b/sound/soc/amd/ps/pci-ps.c index 17e29a3e1c21..daf54fe9cafd 100644 --- a/sound/soc/amd/ps/pci-ps.c +++ b/sound/soc/amd/ps/pci-ps.c @@ -99,14 +99,44 @@ static int acp63_deinit(void __iomem *acp_base, struct device *dev) return 0; } +static irqreturn_t acp63_irq_thread(int irq, void *context) +{ + struct sdw_dma_dev_data *sdw_dma_data; + struct acp63_dev_data *adata = context; + u32 stream_index; + u16 pdev_index; + + pdev_index = adata->sdw_dma_dev_index; + sdw_dma_data = dev_get_drvdata(&adata->pdev[pdev_index]->dev); + + for (stream_index = 0; stream_index < ACP63_SDW0_DMA_MAX_STREAMS; stream_index++) { + if (adata->sdw0_dma_intr_stat[stream_index]) { + if (sdw_dma_data->sdw0_dma_stream[stream_index]) + snd_pcm_period_elapsed(sdw_dma_data->sdw0_dma_stream[stream_index]); + adata->sdw0_dma_intr_stat[stream_index] = 0; + } + } + for (stream_index = 0; stream_index < ACP63_SDW1_DMA_MAX_STREAMS; stream_index++) { + if (adata->sdw1_dma_intr_stat[stream_index]) { + if (sdw_dma_data->sdw1_dma_stream[stream_index]) + snd_pcm_period_elapsed(sdw_dma_data->sdw1_dma_stream[stream_index]); + adata->sdw1_dma_intr_stat[stream_index] = 0; + } + } + return IRQ_HANDLED; +} + static irqreturn_t acp63_irq_handler(int irq, void *dev_id) { struct acp63_dev_data *adata; struct pdm_dev_data *ps_pdm_data; struct amd_sdw_manager *amd_manager; u32 ext_intr_stat, ext_intr_stat1; + u32 stream_id = 0; u16 irq_flag = 0; + u16 sdw_dma_irq_flag = 0; u16 pdev_index; + u16 index; adata = dev_id; if (!adata) @@ -153,6 +183,56 @@ static irqreturn_t acp63_irq_handler(int irq, void *dev_id) snd_pcm_period_elapsed(ps_pdm_data->capture_stream); irq_flag = 1; } + if (ext_intr_stat & ACP_SDW_DMA_IRQ_MASK) { + for (index = ACP_AUDIO2_RX_THRESHOLD; index <= ACP_AUDIO0_TX_THRESHOLD; index++) { + if (ext_intr_stat & BIT(index)) { + writel(BIT(index), adata->acp63_base + ACP_EXTERNAL_INTR_STAT); + switch (index) { + case ACP_AUDIO0_TX_THRESHOLD: + stream_id = ACP_SDW0_AUDIO0_TX; + break; + case ACP_AUDIO1_TX_THRESHOLD: + stream_id = ACP_SDW0_AUDIO1_TX; + break; + case ACP_AUDIO2_TX_THRESHOLD: + stream_id = ACP_SDW0_AUDIO2_TX; + break; + case ACP_AUDIO0_RX_THRESHOLD: + stream_id = ACP_SDW0_AUDIO0_RX; + break; + case ACP_AUDIO1_RX_THRESHOLD: + stream_id = ACP_SDW0_AUDIO1_RX; + break; + case ACP_AUDIO2_RX_THRESHOLD: + stream_id = ACP_SDW0_AUDIO2_RX; + break; + } + + adata->sdw0_dma_intr_stat[stream_id] = 1; + sdw_dma_irq_flag = 1; + } + } + } + + /* SDW1 BT RX */ + if (ext_intr_stat1 & ACP_P1_AUDIO1_RX_THRESHOLD) { + writel(ACP_P1_AUDIO1_RX_THRESHOLD, + adata->acp63_base + ACP_EXTERNAL_INTR_STAT1); + adata->sdw1_dma_intr_stat[ACP_SDW1_AUDIO1_RX] = 1; + sdw_dma_irq_flag = 1; + } + + /* SDW1 BT TX*/ + if (ext_intr_stat1 & ACP_P1_AUDIO1_TX_THRESHOLD) { + writel(ACP_P1_AUDIO1_TX_THRESHOLD, + adata->acp63_base + ACP_EXTERNAL_INTR_STAT1); + adata->sdw1_dma_intr_stat[ACP_SDW1_AUDIO1_TX] = 1; + sdw_dma_irq_flag = 1; + } + + if (sdw_dma_irq_flag) + return IRQ_WAKE_THREAD; + if (irq_flag) return IRQ_HANDLED; else @@ -544,8 +624,8 @@ static int snd_acp63_probe(struct pci_dev *pci, ret = acp63_init(adata->acp63_base, &pci->dev); if (ret) goto release_regions; - ret = devm_request_irq(&pci->dev, pci->irq, acp63_irq_handler, - irqflags, "ACP_PCI_IRQ", adata); + ret = devm_request_threaded_irq(&pci->dev, pci->irq, acp63_irq_handler, + acp63_irq_thread, irqflags, "ACP_PCI_IRQ", adata); if (ret) { dev_err(&pci->dev, "ACP PCI IRQ request failed\n"); goto de_init; -- 2.34.1