Received: by 2002:a05:6a10:c7c6:0:0:0:0 with SMTP id h6csp2458716pxy; Tue, 3 Aug 2021 07:04:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyiTUnU/ls2VHTgkF1JkVtzO7Af7Kqz+AgNLUwNlb7g/GWFM6tHc0zKtd/zQkfuy7uVquyn X-Received: by 2002:a92:de09:: with SMTP id x9mr771190ilm.284.1627999480737; Tue, 03 Aug 2021 07:04:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627999480; cv=none; d=google.com; s=arc-20160816; b=g09D0vZxwM5PM68c01WZuV9W3ddA/EdGbX5XIa1DyIiNlcu5EI9lFYrLsc7Lla0jfR oNLcAOjf5lrdnCGFj15XK56jcQOHrsQyvSmoT1ogt+ZRHVsbJFvz/BK7LINDulSD4v5c XktvvtKad2qEMW9IuVKrZIo1cqfTJ4aLtuoEl81TFsliLmRMM0+pwlmwq+eig6Ld9j8p CtRH0gqj28VuTcXJ43gTZ4jnxcfElEo9OqB3ZVZHahqkAhKhj/T4wHEN++9Cha7S+0fW 9Zw3BidOAeUgsxp1oI5agoF4iQiqyisDDWL5IDjfgXET/E3fnRyLLQgcMBSEfzKeNmJQ X9Zw== 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=NPkwCGbrDYBdXVGQDSHkPChPsZHqvGqOCOzTDOHUik+SEbRhiNSxq2PxHxfP4JaluH Q0NhVAM/r3e/4K3DsvUeqgS1sDVSOSONbuhPVAK/utCFFpctj72TuNabbFNTGpXD+BoS Y5DhGIAFpBiuTUcd7pfihXOh/J/OJmfModfAKSaVWSUI9RmkA9zmrru4JINe7uEB6O30 lnBRiPTRQAV2dCIFkXiPY1S4eUFk6pfeLsRacAlaPgcQscyzZ4BAXLyTjDOt2oIjnc+c uPr5i0bGwDZfVQ+Frl8/k90tokPgqScjmJ2sv0YiweKzjfyOHo7jvtVHgCU6WE/qm1Kb uOpg== 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 linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-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 k40si15128864jav.47.2021.08.03.07.04.26; Tue, 03 Aug 2021 07:04:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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 linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S236601AbhHCOBm (ORCPT + 99 others); Tue, 3 Aug 2021 10:01:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50986 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236467AbhHCOBY (ORCPT ); Tue, 3 Aug 2021 10:01:24 -0400 Received: from mail-il1-x129.google.com (mail-il1-x129.google.com [IPv6:2607:f8b0:4864:20::129]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8EA67C061764 for ; Tue, 3 Aug 2021 07:01:13 -0700 (PDT) Received: by mail-il1-x129.google.com with SMTP id a14so19587567ila.1 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=lNB8KdhXpyBlf0/1hZvJx7akAQUkNoGGvHJBJvDLUSwfwq9ayHg37XLVf+6JHfp8F+ ru6kk3YjKb2PlQoCEUZOTaZz80SN9fUFxMevZWhwEY50DKtJzBuxyv0z41RbB/OoJZQn hM/apUVY+e2wtPfD4I1ZlMDdpkk5EPMvQ5TiDsXWWkHpSRJhaXSPKr8r3durvFN/ta/8 O7/6TWdfbLZrQbGRmIc7AuFnmr4F8WxAMsZkrnLWfClFqp9AhkEkbyYKCBE7JiY4Nilw y2WNO74M94M6M5zCR1z/A//xELwncu4UDWoU6LxgKvlUyTJ775twWX2dGwkEqCt8AVSE n8Jw== X-Gm-Message-State: AOAM5338wXx22vEeBadeXVJxUE9S5FH7V3/JvokDx69yZXd9DsAS6nIC gn7wNEfGYcozIrhnfSnE+HZCDw== 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 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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(-) 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); } -- 2.27.0