From patchwork Mon Apr 2 18:24:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Scheller X-Patchwork-Id: 10320177 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 6C49D60375 for ; Mon, 2 Apr 2018 18:25:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5CB6B28A67 for ; Mon, 2 Apr 2018 18:25:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 50C7E28A74; Mon, 2 Apr 2018 18:25:07 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ED75628A67 for ; Mon, 2 Apr 2018 18:25:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754332AbeDBSZE (ORCPT ); Mon, 2 Apr 2018 14:25:04 -0400 Received: from mail-wm0-f67.google.com ([74.125.82.67]:50831 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753030AbeDBSYi (ORCPT ); Mon, 2 Apr 2018 14:24:38 -0400 Received: by mail-wm0-f67.google.com with SMTP id t67so7622254wmt.0 for ; Mon, 02 Apr 2018 11:24:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references; bh=799Z6bKsR58HxvK5+a1KA2PWNVfsJwwRjIVWLg6LzBE=; b=KeMjXh9Yi8w1RbzbkNsbZJqA3NQIokipnpPxAaT4WYUxuzS3FGKOGTK3BdwiN+04w1 0j0COVEMSDA1dlfcO+BzuMFkv9t5wT0Uyw770nhDh6RbT9KmSEImncV4xu8YR78o1DCb CCgVkmlLoPJLHLok+pHCyOEwrvaRjy5F0kSM4LqU3mjXHLhRvN4sbDu+bh/B9rvKOQIk ZHZfTSTQU27u0RZ5g0t8gmsKC11rEgk+LPPXB4eXeedVLa/83neF2c9k8sFTmQhYjFuH vX1jSsDAmGSw/ieXKaQ2enTJLNx6wK4qWuOSZR9D6G5y0ykyEQQGF37L9NNzVZZqCyA+ rP+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=799Z6bKsR58HxvK5+a1KA2PWNVfsJwwRjIVWLg6LzBE=; b=esqqkv0Hkfl8o0maH6KrsUugcf/i/AMDCL8iSFQ88TZCsKnicNjSYnvAETnK+vpYCE u8HJ15AAGTTlOujjv0u8mJ+Qc7o684V338DnWyVaiKl5+KtJP1lueTQmDYAqJK99jgCs UC/Bfq4HuLcLiO02MMHD9gHL5+ywdljJBVrNi/NY0apK3pJ+h/OhPU6sW1A1AOeSbmNc b8xSS0UE2nF0PEiU6CsGPHLAcE7iv3keKBrDBySr8T9Bq3Dgh+PO5QHX9fnE8rLV7fRf DQQH2NZp3xJ8Ubg1H/nzSNvplBWzh2J05DbZi8jgySfOk34ZrnyOimbAho53TnSLPQI9 i1/Q== X-Gm-Message-State: ALQs6tCT6c+aClEPlPEzRmRlLL7UpWoruAKUixNpQoAml1Ntd8M/RDLF 1e97gPqqPooZCrRU4hkgE3MkDw== X-Google-Smtp-Source: AIpwx4+/2bd3oTihVJUwysm1OFzuEIYvdp3Mbr9Ca2o8xyis9vABMxkjzEpB+ldQProIwcGoUc+CPQ== X-Received: by 10.28.88.141 with SMTP id m135mr300989wmb.156.1522693477177; Mon, 02 Apr 2018 11:24:37 -0700 (PDT) Received: from dvbdev.wuest.de (ip-84-118-193-200.unity-media.net. [84.118.193.200]) by smtp.gmail.com with ESMTPSA id x9sm2368273wrb.18.2018.04.02.11.24.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 02 Apr 2018 11:24:36 -0700 (PDT) From: Daniel Scheller To: linux-media@vger.kernel.org, mchehab@kernel.org, mchehab@s-opensource.com Subject: [PATCH 07/20] [media] ddbridge: request/free_irq using pci_irq_vector, enable MSI-X Date: Mon, 2 Apr 2018 20:24:14 +0200 Message-Id: <20180402182427.20918-8-d.scheller.oss@gmail.com> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180402182427.20918-1-d.scheller.oss@gmail.com> References: <20180402182427.20918-1-d.scheller.oss@gmail.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Daniel Scheller Instead of trying to manage IRQ numbers on itself, utilise the pci_irq_vector() function to do this, which will take care of correct IRQ numbering for MSI and non-MSI IRQs. While at it, request and enable MSI-X interrupts for hardware (boards and cards) that support this. Picked up from the upstream dddvb-0.9.33 release. Signed-off-by: Daniel Scheller --- drivers/media/pci/ddbridge/ddbridge-main.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/drivers/media/pci/ddbridge/ddbridge-main.c b/drivers/media/pci/ddbridge/ddbridge-main.c index 77089081db1f..008be9066814 100644 --- a/drivers/media/pci/ddbridge/ddbridge-main.c +++ b/drivers/media/pci/ddbridge/ddbridge-main.c @@ -77,8 +77,8 @@ static void ddb_irq_exit(struct ddb *dev) { ddb_irq_disable(dev); if (dev->msi == 2) - free_irq(dev->pdev->irq + 1, dev); - free_irq(dev->pdev->irq, dev); + free_irq(pci_irq_vector(dev->pdev, 1), dev); + free_irq(pci_irq_vector(dev->pdev, 0), dev); } static void ddb_remove(struct pci_dev *pdev) @@ -105,7 +105,8 @@ static void ddb_irq_msi(struct ddb *dev, int nr) int stat; if (msi && pci_msi_enabled()) { - stat = pci_alloc_irq_vectors(dev->pdev, 1, nr, PCI_IRQ_MSI); + stat = pci_alloc_irq_vectors(dev->pdev, 1, nr, + PCI_IRQ_MSI | PCI_IRQ_MSIX); if (stat >= 1) { dev->msi = stat; dev_info(dev->dev, "using %d MSI interrupt(s)\n", @@ -137,21 +138,24 @@ static int ddb_irq_init(struct ddb *dev) if (dev->msi) irq_flag = 0; if (dev->msi == 2) { - stat = request_irq(dev->pdev->irq, ddb_irq_handler0, - irq_flag, "ddbridge", (void *)dev); + stat = request_irq(pci_irq_vector(dev->pdev, 0), + ddb_irq_handler0, irq_flag, "ddbridge", + (void *)dev); if (stat < 0) return stat; - stat = request_irq(dev->pdev->irq + 1, ddb_irq_handler1, - irq_flag, "ddbridge", (void *)dev); + stat = request_irq(pci_irq_vector(dev->pdev, 1), + ddb_irq_handler1, irq_flag, "ddbridge", + (void *)dev); if (stat < 0) { - free_irq(dev->pdev->irq, dev); + free_irq(pci_irq_vector(dev->pdev, 0), dev); return stat; } } else #endif { - stat = request_irq(dev->pdev->irq, ddb_irq_handler, - irq_flag, "ddbridge", (void *)dev); + stat = request_irq(pci_irq_vector(dev->pdev, 0), + ddb_irq_handler, irq_flag, "ddbridge", + (void *)dev); if (stat < 0) return stat; }