From nobody Thu Aug 01 22:28:06 2024 X-Original-To: dev-commits-src-all@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 4WZkBG6qQHz5RZYf; Thu, 01 Aug 2024 22:28: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 "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4WZkBG4v0sz4Zc7; Thu, 1 Aug 2024 22:28:06 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1722551286; 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=a9Nl7m3wIn+Ic/Xg3yBcZBHU18cDjBELWCi0wG8Zpp0=; b=q2KQy0mRFGHlR96Bz9aCY1mNFF2L3+2u03vnjjTErF1ZKOGsi71iwcgt8INPskDHCPzSJo wUpUciKB+m6k3bDBOXM//96FrQeAXilyDvKWrPlfCbNG3TJ094zuFVqECn7f39nhWzx5Z4 FmG8bbLU9jdsb8qdNh1KGk8WrZ4fusi82gramHqDf2UAJX+AhJGe45WyQdNNYOzlqwLwG1 LHHwhgthQwYzUuLH1h9Ep64E8EbusLUjaC+jkyQmbbGnKA4taJG/nBeC5KKLqE8kLUxmCa xK7DVgOeGeMAfxOvUsxK4o+Idb3DDtxWEOAvywkxYxGRaoRra+bN71YvHQYVKA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1722551286; a=rsa-sha256; cv=none; b=jnv0WZNaxVQxr3k524ZLvGoIJYpBcZl2zWyVlM2q++/9Rk3c+AUgM/5LIFot9VxexnE69h YYizsRGXGCql++MIo01u3Gzt9FNRxiQv87A58jticrGGpiDOTzCmn4cKb5VBJnm7Ksxci0 mfFlEKr9wNHDmD2D6kS+b/f/txjTKuEbydBNt9oXMXK2q9VV722QsQqCA6lTWisu8uezJl dKeJ/M2p7WYv9027ReNEQJPphD963QGzpm8tAlBhhlFtOwjxLjXt+iQpBv+NA/AQALIY7m Cf6LwA6oR8lJqVANaMiBsioeJfqMv1aTw/3lfriF76/wkOiioPSXNPH2rZj2Aw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1722551286; 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=a9Nl7m3wIn+Ic/Xg3yBcZBHU18cDjBELWCi0wG8Zpp0=; b=YkeQwpMCHxeB0agQqxJStwKt0sHD+Z8Jj6Hfb34l+CCepI3MBs3DspzRGZczxa8Bn1SnpS H2R7/FUpUzZf8J3iWtFSkzhAm7LW/wL0fe8GR4f3reMK5mrFs80kzNoKYElOesKQ/QH06l yF9Z5AyaZ3QhixSrKUf2OF1WYOW5NzA81K5xzrBBn12NmZq10JyQluWfuUTJ5IRBRqSBMu GapUb1OUApSuuvm3DrJghI5iCOdMYfeQEIAng4j5/Y18BFTOxoQgUwbT2Du7nK2WjbDLkB JteO9TZIreUaFFyVcAuKyEbZTEgnubaYK1V+osNNgO/2NkzA/X+L7ec/zIqlBw== 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 4WZkBG4WCdz12nx; Thu, 1 Aug 2024 22:28:06 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 471MS6fc028728; Thu, 1 Aug 2024 22:28:06 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 471MS6FN028725; Thu, 1 Aug 2024 22:28:06 GMT (envelope-from git) Date: Thu, 1 Aug 2024 22:28:06 GMT Message-Id: <202408012228.471MS6FN028725@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Vladimir Kondratyev Subject: git: 7403f2c657dc - stable/14 - LinuxKPI: Add pci_iomap_range function List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: wulf X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: 7403f2c657dc66665d6cff9ab4cd67d2f3d0cf56 Auto-Submitted: auto-generated The branch stable/14 has been updated by wulf: URL: https://cgit.FreeBSD.org/src/commit/?id=7403f2c657dc66665d6cff9ab4cd67d2f3d0cf56 commit 7403f2c657dc66665d6cff9ab4cd67d2f3d0cf56 Author: Vladimir Kondratyev AuthorDate: 2024-07-21 13:10:25 +0000 Commit: Vladimir Kondratyev CommitDate: 2024-08-01 21:16:23 +0000 LinuxKPI: Add pci_iomap_range function pci_iomap_range creates a virtual mapping cookie for a PCI BAR. As compared with pci_iomap it got extra offset parameter. Sponsored by: Serenity CyberSecurity, LLC MFC after: 1 week Reviewed by: manu, bz Differential Revision: https://reviews.freebsd.org/D45904 (cherry picked from commit fcc350c375f776318d0da8021109631492ab9261) --- sys/compat/linuxkpi/common/include/linux/pci.h | 4 ++++ sys/compat/linuxkpi/common/src/linux_pci.c | 16 +++++++++++++--- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/sys/compat/linuxkpi/common/include/linux/pci.h b/sys/compat/linuxkpi/common/include/linux/pci.h index 027dc0dfca0b..f9b60ae186b5 100644 --- a/sys/compat/linuxkpi/common/include/linux/pci.h +++ b/sys/compat/linuxkpi/common/include/linux/pci.h @@ -362,6 +362,8 @@ bool pci_device_is_present(struct pci_dev *pdev); int linuxkpi_pcim_enable_device(struct pci_dev *pdev); void __iomem **linuxkpi_pcim_iomap_table(struct pci_dev *pdev); +void *linuxkpi_pci_iomap_range(struct pci_dev *pdev, int mmio_bar, + unsigned long mmio_off, unsigned long mmio_size); void *linuxkpi_pci_iomap(struct pci_dev *pdev, int mmio_bar, int mmio_size); void linuxkpi_pci_iounmap(struct pci_dev *pdev, void *res); int linuxkpi_pcim_iomap_regions(struct pci_dev *pdev, uint32_t mask, @@ -774,6 +776,8 @@ static inline void pci_disable_sriov(struct pci_dev *dev) { } +#define pci_iomap_range(pdev, mmio_bar, mmio_off, mmio_size) \ + linuxkpi_pci_iomap_range(pdev, mmio_bar, mmio_off, mmio_size) #define pci_iomap(pdev, mmio_bar, mmio_size) \ linuxkpi_pci_iomap(pdev, mmio_bar, mmio_size) #define pci_iounmap(pdev, res) linuxkpi_pci_iounmap(pdev, res) diff --git a/sys/compat/linuxkpi/common/src/linux_pci.c b/sys/compat/linuxkpi/common/src/linux_pci.c index 3ed0f268d5f9..c41a55fc9f87 100644 --- a/sys/compat/linuxkpi/common/src/linux_pci.c +++ b/sys/compat/linuxkpi/common/src/linux_pci.c @@ -756,7 +756,8 @@ _lkpi_pci_iomap(struct pci_dev *pdev, int bar, int mmio_size __unused) } void * -linuxkpi_pci_iomap(struct pci_dev *pdev, int mmio_bar, int mmio_size) +linuxkpi_pci_iomap_range(struct pci_dev *pdev, int mmio_bar, + unsigned long mmio_off, unsigned long mmio_size) { struct resource *res; @@ -766,7 +767,14 @@ linuxkpi_pci_iomap(struct pci_dev *pdev, int mmio_bar, int mmio_size) /* This is a FreeBSD extension so we can use bus_*(). */ if (pdev->want_iomap_res) return (res); - return ((void *)rman_get_bushandle(res)); + MPASS(mmio_off < rman_get_size(res)); + return ((void *)(rman_get_bushandle(res) + mmio_off)); +} + +void * +linuxkpi_pci_iomap(struct pci_dev *pdev, int mmio_bar, int mmio_size) +{ + return (linuxkpi_pci_iomap_range(pdev, mmio_bar, 0, mmio_size)); } void @@ -775,7 +783,9 @@ linuxkpi_pci_iounmap(struct pci_dev *pdev, void *res) struct pci_mmio_region *mmio, *p; TAILQ_FOREACH_SAFE(mmio, &pdev->mmio, next, p) { - if (res != (void *)rman_get_bushandle(mmio->res)) + if ((bus_space_handle_t)res < rman_get_bushandle(mmio->res) || + (bus_space_handle_t)res >= rman_get_bushandle(mmio->res) + + rman_get_size(mmio->res)) continue; bus_release_resource(pdev->dev.bsddev, mmio->type, mmio->rid, mmio->res);