From nobody Wed Jan 18 16:25:05 2023 X-Original-To: dev-commits-src-branches@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 4NxrhL2QxVz2yJY2; Wed, 18 Jan 2023 16:25:06 +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 4NxrhK3tsFz3FgB; Wed, 18 Jan 2023 16:25:05 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1674059105; 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=IwecL/Mkv/8Y5qiBCQKib1p5lnsULQ3G++GR42qcS9k=; b=OSwv0HVn/2eox+QOKRpRvUalxKS9MBh7NM8wQCSqIv0FEuG/UgQ+zbW5lbHV2pBNCl16NR mGpxYLM3OAhO+feNhd317heSLdK8f3GcY9Sa9zpWzcbuSJhaOk+WvLb7G8FoONO1G2iu9B ru1ZjNMnafBtlxW/NT2DpvHhLfREmgsbPFPsFrmDJ7lhLAkEtqtBjThC+z+0l9AQWKUk2M kzPjtqiq8MJezXKSY1v4zA/RA0y8VvKNj2o+HkMah5tY36mOwv7N/1/euEs+cd4bWA/b8n lrOZ+k6w+I2AEBQZs4gUEBhgS/dUe2XJjKmt5XHjDsqxpW2ai4RmWaQbk5THqQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1674059105; 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=IwecL/Mkv/8Y5qiBCQKib1p5lnsULQ3G++GR42qcS9k=; b=PvJrwRSWOsG5bCatXvK8GFo2jMiRIr6vV45yD7vZNI5hjz+vv26kz1vg04Z3iwmAPr5eyR 2mzBVBFTHRC+1HHujh9Xzygx+jJJMU02wftRYhh/ZzlBhYSghhoiHLzIqya0dFRFQUDmJP pVkrM06r00WadktAf69mVLoIvdMwFZdXB6yfZvfoYJ6dGzbvFRgtyHPhpzmdYK8bFfGT97 80FkUqagg19t5M8xQHOwW8DrPofNfI3wchJCc452vHLi5lf+Se1zo08y2/wjJs5b2vhq+O Syeq3UECS/Cvb4mqTRV5OssPMGryNXe6rMr2oCVDh1oAOm4SqDACHdTEozno4A== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1674059105; a=rsa-sha256; cv=none; b=s/eP4t+ie1ugkLGMOKkbuUa9BxTD1tZDXTpUBBRp9NZ0HQ0p+xFZArYI9mvMZ6t8Rkj8Cm LlFRMMuT4GhiFXwKO7FeSnKsa2pV1k49B2QgXPzgLV3hY9XCL9JCLIghTAL9OV7OvUeJ6R 9TO1Y113Q2CWcERSIcQ+36S+MVWAve6HwgHpJwldzo7OrlQaO0jE7/Xh7qPQnFi/7w3BTM bM3iL9uRCIqGPfI0nocbz+rSGJiu1AUqbg/akvke9oaodRSe9b2Y003KVQ8TXVvZkGHBGU HT89f3trk53lJxUgDRIiwhloUYAaBTf5LBjj3HBusJQkbUwG3OXMO1CNStnIgg== 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 4NxrhK2yPdzHc2; Wed, 18 Jan 2023 16:25:05 +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 30IGP5dZ038306; Wed, 18 Jan 2023 16:25:05 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 30IGP5N5038305; Wed, 18 Jan 2023 16:25:05 GMT (envelope-from git) Date: Wed, 18 Jan 2023 16:25:05 GMT Message-Id: <202301181625.30IGP5N5038305@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: "Bjoern A. Zeeb" Subject: git: 3292a54f1ba9 - stable/13 - LinuxKPI: fix pci_alloc_irq_vectors() for MSI List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@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/stable/13 X-Git-Reftype: branch X-Git-Commit: 3292a54f1ba9ccbc18e15290eb35665dc964b1c3 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by bz: URL: https://cgit.FreeBSD.org/src/commit/?id=3292a54f1ba9ccbc18e15290eb35665dc964b1c3 commit 3292a54f1ba9ccbc18e15290eb35665dc964b1c3 Author: Bjoern A. Zeeb AuthorDate: 2022-11-28 18:05:48 +0000 Commit: Bjoern A. Zeeb CommitDate: 2023-01-18 13:26:44 +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 Reviewed by: hselasky (earlier version) Differential Revision: https://reviews.freebsd.org/D37522 (cherry picked from commit e9715b1c4474333ff119aba3a9a74bff91f72372) --- 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 b0820c9b2c3e..a9c859d29623 100644 --- a/sys/compat/linuxkpi/common/src/linux_pci.c +++ b/sys/compat/linuxkpi/common/src/linux_pci.c @@ -928,6 +928,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);