Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp4232937ybb; Tue, 7 Apr 2020 03:29:59 -0700 (PDT) X-Google-Smtp-Source: APiQypIf0tFb3ON8Q107+yUdjcPVCKV9gxXDzkiDVZhxEgzyU65IW7fA32Y2ZLMSMhvLir5fFIvn X-Received: by 2002:a05:6808:a0a:: with SMTP id n10mr1150599oij.10.1586255399145; Tue, 07 Apr 2020 03:29:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586255399; cv=none; d=google.com; s=arc-20160816; b=u6Uu9g2zEtw+cZ6kqHV5naRjssUENzWFYa8iq9xJ6o0kKrg0driaAt0nX9LfPHaSiD RiKjg3RO0JSb9WYlR1ydnNrm8kXjs2ujfzbemJC0TCJGzKnJdekZIf8rv6F+r1XIhr4Z wLcQ12SH/+desI33Vm5s5HHK9BcvbIE7mS9Q2x/9xSBmLKqnWGeM3iPMCPbVfbin62jg 7XjUZ7b2ST/Ojpl3ZT2PkjU7RR6PAKDStB4enbgHI7p+OsCgZMcTqx1luFevJ1goPZds G8Le1xjKnXbH8WjOMZh2UJV+l43P5nec/qWn0T5YgWwoE5NO9Gvv+oupbH8SDfkqnlCi SJTg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=wfhFCs+JWmB1gGOuwbeoKdIiru8r+zd1w0PwCBHYsa8=; b=udTw030llITH3oVH4TbjPclIBVJtp/qOjx+HCafjObl8XSxXr4ffAnmayc7bMz9jMU yH9aQn3hMk/583yzMBSP7O4Hk5Ya2xN0rgoCunl5RdT4C/iqGMHYrgb2P+0wd9TF2tcF ci3/kp14+w/LwN9Zwe21KzSGtvaiRDJedBTuAS5NTBTHRuN74fnU6zjav64GErpM72i4 o1cfkcL+hF4cjROoxDZOFcpqfZfo15Z9BZLo2jFcQ9zbpyQVsNKusn8fJgZxtaHQ1WXW IlnusdLrha53Q1ME7+ZrbGGIb2FZiIgKWntiZE56EjzsRRcq69bd/FSDZvw39uRxRDRS lbsg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=P2iIPHSW; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h26si1106018otg.145.2020.04.07.03.29.47; Tue, 07 Apr 2020 03:29:59 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=P2iIPHSW; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728796AbgDGKYs (ORCPT + 99 others); Tue, 7 Apr 2020 06:24:48 -0400 Received: from mail.kernel.org ([198.145.29.99]:35100 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728776AbgDGKYq (ORCPT ); Tue, 7 Apr 2020 06:24:46 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 995BF2080C; Tue, 7 Apr 2020 10:24:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1586255085; bh=hFSSaaFZs7iS34JeOV/LO3xxtt/qCl6SQ6F3A3HPIlg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=P2iIPHSW+XUIoOQQRoFSPUFx1EvZwE4fgpjoKmc+oq3UrZBnK1zUXSKgf/c86+Tzr 7gam58cjoQeIqwKv6//W7LxfBy19H1W6zTmHZT7Smb8eH7xyowOuMa6k2Fn3IUo2Z+ GSoO+meAVAvVKZDLSr1dQvS6n/5ARm5OSETZgaxw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kishon Vijay Abraham I , Lorenzo Pieralisi Subject: [PATCH 5.5 23/46] misc: pci_endpoint_test: Avoid using module parameter to determine irqtype Date: Tue, 7 Apr 2020 12:21:54 +0200 Message-Id: <20200407101501.970264355@linuxfoundation.org> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20200407101459.502593074@linuxfoundation.org> References: <20200407101459.502593074@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Kishon Vijay Abraham I commit b2ba9225e0313b1de631a44b7b48c109032bffec upstream. commit e03327122e2c ("pci_endpoint_test: Add 2 ioctl commands") uses module parameter 'irqtype' in pci_endpoint_test_set_irq() to check if IRQ vectors of a particular type (MSI or MSI-X or LEGACY) is already allocated. However with multi-function devices, 'irqtype' will not correctly reflect the IRQ type of the PCI device. Fix it here by adding 'irqtype' for each PCI device to show the IRQ type of a particular PCI device. Fixes: e03327122e2c ("pci_endpoint_test: Add 2 ioctl commands") Signed-off-by: Kishon Vijay Abraham I Signed-off-by: Lorenzo Pieralisi Cc: stable@vger.kernel.org # v4.19+ Signed-off-by: Greg Kroah-Hartman --- drivers/misc/pci_endpoint_test.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) --- a/drivers/misc/pci_endpoint_test.c +++ b/drivers/misc/pci_endpoint_test.c @@ -98,6 +98,7 @@ struct pci_endpoint_test { struct completion irq_raised; int last_irq; int num_irqs; + int irq_type; /* mutex to protect the ioctls */ struct mutex mutex; struct miscdevice miscdev; @@ -157,6 +158,7 @@ static void pci_endpoint_test_free_irq_v struct pci_dev *pdev = test->pdev; pci_free_irq_vectors(pdev); + test->irq_type = IRQ_TYPE_UNDEFINED; } static bool pci_endpoint_test_alloc_irq_vectors(struct pci_endpoint_test *test, @@ -191,6 +193,8 @@ static bool pci_endpoint_test_alloc_irq_ irq = 0; res = false; } + + test->irq_type = type; test->num_irqs = irq; return res; @@ -330,6 +334,7 @@ static bool pci_endpoint_test_copy(struc dma_addr_t orig_dst_phys_addr; size_t offset; size_t alignment = test->alignment; + int irq_type = test->irq_type; u32 src_crc32; u32 dst_crc32; @@ -426,6 +431,7 @@ static bool pci_endpoint_test_write(stru dma_addr_t orig_phys_addr; size_t offset; size_t alignment = test->alignment; + int irq_type = test->irq_type; u32 crc32; if (size > SIZE_MAX - alignment) @@ -494,6 +500,7 @@ static bool pci_endpoint_test_read(struc dma_addr_t orig_phys_addr; size_t offset; size_t alignment = test->alignment; + int irq_type = test->irq_type; u32 crc32; if (size > SIZE_MAX - alignment) @@ -555,7 +562,7 @@ static bool pci_endpoint_test_set_irq(st return false; } - if (irq_type == req_irq_type) + if (test->irq_type == req_irq_type) return true; pci_endpoint_test_release_irq(test); @@ -567,12 +574,10 @@ static bool pci_endpoint_test_set_irq(st if (!pci_endpoint_test_request_irq(test)) goto err; - irq_type = req_irq_type; return true; err: pci_endpoint_test_free_irq_vectors(test); - irq_type = IRQ_TYPE_UNDEFINED; return false; } @@ -652,6 +657,7 @@ static int pci_endpoint_test_probe(struc test->test_reg_bar = 0; test->alignment = 0; test->pdev = pdev; + test->irq_type = IRQ_TYPE_UNDEFINED; if (no_msi) irq_type = IRQ_TYPE_LEGACY;