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: 37781 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp3107315wrt; Fri, 30 Dec 2022 15:23:12 -0800 (PST) X-Google-Smtp-Source: AMrXdXvIs+1TIfRLAnPiW2CryQHMXUB2LGJFKpJQUtWHMTBXdzuP+Y/Fb23UTqX6NONaJLA/GKwm X-Received: by 2002:a05:6a21:3988:b0:ad:a09c:5734 with SMTP id ad8-20020a056a21398800b000ada09c5734mr49835253pzc.44.1672442592112; Fri, 30 Dec 2022 15:23:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672442592; cv=none; d=google.com; s=arc-20160816; b=wz1OrOCdtk8Zr10JHGxT75Nlxnm16+vVX1eecwlnhBhJ6f65GPA3I77Gy64R/9ZKWU 2FuFuXX1kk8h7jP72us4E9H7FHzyCPkyIAsjYNdNxi4N2xTUaE0GcLizGJkMSB4LqugX 5ig6xVhQrD5528EImJD3y1MF0MZ4t4WcBW4IpkQNzXLai5M7W23TOqlyuIZF7wxXGh65 ubJvlyqZMmxiPAjjQTGRdc0Gm8zyx50Ora+HdHKuaIlIhK2XF+M5FH3bPff3SfF9sQe9 M4ecX14tZtb0Xf08UyaoldCyvC3Av2BpiPQjqpfuwfjHLuBsv4XCGCVNqYSZfmPvDFCA bK/w== ARC-Message-Signature: i=1; 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=K4WtVwRcqcCUgmYfEzecLg1NkgyQK2BLzDcfIQJWkbQ=; b=p9ZBAPUwejNLYbgZszQstG5Dyrb04rq6Ki44OF00eqJmtJimf8UU/FJnvFBVPBdJzV cO1DC+urcC9typFD89XNs7IArpSabbm1jpSKqeOU/6Pt3LIdVx5wEvlQQtR1b0rx/V4w Qu8NrJiOclpl2vT+g7nhG5tyj6r4D+9ZVOYs9+RRwrFD9CmiB6T1hpM3WZKHSLtZDQQl NpzTRYBn66NTl+/pzhcwOU5UeVFeljUkn08d2A+Q5DVBjYPh9pvUCoQxlfyTOkrH9exW JJAjURRgKh9rgjcjd5wJvZLn6zoMxSJcg9FpAoKJKvkL1MlDp2ttReYuKV7clAWAwAHL qKGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=yR2Hc5la; 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=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v185-20020a6389c2000000b0049bfcc05c74si9237829pgd.268.2022.12.30.15.23.00; Fri, 30 Dec 2022 15:23:12 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=yR2Hc5la; 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=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235728AbiL3XWp (ORCPT + 99 others); Fri, 30 Dec 2022 18:22:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35572 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235650AbiL3XWh (ORCPT ); Fri, 30 Dec 2022 18:22:37 -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 829321D0E9 for ; Fri, 30 Dec 2022 15:22:36 -0800 (PST) Received: by mail-il1-x12f.google.com with SMTP id p15so1080823ilg.9 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=0jQBZZAuiJzfjeyzGq12UY7sBE06vVh2j8EtHHyzRvGT7gdm1sZNgV84DbepEBn3JC QFi/T3YY40GRAg5NZRxFTMJ7eAHo53lt8FpHpNFMtw/SyaB3K+ltm+CkwwWKO3MmeU+C z9CSeKF1ag0gv/ODkkjqDtmqk5LIhpa0kD7ltj4qexjtC/W3UQe6h4s07C8Li7g6TkAw 5HxroYOtH4A3/VAl+Hn4J5kuqIRKHcdXyb9nLHSO/o7ge+Jk4XEo0ruiWsh5mKR+1v/s 59VJQhk7w1cfMDa3Nux7twpwfzpJoXs+20Av8ZymOkcOqn50EQAgYnbldjH4L4MSCeck t7hg== X-Gm-Message-State: AFqh2kp0yPzxJLjr/IITRKGVBwjnmHAC+32gEGECp+79qFOA3bsgaPvq BLmA+/PR7JYqjhCqYltkqvJxzw== 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 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1753683163417610824?= X-GMAIL-MSGID: =?utf-8?q?1753683163417610824?= 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; }