From nobody Fri Jan 13 00:40:38 2023 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4NtMyt3f0Mz2sgJB; Fri, 13 Jan 2023 00:40:38 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4NtMyt37hQz3Pw6; Fri, 13 Jan 2023 00:40:38 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1673570438; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=r8n3NfE1SvfCOiEkxEnMdchweZJWfbBRFNQFV1TxV/g=; b=mwsUU9q78s5IB4QmEFt+eJMAnuMfNJyH/g0//e20/0VqhtesDzGe0jxedBwQ25SPSePdfK ZK1QhZ+ojVnmkkclzk1hlET2YHkcSzHoCIHZqesmwZuip8kYSryB7CK0YBIfjUAio/mly3 J/lflXVv5p1CNYA11W/LxmK00hY+E+6PWbt5vNG3LrHP19y/ZZ8qayEtLwz3fbxRvKjVVU f49VjUCqWezGqtV+MZY964hj2ebl5W2TTRFkJ8Au3Id/tNhDN4fGolHSc0GviEPAmOeuQg Dct5k+5dyekASJo61Lqlvi95z8Z7E/+hXur7FX8VnYvptIpsbCCc4w1k+oOjvQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1673570438; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=r8n3NfE1SvfCOiEkxEnMdchweZJWfbBRFNQFV1TxV/g=; b=hobyYkmi54sOMpwg0yw76ck39S+oN31DbEkjCdrxs9PHFMVmswTRp8lGLHVMrUdC5692oe CBIeB6JUNeniDzh/0/P+9B8H82aCd9TiOW6E2s19BSJBLW+16Bliy5J4wAWekZimvX+f45 bNCEnfSgeeb8zskQFrQ8hJtJOOaLpC3Z4CdqwLzwTbyLQ/ErVLOMobIxGUhhgOObEs7Be/ +q7z4db90C2jMvZKyUvGFdOJ+udsy5f4+8CyIuiAqK6YNTqnYDIy4GQudgvmgcBObK3MCo MrYCuso58VLwQJMthGLzepKTXhzK7DQbCr3t8R1fWdynJ2me657LlVV7uneIcQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1673570438; a=rsa-sha256; cv=none; b=CJNpv4RjiivJD2iNwW/YHHY8tAQqMBgnBOuMJZKgtYm7NQzlQ1WSSF+r/5RhtyUl6uUb57 R4t2IW6FHiPjCXovJWgdRGcndK8IzWmjrl9lTEi/kDrQpRVDmwIElVtTEgCrSsVIc+8TNO 2sATqeUsqrf6cJAKmlSaGzK4DgfNXAMui+BnRb+KNhdQZlSg1P3T+GSlQHh9PXh4IRxXZH t/VxIUfIeDTwa5BJsbS9G2maVUJ36EKQREBq2/FaMGJToMe0otoNM5ck7gxbP4MypVwTq/ HZCpYf4Y+YXYb1AV+A54IaqD6G26ZlaxYMf4KenS5L9qb6pod9sfGGcDs1CvaQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4NtMyt29l2znyN; Fri, 13 Jan 2023 00:40:38 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 30D0ecK1060057; Fri, 13 Jan 2023 00:40:38 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 30D0ecFI060056; Fri, 13 Jan 2023 00:40:38 GMT (envelope-from git) Date: Fri, 13 Jan 2023 00:40:38 GMT Message-Id: <202301130040.30D0ecFI060056@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: "Bjoern A. Zeeb" Subject: git: e9715b1c4474 - main - LinuxKPI: fix pci_alloc_irq_vectors() for MSI List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: bz X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: e9715b1c4474333ff119aba3a9a74bff91f72372 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by bz: URL: https://cgit.FreeBSD.org/src/commit/?id=e9715b1c4474333ff119aba3a9a74bff91f72372 commit e9715b1c4474333ff119aba3a9a74bff91f72372 Author: Bjoern A. Zeeb AuthorDate: 2022-11-28 18:05:48 +0000 Commit: Bjoern A. Zeeb CommitDate: 2023-01-13 00:39:24 +0000 LinuxKPI: fix pci_alloc_irq_vectors() for MSI pci_alloc_irq_vectors() is given a min and max vector value. pci_enable_msi() will always succeed independent of these arguments as it does not know about them. Further it will only ever allocate 1 "vector" not supporting any other amount. So upfront check that (a) the available pci_msi_count() can satisfy the requested minv and (b) given the pci_enable_msi() hard coded limit check that minv is not larger than 1. If we cannot satisfy either requirement return an error. This fixes problems with drivers which check that the returned value of allocated "vectors" will match their requests and only otherwise try to fall back to ask for 1 or deal otherwise. Sponsored by: The FreeBSD Foundation MFC after: 3 days Reviewed by: hselasky (earlier version) Differential Revision: https://reviews.freebsd.org/D37522 --- sys/compat/linuxkpi/common/src/linux_pci.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/sys/compat/linuxkpi/common/src/linux_pci.c b/sys/compat/linuxkpi/common/src/linux_pci.c index aab4bfb6650d..9e79ec80b74f 100644 --- a/sys/compat/linuxkpi/common/src/linux_pci.c +++ b/sys/compat/linuxkpi/common/src/linux_pci.c @@ -931,6 +931,11 @@ out: return (pdev->dev.irq_end - pdev->dev.irq_start); } if (flags & PCI_IRQ_MSI) { + if (pci_msi_count(pdev->dev.bsddev) < minv) + return (-ENOSPC); + /* We only support 1 vector in pci_enable_msi() */ + if (minv != 1) + return (-ENOSPC); error = pci_enable_msi(pdev); if (error == 0 && pdev->msi_enabled) return (pdev->dev.irq_end - pdev->dev.irq_start);