From patchwork Fri Dec 30 23:22:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 638515 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 138FDC3DA7D for ; Fri, 30 Dec 2022 23:22:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235615AbiL3XWh (ORCPT ); Fri, 30 Dec 2022 18:22:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35544 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235595AbiL3XWg (ORCPT ); Fri, 30 Dec 2022 18:22:36 -0500 Received: from mail-il1-x136.google.com (mail-il1-x136.google.com [IPv6:2607:f8b0:4864:20::136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4E78F1D0FF for ; Fri, 30 Dec 2022 15:22:35 -0800 (PST) Received: by mail-il1-x136.google.com with SMTP id d14so12065420ilq.11 for ; Fri, 30 Dec 2022 15:22:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=gh2pdQ8Qz1jZcFQ0f9txmSCzOLVZiWWbqoSXvGeFz+g=; b=ZYZNnlUOkpTkj9RFdJdH5nqOqbvVZ6akzpzo3bs2kmgroaVZ2XWbhB+wWuG/xwOnDv LBhH5Xqo8vL9xzjIGtbVdt4qFpZWLV6DidrbkP5SkL+1broFvO+0ZnVsia5L6Ksl3ykz gDVqKrvgWI7Uon77gbweRmur3AjCAb4o8OGGoRyqyNDVTolRK8cShKrR0I4KEZJ1iJen Anwj4MKvDd+Fr3nfbULRJExr2nvJtOz5ttJGJW4BPpK+WzkUpUDLjMCvOi3x7oLLtWDN 5yzvZL8/yCwGVMDps/VACLEnIB7S3YaPF9uyxpbnHPOg8krLP23UUChtq5Frei1K6oHV Mq/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=gh2pdQ8Qz1jZcFQ0f9txmSCzOLVZiWWbqoSXvGeFz+g=; b=wcV31uCYOZYKuRud38oX0nke2zZvAZ9BDHn/0b267pAL9Cpx1P6dSmOVVjxLMlNKlu LMhbkmg8fKlkFV4PfJrcytQRdPfsak1T52gzV5SoGFvo0vLcHPP8hE9ENgY1RWmmxxvv rSrtdcEiZbWRp9nDhjAbQtl7SpT6INAhI6h9MyuEanltYJraSj/RsTnAWQNOy5s/b24A e/K7GvlsItMVHA2qP6Xti+aPOXeZ8HjwMQt5YOnyaslIqEGAa1pEEgH+NxaPGjix2V1g Kw4x+8g9iY86BqrkuGfSmCZzsFQk2rpqvViBa3DhIRLIT3A3agM2bYNt2XJSSUO7x0/E f6lQ== X-Gm-Message-State: AFqh2krZCAqc2E5ZvxyXnvqoLB4nFFG0SgzAinJAVaFkUIBOpNTroIco rpuRIlACjtyLBCwECgpRvJ2hBQ== X-Google-Smtp-Source: AMrXdXvdocMfWO8HGIymmgpF7Pf8/58co9uNQyH3dB6OF6qzOshTwLzLIkVw2cAja4wlZKCzyqiTWg== X-Received: by 2002:a92:c501:0:b0:30b:e92a:aa8f with SMTP id r1-20020a92c501000000b0030be92aaa8fmr16796909ilg.15.1672442554689; Fri, 30 Dec 2022 15:22:34 -0800 (PST) Received: from presto.localdomain ([98.61.227.136]) by smtp.gmail.com with ESMTPSA id co18-20020a0566383e1200b0038a53fb3911sm7170558jab.97.2022.12.30.15.22.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 30 Dec 2022 15:22:34 -0800 (PST) From: Alex Elder To: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com Cc: caleb.connolly@linaro.org, mka@chromium.org, evgreen@chromium.org, andersson@kernel.org, quic_cpratapa@quicinc.com, quic_avuyyuru@quicinc.com, quic_jponduru@quicinc.com, quic_subashab@quicinc.com, elder@kernel.org, netdev@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next 1/6] net: ipa: introduce a common microcontroller interrupt handler Date: Fri, 30 Dec 2022 17:22:25 -0600 Message-Id: <20221230232230.2348757-2-elder@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221230232230.2348757-1-elder@linaro.org> References: <20221230232230.2348757-1-elder@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org The prototype for an IPA interrupt handler supplies the IPA interrupt ID, so it's possible to use a single function to handle any type of microcontroller interrupt. Introduce ipa_uc_interrupt_handler(), which calls the event or the response handler depending on the IRQ ID provided. Register the new function as the handler for both microcontroller IPA interrupt types. The called functions don't use their "irq_id" arguments, so remove them. Signed-off-by: Alex Elder --- drivers/net/ipa/ipa_uc.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/drivers/net/ipa/ipa_uc.c b/drivers/net/ipa/ipa_uc.c index f0ee472810153..0a890b44c09e1 100644 --- a/drivers/net/ipa/ipa_uc.c +++ b/drivers/net/ipa/ipa_uc.c @@ -124,7 +124,7 @@ static struct ipa_uc_mem_area *ipa_uc_shared(struct ipa *ipa) } /* Microcontroller event IPA interrupt handler */ -static void ipa_uc_event_handler(struct ipa *ipa, enum ipa_irq_id irq_id) +static void ipa_uc_event_handler(struct ipa *ipa) { struct ipa_uc_mem_area *shared = ipa_uc_shared(ipa); struct device *dev = &ipa->pdev->dev; @@ -138,7 +138,7 @@ static void ipa_uc_event_handler(struct ipa *ipa, enum ipa_irq_id irq_id) } /* Microcontroller response IPA interrupt handler */ -static void ipa_uc_response_hdlr(struct ipa *ipa, enum ipa_irq_id irq_id) +static void ipa_uc_response_hdlr(struct ipa *ipa) { struct ipa_uc_mem_area *shared = ipa_uc_shared(ipa); struct device *dev = &ipa->pdev->dev; @@ -170,13 +170,24 @@ static void ipa_uc_response_hdlr(struct ipa *ipa, enum ipa_irq_id irq_id) } } +static void ipa_uc_interrupt_handler(struct ipa *ipa, enum ipa_irq_id irq_id) +{ + /* Silently ignore anything unrecognized */ + if (irq_id == IPA_IRQ_UC_0) + ipa_uc_event_handler(ipa); + else if (irq_id == IPA_IRQ_UC_1) + ipa_uc_response_hdlr(ipa); +} + /* Configure the IPA microcontroller subsystem */ void ipa_uc_config(struct ipa *ipa) { + struct ipa_interrupt *interrupt = ipa->interrupt; + ipa->uc_powered = false; ipa->uc_loaded = false; - ipa_interrupt_add(ipa->interrupt, IPA_IRQ_UC_0, ipa_uc_event_handler); - ipa_interrupt_add(ipa->interrupt, IPA_IRQ_UC_1, ipa_uc_response_hdlr); + ipa_interrupt_add(interrupt, IPA_IRQ_UC_0, ipa_uc_interrupt_handler); + ipa_interrupt_add(interrupt, IPA_IRQ_UC_1, ipa_uc_interrupt_handler); } /* Inverse of ipa_uc_config() */ From patchwork Fri Dec 30 23:22:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 637896 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 64AAEC4708E for ; Fri, 30 Dec 2022 23:22:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235708AbiL3XWi (ORCPT ); Fri, 30 Dec 2022 18:22:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35552 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235595AbiL3XWh (ORCPT ); Fri, 30 Dec 2022 18:22:37 -0500 Received: from mail-il1-x136.google.com (mail-il1-x136.google.com [IPv6:2607:f8b0:4864:20::136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7D2241D0DD for ; Fri, 30 Dec 2022 15:22:36 -0800 (PST) Received: by mail-il1-x136.google.com with SMTP id z18so12089738ils.3 for ; Fri, 30 Dec 2022 15:22:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=K4WtVwRcqcCUgmYfEzecLg1NkgyQK2BLzDcfIQJWkbQ=; b=yR2Hc5lazanlE/E/Zka7pU/a8AlDQgQOVymRxPsg72chP1ZPDjKfOTjM5yKOkLxvhH en/BWfpXJlC28tVJVnALRUO41fMi820pw1D4OY39x1ufyYa4TAKCYZNYcBxkSSZOpkfD 6QEofGFYQP/RFvfNsLitODzGh1PsEyZioSapKhGNOo3yuG9M+8KN4BOKftQq6CiVRCLp mSpxVl4NTxurXxAD481XSHegiipvU7eV0g3B1DcswDVder8H2GZNlBgAjnNz7x5Wcnw1 Gct/bp4+98R9qJm9xuTdAfihtCYhWsJZmfJu1PN+iDJvPEt/AlOQxHeOS+zEiW8hBIlY C/iQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=K4WtVwRcqcCUgmYfEzecLg1NkgyQK2BLzDcfIQJWkbQ=; b=3p4gl46iWuPowQ1W/4qQ344bTzz7E7XqpGmL2QMnZab8sc99oEW8Gqvhxt9QbJN0C/ P5GI5PWlAGEfYY9UkbGxCa4ja/j/tmqbFg7fgd+BZs4Gy9CdWJ3mFZvxHYOvN2GIXiyN +sZYkdzA0JBUDon9VI8AnYbhyDikZP6OKwlGUClx7Tm6bY+P965h9nCcpCx7+tGfwiCU cdOYelwDsISnYtc0w5BJEFSpxaTwuILT4hjMHEyZHX0U4dyzrdrIEgSlX96aIbEi+nC6 JE7ev5EwjpxyGq1DrNcsEJ/GIy7KOOckpJPiYFSbqWI5FFFDS368JVibFPy9eH8JG41L JTSw== X-Gm-Message-State: AFqh2kqUAO8C0miD/OKu2mkRIWZQFlC0YV82iRsu9D8GcGWkpQYadQKP wOE3gOmtGgZlCNQLiV+riUQHAw== X-Google-Smtp-Source: AMrXdXsLV4A+gBum9yoI2gfwK4bHonG4xj06Cnj1QR3kD6dP36KOnLkE8QQH4bBdvz7UV/z0kvfZoQ== X-Received: by 2002:a05:6e02:1ba1:b0:302:c07e:49f8 with SMTP id n1-20020a056e021ba100b00302c07e49f8mr39063946ili.32.1672442555862; Fri, 30 Dec 2022 15:22:35 -0800 (PST) Received: from presto.localdomain ([98.61.227.136]) by smtp.gmail.com with ESMTPSA id co18-20020a0566383e1200b0038a53fb3911sm7170558jab.97.2022.12.30.15.22.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 30 Dec 2022 15:22:35 -0800 (PST) From: Alex Elder To: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com Cc: caleb.connolly@linaro.org, mka@chromium.org, evgreen@chromium.org, andersson@kernel.org, quic_cpratapa@quicinc.com, quic_avuyyuru@quicinc.com, quic_jponduru@quicinc.com, quic_subashab@quicinc.com, elder@kernel.org, netdev@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next 2/6] net: ipa: introduce ipa_interrupt_enable() Date: Fri, 30 Dec 2022 17:22:26 -0600 Message-Id: <20221230232230.2348757-3-elder@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221230232230.2348757-1-elder@linaro.org> References: <20221230232230.2348757-1-elder@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Create new function ipa_interrupt_enable() to encapsulate enabling one of the IPA interrupt types. Introduce ipa_interrupt_disable() to reverse that operation. Add a helper function to factor out the common register update used by both. Use these in ipa_interrupt_add() and ipa_interrupt_remove(). Signed-off-by: Alex Elder --- drivers/net/ipa/ipa_interrupt.c | 41 ++++++++++++++++++++------------- 1 file changed, 25 insertions(+), 16 deletions(-) diff --git a/drivers/net/ipa/ipa_interrupt.c b/drivers/net/ipa/ipa_interrupt.c index a49f66efacb87..7b7388c14806f 100644 --- a/drivers/net/ipa/ipa_interrupt.c +++ b/drivers/net/ipa/ipa_interrupt.c @@ -127,6 +127,29 @@ static irqreturn_t ipa_isr_thread(int irq, void *dev_id) return IRQ_HANDLED; } +static void ipa_interrupt_enabled_update(struct ipa *ipa) +{ + const struct ipa_reg *reg = ipa_reg(ipa, IPA_IRQ_EN); + + iowrite32(ipa->interrupt->enabled, ipa->reg_virt + ipa_reg_offset(reg)); +} + +/* Enable an IPA interrupt type */ +static void ipa_interrupt_enable(struct ipa *ipa, enum ipa_irq_id ipa_irq) +{ + /* Update the IPA interrupt mask to enable it */ + ipa->interrupt->enabled |= BIT(ipa_irq); + ipa_interrupt_enabled_update(ipa); +} + +/* Disable an IPA interrupt type */ +static void ipa_interrupt_disable(struct ipa *ipa, enum ipa_irq_id ipa_irq) +{ + /* Update the IPA interrupt mask to disable it */ + ipa->interrupt->enabled &= ~BIT(ipa_irq); + ipa_interrupt_enabled_update(ipa); +} + /* Common function used to enable/disable TX_SUSPEND for an endpoint */ static void ipa_interrupt_suspend_control(struct ipa_interrupt *interrupt, u32 endpoint_id, bool enable) @@ -205,36 +228,22 @@ void ipa_interrupt_simulate_suspend(struct ipa_interrupt *interrupt) void ipa_interrupt_add(struct ipa_interrupt *interrupt, enum ipa_irq_id ipa_irq, ipa_irq_handler_t handler) { - struct ipa *ipa = interrupt->ipa; - const struct ipa_reg *reg; - if (WARN_ON(ipa_irq >= IPA_IRQ_COUNT)) return; interrupt->handler[ipa_irq] = handler; - /* Update the IPA interrupt mask to enable it */ - interrupt->enabled |= BIT(ipa_irq); - - reg = ipa_reg(ipa, IPA_IRQ_EN); - iowrite32(interrupt->enabled, ipa->reg_virt + ipa_reg_offset(reg)); + ipa_interrupt_enable(interrupt->ipa, ipa_irq); } /* Remove the handler for an IPA interrupt type */ void ipa_interrupt_remove(struct ipa_interrupt *interrupt, enum ipa_irq_id ipa_irq) { - struct ipa *ipa = interrupt->ipa; - const struct ipa_reg *reg; - if (WARN_ON(ipa_irq >= IPA_IRQ_COUNT)) return; - /* Update the IPA interrupt mask to disable it */ - interrupt->enabled &= ~BIT(ipa_irq); - - reg = ipa_reg(ipa, IPA_IRQ_EN); - iowrite32(interrupt->enabled, ipa->reg_virt + ipa_reg_offset(reg)); + ipa_interrupt_disable(interrupt->ipa, ipa_irq); interrupt->handler[ipa_irq] = NULL; } From patchwork Fri Dec 30 23:22:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 638514 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D0CC0C3DA7C for ; Fri, 30 Dec 2022 23:22:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235714AbiL3XWj (ORCPT ); Fri, 30 Dec 2022 18:22:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35590 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235712AbiL3XWi (ORCPT ); Fri, 30 Dec 2022 18:22:38 -0500 Received: from mail-il1-x12b.google.com (mail-il1-x12b.google.com [IPv6:2607:f8b0:4864:20::12b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 83C1B1D0FF for ; Fri, 30 Dec 2022 15:22:37 -0800 (PST) Received: by mail-il1-x12b.google.com with SMTP id o8so12082314ilq.6 for ; Fri, 30 Dec 2022 15:22:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=jLNS1jPjRsNhBYA/KqVgb16Kll0yMpBx8G2zVP5MVaM=; b=RY25bn771moxhyGB8j59tS5rFfUKBjbENFEaSk/EJZimcttEKzdxemHNjZ1wIr++Tv emzvzcg5ketdJl8xF4h76GWBR7GvYN+5mevSo7xqUwTaHWrIQOrd0FxsqCQK2W+8Efxi uulwSJd78bpwzh4/BPcJAheCv4IMuZJYyi7ElysidEut68388vUVoHnH7wHK4Pz/MJeK eq0AHEQ9/f5Hm7P5XLfjGiWWgl4U3Jazs0Hy2+8bc7BWhYtOEu0WGY8onmOfivGa0XTN 1S01iJ8qzUyBqxz/X8wuOIBVdnL+xaP+47vq20/oF5BPydJLBZbIGAQQClGmYJARpvnD cIpw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=jLNS1jPjRsNhBYA/KqVgb16Kll0yMpBx8G2zVP5MVaM=; b=hcpP2s6+IUbQKeJ5738g7c+Aw6wuGzxhdv3DFuab+fHQRuNm4vfuQtwE9ZRN+W8BHl g2O+KkFItSXmLiKLUVtkJ8pDciwSg7eB0Km2gbPYRmKiltCa95Q0KfZF0OB0fuM2xAur zcho536EBHQHXwZUUF2ULbw1FjCCF4QfodczGObZVAuSUUFkh1b/a36Vrbxc28AVl56n f21gudLfmP/Yn2F0VFq0ZJCPSDlmTcNtOLqsIXs0SrRb5qlgEF3RiYQQJmUI96amVB9o 8FK26GZsjiwVU9L0UIZmtRQ82Plt8JmkKvt0qMad29AVHo//b29L7eBn/PtSm8M7nAgY fYaw== X-Gm-Message-State: AFqh2krt9YhAVnhUWJkJjolA5EoWQOTKKkYhALS9e2R/XWDsBvX+wVyj kEPbWPsfU2OrnpGKKj5vnxedGg== X-Google-Smtp-Source: AMrXdXtg3zmJHOHKF5bOxIIvWLS1v7cSxzS+mNeBrzTt4gXtqrZzaKq55DZIR7sjGl+6NUlpvrg9Dg== X-Received: by 2002:a92:d28c:0:b0:305:e0e1:56c5 with SMTP id p12-20020a92d28c000000b00305e0e156c5mr23058394ilp.19.1672442557115; Fri, 30 Dec 2022 15:22:37 -0800 (PST) Received: from presto.localdomain ([98.61.227.136]) by smtp.gmail.com with ESMTPSA id co18-20020a0566383e1200b0038a53fb3911sm7170558jab.97.2022.12.30.15.22.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 30 Dec 2022 15:22:36 -0800 (PST) From: Alex Elder To: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com Cc: caleb.connolly@linaro.org, mka@chromium.org, evgreen@chromium.org, andersson@kernel.org, quic_cpratapa@quicinc.com, quic_avuyyuru@quicinc.com, quic_jponduru@quicinc.com, quic_subashab@quicinc.com, elder@kernel.org, netdev@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next 3/6] net: ipa: enable IPA interrupt handlers separate from registration Date: Fri, 30 Dec 2022 17:22:27 -0600 Message-Id: <20221230232230.2348757-4-elder@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221230232230.2348757-1-elder@linaro.org> References: <20221230232230.2348757-1-elder@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Expose ipa_interrupt_enable() and have functions that register IPA interrupt handlers enable them directly, rather than having the registration process do that. Do the same for disabling IPA interrupt handlers. Signed-off-by: Alex Elder --- drivers/net/ipa/ipa_interrupt.c | 8 ++------ drivers/net/ipa/ipa_interrupt.h | 14 ++++++++++++++ drivers/net/ipa/ipa_power.c | 6 +++++- drivers/net/ipa/ipa_uc.c | 4 ++++ 4 files changed, 25 insertions(+), 7 deletions(-) diff --git a/drivers/net/ipa/ipa_interrupt.c b/drivers/net/ipa/ipa_interrupt.c index 7b7388c14806f..87f4b94d02a3f 100644 --- a/drivers/net/ipa/ipa_interrupt.c +++ b/drivers/net/ipa/ipa_interrupt.c @@ -135,7 +135,7 @@ static void ipa_interrupt_enabled_update(struct ipa *ipa) } /* Enable an IPA interrupt type */ -static void ipa_interrupt_enable(struct ipa *ipa, enum ipa_irq_id ipa_irq) +void ipa_interrupt_enable(struct ipa *ipa, enum ipa_irq_id ipa_irq) { /* Update the IPA interrupt mask to enable it */ ipa->interrupt->enabled |= BIT(ipa_irq); @@ -143,7 +143,7 @@ static void ipa_interrupt_enable(struct ipa *ipa, enum ipa_irq_id ipa_irq) } /* Disable an IPA interrupt type */ -static void ipa_interrupt_disable(struct ipa *ipa, enum ipa_irq_id ipa_irq) +void ipa_interrupt_disable(struct ipa *ipa, enum ipa_irq_id ipa_irq) { /* Update the IPA interrupt mask to disable it */ ipa->interrupt->enabled &= ~BIT(ipa_irq); @@ -232,8 +232,6 @@ void ipa_interrupt_add(struct ipa_interrupt *interrupt, return; interrupt->handler[ipa_irq] = handler; - - ipa_interrupt_enable(interrupt->ipa, ipa_irq); } /* Remove the handler for an IPA interrupt type */ @@ -243,8 +241,6 @@ ipa_interrupt_remove(struct ipa_interrupt *interrupt, enum ipa_irq_id ipa_irq) if (WARN_ON(ipa_irq >= IPA_IRQ_COUNT)) return; - ipa_interrupt_disable(interrupt->ipa, ipa_irq); - interrupt->handler[ipa_irq] = NULL; } diff --git a/drivers/net/ipa/ipa_interrupt.h b/drivers/net/ipa/ipa_interrupt.h index f31fd9965fdc6..5f7d2e90ea337 100644 --- a/drivers/net/ipa/ipa_interrupt.h +++ b/drivers/net/ipa/ipa_interrupt.h @@ -85,6 +85,20 @@ void ipa_interrupt_suspend_clear_all(struct ipa_interrupt *interrupt); */ void ipa_interrupt_simulate_suspend(struct ipa_interrupt *interrupt); +/** + * ipa_interrupt_enable() - Enable an IPA interrupt type + * @ipa: IPA pointer + * @ipa_irq: IPA interrupt ID + */ +void ipa_interrupt_enable(struct ipa *ipa, enum ipa_irq_id ipa_irq); + +/** + * ipa_interrupt_disable() - Disable an IPA interrupt type + * @ipa: IPA pointer + * @ipa_irq: IPA interrupt ID + */ +void ipa_interrupt_disable(struct ipa *ipa, enum ipa_irq_id ipa_irq); + /** * ipa_interrupt_config() - Configure the IPA interrupt framework * @ipa: IPA pointer diff --git a/drivers/net/ipa/ipa_power.c b/drivers/net/ipa/ipa_power.c index 8420f93128a26..9148d606d5fc2 100644 --- a/drivers/net/ipa/ipa_power.c +++ b/drivers/net/ipa/ipa_power.c @@ -337,10 +337,13 @@ int ipa_power_setup(struct ipa *ipa) ipa_interrupt_add(ipa->interrupt, IPA_IRQ_TX_SUSPEND, ipa_suspend_handler); + ipa_interrupt_enable(ipa, IPA_IRQ_TX_SUSPEND); ret = device_init_wakeup(&ipa->pdev->dev, true); - if (ret) + if (ret) { + ipa_interrupt_disable(ipa, IPA_IRQ_TX_SUSPEND); ipa_interrupt_remove(ipa->interrupt, IPA_IRQ_TX_SUSPEND); + } return ret; } @@ -348,6 +351,7 @@ int ipa_power_setup(struct ipa *ipa) void ipa_power_teardown(struct ipa *ipa) { (void)device_init_wakeup(&ipa->pdev->dev, false); + ipa_interrupt_disable(ipa, IPA_IRQ_TX_SUSPEND); ipa_interrupt_remove(ipa->interrupt, IPA_IRQ_TX_SUSPEND); } diff --git a/drivers/net/ipa/ipa_uc.c b/drivers/net/ipa/ipa_uc.c index 0a890b44c09e1..af541758d047f 100644 --- a/drivers/net/ipa/ipa_uc.c +++ b/drivers/net/ipa/ipa_uc.c @@ -187,7 +187,9 @@ void ipa_uc_config(struct ipa *ipa) ipa->uc_powered = false; ipa->uc_loaded = false; ipa_interrupt_add(interrupt, IPA_IRQ_UC_0, ipa_uc_interrupt_handler); + ipa_interrupt_enable(ipa, IPA_IRQ_UC_0); ipa_interrupt_add(interrupt, IPA_IRQ_UC_1, ipa_uc_interrupt_handler); + ipa_interrupt_enable(ipa, IPA_IRQ_UC_1); } /* Inverse of ipa_uc_config() */ @@ -195,7 +197,9 @@ void ipa_uc_deconfig(struct ipa *ipa) { struct device *dev = &ipa->pdev->dev; + ipa_interrupt_disable(ipa, IPA_IRQ_UC_1); ipa_interrupt_remove(ipa->interrupt, IPA_IRQ_UC_1); + ipa_interrupt_disable(ipa, IPA_IRQ_UC_0); ipa_interrupt_remove(ipa->interrupt, IPA_IRQ_UC_0); if (ipa->uc_loaded) ipa_power_retention(ipa, false); From patchwork Fri Dec 30 23:22:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 637895 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 06993C3DA7D for ; Fri, 30 Dec 2022 23:22:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235741AbiL3XWt (ORCPT ); Fri, 30 Dec 2022 18:22:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35632 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235721AbiL3XWk (ORCPT ); Fri, 30 Dec 2022 18:22:40 -0500 Received: from mail-io1-xd2d.google.com (mail-io1-xd2d.google.com [IPv6:2607:f8b0:4864:20::d2d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F0F5D1D0FE for ; Fri, 30 Dec 2022 15:22:38 -0800 (PST) Received: by mail-io1-xd2d.google.com with SMTP id z126so809622iof.13 for ; Fri, 30 Dec 2022 15:22:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=/QwLXlyTB2wFg+f6fFku0I75a5v4iUbGFGBGgx1ehZU=; b=Hm/2P/6UQt95HbAVFv1sCJXkTom3AbsammWHPMUG40G54OIgo/cqYR6oXISj+b4q/E LEllnhOipFjtKw3vVMwA/4UWuq/QgXonkOyHF3CXsO7uhj/QqZCllWF+gvdQPKJsfaWQ Ftv7BtQ/D/RTcpVQNciTyc+OrXwPNNAR/rjh7eT0rHOXkDJAlEoj5AkHU3+nezzWhKYU +7NyRTcDqLVgWJNkJCvO+ZB7VQ/E3SIkIwF6SKy8YY3Ac74iyZbBQ2Wlaw2g1os9JCg/ I8j+ZGuCigaCvXArs9FOCSL9nG9Axldnblge5aDsL2b/ZW+b0Iodq4Q0mAmnMtnzArS2 8EQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=/QwLXlyTB2wFg+f6fFku0I75a5v4iUbGFGBGgx1ehZU=; b=YK+DZ7M9+efm3hKrqCxEwrOUdjho9baW4vZr+su/lbx2L2+swoB7Zw4jYdp1qNhcoH 7p4iawY9um3bhTZLVBfuuwmglRo7JNeeZJCd7jCKvJ1Qm74gDedUqVcnK9tiimWVlrch zhrJ4aillXraO9byhETGAD+ZqxTynZFFtO4jjYjcPnBMSvmPz8ZKtpVziTPgO6n67jso 6jgFeNt9ZGnDleg8bIVZIKdboOpDZQmKzmlIeQ73c3755Xx7CZ8uG4Xb/a47mPkowzcu VdnzvFZPXgD7FtsPKXisuJl99xGg04/+ysu/83LfkUdU18ROibHqX3oVGiTdQnKX3Ydb vG3A== X-Gm-Message-State: AFqh2kqky2jRA6ZvA520wPEEyn0uvPeOqOggn+iw4RYKnlMbPWNB+Ii7 8y+JJzrCMG6iyDf7U6qcu7Z6DQ== X-Google-Smtp-Source: AMrXdXu+YeBztMH+Q3qXIzekNBvvKfknXvWCruTAa/AdlVS1m4dMccVfiveGyeTatllaczAPr2zQKQ== X-Received: by 2002:a5d:8b11:0:b0:6df:de92:91ab with SMTP id k17-20020a5d8b11000000b006dfde9291abmr22002441ion.10.1672442558277; Fri, 30 Dec 2022 15:22:38 -0800 (PST) Received: from presto.localdomain ([98.61.227.136]) by smtp.gmail.com with ESMTPSA id co18-20020a0566383e1200b0038a53fb3911sm7170558jab.97.2022.12.30.15.22.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 30 Dec 2022 15:22:38 -0800 (PST) From: Alex Elder To: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com Cc: caleb.connolly@linaro.org, mka@chromium.org, evgreen@chromium.org, andersson@kernel.org, quic_cpratapa@quicinc.com, quic_avuyyuru@quicinc.com, quic_jponduru@quicinc.com, quic_subashab@quicinc.com, elder@kernel.org, netdev@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next 4/6] net: ipa: register IPA interrupt handlers directly Date: Fri, 30 Dec 2022 17:22:28 -0600 Message-Id: <20221230232230.2348757-5-elder@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221230232230.2348757-1-elder@linaro.org> References: <20221230232230.2348757-1-elder@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Declare the microcontroller IPA interrupt handler publicly, and assign it directly in ipa_interrupt_config(). Make the SUSPEND IPA interrupt handler public, and rename it ipa_power_suspend_handler(). Assign it directly in ipa_interrupt_config() as well. This makes it unnecessary to do this in ipa_interrupt_add(). Make similar changes for removing IPA interrupt handlers. The next two patches will finish the cleanup, removing the add/remove functions and the handler array entirely. Signed-off-by: Alex Elder --- drivers/net/ipa/ipa_interrupt.c | 16 ++++++++-------- drivers/net/ipa/ipa_power.c | 14 ++------------ drivers/net/ipa/ipa_power.h | 12 ++++++++++++ drivers/net/ipa/ipa_uc.c | 2 +- drivers/net/ipa/ipa_uc.h | 8 ++++++++ 5 files changed, 31 insertions(+), 21 deletions(-) diff --git a/drivers/net/ipa/ipa_interrupt.c b/drivers/net/ipa/ipa_interrupt.c index 87f4b94d02a3f..f32ac40a79372 100644 --- a/drivers/net/ipa/ipa_interrupt.c +++ b/drivers/net/ipa/ipa_interrupt.c @@ -26,6 +26,8 @@ #include "ipa.h" #include "ipa_reg.h" #include "ipa_endpoint.h" +#include "ipa_power.h" +#include "ipa_uc.h" #include "ipa_interrupt.h" /** @@ -228,20 +230,14 @@ void ipa_interrupt_simulate_suspend(struct ipa_interrupt *interrupt) void ipa_interrupt_add(struct ipa_interrupt *interrupt, enum ipa_irq_id ipa_irq, ipa_irq_handler_t handler) { - if (WARN_ON(ipa_irq >= IPA_IRQ_COUNT)) - return; - - interrupt->handler[ipa_irq] = handler; + WARN_ON(ipa_irq >= IPA_IRQ_COUNT); } /* Remove the handler for an IPA interrupt type */ void ipa_interrupt_remove(struct ipa_interrupt *interrupt, enum ipa_irq_id ipa_irq) { - if (WARN_ON(ipa_irq >= IPA_IRQ_COUNT)) - return; - - interrupt->handler[ipa_irq] = NULL; + WARN_ON(ipa_irq >= IPA_IRQ_COUNT); } /* Configure the IPA interrupt framework */ @@ -284,6 +280,10 @@ struct ipa_interrupt *ipa_interrupt_config(struct ipa *ipa) goto err_free_irq; } + interrupt->handler[IPA_IRQ_UC_0] = ipa_uc_interrupt_handler; + interrupt->handler[IPA_IRQ_UC_1] = ipa_uc_interrupt_handler; + interrupt->handler[IPA_IRQ_TX_SUSPEND] = ipa_power_suspend_handler; + return interrupt; err_free_irq: diff --git a/drivers/net/ipa/ipa_power.c b/drivers/net/ipa/ipa_power.c index 9148d606d5fc2..4198f8e97e40b 100644 --- a/drivers/net/ipa/ipa_power.c +++ b/drivers/net/ipa/ipa_power.c @@ -202,17 +202,7 @@ u32 ipa_core_clock_rate(struct ipa *ipa) return ipa->power ? (u32)clk_get_rate(ipa->power->core) : 0; } -/** - * ipa_suspend_handler() - Handle the suspend IPA interrupt - * @ipa: IPA pointer - * @irq_id: IPA interrupt type (unused) - * - * If an RX endpoint is suspended, and the IPA has a packet destined for - * that endpoint, the IPA generates a SUSPEND interrupt to inform the AP - * that it should resume the endpoint. If we get one of these interrupts - * we just wake up the system. - */ -static void ipa_suspend_handler(struct ipa *ipa, enum ipa_irq_id irq_id) +void ipa_power_suspend_handler(struct ipa *ipa, enum ipa_irq_id irq_id) { /* To handle an IPA interrupt we will have resumed the hardware * just to handle the interrupt, so we're done. If we are in a @@ -336,7 +326,7 @@ int ipa_power_setup(struct ipa *ipa) int ret; ipa_interrupt_add(ipa->interrupt, IPA_IRQ_TX_SUSPEND, - ipa_suspend_handler); + ipa_power_suspend_handler); ipa_interrupt_enable(ipa, IPA_IRQ_TX_SUSPEND); ret = device_init_wakeup(&ipa->pdev->dev, true); diff --git a/drivers/net/ipa/ipa_power.h b/drivers/net/ipa/ipa_power.h index 896f052e51a1c..3a4c59ea1222b 100644 --- a/drivers/net/ipa/ipa_power.h +++ b/drivers/net/ipa/ipa_power.h @@ -10,6 +10,7 @@ struct device; struct ipa; struct ipa_power_data; +enum ipa_irq_id; /* IPA device power management function block */ extern const struct dev_pm_ops ipa_pm_ops; @@ -47,6 +48,17 @@ void ipa_power_modem_queue_active(struct ipa *ipa); */ void ipa_power_retention(struct ipa *ipa, bool enable); +/** + * ipa_power_suspend_handler() - Handler for SUSPEND IPA interrupts + * @ipa: IPA pointer + * @irq_id: IPA interrupt ID (unused) + * + * If an RX endpoint is suspended, and the IPA has a packet destined for + * that endpoint, the IPA generates a SUSPEND interrupt to inform the AP + * that it should resume the endpoint. + */ +void ipa_power_suspend_handler(struct ipa *ipa, enum ipa_irq_id irq_id); + /** * ipa_power_setup() - Set up IPA power management * @ipa: IPA pointer diff --git a/drivers/net/ipa/ipa_uc.c b/drivers/net/ipa/ipa_uc.c index af541758d047f..6b7d289cfaffa 100644 --- a/drivers/net/ipa/ipa_uc.c +++ b/drivers/net/ipa/ipa_uc.c @@ -170,7 +170,7 @@ static void ipa_uc_response_hdlr(struct ipa *ipa) } } -static void ipa_uc_interrupt_handler(struct ipa *ipa, enum ipa_irq_id irq_id) +void ipa_uc_interrupt_handler(struct ipa *ipa, enum ipa_irq_id irq_id) { /* Silently ignore anything unrecognized */ if (irq_id == IPA_IRQ_UC_0) diff --git a/drivers/net/ipa/ipa_uc.h b/drivers/net/ipa/ipa_uc.h index 8514096e6f36f..85aa0df818c23 100644 --- a/drivers/net/ipa/ipa_uc.h +++ b/drivers/net/ipa/ipa_uc.h @@ -7,6 +7,14 @@ #define _IPA_UC_H_ struct ipa; +enum ipa_irq_id; + +/** + * ipa_uc_interrupt_handler() - Handler for microcontroller IPA interrupts + * @ipa: IPA pointer + * @irq_id: IPA interrupt ID + */ +void ipa_uc_interrupt_handler(struct ipa *ipa, enum ipa_irq_id irq_id); /** * ipa_uc_config() - Configure the IPA microcontroller subsystem From patchwork Fri Dec 30 23:22:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 638513 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AE75BC4332F for ; Fri, 30 Dec 2022 23:22:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235752AbiL3XWy (ORCPT ); Fri, 30 Dec 2022 18:22:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35690 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235725AbiL3XWo (ORCPT ); Fri, 30 Dec 2022 18:22:44 -0500 Received: from mail-il1-x12b.google.com (mail-il1-x12b.google.com [IPv6:2607:f8b0:4864:20::12b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 228B41DDC5 for ; Fri, 30 Dec 2022 15:22:40 -0800 (PST) Received: by mail-il1-x12b.google.com with SMTP id c20so8246847ilj.10 for ; Fri, 30 Dec 2022 15:22:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=/5hYek3nB0dmId6hp5MbMyiFoPLMoLSONTQq8CabMoo=; b=ThNXYLsEVsgBPhzs5Uq7WacMqSL5M7UajFCbfbhPx5wOLapYvV1osW5+VDozSkPYOI ut4z+T/fz4zFWaYz1P3w2cFBc3/Lq0jjU51J0i0A3IRAqy5PQqnp3nqDDzy6AZrGOkBx veXgFUdmpJga3FgDZuirF6OHbfubI+JD5QO2sOQMem17XO2kTdaIPhdozHZO0WHPrSfR ZXogBQQmks8srE/gDmd4kTfr2+BlHTi290JanaEKjiMsogBf5lSM0BJkMRqLqv2haFRG UE/spAzS9ccUc7FxoqvKYGwSUkn9UnsxaDnpgni686T8Wi+nem5Tc82WpF/kaLQxcZrb /jsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=/5hYek3nB0dmId6hp5MbMyiFoPLMoLSONTQq8CabMoo=; b=Sf6GqfhsaRGC7Bu8YsErZl+4tZC2pk+RkA4l53YY9wvIwFd814A0Xhu62HuyuwDb/K 9kbOF7M8nanSrMpa1DTtfaEfVL9iplqSuwakhkez1dKa8XNhaLuAgJ+YfD7iuL7nNSla kr/kqX0rAtKyH3+0fspe9mF4t8PcCUgUwwtegQBCdquuQacj4CCxhN4V+c+395rLUaVw 1QEb08oiSpxDwE5J381FWhUUquuuOy886RYqYpQRBOzt6AgYrRmIIYd6fkIqn/h9I2es tRZ71w5JV531NjvFsN9tofmDKeaRx7CZbfmdgJepSR/FzX3zkiDo1LJu1MIPIu82tzQo MziA== X-Gm-Message-State: AFqh2koJfcJydcps79fQNX5RP/T3IfWJHQlRVxI0tmY7Pu+46SutuabX iw1kG5ZbI8I1A+q9HsBY4Phv+g== X-Google-Smtp-Source: AMrXdXuOwnnWmSMz2q/fl3VFwD3Njo9F6YqQcUoyIMiAkbUKdRfoqdlsdAP12rCRviz/70r4S3K0Kg== X-Received: by 2002:a05:6e02:68c:b0:300:60df:e13e with SMTP id o12-20020a056e02068c00b0030060dfe13emr20628795ils.25.1672442559371; Fri, 30 Dec 2022 15:22:39 -0800 (PST) Received: from presto.localdomain ([98.61.227.136]) by smtp.gmail.com with ESMTPSA id co18-20020a0566383e1200b0038a53fb3911sm7170558jab.97.2022.12.30.15.22.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 30 Dec 2022 15:22:39 -0800 (PST) From: Alex Elder To: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com Cc: caleb.connolly@linaro.org, mka@chromium.org, evgreen@chromium.org, andersson@kernel.org, quic_cpratapa@quicinc.com, quic_avuyyuru@quicinc.com, quic_jponduru@quicinc.com, quic_subashab@quicinc.com, elder@kernel.org, netdev@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next 5/6] net: ipa: kill ipa_interrupt_add() Date: Fri, 30 Dec 2022 17:22:29 -0600 Message-Id: <20221230232230.2348757-6-elder@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221230232230.2348757-1-elder@linaro.org> References: <20221230232230.2348757-1-elder@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org The dynamic assignment of IPA interrupt handlers isn't needed; we only handle three IPA interrupt types, and their handler functions are now assigned directly. We can get rid of ipa_interrupt_add() and ipa_interrupt_remove() now, because they serve no purpose. Signed-off-by: Alex Elder --- drivers/net/ipa/ipa_interrupt.c | 16 ++-------------- drivers/net/ipa/ipa_interrupt.h | 33 --------------------------------- drivers/net/ipa/ipa_power.c | 7 +------ drivers/net/ipa/ipa_uc.c | 6 ------ 4 files changed, 3 insertions(+), 59 deletions(-) diff --git a/drivers/net/ipa/ipa_interrupt.c b/drivers/net/ipa/ipa_interrupt.c index f32ac40a79372..f0a68b0a242c1 100644 --- a/drivers/net/ipa/ipa_interrupt.c +++ b/drivers/net/ipa/ipa_interrupt.c @@ -30,6 +30,8 @@ #include "ipa_uc.h" #include "ipa_interrupt.h" +typedef void (*ipa_irq_handler_t)(struct ipa *ipa, enum ipa_irq_id irq_id); + /** * struct ipa_interrupt - IPA interrupt information * @ipa: IPA pointer @@ -226,20 +228,6 @@ void ipa_interrupt_simulate_suspend(struct ipa_interrupt *interrupt) ipa_interrupt_process(interrupt, IPA_IRQ_TX_SUSPEND); } -/* Add a handler for an IPA interrupt */ -void ipa_interrupt_add(struct ipa_interrupt *interrupt, - enum ipa_irq_id ipa_irq, ipa_irq_handler_t handler) -{ - WARN_ON(ipa_irq >= IPA_IRQ_COUNT); -} - -/* Remove the handler for an IPA interrupt type */ -void -ipa_interrupt_remove(struct ipa_interrupt *interrupt, enum ipa_irq_id ipa_irq) -{ - WARN_ON(ipa_irq >= IPA_IRQ_COUNT); -} - /* Configure the IPA interrupt framework */ struct ipa_interrupt *ipa_interrupt_config(struct ipa *ipa) { diff --git a/drivers/net/ipa/ipa_interrupt.h b/drivers/net/ipa/ipa_interrupt.h index 5f7d2e90ea337..c1df054be8fab 100644 --- a/drivers/net/ipa/ipa_interrupt.h +++ b/drivers/net/ipa/ipa_interrupt.h @@ -12,39 +12,6 @@ struct ipa; struct ipa_interrupt; -/** - * typedef ipa_irq_handler_t - IPA interrupt handler function type - * @ipa: IPA pointer - * @irq_id: interrupt type - * - * Callback function registered by ipa_interrupt_add() to handle a specific - * IPA interrupt type - */ -typedef void (*ipa_irq_handler_t)(struct ipa *ipa, enum ipa_irq_id irq_id); - -/** - * ipa_interrupt_add() - Register a handler for an IPA interrupt type - * @interrupt: IPA interrupt structure - * @irq_id: IPA interrupt type - * @handler: Handler function for the interrupt - * - * Add a handler for an IPA interrupt and enable it. IPA interrupt - * handlers are run in threaded interrupt context, so are allowed to - * block. - */ -void ipa_interrupt_add(struct ipa_interrupt *interrupt, enum ipa_irq_id irq_id, - ipa_irq_handler_t handler); - -/** - * ipa_interrupt_remove() - Remove the handler for an IPA interrupt type - * @interrupt: IPA interrupt structure - * @irq_id: IPA interrupt type - * - * Remove an IPA interrupt handler and disable it. - */ -void ipa_interrupt_remove(struct ipa_interrupt *interrupt, - enum ipa_irq_id irq_id); - /** * ipa_interrupt_suspend_enable - Enable TX_SUSPEND for an endpoint * @interrupt: IPA interrupt structure diff --git a/drivers/net/ipa/ipa_power.c b/drivers/net/ipa/ipa_power.c index 4198f8e97e40b..a282512ebd2d8 100644 --- a/drivers/net/ipa/ipa_power.c +++ b/drivers/net/ipa/ipa_power.c @@ -325,15 +325,11 @@ int ipa_power_setup(struct ipa *ipa) { int ret; - ipa_interrupt_add(ipa->interrupt, IPA_IRQ_TX_SUSPEND, - ipa_power_suspend_handler); ipa_interrupt_enable(ipa, IPA_IRQ_TX_SUSPEND); ret = device_init_wakeup(&ipa->pdev->dev, true); - if (ret) { + if (ret) ipa_interrupt_disable(ipa, IPA_IRQ_TX_SUSPEND); - ipa_interrupt_remove(ipa->interrupt, IPA_IRQ_TX_SUSPEND); - } return ret; } @@ -342,7 +338,6 @@ void ipa_power_teardown(struct ipa *ipa) { (void)device_init_wakeup(&ipa->pdev->dev, false); ipa_interrupt_disable(ipa, IPA_IRQ_TX_SUSPEND); - ipa_interrupt_remove(ipa->interrupt, IPA_IRQ_TX_SUSPEND); } /* Initialize IPA power management */ diff --git a/drivers/net/ipa/ipa_uc.c b/drivers/net/ipa/ipa_uc.c index 6b7d289cfaffa..cb8a76a75f21d 100644 --- a/drivers/net/ipa/ipa_uc.c +++ b/drivers/net/ipa/ipa_uc.c @@ -182,13 +182,9 @@ void ipa_uc_interrupt_handler(struct ipa *ipa, enum ipa_irq_id irq_id) /* Configure the IPA microcontroller subsystem */ void ipa_uc_config(struct ipa *ipa) { - struct ipa_interrupt *interrupt = ipa->interrupt; - ipa->uc_powered = false; ipa->uc_loaded = false; - ipa_interrupt_add(interrupt, IPA_IRQ_UC_0, ipa_uc_interrupt_handler); ipa_interrupt_enable(ipa, IPA_IRQ_UC_0); - ipa_interrupt_add(interrupt, IPA_IRQ_UC_1, ipa_uc_interrupt_handler); ipa_interrupt_enable(ipa, IPA_IRQ_UC_1); } @@ -198,9 +194,7 @@ void ipa_uc_deconfig(struct ipa *ipa) struct device *dev = &ipa->pdev->dev; ipa_interrupt_disable(ipa, IPA_IRQ_UC_1); - ipa_interrupt_remove(ipa->interrupt, IPA_IRQ_UC_1); ipa_interrupt_disable(ipa, IPA_IRQ_UC_0); - ipa_interrupt_remove(ipa->interrupt, IPA_IRQ_UC_0); if (ipa->uc_loaded) ipa_power_retention(ipa, false); From patchwork Fri Dec 30 23:22:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 637894 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 14336C3DA7C for ; Fri, 30 Dec 2022 23:23:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235779AbiL3XXC (ORCPT ); Fri, 30 Dec 2022 18:23:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35612 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235733AbiL3XWr (ORCPT ); Fri, 30 Dec 2022 18:22:47 -0500 Received: from mail-il1-x12c.google.com (mail-il1-x12c.google.com [IPv6:2607:f8b0:4864:20::12c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 243C11DDD6 for ; Fri, 30 Dec 2022 15:22:41 -0800 (PST) Received: by mail-il1-x12c.google.com with SMTP id o8so12105417ilo.1 for ; Fri, 30 Dec 2022 15:22:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=25pBUtrT1XiV3gX50trdZQF7DviwuSyPLPkde8po6zE=; b=E0JZ88iBO8dIMiyDZgV2f3Ta5893v6HdzLJZvj4IHdoC0mPBYmxK78JT5vpGFuNGGQ KxcLb1saMJG5Yb71HlwJydIyn97Y9Fa5iEuXnCxJqMRhABAjmdlWAuZzbPxjDrNRzRa1 TLqKgpHkN1RuuDNEM4Mi0OrOf82ZAtEzo0rh55XmdRTig47EV0u5F7l4Dxs5jd3H51vq y23M5KWwvN2LjG+UwfFyhVtV94qfPNQ1Ts7+eTA3Q81Oz/CTqYhn9GHVV1dfmIaIMGQe iQTipTj53kOAa0Eeqbl7zqr+OmZq3+J2dtxPT8vnGUYwEsWdZ74mgs+y9nXCa0COfVak 6S5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=25pBUtrT1XiV3gX50trdZQF7DviwuSyPLPkde8po6zE=; b=Yo1PgLazJqyoR9EYVeTwJZYeqO4ncL9rqWivrL/7Y66mDY2y3jMaDK1ailqv5FlME5 AlJPujwo/6GWLuR/b9zI9q5s3R8M5Sn3NXGEyM1YgwECcZ0nscVXZNc+02uKOD2qY4fw NUMXF/109rPOujefMEK1G7sFRIt16SLMjty9BCpFJbW0OIs7SJtoyPFHLJX3z54MIuwu r/65d2d3J3v5sJQ2XGXgebl6MEuuylUdKM8iEY7xNm+wC5VNFOULovKsQqperoQmCK2L itzDygVrGlutcs0Z3lPG3LC8aP2iLuTccFnjpz/3PkIIS7a/SByPOv4MRjP+o1TuvIM+ DqYQ== X-Gm-Message-State: AFqh2kpAGUCHltxZOywCe8Plzj+ulT5p5XJCCdJgrgd+pMjbZZttYmiL 27fjr4eKDm8I3y2hRqWLTJ5B4A== X-Google-Smtp-Source: AMrXdXuTHFAs3nyjnITnt9LaOIbfJafXJakYiMb2bBzFUekT87v98SPg+IhTDRV1fZNx3B95QA+mdQ== X-Received: by 2002:a92:cc8b:0:b0:304:bf1c:559a with SMTP id x11-20020a92cc8b000000b00304bf1c559amr22444308ilo.11.1672442560471; Fri, 30 Dec 2022 15:22:40 -0800 (PST) Received: from presto.localdomain ([98.61.227.136]) by smtp.gmail.com with ESMTPSA id co18-20020a0566383e1200b0038a53fb3911sm7170558jab.97.2022.12.30.15.22.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 30 Dec 2022 15:22:40 -0800 (PST) From: Alex Elder To: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com Cc: caleb.connolly@linaro.org, mka@chromium.org, evgreen@chromium.org, andersson@kernel.org, quic_cpratapa@quicinc.com, quic_avuyyuru@quicinc.com, quic_jponduru@quicinc.com, quic_subashab@quicinc.com, elder@kernel.org, netdev@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next 6/6] net: ipa: don't maintain IPA interrupt handler array Date: Fri, 30 Dec 2022 17:22:30 -0600 Message-Id: <20221230232230.2348757-7-elder@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221230232230.2348757-1-elder@linaro.org> References: <20221230232230.2348757-1-elder@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org We can call the two IPA interrupt handler functions directly; there's no need to maintain the array of handler function pointers any more. Signed-off-by: Alex Elder --- drivers/net/ipa/ipa_interrupt.c | 46 ++++++++++++++------------------- 1 file changed, 20 insertions(+), 26 deletions(-) diff --git a/drivers/net/ipa/ipa_interrupt.c b/drivers/net/ipa/ipa_interrupt.c index f0a68b0a242c1..5f047b29e6ef0 100644 --- a/drivers/net/ipa/ipa_interrupt.c +++ b/drivers/net/ipa/ipa_interrupt.c @@ -30,54 +30,52 @@ #include "ipa_uc.h" #include "ipa_interrupt.h" -typedef void (*ipa_irq_handler_t)(struct ipa *ipa, enum ipa_irq_id irq_id); - /** * struct ipa_interrupt - IPA interrupt information * @ipa: IPA pointer * @irq: Linux IRQ number used for IPA interrupts * @enabled: Mask indicating which interrupts are enabled - * @handler: Array of handlers indexed by IPA interrupt ID */ struct ipa_interrupt { struct ipa *ipa; u32 irq; u32 enabled; - ipa_irq_handler_t handler[IPA_IRQ_COUNT]; }; -/* Returns true if the interrupt type is associated with the microcontroller */ -static bool ipa_interrupt_uc(struct ipa_interrupt *interrupt, u32 irq_id) -{ - return irq_id == IPA_IRQ_UC_0 || irq_id == IPA_IRQ_UC_1; -} - /* Process a particular interrupt type that has been received */ static void ipa_interrupt_process(struct ipa_interrupt *interrupt, u32 irq_id) { - bool uc_irq = ipa_interrupt_uc(interrupt, irq_id); struct ipa *ipa = interrupt->ipa; const struct ipa_reg *reg; u32 mask = BIT(irq_id); u32 offset; - /* For microcontroller interrupts, clear the interrupt right away, - * "to avoid clearing unhandled interrupts." - */ reg = ipa_reg(ipa, IPA_IRQ_CLR); offset = ipa_reg_offset(reg); - if (uc_irq) + + switch (irq_id) { + case IPA_IRQ_UC_0: + case IPA_IRQ_UC_1: + /* For microcontroller interrupts, clear the interrupt right + * away, "to avoid clearing unhandled interrupts." + */ iowrite32(mask, ipa->reg_virt + offset); + ipa_uc_interrupt_handler(ipa, irq_id); + break; - if (irq_id < IPA_IRQ_COUNT && interrupt->handler[irq_id]) - interrupt->handler[irq_id](interrupt->ipa, irq_id); + case IPA_IRQ_TX_SUSPEND: + /* Clearing the SUSPEND_TX interrupt also clears the + * register that tells us which suspended endpoint(s) + * caused the interrupt, so defer clearing until after + * the handler has been called. + */ + ipa_power_suspend_handler(ipa, irq_id); + fallthrough; - /* Clearing the SUSPEND_TX interrupt also clears the register - * that tells us which suspended endpoint(s) caused the interrupt, - * so defer clearing until after the handler has been called. - */ - if (!uc_irq) + default: /* Silently ignore (and clear) any other condition */ iowrite32(mask, ipa->reg_virt + offset); + break; + } } /* IPA IRQ handler is threaded */ @@ -268,10 +266,6 @@ struct ipa_interrupt *ipa_interrupt_config(struct ipa *ipa) goto err_free_irq; } - interrupt->handler[IPA_IRQ_UC_0] = ipa_uc_interrupt_handler; - interrupt->handler[IPA_IRQ_UC_1] = ipa_uc_interrupt_handler; - interrupt->handler[IPA_IRQ_TX_SUSPEND] = ipa_power_suspend_handler; - return interrupt; err_free_irq: