From patchwork Wed Jan 4 17:52:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 13088817 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 28ABFC4708D for ; Wed, 4 Jan 2023 17:52:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239670AbjADRwu (ORCPT ); Wed, 4 Jan 2023 12:52:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49466 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239918AbjADRwn (ORCPT ); Wed, 4 Jan 2023 12:52:43 -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 5BFEB395FA for ; Wed, 4 Jan 2023 09:52:39 -0800 (PST) Received: by mail-il1-x12b.google.com with SMTP id u8so19814495ilq.13 for ; Wed, 04 Jan 2023 09:52:39 -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=pUy9/yLcTSPL3IuDyGbacdjkCGV31SZWZXUcFAvvR5SuvUSK9t8Ql7NYsCklIYZQYu J1SB9h06cnJXtaX8CHbdgXVSwh6wRc8rYlNGPNLPOFnSeY2cjK0o6K9LUeq2IhuRacCB uZWEb+gRXm3c8uEgmCqg3MbOpnxDCO5JXVqdTDnSvFoQxXbr5SQibLFbWpcI8pxZeSce ykTTiX+O8btx+tXQCpX7SgtGJHD/GBo3XrlX1kJNryu7m4U3Lc0cCoEeC2DRj0Cu5au+ z41K1/eSknnnxN45DKYEAj+nEi05h4+ZyanQJ6SFFO0VeZFbFZuRQs837KU/gLduUz7K K1ww== 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=baIasDUe0YHVjhIh4HNhJqpv4MZ9dufuolpjrP8eWTl+bQzmrWibWuRDYeG1ylwIsx BaQ9ArE9b8L9gmFn+C0CBNM4Xbr/6zmFjS/nONuTXL9Mc6ggObzjDkP9soGKpte86PcM z0BaOP8br015sK3SyjlNbnlTmxf1AVoKvc5Ud2jqlSkJMU0N05aT9c5quPM4N74Vlu81 8vpxsg3NXlYMrnjzwZ6RJYkFCB5Z8TRy3g/Tyn9SqWXyLnFXEKXCVxAvb1Xr22xiBKRr ShaapzPoOjoSqK2dTegA+7vZ32c3UMONWhbUUT5HQKiYsLFWOAFW97iZ7S0xrWOAWFBE 2HTw== X-Gm-Message-State: AFqh2kq8WPTDa6aj/HBTjbk7bVW2YM9ba1ASnS/N3rx3EXFU5YaqYdPH zHEn1/lXM+j5CQJKUaSHHRiOtg== X-Google-Smtp-Source: AMrXdXuBYKsXs21FOuxGcpBwjdjmaud5vNrg5WsAeiFM8g+64zRwfA88pdkG1gpE6H0G2kgCCQz17A== X-Received: by 2002:a92:c748:0:b0:30b:f2a7:92c2 with SMTP id y8-20020a92c748000000b0030bf2a792c2mr25965907ilp.7.1672854758677; Wed, 04 Jan 2023 09:52:38 -0800 (PST) Received: from presto.localdomain ([98.61.227.136]) by smtp.gmail.com with ESMTPSA id u3-20020a02cbc3000000b00375783003fcsm10872304jaq.136.2023.01.04.09.52.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Jan 2023 09:52: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 v2 1/6] net: ipa: introduce a common microcontroller interrupt handler Date: Wed, 4 Jan 2023 11:52:28 -0600 Message-Id: <20230104175233.2862874-2-elder@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230104175233.2862874-1-elder@linaro.org> References: <20230104175233.2862874-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 Wed Jan 4 17:52:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 13088818 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 14BC4C46467 for ; Wed, 4 Jan 2023 17:53:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239889AbjADRwx (ORCPT ); Wed, 4 Jan 2023 12:52:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49466 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239965AbjADRwp (ORCPT ); Wed, 4 Jan 2023 12:52:45 -0500 Received: from mail-io1-xd2a.google.com (mail-io1-xd2a.google.com [IPv6:2607:f8b0:4864:20::d2a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7BA8E3AA85 for ; Wed, 4 Jan 2023 09:52:40 -0800 (PST) Received: by mail-io1-xd2a.google.com with SMTP id n63so18380629iod.7 for ; Wed, 04 Jan 2023 09:52: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=K4WtVwRcqcCUgmYfEzecLg1NkgyQK2BLzDcfIQJWkbQ=; b=h8gnm6sju51pnbVTrHG7dJ3fS0YGSSBjHduqzBKj7naghh/yHwuLG/OcorWd/hg/iI zAzVEhRojnlDUzHZgLq6J9qqivIm6QBOBR2H/lpci2TcI6u/7iU625Pm1MfE9dkYTCl3 uleCDGWgBPyI4lW1Pc7dnmz1iLic/ZgoSOLJXzIAUaflXCi7Yxhzx7YLEoy56lyEPM4L Oi7FYL6Ph8n/LTSjOMqXUj/GKxtoIH+1y9qO2LVYUj6D3Ot047MhzjGumq0HD50Md2m3 7sXd5nI9UfyxTfMYOVLIOz/+B9XxqeOoaDWjCOECf1PSZG1bcgKDN+ToSpZJ4i4/zNh+ wZLw== 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=VUi4uC6/C2T91i2zTexiVFCR8Gq1XP+6eK4/HpB5Ls12YjzJNEGpBnOD5GpvCZDRXY LRdEWR25/JQFLImuxSDKhNjwfNeb73XJMDueVrRTf7ETAdf0hmwz/URja5L9CrAeIMA/ etllJYFt2AOE/hfQ7uMepaKID0bQXxrZp2AMP4C2V2LCsVV0i6uQAvK7bJ86TDvE2TPf 7IwLiPIxxTSNDwiCFJFG79KTsHS/DorJ/UGNpGRsdfTr0m2Asbhat8zhodKouQqYRn00 fCgfQhrNyRfZfveZSut/e1fJfmoMJBLPEgTLlD/PjaKabV0/BVCQcS5PMEA0uMkK5/s7 ycxQ== X-Gm-Message-State: AFqh2kr86nE0cbRVKfMjxdQ27Vm+0oYHL82n3qV5oG36KuU/4ghlQqP+ gFSBAT7zq3N6I3DmSUuIzTcrmg== X-Google-Smtp-Source: AMrXdXsnEVsfLtfJQKG0qG3L9mvNdiI6gL1E8qt+Cxi9rD5msU3bhUQQ2dX6QVIHyuhPhwPCBpcQsA== X-Received: by 2002:a5e:a519:0:b0:6dc:30bd:ed81 with SMTP id 25-20020a5ea519000000b006dc30bded81mr31254368iog.20.1672854759828; Wed, 04 Jan 2023 09:52:39 -0800 (PST) Received: from presto.localdomain ([98.61.227.136]) by smtp.gmail.com with ESMTPSA id u3-20020a02cbc3000000b00375783003fcsm10872304jaq.136.2023.01.04.09.52.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Jan 2023 09:52: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 v2 2/6] net: ipa: introduce ipa_interrupt_enable() Date: Wed, 4 Jan 2023 11:52:29 -0600 Message-Id: <20230104175233.2862874-3-elder@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230104175233.2862874-1-elder@linaro.org> References: <20230104175233.2862874-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 Wed Jan 4 17:52:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 13088820 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 5F70AC53210 for ; Wed, 4 Jan 2023 17:53:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240050AbjADRwy (ORCPT ); Wed, 4 Jan 2023 12:52:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49542 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239993AbjADRwq (ORCPT ); Wed, 4 Jan 2023 12:52:46 -0500 Received: from mail-il1-x130.google.com (mail-il1-x130.google.com [IPv6:2607:f8b0:4864:20::130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ADFC33AA9D for ; Wed, 4 Jan 2023 09:52:41 -0800 (PST) Received: by mail-il1-x130.google.com with SMTP id z10so11533747ilq.8 for ; Wed, 04 Jan 2023 09:52: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=ri11bVKWxZ8HBQVrgBnLCZL7on//0SsmMOvFkbNuqmY=; b=hf9r/IxUGvYos/EypH+LZsWy8zskjLfb8hLTytQYwDKiOfBHIQN9yppwS+wprEwTqp +KGvNPxNIF8/feFE5Dkbdft9D0c5Nhy0j8dRVcRSCRDFihBg1/Lyv5MRFEhGgtiXhD0A XlvOsCvqsjt/JsZ3Miy3cAdiAURANrXzx/dE6/HJ/TXC0mx7RwUbtGUboFhkoD5KoikE 8oRjsxL3uJdiqfc4DE9KrG5bhv6GIb3svJpl0KN+v+yYYYbxvAvemmzIbWBSrvnr/JFw JAHcKs9asNWQVBtiQ5yFhOEntOALTV0n+I1tnWSr1SmJq5vvAHpIpKUeZFzItzh4a2js NzKA== 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=ri11bVKWxZ8HBQVrgBnLCZL7on//0SsmMOvFkbNuqmY=; b=8GLgAMiRVwRA+vuXCwCJpW1U/1/eCtsZeUPlZdHHl5Y08wQrqiU21CWZggOp1FM2E2 KyfjEfwOuv6ioIoUcCblwn2bwcwCA+jmD+0vcSucgfvoyc2EJ40h/hYov8BjADFmkIB3 9iT6EGZl0RjSc5JbZSARZo9L864OuvJ7itkne5sUuA2j04+PKW4HuOgchR5CgBHR0IZq 6MF7HIAUjlVPiSiW8suiRIVB6Nk92JCht8yCXQCxsNqZ4QwnUPRg8BvK0PPba2WItGA/ +y1b8q2UXmUNzetVM2qPLrJ9Hfg4NpJejTildC5uxzTQgUstjDQiTQtwS7uh/3Zc2AHl sm0g== X-Gm-Message-State: AFqh2ko9fAHT/xYEQ35XqI+XaEZMGLSOibfVxzkUlvMczu/PVPFKDSFP D4H7dCLWnIeO8kY7tvzMJdm58w== X-Google-Smtp-Source: AMrXdXvrZ16sUX5HG4IZ1soj1+hicAdUMGAv2csS9G9UVGcFQfrS33hUW2MYxftdcny617USzT4xKw== X-Received: by 2002:a05:6e02:13d2:b0:30c:251d:f98e with SMTP id v18-20020a056e0213d200b0030c251df98emr14071642ilj.27.1672854760959; Wed, 04 Jan 2023 09:52:40 -0800 (PST) Received: from presto.localdomain ([98.61.227.136]) by smtp.gmail.com with ESMTPSA id u3-20020a02cbc3000000b00375783003fcsm10872304jaq.136.2023.01.04.09.52.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Jan 2023 09:52: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 v2 3/6] net: ipa: enable IPA interrupt handlers separate from registration Date: Wed, 4 Jan 2023 11:52:30 -0600 Message-Id: <20230104175233.2862874-4-elder@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230104175233.2862874-1-elder@linaro.org> References: <20230104175233.2862874-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 --- v2 Declared enum ipa_irq_id at the top of "ipa_interrupt.c". drivers/net/ipa/ipa_interrupt.c | 8 ++------ drivers/net/ipa/ipa_interrupt.h | 15 +++++++++++++++ drivers/net/ipa/ipa_power.c | 6 +++++- drivers/net/ipa/ipa_uc.c | 4 ++++ 4 files changed, 26 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..90b61e013064b 100644 --- a/drivers/net/ipa/ipa_interrupt.h +++ b/drivers/net/ipa/ipa_interrupt.h @@ -11,6 +11,7 @@ struct ipa; struct ipa_interrupt; +enum ipa_irq_id; /** * typedef ipa_irq_handler_t - IPA interrupt handler function type @@ -85,6 +86,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 Wed Jan 4 17:52:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 13088821 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 86D32C54EBE for ; Wed, 4 Jan 2023 17:53:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239965AbjADRwy (ORCPT ); Wed, 4 Jan 2023 12:52:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49460 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240020AbjADRwr (ORCPT ); Wed, 4 Jan 2023 12:52:47 -0500 Received: from mail-io1-xd2c.google.com (mail-io1-xd2c.google.com [IPv6:2607:f8b0:4864:20::d2c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C32053B903 for ; Wed, 4 Jan 2023 09:52:42 -0800 (PST) Received: by mail-io1-xd2c.google.com with SMTP id h6so18381818iof.9 for ; Wed, 04 Jan 2023 09:52:42 -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=xrrxam0XOk7hykrPjRzHHIp0hv6JZmzE2vflvDLE1rjC6SR7Wt19lnE4BCK2OSlqF7 FRRdK76E2Ii6nVseaiIZ+AuHjnIfYccAj3WkNKPF4YWT0BEXaW0Y7PyRcOY5mYlGSKfJ H/cKOaqSxbOuLTratRvGFMmNa/+5p9Rbyu5Zg7Qarg7t2kDj2GxaxIgttXGOKAM5Un8y XOzE2XY5ss+E0FmBt1s7i4yju0XWtUdfd9Lshzaq8OUJR9n/dL0I/z/UM5u4PIwGajmq zfZtkvxuA8HHCCp85HCAeGovfy4g7Ank4ZULfl52A/yaMzIQN0L7nmJLZABfrvIt6Riw BlRA== 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=TS0r98W7fkS69CtIgOdH8xqLm9NmQCz2GvhNeTLUaUhBl+g0FEdNrN+sd0HqlOuTh5 y8C7BMU1JnjWvmDhdG2ilxC4r+koFmw4DEzlRVJ5KKlf2pTQ1VCCLUOfbRrjtLfdbhS6 4+DxzxYyEuwi8fPutnTZvYw/1DknTRoZVGGgsl6SIAp3D0mZGba0hF7/QNSK3vLZt9Xq T4Pyve2IqkEJXR+DQxAw+yMyjrwsDSXvZ1ZKku3BugNQzPtLScj0j1qTtuqkeTY6smNj VC8fDCmc1n2PiyuMO0i+G9LyV7xh+KzXgbX7OIfvzWIECMaEy8JUkVRy2MMG+b46hkqc DatA== X-Gm-Message-State: AFqh2koJReGL0akm2a4iR8qzsY33HmdbggNvtwtwPY5pspWtKR5YgCSL g5Lc2+ABFlIIx7rMPWNNXln9Gg== X-Google-Smtp-Source: AMrXdXsF0KjwJAjuFHYt1tKUJCY6v+AKlNMWeSb48Vf9ENncmKYYEKlkP7MQF87qH7eaHsv1VXPy1g== X-Received: by 2002:a6b:f70e:0:b0:6e5:d22f:8566 with SMTP id k14-20020a6bf70e000000b006e5d22f8566mr43880789iog.14.1672854762126; Wed, 04 Jan 2023 09:52:42 -0800 (PST) Received: from presto.localdomain ([98.61.227.136]) by smtp.gmail.com with ESMTPSA id u3-20020a02cbc3000000b00375783003fcsm10872304jaq.136.2023.01.04.09.52.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Jan 2023 09:52:41 -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 v2 4/6] net: ipa: register IPA interrupt handlers directly Date: Wed, 4 Jan 2023 11:52:31 -0600 Message-Id: <20230104175233.2862874-5-elder@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230104175233.2862874-1-elder@linaro.org> References: <20230104175233.2862874-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 Wed Jan 4 17:52:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 13088823 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 C2F82C61DB3 for ; Wed, 4 Jan 2023 17:53:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240078AbjADRwz (ORCPT ); Wed, 4 Jan 2023 12:52:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49466 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240029AbjADRwr (ORCPT ); Wed, 4 Jan 2023 12:52:47 -0500 Received: from mail-il1-x12f.google.com (mail-il1-x12f.google.com [IPv6:2607:f8b0:4864:20::12f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 070341EEC3 for ; Wed, 4 Jan 2023 09:52:44 -0800 (PST) Received: by mail-il1-x12f.google.com with SMTP id m15so19859117ilq.2 for ; Wed, 04 Jan 2023 09:52:44 -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=5Jqtwulo4xzPm3E3C/EoXy5OKlXyrXoplOZxQkvpLg0=; b=i7I+Knrt5TZe13bZa2OB2m65UCtltdGpXYGt7kgUBd9mUK3GECbDzOjwJU0xb2aeV2 YsykgCL/u0831awefPQ6L1vxBYNcn94VLsoYFkgjkqqaWEJitzDwnFPFFLvbu1ixOMNf 4GlakvnaiSiBxlvSqegICcSiZ3fFZcabGuHLPBSzXDNmZZF9L5o7Ccai17B8G6C/oqpO ZFjJq/Xp7M4uPjT9GBrGdGDhEi99ECUQn4bkoTxtHb/CjFWn1cNaHIuXhkL1X3Q9IoIV oqYGUn2dPE+bes8+9fGveAxO4FpHnrk2KLXvbtqAPLMvuipQcTXUFkhbjCITcybiZAGP 0t4A== 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=5Jqtwulo4xzPm3E3C/EoXy5OKlXyrXoplOZxQkvpLg0=; b=Z98dEUqI49NWMZtiDi+f0ce7ND7AnqPbqj8VPsezUeVdBedqICDR+6xoOqd2UiPC5G Na7CyXJDXHCeTzBWKKpAV/eLjhn827tszcPSTc/TPGHofR77q79qD3qaq9ah3U70MhDk KIv9U5VRg4D+NBU9CNjiF2lSezDH1GO03MQrdDbtHrju4VubYfLzgEdRIfZP25WIizCc wzOAhLT+AoG2OvAP+trr/m7XK6GcY3sdWMDIkea5Y3zNkslBBSglV9VNZElMjsuv0JGT 7EVxRFx/ubGgpFVe/168opfFBwHpbnHYZ5LhT50afrtshEQ5nPvau6mjFdNRReY1DHCp AwwQ== X-Gm-Message-State: AFqh2kpDipIUg/WVWkcFAb85zU43k2eKPKcZ0S6dp1675PEsvWjd1mWH XmweNM5h3G/RxPBq5DkCZnWUcA== X-Google-Smtp-Source: AMrXdXsLStGR6ptjrkejzmOywW/g5BEs3vyXy4zCyjcq2EY+Vc7pxNng3q1df6kZZh906dazD4EkLQ== X-Received: by 2002:a92:d811:0:b0:30a:fb1a:a037 with SMTP id y17-20020a92d811000000b0030afb1aa037mr38951857ilm.31.1672854763362; Wed, 04 Jan 2023 09:52:43 -0800 (PST) Received: from presto.localdomain ([98.61.227.136]) by smtp.gmail.com with ESMTPSA id u3-20020a02cbc3000000b00375783003fcsm10872304jaq.136.2023.01.04.09.52.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Jan 2023 09:52:42 -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 v2 5/6] net: ipa: kill ipa_interrupt_add() Date: Wed, 4 Jan 2023 11:52:32 -0600 Message-Id: <20230104175233.2862874-6-elder@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230104175233.2862874-1-elder@linaro.org> References: <20230104175233.2862874-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 90b61e013064b..764a65e6b5036 100644 --- a/drivers/net/ipa/ipa_interrupt.h +++ b/drivers/net/ipa/ipa_interrupt.h @@ -13,39 +13,6 @@ struct ipa; struct ipa_interrupt; enum ipa_irq_id; -/** - * 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 Wed Jan 4 17:52:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 13088822 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 D1A8EC63707 for ; Wed, 4 Jan 2023 17:53:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240083AbjADRw4 (ORCPT ); Wed, 4 Jan 2023 12:52:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49456 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240030AbjADRws (ORCPT ); Wed, 4 Jan 2023 12:52:48 -0500 Received: from mail-il1-x12a.google.com (mail-il1-x12a.google.com [IPv6:2607:f8b0:4864:20::12a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F103E33D69 for ; Wed, 4 Jan 2023 09:52:44 -0800 (PST) Received: by mail-il1-x12a.google.com with SMTP id u8so12246744ilg.0 for ; Wed, 04 Jan 2023 09:52:44 -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=QzGxU6DyX6RsSixFWY74idDrVdmgX5O5hTxK/7AVVmBGM8s0hr4iCZZLCcjXZoSEMo JWzBpHqdSe9BavTDo1C6VPwZBh4yd7D4SkIr78s8hd2a/rUmtt94bbBcBS0wh36WyGl4 ehpgsPYz5KsFI1zy4JkyPAitdwH94bdRfNRVIoWNP/AghYb1vvAbIevXUkR05tl9LG0R ClHyTNVjC3SAHP4TXVib2rWVo2QIUsLINdy0w03Q137gUED3/pE++84/SC0dxTQL/wTJ tuMTKY1bb/g08dJk51Lm0QdF2Gh3dqeintbZS179zTj2AOjauGzYOQCJ6dn03yb5ujgc Y8Rw== 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=vkRMLyFVlfrmRK1tEpbHBYjiV5z8xeE7cT76Ofar9ALskJRZAhlmhbh1qG6PdhHm79 LoL8tLpXzFqYljFCHFMl2FvmilfIcAsWbJyHewUTAfZLYst8ne/G9IDXZby3vRTxuoHj VULbmLiYD9q5aK7g4TQ1Syj062i8tDYs0DMpBXcSrMBQZqX9ro7cDDv+8PG+P7BV7mj0 427PcNP5xrOnO9vAXfYWaG+OJsofUfH9XV0h7AtqjUK0nd1WjKVdKnsoCGOF+t7SB2UH wRLpwBsjNF8BY29B0iS3xHHzhabzEdyHBbUmS+8H1q6RfRf2s6XWmGbb5G1AGhDKp2co Hlpw== X-Gm-Message-State: AFqh2kqGW8L8hTWmO5+hr1oNjkRzxQzTHH5mr2tIfHZAK44amF4sbRHp 6MEGe2BuH8qxUYToLmGWwjdWhQ== X-Google-Smtp-Source: AMrXdXscaRcNn1dXmwqBDLPOSnFWZCgr0sJ8XlokTYwH69p0B0Yzu99xwasjRP87mqb9n0TILekp1Q== X-Received: by 2002:a92:d06:0:b0:30c:2bb4:a2dc with SMTP id 6-20020a920d06000000b0030c2bb4a2dcmr12940791iln.22.1672854764635; Wed, 04 Jan 2023 09:52:44 -0800 (PST) Received: from presto.localdomain ([98.61.227.136]) by smtp.gmail.com with ESMTPSA id u3-20020a02cbc3000000b00375783003fcsm10872304jaq.136.2023.01.04.09.52.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Jan 2023 09:52:44 -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 v2 6/6] net: ipa: don't maintain IPA interrupt handler array Date: Wed, 4 Jan 2023 11:52:33 -0600 Message-Id: <20230104175233.2862874-7-elder@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230104175233.2862874-1-elder@linaro.org> References: <20230104175233.2862874-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: