From patchwork Tue Aug 3 14:01:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 490956 Delivered-To: patch@linaro.org Received: by 2002:a05:6638:396:0:0:0:0 with SMTP id y22csp677291jap; Tue, 3 Aug 2021 07:01:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzExrS7Da6Yyx22niNlYzs57Ns3ckLWS1PhbSnkGR4g1pFVTt6mGiFaUvoY+2SnOqed15A0 X-Received: by 2002:a5d:858d:: with SMTP id f13mr55439ioj.197.1627999290814; Tue, 03 Aug 2021 07:01:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627999290; cv=none; d=google.com; s=arc-20160816; b=vkJlKoGRmUT6ak2jy93K1LXAu0h35UJkYKKrwETEls85pjsWZN4q6+zVI34RmKHy7V sM1f62EjDtLlqTQjecrs8YVHXUhyAMedOkTc1zCmJ87ERhaf8TbIQ4wQuBpOqk3/HR2G g436Tyo4MTzoS4DIemL/AbwCofC1+Nv1cJiUm+RKkf/y7iMcY7+hTgU1fcdbM0HaRmEC P94HyT94HcU0zyX9leePOcp3/Hl/SOkLkwkJVEXpfFX5XX76amzolrjCHye43jeMNKcP G1F5UHl5i7AwR/NRjwk0ZTkOiTcDE7zcTx2Scur/OKQ8D9apvRVkt9gDoRuunQl+MpaW DYRg== 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=+yxvUAjlQXeGYAgTSezvFwBfFS0lHATudjbMDmfcOIk=; b=pZGpKxlRNqC0tI1II2Hr+PgG9GCjJTm9LPRh3lGJ3Oo2VvhdXQt/N8C01xHsyhB3YT rTSPwkke3cZ7p4+Z1Abacjrw9Z/BB17FF6b6F654I1MpslQwQJiOZE3Mpudm/xKdTgw9 o6TaqJFLEAk+ZuwAtHR87ocBA7kpztxmLCpGok6jMGXHfxj1X1ZhaYwD6VHvjL4Q+GXV w9w7OCm0Z96bmIE7cIJAYa+g5aHPc2IE/TdKbQUyj5BdE89b47zrRJrTvK+ZvvNeeHDX cmKsREhtV9G/LrYBwgFeI62MHGHmqFZwA9qvacLkl4Md1PoISG8qD1vwnxsdhJwrkMkU wjYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Dm3YNwsg; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e16si17170049ils.75.2021.08.03.07.01.30; Tue, 03 Aug 2021 07:01:30 -0700 (PDT) Received-SPF: pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Dm3YNwsg; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-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 S236503AbhHCOBj (ORCPT + 8 others); Tue, 3 Aug 2021 10:01:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50984 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236464AbhHCOBY (ORCPT ); Tue, 3 Aug 2021 10:01:24 -0400 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 8CC84C061757 for ; Tue, 3 Aug 2021 07:01:13 -0700 (PDT) Received: by mail-il1-x12f.google.com with SMTP id i13so7659682ilm.11 for ; Tue, 03 Aug 2021 07:01:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=+yxvUAjlQXeGYAgTSezvFwBfFS0lHATudjbMDmfcOIk=; b=Dm3YNwsg0N6z7fNUXisHxsWrxCpPda9PcrAhzw44fFqIANO0//ygJq53XY6I+9mQhh xhl7BFHEVuHuwcg+lp8btAUOn0bTwn6wUA04Cw9zdDWKjTchYP5bN91bKBP4NTcqWxQv v2MI64FvF+QEo2xolfDQoqt0tknzL7PsBS7lFdfmtSBZWYbTkuSxYE7OdxV79cvAqWFb sziAz2oc6Oz2ynfV/SbC5Tepm1URTx6zcJMNBjsPakXllAAZur1wy3FlGZPENoIuuY81 nPiBJNuwIs0A170yiZtrzIaxgOMK2D/izOxyJIe5YSbUGJcwFLz//HrbTKUWfS4fzPlh Pwsw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=+yxvUAjlQXeGYAgTSezvFwBfFS0lHATudjbMDmfcOIk=; b=dZV2MIrMPFGzEya1OW5XE/fiZZewTRzEu3fDqRjG+5BwTpJfIY3WOjJV6WNwWe+ope oNYQeXLn2S737isHrbkqQrmL+NtkfL7Png0tXftQzMrNt5v519lTtjn2U+5xioTLg2cj JJne7vhfxyIR5Hox+dhhqoNeHbQ7lm/FsX12jguxTK7+gSuNhmfMl8kWklBmsL9+JcNB B3/s3NjoEAWv5AxH9lYexj88mrgCcz3hVENbKmz7bKmg/rAEaKKYyI4ysXkxcUtqedZV 3R/TKkjQdRHEIWrFlWoktJ58WWAvtcUl+CiYBF/yWAd0LQT57mFhRAHp1z2D5t3dt/C8 wU+w== X-Gm-Message-State: AOAM533PWwef2YMG2bFyRkuJH9/xn4IrHc9RDWvikUZA39dedVNKmxce kl/+bdUgrLdsC6fOAZMnnv23LsahlATWTQ== X-Received: by 2002:a92:ca45:: with SMTP id q5mr778759ilo.7.1627999273004; Tue, 03 Aug 2021 07:01:13 -0700 (PDT) Received: from presto.localdomain (c-73-185-129-58.hsd1.mn.comcast.net. [73.185.129.58]) by smtp.gmail.com with ESMTPSA id w7sm9456798iox.1.2021.08.03.07.01.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Aug 2021 07:01:12 -0700 (PDT) From: Alex Elder To: davem@davemloft.net, kuba@kernel.org Cc: bjorn.andersson@linaro.org, evgreen@chromium.org, cpratapa@codeaurora.org, subashab@codeaurora.org, elder@kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next 5/6] net: ipa: move gsi_irq_init() code into setup Date: Tue, 3 Aug 2021 09:01:02 -0500 Message-Id: <20210803140103.1012697-6-elder@linaro.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210803140103.1012697-1-elder@linaro.org> References: <20210803140103.1012697-1-elder@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org The GSI IRQ handler could be triggered as soon as it is registered with request_irq(). The handler function, gsi_isr(), touches hardware, meaning the IPA clock must be operational. The IPA clock is not operating when the handler is registered (in gsi_irq_init()), so this is a problem. Move the call to request_irq() for the GSI interrupt handler into gsi_irq_setup(), which is called when the IPA clock is known to be operational (and furthermore, the GSI firmware will have been loaded). Request the IRQ at the end of that function, after all interrupt types have been disabled and masked. Move the matching free_irq() call into gsi_irq_teardown(), and get rid of the now empty gsi_irq_exit(), Signed-off-by: Alex Elder --- drivers/net/ipa/gsi.c | 33 ++++++++++++--------------------- 1 file changed, 12 insertions(+), 21 deletions(-) -- 2.27.0 diff --git a/drivers/net/ipa/gsi.c b/drivers/net/ipa/gsi.c index be069d7c4feb9..c555ccd778bb8 100644 --- a/drivers/net/ipa/gsi.c +++ b/drivers/net/ipa/gsi.c @@ -1303,33 +1303,20 @@ static irqreturn_t gsi_isr(int irq, void *dev_id) return IRQ_HANDLED; } +/* Init function for GSI IRQ lookup; there is no gsi_irq_exit() */ static int gsi_irq_init(struct gsi *gsi, struct platform_device *pdev) { - struct device *dev = &pdev->dev; - unsigned int irq; int ret; ret = platform_get_irq_byname(pdev, "gsi"); if (ret <= 0) return ret ? : -EINVAL; - irq = ret; - - ret = request_irq(irq, gsi_isr, 0, "gsi", gsi); - if (ret) { - dev_err(dev, "error %d requesting \"gsi\" IRQ\n", ret); - return ret; - } - gsi->irq = irq; + gsi->irq = ret; return 0; } -static void gsi_irq_exit(struct gsi *gsi) -{ - free_irq(gsi->irq, gsi); -} - /* Return the transaction associated with a transfer completion event */ static struct gsi_trans *gsi_event_trans(struct gsi_channel *channel, struct gsi_event *event) @@ -1810,6 +1797,8 @@ static void gsi_channel_teardown(struct gsi *gsi) /* Turn off all GSI interrupts initially */ static int gsi_irq_setup(struct gsi *gsi) { + int ret; + /* Writing 1 indicates IRQ interrupts; 0 would be MSI */ iowrite32(1, gsi->virt + GSI_CNTXT_INTSET_OFFSET); @@ -1835,11 +1824,16 @@ static int gsi_irq_setup(struct gsi *gsi) iowrite32(0, gsi->virt + GSI_CNTXT_GSI_IRQ_EN_OFFSET); - return 0; + ret = request_irq(gsi->irq, gsi_isr, 0, "gsi", gsi); + if (ret) + dev_err(gsi->dev, "error %d requesting \"gsi\" IRQ\n", ret); + + return ret; } static void gsi_irq_teardown(struct gsi *gsi) { + free_irq(gsi->irq, gsi); } /* Get # supported channel and event rings; there is no gsi_ring_teardown() */ @@ -2224,20 +2218,18 @@ int gsi_init(struct gsi *gsi, struct platform_device *pdev, init_completion(&gsi->completion); - ret = gsi_irq_init(gsi, pdev); + ret = gsi_irq_init(gsi, pdev); /* No matching exit required */ if (ret) goto err_iounmap; ret = gsi_channel_init(gsi, count, data); if (ret) - goto err_irq_exit; + goto err_iounmap; mutex_init(&gsi->mutex); return 0; -err_irq_exit: - gsi_irq_exit(gsi); err_iounmap: iounmap(gsi->virt_raw); @@ -2249,7 +2241,6 @@ void gsi_exit(struct gsi *gsi) { mutex_destroy(&gsi->mutex); gsi_channel_exit(gsi); - gsi_irq_exit(gsi); iounmap(gsi->virt_raw); }