From mboxrd@z Thu Jan 1 00:00:00 1970 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 67CF9C7EE2C for ; Thu, 25 May 2023 18:52:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243015AbjEYStv (ORCPT ); Thu, 25 May 2023 14:49:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35244 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242555AbjEYSoq (ORCPT ); Thu, 25 May 2023 14:44:46 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 504D4269F; Thu, 25 May 2023 11:40:58 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id F186A648BB; Thu, 25 May 2023 18:39:49 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 977B1C43444; Thu, 25 May 2023 18:39:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1685039989; bh=vbktacNvzMxmaMmPXfXNjFE5Pft/4vAe4J/2Z+imNbc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SoSv/LCqqEiL3IniAmS7X7gKnryU/WCm0EbvCUub2S6O1xWrdJboTkB4xD4z2RKQj TXvLzpxxSPa5zkltkofTLXEsezQl3bAR7j/O4zMlToXTzPfMQSSMvJKZVFKGctMX4I O9JM3Nhigk1+9FCwkwRiEeVUdi+kxasnxF8qfPPW7dE9aA1ihf8Eh5PBYAYq5PuUrW wo1k7pXZ7wJ+Tvt4myOYNftxYLls/989wORRAAPSjoc9L3EjpDv7Z0JhjcwqQS8MJv 72iQNHsLNn9MO9bYfNMmTxh9VserXs/uKqtmVbUuQeNXDmGkNnBmwZ9rByrv/ZqXoS tL8u4JSn0kiEw== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Wei Chen , Mauro Carvalho Chehab , Sasha Levin , serjk@netup.ru, aospan@netup.ru, linux-media@vger.kernel.org Subject: [PATCH AUTOSEL 5.15 16/43] media: netup_unidvb: fix irq init by register it at the end of probe Date: Thu, 25 May 2023 14:38:27 -0400 Message-Id: <20230525183854.1855431-16-sashal@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230525183854.1855431-1-sashal@kernel.org> References: <20230525183854.1855431-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Wei Chen [ Upstream commit e6ad6233592593079db5c8fa592c298e51bc1356 ] IRQ handler netup_spi_interrupt() takes spinlock spi->lock. The lock is initialized in netup_spi_init(). However, irq handler is registered before initializing the lock. Spinlock dma->lock and i2c->lock suffer from the same problem. Fix this by registering the irq at the end of probe. Link: https://lore.kernel.org/linux-media/20230315134518.1074497-1-harperchen1110@gmail.com Signed-off-by: Wei Chen Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Sasha Levin --- .../media/pci/netup_unidvb/netup_unidvb_core.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/drivers/media/pci/netup_unidvb/netup_unidvb_core.c b/drivers/media/pci/netup_unidvb/netup_unidvb_core.c index 77bae14685513..3fa1d178e70fd 100644 --- a/drivers/media/pci/netup_unidvb/netup_unidvb_core.c +++ b/drivers/media/pci/netup_unidvb/netup_unidvb_core.c @@ -887,12 +887,7 @@ static int netup_unidvb_initdev(struct pci_dev *pci_dev, ndev->lmmio0, (u32)pci_resource_len(pci_dev, 0), ndev->lmmio1, (u32)pci_resource_len(pci_dev, 1), pci_dev->irq); - if (request_irq(pci_dev->irq, netup_unidvb_isr, IRQF_SHARED, - "netup_unidvb", pci_dev) < 0) { - dev_err(&pci_dev->dev, - "%s(): can't get IRQ %d\n", __func__, pci_dev->irq); - goto irq_request_err; - } + ndev->dma_size = 2 * 188 * NETUP_DMA_BLOCKS_COUNT * NETUP_DMA_PACKETS_COUNT; ndev->dma_virt = dma_alloc_coherent(&pci_dev->dev, @@ -933,6 +928,14 @@ static int netup_unidvb_initdev(struct pci_dev *pci_dev, dev_err(&pci_dev->dev, "netup_unidvb: DMA setup failed\n"); goto dma_setup_err; } + + if (request_irq(pci_dev->irq, netup_unidvb_isr, IRQF_SHARED, + "netup_unidvb", pci_dev) < 0) { + dev_err(&pci_dev->dev, + "%s(): can't get IRQ %d\n", __func__, pci_dev->irq); + goto dma_setup_err; + } + dev_info(&pci_dev->dev, "netup_unidvb: device has been initialized\n"); return 0; @@ -951,8 +954,6 @@ static int netup_unidvb_initdev(struct pci_dev *pci_dev, dma_free_coherent(&pci_dev->dev, ndev->dma_size, ndev->dma_virt, ndev->dma_phys); dma_alloc_err: - free_irq(pci_dev->irq, pci_dev); -irq_request_err: iounmap(ndev->lmmio1); pci_bar1_error: iounmap(ndev->lmmio0); -- 2.39.2