data_type
large_stringclasses
3 values
source
large_stringclasses
29 values
code
large_stringlengths
98
49.4M
filepath
large_stringlengths
5
161
message
large_stringclasses
234 values
commit
large_stringclasses
234 values
subject
large_stringclasses
418 values
critique
large_stringlengths
101
1.26M
metadata
dict
lkml_critique
lkml
Hi all, There were various suggestions in the September 2025 thread "[TECH TOPIC] vfio, iommufd: Enabling user space drivers to vend more granular access to client processes" [0], and LPC discussions, around improving the situation for multi-process userspace driver designs. This RFC series implements some of these ideas. Background: Multi-process USDs ============================== The userspace driver scenario discussed in that thread involves a primary process driving a PCIe function through VFIO/iommufd, which manages the function-wide ownership/lifecycle. The function is designed to provide multiple distinct programming interfaces (for example, several independent MMIO register frames in one function), and the primary process delegates control of these interfaces to multiple independent client processes (which do the actual work). This scenario clearly relies on a HW design that provides appropriate isolation between the programming interfaces. The two key needs are: 1. Mechanisms to safely delegate a subset of the device MMIO resources to a client process without over-sharing wider access (or influence over whole-device activities, such as reset). 2. Mechanisms to allow a client process to do its own iommufd management w.r.t. its address space, in a way that's isolated from DMA relating to other clients. mmap() of VFIO DMABUFs ====================== First, this RFC addresses #1, implementing the proposals in [0] to add mmap() support to the existing VFIO DMABUF exporter. This enables a userspace driver to define DMABUF ranges corresponding to sub-ranges of a BAR, and grant a given client (via a shared fd) the capability to access (only) those sub-ranges. The VFIO device fds would be kept private to the primary process. All the client can do with that fd is map (or iomap via iommufd) that specific subset of resources, and the impact of bugs/malice is contained. (We'll follow up on #2 separately, as a related-but-distinct problem. PASIDs are one way to achieve per-client isolation of DMA; another could be sharing of a single IOVA space via 'constrained' iommufds.) Revocation/reclaim ================== That's useful as-is, but then the lifetime of access granted to a client needs to be managed well. For example, a protocol between the primary process and the client can indicate when the client is done, and when it's safe to reuse the resources elsewhere. Resources could be released cooperatively, but it's much more robust to enable the driver to make the resources guaranteed-inaccessible when it chooses, so that it can re-assign them to other uses in future. So, second, I've suggested a PoC/example mechanism for reclaiming ranges shared with clients: a new DMABUF ioctl, DMA_BUF_IOCTL_REVOKE, is routed to a DMABUF exporter callback. The VFIO DMABUF exporter's implementation permanently revokes a DMABUF (notifying importers, and zapping PTEs for any mappings). This makes the DMABUF defunct and any client (or third party the client has shared the buffer onto!) cannot be used to access the BAR ranges, whether via DMABUF import or mmap(). A primary driver process would do this operation when the client's tenure ends to reclaim "loaned-out" MMIO interfaces, at which point the interfaces could be safely re-used. This ioctl is one of several possible approaches to achieve buffer revocation, but I wanted to demonstrate something here as it's an important part of the buffer lifecycle in this driver scenario. An alternative implementation could be some VFIO-specific operation to search for a DMABUF (by address?) and kill it, but if the server keeps hold of the DMABUF fd that's already a clean way to locate it later. BAR mapping access attributes ============================= Third, inspired by Alex [Mastro] and Jason's comments in [0], and Mahmoud's work in [1] with the goal of controlling CPU access attributes for VFIO BAR mappings (e.g. WC) I noticed that once we can mmap() VFIO DMABUFs representing BAR sub-spans, it's straightforward to decorate them with access attributes for the VMA. I've proposed reserving a field in struct vfio_device_feature_dma_buf's flags to specify an attribute for its ranges. Although that keeps the (UAPI) struct unchanged, it means all ranges in a DMABUF share the same attribute. I feel a single attribute-to-mmap() relation is logical/reasonable. An application can also create multiple DMABUFs to describe any BAR layout and mix of attributes. Tests ===== I've included an [RFC ONLY] userspace test program which I am _not_ proposing to merge, but am sharing for context. It illustrates & tests various map/revoke cases, but doesn't use the existing VFIO selftests and relies on a (tweaked) QEMU EDU function. I'm working on integrating the scenarios into the existing VFIO selftests. This code has been tested in mapping DMABUFs of single/multiple ranges, aliasing mmap()s, aliasing ranges across DMABUFs, vm_pgoff > 0, revocation, shutdown/cleanup scenarios, and hugepage mappings seem to work correctly. I've lightly tested WC mappings also (by observing resulting PTEs as having the correct attributes...). (The first two commits are a couple of tiny bugfixes which I can send separately, should reviewers prefer.) This series is based on v6.19 but I expect to rebase, at least onto Leon's recent work [2] ("vfio: Wait for dma-buf invalidation to complete"). What are people's thoughts? I'll respin to de-RFC and capture comments, if we think this approach is appropriate. Thanks, Matt References: [0]: https://lore.kernel.org/linux-iommu/20250918214425.2677057-1-amastro@fb.com/ [1]: https://lore.kernel.org/all/20250804104012.87915-1-mngyadam@amazon.de/ [2]: https://lore.kernel.org/linux-iommu/20260205-nocturnal-poetic-chamois-f566ad@houat/T/#m310cd07011e3a1461b6fda45e3f9b886ba76571a Matt Evans (7): vfio/pci: Ensure VFIO barmap is set up before creating a DMABUF vfio/pci: Clean up DMABUFs before disabling function vfio/pci: Support mmap() of a DMABUF dma-buf: uapi: Mechanism to revoke DMABUFs via ioctl() vfio/pci: Permanently revoke a DMABUF on request vfio/pci: Add mmap() attributes to DMABUF feature [RFC ONLY] selftests: vfio: Add standalone vfio_dmabuf_mmap_test drivers/dma-buf/dma-buf.c | 5 + drivers/vfio/pci/vfio_pci_core.c | 4 +- drivers/vfio/pci/vfio_pci_dmabuf.c | 300 ++++++- include/linux/dma-buf.h | 22 + include/uapi/linux/dma-buf.h | 1 + include/uapi/linux/vfio.h | 12 +- tools/testing/selftests/vfio/Makefile | 1 + .../vfio/standalone/vfio_dmabuf_mmap_test.c | 822 ++++++++++++++++++ 8 files changed, 1153 insertions(+), 14 deletions(-) create mode 100644 tools/testing/selftests/vfio/standalone/vfio_dmabuf_mmap_test.c -- 2.47.3
null
null
null
[RFC PATCH 0/7] vfio/pci: Add mmap() for DMABUFs
A new field is reserved in vfio_device_feature_dma_buf.flags to request CPU-facing memory type attributes for mmap()s of the buffer. Add a flag VFIO_DEVICE_FEATURE_DMA_BUF_ATTR_WC, which results in WC PTEs for the DMABUF's BAR region. Signed-off-by: Matt Evans <mattev@meta.com> --- drivers/vfio/pci/vfio_pci_dmabuf.c | 18 ++++++++++++++---- include/uapi/linux/vfio.h | 12 +++++++++--- 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/drivers/vfio/pci/vfio_pci_dmabuf.c b/drivers/vfio/pci/vfio_pci_dmabuf.c index af30ca205f31..d66a918e9934 100644 --- a/drivers/vfio/pci/vfio_pci_dmabuf.c +++ b/drivers/vfio/pci/vfio_pci_dmabuf.c @@ -28,6 +28,7 @@ struct vfio_pci_dma_buf { struct dma_buf_phys_vec *phys_vec; struct p2pdma_provider *provider; u32 nr_ranges; + u32 attrs; enum vfio_pci_dma_buf_status status; }; @@ -286,13 +287,15 @@ static int vfio_pci_dma_buf_mmap(struct dma_buf *dmabuf, struct vm_area_struct * return -EINVAL; vma->vm_private_data = priv; - vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot); + + if (priv->attrs == VFIO_DEVICE_FEATURE_DMA_BUF_ATTR_WC) + vma->vm_page_prot = pgprot_writecombine(vma->vm_page_prot); + else + vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot); vma->vm_page_prot = pgprot_decrypted(vma->vm_page_prot); /* * See comments in vfio_pci_core_mmap() re VM_ALLOW_ANY_UNCACHED. - * - * FIXME: get mapping attributes from dmabuf? */ vm_flags_set(vma, VM_ALLOW_ANY_UNCACHED | VM_IO | VM_PFNMAP | VM_DONTEXPAND | VM_DONTDUMP); @@ -402,6 +405,12 @@ static int validate_dmabuf_input(struct vfio_device_feature_dma_buf *dma_buf, size_t length = 0; u32 i; + if ((dma_buf->flags != 0) && + ((dma_buf->flags & ~VFIO_DEVICE_FEATURE_DMA_BUF_ATTR_MASK) || + ((dma_buf->flags & VFIO_DEVICE_FEATURE_DMA_BUF_ATTR_MASK) != + VFIO_DEVICE_FEATURE_DMA_BUF_ATTR_WC))) + return -EINVAL; + for (i = 0; i < dma_buf->nr_ranges; i++) { u64 offset = dma_ranges[i].offset; u64 len = dma_ranges[i].length; @@ -446,7 +455,7 @@ int vfio_pci_core_feature_dma_buf(struct vfio_pci_core_device *vdev, u32 flags, if (copy_from_user(&get_dma_buf, arg, sizeof(get_dma_buf))) return -EFAULT; - if (!get_dma_buf.nr_ranges || get_dma_buf.flags) + if (!get_dma_buf.nr_ranges) return -EINVAL; /* @@ -490,6 +499,7 @@ int vfio_pci_core_feature_dma_buf(struct vfio_pci_core_device *vdev, u32 flags, priv->vdev = vdev; priv->nr_ranges = get_dma_buf.nr_ranges; priv->size = length; + priv->attrs = get_dma_buf.flags & VFIO_DEVICE_FEATURE_DMA_BUF_ATTR_MASK; ret = vdev->pci_ops->get_dmabuf_phys(vdev, &priv->provider, get_dma_buf.region_index, priv->phys_vec, dma_ranges, diff --git a/include/uapi/linux/vfio.h b/include/uapi/linux/vfio.h index ac2329f24141..9e0fbf333452 100644 --- a/include/uapi/linux/vfio.h +++ b/include/uapi/linux/vfio.h @@ -1487,7 +1487,9 @@ struct vfio_device_feature_bus_master { * etc. offset/length specify a slice of the region to create the dmabuf from. * nr_ranges is the total number of (P2P DMA) ranges that comprise the dmabuf. * - * flags should be 0. + * flags contains: + * - A field for userspace mapping attribute: by default, suitable for regular + * MMIO. Alternate attributes (such as WC) can be selected. * * Return: The fd number on success, -1 and errno is set on failure. */ @@ -1501,8 +1503,12 @@ struct vfio_region_dma_range { struct vfio_device_feature_dma_buf { __u32 region_index; __u32 open_flags; - __u32 flags; - __u32 nr_ranges; + __u32 flags; + /* Flags sub-field reserved for attribute enum */ +#define VFIO_DEVICE_FEATURE_DMA_BUF_ATTR_MASK (0xf << 28) +#define VFIO_DEVICE_FEATURE_DMA_BUF_ATTR_UC (0 << 28) +#define VFIO_DEVICE_FEATURE_DMA_BUF_ATTR_WC (1 << 28) + __u32 nr_ranges; struct vfio_region_dma_range dma_ranges[] __counted_by(nr_ranges); }; -- 2.47.3
{ "author": "Matt Evans <mattev@meta.com>", "date": "Thu, 26 Feb 2026 12:22:02 -0800", "is_openbsd": false, "thread_id": "a006b938-cd53-4c56-8131-30f557919ec6@amd.com.mbox.gz" }
lkml_critique
lkml
Hi all, There were various suggestions in the September 2025 thread "[TECH TOPIC] vfio, iommufd: Enabling user space drivers to vend more granular access to client processes" [0], and LPC discussions, around improving the situation for multi-process userspace driver designs. This RFC series implements some of these ideas. Background: Multi-process USDs ============================== The userspace driver scenario discussed in that thread involves a primary process driving a PCIe function through VFIO/iommufd, which manages the function-wide ownership/lifecycle. The function is designed to provide multiple distinct programming interfaces (for example, several independent MMIO register frames in one function), and the primary process delegates control of these interfaces to multiple independent client processes (which do the actual work). This scenario clearly relies on a HW design that provides appropriate isolation between the programming interfaces. The two key needs are: 1. Mechanisms to safely delegate a subset of the device MMIO resources to a client process without over-sharing wider access (or influence over whole-device activities, such as reset). 2. Mechanisms to allow a client process to do its own iommufd management w.r.t. its address space, in a way that's isolated from DMA relating to other clients. mmap() of VFIO DMABUFs ====================== First, this RFC addresses #1, implementing the proposals in [0] to add mmap() support to the existing VFIO DMABUF exporter. This enables a userspace driver to define DMABUF ranges corresponding to sub-ranges of a BAR, and grant a given client (via a shared fd) the capability to access (only) those sub-ranges. The VFIO device fds would be kept private to the primary process. All the client can do with that fd is map (or iomap via iommufd) that specific subset of resources, and the impact of bugs/malice is contained. (We'll follow up on #2 separately, as a related-but-distinct problem. PASIDs are one way to achieve per-client isolation of DMA; another could be sharing of a single IOVA space via 'constrained' iommufds.) Revocation/reclaim ================== That's useful as-is, but then the lifetime of access granted to a client needs to be managed well. For example, a protocol between the primary process and the client can indicate when the client is done, and when it's safe to reuse the resources elsewhere. Resources could be released cooperatively, but it's much more robust to enable the driver to make the resources guaranteed-inaccessible when it chooses, so that it can re-assign them to other uses in future. So, second, I've suggested a PoC/example mechanism for reclaiming ranges shared with clients: a new DMABUF ioctl, DMA_BUF_IOCTL_REVOKE, is routed to a DMABUF exporter callback. The VFIO DMABUF exporter's implementation permanently revokes a DMABUF (notifying importers, and zapping PTEs for any mappings). This makes the DMABUF defunct and any client (or third party the client has shared the buffer onto!) cannot be used to access the BAR ranges, whether via DMABUF import or mmap(). A primary driver process would do this operation when the client's tenure ends to reclaim "loaned-out" MMIO interfaces, at which point the interfaces could be safely re-used. This ioctl is one of several possible approaches to achieve buffer revocation, but I wanted to demonstrate something here as it's an important part of the buffer lifecycle in this driver scenario. An alternative implementation could be some VFIO-specific operation to search for a DMABUF (by address?) and kill it, but if the server keeps hold of the DMABUF fd that's already a clean way to locate it later. BAR mapping access attributes ============================= Third, inspired by Alex [Mastro] and Jason's comments in [0], and Mahmoud's work in [1] with the goal of controlling CPU access attributes for VFIO BAR mappings (e.g. WC) I noticed that once we can mmap() VFIO DMABUFs representing BAR sub-spans, it's straightforward to decorate them with access attributes for the VMA. I've proposed reserving a field in struct vfio_device_feature_dma_buf's flags to specify an attribute for its ranges. Although that keeps the (UAPI) struct unchanged, it means all ranges in a DMABUF share the same attribute. I feel a single attribute-to-mmap() relation is logical/reasonable. An application can also create multiple DMABUFs to describe any BAR layout and mix of attributes. Tests ===== I've included an [RFC ONLY] userspace test program which I am _not_ proposing to merge, but am sharing for context. It illustrates & tests various map/revoke cases, but doesn't use the existing VFIO selftests and relies on a (tweaked) QEMU EDU function. I'm working on integrating the scenarios into the existing VFIO selftests. This code has been tested in mapping DMABUFs of single/multiple ranges, aliasing mmap()s, aliasing ranges across DMABUFs, vm_pgoff > 0, revocation, shutdown/cleanup scenarios, and hugepage mappings seem to work correctly. I've lightly tested WC mappings also (by observing resulting PTEs as having the correct attributes...). (The first two commits are a couple of tiny bugfixes which I can send separately, should reviewers prefer.) This series is based on v6.19 but I expect to rebase, at least onto Leon's recent work [2] ("vfio: Wait for dma-buf invalidation to complete"). What are people's thoughts? I'll respin to de-RFC and capture comments, if we think this approach is appropriate. Thanks, Matt References: [0]: https://lore.kernel.org/linux-iommu/20250918214425.2677057-1-amastro@fb.com/ [1]: https://lore.kernel.org/all/20250804104012.87915-1-mngyadam@amazon.de/ [2]: https://lore.kernel.org/linux-iommu/20260205-nocturnal-poetic-chamois-f566ad@houat/T/#m310cd07011e3a1461b6fda45e3f9b886ba76571a Matt Evans (7): vfio/pci: Ensure VFIO barmap is set up before creating a DMABUF vfio/pci: Clean up DMABUFs before disabling function vfio/pci: Support mmap() of a DMABUF dma-buf: uapi: Mechanism to revoke DMABUFs via ioctl() vfio/pci: Permanently revoke a DMABUF on request vfio/pci: Add mmap() attributes to DMABUF feature [RFC ONLY] selftests: vfio: Add standalone vfio_dmabuf_mmap_test drivers/dma-buf/dma-buf.c | 5 + drivers/vfio/pci/vfio_pci_core.c | 4 +- drivers/vfio/pci/vfio_pci_dmabuf.c | 300 ++++++- include/linux/dma-buf.h | 22 + include/uapi/linux/dma-buf.h | 1 + include/uapi/linux/vfio.h | 12 +- tools/testing/selftests/vfio/Makefile | 1 + .../vfio/standalone/vfio_dmabuf_mmap_test.c | 822 ++++++++++++++++++ 8 files changed, 1153 insertions(+), 14 deletions(-) create mode 100644 tools/testing/selftests/vfio/standalone/vfio_dmabuf_mmap_test.c -- 2.47.3
null
null
null
[RFC PATCH 0/7] vfio/pci: Add mmap() for DMABUFs
A VFIO DMABUF can export a subset of a BAR to userspace by fd; add support for mmap() of this fd. This provides another route for a process to map BARs, except one where the process can only map a specific subset of a BAR represented by the exported DMABUF. mmap() support enables userspace driver designs that safely delegate access to BAR sub-ranges to other client processes by sharing a DMABUF fd, without having to share the (omnipotent) VFIO device fd with them. The mmap callback installs vm_ops callbacks for .fault and .huge_fault; they find a PFN by searching the DMABUF's physical ranges. That is, DMABUFs with multiple ranges are supported for mmap(). Signed-off-by: Matt Evans <mattev@meta.com> --- drivers/vfio/pci/vfio_pci_dmabuf.c | 219 +++++++++++++++++++++++++++++ 1 file changed, 219 insertions(+) diff --git a/drivers/vfio/pci/vfio_pci_dmabuf.c b/drivers/vfio/pci/vfio_pci_dmabuf.c index 46ab64fbeb19..bebb496bd0f2 100644 --- a/drivers/vfio/pci/vfio_pci_dmabuf.c +++ b/drivers/vfio/pci/vfio_pci_dmabuf.c @@ -85,6 +85,209 @@ static void vfio_pci_dma_buf_release(struct dma_buf *dmabuf) kfree(priv); } +static int vfio_pci_dma_buf_find_pfn(struct device *dev, + struct vfio_pci_dma_buf *vpdmabuf, + struct vm_area_struct *vma, + unsigned long address, + unsigned int order, + unsigned long *out_pfn) +{ + /* + * Given a VMA (start, end, pgoffs) and a fault address, + * search phys_vec[] to find the range representing the + * address's offset into the VMA (and so a PFN). + * + * The phys_vec ranges represent contiguous spans of VAs + * upwards from the buffer offset 0; the actual PFNs might be + * in any order, overlap/alias, etc. Calculate an offset of + * the desired page given VMA start/pgoff and address, then + * search upwards from 0 to find which span contains it. + * + * On success, a valid PFN for a page sized by 'order' is + * returned into out_pfn. + * + * Failure occurs if: + * - The page would cross the edge of the VMA + * - The page isn't entirely contained within a range + * - We find a range, but the final PFN isn't aligned to the + * requested order. + * + * (Upon failure, the caller is expected to try again with a + * smaller order; the tests above will always succeed for + * order=0 as the limit case.) + * + * It's suboptimal if DMABUFs are created with neigbouring + * ranges that are physically contiguous, since hugepages + * can't straddle range boundaries. (The construction of the + * ranges vector should merge such ranges.) + */ + + unsigned long rounded_page_addr = address & ~((PAGE_SIZE << order) - 1); + unsigned long rounded_page_end = rounded_page_addr + (PAGE_SIZE << order); + unsigned long buf_page_offset; + unsigned long buf_offset = 0; + unsigned int i; + + if (rounded_page_addr < vma->vm_start || rounded_page_end > vma->vm_end) + return -EAGAIN; + + if (unlikely(check_add_overflow(rounded_page_addr - vma->vm_start, + vma->vm_pgoff << PAGE_SHIFT, &buf_page_offset))) + return -EFAULT; + + for (i = 0; i < vpdmabuf->nr_ranges; i++) { + unsigned long range_len = vpdmabuf->phys_vec[i].len; + unsigned long range_start = vpdmabuf->phys_vec[i].paddr; + + if (buf_page_offset >= buf_offset && + buf_page_offset + (PAGE_SIZE << order) <= buf_offset + range_len) { + /* + * The faulting page is wholly contained + * within the span represented by the range. + * Validate PFN alignment for the order: + */ + unsigned long pfn = (range_start >> PAGE_SHIFT) + + ((buf_page_offset - buf_offset) >> PAGE_SHIFT); + + if (IS_ALIGNED(pfn, 1 << order)) { + *out_pfn = pfn; + return 0; + } + /* Retry with smaller order */ + return -EAGAIN; + } + buf_offset += range_len; + } + + /* + * If we get here, the address fell outside of the span + * represented by the (concatenated) ranges. This can + * never happen because vfio_pci_dma_buf_mmap() checks that + * the VMA is <= the total size of the ranges. + * + * But if it does, force SIGBUS for the access, and warn. + */ + WARN_ONCE(1, "No range for addr 0x%lx, order %d: VMA 0x%lx-0x%lx pgoff 0x%lx, %d ranges, size 0x%lx\n", + address, order, vma->vm_start, vma->vm_end, vma->vm_pgoff, + vpdmabuf->nr_ranges, vpdmabuf->size); + + return -EFAULT; +} + +static vm_fault_t vfio_pci_dma_buf_mmap_huge_fault(struct vm_fault *vmf, + unsigned int order) +{ + struct vm_area_struct *vma = vmf->vma; + struct vfio_pci_dma_buf *priv = vma->vm_private_data; + struct vfio_pci_core_device *vdev; + unsigned long pfn; + vm_fault_t ret = VM_FAULT_FALLBACK; + + vdev = READ_ONCE(priv->vdev); + + /* + * A fault for an existing mmap might occur after + * vfio_pci_dma_buf_cleanup() has revoked and destroyed the + * vdev's DMABUFs, and annulled vdev. After creation, vdev is + * only ever written in cleanup. + */ + if (!vdev) + return VM_FAULT_SIGBUS; + + int r = vfio_pci_dma_buf_find_pfn(&vdev->pdev->dev, priv, vma, + vmf->address, order, &pfn); + + if (r == 0) { + scoped_guard(rwsem_read, &vdev->memory_lock) { + /* Deal with the possibility of a fault racing + * with vfio_pci_dma_buf_move() revoking and + * then unmapping the buffer. The + * revocation/unmap and status change occurs + * whilst holding memory_lock. + */ + if (priv->revoked) + ret = VM_FAULT_SIGBUS; + else + ret = vfio_pci_vmf_insert_pfn(vdev, vmf, pfn, order); + } + } else if (r != -EAGAIN) { + ret = VM_FAULT_SIGBUS; + } + + dev_dbg_ratelimited(&vdev->pdev->dev, + "%s(order = %d) PFN 0x%lx, VA 0x%lx, pgoff 0x%lx: 0x%x\n", + __func__, order, pfn, vmf->address, vma->vm_pgoff, (unsigned int)ret); + + return ret; +} + +static vm_fault_t vfio_pci_dma_buf_mmap_page_fault(struct vm_fault *vmf) +{ + return vfio_pci_dma_buf_mmap_huge_fault(vmf, 0); +} + +static const struct vm_operations_struct vfio_pci_dma_buf_mmap_ops = { + .fault = vfio_pci_dma_buf_mmap_page_fault, +#ifdef CONFIG_ARCH_SUPPORTS_HUGE_PFNMAP + .huge_fault = vfio_pci_dma_buf_mmap_huge_fault, +#endif +}; + +static bool vfio_pci_dma_buf_is_mappable(struct dma_buf *dmabuf) +{ + struct vfio_pci_dma_buf *priv = dmabuf->priv; + + /* + * Sanity checks at mmap() time; alignment has already been + * asserted by validate_dmabuf_input(). + * + * Although the revoked state is transient, refuse to map a + * revoked buffer to flag early that something odd is going + * on: for example, users should not be mmap()ing a buffer + * that's being moved [by a user-triggered activity]. + */ + if (priv->revoked) + return false; + + return true; +} + +/* + * Similar to vfio_pci_core_mmap() for a regular VFIO device fd, but + * differs by pre-checks performed and ultimately the vm_ops installed. + */ +static int vfio_pci_dma_buf_mmap(struct dma_buf *dmabuf, struct vm_area_struct *vma) +{ + struct vfio_pci_dma_buf *priv = dmabuf->priv; + u64 req_len, req_start; + + if (!vfio_pci_dma_buf_is_mappable(dmabuf)) + return -ENODEV; + if ((vma->vm_flags & VM_SHARED) == 0) + return -EINVAL; + + req_len = vma->vm_end - vma->vm_start; + req_start = vma->vm_pgoff << PAGE_SHIFT; + + if (req_start + req_len > priv->size) + return -EINVAL; + + vma->vm_private_data = priv; + vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot); + vma->vm_page_prot = pgprot_decrypted(vma->vm_page_prot); + + /* + * See comments in vfio_pci_core_mmap() re VM_ALLOW_ANY_UNCACHED. + * + * FIXME: get mapping attributes from dmabuf? + */ + vm_flags_set(vma, VM_ALLOW_ANY_UNCACHED | VM_IO | VM_PFNMAP | + VM_DONTEXPAND | VM_DONTDUMP); + vma->vm_ops = &vfio_pci_dma_buf_mmap_ops; + + return 0; +} + static const struct dma_buf_ops vfio_pci_dmabuf_ops = { .pin = vfio_pci_dma_buf_pin, .unpin = vfio_pci_dma_buf_unpin, @@ -92,6 +295,7 @@ static const struct dma_buf_ops vfio_pci_dmabuf_ops = { .map_dma_buf = vfio_pci_dma_buf_map, .unmap_dma_buf = vfio_pci_dma_buf_unmap, .release = vfio_pci_dma_buf_release, + .mmap = vfio_pci_dma_buf_mmap, }; /* @@ -335,6 +539,11 @@ void vfio_pci_dma_buf_move(struct vfio_pci_core_device *vdev, bool revoked) struct vfio_pci_dma_buf *tmp; lockdep_assert_held_write(&vdev->memory_lock); + /* + * Holding memory_lock ensures a racing + * vfio_pci_dma_buf_mmap_*_fault() observes priv->revoked + * properly. + */ list_for_each_entry_safe(priv, tmp, &vdev->dmabufs, dmabufs_elm) { if (!get_file_active(&priv->dmabuf->file)) @@ -345,6 +554,14 @@ void vfio_pci_dma_buf_move(struct vfio_pci_core_device *vdev, bool revoked) priv->revoked = revoked; dma_buf_move_notify(priv->dmabuf); dma_resv_unlock(priv->dmabuf->resv); + + /* + * Unmap any possible userspace mappings for a + * now-revoked DMABUF: + */ + if (revoked) + unmap_mapping_range(priv->dmabuf->file->f_mapping, + 0, priv->size, 1); } fput(priv->dmabuf->file); } @@ -366,6 +583,8 @@ void vfio_pci_dma_buf_cleanup(struct vfio_pci_core_device *vdev) priv->revoked = true; dma_buf_move_notify(priv->dmabuf); dma_resv_unlock(priv->dmabuf->resv); + unmap_mapping_range(priv->dmabuf->file->f_mapping, + 0, priv->size, 1); vfio_device_put_registration(&vdev->vdev); fput(priv->dmabuf->file); } -- 2.47.3
{ "author": "Matt Evans <mattev@meta.com>", "date": "Thu, 26 Feb 2026 12:21:59 -0800", "is_openbsd": false, "thread_id": "a006b938-cd53-4c56-8131-30f557919ec6@amd.com.mbox.gz" }
lkml_critique
lkml
Hi all, There were various suggestions in the September 2025 thread "[TECH TOPIC] vfio, iommufd: Enabling user space drivers to vend more granular access to client processes" [0], and LPC discussions, around improving the situation for multi-process userspace driver designs. This RFC series implements some of these ideas. Background: Multi-process USDs ============================== The userspace driver scenario discussed in that thread involves a primary process driving a PCIe function through VFIO/iommufd, which manages the function-wide ownership/lifecycle. The function is designed to provide multiple distinct programming interfaces (for example, several independent MMIO register frames in one function), and the primary process delegates control of these interfaces to multiple independent client processes (which do the actual work). This scenario clearly relies on a HW design that provides appropriate isolation between the programming interfaces. The two key needs are: 1. Mechanisms to safely delegate a subset of the device MMIO resources to a client process without over-sharing wider access (or influence over whole-device activities, such as reset). 2. Mechanisms to allow a client process to do its own iommufd management w.r.t. its address space, in a way that's isolated from DMA relating to other clients. mmap() of VFIO DMABUFs ====================== First, this RFC addresses #1, implementing the proposals in [0] to add mmap() support to the existing VFIO DMABUF exporter. This enables a userspace driver to define DMABUF ranges corresponding to sub-ranges of a BAR, and grant a given client (via a shared fd) the capability to access (only) those sub-ranges. The VFIO device fds would be kept private to the primary process. All the client can do with that fd is map (or iomap via iommufd) that specific subset of resources, and the impact of bugs/malice is contained. (We'll follow up on #2 separately, as a related-but-distinct problem. PASIDs are one way to achieve per-client isolation of DMA; another could be sharing of a single IOVA space via 'constrained' iommufds.) Revocation/reclaim ================== That's useful as-is, but then the lifetime of access granted to a client needs to be managed well. For example, a protocol between the primary process and the client can indicate when the client is done, and when it's safe to reuse the resources elsewhere. Resources could be released cooperatively, but it's much more robust to enable the driver to make the resources guaranteed-inaccessible when it chooses, so that it can re-assign them to other uses in future. So, second, I've suggested a PoC/example mechanism for reclaiming ranges shared with clients: a new DMABUF ioctl, DMA_BUF_IOCTL_REVOKE, is routed to a DMABUF exporter callback. The VFIO DMABUF exporter's implementation permanently revokes a DMABUF (notifying importers, and zapping PTEs for any mappings). This makes the DMABUF defunct and any client (or third party the client has shared the buffer onto!) cannot be used to access the BAR ranges, whether via DMABUF import or mmap(). A primary driver process would do this operation when the client's tenure ends to reclaim "loaned-out" MMIO interfaces, at which point the interfaces could be safely re-used. This ioctl is one of several possible approaches to achieve buffer revocation, but I wanted to demonstrate something here as it's an important part of the buffer lifecycle in this driver scenario. An alternative implementation could be some VFIO-specific operation to search for a DMABUF (by address?) and kill it, but if the server keeps hold of the DMABUF fd that's already a clean way to locate it later. BAR mapping access attributes ============================= Third, inspired by Alex [Mastro] and Jason's comments in [0], and Mahmoud's work in [1] with the goal of controlling CPU access attributes for VFIO BAR mappings (e.g. WC) I noticed that once we can mmap() VFIO DMABUFs representing BAR sub-spans, it's straightforward to decorate them with access attributes for the VMA. I've proposed reserving a field in struct vfio_device_feature_dma_buf's flags to specify an attribute for its ranges. Although that keeps the (UAPI) struct unchanged, it means all ranges in a DMABUF share the same attribute. I feel a single attribute-to-mmap() relation is logical/reasonable. An application can also create multiple DMABUFs to describe any BAR layout and mix of attributes. Tests ===== I've included an [RFC ONLY] userspace test program which I am _not_ proposing to merge, but am sharing for context. It illustrates & tests various map/revoke cases, but doesn't use the existing VFIO selftests and relies on a (tweaked) QEMU EDU function. I'm working on integrating the scenarios into the existing VFIO selftests. This code has been tested in mapping DMABUFs of single/multiple ranges, aliasing mmap()s, aliasing ranges across DMABUFs, vm_pgoff > 0, revocation, shutdown/cleanup scenarios, and hugepage mappings seem to work correctly. I've lightly tested WC mappings also (by observing resulting PTEs as having the correct attributes...). (The first two commits are a couple of tiny bugfixes which I can send separately, should reviewers prefer.) This series is based on v6.19 but I expect to rebase, at least onto Leon's recent work [2] ("vfio: Wait for dma-buf invalidation to complete"). What are people's thoughts? I'll respin to de-RFC and capture comments, if we think this approach is appropriate. Thanks, Matt References: [0]: https://lore.kernel.org/linux-iommu/20250918214425.2677057-1-amastro@fb.com/ [1]: https://lore.kernel.org/all/20250804104012.87915-1-mngyadam@amazon.de/ [2]: https://lore.kernel.org/linux-iommu/20260205-nocturnal-poetic-chamois-f566ad@houat/T/#m310cd07011e3a1461b6fda45e3f9b886ba76571a Matt Evans (7): vfio/pci: Ensure VFIO barmap is set up before creating a DMABUF vfio/pci: Clean up DMABUFs before disabling function vfio/pci: Support mmap() of a DMABUF dma-buf: uapi: Mechanism to revoke DMABUFs via ioctl() vfio/pci: Permanently revoke a DMABUF on request vfio/pci: Add mmap() attributes to DMABUF feature [RFC ONLY] selftests: vfio: Add standalone vfio_dmabuf_mmap_test drivers/dma-buf/dma-buf.c | 5 + drivers/vfio/pci/vfio_pci_core.c | 4 +- drivers/vfio/pci/vfio_pci_dmabuf.c | 300 ++++++- include/linux/dma-buf.h | 22 + include/uapi/linux/dma-buf.h | 1 + include/uapi/linux/vfio.h | 12 +- tools/testing/selftests/vfio/Makefile | 1 + .../vfio/standalone/vfio_dmabuf_mmap_test.c | 822 ++++++++++++++++++ 8 files changed, 1153 insertions(+), 14 deletions(-) create mode 100644 tools/testing/selftests/vfio/standalone/vfio_dmabuf_mmap_test.c -- 2.47.3
null
null
null
[RFC PATCH 0/7] vfio/pci: Add mmap() for DMABUFs
This test exercises VFIO DMABUF mmap() to userspace, including various revocation/shutdown cases (which make the VMA inacessible). This is a TEMPORARY test, just to illustrate a new UAPI and DMABUF/mmap() usage. Since it originates from out-of-tree code, it duplicates some of the VFIO device setup code in .../selftests/vfio/lib. Instead, the tests should be folded into the existing VFIO tests. Signed-off-by: Matt Evans <mattev@meta.com> --- tools/testing/selftests/vfio/Makefile | 1 + .../vfio/standalone/vfio_dmabuf_mmap_test.c | 822 ++++++++++++++++++ 2 files changed, 823 insertions(+) create mode 100644 tools/testing/selftests/vfio/standalone/vfio_dmabuf_mmap_test.c diff --git a/tools/testing/selftests/vfio/Makefile b/tools/testing/selftests/vfio/Makefile index 3c796ca99a50..3382a2617f2d 100644 --- a/tools/testing/selftests/vfio/Makefile +++ b/tools/testing/selftests/vfio/Makefile @@ -4,6 +4,7 @@ TEST_GEN_PROGS += vfio_iommufd_setup_test TEST_GEN_PROGS += vfio_pci_device_test TEST_GEN_PROGS += vfio_pci_device_init_perf_test TEST_GEN_PROGS += vfio_pci_driver_test +TEST_GEN_PROGS += standalone/vfio_dmabuf_mmap_test TEST_FILES += scripts/cleanup.sh TEST_FILES += scripts/lib.sh diff --git a/tools/testing/selftests/vfio/standalone/vfio_dmabuf_mmap_test.c b/tools/testing/selftests/vfio/standalone/vfio_dmabuf_mmap_test.c new file mode 100644 index 000000000000..450d6e883bb0 --- /dev/null +++ b/tools/testing/selftests/vfio/standalone/vfio_dmabuf_mmap_test.c @@ -0,0 +1,822 @@ +/* + * Tests for VFIO DMABUF userspace mmap() + * + * As well as the basics (mmap() a BAR resource to userspace), test + * shutdown/unmapping, aliasing, and DMABUF revocation scenarios. + * + * This test relies on being attached to a QEMU EDU device (for a + * simple known MMIO layout). Example invocation, assuming function + * 0000:00:03.0 is the target: + * + * # lspci -n -s 00:03.0 + * 00:03.0 00ff: 1234:11e8 (rev 10) + * + * # readlink /sys/bus/pci/devices/0000\:00\:03.0/iommu_group + * ../../../../../kernel/iommu_groups/3 + * + * (if there's a driver already attached) + * # echo 0000:00:03.0 > /sys/bus/pci/devices/0000:00:03.0/driver/unbind + * + * (and, might need) + * # echo 1 > /sys/module/vfio_iommu_type1/parameters/allow_unsafe_interrupts + * + * Attach to VFIO: + * # echo 1234 11e8 > /sys/bus/pci/drivers/vfio-pci/new_id + * + * There should be only one thing in the group: + * # ls /sys/bus/pci/devices/0000:00:03.0/iommu_group/devices + * + * Then given above an invocation would be: + * # this_test -r 0000:00:03.0 -g 3 + * + * However, note the QEMU EDU device has a very small address span of + * useful things in BAR0, which makes testing a non-zero BAR offset + * impossible. An "extended EDU" device is supported, which just + * presents a large chunk of memory as a second BAR resource: this + * allows non-zero BAR offsets to be tested. See below for a QEMU + * diff... + * + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This software may be used and distributed according to the terms of the + * GNU General Public License version 2. + */ + +/* +diff --git a/hw/misc/edu.c b/hw/misc/edu.c +index cece633e11..5f119e0642 100644 +--- a/hw/misc/edu.c ++++ b/hw/misc/edu.c +@@ -47,6 +47,7 @@ DECLARE_INSTANCE_CHECKER(EduState, EDU, + struct EduState { + PCIDevice pdev; + MemoryRegion mmio; ++ MemoryRegion ram; + + QemuThread thread; + QemuMutex thr_mutex; +@@ -386,7 +387,12 @@ static void pci_edu_realize(PCIDevice *pdev, Error **errp) + + memory_region_init_io(&edu->mmio, OBJECT(edu), &edu_mmio_ops, edu, + "edu-mmio", 1 * MiB); ++ memory_region_init_ram(&edu->ram, OBJECT(edu), "edu-ram", 64 * MiB, &error_fatal); + pci_register_bar(pdev, 0, PCI_BASE_ADDRESS_SPACE_MEMORY, &edu->mmio); ++ pci_register_bar(pdev, 1, ++ PCI_BASE_ADDRESS_SPACE_MEMORY | ++ PCI_BASE_ADDRESS_MEM_PREFETCH | ++ PCI_BASE_ADDRESS_MEM_TYPE_64, &edu->ram); + } + + static void pci_edu_uninit(PCIDevice *pdev) +*/ + +#include <errno.h> +#include <inttypes.h> +#include <fcntl.h> +#include <limits.h> +#include <linux/dma-buf.h> +#include <linux/vfio.h> +#include <setjmp.h> +#include <signal.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <sys/ioctl.h> +#include <sys/mman.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <unistd.h> + +#define ROUND_UP(x, to) (((x) + (to) - 1) & ~((to) - 1)) +#define MiB(x) ((x) * 1024ULL * 1024) + +#define EDU_REG_MAGIC 0x00 +#define EDU_MAGIC_VAL 0x010000edu +#define EDU_REG_INVERT 0x04 + +#define FAIL_IF(cond, msg...) \ + do { \ + if (cond) { \ + printf("\n\nFAIL:\t"); \ + printf(msg); \ + exit(1); \ + } \ + } while (0) + +static int vfio_setup(int groupnr, char *rid_str, + struct vfio_region_info *out_mappable_regions, + int nr_regions, int *out_nr_regions, int *out_vfio_cfd, + int *out_vfio_devfd) +{ + /* Create a new container, add group to it, open device, read + * resource, reset, etc. Based on the example code in + * Documentation/driver-api/vfio.rst + */ + + int container = open("/dev/vfio/vfio", O_RDWR); + + int r = ioctl(container, VFIO_GET_API_VERSION); + + if (r != VFIO_API_VERSION) { + /* Unknown API version */ + printf("-E- Unknown API ver %d\n", r); + return 1; + } + + if (ioctl(container, VFIO_CHECK_EXTENSION, VFIO_TYPE1_IOMMU) != 1) { + printf("-E- Doesn't support type 1\n"); + return 1; + } + + char devpath[PATH_MAX]; + + snprintf(devpath, PATH_MAX - 1, "/dev/vfio/%d", groupnr); + /* Open the group */ + int group = open(devpath, O_RDWR); + + if (group < 0) { + printf("-E- Can't open VFIO device (group %d)\n", groupnr); + return 1; + } + + /* Test the group is viable and available */ + struct vfio_group_status group_status = { .argsz = sizeof( + group_status) }; + + if (ioctl(group, VFIO_GROUP_GET_STATUS, &group_status)) { + perror("-E- Can't get group status"); + return 1; + } + + if (!(group_status.flags & VFIO_GROUP_FLAGS_VIABLE)) { + /* Group is not viable (ie, not all devices bound for vfio) */ + printf("-E- Group %d is not viable!\n", groupnr); + return 1; + } + + /* Add the group to the container */ + if (ioctl(group, VFIO_GROUP_SET_CONTAINER, &container)) { + perror("-E- Can't add group to container"); + return 1; + } + + /* Enable the IOMMU model we want */ + if (ioctl(container, VFIO_SET_IOMMU, VFIO_TYPE1_IOMMU)) { + perror("-E- Can't select T1"); + return 1; + } + + /* Get addition IOMMU info */ + struct vfio_iommu_type1_info iommu_info = { .argsz = sizeof( + iommu_info) }; + + if (ioctl(container, VFIO_IOMMU_GET_INFO, &iommu_info)) { + perror("-E- Can't get VFIO info"); + return 1; + } + + /* Get a file descriptor for the device */ + int device = ioctl(group, VFIO_GROUP_GET_DEVICE_FD, rid_str); + + if (device < 0) { + perror("-E- Can't get device fd"); + return 1; + } + close(group); + + /* Test and setup the device */ + struct vfio_device_info device_info = { .argsz = sizeof(device_info) }; + + if (ioctl(device, VFIO_DEVICE_GET_INFO, &device_info)) { + perror("-E- Can't get device info"); + return 1; + } + printf("-i- %d device regions, flags 0x%x\n", device_info.num_regions, + device_info.flags); + + /* Regions are BAR0-5 then ROM, config, VGA */ + int out_region = 0; + + for (int i = 0; i < device_info.num_regions; i++) { + struct vfio_region_info reg = { .argsz = sizeof(reg) }; + + reg.index = i; + + if (ioctl(device, VFIO_DEVICE_GET_REGION_INFO, &reg)) { + /* We expect EINVAL if there's no VGA region */ + printf("-W- Region %d: ERROR %d\n", i, errno); + } else { + printf("-i- Region %d: flags 0x%08x (%c%c%c), cap_offs %d, size 0x%llx, offs 0x%llx\n", + i, reg.flags, + (reg.flags & VFIO_REGION_INFO_FLAG_READ) ? 'R' : + '-', + (reg.flags & VFIO_REGION_INFO_FLAG_WRITE) ? 'W' : + '-', + (reg.flags & VFIO_REGION_INFO_FLAG_MMAP) ? 'M' : + '-', + reg.cap_offset, reg.size, reg.offset); + + if ((reg.flags & VFIO_REGION_INFO_FLAG_MMAP) && + (out_region < nr_regions)) + out_mappable_regions[out_region++] = reg; + } + } + *out_nr_regions = out_region; + +#ifdef THERE_ARE_NO_IRQS_YET + for (i = 0; i < device_info.num_irqs; i++) { + struct vfio_irq_info irq = { .argsz = sizeof(irq) }; + + irq.index = i; + + ioctl(device, VFIO_DEVICE_GET_IRQ_INFO, &irq); + + /* Setup IRQs... eventfds, VFIO_DEVICE_SET_IRQS */ + } +#endif + /* Gratuitous device reset and go... */ + if (ioctl(device, VFIO_DEVICE_RESET)) + perror("-W- Can't reset device (continuing)"); + + *out_vfio_cfd = container; + *out_vfio_devfd = device; + + return 0; +} + +static int vfio_feature_present(int dev_fd, uint32_t feature) +{ + struct vfio_device_feature probeftr = { + .argsz = sizeof(probeftr), + .flags = VFIO_DEVICE_FEATURE_PROBE | VFIO_DEVICE_FEATURE_GET | + feature, + }; + return ioctl(dev_fd, VFIO_DEVICE_FEATURE, &probeftr) == 0; +} + +static int vfio_create_dmabuf(int dev_fd, uint32_t region, uint64_t offset, + uint64_t length) +{ + uint64_t ftrbuf + [ROUND_UP(sizeof(struct vfio_device_feature) + + sizeof(struct vfio_device_feature_dma_buf) + + sizeof(struct vfio_region_dma_range), + 8) / + 8]; + + struct vfio_device_feature *f = (struct vfio_device_feature *)ftrbuf; + struct vfio_device_feature_dma_buf *db = + (struct vfio_device_feature_dma_buf *)f->data; + struct vfio_region_dma_range *range = + (struct vfio_region_dma_range *)db->dma_ranges; + + f->argsz = sizeof(ftrbuf); + f->flags = VFIO_DEVICE_FEATURE_GET | VFIO_DEVICE_FEATURE_DMA_BUF; + db->region_index = region; + db->open_flags = O_RDWR | O_CLOEXEC; + db->flags = 0; + db->nr_ranges = 1; + range->offset = offset; + range->length = length; + + return ioctl(dev_fd, VFIO_DEVICE_FEATURE, &ftrbuf); +} + +/* As above, but try multiple ranges in one dmabuf */ +static int vfio_create_dmabuf_dual(int dev_fd, uint32_t region, + uint64_t offset0, uint64_t length0, + uint64_t offset1, uint64_t length1) +{ + uint64_t ftrbuf + [ROUND_UP(sizeof(struct vfio_device_feature) + + sizeof(struct vfio_device_feature_dma_buf) + + (sizeof(struct vfio_region_dma_range) * 2), + 8) / + 8]; + + struct vfio_device_feature *f = (struct vfio_device_feature *)ftrbuf; + struct vfio_device_feature_dma_buf *db = + (struct vfio_device_feature_dma_buf *)f->data; + struct vfio_region_dma_range *range = + (struct vfio_region_dma_range *)db->dma_ranges; + + f->argsz = sizeof(ftrbuf); + f->flags = VFIO_DEVICE_FEATURE_GET | VFIO_DEVICE_FEATURE_DMA_BUF; + db->region_index = region; + db->open_flags = O_RDWR | O_CLOEXEC; + db->flags = 0; + db->nr_ranges = 2; + range[0].offset = offset0; + range[0].length = length0; + range[1].offset = offset1; + range[1].length = length1; + + return ioctl(dev_fd, VFIO_DEVICE_FEATURE, &ftrbuf); +} + +static volatile uint32_t *mmap_resource_aligned(size_t size, + unsigned long align, int fd, + unsigned long offset) +{ + void *v; + + if (align <= getpagesize()) { + v = mmap(0, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, + offset); + FAIL_IF(v == MAP_FAILED, + "Can't mmap fd %d (size 0x%lx, offset 0x%lx), %d\n", fd, + size, offset, errno); + } else { + size_t resv_size = size + align; + void *resv = + mmap(0, resv_size, 0, MAP_PRIVATE | MAP_ANON, -1, 0); + FAIL_IF(resv == MAP_FAILED, + "Can't mmap reservation, size 0x%lx, %d\n", resv_size, + errno); + + uintptr_t pos = ((uintptr_t)resv + (align - 1)) & ~(align - 1); + + v = mmap((void *)pos, size, PROT_READ | PROT_WRITE, + MAP_SHARED | MAP_FIXED, fd, offset); + FAIL_IF(v == MAP_FAILED, + "Can't mmap-fixed fd %d (size 0x%lx, offset 0x%lx), %d\n", + fd, size, offset, errno); + madvise((void *)v, size, MADV_HUGEPAGE); + + /* Tidy */ + if (pos > (uintptr_t)resv) + munmap(resv, pos - (uintptr_t)resv); + if (pos + size < (uintptr_t)resv + resv_size) + munmap((void *)pos + size, + (uintptr_t)resv + resv_size - (pos + size)); + } + + return (volatile uint32_t *)v; +} + +static volatile uint32_t *mmap_resource(size_t size, int fd, + unsigned long offset) +{ + return mmap_resource_aligned(size, getpagesize(), fd, offset); +} + +static void check_mmio(volatile uint32_t *base) +{ + static uint32_t magic = 0xdeadbeef; + uint32_t v; + + printf("-i- MMIO check: "); + + /* Trivial MMIO */ + v = base[EDU_REG_MAGIC / 4]; + FAIL_IF(v != EDU_MAGIC_VAL, + "Magic value %08x incorrect, BAR map bad?\n", v); + + base[EDU_REG_INVERT / 4] = magic; + v = base[EDU_REG_INVERT / 4]; + FAIL_IF(v != ~magic, "Inverterizer value %08x bad (should be %08x)\n", + v, ~magic); + printf("OK\n"); + + magic = (magic << 1) ^ (magic >> 1) ^ (magic << 7); +} + +static jmp_buf jmpbuf; + +static void sighandler(int sig) +{ + printf("*** Signal %d ***\n", sig); + siglongjmp(jmpbuf, sig); +} + +static void setup_signals(void) +{ + struct sigaction sa = { + .sa_handler = sighandler, + .sa_flags = 0, + }; + + sigaction(SIGBUS, &sa, NULL); +} + +static int vfio_dmabuf_test(int groupnr, char *rid_str) +{ + /* Only expecting one or two regions */ + struct vfio_region_info bar_region[2]; + int num_regions = 0; + int container_fd, dev_fd; + int r = vfio_setup(groupnr, rid_str, &bar_region[0], 2, &num_regions, + &container_fd, &dev_fd); + + FAIL_IF(r, "VFIO setup failed\n"); + FAIL_IF(!vfio_feature_present(dev_fd, VFIO_DEVICE_FEATURE_DMA_BUF), + "VFIO DMABUF support not available\n"); + + printf("-i- Container fd %d, device fd %d, and got DMA_BUF\n", + container_fd, dev_fd); + + setup_signals(); + + //////////////////////////////////////////////////////////////////////////////// + + /* Real basics: create DMABUF, and mmap it, and access MMIO through it. + * Do this for 2nd BAR if present, too (just plain memory). + */ + printf("\nTEST: Create DMABUF, map it\n"); + int bar_db_fd = vfio_create_dmabuf(dev_fd, /* region */ 0, + /* offset */ 0, bar_region[0].size); + FAIL_IF(bar_db_fd < 0, "Can't create DMABUF, %d\n", errno); + + volatile uint32_t *dbbar0 = + mmap_resource(bar_region[0].size, bar_db_fd, 0); + + printf("-i- Mapped DMABUF BAR0 at %p+0x%llx\n", dbbar0, + bar_region[0].size); + check_mmio(dbbar0); + + /* TEST: Map the traditional VFIO one _second_; it should still work. */ + printf("\nTEST: Map the regular VFIO BAR\n"); + volatile uint32_t *vfiobar = + mmap_resource(bar_region[0].size, dev_fd, bar_region[0].offset); + + printf("-i- Mapped VIRTIO BAR0 at %p+0x%llx\n", vfiobar, + bar_region[0].size); + check_mmio(vfiobar); + + /* Test plan: + * + * - Revoke the first DMABUF, check for fault + * - Check VFIO BAR access still works + * - Revoke first DMABUF fd again: -EBADFD + * - create new DMABUF for same (previously-revoked) region: accessible + * + * - Create overlapping DMABUFs: map success, maps alias OK + * - Create a second mapping of the second DMABUF, maps alias OK + * - Destroy one by revoking through a dup()ed fd: check mapping revoked + * - Check original is still accessible + * + * If we have a larger (>4K of accessible stuff!) second BAR resource: + * - Map it, create an overlapping alias with offset != 0 + * - Check alias/offset is sane + * + * Last: + * - close container_fd and dev_fd: check DMABUF mapping revoked + * - try revoking that dmabuf_fd: -ENODEV + */ + + printf("\nTEST: Revocation of first DMABUF\n"); + r = ioctl(bar_db_fd, DMA_BUF_IOCTL_REVOKE); + FAIL_IF(r != 0, "Can't revoke: %d\n", r); + + if (sigsetjmp(jmpbuf, 1) == 0) { + // Try an access: expect BOOM + check_mmio(dbbar0); + FAIL_IF(true, "Expecting fault after revoke!\n"); + } + printf("-i- Revoked OK\n"); + + printf("\nTEST: Access through VFIO-mapped region still works\n"); + if (sigsetjmp(jmpbuf, 1) == 0) + check_mmio(vfiobar); + else + FAIL_IF(true, "Expecting VFIO-mapped BAR to still work!\n"); + + printf("\nTEST: Double-revoke\n"); + r = ioctl(bar_db_fd, DMA_BUF_IOCTL_REVOKE); + FAIL_IF(r != -1 || errno != EBADFD, + "Expecting 2nd revoke to give EBADFD, got %d errno %d\n", r, + errno); + printf("-i- Correctly failed second revoke\n"); + + printf("\nTEST: Can't mmap() revoked DMABUF\n"); + void *dbfail = mmap(0, bar_region[1].size, PROT_READ | PROT_WRITE, + MAP_SHARED, bar_db_fd, 0); + FAIL_IF(dbfail != MAP_FAILED, "mmap() should fail\n"); + printf("-i- OK\n"); + + printf("\nTEST: Recreate new DMABUF for previously-revoked region\n"); + int bar_db_fd_2 = vfio_create_dmabuf( + dev_fd, /* region */ 0, /* offset */ 0, bar_region[0].size); + FAIL_IF(bar_db_fd_2 < 0, "Can't create DMABUF, %d\n", errno); + + volatile uint32_t *dbbar0_2 = + mmap_resource(bar_region[0].size, bar_db_fd_2, 0); + + printf("-i- Mapped 2nd DMABUF BAR0 at %p+0x%llx\n", dbbar0_2, + bar_region[0].size); + check_mmio(dbbar0_2); + + munmap((void *)dbbar0, bar_region[0].size); + close(bar_db_fd); + + printf("\nTEST: Create aliasing/overlapping DMABUF\n"); + int bar_db_fd_3 = vfio_create_dmabuf( + dev_fd, /* region */ 0, /* offset */ 0, bar_region[0].size); + FAIL_IF(bar_db_fd_3 < 0, "Can't create DMABUF, %d\n", errno); + + volatile uint32_t *dbbar0_3 = + mmap_resource(bar_region[0].size, bar_db_fd_3, 0); + + printf("-i- Mapped 3rd DMABUF BAR0 at %p+0x%llx\n", dbbar0_3, + bar_region[0].size); + check_mmio(dbbar0_3); + + /* Basic aliasing check: Write value through 2nd, read back through 3rd */ + uint32_t v; + + dbbar0_2[EDU_REG_INVERT / 4] = 0xfacecace; + v = dbbar0_3[EDU_REG_INVERT / 4]; + FAIL_IF(v != ~0xfacecace, + "Alias inverted MMIO value %08x bad (should be %08x)\n", v, + ~0xfacecace); + printf("-i- Aliasing DMABUF OK\n"); + + printf("\nTEST: Create a double-mapping of DMABUF\n"); + /* Create another mmap of the existing aliasing DMABUF fd */ + volatile uint32_t *dbbar0_3_2 = + mmap_resource(bar_region[0].size, bar_db_fd_3, 0); + + printf("-i- Mapped 3rd DMABUF BAR0 _again_ at %p+0x%llx\n", dbbar0_3_2, + bar_region[0].size); + /* Can we see the value we wrote before? */ + v = dbbar0_3_2[EDU_REG_INVERT / 4]; + FAIL_IF(v != ~0xfacecace, + "Alias alias inverted MMIO value %08x bad (should be %08x)\n", + v, ~0xfacecace); + check_mmio(dbbar0_3_2); + + printf("\nTEST: revoke aliasing DMABUF through dup()ed fd\n"); + int dup_dbfd3 = dup(bar_db_fd_3); + + r = ioctl(dup_dbfd3, DMA_BUF_IOCTL_REVOKE); + FAIL_IF(r != 0, "Can't revoke: %d\n", r); + + /* Both of the mmap()s made should now be gone */ + if (sigsetjmp(jmpbuf, 1) == 0) { + check_mmio(dbbar0_3); + FAIL_IF(true, "Expecting fault on 1st mmap after revoke!\n"); + } + + if (sigsetjmp(jmpbuf, 1) == 0) { + check_mmio(dbbar0_3_2); + FAIL_IF(true, "Expecting fault on 2nd mmap after revoke!\n"); + } + printf("-i- Both aliasing DMABUF mappings revoked OK\n"); + + close(dup_dbfd3); + close(bar_db_fd_3); + munmap((void *)dbbar0_3, bar_region[0].size); + munmap((void *)dbbar0_3_2, bar_region[0].size); + + /* And finally, although the aliasing DMABUF is gone, access + * through the original one should still work: + */ + if (sigsetjmp(jmpbuf, 1) == 0) + check_mmio(dbbar0_2); + else + FAIL_IF(true, + "Expecting original DMABUF mapping to still work!\n"); + printf("-i- Aliasing DMABUF removal OK, original still accessible\n"); + + /* If we're attached to a hacked/extended QEMU EDU device with + * a large memory region 1 then we can test things like + * offsets/aliasing. + */ + if (num_regions >= 2) { + printf("\nTEST: Second BAR: test overlapping+offset DMABUF\n"); + + printf("-i- Region 1 DMABUF: offset %llx, size %llx\n", + bar_region[1].offset, bar_region[1].size); + int bar1_db_fd = + vfio_create_dmabuf(dev_fd, 1, 0, bar_region[1].size); + + FAIL_IF(bar1_db_fd < 0, "Can't create DMABUF, %d\n", errno); + + volatile uint32_t *dbbar1 = mmap_resource_aligned( + bar_region[1].size, MiB(32), bar1_db_fd, 0); + printf("-i- Mapped DMABUF Region 1 at %p+0x%llx\n", dbbar1, + bar_region[1].size); + + /* Init with known values */ + for (unsigned long i = 0; i < (bar_region[1].size); + i += getpagesize()) + dbbar1[i / 4] = 0xca77face ^ i; + + v = dbbar1[0]; + FAIL_IF(v != 0xca77face, + "DB Region 1 read: Magic value %08x incorrect\n", v); + printf("-i- DB Region 1 read: Magic: 0x%08x\n", v); + + /* TEST: Overlap/aliasing; map same BAR with a range + * offset > 0. Also test disjoint/multi-range DMABUFs + * by creating a second range. This appears as one + * contiguous VA range mapped to a first BAR range + * (starting from range0_offset), then skipping a few + * physical pages, then a second range (starting at + * range1_offset). + */ + unsigned long range0_offset = getpagesize() * 3; + unsigned long range1_skip_pages = 5; + unsigned long range1_skip = getpagesize() * range1_skip_pages; + unsigned long range_size = + (bar_region[1].size - range0_offset - range1_skip) / 2; + unsigned long range1_offset = + range0_offset + range_size + range1_skip; + unsigned long map_size = range_size * 2; + + printf("\nTEST: Second BAR aliasing mapping, two ranges size 0x%lx:\n\t\t0x%lx-0x%lx, 0x%lx-0x%lx\n", + range_size, range0_offset, range0_offset + range_size, + range1_offset, range1_offset + range_size); + + int bar1_2_db_fd = vfio_create_dmabuf_dual( + dev_fd, 1, range0_offset, range_size, range1_offset, + range_size); + FAIL_IF(bar1_2_db_fd < 0, "Can't create DMABUF, %d\n", errno); + + volatile uint32_t *dbbar1_2 = + mmap_resource(map_size, bar1_2_db_fd, 0); + + printf("-i- Mapped DMABUF Region 1 alias at %p+0x%lx\n", + dbbar1_2, map_size); + FAIL_IF(dbbar1_2[0] != dbbar1[range0_offset / 4], + "slice2 value mismatch\n"); + + dbbar1[(range0_offset + 4) / 4] = 0xfacef00d; + /* Check we can see the value written above at +offset + * from offset 0 of this mapping (since the DMABUF + * itself is offsetted): + */ + v = dbbar1_2[4 / 4]; + FAIL_IF(v != 0xfacef00d, + "DB Region 1 alias read: Magic value %08x incorrect\n", + v); + printf("-i- DB Region 1 alias read: Magic 0x%08x, OK\n", v); + + /* Read back the known values across the two + * sub-ranges of the dbbar1_2 mapping, accounting for + * the physical pages skipped between them + */ + for (unsigned long i = 0; i < range_size; i += getpagesize()) { + unsigned long t = i + range0_offset; + uint32_t want = (0xca77face ^ t); + + v = dbbar1_2[i / 4]; + FAIL_IF(v != want, + "Expected %08x (got %08x) from range0 +%08lx (real %08lx)\n", + want, v, i, t); + } + for (unsigned long i = range_size; i < (range_size * 2); + i += getpagesize()) { + unsigned long t = i + range1_offset - range_size; + uint32_t want = (0xca77face ^ t); + + v = dbbar1_2[i / 4]; + FAIL_IF(v != want, + "Expected %08x (got %08x) from range1 +%08lx (real %08lx)\n", + want, v, i, t); + } + + printf("\nTEST: Third BAR aliasing mapping, testing mmap() non-zero offset:\n"); + + unsigned long smaller = range_size - 0x1000; + volatile uint32_t *dbbar1_3 = mmap_resource_aligned( + smaller, MiB(32), bar1_2_db_fd, range_size); + printf("-i- Mapped DMABUF Region 1 range 1 alias at %p+0x%lx\n", + dbbar1_3, smaller); + + for (unsigned long i = 0; i < smaller; i += getpagesize()) { + unsigned long t = i + range1_offset; + uint32_t want = (0xca77face ^ t); + + v = dbbar1_3[i / 4]; + FAIL_IF(v != want, + "Expected %08x (got %08x) from 3rd range1 +%08lx (real %08lx)\n", + want, v, i, t); + } + printf("-i- mmap offset OK\n"); + + /* TODO: If we can observe hugepages (mechanically, + * rather than human reading debug), we can test + * interesting alignment cases for the PFN search: + * + * - Deny hugepages at start/end of an mmap() that + * starts/ends at non-HP-aligned addresses + * (e.g. first pages are small, middle is fully + * aligned in VA and PFN so 2M, and buffer finishes + * before 2M boundary, so last pages are small). + * + * - Everything aligned nicely except the mmap() size + * is <2MB, so hugepage denied due to straddling + * end. + * + * - Buffer offsets into BAR not aligned, so no huge + * mappings even if mmap() is perfectly aligned. + */ + + /* Check that access after DMABUF fd close still works + * (VMA still holds refcount, obvs!) + */ + close(bar1_2_db_fd); + if (sigsetjmp(jmpbuf, 1) == 0) + v = dbbar1_2[0x4 / 4]; + else + FAIL_IF(true, + "Expecting original DMABUF mapping to still work!\n"); + printf("-i- DB Region 1 alias read 2: Magic 0x%08x, OK\n", v); + printf("-i- Offset check OK\n"); + } + + printf("\nTEST: Shutdown: close VFIO container/device fds, check DMABUF gone\n"); + + /* Closing all uses of dev_fd (including the VFIO BAR mmap()!) + * will revoke the DMABUF; even though the DMABUF fd might + * remain open, the mapping itself is zapped. Start with a + * plain close (before unmapping the VFIO BAR mapping): + */ + close(dev_fd); + close(container_fd); + printf("-i- VFIO fds closed\n"); + + if (sigsetjmp(jmpbuf, 1) == 0) + check_mmio(dbbar0_2); + else + FAIL_IF(true, + "Expecting DMABUF mapping to still work if VFIO mapping still live!\n"); + + munmap((void *)vfiobar, bar_region[0].size); + printf("-i- VFIO BAR unmapped\n"); + + /* The final reference via VFIO should now be gone, and the + * DMABUF should now be destroyed. The mapping of it should + * be inaccessible: + */ + if (sigsetjmp(jmpbuf, 1) == 0) { + check_mmio(dbbar0_2); + FAIL_IF(true, + "Expecting DMABUF mapping to fault after VFIO fd shutdown!\n"); + } + printf("-i- DMABUF mappings inaccessible\n"); + + /* Ensure we can't mmap() DMABUF for closed device */ + void *dbfail2 = mmap(0, bar_region[1].size, PROT_READ | PROT_WRITE, + MAP_SHARED, bar_db_fd_2, 0); + FAIL_IF(dbfail2 != MAP_FAILED, "mmap() should fail\n"); + printf("-i- Can't mmap DMABUF for closed device, OK\n"); + + /* The DMABUF fd is still open though; try a revoke on it: */ + r = ioctl(bar_db_fd_2, DMA_BUF_IOCTL_REVOKE); + FAIL_IF(r != -1 || errno != ENODEV, + "Expecting revoke after shutdown to give ENODEV, got %d errno %d\n", + r, errno); + printf("-i- Correctly failed final revoke\n"); + + munmap((void *)dbbar0_2, bar_region[0].size); + close(bar_db_fd_2); + + printf("\nPASS\n"); + + return 0; +} + +static void usage(char *me) +{ + printf("Usage:\t%s -g <group_number> -r <RID/BDF>\n" + "\n" + "\t\tGroup is found via device path, e.g. cat /sys/bus/pci/devices/0000:03:1d.0/iommu_group\n" + "\t\tRID is of the form 0000:03:1d.0\n" + "\n", + me); +} + +int main(int argc, char *argv[]) +{ + /* Get args: IOMMU group and BDF/path */ + int groupnr = -1; + char *rid_str = NULL; + int arg; + + while ((arg = getopt(argc, argv, "g:r:h")) != -1) { + switch (arg) { + case 'g': + groupnr = atoi(optarg); + break; + + case 'r': + rid_str = strdup(optarg); + break; + case 'h': + default: + usage(argv[0]); + return 1; + } + } + + if (rid_str == NULL || groupnr == -1) { + usage(argv[0]); + return 1; + } + + printf("-i- Using group number %d, RID '%s'\n", groupnr, rid_str); + + return vfio_dmabuf_test(groupnr, rid_str); +} -- 2.47.3
{ "author": "Matt Evans <mattev@meta.com>", "date": "Thu, 26 Feb 2026 12:22:03 -0800", "is_openbsd": false, "thread_id": "a006b938-cd53-4c56-8131-30f557919ec6@amd.com.mbox.gz" }
lkml_critique
lkml
Hi all, There were various suggestions in the September 2025 thread "[TECH TOPIC] vfio, iommufd: Enabling user space drivers to vend more granular access to client processes" [0], and LPC discussions, around improving the situation for multi-process userspace driver designs. This RFC series implements some of these ideas. Background: Multi-process USDs ============================== The userspace driver scenario discussed in that thread involves a primary process driving a PCIe function through VFIO/iommufd, which manages the function-wide ownership/lifecycle. The function is designed to provide multiple distinct programming interfaces (for example, several independent MMIO register frames in one function), and the primary process delegates control of these interfaces to multiple independent client processes (which do the actual work). This scenario clearly relies on a HW design that provides appropriate isolation between the programming interfaces. The two key needs are: 1. Mechanisms to safely delegate a subset of the device MMIO resources to a client process without over-sharing wider access (or influence over whole-device activities, such as reset). 2. Mechanisms to allow a client process to do its own iommufd management w.r.t. its address space, in a way that's isolated from DMA relating to other clients. mmap() of VFIO DMABUFs ====================== First, this RFC addresses #1, implementing the proposals in [0] to add mmap() support to the existing VFIO DMABUF exporter. This enables a userspace driver to define DMABUF ranges corresponding to sub-ranges of a BAR, and grant a given client (via a shared fd) the capability to access (only) those sub-ranges. The VFIO device fds would be kept private to the primary process. All the client can do with that fd is map (or iomap via iommufd) that specific subset of resources, and the impact of bugs/malice is contained. (We'll follow up on #2 separately, as a related-but-distinct problem. PASIDs are one way to achieve per-client isolation of DMA; another could be sharing of a single IOVA space via 'constrained' iommufds.) Revocation/reclaim ================== That's useful as-is, but then the lifetime of access granted to a client needs to be managed well. For example, a protocol between the primary process and the client can indicate when the client is done, and when it's safe to reuse the resources elsewhere. Resources could be released cooperatively, but it's much more robust to enable the driver to make the resources guaranteed-inaccessible when it chooses, so that it can re-assign them to other uses in future. So, second, I've suggested a PoC/example mechanism for reclaiming ranges shared with clients: a new DMABUF ioctl, DMA_BUF_IOCTL_REVOKE, is routed to a DMABUF exporter callback. The VFIO DMABUF exporter's implementation permanently revokes a DMABUF (notifying importers, and zapping PTEs for any mappings). This makes the DMABUF defunct and any client (or third party the client has shared the buffer onto!) cannot be used to access the BAR ranges, whether via DMABUF import or mmap(). A primary driver process would do this operation when the client's tenure ends to reclaim "loaned-out" MMIO interfaces, at which point the interfaces could be safely re-used. This ioctl is one of several possible approaches to achieve buffer revocation, but I wanted to demonstrate something here as it's an important part of the buffer lifecycle in this driver scenario. An alternative implementation could be some VFIO-specific operation to search for a DMABUF (by address?) and kill it, but if the server keeps hold of the DMABUF fd that's already a clean way to locate it later. BAR mapping access attributes ============================= Third, inspired by Alex [Mastro] and Jason's comments in [0], and Mahmoud's work in [1] with the goal of controlling CPU access attributes for VFIO BAR mappings (e.g. WC) I noticed that once we can mmap() VFIO DMABUFs representing BAR sub-spans, it's straightforward to decorate them with access attributes for the VMA. I've proposed reserving a field in struct vfio_device_feature_dma_buf's flags to specify an attribute for its ranges. Although that keeps the (UAPI) struct unchanged, it means all ranges in a DMABUF share the same attribute. I feel a single attribute-to-mmap() relation is logical/reasonable. An application can also create multiple DMABUFs to describe any BAR layout and mix of attributes. Tests ===== I've included an [RFC ONLY] userspace test program which I am _not_ proposing to merge, but am sharing for context. It illustrates & tests various map/revoke cases, but doesn't use the existing VFIO selftests and relies on a (tweaked) QEMU EDU function. I'm working on integrating the scenarios into the existing VFIO selftests. This code has been tested in mapping DMABUFs of single/multiple ranges, aliasing mmap()s, aliasing ranges across DMABUFs, vm_pgoff > 0, revocation, shutdown/cleanup scenarios, and hugepage mappings seem to work correctly. I've lightly tested WC mappings also (by observing resulting PTEs as having the correct attributes...). (The first two commits are a couple of tiny bugfixes which I can send separately, should reviewers prefer.) This series is based on v6.19 but I expect to rebase, at least onto Leon's recent work [2] ("vfio: Wait for dma-buf invalidation to complete"). What are people's thoughts? I'll respin to de-RFC and capture comments, if we think this approach is appropriate. Thanks, Matt References: [0]: https://lore.kernel.org/linux-iommu/20250918214425.2677057-1-amastro@fb.com/ [1]: https://lore.kernel.org/all/20250804104012.87915-1-mngyadam@amazon.de/ [2]: https://lore.kernel.org/linux-iommu/20260205-nocturnal-poetic-chamois-f566ad@houat/T/#m310cd07011e3a1461b6fda45e3f9b886ba76571a Matt Evans (7): vfio/pci: Ensure VFIO barmap is set up before creating a DMABUF vfio/pci: Clean up DMABUFs before disabling function vfio/pci: Support mmap() of a DMABUF dma-buf: uapi: Mechanism to revoke DMABUFs via ioctl() vfio/pci: Permanently revoke a DMABUF on request vfio/pci: Add mmap() attributes to DMABUF feature [RFC ONLY] selftests: vfio: Add standalone vfio_dmabuf_mmap_test drivers/dma-buf/dma-buf.c | 5 + drivers/vfio/pci/vfio_pci_core.c | 4 +- drivers/vfio/pci/vfio_pci_dmabuf.c | 300 ++++++- include/linux/dma-buf.h | 22 + include/uapi/linux/dma-buf.h | 1 + include/uapi/linux/vfio.h | 12 +- tools/testing/selftests/vfio/Makefile | 1 + .../vfio/standalone/vfio_dmabuf_mmap_test.c | 822 ++++++++++++++++++ 8 files changed, 1153 insertions(+), 14 deletions(-) create mode 100644 tools/testing/selftests/vfio/standalone/vfio_dmabuf_mmap_test.c -- 2.47.3
null
null
null
[RFC PATCH 0/7] vfio/pci: Add mmap() for DMABUFs
Add a new dma-buf ioctl() op, DMA_BUF_IOCTL_REVOKE, connected to a new (optional) dma_buf_ops callback, revoke(). An exporter receiving this will _permanently_ revoke the DMABUF, meaning it can no longer be mapped/attached/mmap()ed. It also guarantees that existing importers have been detached (e.g. via move_notify) and all mappings made inaccessible. This is useful for lifecycle management in scenarios where a process has created a DMABUF representing a resource, then delegated it to a client process; access to the resource is revoked when the client is deemed "done", and the resource can be safely re-used elsewhere. Signed-off-by: Matt Evans <mattev@meta.com> --- drivers/dma-buf/dma-buf.c | 5 +++++ include/linux/dma-buf.h | 22 ++++++++++++++++++++++ include/uapi/linux/dma-buf.h | 1 + 3 files changed, 28 insertions(+) diff --git a/drivers/dma-buf/dma-buf.c b/drivers/dma-buf/dma-buf.c index edaa9e4ee4ae..b9b315317f2d 100644 --- a/drivers/dma-buf/dma-buf.c +++ b/drivers/dma-buf/dma-buf.c @@ -561,6 +561,11 @@ static long dma_buf_ioctl(struct file *file, case DMA_BUF_IOCTL_IMPORT_SYNC_FILE: return dma_buf_import_sync_file(dmabuf, (const void __user *)arg); #endif + case DMA_BUF_IOCTL_REVOKE: + if (dmabuf->ops->revoke) + return dmabuf->ops->revoke(dmabuf); + else + return -EINVAL; default: return -ENOTTY; diff --git a/include/linux/dma-buf.h b/include/linux/dma-buf.h index 0bc492090237..a68c9ad7aebd 100644 --- a/include/linux/dma-buf.h +++ b/include/linux/dma-buf.h @@ -277,6 +277,28 @@ struct dma_buf_ops { int (*vmap)(struct dma_buf *dmabuf, struct iosys_map *map); void (*vunmap)(struct dma_buf *dmabuf, struct iosys_map *map); + + /** + * @revoke: + * + * This callback is invoked from a userspace + * DMA_BUF_IOCTL_REVOKE operation, and requests that access to + * the buffer is immediately and permanently revoked. On + * successful return, the buffer is not accessible through any + * mmap() or dma-buf import. The request fails if the buffer + * is pinned; otherwise, the exporter marks the buffer as + * inaccessible and uses the move_notify callback to inform + * importers of the change. The buffer is permanently + * disabled, and the exporter must refuse all map, mmap, + * attach, etc. requests. + * + * Returns: + * + * 0 on success, or a negative error code on failure: + * -ENODEV if the associated device no longer exists/is closed. + * -EBADFD if the buffer has already been revoked. + */ + int (*revoke)(struct dma_buf *dmabuf); }; /** diff --git a/include/uapi/linux/dma-buf.h b/include/uapi/linux/dma-buf.h index 5a6fda66d9ad..84bf2dd2d0f3 100644 --- a/include/uapi/linux/dma-buf.h +++ b/include/uapi/linux/dma-buf.h @@ -178,5 +178,6 @@ struct dma_buf_import_sync_file { #define DMA_BUF_SET_NAME_B _IOW(DMA_BUF_BASE, 1, __u64) #define DMA_BUF_IOCTL_EXPORT_SYNC_FILE _IOWR(DMA_BUF_BASE, 2, struct dma_buf_export_sync_file) #define DMA_BUF_IOCTL_IMPORT_SYNC_FILE _IOW(DMA_BUF_BASE, 3, struct dma_buf_import_sync_file) +#define DMA_BUF_IOCTL_REVOKE _IO(DMA_BUF_BASE, 4) #endif -- 2.47.3
{ "author": "Matt Evans <mattev@meta.com>", "date": "Thu, 26 Feb 2026 12:22:00 -0800", "is_openbsd": false, "thread_id": "a006b938-cd53-4c56-8131-30f557919ec6@amd.com.mbox.gz" }
lkml_critique
lkml
Hi all, There were various suggestions in the September 2025 thread "[TECH TOPIC] vfio, iommufd: Enabling user space drivers to vend more granular access to client processes" [0], and LPC discussions, around improving the situation for multi-process userspace driver designs. This RFC series implements some of these ideas. Background: Multi-process USDs ============================== The userspace driver scenario discussed in that thread involves a primary process driving a PCIe function through VFIO/iommufd, which manages the function-wide ownership/lifecycle. The function is designed to provide multiple distinct programming interfaces (for example, several independent MMIO register frames in one function), and the primary process delegates control of these interfaces to multiple independent client processes (which do the actual work). This scenario clearly relies on a HW design that provides appropriate isolation between the programming interfaces. The two key needs are: 1. Mechanisms to safely delegate a subset of the device MMIO resources to a client process without over-sharing wider access (or influence over whole-device activities, such as reset). 2. Mechanisms to allow a client process to do its own iommufd management w.r.t. its address space, in a way that's isolated from DMA relating to other clients. mmap() of VFIO DMABUFs ====================== First, this RFC addresses #1, implementing the proposals in [0] to add mmap() support to the existing VFIO DMABUF exporter. This enables a userspace driver to define DMABUF ranges corresponding to sub-ranges of a BAR, and grant a given client (via a shared fd) the capability to access (only) those sub-ranges. The VFIO device fds would be kept private to the primary process. All the client can do with that fd is map (or iomap via iommufd) that specific subset of resources, and the impact of bugs/malice is contained. (We'll follow up on #2 separately, as a related-but-distinct problem. PASIDs are one way to achieve per-client isolation of DMA; another could be sharing of a single IOVA space via 'constrained' iommufds.) Revocation/reclaim ================== That's useful as-is, but then the lifetime of access granted to a client needs to be managed well. For example, a protocol between the primary process and the client can indicate when the client is done, and when it's safe to reuse the resources elsewhere. Resources could be released cooperatively, but it's much more robust to enable the driver to make the resources guaranteed-inaccessible when it chooses, so that it can re-assign them to other uses in future. So, second, I've suggested a PoC/example mechanism for reclaiming ranges shared with clients: a new DMABUF ioctl, DMA_BUF_IOCTL_REVOKE, is routed to a DMABUF exporter callback. The VFIO DMABUF exporter's implementation permanently revokes a DMABUF (notifying importers, and zapping PTEs for any mappings). This makes the DMABUF defunct and any client (or third party the client has shared the buffer onto!) cannot be used to access the BAR ranges, whether via DMABUF import or mmap(). A primary driver process would do this operation when the client's tenure ends to reclaim "loaned-out" MMIO interfaces, at which point the interfaces could be safely re-used. This ioctl is one of several possible approaches to achieve buffer revocation, but I wanted to demonstrate something here as it's an important part of the buffer lifecycle in this driver scenario. An alternative implementation could be some VFIO-specific operation to search for a DMABUF (by address?) and kill it, but if the server keeps hold of the DMABUF fd that's already a clean way to locate it later. BAR mapping access attributes ============================= Third, inspired by Alex [Mastro] and Jason's comments in [0], and Mahmoud's work in [1] with the goal of controlling CPU access attributes for VFIO BAR mappings (e.g. WC) I noticed that once we can mmap() VFIO DMABUFs representing BAR sub-spans, it's straightforward to decorate them with access attributes for the VMA. I've proposed reserving a field in struct vfio_device_feature_dma_buf's flags to specify an attribute for its ranges. Although that keeps the (UAPI) struct unchanged, it means all ranges in a DMABUF share the same attribute. I feel a single attribute-to-mmap() relation is logical/reasonable. An application can also create multiple DMABUFs to describe any BAR layout and mix of attributes. Tests ===== I've included an [RFC ONLY] userspace test program which I am _not_ proposing to merge, but am sharing for context. It illustrates & tests various map/revoke cases, but doesn't use the existing VFIO selftests and relies on a (tweaked) QEMU EDU function. I'm working on integrating the scenarios into the existing VFIO selftests. This code has been tested in mapping DMABUFs of single/multiple ranges, aliasing mmap()s, aliasing ranges across DMABUFs, vm_pgoff > 0, revocation, shutdown/cleanup scenarios, and hugepage mappings seem to work correctly. I've lightly tested WC mappings also (by observing resulting PTEs as having the correct attributes...). (The first two commits are a couple of tiny bugfixes which I can send separately, should reviewers prefer.) This series is based on v6.19 but I expect to rebase, at least onto Leon's recent work [2] ("vfio: Wait for dma-buf invalidation to complete"). What are people's thoughts? I'll respin to de-RFC and capture comments, if we think this approach is appropriate. Thanks, Matt References: [0]: https://lore.kernel.org/linux-iommu/20250918214425.2677057-1-amastro@fb.com/ [1]: https://lore.kernel.org/all/20250804104012.87915-1-mngyadam@amazon.de/ [2]: https://lore.kernel.org/linux-iommu/20260205-nocturnal-poetic-chamois-f566ad@houat/T/#m310cd07011e3a1461b6fda45e3f9b886ba76571a Matt Evans (7): vfio/pci: Ensure VFIO barmap is set up before creating a DMABUF vfio/pci: Clean up DMABUFs before disabling function vfio/pci: Support mmap() of a DMABUF dma-buf: uapi: Mechanism to revoke DMABUFs via ioctl() vfio/pci: Permanently revoke a DMABUF on request vfio/pci: Add mmap() attributes to DMABUF feature [RFC ONLY] selftests: vfio: Add standalone vfio_dmabuf_mmap_test drivers/dma-buf/dma-buf.c | 5 + drivers/vfio/pci/vfio_pci_core.c | 4 +- drivers/vfio/pci/vfio_pci_dmabuf.c | 300 ++++++- include/linux/dma-buf.h | 22 + include/uapi/linux/dma-buf.h | 1 + include/uapi/linux/vfio.h | 12 +- tools/testing/selftests/vfio/Makefile | 1 + .../vfio/standalone/vfio_dmabuf_mmap_test.c | 822 ++++++++++++++++++ 8 files changed, 1153 insertions(+), 14 deletions(-) create mode 100644 tools/testing/selftests/vfio/standalone/vfio_dmabuf_mmap_test.c -- 2.47.3
null
null
null
[RFC PATCH 0/7] vfio/pci: Add mmap() for DMABUFs
On 2/26/26 21:22, Matt Evans wrote: Well that means revoking from the importer side. That absolutely doesn't make sense to me. Why would you do that? Regards, Christian.
{ "author": "=?UTF-8?Q?Christian_K=C3=B6nig?= <christian.koenig@amd.com>", "date": "Fri, 27 Feb 2026 11:05:24 +0100", "is_openbsd": false, "thread_id": "a006b938-cd53-4c56-8131-30f557919ec6@amd.com.mbox.gz" }
lkml_critique
lkml
Hi all, There were various suggestions in the September 2025 thread "[TECH TOPIC] vfio, iommufd: Enabling user space drivers to vend more granular access to client processes" [0], and LPC discussions, around improving the situation for multi-process userspace driver designs. This RFC series implements some of these ideas. Background: Multi-process USDs ============================== The userspace driver scenario discussed in that thread involves a primary process driving a PCIe function through VFIO/iommufd, which manages the function-wide ownership/lifecycle. The function is designed to provide multiple distinct programming interfaces (for example, several independent MMIO register frames in one function), and the primary process delegates control of these interfaces to multiple independent client processes (which do the actual work). This scenario clearly relies on a HW design that provides appropriate isolation between the programming interfaces. The two key needs are: 1. Mechanisms to safely delegate a subset of the device MMIO resources to a client process without over-sharing wider access (or influence over whole-device activities, such as reset). 2. Mechanisms to allow a client process to do its own iommufd management w.r.t. its address space, in a way that's isolated from DMA relating to other clients. mmap() of VFIO DMABUFs ====================== First, this RFC addresses #1, implementing the proposals in [0] to add mmap() support to the existing VFIO DMABUF exporter. This enables a userspace driver to define DMABUF ranges corresponding to sub-ranges of a BAR, and grant a given client (via a shared fd) the capability to access (only) those sub-ranges. The VFIO device fds would be kept private to the primary process. All the client can do with that fd is map (or iomap via iommufd) that specific subset of resources, and the impact of bugs/malice is contained. (We'll follow up on #2 separately, as a related-but-distinct problem. PASIDs are one way to achieve per-client isolation of DMA; another could be sharing of a single IOVA space via 'constrained' iommufds.) Revocation/reclaim ================== That's useful as-is, but then the lifetime of access granted to a client needs to be managed well. For example, a protocol between the primary process and the client can indicate when the client is done, and when it's safe to reuse the resources elsewhere. Resources could be released cooperatively, but it's much more robust to enable the driver to make the resources guaranteed-inaccessible when it chooses, so that it can re-assign them to other uses in future. So, second, I've suggested a PoC/example mechanism for reclaiming ranges shared with clients: a new DMABUF ioctl, DMA_BUF_IOCTL_REVOKE, is routed to a DMABUF exporter callback. The VFIO DMABUF exporter's implementation permanently revokes a DMABUF (notifying importers, and zapping PTEs for any mappings). This makes the DMABUF defunct and any client (or third party the client has shared the buffer onto!) cannot be used to access the BAR ranges, whether via DMABUF import or mmap(). A primary driver process would do this operation when the client's tenure ends to reclaim "loaned-out" MMIO interfaces, at which point the interfaces could be safely re-used. This ioctl is one of several possible approaches to achieve buffer revocation, but I wanted to demonstrate something here as it's an important part of the buffer lifecycle in this driver scenario. An alternative implementation could be some VFIO-specific operation to search for a DMABUF (by address?) and kill it, but if the server keeps hold of the DMABUF fd that's already a clean way to locate it later. BAR mapping access attributes ============================= Third, inspired by Alex [Mastro] and Jason's comments in [0], and Mahmoud's work in [1] with the goal of controlling CPU access attributes for VFIO BAR mappings (e.g. WC) I noticed that once we can mmap() VFIO DMABUFs representing BAR sub-spans, it's straightforward to decorate them with access attributes for the VMA. I've proposed reserving a field in struct vfio_device_feature_dma_buf's flags to specify an attribute for its ranges. Although that keeps the (UAPI) struct unchanged, it means all ranges in a DMABUF share the same attribute. I feel a single attribute-to-mmap() relation is logical/reasonable. An application can also create multiple DMABUFs to describe any BAR layout and mix of attributes. Tests ===== I've included an [RFC ONLY] userspace test program which I am _not_ proposing to merge, but am sharing for context. It illustrates & tests various map/revoke cases, but doesn't use the existing VFIO selftests and relies on a (tweaked) QEMU EDU function. I'm working on integrating the scenarios into the existing VFIO selftests. This code has been tested in mapping DMABUFs of single/multiple ranges, aliasing mmap()s, aliasing ranges across DMABUFs, vm_pgoff > 0, revocation, shutdown/cleanup scenarios, and hugepage mappings seem to work correctly. I've lightly tested WC mappings also (by observing resulting PTEs as having the correct attributes...). (The first two commits are a couple of tiny bugfixes which I can send separately, should reviewers prefer.) This series is based on v6.19 but I expect to rebase, at least onto Leon's recent work [2] ("vfio: Wait for dma-buf invalidation to complete"). What are people's thoughts? I'll respin to de-RFC and capture comments, if we think this approach is appropriate. Thanks, Matt References: [0]: https://lore.kernel.org/linux-iommu/20250918214425.2677057-1-amastro@fb.com/ [1]: https://lore.kernel.org/all/20250804104012.87915-1-mngyadam@amazon.de/ [2]: https://lore.kernel.org/linux-iommu/20260205-nocturnal-poetic-chamois-f566ad@houat/T/#m310cd07011e3a1461b6fda45e3f9b886ba76571a Matt Evans (7): vfio/pci: Ensure VFIO barmap is set up before creating a DMABUF vfio/pci: Clean up DMABUFs before disabling function vfio/pci: Support mmap() of a DMABUF dma-buf: uapi: Mechanism to revoke DMABUFs via ioctl() vfio/pci: Permanently revoke a DMABUF on request vfio/pci: Add mmap() attributes to DMABUF feature [RFC ONLY] selftests: vfio: Add standalone vfio_dmabuf_mmap_test drivers/dma-buf/dma-buf.c | 5 + drivers/vfio/pci/vfio_pci_core.c | 4 +- drivers/vfio/pci/vfio_pci_dmabuf.c | 300 ++++++- include/linux/dma-buf.h | 22 + include/uapi/linux/dma-buf.h | 1 + include/uapi/linux/vfio.h | 12 +- tools/testing/selftests/vfio/Makefile | 1 + .../vfio/standalone/vfio_dmabuf_mmap_test.c | 822 ++++++++++++++++++ 8 files changed, 1153 insertions(+), 14 deletions(-) create mode 100644 tools/testing/selftests/vfio/standalone/vfio_dmabuf_mmap_test.c -- 2.47.3
null
null
null
[RFC PATCH 0/7] vfio/pci: Add mmap() for DMABUFs
On 2/26/26 21:21, Matt Evans wrote: In general sounds like a good idea but this approach here doesn't looks good at all. Especially how you call unmap_mapping_range() from your DMA-buf cleanup path looks extremely questionable. ... Let's start with this here, it just looks horrible over complicated. When a DMA-buf just represents a linear piece of BAR which is map-able through the VFIO FD anyway then the right approach is to just re-direct the mapping to this VFIO FD. Roughly something like this here should do it: vma->vm_pgoff += offset_which_your_dma_buf_represents; vma_set_file(vma, core_dev->file); vfio_pci_core_mmap(core_dev, vma); It can be that you want additional checks (e.g. if the DMA-buf is revoked) in which case you would need to override the vma->vm_ops, but then just do the access checks and call the vfio_pci_mmap_ops to get the actually page fault handling done. When you need to use unmap_mapping_range() then you usually share the address space object between the file descriptor exporting the DMA-buf and the DMA-buf fd itself. Otherwise functions like vfio_pci_zap_bars() doesn't work correctly any more and that usually creates a huge bunch of problems. Regards, Christian.
{ "author": "=?UTF-8?Q?Christian_K=C3=B6nig?= <christian.koenig@amd.com>", "date": "Fri, 27 Feb 2026 11:09:31 +0100", "is_openbsd": false, "thread_id": "a006b938-cd53-4c56-8131-30f557919ec6@amd.com.mbox.gz" }
lkml_critique
lkml
Hi all, There were various suggestions in the September 2025 thread "[TECH TOPIC] vfio, iommufd: Enabling user space drivers to vend more granular access to client processes" [0], and LPC discussions, around improving the situation for multi-process userspace driver designs. This RFC series implements some of these ideas. Background: Multi-process USDs ============================== The userspace driver scenario discussed in that thread involves a primary process driving a PCIe function through VFIO/iommufd, which manages the function-wide ownership/lifecycle. The function is designed to provide multiple distinct programming interfaces (for example, several independent MMIO register frames in one function), and the primary process delegates control of these interfaces to multiple independent client processes (which do the actual work). This scenario clearly relies on a HW design that provides appropriate isolation between the programming interfaces. The two key needs are: 1. Mechanisms to safely delegate a subset of the device MMIO resources to a client process without over-sharing wider access (or influence over whole-device activities, such as reset). 2. Mechanisms to allow a client process to do its own iommufd management w.r.t. its address space, in a way that's isolated from DMA relating to other clients. mmap() of VFIO DMABUFs ====================== First, this RFC addresses #1, implementing the proposals in [0] to add mmap() support to the existing VFIO DMABUF exporter. This enables a userspace driver to define DMABUF ranges corresponding to sub-ranges of a BAR, and grant a given client (via a shared fd) the capability to access (only) those sub-ranges. The VFIO device fds would be kept private to the primary process. All the client can do with that fd is map (or iomap via iommufd) that specific subset of resources, and the impact of bugs/malice is contained. (We'll follow up on #2 separately, as a related-but-distinct problem. PASIDs are one way to achieve per-client isolation of DMA; another could be sharing of a single IOVA space via 'constrained' iommufds.) Revocation/reclaim ================== That's useful as-is, but then the lifetime of access granted to a client needs to be managed well. For example, a protocol between the primary process and the client can indicate when the client is done, and when it's safe to reuse the resources elsewhere. Resources could be released cooperatively, but it's much more robust to enable the driver to make the resources guaranteed-inaccessible when it chooses, so that it can re-assign them to other uses in future. So, second, I've suggested a PoC/example mechanism for reclaiming ranges shared with clients: a new DMABUF ioctl, DMA_BUF_IOCTL_REVOKE, is routed to a DMABUF exporter callback. The VFIO DMABUF exporter's implementation permanently revokes a DMABUF (notifying importers, and zapping PTEs for any mappings). This makes the DMABUF defunct and any client (or third party the client has shared the buffer onto!) cannot be used to access the BAR ranges, whether via DMABUF import or mmap(). A primary driver process would do this operation when the client's tenure ends to reclaim "loaned-out" MMIO interfaces, at which point the interfaces could be safely re-used. This ioctl is one of several possible approaches to achieve buffer revocation, but I wanted to demonstrate something here as it's an important part of the buffer lifecycle in this driver scenario. An alternative implementation could be some VFIO-specific operation to search for a DMABUF (by address?) and kill it, but if the server keeps hold of the DMABUF fd that's already a clean way to locate it later. BAR mapping access attributes ============================= Third, inspired by Alex [Mastro] and Jason's comments in [0], and Mahmoud's work in [1] with the goal of controlling CPU access attributes for VFIO BAR mappings (e.g. WC) I noticed that once we can mmap() VFIO DMABUFs representing BAR sub-spans, it's straightforward to decorate them with access attributes for the VMA. I've proposed reserving a field in struct vfio_device_feature_dma_buf's flags to specify an attribute for its ranges. Although that keeps the (UAPI) struct unchanged, it means all ranges in a DMABUF share the same attribute. I feel a single attribute-to-mmap() relation is logical/reasonable. An application can also create multiple DMABUFs to describe any BAR layout and mix of attributes. Tests ===== I've included an [RFC ONLY] userspace test program which I am _not_ proposing to merge, but am sharing for context. It illustrates & tests various map/revoke cases, but doesn't use the existing VFIO selftests and relies on a (tweaked) QEMU EDU function. I'm working on integrating the scenarios into the existing VFIO selftests. This code has been tested in mapping DMABUFs of single/multiple ranges, aliasing mmap()s, aliasing ranges across DMABUFs, vm_pgoff > 0, revocation, shutdown/cleanup scenarios, and hugepage mappings seem to work correctly. I've lightly tested WC mappings also (by observing resulting PTEs as having the correct attributes...). (The first two commits are a couple of tiny bugfixes which I can send separately, should reviewers prefer.) This series is based on v6.19 but I expect to rebase, at least onto Leon's recent work [2] ("vfio: Wait for dma-buf invalidation to complete"). What are people's thoughts? I'll respin to de-RFC and capture comments, if we think this approach is appropriate. Thanks, Matt References: [0]: https://lore.kernel.org/linux-iommu/20250918214425.2677057-1-amastro@fb.com/ [1]: https://lore.kernel.org/all/20250804104012.87915-1-mngyadam@amazon.de/ [2]: https://lore.kernel.org/linux-iommu/20260205-nocturnal-poetic-chamois-f566ad@houat/T/#m310cd07011e3a1461b6fda45e3f9b886ba76571a Matt Evans (7): vfio/pci: Ensure VFIO barmap is set up before creating a DMABUF vfio/pci: Clean up DMABUFs before disabling function vfio/pci: Support mmap() of a DMABUF dma-buf: uapi: Mechanism to revoke DMABUFs via ioctl() vfio/pci: Permanently revoke a DMABUF on request vfio/pci: Add mmap() attributes to DMABUF feature [RFC ONLY] selftests: vfio: Add standalone vfio_dmabuf_mmap_test drivers/dma-buf/dma-buf.c | 5 + drivers/vfio/pci/vfio_pci_core.c | 4 +- drivers/vfio/pci/vfio_pci_dmabuf.c | 300 ++++++- include/linux/dma-buf.h | 22 + include/uapi/linux/dma-buf.h | 1 + include/uapi/linux/vfio.h | 12 +- tools/testing/selftests/vfio/Makefile | 1 + .../vfio/standalone/vfio_dmabuf_mmap_test.c | 822 ++++++++++++++++++ 8 files changed, 1153 insertions(+), 14 deletions(-) create mode 100644 tools/testing/selftests/vfio/standalone/vfio_dmabuf_mmap_test.c -- 2.47.3
null
null
null
[RFC PATCH 0/7] vfio/pci: Add mmap() for DMABUFs
On Fri, Feb 27, 2026 at 11:09:31AM +0100, Christian König wrote: I actually would like to go the other way and have VFIO always have a DMABUF under the VMA's it mmaps because that will make it easy to finish the type1 emulation which requires finding dmabufs for the VMAs. It isn't that simple, the vm_ops won't have a way to get back to the dmabuf from the vma to find the per-fd revoke flag to check it. Yeah, this becomes problematic. Right now there is a single address space per vfio-device and the invalidation is global. Possibly for this use case you can keep that and do a global unmap and rely on fault to restore the mmaps that were not revoked. Jason
{ "author": "Jason Gunthorpe <jgg@nvidia.com>", "date": "Fri, 27 Feb 2026 08:51:09 -0400", "is_openbsd": false, "thread_id": "a006b938-cd53-4c56-8131-30f557919ec6@amd.com.mbox.gz" }
lkml_critique
lkml
Hi all, There were various suggestions in the September 2025 thread "[TECH TOPIC] vfio, iommufd: Enabling user space drivers to vend more granular access to client processes" [0], and LPC discussions, around improving the situation for multi-process userspace driver designs. This RFC series implements some of these ideas. Background: Multi-process USDs ============================== The userspace driver scenario discussed in that thread involves a primary process driving a PCIe function through VFIO/iommufd, which manages the function-wide ownership/lifecycle. The function is designed to provide multiple distinct programming interfaces (for example, several independent MMIO register frames in one function), and the primary process delegates control of these interfaces to multiple independent client processes (which do the actual work). This scenario clearly relies on a HW design that provides appropriate isolation between the programming interfaces. The two key needs are: 1. Mechanisms to safely delegate a subset of the device MMIO resources to a client process without over-sharing wider access (or influence over whole-device activities, such as reset). 2. Mechanisms to allow a client process to do its own iommufd management w.r.t. its address space, in a way that's isolated from DMA relating to other clients. mmap() of VFIO DMABUFs ====================== First, this RFC addresses #1, implementing the proposals in [0] to add mmap() support to the existing VFIO DMABUF exporter. This enables a userspace driver to define DMABUF ranges corresponding to sub-ranges of a BAR, and grant a given client (via a shared fd) the capability to access (only) those sub-ranges. The VFIO device fds would be kept private to the primary process. All the client can do with that fd is map (or iomap via iommufd) that specific subset of resources, and the impact of bugs/malice is contained. (We'll follow up on #2 separately, as a related-but-distinct problem. PASIDs are one way to achieve per-client isolation of DMA; another could be sharing of a single IOVA space via 'constrained' iommufds.) Revocation/reclaim ================== That's useful as-is, but then the lifetime of access granted to a client needs to be managed well. For example, a protocol between the primary process and the client can indicate when the client is done, and when it's safe to reuse the resources elsewhere. Resources could be released cooperatively, but it's much more robust to enable the driver to make the resources guaranteed-inaccessible when it chooses, so that it can re-assign them to other uses in future. So, second, I've suggested a PoC/example mechanism for reclaiming ranges shared with clients: a new DMABUF ioctl, DMA_BUF_IOCTL_REVOKE, is routed to a DMABUF exporter callback. The VFIO DMABUF exporter's implementation permanently revokes a DMABUF (notifying importers, and zapping PTEs for any mappings). This makes the DMABUF defunct and any client (or third party the client has shared the buffer onto!) cannot be used to access the BAR ranges, whether via DMABUF import or mmap(). A primary driver process would do this operation when the client's tenure ends to reclaim "loaned-out" MMIO interfaces, at which point the interfaces could be safely re-used. This ioctl is one of several possible approaches to achieve buffer revocation, but I wanted to demonstrate something here as it's an important part of the buffer lifecycle in this driver scenario. An alternative implementation could be some VFIO-specific operation to search for a DMABUF (by address?) and kill it, but if the server keeps hold of the DMABUF fd that's already a clean way to locate it later. BAR mapping access attributes ============================= Third, inspired by Alex [Mastro] and Jason's comments in [0], and Mahmoud's work in [1] with the goal of controlling CPU access attributes for VFIO BAR mappings (e.g. WC) I noticed that once we can mmap() VFIO DMABUFs representing BAR sub-spans, it's straightforward to decorate them with access attributes for the VMA. I've proposed reserving a field in struct vfio_device_feature_dma_buf's flags to specify an attribute for its ranges. Although that keeps the (UAPI) struct unchanged, it means all ranges in a DMABUF share the same attribute. I feel a single attribute-to-mmap() relation is logical/reasonable. An application can also create multiple DMABUFs to describe any BAR layout and mix of attributes. Tests ===== I've included an [RFC ONLY] userspace test program which I am _not_ proposing to merge, but am sharing for context. It illustrates & tests various map/revoke cases, but doesn't use the existing VFIO selftests and relies on a (tweaked) QEMU EDU function. I'm working on integrating the scenarios into the existing VFIO selftests. This code has been tested in mapping DMABUFs of single/multiple ranges, aliasing mmap()s, aliasing ranges across DMABUFs, vm_pgoff > 0, revocation, shutdown/cleanup scenarios, and hugepage mappings seem to work correctly. I've lightly tested WC mappings also (by observing resulting PTEs as having the correct attributes...). (The first two commits are a couple of tiny bugfixes which I can send separately, should reviewers prefer.) This series is based on v6.19 but I expect to rebase, at least onto Leon's recent work [2] ("vfio: Wait for dma-buf invalidation to complete"). What are people's thoughts? I'll respin to de-RFC and capture comments, if we think this approach is appropriate. Thanks, Matt References: [0]: https://lore.kernel.org/linux-iommu/20250918214425.2677057-1-amastro@fb.com/ [1]: https://lore.kernel.org/all/20250804104012.87915-1-mngyadam@amazon.de/ [2]: https://lore.kernel.org/linux-iommu/20260205-nocturnal-poetic-chamois-f566ad@houat/T/#m310cd07011e3a1461b6fda45e3f9b886ba76571a Matt Evans (7): vfio/pci: Ensure VFIO barmap is set up before creating a DMABUF vfio/pci: Clean up DMABUFs before disabling function vfio/pci: Support mmap() of a DMABUF dma-buf: uapi: Mechanism to revoke DMABUFs via ioctl() vfio/pci: Permanently revoke a DMABUF on request vfio/pci: Add mmap() attributes to DMABUF feature [RFC ONLY] selftests: vfio: Add standalone vfio_dmabuf_mmap_test drivers/dma-buf/dma-buf.c | 5 + drivers/vfio/pci/vfio_pci_core.c | 4 +- drivers/vfio/pci/vfio_pci_dmabuf.c | 300 ++++++- include/linux/dma-buf.h | 22 + include/uapi/linux/dma-buf.h | 1 + include/uapi/linux/vfio.h | 12 +- tools/testing/selftests/vfio/Makefile | 1 + .../vfio/standalone/vfio_dmabuf_mmap_test.c | 822 ++++++++++++++++++ 8 files changed, 1153 insertions(+), 14 deletions(-) create mode 100644 tools/testing/selftests/vfio/standalone/vfio_dmabuf_mmap_test.c -- 2.47.3
null
null
null
[RFC PATCH 0/7] vfio/pci: Add mmap() for DMABUFs
On Fri, Feb 27, 2026 at 11:05:24AM +0100, Christian König wrote: They are building a "vending process" to wrapper VFIO. They want to send a little bit of MMIO space wrapped in a DMABUF to some other process over a unix FD. At some later point the vending process will want to revoke the MMIO so it will issue this IOCTL to the DMABUF FD it held on to. That will render the FD unusable wherever else it happened to go. I had a similar discussion about other iommu features where they want to insert security protocols into this vending sequence. IDK if this should be generic DMABUF or not. Another option is to add a new VFIO ioctl that does the revoke and takes in a DMABUF FD. If it is a VFIO DMABUF FD then it will revoke it as desired here using the VFIO machinery. Jason
{ "author": "Jason Gunthorpe <jgg@nvidia.com>", "date": "Fri, 27 Feb 2026 08:56:21 -0400", "is_openbsd": false, "thread_id": "a006b938-cd53-4c56-8131-30f557919ec6@amd.com.mbox.gz" }
lkml_critique
lkml
Hi all, There were various suggestions in the September 2025 thread "[TECH TOPIC] vfio, iommufd: Enabling user space drivers to vend more granular access to client processes" [0], and LPC discussions, around improving the situation for multi-process userspace driver designs. This RFC series implements some of these ideas. Background: Multi-process USDs ============================== The userspace driver scenario discussed in that thread involves a primary process driving a PCIe function through VFIO/iommufd, which manages the function-wide ownership/lifecycle. The function is designed to provide multiple distinct programming interfaces (for example, several independent MMIO register frames in one function), and the primary process delegates control of these interfaces to multiple independent client processes (which do the actual work). This scenario clearly relies on a HW design that provides appropriate isolation between the programming interfaces. The two key needs are: 1. Mechanisms to safely delegate a subset of the device MMIO resources to a client process without over-sharing wider access (or influence over whole-device activities, such as reset). 2. Mechanisms to allow a client process to do its own iommufd management w.r.t. its address space, in a way that's isolated from DMA relating to other clients. mmap() of VFIO DMABUFs ====================== First, this RFC addresses #1, implementing the proposals in [0] to add mmap() support to the existing VFIO DMABUF exporter. This enables a userspace driver to define DMABUF ranges corresponding to sub-ranges of a BAR, and grant a given client (via a shared fd) the capability to access (only) those sub-ranges. The VFIO device fds would be kept private to the primary process. All the client can do with that fd is map (or iomap via iommufd) that specific subset of resources, and the impact of bugs/malice is contained. (We'll follow up on #2 separately, as a related-but-distinct problem. PASIDs are one way to achieve per-client isolation of DMA; another could be sharing of a single IOVA space via 'constrained' iommufds.) Revocation/reclaim ================== That's useful as-is, but then the lifetime of access granted to a client needs to be managed well. For example, a protocol between the primary process and the client can indicate when the client is done, and when it's safe to reuse the resources elsewhere. Resources could be released cooperatively, but it's much more robust to enable the driver to make the resources guaranteed-inaccessible when it chooses, so that it can re-assign them to other uses in future. So, second, I've suggested a PoC/example mechanism for reclaiming ranges shared with clients: a new DMABUF ioctl, DMA_BUF_IOCTL_REVOKE, is routed to a DMABUF exporter callback. The VFIO DMABUF exporter's implementation permanently revokes a DMABUF (notifying importers, and zapping PTEs for any mappings). This makes the DMABUF defunct and any client (or third party the client has shared the buffer onto!) cannot be used to access the BAR ranges, whether via DMABUF import or mmap(). A primary driver process would do this operation when the client's tenure ends to reclaim "loaned-out" MMIO interfaces, at which point the interfaces could be safely re-used. This ioctl is one of several possible approaches to achieve buffer revocation, but I wanted to demonstrate something here as it's an important part of the buffer lifecycle in this driver scenario. An alternative implementation could be some VFIO-specific operation to search for a DMABUF (by address?) and kill it, but if the server keeps hold of the DMABUF fd that's already a clean way to locate it later. BAR mapping access attributes ============================= Third, inspired by Alex [Mastro] and Jason's comments in [0], and Mahmoud's work in [1] with the goal of controlling CPU access attributes for VFIO BAR mappings (e.g. WC) I noticed that once we can mmap() VFIO DMABUFs representing BAR sub-spans, it's straightforward to decorate them with access attributes for the VMA. I've proposed reserving a field in struct vfio_device_feature_dma_buf's flags to specify an attribute for its ranges. Although that keeps the (UAPI) struct unchanged, it means all ranges in a DMABUF share the same attribute. I feel a single attribute-to-mmap() relation is logical/reasonable. An application can also create multiple DMABUFs to describe any BAR layout and mix of attributes. Tests ===== I've included an [RFC ONLY] userspace test program which I am _not_ proposing to merge, but am sharing for context. It illustrates & tests various map/revoke cases, but doesn't use the existing VFIO selftests and relies on a (tweaked) QEMU EDU function. I'm working on integrating the scenarios into the existing VFIO selftests. This code has been tested in mapping DMABUFs of single/multiple ranges, aliasing mmap()s, aliasing ranges across DMABUFs, vm_pgoff > 0, revocation, shutdown/cleanup scenarios, and hugepage mappings seem to work correctly. I've lightly tested WC mappings also (by observing resulting PTEs as having the correct attributes...). (The first two commits are a couple of tiny bugfixes which I can send separately, should reviewers prefer.) This series is based on v6.19 but I expect to rebase, at least onto Leon's recent work [2] ("vfio: Wait for dma-buf invalidation to complete"). What are people's thoughts? I'll respin to de-RFC and capture comments, if we think this approach is appropriate. Thanks, Matt References: [0]: https://lore.kernel.org/linux-iommu/20250918214425.2677057-1-amastro@fb.com/ [1]: https://lore.kernel.org/all/20250804104012.87915-1-mngyadam@amazon.de/ [2]: https://lore.kernel.org/linux-iommu/20260205-nocturnal-poetic-chamois-f566ad@houat/T/#m310cd07011e3a1461b6fda45e3f9b886ba76571a Matt Evans (7): vfio/pci: Ensure VFIO barmap is set up before creating a DMABUF vfio/pci: Clean up DMABUFs before disabling function vfio/pci: Support mmap() of a DMABUF dma-buf: uapi: Mechanism to revoke DMABUFs via ioctl() vfio/pci: Permanently revoke a DMABUF on request vfio/pci: Add mmap() attributes to DMABUF feature [RFC ONLY] selftests: vfio: Add standalone vfio_dmabuf_mmap_test drivers/dma-buf/dma-buf.c | 5 + drivers/vfio/pci/vfio_pci_core.c | 4 +- drivers/vfio/pci/vfio_pci_dmabuf.c | 300 ++++++- include/linux/dma-buf.h | 22 + include/uapi/linux/dma-buf.h | 1 + include/uapi/linux/vfio.h | 12 +- tools/testing/selftests/vfio/Makefile | 1 + .../vfio/standalone/vfio_dmabuf_mmap_test.c | 822 ++++++++++++++++++ 8 files changed, 1153 insertions(+), 14 deletions(-) create mode 100644 tools/testing/selftests/vfio/standalone/vfio_dmabuf_mmap_test.c -- 2.47.3
null
null
null
[RFC PATCH 0/7] vfio/pci: Add mmap() for DMABUFs
Hi Christian, On 27/02/2026 10:05, Christian König wrote: Well, it's for cleanup, but directed to a specific buffer. Elaborating on the original example, a userspace driver creates a DMABUF for parts of a BAR and then sends its fd to some other client process via SCM_RIGHTS. The client might then do all of: - Process mappings of the buffer - iommufd IO-mappings of it - other unrelated drivers import it - share the fd with more processes! i.e. poking a programming interface and orchestrating P2P DMA to it. Eventually the client completes and messages the driver to say goodbye, except the client is buggy: it hangs before it munmaps or request other drivers to shut down/detach their imports. Now the original driver can't reuse any BAR ranges it shared out, as there might still be active mappings or even ongoing P2P DMA to them. The goal is to guarantee a point in time where resources corresponding to a previously-shared DMABUF fd _cannot_ be accessed anymore: CPUs, or other drivers/importers, or any other kind of P2P DMA. So yes, a revoke must detach importers, using the synchronous revocation flow Leon added in [0] ("dma-buf: Use revoke mechanism to invalidate shared buffers"). (Apologies, I should really have just built this on top of a tree containing that series to make this need clearer.) But, it ultimately seems to have the same downstream effects as if one were to, say, shut down VFIO device fds and therefore trigger vfio_pci_dma_buf_cleanup(). It's just the reason to trigger revocation is different: a selective userspace-triggered revocation of a given buffer, instead of an exporter cleanup-triggered revocation of all buffers. In both cases the goals are identical too, of a synchronised point after which no more DMA/CPU access can happen. (If I've misunderstood your question please clarify, but I hope that answers it!) Cheers, Matt [0] https://lore.kernel.org/linux-iommu/20260205-nocturnal-poetic-chamois-f566ad@houat/T/#m310cd07011e3a1461b6fda45e3f9b886ba76571a
{ "author": "Matt Evans <mattev@meta.com>", "date": "Fri, 27 Feb 2026 13:02:08 +0000", "is_openbsd": false, "thread_id": "a006b938-cd53-4c56-8131-30f557919ec6@amd.com.mbox.gz" }
lkml_critique
lkml
Hi all, There were various suggestions in the September 2025 thread "[TECH TOPIC] vfio, iommufd: Enabling user space drivers to vend more granular access to client processes" [0], and LPC discussions, around improving the situation for multi-process userspace driver designs. This RFC series implements some of these ideas. Background: Multi-process USDs ============================== The userspace driver scenario discussed in that thread involves a primary process driving a PCIe function through VFIO/iommufd, which manages the function-wide ownership/lifecycle. The function is designed to provide multiple distinct programming interfaces (for example, several independent MMIO register frames in one function), and the primary process delegates control of these interfaces to multiple independent client processes (which do the actual work). This scenario clearly relies on a HW design that provides appropriate isolation between the programming interfaces. The two key needs are: 1. Mechanisms to safely delegate a subset of the device MMIO resources to a client process without over-sharing wider access (or influence over whole-device activities, such as reset). 2. Mechanisms to allow a client process to do its own iommufd management w.r.t. its address space, in a way that's isolated from DMA relating to other clients. mmap() of VFIO DMABUFs ====================== First, this RFC addresses #1, implementing the proposals in [0] to add mmap() support to the existing VFIO DMABUF exporter. This enables a userspace driver to define DMABUF ranges corresponding to sub-ranges of a BAR, and grant a given client (via a shared fd) the capability to access (only) those sub-ranges. The VFIO device fds would be kept private to the primary process. All the client can do with that fd is map (or iomap via iommufd) that specific subset of resources, and the impact of bugs/malice is contained. (We'll follow up on #2 separately, as a related-but-distinct problem. PASIDs are one way to achieve per-client isolation of DMA; another could be sharing of a single IOVA space via 'constrained' iommufds.) Revocation/reclaim ================== That's useful as-is, but then the lifetime of access granted to a client needs to be managed well. For example, a protocol between the primary process and the client can indicate when the client is done, and when it's safe to reuse the resources elsewhere. Resources could be released cooperatively, but it's much more robust to enable the driver to make the resources guaranteed-inaccessible when it chooses, so that it can re-assign them to other uses in future. So, second, I've suggested a PoC/example mechanism for reclaiming ranges shared with clients: a new DMABUF ioctl, DMA_BUF_IOCTL_REVOKE, is routed to a DMABUF exporter callback. The VFIO DMABUF exporter's implementation permanently revokes a DMABUF (notifying importers, and zapping PTEs for any mappings). This makes the DMABUF defunct and any client (or third party the client has shared the buffer onto!) cannot be used to access the BAR ranges, whether via DMABUF import or mmap(). A primary driver process would do this operation when the client's tenure ends to reclaim "loaned-out" MMIO interfaces, at which point the interfaces could be safely re-used. This ioctl is one of several possible approaches to achieve buffer revocation, but I wanted to demonstrate something here as it's an important part of the buffer lifecycle in this driver scenario. An alternative implementation could be some VFIO-specific operation to search for a DMABUF (by address?) and kill it, but if the server keeps hold of the DMABUF fd that's already a clean way to locate it later. BAR mapping access attributes ============================= Third, inspired by Alex [Mastro] and Jason's comments in [0], and Mahmoud's work in [1] with the goal of controlling CPU access attributes for VFIO BAR mappings (e.g. WC) I noticed that once we can mmap() VFIO DMABUFs representing BAR sub-spans, it's straightforward to decorate them with access attributes for the VMA. I've proposed reserving a field in struct vfio_device_feature_dma_buf's flags to specify an attribute for its ranges. Although that keeps the (UAPI) struct unchanged, it means all ranges in a DMABUF share the same attribute. I feel a single attribute-to-mmap() relation is logical/reasonable. An application can also create multiple DMABUFs to describe any BAR layout and mix of attributes. Tests ===== I've included an [RFC ONLY] userspace test program which I am _not_ proposing to merge, but am sharing for context. It illustrates & tests various map/revoke cases, but doesn't use the existing VFIO selftests and relies on a (tweaked) QEMU EDU function. I'm working on integrating the scenarios into the existing VFIO selftests. This code has been tested in mapping DMABUFs of single/multiple ranges, aliasing mmap()s, aliasing ranges across DMABUFs, vm_pgoff > 0, revocation, shutdown/cleanup scenarios, and hugepage mappings seem to work correctly. I've lightly tested WC mappings also (by observing resulting PTEs as having the correct attributes...). (The first two commits are a couple of tiny bugfixes which I can send separately, should reviewers prefer.) This series is based on v6.19 but I expect to rebase, at least onto Leon's recent work [2] ("vfio: Wait for dma-buf invalidation to complete"). What are people's thoughts? I'll respin to de-RFC and capture comments, if we think this approach is appropriate. Thanks, Matt References: [0]: https://lore.kernel.org/linux-iommu/20250918214425.2677057-1-amastro@fb.com/ [1]: https://lore.kernel.org/all/20250804104012.87915-1-mngyadam@amazon.de/ [2]: https://lore.kernel.org/linux-iommu/20260205-nocturnal-poetic-chamois-f566ad@houat/T/#m310cd07011e3a1461b6fda45e3f9b886ba76571a Matt Evans (7): vfio/pci: Ensure VFIO barmap is set up before creating a DMABUF vfio/pci: Clean up DMABUFs before disabling function vfio/pci: Support mmap() of a DMABUF dma-buf: uapi: Mechanism to revoke DMABUFs via ioctl() vfio/pci: Permanently revoke a DMABUF on request vfio/pci: Add mmap() attributes to DMABUF feature [RFC ONLY] selftests: vfio: Add standalone vfio_dmabuf_mmap_test drivers/dma-buf/dma-buf.c | 5 + drivers/vfio/pci/vfio_pci_core.c | 4 +- drivers/vfio/pci/vfio_pci_dmabuf.c | 300 ++++++- include/linux/dma-buf.h | 22 + include/uapi/linux/dma-buf.h | 1 + include/uapi/linux/vfio.h | 12 +- tools/testing/selftests/vfio/Makefile | 1 + .../vfio/standalone/vfio_dmabuf_mmap_test.c | 822 ++++++++++++++++++ 8 files changed, 1153 insertions(+), 14 deletions(-) create mode 100644 tools/testing/selftests/vfio/standalone/vfio_dmabuf_mmap_test.c -- 2.47.3
null
null
null
[RFC PATCH 0/7] vfio/pci: Add mmap() for DMABUFs
Hi Matt, On 2/27/26 14:02, Matt Evans wrote: Yeah that makes it clear, Jasons answer also helped quite a bit to understand what you want to do here. First of all your requirements sound reasonable, but absolutely clear NAK to the way those patches approach of implementing them. You completely mixed up the different DMA-buf roles and which is used for what. See the IOCTLs on the DMA-buf file descriptor are for the importer side to communicate with the exporter side. E.g. thinks like "I'm done writing with the CPU, please make that visible to yourself and other importers"..... But what you want to do here is just the other way around, the exporter side wants to signal to all importers that it can't use the buffer any more, correct? If I understood that correctly then my suggestion is that you have a new IOCTL on the VFIO fd you originally used to export the DMA-buf fd. This IOCTL takes the DMA-buf fd and after double checking that it indeed is the exporter of that fd revokes all importer access to it. I'm certainly open on suggestions on how to improve the DMA-buf documentation to make that more clearer in the future. Regards, Christian.
{ "author": "=?UTF-8?Q?Christian_K=C3=B6nig?= <christian.koenig@amd.com>", "date": "Fri, 27 Feb 2026 16:20:54 +0100", "is_openbsd": false, "thread_id": "a006b938-cd53-4c56-8131-30f557919ec6@amd.com.mbox.gz" }
lkml_critique
lkml
Document the QMP UFS PHY compatible for the Eliza Platform. It is fully compatible with the PHY implemented in SM8650, so use the SM8650 compatible as fallback. While at it, move the QCS8300 one so that it is sorted correctly by fallback compatible. Reviewed-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com> Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com> Signed-off-by: Abel Vesa <abel.vesa@oss.qualcomm.com> --- Changes in v3: - Fix commit message by dropping extra "the" word from last sentence. - Picked up Krzysztof's R-b tag. - Link to v2: https://patch.msgid.link/20260220-eliza-bindings-phy-ufs-v2-1-4910bdcc585a@oss.qualcomm.com Changes in v2: - Fixed the order by moving it below X1E80100 so that the fallback compatibles would be sorted, like Krzysztof suggested. - While at it, moved the QCS8300 in first, so the sorting of all fallback compatibles will be complete all the way. - Picked up Konrad's R-b tag. - Link to v1: https://patch.msgid.link/20260219-eliza-bindings-phy-ufs-v1-1-1635e7b53049@oss.qualcomm.com --- .../devicetree/bindings/phy/qcom,sc8280xp-qmp-ufs-phy.yaml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Documentation/devicetree/bindings/phy/qcom,sc8280xp-qmp-ufs-phy.yaml b/Documentation/devicetree/bindings/phy/qcom,sc8280xp-qmp-ufs-phy.yaml index a1731b08c9d1..9616c736b6d4 100644 --- a/Documentation/devicetree/bindings/phy/qcom,sc8280xp-qmp-ufs-phy.yaml +++ b/Documentation/devicetree/bindings/phy/qcom,sc8280xp-qmp-ufs-phy.yaml @@ -16,6 +16,10 @@ description: properties: compatible: oneOf: + - items: + - enum: + - qcom,qcs8300-qmp-ufs-phy + - const: qcom,sa8775p-qmp-ufs-phy - items: - enum: - qcom,qcs615-qmp-ufs-phy @@ -26,8 +30,8 @@ properties: - const: qcom,sm8550-qmp-ufs-phy - items: - enum: - - qcom,qcs8300-qmp-ufs-phy - - const: qcom,sa8775p-qmp-ufs-phy + - qcom,eliza-qmp-ufs-phy + - const: qcom,sm8650-qmp-ufs-phy - items: - enum: - qcom,kaanapali-qmp-ufs-phy --- base-commit: 6de23f81a5e08be8fbf5e8d7e9febc72a5b5f27f change-id: 20260219-eliza-bindings-phy-ufs-3d95c2377aeb Best regards, -- Abel Vesa <abel.vesa@oss.qualcomm.com>
null
null
null
[PATCH v3] dt-bindings: phy: qcom,sc8280xp-qmp-ufs-phy: document the Eliza QMP UFS PHY
On Mon, 23 Feb 2026 10:19:38 +0200, Abel Vesa wrote: Applied, thanks! [1/1] dt-bindings: phy: qcom,sc8280xp-qmp-ufs-phy: document the Eliza QMP UFS PHY commit: caf08514bbee0736c31d8d4f406e3415cdf726bb Best regards, -- ~Vinod
{ "author": "Vinod Koul <vkoul@kernel.org>", "date": "Fri, 27 Feb 2026 20:59:37 +0530", "is_openbsd": false, "thread_id": "177220617754.330302.8800181516621926196.b4-ty@kernel.org.mbox.gz" }
lkml_critique
lkml
From: Yufan Chen <ericterminal@gmail.com> hidp_setup_hid() duplicates the report descriptor from userspace based on req->rd_size. hidp_session_dev_init() only checked rd_size > 0, so oversized values were accepted and propagated to memdup_user(). Reject values larger than HID_MAX_DESCRIPTOR_SIZE and return -EINVAL before entering the HID setup path. Signed-off-by: Yufan Chen <ericterminal@gmail.com> --- net/bluetooth/hidp/core.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/net/bluetooth/hidp/core.c b/net/bluetooth/hidp/core.c index 6fe815241..ce68b3c27 100644 --- a/net/bluetooth/hidp/core.c +++ b/net/bluetooth/hidp/core.c @@ -815,6 +815,9 @@ static int hidp_session_dev_init(struct hidp_session *session, { int ret; + if (req->rd_size > HID_MAX_DESCRIPTOR_SIZE) + return -EINVAL; + if (req->rd_size > 0) { ret = hidp_setup_hid(session, req); if (ret && ret != -ENODEV) -- 2.53.0
null
null
null
[PATCH] Bluetooth: HIDP: reject oversized report descriptor
Hi Yafan, On Tue, Feb 24, 2026 at 8:35 PM Eric-Terminal <ericterminal@gmail.com> wrote: Well this has the potential to break compatibility if a device misbehaves. So is this causing a real problem or is it just defensive coding? In case of the later, we may just truncate or something, if that is not already truncated somewhere else. -- Luiz Augusto von Dentz
{ "author": "Luiz Augusto von Dentz <luiz.dentz@gmail.com>", "date": "Fri, 27 Feb 2026 10:04:03 -0500", "is_openbsd": false, "thread_id": "CABBYNZ+9Z8Yd9mRhgz0N9kSSvLR-6euPf9CRA1Sop_D8zV8wqQ@mail.gmail.com.mbox.gz" }
lkml_critique
lkml
Hi, This series add support for SFPs ports available on the LAN966x PCI device. In order to have the SFPs supported, additional devices are needed such as clock controller and I2C. As a reminder, the LAN966x PCI device driver use a device-tree overlay to describe devices available on the PCI board. Adding support for SFPs ports consists in adding more devices in the already existing device-tree overlay. With those devices added, the device-tree overlay is more complex and some consumer/supplier relationship are needed in order to remove devices in correct order when the LAN966x PCI driver is removed. Those links are typically provided by fw_devlink and we faced some issues with fw_devlink and overlays. This series gives the big picture related to the SFPs support from fixing issues to adding new devices. Of course, it can be split if needed. The first part of the series (patch 1, 2 and 3) fixes fw_devlink when it is used with overlay. Patches 1 and 3 were previously sent by Saravana [0]. I rebased them on top of v7.0-rc1 and added patch 2 in order to take into account feedback received on the series sent by Saravana. Also I added a call to driver_deferred_probe_trigger() in Saravana's patch (patch 3) to ensure that probes are retried after the modification performed on the dangling consumers. This allows to fix issues reported by Matti and Geert [2] with the previous iteration patches. Those modification were not sufficient in our case and so, on top of that, patches 4 to 6 fix some more issues related to fw_devlink. Patches 7 to 12 introduce and use fw_devlink_set_device() in already existing code. Patches 13 and 14 are related also to fw_devlink but specific to PCI and the device-tree nodes created during enumeration. Patches 15, 16 and 17 are related fw_devlink too but specific to I2C muxes. Patches purpose is to correctly set a link between an adapter supplier and its consumer. Indeed, an i2c mux adapter's parent is not the i2c mux supplier but the adapter the i2c mux is connected to. Adding a new link between the adapter supplier involved when i2c muxes are used avoid a freeze observed during device removal. Patch 18 adds support for fw_delink on x86. fw_devlink is needed to have the consumer/supplier relationship between devices in order to ensure a correct device removal order. Adding fw_devlink support for x86 has been tried in the past but was reverted [1] because it broke some systems. Instead of enabling fw_devlink on *all* x86 system, enable it on *all* x86 except on those where it leads to issue. Patches 19 and 20 allow to build clock and i2c controller used by the LAN966x PCI device when the LAN966x PCI device is enabled. Patches 21 to 25 are specific to the LAN966x. They touch the current dtso, split it in dtsi/dtso files, rename the dtso and improve the driver to allow easier support for other boards. The next patch (patch 26) update the LAN966x device-tree overlay itself to have the SPF ports and devices they depends on described. The last two patches (patches 27 and 29) sort the existing drivers in the needed driver list available in the Kconfig help and add new drivers in this list keep the list up to date with the devices described in the device-tree overlay. We believe some items from the above list can be merged separately, with no build dependencies. We expect: - Patches 1 to 6 to be taken by driver core maintainers - Patches 7 to 12 to be taken by driver core maintainers - Patches 13 and 14 to be taken by driver core or PCI maintainers (depend on patch 7) - Patches 15 to 17 to be taken by I2C maintainers - Patch 18 to be taken by driver core or OF maintainers - Patch 19 to be taken by clock maintainers - Patch 20 to be taken by I2C maintainers - Patches 21 to 28 to be taken by misc maintainers Once again, this series gives the big picture and can be split if needed. Let me know. Compare to previous iteration, this v5 series mainly: - Handle Matti and Geert use cases [2] - Remove simple-platform-bus driver introduced in v4 and switch the simple-bus modification back to what was proposed in v3. In the v4 iteration, conclusion was to use v3 changes [3]. [0] https://lore.kernel.org/lkml/20240411235623.1260061-1-saravanak@google.com/ [1] https://lore.kernel.org/lkml/3c1f2473-92ad-bfc4-258e-a5a08ad73dd0@web.de/ [2] https://lore.kernel.org/all/072dde7c-a53c-4525-83ac-57ea38edc0b5@gmail.com/ [3] https://lore.kernel.org/lkml/20251114083056.31553866@bootlin.com/ Best regards, Hervé Changes: v4 -> v5 v4: https://lore.kernel.org/lkml/20251015071420.1173068-1-herve.codina@bootlin.com/ - Patch 2: Add 'Acked-by: Ulf Hansson' - Patch 3: Add a call to driver_deferred_probe_trigger() - Patch 5: (new patch) Depopulate devices at remove - Patch 6: Populate devices at probe. Switched back to modification proposed in v3 - Patch 7 in v3 removed - Patch 7 (8 in v4): Add 'Reviewed-by: Andy Shevchenko' Add 'Reviewed-by: Ulf Hansson' - Patch 8 (9 in v4): Add 'Reviewed-by: Ulf Hansson' - Patches 9 to 15 (10 to 16 in v3) No changes - Patch 16 (17 in v4): Add 'Reviewed-by: Andi Shyti' - Patch 17 (18 in v4): Change an error code from -EINVAL to -ENODEV Add a blank line and fix a typo in commit log - Patch 18 (19 in v4): Simplify of_is_fwnode_add_links_supported(). Move IS_ENABLED(CONFIG_X86) check in of_is_fwnode_add_links_supported(). - Patches 19 to 21 (20 to 22 in v4) No changes - Patch 22 (23 in v4) Update due to simple-platform-bus removal - Patches 23 to 28 (24 to 29 in v4) No changes v3 -> v4 v3: https://lore.kernel.org/lkml/20250613134817.681832-1-herve.codina@bootlin.com/ - Patch 1: No change - Patch 2: Update and fix conflicts. Indeed, since v3 iteration get_dev_from_fwnode() has been moved to device.h and used by pmdomain/core.c. - Patch 3: remove '#define get_device_from_fwnode()' - Patch 4: Fix conflict (rebase v6.17-rc6) Add 'Reviewed-by: Rafael J. Wysocki' Add 'Reviewed-by: Saravana Kannan' - Patch 5 (new in v4): Introduce simple-platform-bus (binding) - Patch 6 (5 in v3): Rework patch and introduce simple-platform-bus - Patch 7: (new) Use simple-platform-bus in LAN966x - Patch 8 (6 in v3): - No change - Patch 9 and 10 (7 and 8 in v3): Add 'Reviewed-by: Andy Shevchenko' - Patch 11 and 12 (9 and 10 in v3): Add 'Reviewed-by: Dave Jiang' - Patch 13 (11 in v3): Add 'Reviewed-by: Andy Shevchenko' - Patch 12 in v3: Patch removed. Adding __private tag in fwnode.dev is going to be handled in a dedicated series. Indeed a test robot reported an issue and more patches are needed (I have missed fwnode.dev users in several part in the kernel). - Patch 14 and 15 (13 and 14 in v3): No change - Patch 16 (14 in v3): Add 'Reviewed-by: Andi Shyti' - Patch 17 and 18 (16 and 17 in v3): No change - Patch 19 (18 in v3): Filter out support for fw_devlink on x86 based on some device-tree properties. Rewrite commit changelog Remove 'Reviewed-by: Andy Shevchenko' (significant modification) - Patch 20 (19 in v3): Add 'Acked-by: Stephen Boyd' - Patch 21 (20 in v3): Fix conflict (rebase v6.18-rc1) - Patches 22 to 24 (21 to 23 in v3): No change - Patch 25 (24 in v3): Fix conflict (rebase v6.18-rc1) Add 'Acked-by: Bjorn Helgaas' - Patches 26 to 29 (25 to 28 in v3): No change v2 -> v3 v2: https://lore.kernel.org/all/20250507071315.394857-1-herve.codina@bootlin.com/ - Patch 1: Add 'Acked-by: Mark Brown' - Patch 2 and 3: No changes - Patch 4: Rewrite the WARN_ON() condition to avoid an additional 'if' - Patch 5: Fix typos in commit log Update a comment Remove the unneeded check before calling of_platform_depopulate() - Patches 6 to 11: No changes - Patch 12 (new in v3) Tag the fwnode dev member as private - Patch 13 (12 in v2) Fix a typo in the commit log - Patches 14 to 16 (13 to 15 in v2) No changes - Patch 17 (16 in v2) Check parent_physdev for NULL - Patch 18 (17 in v2) Capitalize "Link:" Add 'Reviewed-by: Andy Shevchenko' - Patch 19 (18 in v2) No changes - Patch 20 (19 in v2) Add 'Acked-by: Andi Shyti' - Patch 21 (20 in v2) No changes - Patch 22 (21 in v2) Add 'Reviewed-by: Andrew Lunn' - Patch 23 (22 in v2) Add 'Reviewed-by: Andrew Lunn' - Patch 24 (new in v3) Introduce PCI_DEVICE_ID_EFAR_LAN9662, the LAN966x PCI device ID - Patch 25 (23 in v2) Add 'Reviewed-by: Andrew Lunn' Use PCI_DEVICE_DATA() with PCI_DEVICE_ID_EFAR_LAN9662 instead of PCI_VDEVICE() - Patch 26 to 28 (24 to 26 in v2) No changes v1 -> v2 v1: https://lore.kernel.org/lkml/20250407145546.270683-1-herve.codina@bootlin.com/ - Patch 1 and 3 Remove 'From' tag from the commit log - Patch 2 Add 'Reviewed-by: Andy Shevchenko' Add 'Reviewed-by: Saravana Kannan' Add 'Reviewed-by: Luca Ceresoli' - Patch 4 and 5 No changes - Patch 6 (new in v2) Introduce fw_devlink_set_device() - Patch 7 (new in v2) Use existing device_set_node() helper. - Patch 8 to 11 (new in v2) Use fw_devlink_set_device() in existing code. - Patch 12 (6 in v1) Use fw_devlink_add_device() - Patch 13 (7 in v1) No changes - Patch 14 (8 in v1) Update commit log Use 'physdev' instead of 'supplier' Minor fixes in i2c_get_adapter_physdev() kdoc - Patch 15 and 16 (9 and 10 in v1) Use 'physdev' instead of 'supplier' (commit log, title and code) - Patch 17 (11 in v2) Enable fw_devlink on x86 only if PCI_DYNAMIC_OF_NODES is enabled. Rework commit log. - Patch 18, 19 and 20 (12, 13 and 14 in v1) No changes - Patch 21 (new in v2) Split dtso in dtsi/dtso - Patch 22 (new in v2) Rename lan966x_pci.dtso using the specific board name - Patch 23 (new in v2) Improve the driver introducing board specific data to ease support for other boards (avoid the direct dtbo reference in the function loading the dtbo). - Patch 24 (15 in v1) Refactor due to dtso split in dtsi/dtso - Patch 25 (new in v2) Sort exist driver list in Kconfig help - Patch 26 (16 in v1) Keep alphanumeric order for new drivers added in Kconfig help Herve Codina (26): driver core: Rename get_dev_from_fwnode() wrapper to get_device_from_fwnode() driver core: Avoid warning when removing a device while its supplier is unbinding bus: simple-pm-bus: Remove child devices when the bus is unbound bus: simple-pm-bus: Populate child nodes at probe driver core: fw_devlink: Introduce fw_devlink_set_device() drivers: core: Use fw_devlink_set_device() pinctrl: cs42l43: Use fw_devlink_set_device() cxl/test: Use device_set_node() cxl/test: Use fw_devlink_set_device() PCI: of: Use fw_devlink_set_device() PCI: of: Set fwnode device of newly created PCI device nodes PCI: of: Remove fwnode_dev_initialized() call for a PCI root bridge node i2c: core: Introduce i2c_get_adapter_physdev() i2c: mux: Set adapter physical device i2c: mux: Create missing devlink between mux and adapter physical device of: property: Allow fw_devlink device-tree on x86 clk: lan966x: Add MCHP_LAN966X_PCI dependency i2c: busses: at91: Add MCHP_LAN966X_PCI dependency misc: lan966x_pci: Fix dtso nodes ordering misc: lan966x_pci: Split dtso in dtsi/dtso misc: lan966x_pci: Rename lan966x_pci.dtso to lan966x_evb_lan9662_nic.dtso PCI: Add Microchip LAN9662 PCI Device ID misc: lan966x_pci: Introduce board specific data misc: lan966x_pci: Add dtsi/dtso nodes in order to support SFPs misc: lan966x_pci: Sort the drivers list in Kconfig help misc: lan966x_pci: Add drivers needed to support SFPs in Kconfig help Saravana Kannan (2): Revert "treewide: Fix probing of devices in DT overlays" of: dynamic: Fix overlayed devices not probing because of fw_devlink MAINTAINERS | 3 +- drivers/base/core.c | 108 ++++++++++--- drivers/bus/imx-weim.c | 6 - drivers/bus/simple-pm-bus.c | 24 +-- drivers/clk/Kconfig | 2 +- drivers/i2c/busses/Kconfig | 2 +- drivers/i2c/i2c-core-base.c | 16 ++ drivers/i2c/i2c-core-of.c | 5 - drivers/i2c/i2c-mux.c | 26 ++++ drivers/misc/Kconfig | 11 +- drivers/misc/Makefile | 2 +- drivers/misc/lan966x_evb_lan9662_nic.dtso | 167 ++++++++++++++++++++ drivers/misc/lan966x_pci.c | 30 +++- drivers/misc/lan966x_pci.dtsi | 172 +++++++++++++++++++++ drivers/misc/lan966x_pci.dtso | 177 ---------------------- drivers/of/dynamic.c | 1 - drivers/of/overlay.c | 15 ++ drivers/of/platform.c | 5 - drivers/of/property.c | 26 +++- drivers/pci/of.c | 10 +- drivers/pci/quirks.c | 2 +- drivers/pinctrl/cirrus/pinctrl-cs42l43.c | 2 +- drivers/pmdomain/core.c | 4 +- drivers/spi/spi.c | 5 - include/linux/device.h | 2 +- include/linux/fwnode.h | 7 + include/linux/i2c.h | 3 + include/linux/pci_ids.h | 1 + tools/testing/cxl/test/cxl.c | 4 +- 29 files changed, 584 insertions(+), 254 deletions(-) create mode 100644 drivers/misc/lan966x_evb_lan9662_nic.dtso create mode 100644 drivers/misc/lan966x_pci.dtsi delete mode 100644 drivers/misc/lan966x_pci.dtso -- 2.53.0
null
null
null
[PATCH v5 00/28] lan966x pci device: Add support for SFPs
From: Saravana Kannan <saravanak@google.com> This reverts commit 1a50d9403fb90cbe4dea0ec9fd0351d2ecbd8924. While the commit fixed fw_devlink overlay handling for one case, it broke it for another case. So revert it and redo the fix in a separate patch. Fixes: 1a50d9403fb9 ("treewide: Fix probing of devices in DT overlays") Reported-by: Herve Codina <herve.codina@bootlin.com> Closes: https://lore.kernel.org/lkml/CAMuHMdXEnSD4rRJ-o90x4OprUacN_rJgyo8x6=9F9rZ+-KzjOg@mail.gmail.com/ Closes: https://lore.kernel.org/all/20240221095137.616d2aaa@bootlin.com/ Closes: https://lore.kernel.org/lkml/20240312151835.29ef62a0@bootlin.com/ Signed-off-by: Saravana Kannan <saravanak@google.com> Link: https://lore.kernel.org/lkml/20240411235623.1260061-2-saravanak@google.com/ Signed-off-by: Herve Codina <herve.codina@bootlin.com> Acked-by: Mark Brown <broonie@kernel.org> --- drivers/bus/imx-weim.c | 6 ------ drivers/i2c/i2c-core-of.c | 5 ----- drivers/of/dynamic.c | 1 - drivers/of/platform.c | 5 ----- drivers/spi/spi.c | 5 ----- 5 files changed, 22 deletions(-) diff --git a/drivers/bus/imx-weim.c b/drivers/bus/imx-weim.c index 83d623d97f5f..87070155b057 100644 --- a/drivers/bus/imx-weim.c +++ b/drivers/bus/imx-weim.c @@ -327,12 +327,6 @@ static int of_weim_notify(struct notifier_block *nb, unsigned long action, "Failed to setup timing for '%pOF'\n", rd->dn); if (!of_node_check_flag(rd->dn, OF_POPULATED)) { - /* - * Clear the flag before adding the device so that - * fw_devlink doesn't skip adding consumers to this - * device. - */ - rd->dn->fwnode.flags &= ~FWNODE_FLAG_NOT_DEVICE; if (!of_platform_device_create(rd->dn, NULL, &pdev->dev)) { dev_err(&pdev->dev, "Failed to create child device '%pOF'\n", diff --git a/drivers/i2c/i2c-core-of.c b/drivers/i2c/i2c-core-of.c index eb7fb202355f..30b48a428c0b 100644 --- a/drivers/i2c/i2c-core-of.c +++ b/drivers/i2c/i2c-core-of.c @@ -176,11 +176,6 @@ static int of_i2c_notify(struct notifier_block *nb, unsigned long action, return NOTIFY_OK; } - /* - * Clear the flag before adding the device so that fw_devlink - * doesn't skip adding consumers to this device. - */ - rd->dn->fwnode.flags &= ~FWNODE_FLAG_NOT_DEVICE; client = of_i2c_register_device(adap, rd->dn); if (IS_ERR(client)) { dev_err(&adap->dev, "failed to create client for '%pOF'\n", diff --git a/drivers/of/dynamic.c b/drivers/of/dynamic.c index 1a06175def37..aa450425ec1e 100644 --- a/drivers/of/dynamic.c +++ b/drivers/of/dynamic.c @@ -225,7 +225,6 @@ static void __of_attach_node(struct device_node *np) np->sibling = np->parent->child; np->parent->child = np; of_node_clear_flag(np, OF_DETACHED); - np->fwnode.flags |= FWNODE_FLAG_NOT_DEVICE; raw_spin_unlock_irqrestore(&devtree_lock, flags); diff --git a/drivers/of/platform.c b/drivers/of/platform.c index ba591fbceb56..2037c0b3880d 100644 --- a/drivers/of/platform.c +++ b/drivers/of/platform.c @@ -738,11 +738,6 @@ static int of_platform_notify(struct notifier_block *nb, if (of_node_check_flag(rd->dn, OF_POPULATED)) return NOTIFY_OK; - /* - * Clear the flag before adding the device so that fw_devlink - * doesn't skip adding consumers to this device. - */ - rd->dn->fwnode.flags &= ~FWNODE_FLAG_NOT_DEVICE; /* pdev_parent may be NULL when no bus platform device */ pdev_parent = of_find_device_by_node(parent); pdev = of_platform_device_create(rd->dn, NULL, diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index 61f7bde8c7fb..749d306ce1cc 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c @@ -4934,11 +4934,6 @@ static int of_spi_notify(struct notifier_block *nb, unsigned long action, return NOTIFY_OK; } - /* - * Clear the flag before adding the device so that fw_devlink - * doesn't skip adding consumers to this device. - */ - rd->dn->fwnode.flags &= ~FWNODE_FLAG_NOT_DEVICE; spi = of_register_spi_device(ctlr, rd->dn); put_device(&ctlr->dev); -- 2.53.0
{ "author": "Herve Codina <herve.codina@bootlin.com>", "date": "Fri, 27 Feb 2026 14:53:58 +0100", "is_openbsd": false, "thread_id": "20260227135428.783983-1-herve.codina@bootlin.com.mbox.gz" }
lkml_critique
lkml
Hi, This series add support for SFPs ports available on the LAN966x PCI device. In order to have the SFPs supported, additional devices are needed such as clock controller and I2C. As a reminder, the LAN966x PCI device driver use a device-tree overlay to describe devices available on the PCI board. Adding support for SFPs ports consists in adding more devices in the already existing device-tree overlay. With those devices added, the device-tree overlay is more complex and some consumer/supplier relationship are needed in order to remove devices in correct order when the LAN966x PCI driver is removed. Those links are typically provided by fw_devlink and we faced some issues with fw_devlink and overlays. This series gives the big picture related to the SFPs support from fixing issues to adding new devices. Of course, it can be split if needed. The first part of the series (patch 1, 2 and 3) fixes fw_devlink when it is used with overlay. Patches 1 and 3 were previously sent by Saravana [0]. I rebased them on top of v7.0-rc1 and added patch 2 in order to take into account feedback received on the series sent by Saravana. Also I added a call to driver_deferred_probe_trigger() in Saravana's patch (patch 3) to ensure that probes are retried after the modification performed on the dangling consumers. This allows to fix issues reported by Matti and Geert [2] with the previous iteration patches. Those modification were not sufficient in our case and so, on top of that, patches 4 to 6 fix some more issues related to fw_devlink. Patches 7 to 12 introduce and use fw_devlink_set_device() in already existing code. Patches 13 and 14 are related also to fw_devlink but specific to PCI and the device-tree nodes created during enumeration. Patches 15, 16 and 17 are related fw_devlink too but specific to I2C muxes. Patches purpose is to correctly set a link between an adapter supplier and its consumer. Indeed, an i2c mux adapter's parent is not the i2c mux supplier but the adapter the i2c mux is connected to. Adding a new link between the adapter supplier involved when i2c muxes are used avoid a freeze observed during device removal. Patch 18 adds support for fw_delink on x86. fw_devlink is needed to have the consumer/supplier relationship between devices in order to ensure a correct device removal order. Adding fw_devlink support for x86 has been tried in the past but was reverted [1] because it broke some systems. Instead of enabling fw_devlink on *all* x86 system, enable it on *all* x86 except on those where it leads to issue. Patches 19 and 20 allow to build clock and i2c controller used by the LAN966x PCI device when the LAN966x PCI device is enabled. Patches 21 to 25 are specific to the LAN966x. They touch the current dtso, split it in dtsi/dtso files, rename the dtso and improve the driver to allow easier support for other boards. The next patch (patch 26) update the LAN966x device-tree overlay itself to have the SPF ports and devices they depends on described. The last two patches (patches 27 and 29) sort the existing drivers in the needed driver list available in the Kconfig help and add new drivers in this list keep the list up to date with the devices described in the device-tree overlay. We believe some items from the above list can be merged separately, with no build dependencies. We expect: - Patches 1 to 6 to be taken by driver core maintainers - Patches 7 to 12 to be taken by driver core maintainers - Patches 13 and 14 to be taken by driver core or PCI maintainers (depend on patch 7) - Patches 15 to 17 to be taken by I2C maintainers - Patch 18 to be taken by driver core or OF maintainers - Patch 19 to be taken by clock maintainers - Patch 20 to be taken by I2C maintainers - Patches 21 to 28 to be taken by misc maintainers Once again, this series gives the big picture and can be split if needed. Let me know. Compare to previous iteration, this v5 series mainly: - Handle Matti and Geert use cases [2] - Remove simple-platform-bus driver introduced in v4 and switch the simple-bus modification back to what was proposed in v3. In the v4 iteration, conclusion was to use v3 changes [3]. [0] https://lore.kernel.org/lkml/20240411235623.1260061-1-saravanak@google.com/ [1] https://lore.kernel.org/lkml/3c1f2473-92ad-bfc4-258e-a5a08ad73dd0@web.de/ [2] https://lore.kernel.org/all/072dde7c-a53c-4525-83ac-57ea38edc0b5@gmail.com/ [3] https://lore.kernel.org/lkml/20251114083056.31553866@bootlin.com/ Best regards, Hervé Changes: v4 -> v5 v4: https://lore.kernel.org/lkml/20251015071420.1173068-1-herve.codina@bootlin.com/ - Patch 2: Add 'Acked-by: Ulf Hansson' - Patch 3: Add a call to driver_deferred_probe_trigger() - Patch 5: (new patch) Depopulate devices at remove - Patch 6: Populate devices at probe. Switched back to modification proposed in v3 - Patch 7 in v3 removed - Patch 7 (8 in v4): Add 'Reviewed-by: Andy Shevchenko' Add 'Reviewed-by: Ulf Hansson' - Patch 8 (9 in v4): Add 'Reviewed-by: Ulf Hansson' - Patches 9 to 15 (10 to 16 in v3) No changes - Patch 16 (17 in v4): Add 'Reviewed-by: Andi Shyti' - Patch 17 (18 in v4): Change an error code from -EINVAL to -ENODEV Add a blank line and fix a typo in commit log - Patch 18 (19 in v4): Simplify of_is_fwnode_add_links_supported(). Move IS_ENABLED(CONFIG_X86) check in of_is_fwnode_add_links_supported(). - Patches 19 to 21 (20 to 22 in v4) No changes - Patch 22 (23 in v4) Update due to simple-platform-bus removal - Patches 23 to 28 (24 to 29 in v4) No changes v3 -> v4 v3: https://lore.kernel.org/lkml/20250613134817.681832-1-herve.codina@bootlin.com/ - Patch 1: No change - Patch 2: Update and fix conflicts. Indeed, since v3 iteration get_dev_from_fwnode() has been moved to device.h and used by pmdomain/core.c. - Patch 3: remove '#define get_device_from_fwnode()' - Patch 4: Fix conflict (rebase v6.17-rc6) Add 'Reviewed-by: Rafael J. Wysocki' Add 'Reviewed-by: Saravana Kannan' - Patch 5 (new in v4): Introduce simple-platform-bus (binding) - Patch 6 (5 in v3): Rework patch and introduce simple-platform-bus - Patch 7: (new) Use simple-platform-bus in LAN966x - Patch 8 (6 in v3): - No change - Patch 9 and 10 (7 and 8 in v3): Add 'Reviewed-by: Andy Shevchenko' - Patch 11 and 12 (9 and 10 in v3): Add 'Reviewed-by: Dave Jiang' - Patch 13 (11 in v3): Add 'Reviewed-by: Andy Shevchenko' - Patch 12 in v3: Patch removed. Adding __private tag in fwnode.dev is going to be handled in a dedicated series. Indeed a test robot reported an issue and more patches are needed (I have missed fwnode.dev users in several part in the kernel). - Patch 14 and 15 (13 and 14 in v3): No change - Patch 16 (14 in v3): Add 'Reviewed-by: Andi Shyti' - Patch 17 and 18 (16 and 17 in v3): No change - Patch 19 (18 in v3): Filter out support for fw_devlink on x86 based on some device-tree properties. Rewrite commit changelog Remove 'Reviewed-by: Andy Shevchenko' (significant modification) - Patch 20 (19 in v3): Add 'Acked-by: Stephen Boyd' - Patch 21 (20 in v3): Fix conflict (rebase v6.18-rc1) - Patches 22 to 24 (21 to 23 in v3): No change - Patch 25 (24 in v3): Fix conflict (rebase v6.18-rc1) Add 'Acked-by: Bjorn Helgaas' - Patches 26 to 29 (25 to 28 in v3): No change v2 -> v3 v2: https://lore.kernel.org/all/20250507071315.394857-1-herve.codina@bootlin.com/ - Patch 1: Add 'Acked-by: Mark Brown' - Patch 2 and 3: No changes - Patch 4: Rewrite the WARN_ON() condition to avoid an additional 'if' - Patch 5: Fix typos in commit log Update a comment Remove the unneeded check before calling of_platform_depopulate() - Patches 6 to 11: No changes - Patch 12 (new in v3) Tag the fwnode dev member as private - Patch 13 (12 in v2) Fix a typo in the commit log - Patches 14 to 16 (13 to 15 in v2) No changes - Patch 17 (16 in v2) Check parent_physdev for NULL - Patch 18 (17 in v2) Capitalize "Link:" Add 'Reviewed-by: Andy Shevchenko' - Patch 19 (18 in v2) No changes - Patch 20 (19 in v2) Add 'Acked-by: Andi Shyti' - Patch 21 (20 in v2) No changes - Patch 22 (21 in v2) Add 'Reviewed-by: Andrew Lunn' - Patch 23 (22 in v2) Add 'Reviewed-by: Andrew Lunn' - Patch 24 (new in v3) Introduce PCI_DEVICE_ID_EFAR_LAN9662, the LAN966x PCI device ID - Patch 25 (23 in v2) Add 'Reviewed-by: Andrew Lunn' Use PCI_DEVICE_DATA() with PCI_DEVICE_ID_EFAR_LAN9662 instead of PCI_VDEVICE() - Patch 26 to 28 (24 to 26 in v2) No changes v1 -> v2 v1: https://lore.kernel.org/lkml/20250407145546.270683-1-herve.codina@bootlin.com/ - Patch 1 and 3 Remove 'From' tag from the commit log - Patch 2 Add 'Reviewed-by: Andy Shevchenko' Add 'Reviewed-by: Saravana Kannan' Add 'Reviewed-by: Luca Ceresoli' - Patch 4 and 5 No changes - Patch 6 (new in v2) Introduce fw_devlink_set_device() - Patch 7 (new in v2) Use existing device_set_node() helper. - Patch 8 to 11 (new in v2) Use fw_devlink_set_device() in existing code. - Patch 12 (6 in v1) Use fw_devlink_add_device() - Patch 13 (7 in v1) No changes - Patch 14 (8 in v1) Update commit log Use 'physdev' instead of 'supplier' Minor fixes in i2c_get_adapter_physdev() kdoc - Patch 15 and 16 (9 and 10 in v1) Use 'physdev' instead of 'supplier' (commit log, title and code) - Patch 17 (11 in v2) Enable fw_devlink on x86 only if PCI_DYNAMIC_OF_NODES is enabled. Rework commit log. - Patch 18, 19 and 20 (12, 13 and 14 in v1) No changes - Patch 21 (new in v2) Split dtso in dtsi/dtso - Patch 22 (new in v2) Rename lan966x_pci.dtso using the specific board name - Patch 23 (new in v2) Improve the driver introducing board specific data to ease support for other boards (avoid the direct dtbo reference in the function loading the dtbo). - Patch 24 (15 in v1) Refactor due to dtso split in dtsi/dtso - Patch 25 (new in v2) Sort exist driver list in Kconfig help - Patch 26 (16 in v1) Keep alphanumeric order for new drivers added in Kconfig help Herve Codina (26): driver core: Rename get_dev_from_fwnode() wrapper to get_device_from_fwnode() driver core: Avoid warning when removing a device while its supplier is unbinding bus: simple-pm-bus: Remove child devices when the bus is unbound bus: simple-pm-bus: Populate child nodes at probe driver core: fw_devlink: Introduce fw_devlink_set_device() drivers: core: Use fw_devlink_set_device() pinctrl: cs42l43: Use fw_devlink_set_device() cxl/test: Use device_set_node() cxl/test: Use fw_devlink_set_device() PCI: of: Use fw_devlink_set_device() PCI: of: Set fwnode device of newly created PCI device nodes PCI: of: Remove fwnode_dev_initialized() call for a PCI root bridge node i2c: core: Introduce i2c_get_adapter_physdev() i2c: mux: Set adapter physical device i2c: mux: Create missing devlink between mux and adapter physical device of: property: Allow fw_devlink device-tree on x86 clk: lan966x: Add MCHP_LAN966X_PCI dependency i2c: busses: at91: Add MCHP_LAN966X_PCI dependency misc: lan966x_pci: Fix dtso nodes ordering misc: lan966x_pci: Split dtso in dtsi/dtso misc: lan966x_pci: Rename lan966x_pci.dtso to lan966x_evb_lan9662_nic.dtso PCI: Add Microchip LAN9662 PCI Device ID misc: lan966x_pci: Introduce board specific data misc: lan966x_pci: Add dtsi/dtso nodes in order to support SFPs misc: lan966x_pci: Sort the drivers list in Kconfig help misc: lan966x_pci: Add drivers needed to support SFPs in Kconfig help Saravana Kannan (2): Revert "treewide: Fix probing of devices in DT overlays" of: dynamic: Fix overlayed devices not probing because of fw_devlink MAINTAINERS | 3 +- drivers/base/core.c | 108 ++++++++++--- drivers/bus/imx-weim.c | 6 - drivers/bus/simple-pm-bus.c | 24 +-- drivers/clk/Kconfig | 2 +- drivers/i2c/busses/Kconfig | 2 +- drivers/i2c/i2c-core-base.c | 16 ++ drivers/i2c/i2c-core-of.c | 5 - drivers/i2c/i2c-mux.c | 26 ++++ drivers/misc/Kconfig | 11 +- drivers/misc/Makefile | 2 +- drivers/misc/lan966x_evb_lan9662_nic.dtso | 167 ++++++++++++++++++++ drivers/misc/lan966x_pci.c | 30 +++- drivers/misc/lan966x_pci.dtsi | 172 +++++++++++++++++++++ drivers/misc/lan966x_pci.dtso | 177 ---------------------- drivers/of/dynamic.c | 1 - drivers/of/overlay.c | 15 ++ drivers/of/platform.c | 5 - drivers/of/property.c | 26 +++- drivers/pci/of.c | 10 +- drivers/pci/quirks.c | 2 +- drivers/pinctrl/cirrus/pinctrl-cs42l43.c | 2 +- drivers/pmdomain/core.c | 4 +- drivers/spi/spi.c | 5 - include/linux/device.h | 2 +- include/linux/fwnode.h | 7 + include/linux/i2c.h | 3 + include/linux/pci_ids.h | 1 + tools/testing/cxl/test/cxl.c | 4 +- 29 files changed, 584 insertions(+), 254 deletions(-) create mode 100644 drivers/misc/lan966x_evb_lan9662_nic.dtso create mode 100644 drivers/misc/lan966x_pci.dtsi delete mode 100644 drivers/misc/lan966x_pci.dtso -- 2.53.0
null
null
null
[PATCH v5 00/28] lan966x pci device: Add support for SFPs
get_dev_from_fwnode() calls get_device() and so it acquires a reference on the device returned. In order to be more obvious that this wrapper is a get_device() variant, rename it to get_device_from_fwnode(). Suggested-by: Mark Brown <broonie@kernel.org> Link: https://lore.kernel.org/lkml/CAGETcx97QjnjVR8Z5g0ndLHpK96hLd4aYSV=iEkKPNbNOccYmA@mail.gmail.com/ Signed-off-by: Herve Codina <herve.codina@bootlin.com> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Reviewed-by: Saravana Kannan <saravanak@google.com> Reviewed-by: Luca Ceresoli <luca.ceresoli@bootlin.com> Acked-by: Ulf Hansson <ulf.hansson@linaro.org> --- drivers/base/core.c | 18 +++++++++--------- drivers/pmdomain/core.c | 4 ++-- include/linux/device.h | 2 +- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/drivers/base/core.c b/drivers/base/core.c index 791f9e444df8..33c0ff2b162d 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c @@ -1888,7 +1888,7 @@ static bool fwnode_init_without_drv(struct fwnode_handle *fwnode) if (!(fwnode->flags & FWNODE_FLAG_INITIALIZED)) return false; - dev = get_dev_from_fwnode(fwnode); + dev = get_device_from_fwnode(fwnode); ret = !dev || dev->links.status == DL_DEV_NO_DRIVER; put_device(dev); @@ -1957,7 +1957,7 @@ static struct device *fwnode_get_next_parent_dev(const struct fwnode_handle *fwn struct device *dev; fwnode_for_each_parent_node(fwnode, parent) { - dev = get_dev_from_fwnode(parent); + dev = get_device_from_fwnode(parent); if (dev) { fwnode_handle_put(parent); return dev; @@ -2013,8 +2013,8 @@ static bool __fw_devlink_relax_cycles(struct fwnode_handle *con_handle, goto out; } - sup_dev = get_dev_from_fwnode(sup_handle); - con_dev = get_dev_from_fwnode(con_handle); + sup_dev = get_device_from_fwnode(sup_handle); + con_dev = get_device_from_fwnode(con_handle); /* * If sup_dev is bound to a driver and @con hasn't started binding to a * driver, sup_dev can't be a consumer of @con. So, no need to check @@ -2153,7 +2153,7 @@ static int fw_devlink_create_devlink(struct device *con, if (sup_handle->flags & FWNODE_FLAG_NOT_DEVICE) sup_dev = fwnode_get_next_parent_dev(sup_handle); else - sup_dev = get_dev_from_fwnode(sup_handle); + sup_dev = get_device_from_fwnode(sup_handle); if (sup_dev) { /* @@ -2222,7 +2222,7 @@ static void __fw_devlink_link_to_consumers(struct device *dev) bool own_link = true; int ret; - con_dev = get_dev_from_fwnode(link->consumer); + con_dev = get_device_from_fwnode(link->consumer); /* * If consumer device is not available yet, make a "proxy" * SYNC_STATE_ONLY link from the consumer's parent device to @@ -5278,7 +5278,7 @@ void device_set_node(struct device *dev, struct fwnode_handle *fwnode) EXPORT_SYMBOL_GPL(device_set_node); /** - * get_dev_from_fwnode - Obtain a reference count of the struct device the + * get_device_from_fwnode - Obtain a reference count of the struct device the * struct fwnode_handle is associated with. * @fwnode: The pointer to the struct fwnode_handle to obtain the struct device * reference count of. @@ -5296,11 +5296,11 @@ EXPORT_SYMBOL_GPL(device_set_node); * This is possible since struct fwnode_handle has its own reference count and * hence can out-live the struct device it is associated with. */ -struct device *get_dev_from_fwnode(struct fwnode_handle *fwnode) +struct device *get_device_from_fwnode(struct fwnode_handle *fwnode) { return get_device((fwnode)->dev); } -EXPORT_SYMBOL_GPL(get_dev_from_fwnode); +EXPORT_SYMBOL_GPL(get_device_from_fwnode); int device_match_name(struct device *dev, const void *name) { diff --git a/drivers/pmdomain/core.c b/drivers/pmdomain/core.c index 52ea84e548ff..444008234b05 100644 --- a/drivers/pmdomain/core.c +++ b/drivers/pmdomain/core.c @@ -2686,7 +2686,7 @@ int of_genpd_add_provider_simple(struct device_node *np, genpd->dev.of_node = np; fwnode = of_fwnode_handle(np); - dev = get_dev_from_fwnode(fwnode); + dev = get_device_from_fwnode(fwnode); if (!dev && !genpd_is_no_sync_state(genpd)) { genpd->sync_state = GENPD_SYNC_STATE_SIMPLE; device_set_node(&genpd->dev, fwnode); @@ -2761,7 +2761,7 @@ int of_genpd_add_provider_onecell(struct device_node *np, data->xlate = genpd_xlate_onecell; fwnode = of_fwnode_handle(np); - dev = get_dev_from_fwnode(fwnode); + dev = get_device_from_fwnode(fwnode); if (!dev) sync_state = true; else diff --git a/include/linux/device.h b/include/linux/device.h index 0be95294b6e6..fd08e55e05de 100644 --- a/include/linux/device.h +++ b/include/linux/device.h @@ -1071,7 +1071,7 @@ void device_set_node(struct device *dev, struct fwnode_handle *fwnode); int device_add_of_node(struct device *dev, struct device_node *of_node); void device_remove_of_node(struct device *dev); void device_set_of_node_from_dev(struct device *dev, const struct device *dev2); -struct device *get_dev_from_fwnode(struct fwnode_handle *fwnode); +struct device *get_device_from_fwnode(struct fwnode_handle *fwnode); static inline struct device_node *dev_of_node(struct device *dev) { -- 2.53.0
{ "author": "Herve Codina <herve.codina@bootlin.com>", "date": "Fri, 27 Feb 2026 14:53:59 +0100", "is_openbsd": false, "thread_id": "20260227135428.783983-1-herve.codina@bootlin.com.mbox.gz" }
lkml_critique
lkml
Hi, This series add support for SFPs ports available on the LAN966x PCI device. In order to have the SFPs supported, additional devices are needed such as clock controller and I2C. As a reminder, the LAN966x PCI device driver use a device-tree overlay to describe devices available on the PCI board. Adding support for SFPs ports consists in adding more devices in the already existing device-tree overlay. With those devices added, the device-tree overlay is more complex and some consumer/supplier relationship are needed in order to remove devices in correct order when the LAN966x PCI driver is removed. Those links are typically provided by fw_devlink and we faced some issues with fw_devlink and overlays. This series gives the big picture related to the SFPs support from fixing issues to adding new devices. Of course, it can be split if needed. The first part of the series (patch 1, 2 and 3) fixes fw_devlink when it is used with overlay. Patches 1 and 3 were previously sent by Saravana [0]. I rebased them on top of v7.0-rc1 and added patch 2 in order to take into account feedback received on the series sent by Saravana. Also I added a call to driver_deferred_probe_trigger() in Saravana's patch (patch 3) to ensure that probes are retried after the modification performed on the dangling consumers. This allows to fix issues reported by Matti and Geert [2] with the previous iteration patches. Those modification were not sufficient in our case and so, on top of that, patches 4 to 6 fix some more issues related to fw_devlink. Patches 7 to 12 introduce and use fw_devlink_set_device() in already existing code. Patches 13 and 14 are related also to fw_devlink but specific to PCI and the device-tree nodes created during enumeration. Patches 15, 16 and 17 are related fw_devlink too but specific to I2C muxes. Patches purpose is to correctly set a link between an adapter supplier and its consumer. Indeed, an i2c mux adapter's parent is not the i2c mux supplier but the adapter the i2c mux is connected to. Adding a new link between the adapter supplier involved when i2c muxes are used avoid a freeze observed during device removal. Patch 18 adds support for fw_delink on x86. fw_devlink is needed to have the consumer/supplier relationship between devices in order to ensure a correct device removal order. Adding fw_devlink support for x86 has been tried in the past but was reverted [1] because it broke some systems. Instead of enabling fw_devlink on *all* x86 system, enable it on *all* x86 except on those where it leads to issue. Patches 19 and 20 allow to build clock and i2c controller used by the LAN966x PCI device when the LAN966x PCI device is enabled. Patches 21 to 25 are specific to the LAN966x. They touch the current dtso, split it in dtsi/dtso files, rename the dtso and improve the driver to allow easier support for other boards. The next patch (patch 26) update the LAN966x device-tree overlay itself to have the SPF ports and devices they depends on described. The last two patches (patches 27 and 29) sort the existing drivers in the needed driver list available in the Kconfig help and add new drivers in this list keep the list up to date with the devices described in the device-tree overlay. We believe some items from the above list can be merged separately, with no build dependencies. We expect: - Patches 1 to 6 to be taken by driver core maintainers - Patches 7 to 12 to be taken by driver core maintainers - Patches 13 and 14 to be taken by driver core or PCI maintainers (depend on patch 7) - Patches 15 to 17 to be taken by I2C maintainers - Patch 18 to be taken by driver core or OF maintainers - Patch 19 to be taken by clock maintainers - Patch 20 to be taken by I2C maintainers - Patches 21 to 28 to be taken by misc maintainers Once again, this series gives the big picture and can be split if needed. Let me know. Compare to previous iteration, this v5 series mainly: - Handle Matti and Geert use cases [2] - Remove simple-platform-bus driver introduced in v4 and switch the simple-bus modification back to what was proposed in v3. In the v4 iteration, conclusion was to use v3 changes [3]. [0] https://lore.kernel.org/lkml/20240411235623.1260061-1-saravanak@google.com/ [1] https://lore.kernel.org/lkml/3c1f2473-92ad-bfc4-258e-a5a08ad73dd0@web.de/ [2] https://lore.kernel.org/all/072dde7c-a53c-4525-83ac-57ea38edc0b5@gmail.com/ [3] https://lore.kernel.org/lkml/20251114083056.31553866@bootlin.com/ Best regards, Hervé Changes: v4 -> v5 v4: https://lore.kernel.org/lkml/20251015071420.1173068-1-herve.codina@bootlin.com/ - Patch 2: Add 'Acked-by: Ulf Hansson' - Patch 3: Add a call to driver_deferred_probe_trigger() - Patch 5: (new patch) Depopulate devices at remove - Patch 6: Populate devices at probe. Switched back to modification proposed in v3 - Patch 7 in v3 removed - Patch 7 (8 in v4): Add 'Reviewed-by: Andy Shevchenko' Add 'Reviewed-by: Ulf Hansson' - Patch 8 (9 in v4): Add 'Reviewed-by: Ulf Hansson' - Patches 9 to 15 (10 to 16 in v3) No changes - Patch 16 (17 in v4): Add 'Reviewed-by: Andi Shyti' - Patch 17 (18 in v4): Change an error code from -EINVAL to -ENODEV Add a blank line and fix a typo in commit log - Patch 18 (19 in v4): Simplify of_is_fwnode_add_links_supported(). Move IS_ENABLED(CONFIG_X86) check in of_is_fwnode_add_links_supported(). - Patches 19 to 21 (20 to 22 in v4) No changes - Patch 22 (23 in v4) Update due to simple-platform-bus removal - Patches 23 to 28 (24 to 29 in v4) No changes v3 -> v4 v3: https://lore.kernel.org/lkml/20250613134817.681832-1-herve.codina@bootlin.com/ - Patch 1: No change - Patch 2: Update and fix conflicts. Indeed, since v3 iteration get_dev_from_fwnode() has been moved to device.h and used by pmdomain/core.c. - Patch 3: remove '#define get_device_from_fwnode()' - Patch 4: Fix conflict (rebase v6.17-rc6) Add 'Reviewed-by: Rafael J. Wysocki' Add 'Reviewed-by: Saravana Kannan' - Patch 5 (new in v4): Introduce simple-platform-bus (binding) - Patch 6 (5 in v3): Rework patch and introduce simple-platform-bus - Patch 7: (new) Use simple-platform-bus in LAN966x - Patch 8 (6 in v3): - No change - Patch 9 and 10 (7 and 8 in v3): Add 'Reviewed-by: Andy Shevchenko' - Patch 11 and 12 (9 and 10 in v3): Add 'Reviewed-by: Dave Jiang' - Patch 13 (11 in v3): Add 'Reviewed-by: Andy Shevchenko' - Patch 12 in v3: Patch removed. Adding __private tag in fwnode.dev is going to be handled in a dedicated series. Indeed a test robot reported an issue and more patches are needed (I have missed fwnode.dev users in several part in the kernel). - Patch 14 and 15 (13 and 14 in v3): No change - Patch 16 (14 in v3): Add 'Reviewed-by: Andi Shyti' - Patch 17 and 18 (16 and 17 in v3): No change - Patch 19 (18 in v3): Filter out support for fw_devlink on x86 based on some device-tree properties. Rewrite commit changelog Remove 'Reviewed-by: Andy Shevchenko' (significant modification) - Patch 20 (19 in v3): Add 'Acked-by: Stephen Boyd' - Patch 21 (20 in v3): Fix conflict (rebase v6.18-rc1) - Patches 22 to 24 (21 to 23 in v3): No change - Patch 25 (24 in v3): Fix conflict (rebase v6.18-rc1) Add 'Acked-by: Bjorn Helgaas' - Patches 26 to 29 (25 to 28 in v3): No change v2 -> v3 v2: https://lore.kernel.org/all/20250507071315.394857-1-herve.codina@bootlin.com/ - Patch 1: Add 'Acked-by: Mark Brown' - Patch 2 and 3: No changes - Patch 4: Rewrite the WARN_ON() condition to avoid an additional 'if' - Patch 5: Fix typos in commit log Update a comment Remove the unneeded check before calling of_platform_depopulate() - Patches 6 to 11: No changes - Patch 12 (new in v3) Tag the fwnode dev member as private - Patch 13 (12 in v2) Fix a typo in the commit log - Patches 14 to 16 (13 to 15 in v2) No changes - Patch 17 (16 in v2) Check parent_physdev for NULL - Patch 18 (17 in v2) Capitalize "Link:" Add 'Reviewed-by: Andy Shevchenko' - Patch 19 (18 in v2) No changes - Patch 20 (19 in v2) Add 'Acked-by: Andi Shyti' - Patch 21 (20 in v2) No changes - Patch 22 (21 in v2) Add 'Reviewed-by: Andrew Lunn' - Patch 23 (22 in v2) Add 'Reviewed-by: Andrew Lunn' - Patch 24 (new in v3) Introduce PCI_DEVICE_ID_EFAR_LAN9662, the LAN966x PCI device ID - Patch 25 (23 in v2) Add 'Reviewed-by: Andrew Lunn' Use PCI_DEVICE_DATA() with PCI_DEVICE_ID_EFAR_LAN9662 instead of PCI_VDEVICE() - Patch 26 to 28 (24 to 26 in v2) No changes v1 -> v2 v1: https://lore.kernel.org/lkml/20250407145546.270683-1-herve.codina@bootlin.com/ - Patch 1 and 3 Remove 'From' tag from the commit log - Patch 2 Add 'Reviewed-by: Andy Shevchenko' Add 'Reviewed-by: Saravana Kannan' Add 'Reviewed-by: Luca Ceresoli' - Patch 4 and 5 No changes - Patch 6 (new in v2) Introduce fw_devlink_set_device() - Patch 7 (new in v2) Use existing device_set_node() helper. - Patch 8 to 11 (new in v2) Use fw_devlink_set_device() in existing code. - Patch 12 (6 in v1) Use fw_devlink_add_device() - Patch 13 (7 in v1) No changes - Patch 14 (8 in v1) Update commit log Use 'physdev' instead of 'supplier' Minor fixes in i2c_get_adapter_physdev() kdoc - Patch 15 and 16 (9 and 10 in v1) Use 'physdev' instead of 'supplier' (commit log, title and code) - Patch 17 (11 in v2) Enable fw_devlink on x86 only if PCI_DYNAMIC_OF_NODES is enabled. Rework commit log. - Patch 18, 19 and 20 (12, 13 and 14 in v1) No changes - Patch 21 (new in v2) Split dtso in dtsi/dtso - Patch 22 (new in v2) Rename lan966x_pci.dtso using the specific board name - Patch 23 (new in v2) Improve the driver introducing board specific data to ease support for other boards (avoid the direct dtbo reference in the function loading the dtbo). - Patch 24 (15 in v1) Refactor due to dtso split in dtsi/dtso - Patch 25 (new in v2) Sort exist driver list in Kconfig help - Patch 26 (16 in v1) Keep alphanumeric order for new drivers added in Kconfig help Herve Codina (26): driver core: Rename get_dev_from_fwnode() wrapper to get_device_from_fwnode() driver core: Avoid warning when removing a device while its supplier is unbinding bus: simple-pm-bus: Remove child devices when the bus is unbound bus: simple-pm-bus: Populate child nodes at probe driver core: fw_devlink: Introduce fw_devlink_set_device() drivers: core: Use fw_devlink_set_device() pinctrl: cs42l43: Use fw_devlink_set_device() cxl/test: Use device_set_node() cxl/test: Use fw_devlink_set_device() PCI: of: Use fw_devlink_set_device() PCI: of: Set fwnode device of newly created PCI device nodes PCI: of: Remove fwnode_dev_initialized() call for a PCI root bridge node i2c: core: Introduce i2c_get_adapter_physdev() i2c: mux: Set adapter physical device i2c: mux: Create missing devlink between mux and adapter physical device of: property: Allow fw_devlink device-tree on x86 clk: lan966x: Add MCHP_LAN966X_PCI dependency i2c: busses: at91: Add MCHP_LAN966X_PCI dependency misc: lan966x_pci: Fix dtso nodes ordering misc: lan966x_pci: Split dtso in dtsi/dtso misc: lan966x_pci: Rename lan966x_pci.dtso to lan966x_evb_lan9662_nic.dtso PCI: Add Microchip LAN9662 PCI Device ID misc: lan966x_pci: Introduce board specific data misc: lan966x_pci: Add dtsi/dtso nodes in order to support SFPs misc: lan966x_pci: Sort the drivers list in Kconfig help misc: lan966x_pci: Add drivers needed to support SFPs in Kconfig help Saravana Kannan (2): Revert "treewide: Fix probing of devices in DT overlays" of: dynamic: Fix overlayed devices not probing because of fw_devlink MAINTAINERS | 3 +- drivers/base/core.c | 108 ++++++++++--- drivers/bus/imx-weim.c | 6 - drivers/bus/simple-pm-bus.c | 24 +-- drivers/clk/Kconfig | 2 +- drivers/i2c/busses/Kconfig | 2 +- drivers/i2c/i2c-core-base.c | 16 ++ drivers/i2c/i2c-core-of.c | 5 - drivers/i2c/i2c-mux.c | 26 ++++ drivers/misc/Kconfig | 11 +- drivers/misc/Makefile | 2 +- drivers/misc/lan966x_evb_lan9662_nic.dtso | 167 ++++++++++++++++++++ drivers/misc/lan966x_pci.c | 30 +++- drivers/misc/lan966x_pci.dtsi | 172 +++++++++++++++++++++ drivers/misc/lan966x_pci.dtso | 177 ---------------------- drivers/of/dynamic.c | 1 - drivers/of/overlay.c | 15 ++ drivers/of/platform.c | 5 - drivers/of/property.c | 26 +++- drivers/pci/of.c | 10 +- drivers/pci/quirks.c | 2 +- drivers/pinctrl/cirrus/pinctrl-cs42l43.c | 2 +- drivers/pmdomain/core.c | 4 +- drivers/spi/spi.c | 5 - include/linux/device.h | 2 +- include/linux/fwnode.h | 7 + include/linux/i2c.h | 3 + include/linux/pci_ids.h | 1 + tools/testing/cxl/test/cxl.c | 4 +- 29 files changed, 584 insertions(+), 254 deletions(-) create mode 100644 drivers/misc/lan966x_evb_lan9662_nic.dtso create mode 100644 drivers/misc/lan966x_pci.dtsi delete mode 100644 drivers/misc/lan966x_pci.dtso -- 2.53.0
null
null
null
[PATCH v5 00/28] lan966x pci device: Add support for SFPs
From: Saravana Kannan <saravanak@google.com> When an overlay is applied, if the target device has already probed successfully and bound to a device, then some of the fw_devlink logic that ran when the device was probed needs to be rerun. This allows newly created dangling consumers of the overlayed device tree nodes to be moved to become consumers of the target device. Fixes: 1a50d9403fb9 ("treewide: Fix probing of devices in DT overlays") Reported-by: Herve Codina <herve.codina@bootlin.com> Closes: https://lore.kernel.org/lkml/CAMuHMdXEnSD4rRJ-o90x4OprUacN_rJgyo8x6=9F9rZ+-KzjOg@mail.gmail.com/ Closes: https://lore.kernel.org/all/20240221095137.616d2aaa@bootlin.com/ Closes: https://lore.kernel.org/lkml/20240312151835.29ef62a0@bootlin.com/ Signed-off-by: Saravana Kannan <saravanak@google.com> Link: https://lore.kernel.org/lkml/20240411235623.1260061-3-saravanak@google.com/ [Herve: Rebase on top of recent kernel and use get_device_from_fwnode()] [Herve: Add the call to driver_deferred_probe_trigger()] Signed-off-by: Herve Codina <herve.codina@bootlin.com> --- drivers/base/core.c | 83 +++++++++++++++++++++++++++++++++++++----- drivers/of/overlay.c | 15 ++++++++ include/linux/fwnode.h | 1 + 3 files changed, 90 insertions(+), 9 deletions(-) diff --git a/drivers/base/core.c b/drivers/base/core.c index 33c0ff2b162d..726e4af9b1a6 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c @@ -235,6 +235,79 @@ static void __fw_devlink_pickup_dangling_consumers(struct fwnode_handle *fwnode, __fw_devlink_pickup_dangling_consumers(child, new_sup); } +static void fw_devlink_pickup_dangling_consumers(struct device *dev) +{ + struct fwnode_handle *child; + + guard(mutex)(&fwnode_link_lock); + + fwnode_for_each_available_child_node(dev->fwnode, child) + __fw_devlink_pickup_dangling_consumers(child, dev->fwnode); + __fw_devlink_link_to_consumers(dev); +} + +/** + * fw_devlink_refresh_fwnode - Recheck the tree under this firmware node + * @fwnode: The fwnode under which the fwnode tree has changed + * + * This function is mainly meant to adjust the supplier/consumer dependencies + * after a fwnode tree overlay has occurred. + */ +void fw_devlink_refresh_fwnode(struct fwnode_handle *fwnode) +{ + struct device *dev; + + /* + * Find the closest ancestor fwnode that has been converted to a device + * that can bind to a driver (bus device). + */ + fwnode_handle_get(fwnode); + do { + if (fwnode->flags & FWNODE_FLAG_NOT_DEVICE) + continue; + + dev = get_device_from_fwnode(fwnode); + if (!dev) + continue; + + if (dev->bus) + break; + + put_device(dev); + } while ((fwnode = fwnode_get_next_parent(fwnode))); + + /* + * If none of the ancestor fwnodes have (yet) been converted to a device + * that can bind to a driver, there's nothing to fix up. + */ + if (!fwnode) + return; + + WARN(device_is_bound(dev) && dev->links.status != DL_DEV_DRIVER_BOUND, + "Don't multithread overlaying and probing the same device!\n"); + + /* + * If the device has already bound to a driver, then we need to redo + * some of the work that was done after the device was bound to a + * driver. If the device hasn't bound to a driver, running thing too + * soon would incorrectly pick up consumers that it shouldn't. + */ + if (dev->links.status == DL_DEV_DRIVER_BOUND) { + fw_devlink_pickup_dangling_consumers(dev); + /* + * Some of dangling consumers could have been put previously in + * the deferred probe list due to the unavailability of their + * suppliers. Those consumers have been picked up and some of + * their suppliers links have been update. Time to re-try their + * probe sequence. + */ + driver_deferred_probe_trigger(); + } + + put_device(dev); + fwnode_handle_put(fwnode); +} + static DEFINE_MUTEX(device_links_lock); DEFINE_STATIC_SRCU(device_links_srcu); @@ -1312,16 +1385,8 @@ void device_links_driver_bound(struct device *dev) * child firmware node. */ if (dev->fwnode && dev->fwnode->dev == dev) { - struct fwnode_handle *child; - fwnode_links_purge_suppliers(dev->fwnode); - - guard(mutex)(&fwnode_link_lock); - - fwnode_for_each_available_child_node(dev->fwnode, child) - __fw_devlink_pickup_dangling_consumers(child, - dev->fwnode); - __fw_devlink_link_to_consumers(dev); + fw_devlink_pickup_dangling_consumers(dev); } device_remove_file(dev, &dev_attr_waiting_for_supplier); diff --git a/drivers/of/overlay.c b/drivers/of/overlay.c index c1c5686fc7b1..4e45f3414c2c 100644 --- a/drivers/of/overlay.c +++ b/drivers/of/overlay.c @@ -185,6 +185,15 @@ static int overlay_notify(struct overlay_changeset *ovcs, return 0; } +static void overlay_fw_devlink_refresh(struct overlay_changeset *ovcs) +{ + for (int i = 0; i < ovcs->count; i++) { + struct device_node *np = ovcs->fragments[i].target; + + fw_devlink_refresh_fwnode(of_fwnode_handle(np)); + } +} + /* * The values of properties in the "/__symbols__" node are paths in * the ovcs->overlay_root. When duplicating the properties, the paths @@ -951,6 +960,12 @@ static int of_overlay_apply(struct overlay_changeset *ovcs, pr_err("overlay apply changeset entry notify error %d\n", ret); /* notify failure is not fatal, continue */ + /* + * Needs to happen after changeset notify to give the listeners a chance + * to finish creating all the devices they need to create. + */ + overlay_fw_devlink_refresh(ovcs); + ret_tmp = overlay_notify(ovcs, OF_OVERLAY_POST_APPLY); if (ret_tmp) if (!ret) diff --git a/include/linux/fwnode.h b/include/linux/fwnode.h index 097be89487bf..a921ca2fe940 100644 --- a/include/linux/fwnode.h +++ b/include/linux/fwnode.h @@ -228,6 +228,7 @@ int fwnode_link_add(struct fwnode_handle *con, struct fwnode_handle *sup, u8 flags); void fwnode_links_purge(struct fwnode_handle *fwnode); void fw_devlink_purge_absent_suppliers(struct fwnode_handle *fwnode); +void fw_devlink_refresh_fwnode(struct fwnode_handle *fwnode); bool fw_devlink_is_strict(void); #endif -- 2.53.0
{ "author": "Herve Codina <herve.codina@bootlin.com>", "date": "Fri, 27 Feb 2026 14:54:00 +0100", "is_openbsd": false, "thread_id": "20260227135428.783983-1-herve.codina@bootlin.com.mbox.gz" }
lkml_critique
lkml
Hi, This series add support for SFPs ports available on the LAN966x PCI device. In order to have the SFPs supported, additional devices are needed such as clock controller and I2C. As a reminder, the LAN966x PCI device driver use a device-tree overlay to describe devices available on the PCI board. Adding support for SFPs ports consists in adding more devices in the already existing device-tree overlay. With those devices added, the device-tree overlay is more complex and some consumer/supplier relationship are needed in order to remove devices in correct order when the LAN966x PCI driver is removed. Those links are typically provided by fw_devlink and we faced some issues with fw_devlink and overlays. This series gives the big picture related to the SFPs support from fixing issues to adding new devices. Of course, it can be split if needed. The first part of the series (patch 1, 2 and 3) fixes fw_devlink when it is used with overlay. Patches 1 and 3 were previously sent by Saravana [0]. I rebased them on top of v7.0-rc1 and added patch 2 in order to take into account feedback received on the series sent by Saravana. Also I added a call to driver_deferred_probe_trigger() in Saravana's patch (patch 3) to ensure that probes are retried after the modification performed on the dangling consumers. This allows to fix issues reported by Matti and Geert [2] with the previous iteration patches. Those modification were not sufficient in our case and so, on top of that, patches 4 to 6 fix some more issues related to fw_devlink. Patches 7 to 12 introduce and use fw_devlink_set_device() in already existing code. Patches 13 and 14 are related also to fw_devlink but specific to PCI and the device-tree nodes created during enumeration. Patches 15, 16 and 17 are related fw_devlink too but specific to I2C muxes. Patches purpose is to correctly set a link between an adapter supplier and its consumer. Indeed, an i2c mux adapter's parent is not the i2c mux supplier but the adapter the i2c mux is connected to. Adding a new link between the adapter supplier involved when i2c muxes are used avoid a freeze observed during device removal. Patch 18 adds support for fw_delink on x86. fw_devlink is needed to have the consumer/supplier relationship between devices in order to ensure a correct device removal order. Adding fw_devlink support for x86 has been tried in the past but was reverted [1] because it broke some systems. Instead of enabling fw_devlink on *all* x86 system, enable it on *all* x86 except on those where it leads to issue. Patches 19 and 20 allow to build clock and i2c controller used by the LAN966x PCI device when the LAN966x PCI device is enabled. Patches 21 to 25 are specific to the LAN966x. They touch the current dtso, split it in dtsi/dtso files, rename the dtso and improve the driver to allow easier support for other boards. The next patch (patch 26) update the LAN966x device-tree overlay itself to have the SPF ports and devices they depends on described. The last two patches (patches 27 and 29) sort the existing drivers in the needed driver list available in the Kconfig help and add new drivers in this list keep the list up to date with the devices described in the device-tree overlay. We believe some items from the above list can be merged separately, with no build dependencies. We expect: - Patches 1 to 6 to be taken by driver core maintainers - Patches 7 to 12 to be taken by driver core maintainers - Patches 13 and 14 to be taken by driver core or PCI maintainers (depend on patch 7) - Patches 15 to 17 to be taken by I2C maintainers - Patch 18 to be taken by driver core or OF maintainers - Patch 19 to be taken by clock maintainers - Patch 20 to be taken by I2C maintainers - Patches 21 to 28 to be taken by misc maintainers Once again, this series gives the big picture and can be split if needed. Let me know. Compare to previous iteration, this v5 series mainly: - Handle Matti and Geert use cases [2] - Remove simple-platform-bus driver introduced in v4 and switch the simple-bus modification back to what was proposed in v3. In the v4 iteration, conclusion was to use v3 changes [3]. [0] https://lore.kernel.org/lkml/20240411235623.1260061-1-saravanak@google.com/ [1] https://lore.kernel.org/lkml/3c1f2473-92ad-bfc4-258e-a5a08ad73dd0@web.de/ [2] https://lore.kernel.org/all/072dde7c-a53c-4525-83ac-57ea38edc0b5@gmail.com/ [3] https://lore.kernel.org/lkml/20251114083056.31553866@bootlin.com/ Best regards, Hervé Changes: v4 -> v5 v4: https://lore.kernel.org/lkml/20251015071420.1173068-1-herve.codina@bootlin.com/ - Patch 2: Add 'Acked-by: Ulf Hansson' - Patch 3: Add a call to driver_deferred_probe_trigger() - Patch 5: (new patch) Depopulate devices at remove - Patch 6: Populate devices at probe. Switched back to modification proposed in v3 - Patch 7 in v3 removed - Patch 7 (8 in v4): Add 'Reviewed-by: Andy Shevchenko' Add 'Reviewed-by: Ulf Hansson' - Patch 8 (9 in v4): Add 'Reviewed-by: Ulf Hansson' - Patches 9 to 15 (10 to 16 in v3) No changes - Patch 16 (17 in v4): Add 'Reviewed-by: Andi Shyti' - Patch 17 (18 in v4): Change an error code from -EINVAL to -ENODEV Add a blank line and fix a typo in commit log - Patch 18 (19 in v4): Simplify of_is_fwnode_add_links_supported(). Move IS_ENABLED(CONFIG_X86) check in of_is_fwnode_add_links_supported(). - Patches 19 to 21 (20 to 22 in v4) No changes - Patch 22 (23 in v4) Update due to simple-platform-bus removal - Patches 23 to 28 (24 to 29 in v4) No changes v3 -> v4 v3: https://lore.kernel.org/lkml/20250613134817.681832-1-herve.codina@bootlin.com/ - Patch 1: No change - Patch 2: Update and fix conflicts. Indeed, since v3 iteration get_dev_from_fwnode() has been moved to device.h and used by pmdomain/core.c. - Patch 3: remove '#define get_device_from_fwnode()' - Patch 4: Fix conflict (rebase v6.17-rc6) Add 'Reviewed-by: Rafael J. Wysocki' Add 'Reviewed-by: Saravana Kannan' - Patch 5 (new in v4): Introduce simple-platform-bus (binding) - Patch 6 (5 in v3): Rework patch and introduce simple-platform-bus - Patch 7: (new) Use simple-platform-bus in LAN966x - Patch 8 (6 in v3): - No change - Patch 9 and 10 (7 and 8 in v3): Add 'Reviewed-by: Andy Shevchenko' - Patch 11 and 12 (9 and 10 in v3): Add 'Reviewed-by: Dave Jiang' - Patch 13 (11 in v3): Add 'Reviewed-by: Andy Shevchenko' - Patch 12 in v3: Patch removed. Adding __private tag in fwnode.dev is going to be handled in a dedicated series. Indeed a test robot reported an issue and more patches are needed (I have missed fwnode.dev users in several part in the kernel). - Patch 14 and 15 (13 and 14 in v3): No change - Patch 16 (14 in v3): Add 'Reviewed-by: Andi Shyti' - Patch 17 and 18 (16 and 17 in v3): No change - Patch 19 (18 in v3): Filter out support for fw_devlink on x86 based on some device-tree properties. Rewrite commit changelog Remove 'Reviewed-by: Andy Shevchenko' (significant modification) - Patch 20 (19 in v3): Add 'Acked-by: Stephen Boyd' - Patch 21 (20 in v3): Fix conflict (rebase v6.18-rc1) - Patches 22 to 24 (21 to 23 in v3): No change - Patch 25 (24 in v3): Fix conflict (rebase v6.18-rc1) Add 'Acked-by: Bjorn Helgaas' - Patches 26 to 29 (25 to 28 in v3): No change v2 -> v3 v2: https://lore.kernel.org/all/20250507071315.394857-1-herve.codina@bootlin.com/ - Patch 1: Add 'Acked-by: Mark Brown' - Patch 2 and 3: No changes - Patch 4: Rewrite the WARN_ON() condition to avoid an additional 'if' - Patch 5: Fix typos in commit log Update a comment Remove the unneeded check before calling of_platform_depopulate() - Patches 6 to 11: No changes - Patch 12 (new in v3) Tag the fwnode dev member as private - Patch 13 (12 in v2) Fix a typo in the commit log - Patches 14 to 16 (13 to 15 in v2) No changes - Patch 17 (16 in v2) Check parent_physdev for NULL - Patch 18 (17 in v2) Capitalize "Link:" Add 'Reviewed-by: Andy Shevchenko' - Patch 19 (18 in v2) No changes - Patch 20 (19 in v2) Add 'Acked-by: Andi Shyti' - Patch 21 (20 in v2) No changes - Patch 22 (21 in v2) Add 'Reviewed-by: Andrew Lunn' - Patch 23 (22 in v2) Add 'Reviewed-by: Andrew Lunn' - Patch 24 (new in v3) Introduce PCI_DEVICE_ID_EFAR_LAN9662, the LAN966x PCI device ID - Patch 25 (23 in v2) Add 'Reviewed-by: Andrew Lunn' Use PCI_DEVICE_DATA() with PCI_DEVICE_ID_EFAR_LAN9662 instead of PCI_VDEVICE() - Patch 26 to 28 (24 to 26 in v2) No changes v1 -> v2 v1: https://lore.kernel.org/lkml/20250407145546.270683-1-herve.codina@bootlin.com/ - Patch 1 and 3 Remove 'From' tag from the commit log - Patch 2 Add 'Reviewed-by: Andy Shevchenko' Add 'Reviewed-by: Saravana Kannan' Add 'Reviewed-by: Luca Ceresoli' - Patch 4 and 5 No changes - Patch 6 (new in v2) Introduce fw_devlink_set_device() - Patch 7 (new in v2) Use existing device_set_node() helper. - Patch 8 to 11 (new in v2) Use fw_devlink_set_device() in existing code. - Patch 12 (6 in v1) Use fw_devlink_add_device() - Patch 13 (7 in v1) No changes - Patch 14 (8 in v1) Update commit log Use 'physdev' instead of 'supplier' Minor fixes in i2c_get_adapter_physdev() kdoc - Patch 15 and 16 (9 and 10 in v1) Use 'physdev' instead of 'supplier' (commit log, title and code) - Patch 17 (11 in v2) Enable fw_devlink on x86 only if PCI_DYNAMIC_OF_NODES is enabled. Rework commit log. - Patch 18, 19 and 20 (12, 13 and 14 in v1) No changes - Patch 21 (new in v2) Split dtso in dtsi/dtso - Patch 22 (new in v2) Rename lan966x_pci.dtso using the specific board name - Patch 23 (new in v2) Improve the driver introducing board specific data to ease support for other boards (avoid the direct dtbo reference in the function loading the dtbo). - Patch 24 (15 in v1) Refactor due to dtso split in dtsi/dtso - Patch 25 (new in v2) Sort exist driver list in Kconfig help - Patch 26 (16 in v1) Keep alphanumeric order for new drivers added in Kconfig help Herve Codina (26): driver core: Rename get_dev_from_fwnode() wrapper to get_device_from_fwnode() driver core: Avoid warning when removing a device while its supplier is unbinding bus: simple-pm-bus: Remove child devices when the bus is unbound bus: simple-pm-bus: Populate child nodes at probe driver core: fw_devlink: Introduce fw_devlink_set_device() drivers: core: Use fw_devlink_set_device() pinctrl: cs42l43: Use fw_devlink_set_device() cxl/test: Use device_set_node() cxl/test: Use fw_devlink_set_device() PCI: of: Use fw_devlink_set_device() PCI: of: Set fwnode device of newly created PCI device nodes PCI: of: Remove fwnode_dev_initialized() call for a PCI root bridge node i2c: core: Introduce i2c_get_adapter_physdev() i2c: mux: Set adapter physical device i2c: mux: Create missing devlink between mux and adapter physical device of: property: Allow fw_devlink device-tree on x86 clk: lan966x: Add MCHP_LAN966X_PCI dependency i2c: busses: at91: Add MCHP_LAN966X_PCI dependency misc: lan966x_pci: Fix dtso nodes ordering misc: lan966x_pci: Split dtso in dtsi/dtso misc: lan966x_pci: Rename lan966x_pci.dtso to lan966x_evb_lan9662_nic.dtso PCI: Add Microchip LAN9662 PCI Device ID misc: lan966x_pci: Introduce board specific data misc: lan966x_pci: Add dtsi/dtso nodes in order to support SFPs misc: lan966x_pci: Sort the drivers list in Kconfig help misc: lan966x_pci: Add drivers needed to support SFPs in Kconfig help Saravana Kannan (2): Revert "treewide: Fix probing of devices in DT overlays" of: dynamic: Fix overlayed devices not probing because of fw_devlink MAINTAINERS | 3 +- drivers/base/core.c | 108 ++++++++++--- drivers/bus/imx-weim.c | 6 - drivers/bus/simple-pm-bus.c | 24 +-- drivers/clk/Kconfig | 2 +- drivers/i2c/busses/Kconfig | 2 +- drivers/i2c/i2c-core-base.c | 16 ++ drivers/i2c/i2c-core-of.c | 5 - drivers/i2c/i2c-mux.c | 26 ++++ drivers/misc/Kconfig | 11 +- drivers/misc/Makefile | 2 +- drivers/misc/lan966x_evb_lan9662_nic.dtso | 167 ++++++++++++++++++++ drivers/misc/lan966x_pci.c | 30 +++- drivers/misc/lan966x_pci.dtsi | 172 +++++++++++++++++++++ drivers/misc/lan966x_pci.dtso | 177 ---------------------- drivers/of/dynamic.c | 1 - drivers/of/overlay.c | 15 ++ drivers/of/platform.c | 5 - drivers/of/property.c | 26 +++- drivers/pci/of.c | 10 +- drivers/pci/quirks.c | 2 +- drivers/pinctrl/cirrus/pinctrl-cs42l43.c | 2 +- drivers/pmdomain/core.c | 4 +- drivers/spi/spi.c | 5 - include/linux/device.h | 2 +- include/linux/fwnode.h | 7 + include/linux/i2c.h | 3 + include/linux/pci_ids.h | 1 + tools/testing/cxl/test/cxl.c | 4 +- 29 files changed, 584 insertions(+), 254 deletions(-) create mode 100644 drivers/misc/lan966x_evb_lan9662_nic.dtso create mode 100644 drivers/misc/lan966x_pci.dtsi delete mode 100644 drivers/misc/lan966x_pci.dtso -- 2.53.0
null
null
null
[PATCH v5 00/28] lan966x pci device: Add support for SFPs
During driver removal, the following warning can appear: WARNING: CPU: 1 PID: 139 at drivers/base/core.c:1497 __device_links_no_driver+0xcc/0xfc ... Call trace: __device_links_no_driver+0xcc/0xfc (P) device_links_driver_cleanup+0xa8/0xf0 device_release_driver_internal+0x208/0x23c device_links_unbind_consumers+0xe0/0x108 device_release_driver_internal+0xec/0x23c device_links_unbind_consumers+0xe0/0x108 device_release_driver_internal+0xec/0x23c device_links_unbind_consumers+0xe0/0x108 device_release_driver_internal+0xec/0x23c driver_detach+0xa0/0x12c bus_remove_driver+0x6c/0xbc driver_unregister+0x30/0x60 pci_unregister_driver+0x20/0x9c lan966x_pci_driver_exit+0x18/0xa90 [lan966x_pci] This warning is triggered when a consumer is removed because the links status of its supplier is not DL_DEV_DRIVER_BOUND and the link flag DL_FLAG_SYNC_STATE_ONLY is not set. The topology in terms of consumers/suppliers used was the following (consumer ---> supplier): i2c -----------> OIC ----> PCI device | ^ | | +---> pinctrl ---+ When the PCI device is removed, the OIC (interrupt controller) has to be removed. In order to remove the OIC, pinctrl and i2c need to be removed and to remove pinctrl, i2c need to be removed. The removal order is: 1) i2c 2) pinctrl 3) OIC 4) PCI device In details, the removal sequence is the following (with 0000:01:00.0 the PCI device): driver_detach: call device_release_driver_internal(0000:01:00.0)... device_links_busy(0000:01:00.0): links->status = DL_DEV_UNBINDING device_links_unbind_consumers(0000:01:00.0): 0000:01:00.0--oic link->status = DL_STATE_SUPPLIER_UNBIND call device_release_driver_internal(oic)... device_links_busy(oic): links->status = DL_DEV_UNBINDING device_links_unbind_consumers(oic): oic--pinctrl link->status = DL_STATE_SUPPLIER_UNBIND call device_release_driver_internal(pinctrl)... device_links_busy(pinctrl): links->status = DL_DEV_UNBINDING device_links_unbind_consumers(pinctrl): pinctrl--i2c link->status = DL_STATE_SUPPLIER_UNBIND call device_release_driver_internal(i2c)... device_links_busy(i2c): links->status = DL_DEV_UNBINDING __device_links_no_driver(i2c)... pinctrl--i2c link->status is DL_STATE_SUPPLIER_UNBIND oic--i2c link->status is DL_STATE_ACTIVE oic--i2c link->supplier->links.status is DL_DEV_UNBINDING The warning is triggered by the i2c removal because the OIC (supplier) links status is not DL_DEV_DRIVER_BOUND. Its links status is indeed set to DL_DEV_UNBINDING. It is perfectly legit to have the links status set to DL_DEV_UNBINDING in that case. Indeed we had started to unbind the OIC which triggered the consumer unbinding and didn't finish yet when the i2c is unbound. Avoid the warning when the supplier links status is set to DL_DEV_UNBINDING and thus support this removal sequence without any warnings. Signed-off-by: Herve Codina <herve.codina@bootlin.com> Reviewed-by: Rafael J. Wysocki <rafael@kernel.org> Reviewed-by: Saravana Kannan <saravanak@google.com> --- drivers/base/core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/base/core.c b/drivers/base/core.c index 726e4af9b1a6..a290bc8d2845 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c @@ -1500,7 +1500,8 @@ static void __device_links_no_driver(struct device *dev) if (link->supplier->links.status == DL_DEV_DRIVER_BOUND) { WRITE_ONCE(link->status, DL_STATE_AVAILABLE); } else { - WARN_ON(!device_link_test(link, DL_FLAG_SYNC_STATE_ONLY)); + WARN_ON(link->supplier->links.status != DL_DEV_UNBINDING && + !device_link_test(link, DL_FLAG_SYNC_STATE_ONLY)); WRITE_ONCE(link->status, DL_STATE_DORMANT); } } -- 2.53.0
{ "author": "Herve Codina <herve.codina@bootlin.com>", "date": "Fri, 27 Feb 2026 14:54:01 +0100", "is_openbsd": false, "thread_id": "20260227135428.783983-1-herve.codina@bootlin.com.mbox.gz" }
lkml_critique
lkml
Hi, This series add support for SFPs ports available on the LAN966x PCI device. In order to have the SFPs supported, additional devices are needed such as clock controller and I2C. As a reminder, the LAN966x PCI device driver use a device-tree overlay to describe devices available on the PCI board. Adding support for SFPs ports consists in adding more devices in the already existing device-tree overlay. With those devices added, the device-tree overlay is more complex and some consumer/supplier relationship are needed in order to remove devices in correct order when the LAN966x PCI driver is removed. Those links are typically provided by fw_devlink and we faced some issues with fw_devlink and overlays. This series gives the big picture related to the SFPs support from fixing issues to adding new devices. Of course, it can be split if needed. The first part of the series (patch 1, 2 and 3) fixes fw_devlink when it is used with overlay. Patches 1 and 3 were previously sent by Saravana [0]. I rebased them on top of v7.0-rc1 and added patch 2 in order to take into account feedback received on the series sent by Saravana. Also I added a call to driver_deferred_probe_trigger() in Saravana's patch (patch 3) to ensure that probes are retried after the modification performed on the dangling consumers. This allows to fix issues reported by Matti and Geert [2] with the previous iteration patches. Those modification were not sufficient in our case and so, on top of that, patches 4 to 6 fix some more issues related to fw_devlink. Patches 7 to 12 introduce and use fw_devlink_set_device() in already existing code. Patches 13 and 14 are related also to fw_devlink but specific to PCI and the device-tree nodes created during enumeration. Patches 15, 16 and 17 are related fw_devlink too but specific to I2C muxes. Patches purpose is to correctly set a link between an adapter supplier and its consumer. Indeed, an i2c mux adapter's parent is not the i2c mux supplier but the adapter the i2c mux is connected to. Adding a new link between the adapter supplier involved when i2c muxes are used avoid a freeze observed during device removal. Patch 18 adds support for fw_delink on x86. fw_devlink is needed to have the consumer/supplier relationship between devices in order to ensure a correct device removal order. Adding fw_devlink support for x86 has been tried in the past but was reverted [1] because it broke some systems. Instead of enabling fw_devlink on *all* x86 system, enable it on *all* x86 except on those where it leads to issue. Patches 19 and 20 allow to build clock and i2c controller used by the LAN966x PCI device when the LAN966x PCI device is enabled. Patches 21 to 25 are specific to the LAN966x. They touch the current dtso, split it in dtsi/dtso files, rename the dtso and improve the driver to allow easier support for other boards. The next patch (patch 26) update the LAN966x device-tree overlay itself to have the SPF ports and devices they depends on described. The last two patches (patches 27 and 29) sort the existing drivers in the needed driver list available in the Kconfig help and add new drivers in this list keep the list up to date with the devices described in the device-tree overlay. We believe some items from the above list can be merged separately, with no build dependencies. We expect: - Patches 1 to 6 to be taken by driver core maintainers - Patches 7 to 12 to be taken by driver core maintainers - Patches 13 and 14 to be taken by driver core or PCI maintainers (depend on patch 7) - Patches 15 to 17 to be taken by I2C maintainers - Patch 18 to be taken by driver core or OF maintainers - Patch 19 to be taken by clock maintainers - Patch 20 to be taken by I2C maintainers - Patches 21 to 28 to be taken by misc maintainers Once again, this series gives the big picture and can be split if needed. Let me know. Compare to previous iteration, this v5 series mainly: - Handle Matti and Geert use cases [2] - Remove simple-platform-bus driver introduced in v4 and switch the simple-bus modification back to what was proposed in v3. In the v4 iteration, conclusion was to use v3 changes [3]. [0] https://lore.kernel.org/lkml/20240411235623.1260061-1-saravanak@google.com/ [1] https://lore.kernel.org/lkml/3c1f2473-92ad-bfc4-258e-a5a08ad73dd0@web.de/ [2] https://lore.kernel.org/all/072dde7c-a53c-4525-83ac-57ea38edc0b5@gmail.com/ [3] https://lore.kernel.org/lkml/20251114083056.31553866@bootlin.com/ Best regards, Hervé Changes: v4 -> v5 v4: https://lore.kernel.org/lkml/20251015071420.1173068-1-herve.codina@bootlin.com/ - Patch 2: Add 'Acked-by: Ulf Hansson' - Patch 3: Add a call to driver_deferred_probe_trigger() - Patch 5: (new patch) Depopulate devices at remove - Patch 6: Populate devices at probe. Switched back to modification proposed in v3 - Patch 7 in v3 removed - Patch 7 (8 in v4): Add 'Reviewed-by: Andy Shevchenko' Add 'Reviewed-by: Ulf Hansson' - Patch 8 (9 in v4): Add 'Reviewed-by: Ulf Hansson' - Patches 9 to 15 (10 to 16 in v3) No changes - Patch 16 (17 in v4): Add 'Reviewed-by: Andi Shyti' - Patch 17 (18 in v4): Change an error code from -EINVAL to -ENODEV Add a blank line and fix a typo in commit log - Patch 18 (19 in v4): Simplify of_is_fwnode_add_links_supported(). Move IS_ENABLED(CONFIG_X86) check in of_is_fwnode_add_links_supported(). - Patches 19 to 21 (20 to 22 in v4) No changes - Patch 22 (23 in v4) Update due to simple-platform-bus removal - Patches 23 to 28 (24 to 29 in v4) No changes v3 -> v4 v3: https://lore.kernel.org/lkml/20250613134817.681832-1-herve.codina@bootlin.com/ - Patch 1: No change - Patch 2: Update and fix conflicts. Indeed, since v3 iteration get_dev_from_fwnode() has been moved to device.h and used by pmdomain/core.c. - Patch 3: remove '#define get_device_from_fwnode()' - Patch 4: Fix conflict (rebase v6.17-rc6) Add 'Reviewed-by: Rafael J. Wysocki' Add 'Reviewed-by: Saravana Kannan' - Patch 5 (new in v4): Introduce simple-platform-bus (binding) - Patch 6 (5 in v3): Rework patch and introduce simple-platform-bus - Patch 7: (new) Use simple-platform-bus in LAN966x - Patch 8 (6 in v3): - No change - Patch 9 and 10 (7 and 8 in v3): Add 'Reviewed-by: Andy Shevchenko' - Patch 11 and 12 (9 and 10 in v3): Add 'Reviewed-by: Dave Jiang' - Patch 13 (11 in v3): Add 'Reviewed-by: Andy Shevchenko' - Patch 12 in v3: Patch removed. Adding __private tag in fwnode.dev is going to be handled in a dedicated series. Indeed a test robot reported an issue and more patches are needed (I have missed fwnode.dev users in several part in the kernel). - Patch 14 and 15 (13 and 14 in v3): No change - Patch 16 (14 in v3): Add 'Reviewed-by: Andi Shyti' - Patch 17 and 18 (16 and 17 in v3): No change - Patch 19 (18 in v3): Filter out support for fw_devlink on x86 based on some device-tree properties. Rewrite commit changelog Remove 'Reviewed-by: Andy Shevchenko' (significant modification) - Patch 20 (19 in v3): Add 'Acked-by: Stephen Boyd' - Patch 21 (20 in v3): Fix conflict (rebase v6.18-rc1) - Patches 22 to 24 (21 to 23 in v3): No change - Patch 25 (24 in v3): Fix conflict (rebase v6.18-rc1) Add 'Acked-by: Bjorn Helgaas' - Patches 26 to 29 (25 to 28 in v3): No change v2 -> v3 v2: https://lore.kernel.org/all/20250507071315.394857-1-herve.codina@bootlin.com/ - Patch 1: Add 'Acked-by: Mark Brown' - Patch 2 and 3: No changes - Patch 4: Rewrite the WARN_ON() condition to avoid an additional 'if' - Patch 5: Fix typos in commit log Update a comment Remove the unneeded check before calling of_platform_depopulate() - Patches 6 to 11: No changes - Patch 12 (new in v3) Tag the fwnode dev member as private - Patch 13 (12 in v2) Fix a typo in the commit log - Patches 14 to 16 (13 to 15 in v2) No changes - Patch 17 (16 in v2) Check parent_physdev for NULL - Patch 18 (17 in v2) Capitalize "Link:" Add 'Reviewed-by: Andy Shevchenko' - Patch 19 (18 in v2) No changes - Patch 20 (19 in v2) Add 'Acked-by: Andi Shyti' - Patch 21 (20 in v2) No changes - Patch 22 (21 in v2) Add 'Reviewed-by: Andrew Lunn' - Patch 23 (22 in v2) Add 'Reviewed-by: Andrew Lunn' - Patch 24 (new in v3) Introduce PCI_DEVICE_ID_EFAR_LAN9662, the LAN966x PCI device ID - Patch 25 (23 in v2) Add 'Reviewed-by: Andrew Lunn' Use PCI_DEVICE_DATA() with PCI_DEVICE_ID_EFAR_LAN9662 instead of PCI_VDEVICE() - Patch 26 to 28 (24 to 26 in v2) No changes v1 -> v2 v1: https://lore.kernel.org/lkml/20250407145546.270683-1-herve.codina@bootlin.com/ - Patch 1 and 3 Remove 'From' tag from the commit log - Patch 2 Add 'Reviewed-by: Andy Shevchenko' Add 'Reviewed-by: Saravana Kannan' Add 'Reviewed-by: Luca Ceresoli' - Patch 4 and 5 No changes - Patch 6 (new in v2) Introduce fw_devlink_set_device() - Patch 7 (new in v2) Use existing device_set_node() helper. - Patch 8 to 11 (new in v2) Use fw_devlink_set_device() in existing code. - Patch 12 (6 in v1) Use fw_devlink_add_device() - Patch 13 (7 in v1) No changes - Patch 14 (8 in v1) Update commit log Use 'physdev' instead of 'supplier' Minor fixes in i2c_get_adapter_physdev() kdoc - Patch 15 and 16 (9 and 10 in v1) Use 'physdev' instead of 'supplier' (commit log, title and code) - Patch 17 (11 in v2) Enable fw_devlink on x86 only if PCI_DYNAMIC_OF_NODES is enabled. Rework commit log. - Patch 18, 19 and 20 (12, 13 and 14 in v1) No changes - Patch 21 (new in v2) Split dtso in dtsi/dtso - Patch 22 (new in v2) Rename lan966x_pci.dtso using the specific board name - Patch 23 (new in v2) Improve the driver introducing board specific data to ease support for other boards (avoid the direct dtbo reference in the function loading the dtbo). - Patch 24 (15 in v1) Refactor due to dtso split in dtsi/dtso - Patch 25 (new in v2) Sort exist driver list in Kconfig help - Patch 26 (16 in v1) Keep alphanumeric order for new drivers added in Kconfig help Herve Codina (26): driver core: Rename get_dev_from_fwnode() wrapper to get_device_from_fwnode() driver core: Avoid warning when removing a device while its supplier is unbinding bus: simple-pm-bus: Remove child devices when the bus is unbound bus: simple-pm-bus: Populate child nodes at probe driver core: fw_devlink: Introduce fw_devlink_set_device() drivers: core: Use fw_devlink_set_device() pinctrl: cs42l43: Use fw_devlink_set_device() cxl/test: Use device_set_node() cxl/test: Use fw_devlink_set_device() PCI: of: Use fw_devlink_set_device() PCI: of: Set fwnode device of newly created PCI device nodes PCI: of: Remove fwnode_dev_initialized() call for a PCI root bridge node i2c: core: Introduce i2c_get_adapter_physdev() i2c: mux: Set adapter physical device i2c: mux: Create missing devlink between mux and adapter physical device of: property: Allow fw_devlink device-tree on x86 clk: lan966x: Add MCHP_LAN966X_PCI dependency i2c: busses: at91: Add MCHP_LAN966X_PCI dependency misc: lan966x_pci: Fix dtso nodes ordering misc: lan966x_pci: Split dtso in dtsi/dtso misc: lan966x_pci: Rename lan966x_pci.dtso to lan966x_evb_lan9662_nic.dtso PCI: Add Microchip LAN9662 PCI Device ID misc: lan966x_pci: Introduce board specific data misc: lan966x_pci: Add dtsi/dtso nodes in order to support SFPs misc: lan966x_pci: Sort the drivers list in Kconfig help misc: lan966x_pci: Add drivers needed to support SFPs in Kconfig help Saravana Kannan (2): Revert "treewide: Fix probing of devices in DT overlays" of: dynamic: Fix overlayed devices not probing because of fw_devlink MAINTAINERS | 3 +- drivers/base/core.c | 108 ++++++++++--- drivers/bus/imx-weim.c | 6 - drivers/bus/simple-pm-bus.c | 24 +-- drivers/clk/Kconfig | 2 +- drivers/i2c/busses/Kconfig | 2 +- drivers/i2c/i2c-core-base.c | 16 ++ drivers/i2c/i2c-core-of.c | 5 - drivers/i2c/i2c-mux.c | 26 ++++ drivers/misc/Kconfig | 11 +- drivers/misc/Makefile | 2 +- drivers/misc/lan966x_evb_lan9662_nic.dtso | 167 ++++++++++++++++++++ drivers/misc/lan966x_pci.c | 30 +++- drivers/misc/lan966x_pci.dtsi | 172 +++++++++++++++++++++ drivers/misc/lan966x_pci.dtso | 177 ---------------------- drivers/of/dynamic.c | 1 - drivers/of/overlay.c | 15 ++ drivers/of/platform.c | 5 - drivers/of/property.c | 26 +++- drivers/pci/of.c | 10 +- drivers/pci/quirks.c | 2 +- drivers/pinctrl/cirrus/pinctrl-cs42l43.c | 2 +- drivers/pmdomain/core.c | 4 +- drivers/spi/spi.c | 5 - include/linux/device.h | 2 +- include/linux/fwnode.h | 7 + include/linux/i2c.h | 3 + include/linux/pci_ids.h | 1 + tools/testing/cxl/test/cxl.c | 4 +- 29 files changed, 584 insertions(+), 254 deletions(-) create mode 100644 drivers/misc/lan966x_evb_lan9662_nic.dtso create mode 100644 drivers/misc/lan966x_pci.dtsi delete mode 100644 drivers/misc/lan966x_pci.dtso -- 2.53.0
null
null
null
[PATCH v5 00/28] lan966x pci device: Add support for SFPs
During its probe, the simple-pm-bus driver (simple-pm-bus compatible variant) populates its child devices but it doesn't touch them during its removal. This leads to bus child devices present and bound to drivers whereas the bus itself is unbound. Be consistent and remove child devices when the bus itself is unbound. Signed-off-by: Herve Codina <herve.codina@bootlin.com> --- drivers/bus/simple-pm-bus.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/bus/simple-pm-bus.c b/drivers/bus/simple-pm-bus.c index 3f00d953fb9a..9ebd588ea24f 100644 --- a/drivers/bus/simple-pm-bus.c +++ b/drivers/bus/simple-pm-bus.c @@ -83,6 +83,9 @@ static void simple_pm_bus_remove(struct platform_device *pdev) dev_dbg(&pdev->dev, "%s\n", __func__); + if (pdev->dev.of_node) + of_platform_depopulate(&pdev->dev); + pm_runtime_disable(&pdev->dev); } -- 2.53.0
{ "author": "Herve Codina <herve.codina@bootlin.com>", "date": "Fri, 27 Feb 2026 14:54:02 +0100", "is_openbsd": false, "thread_id": "20260227135428.783983-1-herve.codina@bootlin.com.mbox.gz" }
lkml_critique
lkml
Hi, This series add support for SFPs ports available on the LAN966x PCI device. In order to have the SFPs supported, additional devices are needed such as clock controller and I2C. As a reminder, the LAN966x PCI device driver use a device-tree overlay to describe devices available on the PCI board. Adding support for SFPs ports consists in adding more devices in the already existing device-tree overlay. With those devices added, the device-tree overlay is more complex and some consumer/supplier relationship are needed in order to remove devices in correct order when the LAN966x PCI driver is removed. Those links are typically provided by fw_devlink and we faced some issues with fw_devlink and overlays. This series gives the big picture related to the SFPs support from fixing issues to adding new devices. Of course, it can be split if needed. The first part of the series (patch 1, 2 and 3) fixes fw_devlink when it is used with overlay. Patches 1 and 3 were previously sent by Saravana [0]. I rebased them on top of v7.0-rc1 and added patch 2 in order to take into account feedback received on the series sent by Saravana. Also I added a call to driver_deferred_probe_trigger() in Saravana's patch (patch 3) to ensure that probes are retried after the modification performed on the dangling consumers. This allows to fix issues reported by Matti and Geert [2] with the previous iteration patches. Those modification were not sufficient in our case and so, on top of that, patches 4 to 6 fix some more issues related to fw_devlink. Patches 7 to 12 introduce and use fw_devlink_set_device() in already existing code. Patches 13 and 14 are related also to fw_devlink but specific to PCI and the device-tree nodes created during enumeration. Patches 15, 16 and 17 are related fw_devlink too but specific to I2C muxes. Patches purpose is to correctly set a link between an adapter supplier and its consumer. Indeed, an i2c mux adapter's parent is not the i2c mux supplier but the adapter the i2c mux is connected to. Adding a new link between the adapter supplier involved when i2c muxes are used avoid a freeze observed during device removal. Patch 18 adds support for fw_delink on x86. fw_devlink is needed to have the consumer/supplier relationship between devices in order to ensure a correct device removal order. Adding fw_devlink support for x86 has been tried in the past but was reverted [1] because it broke some systems. Instead of enabling fw_devlink on *all* x86 system, enable it on *all* x86 except on those where it leads to issue. Patches 19 and 20 allow to build clock and i2c controller used by the LAN966x PCI device when the LAN966x PCI device is enabled. Patches 21 to 25 are specific to the LAN966x. They touch the current dtso, split it in dtsi/dtso files, rename the dtso and improve the driver to allow easier support for other boards. The next patch (patch 26) update the LAN966x device-tree overlay itself to have the SPF ports and devices they depends on described. The last two patches (patches 27 and 29) sort the existing drivers in the needed driver list available in the Kconfig help and add new drivers in this list keep the list up to date with the devices described in the device-tree overlay. We believe some items from the above list can be merged separately, with no build dependencies. We expect: - Patches 1 to 6 to be taken by driver core maintainers - Patches 7 to 12 to be taken by driver core maintainers - Patches 13 and 14 to be taken by driver core or PCI maintainers (depend on patch 7) - Patches 15 to 17 to be taken by I2C maintainers - Patch 18 to be taken by driver core or OF maintainers - Patch 19 to be taken by clock maintainers - Patch 20 to be taken by I2C maintainers - Patches 21 to 28 to be taken by misc maintainers Once again, this series gives the big picture and can be split if needed. Let me know. Compare to previous iteration, this v5 series mainly: - Handle Matti and Geert use cases [2] - Remove simple-platform-bus driver introduced in v4 and switch the simple-bus modification back to what was proposed in v3. In the v4 iteration, conclusion was to use v3 changes [3]. [0] https://lore.kernel.org/lkml/20240411235623.1260061-1-saravanak@google.com/ [1] https://lore.kernel.org/lkml/3c1f2473-92ad-bfc4-258e-a5a08ad73dd0@web.de/ [2] https://lore.kernel.org/all/072dde7c-a53c-4525-83ac-57ea38edc0b5@gmail.com/ [3] https://lore.kernel.org/lkml/20251114083056.31553866@bootlin.com/ Best regards, Hervé Changes: v4 -> v5 v4: https://lore.kernel.org/lkml/20251015071420.1173068-1-herve.codina@bootlin.com/ - Patch 2: Add 'Acked-by: Ulf Hansson' - Patch 3: Add a call to driver_deferred_probe_trigger() - Patch 5: (new patch) Depopulate devices at remove - Patch 6: Populate devices at probe. Switched back to modification proposed in v3 - Patch 7 in v3 removed - Patch 7 (8 in v4): Add 'Reviewed-by: Andy Shevchenko' Add 'Reviewed-by: Ulf Hansson' - Patch 8 (9 in v4): Add 'Reviewed-by: Ulf Hansson' - Patches 9 to 15 (10 to 16 in v3) No changes - Patch 16 (17 in v4): Add 'Reviewed-by: Andi Shyti' - Patch 17 (18 in v4): Change an error code from -EINVAL to -ENODEV Add a blank line and fix a typo in commit log - Patch 18 (19 in v4): Simplify of_is_fwnode_add_links_supported(). Move IS_ENABLED(CONFIG_X86) check in of_is_fwnode_add_links_supported(). - Patches 19 to 21 (20 to 22 in v4) No changes - Patch 22 (23 in v4) Update due to simple-platform-bus removal - Patches 23 to 28 (24 to 29 in v4) No changes v3 -> v4 v3: https://lore.kernel.org/lkml/20250613134817.681832-1-herve.codina@bootlin.com/ - Patch 1: No change - Patch 2: Update and fix conflicts. Indeed, since v3 iteration get_dev_from_fwnode() has been moved to device.h and used by pmdomain/core.c. - Patch 3: remove '#define get_device_from_fwnode()' - Patch 4: Fix conflict (rebase v6.17-rc6) Add 'Reviewed-by: Rafael J. Wysocki' Add 'Reviewed-by: Saravana Kannan' - Patch 5 (new in v4): Introduce simple-platform-bus (binding) - Patch 6 (5 in v3): Rework patch and introduce simple-platform-bus - Patch 7: (new) Use simple-platform-bus in LAN966x - Patch 8 (6 in v3): - No change - Patch 9 and 10 (7 and 8 in v3): Add 'Reviewed-by: Andy Shevchenko' - Patch 11 and 12 (9 and 10 in v3): Add 'Reviewed-by: Dave Jiang' - Patch 13 (11 in v3): Add 'Reviewed-by: Andy Shevchenko' - Patch 12 in v3: Patch removed. Adding __private tag in fwnode.dev is going to be handled in a dedicated series. Indeed a test robot reported an issue and more patches are needed (I have missed fwnode.dev users in several part in the kernel). - Patch 14 and 15 (13 and 14 in v3): No change - Patch 16 (14 in v3): Add 'Reviewed-by: Andi Shyti' - Patch 17 and 18 (16 and 17 in v3): No change - Patch 19 (18 in v3): Filter out support for fw_devlink on x86 based on some device-tree properties. Rewrite commit changelog Remove 'Reviewed-by: Andy Shevchenko' (significant modification) - Patch 20 (19 in v3): Add 'Acked-by: Stephen Boyd' - Patch 21 (20 in v3): Fix conflict (rebase v6.18-rc1) - Patches 22 to 24 (21 to 23 in v3): No change - Patch 25 (24 in v3): Fix conflict (rebase v6.18-rc1) Add 'Acked-by: Bjorn Helgaas' - Patches 26 to 29 (25 to 28 in v3): No change v2 -> v3 v2: https://lore.kernel.org/all/20250507071315.394857-1-herve.codina@bootlin.com/ - Patch 1: Add 'Acked-by: Mark Brown' - Patch 2 and 3: No changes - Patch 4: Rewrite the WARN_ON() condition to avoid an additional 'if' - Patch 5: Fix typos in commit log Update a comment Remove the unneeded check before calling of_platform_depopulate() - Patches 6 to 11: No changes - Patch 12 (new in v3) Tag the fwnode dev member as private - Patch 13 (12 in v2) Fix a typo in the commit log - Patches 14 to 16 (13 to 15 in v2) No changes - Patch 17 (16 in v2) Check parent_physdev for NULL - Patch 18 (17 in v2) Capitalize "Link:" Add 'Reviewed-by: Andy Shevchenko' - Patch 19 (18 in v2) No changes - Patch 20 (19 in v2) Add 'Acked-by: Andi Shyti' - Patch 21 (20 in v2) No changes - Patch 22 (21 in v2) Add 'Reviewed-by: Andrew Lunn' - Patch 23 (22 in v2) Add 'Reviewed-by: Andrew Lunn' - Patch 24 (new in v3) Introduce PCI_DEVICE_ID_EFAR_LAN9662, the LAN966x PCI device ID - Patch 25 (23 in v2) Add 'Reviewed-by: Andrew Lunn' Use PCI_DEVICE_DATA() with PCI_DEVICE_ID_EFAR_LAN9662 instead of PCI_VDEVICE() - Patch 26 to 28 (24 to 26 in v2) No changes v1 -> v2 v1: https://lore.kernel.org/lkml/20250407145546.270683-1-herve.codina@bootlin.com/ - Patch 1 and 3 Remove 'From' tag from the commit log - Patch 2 Add 'Reviewed-by: Andy Shevchenko' Add 'Reviewed-by: Saravana Kannan' Add 'Reviewed-by: Luca Ceresoli' - Patch 4 and 5 No changes - Patch 6 (new in v2) Introduce fw_devlink_set_device() - Patch 7 (new in v2) Use existing device_set_node() helper. - Patch 8 to 11 (new in v2) Use fw_devlink_set_device() in existing code. - Patch 12 (6 in v1) Use fw_devlink_add_device() - Patch 13 (7 in v1) No changes - Patch 14 (8 in v1) Update commit log Use 'physdev' instead of 'supplier' Minor fixes in i2c_get_adapter_physdev() kdoc - Patch 15 and 16 (9 and 10 in v1) Use 'physdev' instead of 'supplier' (commit log, title and code) - Patch 17 (11 in v2) Enable fw_devlink on x86 only if PCI_DYNAMIC_OF_NODES is enabled. Rework commit log. - Patch 18, 19 and 20 (12, 13 and 14 in v1) No changes - Patch 21 (new in v2) Split dtso in dtsi/dtso - Patch 22 (new in v2) Rename lan966x_pci.dtso using the specific board name - Patch 23 (new in v2) Improve the driver introducing board specific data to ease support for other boards (avoid the direct dtbo reference in the function loading the dtbo). - Patch 24 (15 in v1) Refactor due to dtso split in dtsi/dtso - Patch 25 (new in v2) Sort exist driver list in Kconfig help - Patch 26 (16 in v1) Keep alphanumeric order for new drivers added in Kconfig help Herve Codina (26): driver core: Rename get_dev_from_fwnode() wrapper to get_device_from_fwnode() driver core: Avoid warning when removing a device while its supplier is unbinding bus: simple-pm-bus: Remove child devices when the bus is unbound bus: simple-pm-bus: Populate child nodes at probe driver core: fw_devlink: Introduce fw_devlink_set_device() drivers: core: Use fw_devlink_set_device() pinctrl: cs42l43: Use fw_devlink_set_device() cxl/test: Use device_set_node() cxl/test: Use fw_devlink_set_device() PCI: of: Use fw_devlink_set_device() PCI: of: Set fwnode device of newly created PCI device nodes PCI: of: Remove fwnode_dev_initialized() call for a PCI root bridge node i2c: core: Introduce i2c_get_adapter_physdev() i2c: mux: Set adapter physical device i2c: mux: Create missing devlink between mux and adapter physical device of: property: Allow fw_devlink device-tree on x86 clk: lan966x: Add MCHP_LAN966X_PCI dependency i2c: busses: at91: Add MCHP_LAN966X_PCI dependency misc: lan966x_pci: Fix dtso nodes ordering misc: lan966x_pci: Split dtso in dtsi/dtso misc: lan966x_pci: Rename lan966x_pci.dtso to lan966x_evb_lan9662_nic.dtso PCI: Add Microchip LAN9662 PCI Device ID misc: lan966x_pci: Introduce board specific data misc: lan966x_pci: Add dtsi/dtso nodes in order to support SFPs misc: lan966x_pci: Sort the drivers list in Kconfig help misc: lan966x_pci: Add drivers needed to support SFPs in Kconfig help Saravana Kannan (2): Revert "treewide: Fix probing of devices in DT overlays" of: dynamic: Fix overlayed devices not probing because of fw_devlink MAINTAINERS | 3 +- drivers/base/core.c | 108 ++++++++++--- drivers/bus/imx-weim.c | 6 - drivers/bus/simple-pm-bus.c | 24 +-- drivers/clk/Kconfig | 2 +- drivers/i2c/busses/Kconfig | 2 +- drivers/i2c/i2c-core-base.c | 16 ++ drivers/i2c/i2c-core-of.c | 5 - drivers/i2c/i2c-mux.c | 26 ++++ drivers/misc/Kconfig | 11 +- drivers/misc/Makefile | 2 +- drivers/misc/lan966x_evb_lan9662_nic.dtso | 167 ++++++++++++++++++++ drivers/misc/lan966x_pci.c | 30 +++- drivers/misc/lan966x_pci.dtsi | 172 +++++++++++++++++++++ drivers/misc/lan966x_pci.dtso | 177 ---------------------- drivers/of/dynamic.c | 1 - drivers/of/overlay.c | 15 ++ drivers/of/platform.c | 5 - drivers/of/property.c | 26 +++- drivers/pci/of.c | 10 +- drivers/pci/quirks.c | 2 +- drivers/pinctrl/cirrus/pinctrl-cs42l43.c | 2 +- drivers/pmdomain/core.c | 4 +- drivers/spi/spi.c | 5 - include/linux/device.h | 2 +- include/linux/fwnode.h | 7 + include/linux/i2c.h | 3 + include/linux/pci_ids.h | 1 + tools/testing/cxl/test/cxl.c | 4 +- 29 files changed, 584 insertions(+), 254 deletions(-) create mode 100644 drivers/misc/lan966x_evb_lan9662_nic.dtso create mode 100644 drivers/misc/lan966x_pci.dtsi delete mode 100644 drivers/misc/lan966x_pci.dtso -- 2.53.0
null
null
null
[PATCH v5 00/28] lan966x pci device: Add support for SFPs
The simple-pm-bus driver handles several simple busses. When it is used with busses other than a compatible "simple-pm-bus", it doesn't populate its child devices during its probe. This confuses fw_devlink and results in wrong or missing devlinks. Once a driver is bound to a device and the probe() has been called, device_links_driver_bound() is called. This function performs operation based on the following assumption: If a child firmware node of the bound device is not added as a device, it will never be added. Among operations done on fw_devlinks of those "never be added" devices, device_links_driver_bound() changes their supplier. With devices attached to a simple-bus compatible device, this change leads to wrong devlinks where supplier of devices points to the device parent (i.e. simple-bus compatible device) instead of the device itself (i.e. simple-bus child). When the device attached to the simple-bus is removed, because devlinks are not correct, its consumers are not removed first. In order to have correct devlinks created, make the simple-pm-bus driver compliant with the devlink assumption and create its child devices during its probe. Signed-off-by: Herve Codina <herve.codina@bootlin.com> --- drivers/bus/simple-pm-bus.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/drivers/bus/simple-pm-bus.c b/drivers/bus/simple-pm-bus.c index 9ebd588ea24f..30628958c923 100644 --- a/drivers/bus/simple-pm-bus.c +++ b/drivers/bus/simple-pm-bus.c @@ -42,14 +42,15 @@ static int simple_pm_bus_probe(struct platform_device *pdev) match = of_match_device(dev->driver->of_match_table, dev); /* * These are transparent bus devices (not simple-pm-bus matches) that - * have their child nodes populated automatically. So, don't need to - * do anything more. We only match with the device if this driver is - * the most specific match because we don't want to incorrectly bind to - * a device that has a more specific driver. + * need to have their child nodes populated. So, don't need to do + * anything more except populate child nodes during this probe(). We + * only match with the device if this driver is the most specific match + * because we don't want to incorrectly bind to a device that has a more + * specific driver. */ if (match && match->data) { if (of_property_match_string(np, "compatible", match->compatible) == 0) - return 0; + goto populate; else return -ENODEV; } @@ -64,13 +65,14 @@ static int simple_pm_bus_probe(struct platform_device *pdev) dev_set_drvdata(&pdev->dev, bus); - dev_dbg(&pdev->dev, "%s\n", __func__); - pm_runtime_enable(&pdev->dev); +populate: if (np) of_platform_populate(np, NULL, lookup, &pdev->dev); + dev_dbg(&pdev->dev, "%s\n", __func__); + return 0; } @@ -78,7 +80,7 @@ static void simple_pm_bus_remove(struct platform_device *pdev) { const void *data = of_device_get_match_data(&pdev->dev); - if (pdev->driver_override || data) + if (pdev->driver_override) return; dev_dbg(&pdev->dev, "%s\n", __func__); @@ -86,7 +88,8 @@ static void simple_pm_bus_remove(struct platform_device *pdev) if (pdev->dev.of_node) of_platform_depopulate(&pdev->dev); - pm_runtime_disable(&pdev->dev); + if (!data) + pm_runtime_disable(&pdev->dev); } static int simple_pm_bus_runtime_suspend(struct device *dev) -- 2.53.0
{ "author": "Herve Codina <herve.codina@bootlin.com>", "date": "Fri, 27 Feb 2026 14:54:03 +0100", "is_openbsd": false, "thread_id": "20260227135428.783983-1-herve.codina@bootlin.com.mbox.gz" }
lkml_critique
lkml
Hi, This series add support for SFPs ports available on the LAN966x PCI device. In order to have the SFPs supported, additional devices are needed such as clock controller and I2C. As a reminder, the LAN966x PCI device driver use a device-tree overlay to describe devices available on the PCI board. Adding support for SFPs ports consists in adding more devices in the already existing device-tree overlay. With those devices added, the device-tree overlay is more complex and some consumer/supplier relationship are needed in order to remove devices in correct order when the LAN966x PCI driver is removed. Those links are typically provided by fw_devlink and we faced some issues with fw_devlink and overlays. This series gives the big picture related to the SFPs support from fixing issues to adding new devices. Of course, it can be split if needed. The first part of the series (patch 1, 2 and 3) fixes fw_devlink when it is used with overlay. Patches 1 and 3 were previously sent by Saravana [0]. I rebased them on top of v7.0-rc1 and added patch 2 in order to take into account feedback received on the series sent by Saravana. Also I added a call to driver_deferred_probe_trigger() in Saravana's patch (patch 3) to ensure that probes are retried after the modification performed on the dangling consumers. This allows to fix issues reported by Matti and Geert [2] with the previous iteration patches. Those modification were not sufficient in our case and so, on top of that, patches 4 to 6 fix some more issues related to fw_devlink. Patches 7 to 12 introduce and use fw_devlink_set_device() in already existing code. Patches 13 and 14 are related also to fw_devlink but specific to PCI and the device-tree nodes created during enumeration. Patches 15, 16 and 17 are related fw_devlink too but specific to I2C muxes. Patches purpose is to correctly set a link between an adapter supplier and its consumer. Indeed, an i2c mux adapter's parent is not the i2c mux supplier but the adapter the i2c mux is connected to. Adding a new link between the adapter supplier involved when i2c muxes are used avoid a freeze observed during device removal. Patch 18 adds support for fw_delink on x86. fw_devlink is needed to have the consumer/supplier relationship between devices in order to ensure a correct device removal order. Adding fw_devlink support for x86 has been tried in the past but was reverted [1] because it broke some systems. Instead of enabling fw_devlink on *all* x86 system, enable it on *all* x86 except on those where it leads to issue. Patches 19 and 20 allow to build clock and i2c controller used by the LAN966x PCI device when the LAN966x PCI device is enabled. Patches 21 to 25 are specific to the LAN966x. They touch the current dtso, split it in dtsi/dtso files, rename the dtso and improve the driver to allow easier support for other boards. The next patch (patch 26) update the LAN966x device-tree overlay itself to have the SPF ports and devices they depends on described. The last two patches (patches 27 and 29) sort the existing drivers in the needed driver list available in the Kconfig help and add new drivers in this list keep the list up to date with the devices described in the device-tree overlay. We believe some items from the above list can be merged separately, with no build dependencies. We expect: - Patches 1 to 6 to be taken by driver core maintainers - Patches 7 to 12 to be taken by driver core maintainers - Patches 13 and 14 to be taken by driver core or PCI maintainers (depend on patch 7) - Patches 15 to 17 to be taken by I2C maintainers - Patch 18 to be taken by driver core or OF maintainers - Patch 19 to be taken by clock maintainers - Patch 20 to be taken by I2C maintainers - Patches 21 to 28 to be taken by misc maintainers Once again, this series gives the big picture and can be split if needed. Let me know. Compare to previous iteration, this v5 series mainly: - Handle Matti and Geert use cases [2] - Remove simple-platform-bus driver introduced in v4 and switch the simple-bus modification back to what was proposed in v3. In the v4 iteration, conclusion was to use v3 changes [3]. [0] https://lore.kernel.org/lkml/20240411235623.1260061-1-saravanak@google.com/ [1] https://lore.kernel.org/lkml/3c1f2473-92ad-bfc4-258e-a5a08ad73dd0@web.de/ [2] https://lore.kernel.org/all/072dde7c-a53c-4525-83ac-57ea38edc0b5@gmail.com/ [3] https://lore.kernel.org/lkml/20251114083056.31553866@bootlin.com/ Best regards, Hervé Changes: v4 -> v5 v4: https://lore.kernel.org/lkml/20251015071420.1173068-1-herve.codina@bootlin.com/ - Patch 2: Add 'Acked-by: Ulf Hansson' - Patch 3: Add a call to driver_deferred_probe_trigger() - Patch 5: (new patch) Depopulate devices at remove - Patch 6: Populate devices at probe. Switched back to modification proposed in v3 - Patch 7 in v3 removed - Patch 7 (8 in v4): Add 'Reviewed-by: Andy Shevchenko' Add 'Reviewed-by: Ulf Hansson' - Patch 8 (9 in v4): Add 'Reviewed-by: Ulf Hansson' - Patches 9 to 15 (10 to 16 in v3) No changes - Patch 16 (17 in v4): Add 'Reviewed-by: Andi Shyti' - Patch 17 (18 in v4): Change an error code from -EINVAL to -ENODEV Add a blank line and fix a typo in commit log - Patch 18 (19 in v4): Simplify of_is_fwnode_add_links_supported(). Move IS_ENABLED(CONFIG_X86) check in of_is_fwnode_add_links_supported(). - Patches 19 to 21 (20 to 22 in v4) No changes - Patch 22 (23 in v4) Update due to simple-platform-bus removal - Patches 23 to 28 (24 to 29 in v4) No changes v3 -> v4 v3: https://lore.kernel.org/lkml/20250613134817.681832-1-herve.codina@bootlin.com/ - Patch 1: No change - Patch 2: Update and fix conflicts. Indeed, since v3 iteration get_dev_from_fwnode() has been moved to device.h and used by pmdomain/core.c. - Patch 3: remove '#define get_device_from_fwnode()' - Patch 4: Fix conflict (rebase v6.17-rc6) Add 'Reviewed-by: Rafael J. Wysocki' Add 'Reviewed-by: Saravana Kannan' - Patch 5 (new in v4): Introduce simple-platform-bus (binding) - Patch 6 (5 in v3): Rework patch and introduce simple-platform-bus - Patch 7: (new) Use simple-platform-bus in LAN966x - Patch 8 (6 in v3): - No change - Patch 9 and 10 (7 and 8 in v3): Add 'Reviewed-by: Andy Shevchenko' - Patch 11 and 12 (9 and 10 in v3): Add 'Reviewed-by: Dave Jiang' - Patch 13 (11 in v3): Add 'Reviewed-by: Andy Shevchenko' - Patch 12 in v3: Patch removed. Adding __private tag in fwnode.dev is going to be handled in a dedicated series. Indeed a test robot reported an issue and more patches are needed (I have missed fwnode.dev users in several part in the kernel). - Patch 14 and 15 (13 and 14 in v3): No change - Patch 16 (14 in v3): Add 'Reviewed-by: Andi Shyti' - Patch 17 and 18 (16 and 17 in v3): No change - Patch 19 (18 in v3): Filter out support for fw_devlink on x86 based on some device-tree properties. Rewrite commit changelog Remove 'Reviewed-by: Andy Shevchenko' (significant modification) - Patch 20 (19 in v3): Add 'Acked-by: Stephen Boyd' - Patch 21 (20 in v3): Fix conflict (rebase v6.18-rc1) - Patches 22 to 24 (21 to 23 in v3): No change - Patch 25 (24 in v3): Fix conflict (rebase v6.18-rc1) Add 'Acked-by: Bjorn Helgaas' - Patches 26 to 29 (25 to 28 in v3): No change v2 -> v3 v2: https://lore.kernel.org/all/20250507071315.394857-1-herve.codina@bootlin.com/ - Patch 1: Add 'Acked-by: Mark Brown' - Patch 2 and 3: No changes - Patch 4: Rewrite the WARN_ON() condition to avoid an additional 'if' - Patch 5: Fix typos in commit log Update a comment Remove the unneeded check before calling of_platform_depopulate() - Patches 6 to 11: No changes - Patch 12 (new in v3) Tag the fwnode dev member as private - Patch 13 (12 in v2) Fix a typo in the commit log - Patches 14 to 16 (13 to 15 in v2) No changes - Patch 17 (16 in v2) Check parent_physdev for NULL - Patch 18 (17 in v2) Capitalize "Link:" Add 'Reviewed-by: Andy Shevchenko' - Patch 19 (18 in v2) No changes - Patch 20 (19 in v2) Add 'Acked-by: Andi Shyti' - Patch 21 (20 in v2) No changes - Patch 22 (21 in v2) Add 'Reviewed-by: Andrew Lunn' - Patch 23 (22 in v2) Add 'Reviewed-by: Andrew Lunn' - Patch 24 (new in v3) Introduce PCI_DEVICE_ID_EFAR_LAN9662, the LAN966x PCI device ID - Patch 25 (23 in v2) Add 'Reviewed-by: Andrew Lunn' Use PCI_DEVICE_DATA() with PCI_DEVICE_ID_EFAR_LAN9662 instead of PCI_VDEVICE() - Patch 26 to 28 (24 to 26 in v2) No changes v1 -> v2 v1: https://lore.kernel.org/lkml/20250407145546.270683-1-herve.codina@bootlin.com/ - Patch 1 and 3 Remove 'From' tag from the commit log - Patch 2 Add 'Reviewed-by: Andy Shevchenko' Add 'Reviewed-by: Saravana Kannan' Add 'Reviewed-by: Luca Ceresoli' - Patch 4 and 5 No changes - Patch 6 (new in v2) Introduce fw_devlink_set_device() - Patch 7 (new in v2) Use existing device_set_node() helper. - Patch 8 to 11 (new in v2) Use fw_devlink_set_device() in existing code. - Patch 12 (6 in v1) Use fw_devlink_add_device() - Patch 13 (7 in v1) No changes - Patch 14 (8 in v1) Update commit log Use 'physdev' instead of 'supplier' Minor fixes in i2c_get_adapter_physdev() kdoc - Patch 15 and 16 (9 and 10 in v1) Use 'physdev' instead of 'supplier' (commit log, title and code) - Patch 17 (11 in v2) Enable fw_devlink on x86 only if PCI_DYNAMIC_OF_NODES is enabled. Rework commit log. - Patch 18, 19 and 20 (12, 13 and 14 in v1) No changes - Patch 21 (new in v2) Split dtso in dtsi/dtso - Patch 22 (new in v2) Rename lan966x_pci.dtso using the specific board name - Patch 23 (new in v2) Improve the driver introducing board specific data to ease support for other boards (avoid the direct dtbo reference in the function loading the dtbo). - Patch 24 (15 in v1) Refactor due to dtso split in dtsi/dtso - Patch 25 (new in v2) Sort exist driver list in Kconfig help - Patch 26 (16 in v1) Keep alphanumeric order for new drivers added in Kconfig help Herve Codina (26): driver core: Rename get_dev_from_fwnode() wrapper to get_device_from_fwnode() driver core: Avoid warning when removing a device while its supplier is unbinding bus: simple-pm-bus: Remove child devices when the bus is unbound bus: simple-pm-bus: Populate child nodes at probe driver core: fw_devlink: Introduce fw_devlink_set_device() drivers: core: Use fw_devlink_set_device() pinctrl: cs42l43: Use fw_devlink_set_device() cxl/test: Use device_set_node() cxl/test: Use fw_devlink_set_device() PCI: of: Use fw_devlink_set_device() PCI: of: Set fwnode device of newly created PCI device nodes PCI: of: Remove fwnode_dev_initialized() call for a PCI root bridge node i2c: core: Introduce i2c_get_adapter_physdev() i2c: mux: Set adapter physical device i2c: mux: Create missing devlink between mux and adapter physical device of: property: Allow fw_devlink device-tree on x86 clk: lan966x: Add MCHP_LAN966X_PCI dependency i2c: busses: at91: Add MCHP_LAN966X_PCI dependency misc: lan966x_pci: Fix dtso nodes ordering misc: lan966x_pci: Split dtso in dtsi/dtso misc: lan966x_pci: Rename lan966x_pci.dtso to lan966x_evb_lan9662_nic.dtso PCI: Add Microchip LAN9662 PCI Device ID misc: lan966x_pci: Introduce board specific data misc: lan966x_pci: Add dtsi/dtso nodes in order to support SFPs misc: lan966x_pci: Sort the drivers list in Kconfig help misc: lan966x_pci: Add drivers needed to support SFPs in Kconfig help Saravana Kannan (2): Revert "treewide: Fix probing of devices in DT overlays" of: dynamic: Fix overlayed devices not probing because of fw_devlink MAINTAINERS | 3 +- drivers/base/core.c | 108 ++++++++++--- drivers/bus/imx-weim.c | 6 - drivers/bus/simple-pm-bus.c | 24 +-- drivers/clk/Kconfig | 2 +- drivers/i2c/busses/Kconfig | 2 +- drivers/i2c/i2c-core-base.c | 16 ++ drivers/i2c/i2c-core-of.c | 5 - drivers/i2c/i2c-mux.c | 26 ++++ drivers/misc/Kconfig | 11 +- drivers/misc/Makefile | 2 +- drivers/misc/lan966x_evb_lan9662_nic.dtso | 167 ++++++++++++++++++++ drivers/misc/lan966x_pci.c | 30 +++- drivers/misc/lan966x_pci.dtsi | 172 +++++++++++++++++++++ drivers/misc/lan966x_pci.dtso | 177 ---------------------- drivers/of/dynamic.c | 1 - drivers/of/overlay.c | 15 ++ drivers/of/platform.c | 5 - drivers/of/property.c | 26 +++- drivers/pci/of.c | 10 +- drivers/pci/quirks.c | 2 +- drivers/pinctrl/cirrus/pinctrl-cs42l43.c | 2 +- drivers/pmdomain/core.c | 4 +- drivers/spi/spi.c | 5 - include/linux/device.h | 2 +- include/linux/fwnode.h | 7 + include/linux/i2c.h | 3 + include/linux/pci_ids.h | 1 + tools/testing/cxl/test/cxl.c | 4 +- 29 files changed, 584 insertions(+), 254 deletions(-) create mode 100644 drivers/misc/lan966x_evb_lan9662_nic.dtso create mode 100644 drivers/misc/lan966x_pci.dtsi delete mode 100644 drivers/misc/lan966x_pci.dtso -- 2.53.0
null
null
null
[PATCH v5 00/28] lan966x pci device: Add support for SFPs
Setting fwnode->dev is specific to fw_devlink. In order to avoid having a direct 'fwnode->dev = dev;' in several place in the kernel, introduce fw_devlink_set_device() helper to perform this operation. Signed-off-by: Herve Codina <herve.codina@bootlin.com> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Reviewed-by: Ulf Hansson <ulf.hansson@linaro.org> --- include/linux/fwnode.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/include/linux/fwnode.h b/include/linux/fwnode.h index a921ca2fe940..a1345e274125 100644 --- a/include/linux/fwnode.h +++ b/include/linux/fwnode.h @@ -231,4 +231,10 @@ void fw_devlink_purge_absent_suppliers(struct fwnode_handle *fwnode); void fw_devlink_refresh_fwnode(struct fwnode_handle *fwnode); bool fw_devlink_is_strict(void); +static inline void fw_devlink_set_device(struct fwnode_handle *fwnode, + struct device *dev) +{ + fwnode->dev = dev; +} + #endif -- 2.53.0
{ "author": "Herve Codina <herve.codina@bootlin.com>", "date": "Fri, 27 Feb 2026 14:54:04 +0100", "is_openbsd": false, "thread_id": "20260227135428.783983-1-herve.codina@bootlin.com.mbox.gz" }
lkml_critique
lkml
Hi, This series add support for SFPs ports available on the LAN966x PCI device. In order to have the SFPs supported, additional devices are needed such as clock controller and I2C. As a reminder, the LAN966x PCI device driver use a device-tree overlay to describe devices available on the PCI board. Adding support for SFPs ports consists in adding more devices in the already existing device-tree overlay. With those devices added, the device-tree overlay is more complex and some consumer/supplier relationship are needed in order to remove devices in correct order when the LAN966x PCI driver is removed. Those links are typically provided by fw_devlink and we faced some issues with fw_devlink and overlays. This series gives the big picture related to the SFPs support from fixing issues to adding new devices. Of course, it can be split if needed. The first part of the series (patch 1, 2 and 3) fixes fw_devlink when it is used with overlay. Patches 1 and 3 were previously sent by Saravana [0]. I rebased them on top of v7.0-rc1 and added patch 2 in order to take into account feedback received on the series sent by Saravana. Also I added a call to driver_deferred_probe_trigger() in Saravana's patch (patch 3) to ensure that probes are retried after the modification performed on the dangling consumers. This allows to fix issues reported by Matti and Geert [2] with the previous iteration patches. Those modification were not sufficient in our case and so, on top of that, patches 4 to 6 fix some more issues related to fw_devlink. Patches 7 to 12 introduce and use fw_devlink_set_device() in already existing code. Patches 13 and 14 are related also to fw_devlink but specific to PCI and the device-tree nodes created during enumeration. Patches 15, 16 and 17 are related fw_devlink too but specific to I2C muxes. Patches purpose is to correctly set a link between an adapter supplier and its consumer. Indeed, an i2c mux adapter's parent is not the i2c mux supplier but the adapter the i2c mux is connected to. Adding a new link between the adapter supplier involved when i2c muxes are used avoid a freeze observed during device removal. Patch 18 adds support for fw_delink on x86. fw_devlink is needed to have the consumer/supplier relationship between devices in order to ensure a correct device removal order. Adding fw_devlink support for x86 has been tried in the past but was reverted [1] because it broke some systems. Instead of enabling fw_devlink on *all* x86 system, enable it on *all* x86 except on those where it leads to issue. Patches 19 and 20 allow to build clock and i2c controller used by the LAN966x PCI device when the LAN966x PCI device is enabled. Patches 21 to 25 are specific to the LAN966x. They touch the current dtso, split it in dtsi/dtso files, rename the dtso and improve the driver to allow easier support for other boards. The next patch (patch 26) update the LAN966x device-tree overlay itself to have the SPF ports and devices they depends on described. The last two patches (patches 27 and 29) sort the existing drivers in the needed driver list available in the Kconfig help and add new drivers in this list keep the list up to date with the devices described in the device-tree overlay. We believe some items from the above list can be merged separately, with no build dependencies. We expect: - Patches 1 to 6 to be taken by driver core maintainers - Patches 7 to 12 to be taken by driver core maintainers - Patches 13 and 14 to be taken by driver core or PCI maintainers (depend on patch 7) - Patches 15 to 17 to be taken by I2C maintainers - Patch 18 to be taken by driver core or OF maintainers - Patch 19 to be taken by clock maintainers - Patch 20 to be taken by I2C maintainers - Patches 21 to 28 to be taken by misc maintainers Once again, this series gives the big picture and can be split if needed. Let me know. Compare to previous iteration, this v5 series mainly: - Handle Matti and Geert use cases [2] - Remove simple-platform-bus driver introduced in v4 and switch the simple-bus modification back to what was proposed in v3. In the v4 iteration, conclusion was to use v3 changes [3]. [0] https://lore.kernel.org/lkml/20240411235623.1260061-1-saravanak@google.com/ [1] https://lore.kernel.org/lkml/3c1f2473-92ad-bfc4-258e-a5a08ad73dd0@web.de/ [2] https://lore.kernel.org/all/072dde7c-a53c-4525-83ac-57ea38edc0b5@gmail.com/ [3] https://lore.kernel.org/lkml/20251114083056.31553866@bootlin.com/ Best regards, Hervé Changes: v4 -> v5 v4: https://lore.kernel.org/lkml/20251015071420.1173068-1-herve.codina@bootlin.com/ - Patch 2: Add 'Acked-by: Ulf Hansson' - Patch 3: Add a call to driver_deferred_probe_trigger() - Patch 5: (new patch) Depopulate devices at remove - Patch 6: Populate devices at probe. Switched back to modification proposed in v3 - Patch 7 in v3 removed - Patch 7 (8 in v4): Add 'Reviewed-by: Andy Shevchenko' Add 'Reviewed-by: Ulf Hansson' - Patch 8 (9 in v4): Add 'Reviewed-by: Ulf Hansson' - Patches 9 to 15 (10 to 16 in v3) No changes - Patch 16 (17 in v4): Add 'Reviewed-by: Andi Shyti' - Patch 17 (18 in v4): Change an error code from -EINVAL to -ENODEV Add a blank line and fix a typo in commit log - Patch 18 (19 in v4): Simplify of_is_fwnode_add_links_supported(). Move IS_ENABLED(CONFIG_X86) check in of_is_fwnode_add_links_supported(). - Patches 19 to 21 (20 to 22 in v4) No changes - Patch 22 (23 in v4) Update due to simple-platform-bus removal - Patches 23 to 28 (24 to 29 in v4) No changes v3 -> v4 v3: https://lore.kernel.org/lkml/20250613134817.681832-1-herve.codina@bootlin.com/ - Patch 1: No change - Patch 2: Update and fix conflicts. Indeed, since v3 iteration get_dev_from_fwnode() has been moved to device.h and used by pmdomain/core.c. - Patch 3: remove '#define get_device_from_fwnode()' - Patch 4: Fix conflict (rebase v6.17-rc6) Add 'Reviewed-by: Rafael J. Wysocki' Add 'Reviewed-by: Saravana Kannan' - Patch 5 (new in v4): Introduce simple-platform-bus (binding) - Patch 6 (5 in v3): Rework patch and introduce simple-platform-bus - Patch 7: (new) Use simple-platform-bus in LAN966x - Patch 8 (6 in v3): - No change - Patch 9 and 10 (7 and 8 in v3): Add 'Reviewed-by: Andy Shevchenko' - Patch 11 and 12 (9 and 10 in v3): Add 'Reviewed-by: Dave Jiang' - Patch 13 (11 in v3): Add 'Reviewed-by: Andy Shevchenko' - Patch 12 in v3: Patch removed. Adding __private tag in fwnode.dev is going to be handled in a dedicated series. Indeed a test robot reported an issue and more patches are needed (I have missed fwnode.dev users in several part in the kernel). - Patch 14 and 15 (13 and 14 in v3): No change - Patch 16 (14 in v3): Add 'Reviewed-by: Andi Shyti' - Patch 17 and 18 (16 and 17 in v3): No change - Patch 19 (18 in v3): Filter out support for fw_devlink on x86 based on some device-tree properties. Rewrite commit changelog Remove 'Reviewed-by: Andy Shevchenko' (significant modification) - Patch 20 (19 in v3): Add 'Acked-by: Stephen Boyd' - Patch 21 (20 in v3): Fix conflict (rebase v6.18-rc1) - Patches 22 to 24 (21 to 23 in v3): No change - Patch 25 (24 in v3): Fix conflict (rebase v6.18-rc1) Add 'Acked-by: Bjorn Helgaas' - Patches 26 to 29 (25 to 28 in v3): No change v2 -> v3 v2: https://lore.kernel.org/all/20250507071315.394857-1-herve.codina@bootlin.com/ - Patch 1: Add 'Acked-by: Mark Brown' - Patch 2 and 3: No changes - Patch 4: Rewrite the WARN_ON() condition to avoid an additional 'if' - Patch 5: Fix typos in commit log Update a comment Remove the unneeded check before calling of_platform_depopulate() - Patches 6 to 11: No changes - Patch 12 (new in v3) Tag the fwnode dev member as private - Patch 13 (12 in v2) Fix a typo in the commit log - Patches 14 to 16 (13 to 15 in v2) No changes - Patch 17 (16 in v2) Check parent_physdev for NULL - Patch 18 (17 in v2) Capitalize "Link:" Add 'Reviewed-by: Andy Shevchenko' - Patch 19 (18 in v2) No changes - Patch 20 (19 in v2) Add 'Acked-by: Andi Shyti' - Patch 21 (20 in v2) No changes - Patch 22 (21 in v2) Add 'Reviewed-by: Andrew Lunn' - Patch 23 (22 in v2) Add 'Reviewed-by: Andrew Lunn' - Patch 24 (new in v3) Introduce PCI_DEVICE_ID_EFAR_LAN9662, the LAN966x PCI device ID - Patch 25 (23 in v2) Add 'Reviewed-by: Andrew Lunn' Use PCI_DEVICE_DATA() with PCI_DEVICE_ID_EFAR_LAN9662 instead of PCI_VDEVICE() - Patch 26 to 28 (24 to 26 in v2) No changes v1 -> v2 v1: https://lore.kernel.org/lkml/20250407145546.270683-1-herve.codina@bootlin.com/ - Patch 1 and 3 Remove 'From' tag from the commit log - Patch 2 Add 'Reviewed-by: Andy Shevchenko' Add 'Reviewed-by: Saravana Kannan' Add 'Reviewed-by: Luca Ceresoli' - Patch 4 and 5 No changes - Patch 6 (new in v2) Introduce fw_devlink_set_device() - Patch 7 (new in v2) Use existing device_set_node() helper. - Patch 8 to 11 (new in v2) Use fw_devlink_set_device() in existing code. - Patch 12 (6 in v1) Use fw_devlink_add_device() - Patch 13 (7 in v1) No changes - Patch 14 (8 in v1) Update commit log Use 'physdev' instead of 'supplier' Minor fixes in i2c_get_adapter_physdev() kdoc - Patch 15 and 16 (9 and 10 in v1) Use 'physdev' instead of 'supplier' (commit log, title and code) - Patch 17 (11 in v2) Enable fw_devlink on x86 only if PCI_DYNAMIC_OF_NODES is enabled. Rework commit log. - Patch 18, 19 and 20 (12, 13 and 14 in v1) No changes - Patch 21 (new in v2) Split dtso in dtsi/dtso - Patch 22 (new in v2) Rename lan966x_pci.dtso using the specific board name - Patch 23 (new in v2) Improve the driver introducing board specific data to ease support for other boards (avoid the direct dtbo reference in the function loading the dtbo). - Patch 24 (15 in v1) Refactor due to dtso split in dtsi/dtso - Patch 25 (new in v2) Sort exist driver list in Kconfig help - Patch 26 (16 in v1) Keep alphanumeric order for new drivers added in Kconfig help Herve Codina (26): driver core: Rename get_dev_from_fwnode() wrapper to get_device_from_fwnode() driver core: Avoid warning when removing a device while its supplier is unbinding bus: simple-pm-bus: Remove child devices when the bus is unbound bus: simple-pm-bus: Populate child nodes at probe driver core: fw_devlink: Introduce fw_devlink_set_device() drivers: core: Use fw_devlink_set_device() pinctrl: cs42l43: Use fw_devlink_set_device() cxl/test: Use device_set_node() cxl/test: Use fw_devlink_set_device() PCI: of: Use fw_devlink_set_device() PCI: of: Set fwnode device of newly created PCI device nodes PCI: of: Remove fwnode_dev_initialized() call for a PCI root bridge node i2c: core: Introduce i2c_get_adapter_physdev() i2c: mux: Set adapter physical device i2c: mux: Create missing devlink between mux and adapter physical device of: property: Allow fw_devlink device-tree on x86 clk: lan966x: Add MCHP_LAN966X_PCI dependency i2c: busses: at91: Add MCHP_LAN966X_PCI dependency misc: lan966x_pci: Fix dtso nodes ordering misc: lan966x_pci: Split dtso in dtsi/dtso misc: lan966x_pci: Rename lan966x_pci.dtso to lan966x_evb_lan9662_nic.dtso PCI: Add Microchip LAN9662 PCI Device ID misc: lan966x_pci: Introduce board specific data misc: lan966x_pci: Add dtsi/dtso nodes in order to support SFPs misc: lan966x_pci: Sort the drivers list in Kconfig help misc: lan966x_pci: Add drivers needed to support SFPs in Kconfig help Saravana Kannan (2): Revert "treewide: Fix probing of devices in DT overlays" of: dynamic: Fix overlayed devices not probing because of fw_devlink MAINTAINERS | 3 +- drivers/base/core.c | 108 ++++++++++--- drivers/bus/imx-weim.c | 6 - drivers/bus/simple-pm-bus.c | 24 +-- drivers/clk/Kconfig | 2 +- drivers/i2c/busses/Kconfig | 2 +- drivers/i2c/i2c-core-base.c | 16 ++ drivers/i2c/i2c-core-of.c | 5 - drivers/i2c/i2c-mux.c | 26 ++++ drivers/misc/Kconfig | 11 +- drivers/misc/Makefile | 2 +- drivers/misc/lan966x_evb_lan9662_nic.dtso | 167 ++++++++++++++++++++ drivers/misc/lan966x_pci.c | 30 +++- drivers/misc/lan966x_pci.dtsi | 172 +++++++++++++++++++++ drivers/misc/lan966x_pci.dtso | 177 ---------------------- drivers/of/dynamic.c | 1 - drivers/of/overlay.c | 15 ++ drivers/of/platform.c | 5 - drivers/of/property.c | 26 +++- drivers/pci/of.c | 10 +- drivers/pci/quirks.c | 2 +- drivers/pinctrl/cirrus/pinctrl-cs42l43.c | 2 +- drivers/pmdomain/core.c | 4 +- drivers/spi/spi.c | 5 - include/linux/device.h | 2 +- include/linux/fwnode.h | 7 + include/linux/i2c.h | 3 + include/linux/pci_ids.h | 1 + tools/testing/cxl/test/cxl.c | 4 +- 29 files changed, 584 insertions(+), 254 deletions(-) create mode 100644 drivers/misc/lan966x_evb_lan9662_nic.dtso create mode 100644 drivers/misc/lan966x_pci.dtsi delete mode 100644 drivers/misc/lan966x_pci.dtso -- 2.53.0
null
null
null
[PATCH v5 00/28] lan966x pci device: Add support for SFPs
The code set directly fwnode->dev field. Use the dedicated fw_devlink_set_device() helper to perform this operation. Signed-off-by: Herve Codina <herve.codina@bootlin.com> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Reviewed-by: Ulf Hansson <ulf.hansson@linaro.org> --- drivers/base/core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/base/core.c b/drivers/base/core.c index a290bc8d2845..3f3a909306d2 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c @@ -3748,7 +3748,7 @@ int device_add(struct device *dev) * device and the driver sync_state callback is called for this device. */ if (dev->fwnode && !dev->fwnode->dev) { - dev->fwnode->dev = dev; + fw_devlink_set_device(dev->fwnode, dev); fw_devlink_link_device(dev); } @@ -3908,7 +3908,7 @@ void device_del(struct device *dev) device_unlock(dev); if (dev->fwnode && dev->fwnode->dev == dev) - dev->fwnode->dev = NULL; + fw_devlink_set_device(dev->fwnode, NULL); /* Notify clients of device removal. This call must come * before dpm_sysfs_remove(). -- 2.53.0
{ "author": "Herve Codina <herve.codina@bootlin.com>", "date": "Fri, 27 Feb 2026 14:54:05 +0100", "is_openbsd": false, "thread_id": "20260227135428.783983-1-herve.codina@bootlin.com.mbox.gz" }
lkml_critique
lkml
Hi, This series add support for SFPs ports available on the LAN966x PCI device. In order to have the SFPs supported, additional devices are needed such as clock controller and I2C. As a reminder, the LAN966x PCI device driver use a device-tree overlay to describe devices available on the PCI board. Adding support for SFPs ports consists in adding more devices in the already existing device-tree overlay. With those devices added, the device-tree overlay is more complex and some consumer/supplier relationship are needed in order to remove devices in correct order when the LAN966x PCI driver is removed. Those links are typically provided by fw_devlink and we faced some issues with fw_devlink and overlays. This series gives the big picture related to the SFPs support from fixing issues to adding new devices. Of course, it can be split if needed. The first part of the series (patch 1, 2 and 3) fixes fw_devlink when it is used with overlay. Patches 1 and 3 were previously sent by Saravana [0]. I rebased them on top of v7.0-rc1 and added patch 2 in order to take into account feedback received on the series sent by Saravana. Also I added a call to driver_deferred_probe_trigger() in Saravana's patch (patch 3) to ensure that probes are retried after the modification performed on the dangling consumers. This allows to fix issues reported by Matti and Geert [2] with the previous iteration patches. Those modification were not sufficient in our case and so, on top of that, patches 4 to 6 fix some more issues related to fw_devlink. Patches 7 to 12 introduce and use fw_devlink_set_device() in already existing code. Patches 13 and 14 are related also to fw_devlink but specific to PCI and the device-tree nodes created during enumeration. Patches 15, 16 and 17 are related fw_devlink too but specific to I2C muxes. Patches purpose is to correctly set a link between an adapter supplier and its consumer. Indeed, an i2c mux adapter's parent is not the i2c mux supplier but the adapter the i2c mux is connected to. Adding a new link between the adapter supplier involved when i2c muxes are used avoid a freeze observed during device removal. Patch 18 adds support for fw_delink on x86. fw_devlink is needed to have the consumer/supplier relationship between devices in order to ensure a correct device removal order. Adding fw_devlink support for x86 has been tried in the past but was reverted [1] because it broke some systems. Instead of enabling fw_devlink on *all* x86 system, enable it on *all* x86 except on those where it leads to issue. Patches 19 and 20 allow to build clock and i2c controller used by the LAN966x PCI device when the LAN966x PCI device is enabled. Patches 21 to 25 are specific to the LAN966x. They touch the current dtso, split it in dtsi/dtso files, rename the dtso and improve the driver to allow easier support for other boards. The next patch (patch 26) update the LAN966x device-tree overlay itself to have the SPF ports and devices they depends on described. The last two patches (patches 27 and 29) sort the existing drivers in the needed driver list available in the Kconfig help and add new drivers in this list keep the list up to date with the devices described in the device-tree overlay. We believe some items from the above list can be merged separately, with no build dependencies. We expect: - Patches 1 to 6 to be taken by driver core maintainers - Patches 7 to 12 to be taken by driver core maintainers - Patches 13 and 14 to be taken by driver core or PCI maintainers (depend on patch 7) - Patches 15 to 17 to be taken by I2C maintainers - Patch 18 to be taken by driver core or OF maintainers - Patch 19 to be taken by clock maintainers - Patch 20 to be taken by I2C maintainers - Patches 21 to 28 to be taken by misc maintainers Once again, this series gives the big picture and can be split if needed. Let me know. Compare to previous iteration, this v5 series mainly: - Handle Matti and Geert use cases [2] - Remove simple-platform-bus driver introduced in v4 and switch the simple-bus modification back to what was proposed in v3. In the v4 iteration, conclusion was to use v3 changes [3]. [0] https://lore.kernel.org/lkml/20240411235623.1260061-1-saravanak@google.com/ [1] https://lore.kernel.org/lkml/3c1f2473-92ad-bfc4-258e-a5a08ad73dd0@web.de/ [2] https://lore.kernel.org/all/072dde7c-a53c-4525-83ac-57ea38edc0b5@gmail.com/ [3] https://lore.kernel.org/lkml/20251114083056.31553866@bootlin.com/ Best regards, Hervé Changes: v4 -> v5 v4: https://lore.kernel.org/lkml/20251015071420.1173068-1-herve.codina@bootlin.com/ - Patch 2: Add 'Acked-by: Ulf Hansson' - Patch 3: Add a call to driver_deferred_probe_trigger() - Patch 5: (new patch) Depopulate devices at remove - Patch 6: Populate devices at probe. Switched back to modification proposed in v3 - Patch 7 in v3 removed - Patch 7 (8 in v4): Add 'Reviewed-by: Andy Shevchenko' Add 'Reviewed-by: Ulf Hansson' - Patch 8 (9 in v4): Add 'Reviewed-by: Ulf Hansson' - Patches 9 to 15 (10 to 16 in v3) No changes - Patch 16 (17 in v4): Add 'Reviewed-by: Andi Shyti' - Patch 17 (18 in v4): Change an error code from -EINVAL to -ENODEV Add a blank line and fix a typo in commit log - Patch 18 (19 in v4): Simplify of_is_fwnode_add_links_supported(). Move IS_ENABLED(CONFIG_X86) check in of_is_fwnode_add_links_supported(). - Patches 19 to 21 (20 to 22 in v4) No changes - Patch 22 (23 in v4) Update due to simple-platform-bus removal - Patches 23 to 28 (24 to 29 in v4) No changes v3 -> v4 v3: https://lore.kernel.org/lkml/20250613134817.681832-1-herve.codina@bootlin.com/ - Patch 1: No change - Patch 2: Update and fix conflicts. Indeed, since v3 iteration get_dev_from_fwnode() has been moved to device.h and used by pmdomain/core.c. - Patch 3: remove '#define get_device_from_fwnode()' - Patch 4: Fix conflict (rebase v6.17-rc6) Add 'Reviewed-by: Rafael J. Wysocki' Add 'Reviewed-by: Saravana Kannan' - Patch 5 (new in v4): Introduce simple-platform-bus (binding) - Patch 6 (5 in v3): Rework patch and introduce simple-platform-bus - Patch 7: (new) Use simple-platform-bus in LAN966x - Patch 8 (6 in v3): - No change - Patch 9 and 10 (7 and 8 in v3): Add 'Reviewed-by: Andy Shevchenko' - Patch 11 and 12 (9 and 10 in v3): Add 'Reviewed-by: Dave Jiang' - Patch 13 (11 in v3): Add 'Reviewed-by: Andy Shevchenko' - Patch 12 in v3: Patch removed. Adding __private tag in fwnode.dev is going to be handled in a dedicated series. Indeed a test robot reported an issue and more patches are needed (I have missed fwnode.dev users in several part in the kernel). - Patch 14 and 15 (13 and 14 in v3): No change - Patch 16 (14 in v3): Add 'Reviewed-by: Andi Shyti' - Patch 17 and 18 (16 and 17 in v3): No change - Patch 19 (18 in v3): Filter out support for fw_devlink on x86 based on some device-tree properties. Rewrite commit changelog Remove 'Reviewed-by: Andy Shevchenko' (significant modification) - Patch 20 (19 in v3): Add 'Acked-by: Stephen Boyd' - Patch 21 (20 in v3): Fix conflict (rebase v6.18-rc1) - Patches 22 to 24 (21 to 23 in v3): No change - Patch 25 (24 in v3): Fix conflict (rebase v6.18-rc1) Add 'Acked-by: Bjorn Helgaas' - Patches 26 to 29 (25 to 28 in v3): No change v2 -> v3 v2: https://lore.kernel.org/all/20250507071315.394857-1-herve.codina@bootlin.com/ - Patch 1: Add 'Acked-by: Mark Brown' - Patch 2 and 3: No changes - Patch 4: Rewrite the WARN_ON() condition to avoid an additional 'if' - Patch 5: Fix typos in commit log Update a comment Remove the unneeded check before calling of_platform_depopulate() - Patches 6 to 11: No changes - Patch 12 (new in v3) Tag the fwnode dev member as private - Patch 13 (12 in v2) Fix a typo in the commit log - Patches 14 to 16 (13 to 15 in v2) No changes - Patch 17 (16 in v2) Check parent_physdev for NULL - Patch 18 (17 in v2) Capitalize "Link:" Add 'Reviewed-by: Andy Shevchenko' - Patch 19 (18 in v2) No changes - Patch 20 (19 in v2) Add 'Acked-by: Andi Shyti' - Patch 21 (20 in v2) No changes - Patch 22 (21 in v2) Add 'Reviewed-by: Andrew Lunn' - Patch 23 (22 in v2) Add 'Reviewed-by: Andrew Lunn' - Patch 24 (new in v3) Introduce PCI_DEVICE_ID_EFAR_LAN9662, the LAN966x PCI device ID - Patch 25 (23 in v2) Add 'Reviewed-by: Andrew Lunn' Use PCI_DEVICE_DATA() with PCI_DEVICE_ID_EFAR_LAN9662 instead of PCI_VDEVICE() - Patch 26 to 28 (24 to 26 in v2) No changes v1 -> v2 v1: https://lore.kernel.org/lkml/20250407145546.270683-1-herve.codina@bootlin.com/ - Patch 1 and 3 Remove 'From' tag from the commit log - Patch 2 Add 'Reviewed-by: Andy Shevchenko' Add 'Reviewed-by: Saravana Kannan' Add 'Reviewed-by: Luca Ceresoli' - Patch 4 and 5 No changes - Patch 6 (new in v2) Introduce fw_devlink_set_device() - Patch 7 (new in v2) Use existing device_set_node() helper. - Patch 8 to 11 (new in v2) Use fw_devlink_set_device() in existing code. - Patch 12 (6 in v1) Use fw_devlink_add_device() - Patch 13 (7 in v1) No changes - Patch 14 (8 in v1) Update commit log Use 'physdev' instead of 'supplier' Minor fixes in i2c_get_adapter_physdev() kdoc - Patch 15 and 16 (9 and 10 in v1) Use 'physdev' instead of 'supplier' (commit log, title and code) - Patch 17 (11 in v2) Enable fw_devlink on x86 only if PCI_DYNAMIC_OF_NODES is enabled. Rework commit log. - Patch 18, 19 and 20 (12, 13 and 14 in v1) No changes - Patch 21 (new in v2) Split dtso in dtsi/dtso - Patch 22 (new in v2) Rename lan966x_pci.dtso using the specific board name - Patch 23 (new in v2) Improve the driver introducing board specific data to ease support for other boards (avoid the direct dtbo reference in the function loading the dtbo). - Patch 24 (15 in v1) Refactor due to dtso split in dtsi/dtso - Patch 25 (new in v2) Sort exist driver list in Kconfig help - Patch 26 (16 in v1) Keep alphanumeric order for new drivers added in Kconfig help Herve Codina (26): driver core: Rename get_dev_from_fwnode() wrapper to get_device_from_fwnode() driver core: Avoid warning when removing a device while its supplier is unbinding bus: simple-pm-bus: Remove child devices when the bus is unbound bus: simple-pm-bus: Populate child nodes at probe driver core: fw_devlink: Introduce fw_devlink_set_device() drivers: core: Use fw_devlink_set_device() pinctrl: cs42l43: Use fw_devlink_set_device() cxl/test: Use device_set_node() cxl/test: Use fw_devlink_set_device() PCI: of: Use fw_devlink_set_device() PCI: of: Set fwnode device of newly created PCI device nodes PCI: of: Remove fwnode_dev_initialized() call for a PCI root bridge node i2c: core: Introduce i2c_get_adapter_physdev() i2c: mux: Set adapter physical device i2c: mux: Create missing devlink between mux and adapter physical device of: property: Allow fw_devlink device-tree on x86 clk: lan966x: Add MCHP_LAN966X_PCI dependency i2c: busses: at91: Add MCHP_LAN966X_PCI dependency misc: lan966x_pci: Fix dtso nodes ordering misc: lan966x_pci: Split dtso in dtsi/dtso misc: lan966x_pci: Rename lan966x_pci.dtso to lan966x_evb_lan9662_nic.dtso PCI: Add Microchip LAN9662 PCI Device ID misc: lan966x_pci: Introduce board specific data misc: lan966x_pci: Add dtsi/dtso nodes in order to support SFPs misc: lan966x_pci: Sort the drivers list in Kconfig help misc: lan966x_pci: Add drivers needed to support SFPs in Kconfig help Saravana Kannan (2): Revert "treewide: Fix probing of devices in DT overlays" of: dynamic: Fix overlayed devices not probing because of fw_devlink MAINTAINERS | 3 +- drivers/base/core.c | 108 ++++++++++--- drivers/bus/imx-weim.c | 6 - drivers/bus/simple-pm-bus.c | 24 +-- drivers/clk/Kconfig | 2 +- drivers/i2c/busses/Kconfig | 2 +- drivers/i2c/i2c-core-base.c | 16 ++ drivers/i2c/i2c-core-of.c | 5 - drivers/i2c/i2c-mux.c | 26 ++++ drivers/misc/Kconfig | 11 +- drivers/misc/Makefile | 2 +- drivers/misc/lan966x_evb_lan9662_nic.dtso | 167 ++++++++++++++++++++ drivers/misc/lan966x_pci.c | 30 +++- drivers/misc/lan966x_pci.dtsi | 172 +++++++++++++++++++++ drivers/misc/lan966x_pci.dtso | 177 ---------------------- drivers/of/dynamic.c | 1 - drivers/of/overlay.c | 15 ++ drivers/of/platform.c | 5 - drivers/of/property.c | 26 +++- drivers/pci/of.c | 10 +- drivers/pci/quirks.c | 2 +- drivers/pinctrl/cirrus/pinctrl-cs42l43.c | 2 +- drivers/pmdomain/core.c | 4 +- drivers/spi/spi.c | 5 - include/linux/device.h | 2 +- include/linux/fwnode.h | 7 + include/linux/i2c.h | 3 + include/linux/pci_ids.h | 1 + tools/testing/cxl/test/cxl.c | 4 +- 29 files changed, 584 insertions(+), 254 deletions(-) create mode 100644 drivers/misc/lan966x_evb_lan9662_nic.dtso create mode 100644 drivers/misc/lan966x_pci.dtsi delete mode 100644 drivers/misc/lan966x_pci.dtso -- 2.53.0
null
null
null
[PATCH v5 00/28] lan966x pci device: Add support for SFPs
The code set directly fwnode->dev field. Use the dedicated fw_devlink_set_device() helper to perform this operation. Signed-off-by: Herve Codina <herve.codina@bootlin.com> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> --- drivers/pinctrl/cirrus/pinctrl-cs42l43.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/pinctrl/cirrus/pinctrl-cs42l43.c b/drivers/pinctrl/cirrus/pinctrl-cs42l43.c index a8f82104a384..a3dd8da15919 100644 --- a/drivers/pinctrl/cirrus/pinctrl-cs42l43.c +++ b/drivers/pinctrl/cirrus/pinctrl-cs42l43.c @@ -579,7 +579,7 @@ static int cs42l43_pin_probe(struct platform_device *pdev) return ret; } if (!child->dev) - child->dev = priv->dev; + fw_devlink_set_device(child, priv->dev); fwnode = child; } } -- 2.53.0
{ "author": "Herve Codina <herve.codina@bootlin.com>", "date": "Fri, 27 Feb 2026 14:54:06 +0100", "is_openbsd": false, "thread_id": "20260227135428.783983-1-herve.codina@bootlin.com.mbox.gz" }
lkml_critique
lkml
Hi, This series add support for SFPs ports available on the LAN966x PCI device. In order to have the SFPs supported, additional devices are needed such as clock controller and I2C. As a reminder, the LAN966x PCI device driver use a device-tree overlay to describe devices available on the PCI board. Adding support for SFPs ports consists in adding more devices in the already existing device-tree overlay. With those devices added, the device-tree overlay is more complex and some consumer/supplier relationship are needed in order to remove devices in correct order when the LAN966x PCI driver is removed. Those links are typically provided by fw_devlink and we faced some issues with fw_devlink and overlays. This series gives the big picture related to the SFPs support from fixing issues to adding new devices. Of course, it can be split if needed. The first part of the series (patch 1, 2 and 3) fixes fw_devlink when it is used with overlay. Patches 1 and 3 were previously sent by Saravana [0]. I rebased them on top of v7.0-rc1 and added patch 2 in order to take into account feedback received on the series sent by Saravana. Also I added a call to driver_deferred_probe_trigger() in Saravana's patch (patch 3) to ensure that probes are retried after the modification performed on the dangling consumers. This allows to fix issues reported by Matti and Geert [2] with the previous iteration patches. Those modification were not sufficient in our case and so, on top of that, patches 4 to 6 fix some more issues related to fw_devlink. Patches 7 to 12 introduce and use fw_devlink_set_device() in already existing code. Patches 13 and 14 are related also to fw_devlink but specific to PCI and the device-tree nodes created during enumeration. Patches 15, 16 and 17 are related fw_devlink too but specific to I2C muxes. Patches purpose is to correctly set a link between an adapter supplier and its consumer. Indeed, an i2c mux adapter's parent is not the i2c mux supplier but the adapter the i2c mux is connected to. Adding a new link between the adapter supplier involved when i2c muxes are used avoid a freeze observed during device removal. Patch 18 adds support for fw_delink on x86. fw_devlink is needed to have the consumer/supplier relationship between devices in order to ensure a correct device removal order. Adding fw_devlink support for x86 has been tried in the past but was reverted [1] because it broke some systems. Instead of enabling fw_devlink on *all* x86 system, enable it on *all* x86 except on those where it leads to issue. Patches 19 and 20 allow to build clock and i2c controller used by the LAN966x PCI device when the LAN966x PCI device is enabled. Patches 21 to 25 are specific to the LAN966x. They touch the current dtso, split it in dtsi/dtso files, rename the dtso and improve the driver to allow easier support for other boards. The next patch (patch 26) update the LAN966x device-tree overlay itself to have the SPF ports and devices they depends on described. The last two patches (patches 27 and 29) sort the existing drivers in the needed driver list available in the Kconfig help and add new drivers in this list keep the list up to date with the devices described in the device-tree overlay. We believe some items from the above list can be merged separately, with no build dependencies. We expect: - Patches 1 to 6 to be taken by driver core maintainers - Patches 7 to 12 to be taken by driver core maintainers - Patches 13 and 14 to be taken by driver core or PCI maintainers (depend on patch 7) - Patches 15 to 17 to be taken by I2C maintainers - Patch 18 to be taken by driver core or OF maintainers - Patch 19 to be taken by clock maintainers - Patch 20 to be taken by I2C maintainers - Patches 21 to 28 to be taken by misc maintainers Once again, this series gives the big picture and can be split if needed. Let me know. Compare to previous iteration, this v5 series mainly: - Handle Matti and Geert use cases [2] - Remove simple-platform-bus driver introduced in v4 and switch the simple-bus modification back to what was proposed in v3. In the v4 iteration, conclusion was to use v3 changes [3]. [0] https://lore.kernel.org/lkml/20240411235623.1260061-1-saravanak@google.com/ [1] https://lore.kernel.org/lkml/3c1f2473-92ad-bfc4-258e-a5a08ad73dd0@web.de/ [2] https://lore.kernel.org/all/072dde7c-a53c-4525-83ac-57ea38edc0b5@gmail.com/ [3] https://lore.kernel.org/lkml/20251114083056.31553866@bootlin.com/ Best regards, Hervé Changes: v4 -> v5 v4: https://lore.kernel.org/lkml/20251015071420.1173068-1-herve.codina@bootlin.com/ - Patch 2: Add 'Acked-by: Ulf Hansson' - Patch 3: Add a call to driver_deferred_probe_trigger() - Patch 5: (new patch) Depopulate devices at remove - Patch 6: Populate devices at probe. Switched back to modification proposed in v3 - Patch 7 in v3 removed - Patch 7 (8 in v4): Add 'Reviewed-by: Andy Shevchenko' Add 'Reviewed-by: Ulf Hansson' - Patch 8 (9 in v4): Add 'Reviewed-by: Ulf Hansson' - Patches 9 to 15 (10 to 16 in v3) No changes - Patch 16 (17 in v4): Add 'Reviewed-by: Andi Shyti' - Patch 17 (18 in v4): Change an error code from -EINVAL to -ENODEV Add a blank line and fix a typo in commit log - Patch 18 (19 in v4): Simplify of_is_fwnode_add_links_supported(). Move IS_ENABLED(CONFIG_X86) check in of_is_fwnode_add_links_supported(). - Patches 19 to 21 (20 to 22 in v4) No changes - Patch 22 (23 in v4) Update due to simple-platform-bus removal - Patches 23 to 28 (24 to 29 in v4) No changes v3 -> v4 v3: https://lore.kernel.org/lkml/20250613134817.681832-1-herve.codina@bootlin.com/ - Patch 1: No change - Patch 2: Update and fix conflicts. Indeed, since v3 iteration get_dev_from_fwnode() has been moved to device.h and used by pmdomain/core.c. - Patch 3: remove '#define get_device_from_fwnode()' - Patch 4: Fix conflict (rebase v6.17-rc6) Add 'Reviewed-by: Rafael J. Wysocki' Add 'Reviewed-by: Saravana Kannan' - Patch 5 (new in v4): Introduce simple-platform-bus (binding) - Patch 6 (5 in v3): Rework patch and introduce simple-platform-bus - Patch 7: (new) Use simple-platform-bus in LAN966x - Patch 8 (6 in v3): - No change - Patch 9 and 10 (7 and 8 in v3): Add 'Reviewed-by: Andy Shevchenko' - Patch 11 and 12 (9 and 10 in v3): Add 'Reviewed-by: Dave Jiang' - Patch 13 (11 in v3): Add 'Reviewed-by: Andy Shevchenko' - Patch 12 in v3: Patch removed. Adding __private tag in fwnode.dev is going to be handled in a dedicated series. Indeed a test robot reported an issue and more patches are needed (I have missed fwnode.dev users in several part in the kernel). - Patch 14 and 15 (13 and 14 in v3): No change - Patch 16 (14 in v3): Add 'Reviewed-by: Andi Shyti' - Patch 17 and 18 (16 and 17 in v3): No change - Patch 19 (18 in v3): Filter out support for fw_devlink on x86 based on some device-tree properties. Rewrite commit changelog Remove 'Reviewed-by: Andy Shevchenko' (significant modification) - Patch 20 (19 in v3): Add 'Acked-by: Stephen Boyd' - Patch 21 (20 in v3): Fix conflict (rebase v6.18-rc1) - Patches 22 to 24 (21 to 23 in v3): No change - Patch 25 (24 in v3): Fix conflict (rebase v6.18-rc1) Add 'Acked-by: Bjorn Helgaas' - Patches 26 to 29 (25 to 28 in v3): No change v2 -> v3 v2: https://lore.kernel.org/all/20250507071315.394857-1-herve.codina@bootlin.com/ - Patch 1: Add 'Acked-by: Mark Brown' - Patch 2 and 3: No changes - Patch 4: Rewrite the WARN_ON() condition to avoid an additional 'if' - Patch 5: Fix typos in commit log Update a comment Remove the unneeded check before calling of_platform_depopulate() - Patches 6 to 11: No changes - Patch 12 (new in v3) Tag the fwnode dev member as private - Patch 13 (12 in v2) Fix a typo in the commit log - Patches 14 to 16 (13 to 15 in v2) No changes - Patch 17 (16 in v2) Check parent_physdev for NULL - Patch 18 (17 in v2) Capitalize "Link:" Add 'Reviewed-by: Andy Shevchenko' - Patch 19 (18 in v2) No changes - Patch 20 (19 in v2) Add 'Acked-by: Andi Shyti' - Patch 21 (20 in v2) No changes - Patch 22 (21 in v2) Add 'Reviewed-by: Andrew Lunn' - Patch 23 (22 in v2) Add 'Reviewed-by: Andrew Lunn' - Patch 24 (new in v3) Introduce PCI_DEVICE_ID_EFAR_LAN9662, the LAN966x PCI device ID - Patch 25 (23 in v2) Add 'Reviewed-by: Andrew Lunn' Use PCI_DEVICE_DATA() with PCI_DEVICE_ID_EFAR_LAN9662 instead of PCI_VDEVICE() - Patch 26 to 28 (24 to 26 in v2) No changes v1 -> v2 v1: https://lore.kernel.org/lkml/20250407145546.270683-1-herve.codina@bootlin.com/ - Patch 1 and 3 Remove 'From' tag from the commit log - Patch 2 Add 'Reviewed-by: Andy Shevchenko' Add 'Reviewed-by: Saravana Kannan' Add 'Reviewed-by: Luca Ceresoli' - Patch 4 and 5 No changes - Patch 6 (new in v2) Introduce fw_devlink_set_device() - Patch 7 (new in v2) Use existing device_set_node() helper. - Patch 8 to 11 (new in v2) Use fw_devlink_set_device() in existing code. - Patch 12 (6 in v1) Use fw_devlink_add_device() - Patch 13 (7 in v1) No changes - Patch 14 (8 in v1) Update commit log Use 'physdev' instead of 'supplier' Minor fixes in i2c_get_adapter_physdev() kdoc - Patch 15 and 16 (9 and 10 in v1) Use 'physdev' instead of 'supplier' (commit log, title and code) - Patch 17 (11 in v2) Enable fw_devlink on x86 only if PCI_DYNAMIC_OF_NODES is enabled. Rework commit log. - Patch 18, 19 and 20 (12, 13 and 14 in v1) No changes - Patch 21 (new in v2) Split dtso in dtsi/dtso - Patch 22 (new in v2) Rename lan966x_pci.dtso using the specific board name - Patch 23 (new in v2) Improve the driver introducing board specific data to ease support for other boards (avoid the direct dtbo reference in the function loading the dtbo). - Patch 24 (15 in v1) Refactor due to dtso split in dtsi/dtso - Patch 25 (new in v2) Sort exist driver list in Kconfig help - Patch 26 (16 in v1) Keep alphanumeric order for new drivers added in Kconfig help Herve Codina (26): driver core: Rename get_dev_from_fwnode() wrapper to get_device_from_fwnode() driver core: Avoid warning when removing a device while its supplier is unbinding bus: simple-pm-bus: Remove child devices when the bus is unbound bus: simple-pm-bus: Populate child nodes at probe driver core: fw_devlink: Introduce fw_devlink_set_device() drivers: core: Use fw_devlink_set_device() pinctrl: cs42l43: Use fw_devlink_set_device() cxl/test: Use device_set_node() cxl/test: Use fw_devlink_set_device() PCI: of: Use fw_devlink_set_device() PCI: of: Set fwnode device of newly created PCI device nodes PCI: of: Remove fwnode_dev_initialized() call for a PCI root bridge node i2c: core: Introduce i2c_get_adapter_physdev() i2c: mux: Set adapter physical device i2c: mux: Create missing devlink between mux and adapter physical device of: property: Allow fw_devlink device-tree on x86 clk: lan966x: Add MCHP_LAN966X_PCI dependency i2c: busses: at91: Add MCHP_LAN966X_PCI dependency misc: lan966x_pci: Fix dtso nodes ordering misc: lan966x_pci: Split dtso in dtsi/dtso misc: lan966x_pci: Rename lan966x_pci.dtso to lan966x_evb_lan9662_nic.dtso PCI: Add Microchip LAN9662 PCI Device ID misc: lan966x_pci: Introduce board specific data misc: lan966x_pci: Add dtsi/dtso nodes in order to support SFPs misc: lan966x_pci: Sort the drivers list in Kconfig help misc: lan966x_pci: Add drivers needed to support SFPs in Kconfig help Saravana Kannan (2): Revert "treewide: Fix probing of devices in DT overlays" of: dynamic: Fix overlayed devices not probing because of fw_devlink MAINTAINERS | 3 +- drivers/base/core.c | 108 ++++++++++--- drivers/bus/imx-weim.c | 6 - drivers/bus/simple-pm-bus.c | 24 +-- drivers/clk/Kconfig | 2 +- drivers/i2c/busses/Kconfig | 2 +- drivers/i2c/i2c-core-base.c | 16 ++ drivers/i2c/i2c-core-of.c | 5 - drivers/i2c/i2c-mux.c | 26 ++++ drivers/misc/Kconfig | 11 +- drivers/misc/Makefile | 2 +- drivers/misc/lan966x_evb_lan9662_nic.dtso | 167 ++++++++++++++++++++ drivers/misc/lan966x_pci.c | 30 +++- drivers/misc/lan966x_pci.dtsi | 172 +++++++++++++++++++++ drivers/misc/lan966x_pci.dtso | 177 ---------------------- drivers/of/dynamic.c | 1 - drivers/of/overlay.c | 15 ++ drivers/of/platform.c | 5 - drivers/of/property.c | 26 +++- drivers/pci/of.c | 10 +- drivers/pci/quirks.c | 2 +- drivers/pinctrl/cirrus/pinctrl-cs42l43.c | 2 +- drivers/pmdomain/core.c | 4 +- drivers/spi/spi.c | 5 - include/linux/device.h | 2 +- include/linux/fwnode.h | 7 + include/linux/i2c.h | 3 + include/linux/pci_ids.h | 1 + tools/testing/cxl/test/cxl.c | 4 +- 29 files changed, 584 insertions(+), 254 deletions(-) create mode 100644 drivers/misc/lan966x_evb_lan9662_nic.dtso create mode 100644 drivers/misc/lan966x_pci.dtsi delete mode 100644 drivers/misc/lan966x_pci.dtso -- 2.53.0
null
null
null
[PATCH v5 00/28] lan966x pci device: Add support for SFPs
The code set directly dev->fwnode. Use the dedicated helper to perform this operation. Signed-off-by: Herve Codina <herve.codina@bootlin.com> Reviewed-by: Dave Jiang <dave.jiang@intel.com> --- tools/testing/cxl/test/cxl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/testing/cxl/test/cxl.c b/tools/testing/cxl/test/cxl.c index 81e2aef3627a..3d9107b2661c 100644 --- a/tools/testing/cxl/test/cxl.c +++ b/tools/testing/cxl/test/cxl.c @@ -1136,7 +1136,7 @@ static void mock_companion(struct acpi_device *adev, struct device *dev) { device_initialize(&adev->dev); fwnode_init(&adev->fwnode, NULL); - dev->fwnode = &adev->fwnode; + device_set_node(dev, &adev->fwnode); adev->fwnode.dev = dev; } -- 2.53.0
{ "author": "Herve Codina <herve.codina@bootlin.com>", "date": "Fri, 27 Feb 2026 14:54:07 +0100", "is_openbsd": false, "thread_id": "20260227135428.783983-1-herve.codina@bootlin.com.mbox.gz" }
lkml_critique
lkml
Hi, This series add support for SFPs ports available on the LAN966x PCI device. In order to have the SFPs supported, additional devices are needed such as clock controller and I2C. As a reminder, the LAN966x PCI device driver use a device-tree overlay to describe devices available on the PCI board. Adding support for SFPs ports consists in adding more devices in the already existing device-tree overlay. With those devices added, the device-tree overlay is more complex and some consumer/supplier relationship are needed in order to remove devices in correct order when the LAN966x PCI driver is removed. Those links are typically provided by fw_devlink and we faced some issues with fw_devlink and overlays. This series gives the big picture related to the SFPs support from fixing issues to adding new devices. Of course, it can be split if needed. The first part of the series (patch 1, 2 and 3) fixes fw_devlink when it is used with overlay. Patches 1 and 3 were previously sent by Saravana [0]. I rebased them on top of v7.0-rc1 and added patch 2 in order to take into account feedback received on the series sent by Saravana. Also I added a call to driver_deferred_probe_trigger() in Saravana's patch (patch 3) to ensure that probes are retried after the modification performed on the dangling consumers. This allows to fix issues reported by Matti and Geert [2] with the previous iteration patches. Those modification were not sufficient in our case and so, on top of that, patches 4 to 6 fix some more issues related to fw_devlink. Patches 7 to 12 introduce and use fw_devlink_set_device() in already existing code. Patches 13 and 14 are related also to fw_devlink but specific to PCI and the device-tree nodes created during enumeration. Patches 15, 16 and 17 are related fw_devlink too but specific to I2C muxes. Patches purpose is to correctly set a link between an adapter supplier and its consumer. Indeed, an i2c mux adapter's parent is not the i2c mux supplier but the adapter the i2c mux is connected to. Adding a new link between the adapter supplier involved when i2c muxes are used avoid a freeze observed during device removal. Patch 18 adds support for fw_delink on x86. fw_devlink is needed to have the consumer/supplier relationship between devices in order to ensure a correct device removal order. Adding fw_devlink support for x86 has been tried in the past but was reverted [1] because it broke some systems. Instead of enabling fw_devlink on *all* x86 system, enable it on *all* x86 except on those where it leads to issue. Patches 19 and 20 allow to build clock and i2c controller used by the LAN966x PCI device when the LAN966x PCI device is enabled. Patches 21 to 25 are specific to the LAN966x. They touch the current dtso, split it in dtsi/dtso files, rename the dtso and improve the driver to allow easier support for other boards. The next patch (patch 26) update the LAN966x device-tree overlay itself to have the SPF ports and devices they depends on described. The last two patches (patches 27 and 29) sort the existing drivers in the needed driver list available in the Kconfig help and add new drivers in this list keep the list up to date with the devices described in the device-tree overlay. We believe some items from the above list can be merged separately, with no build dependencies. We expect: - Patches 1 to 6 to be taken by driver core maintainers - Patches 7 to 12 to be taken by driver core maintainers - Patches 13 and 14 to be taken by driver core or PCI maintainers (depend on patch 7) - Patches 15 to 17 to be taken by I2C maintainers - Patch 18 to be taken by driver core or OF maintainers - Patch 19 to be taken by clock maintainers - Patch 20 to be taken by I2C maintainers - Patches 21 to 28 to be taken by misc maintainers Once again, this series gives the big picture and can be split if needed. Let me know. Compare to previous iteration, this v5 series mainly: - Handle Matti and Geert use cases [2] - Remove simple-platform-bus driver introduced in v4 and switch the simple-bus modification back to what was proposed in v3. In the v4 iteration, conclusion was to use v3 changes [3]. [0] https://lore.kernel.org/lkml/20240411235623.1260061-1-saravanak@google.com/ [1] https://lore.kernel.org/lkml/3c1f2473-92ad-bfc4-258e-a5a08ad73dd0@web.de/ [2] https://lore.kernel.org/all/072dde7c-a53c-4525-83ac-57ea38edc0b5@gmail.com/ [3] https://lore.kernel.org/lkml/20251114083056.31553866@bootlin.com/ Best regards, Hervé Changes: v4 -> v5 v4: https://lore.kernel.org/lkml/20251015071420.1173068-1-herve.codina@bootlin.com/ - Patch 2: Add 'Acked-by: Ulf Hansson' - Patch 3: Add a call to driver_deferred_probe_trigger() - Patch 5: (new patch) Depopulate devices at remove - Patch 6: Populate devices at probe. Switched back to modification proposed in v3 - Patch 7 in v3 removed - Patch 7 (8 in v4): Add 'Reviewed-by: Andy Shevchenko' Add 'Reviewed-by: Ulf Hansson' - Patch 8 (9 in v4): Add 'Reviewed-by: Ulf Hansson' - Patches 9 to 15 (10 to 16 in v3) No changes - Patch 16 (17 in v4): Add 'Reviewed-by: Andi Shyti' - Patch 17 (18 in v4): Change an error code from -EINVAL to -ENODEV Add a blank line and fix a typo in commit log - Patch 18 (19 in v4): Simplify of_is_fwnode_add_links_supported(). Move IS_ENABLED(CONFIG_X86) check in of_is_fwnode_add_links_supported(). - Patches 19 to 21 (20 to 22 in v4) No changes - Patch 22 (23 in v4) Update due to simple-platform-bus removal - Patches 23 to 28 (24 to 29 in v4) No changes v3 -> v4 v3: https://lore.kernel.org/lkml/20250613134817.681832-1-herve.codina@bootlin.com/ - Patch 1: No change - Patch 2: Update and fix conflicts. Indeed, since v3 iteration get_dev_from_fwnode() has been moved to device.h and used by pmdomain/core.c. - Patch 3: remove '#define get_device_from_fwnode()' - Patch 4: Fix conflict (rebase v6.17-rc6) Add 'Reviewed-by: Rafael J. Wysocki' Add 'Reviewed-by: Saravana Kannan' - Patch 5 (new in v4): Introduce simple-platform-bus (binding) - Patch 6 (5 in v3): Rework patch and introduce simple-platform-bus - Patch 7: (new) Use simple-platform-bus in LAN966x - Patch 8 (6 in v3): - No change - Patch 9 and 10 (7 and 8 in v3): Add 'Reviewed-by: Andy Shevchenko' - Patch 11 and 12 (9 and 10 in v3): Add 'Reviewed-by: Dave Jiang' - Patch 13 (11 in v3): Add 'Reviewed-by: Andy Shevchenko' - Patch 12 in v3: Patch removed. Adding __private tag in fwnode.dev is going to be handled in a dedicated series. Indeed a test robot reported an issue and more patches are needed (I have missed fwnode.dev users in several part in the kernel). - Patch 14 and 15 (13 and 14 in v3): No change - Patch 16 (14 in v3): Add 'Reviewed-by: Andi Shyti' - Patch 17 and 18 (16 and 17 in v3): No change - Patch 19 (18 in v3): Filter out support for fw_devlink on x86 based on some device-tree properties. Rewrite commit changelog Remove 'Reviewed-by: Andy Shevchenko' (significant modification) - Patch 20 (19 in v3): Add 'Acked-by: Stephen Boyd' - Patch 21 (20 in v3): Fix conflict (rebase v6.18-rc1) - Patches 22 to 24 (21 to 23 in v3): No change - Patch 25 (24 in v3): Fix conflict (rebase v6.18-rc1) Add 'Acked-by: Bjorn Helgaas' - Patches 26 to 29 (25 to 28 in v3): No change v2 -> v3 v2: https://lore.kernel.org/all/20250507071315.394857-1-herve.codina@bootlin.com/ - Patch 1: Add 'Acked-by: Mark Brown' - Patch 2 and 3: No changes - Patch 4: Rewrite the WARN_ON() condition to avoid an additional 'if' - Patch 5: Fix typos in commit log Update a comment Remove the unneeded check before calling of_platform_depopulate() - Patches 6 to 11: No changes - Patch 12 (new in v3) Tag the fwnode dev member as private - Patch 13 (12 in v2) Fix a typo in the commit log - Patches 14 to 16 (13 to 15 in v2) No changes - Patch 17 (16 in v2) Check parent_physdev for NULL - Patch 18 (17 in v2) Capitalize "Link:" Add 'Reviewed-by: Andy Shevchenko' - Patch 19 (18 in v2) No changes - Patch 20 (19 in v2) Add 'Acked-by: Andi Shyti' - Patch 21 (20 in v2) No changes - Patch 22 (21 in v2) Add 'Reviewed-by: Andrew Lunn' - Patch 23 (22 in v2) Add 'Reviewed-by: Andrew Lunn' - Patch 24 (new in v3) Introduce PCI_DEVICE_ID_EFAR_LAN9662, the LAN966x PCI device ID - Patch 25 (23 in v2) Add 'Reviewed-by: Andrew Lunn' Use PCI_DEVICE_DATA() with PCI_DEVICE_ID_EFAR_LAN9662 instead of PCI_VDEVICE() - Patch 26 to 28 (24 to 26 in v2) No changes v1 -> v2 v1: https://lore.kernel.org/lkml/20250407145546.270683-1-herve.codina@bootlin.com/ - Patch 1 and 3 Remove 'From' tag from the commit log - Patch 2 Add 'Reviewed-by: Andy Shevchenko' Add 'Reviewed-by: Saravana Kannan' Add 'Reviewed-by: Luca Ceresoli' - Patch 4 and 5 No changes - Patch 6 (new in v2) Introduce fw_devlink_set_device() - Patch 7 (new in v2) Use existing device_set_node() helper. - Patch 8 to 11 (new in v2) Use fw_devlink_set_device() in existing code. - Patch 12 (6 in v1) Use fw_devlink_add_device() - Patch 13 (7 in v1) No changes - Patch 14 (8 in v1) Update commit log Use 'physdev' instead of 'supplier' Minor fixes in i2c_get_adapter_physdev() kdoc - Patch 15 and 16 (9 and 10 in v1) Use 'physdev' instead of 'supplier' (commit log, title and code) - Patch 17 (11 in v2) Enable fw_devlink on x86 only if PCI_DYNAMIC_OF_NODES is enabled. Rework commit log. - Patch 18, 19 and 20 (12, 13 and 14 in v1) No changes - Patch 21 (new in v2) Split dtso in dtsi/dtso - Patch 22 (new in v2) Rename lan966x_pci.dtso using the specific board name - Patch 23 (new in v2) Improve the driver introducing board specific data to ease support for other boards (avoid the direct dtbo reference in the function loading the dtbo). - Patch 24 (15 in v1) Refactor due to dtso split in dtsi/dtso - Patch 25 (new in v2) Sort exist driver list in Kconfig help - Patch 26 (16 in v1) Keep alphanumeric order for new drivers added in Kconfig help Herve Codina (26): driver core: Rename get_dev_from_fwnode() wrapper to get_device_from_fwnode() driver core: Avoid warning when removing a device while its supplier is unbinding bus: simple-pm-bus: Remove child devices when the bus is unbound bus: simple-pm-bus: Populate child nodes at probe driver core: fw_devlink: Introduce fw_devlink_set_device() drivers: core: Use fw_devlink_set_device() pinctrl: cs42l43: Use fw_devlink_set_device() cxl/test: Use device_set_node() cxl/test: Use fw_devlink_set_device() PCI: of: Use fw_devlink_set_device() PCI: of: Set fwnode device of newly created PCI device nodes PCI: of: Remove fwnode_dev_initialized() call for a PCI root bridge node i2c: core: Introduce i2c_get_adapter_physdev() i2c: mux: Set adapter physical device i2c: mux: Create missing devlink between mux and adapter physical device of: property: Allow fw_devlink device-tree on x86 clk: lan966x: Add MCHP_LAN966X_PCI dependency i2c: busses: at91: Add MCHP_LAN966X_PCI dependency misc: lan966x_pci: Fix dtso nodes ordering misc: lan966x_pci: Split dtso in dtsi/dtso misc: lan966x_pci: Rename lan966x_pci.dtso to lan966x_evb_lan9662_nic.dtso PCI: Add Microchip LAN9662 PCI Device ID misc: lan966x_pci: Introduce board specific data misc: lan966x_pci: Add dtsi/dtso nodes in order to support SFPs misc: lan966x_pci: Sort the drivers list in Kconfig help misc: lan966x_pci: Add drivers needed to support SFPs in Kconfig help Saravana Kannan (2): Revert "treewide: Fix probing of devices in DT overlays" of: dynamic: Fix overlayed devices not probing because of fw_devlink MAINTAINERS | 3 +- drivers/base/core.c | 108 ++++++++++--- drivers/bus/imx-weim.c | 6 - drivers/bus/simple-pm-bus.c | 24 +-- drivers/clk/Kconfig | 2 +- drivers/i2c/busses/Kconfig | 2 +- drivers/i2c/i2c-core-base.c | 16 ++ drivers/i2c/i2c-core-of.c | 5 - drivers/i2c/i2c-mux.c | 26 ++++ drivers/misc/Kconfig | 11 +- drivers/misc/Makefile | 2 +- drivers/misc/lan966x_evb_lan9662_nic.dtso | 167 ++++++++++++++++++++ drivers/misc/lan966x_pci.c | 30 +++- drivers/misc/lan966x_pci.dtsi | 172 +++++++++++++++++++++ drivers/misc/lan966x_pci.dtso | 177 ---------------------- drivers/of/dynamic.c | 1 - drivers/of/overlay.c | 15 ++ drivers/of/platform.c | 5 - drivers/of/property.c | 26 +++- drivers/pci/of.c | 10 +- drivers/pci/quirks.c | 2 +- drivers/pinctrl/cirrus/pinctrl-cs42l43.c | 2 +- drivers/pmdomain/core.c | 4 +- drivers/spi/spi.c | 5 - include/linux/device.h | 2 +- include/linux/fwnode.h | 7 + include/linux/i2c.h | 3 + include/linux/pci_ids.h | 1 + tools/testing/cxl/test/cxl.c | 4 +- 29 files changed, 584 insertions(+), 254 deletions(-) create mode 100644 drivers/misc/lan966x_evb_lan9662_nic.dtso create mode 100644 drivers/misc/lan966x_pci.dtsi delete mode 100644 drivers/misc/lan966x_pci.dtso -- 2.53.0
null
null
null
[PATCH v5 00/28] lan966x pci device: Add support for SFPs
The code set directly fwnode.dev field. Use the dedicated fw_devlink_set_device() helper to perform this operation. Signed-off-by: Herve Codina <herve.codina@bootlin.com> Reviewed-by: Dave Jiang <dave.jiang@intel.com> --- tools/testing/cxl/test/cxl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/testing/cxl/test/cxl.c b/tools/testing/cxl/test/cxl.c index 3d9107b2661c..7f232a869389 100644 --- a/tools/testing/cxl/test/cxl.c +++ b/tools/testing/cxl/test/cxl.c @@ -1137,7 +1137,7 @@ static void mock_companion(struct acpi_device *adev, struct device *dev) device_initialize(&adev->dev); fwnode_init(&adev->fwnode, NULL); device_set_node(dev, &adev->fwnode); - adev->fwnode.dev = dev; + fw_devlink_set_device(&adev->fwnode, dev); } #ifndef SZ_64G -- 2.53.0
{ "author": "Herve Codina <herve.codina@bootlin.com>", "date": "Fri, 27 Feb 2026 14:54:08 +0100", "is_openbsd": false, "thread_id": "20260227135428.783983-1-herve.codina@bootlin.com.mbox.gz" }
lkml_critique
lkml
Hi, This series add support for SFPs ports available on the LAN966x PCI device. In order to have the SFPs supported, additional devices are needed such as clock controller and I2C. As a reminder, the LAN966x PCI device driver use a device-tree overlay to describe devices available on the PCI board. Adding support for SFPs ports consists in adding more devices in the already existing device-tree overlay. With those devices added, the device-tree overlay is more complex and some consumer/supplier relationship are needed in order to remove devices in correct order when the LAN966x PCI driver is removed. Those links are typically provided by fw_devlink and we faced some issues with fw_devlink and overlays. This series gives the big picture related to the SFPs support from fixing issues to adding new devices. Of course, it can be split if needed. The first part of the series (patch 1, 2 and 3) fixes fw_devlink when it is used with overlay. Patches 1 and 3 were previously sent by Saravana [0]. I rebased them on top of v7.0-rc1 and added patch 2 in order to take into account feedback received on the series sent by Saravana. Also I added a call to driver_deferred_probe_trigger() in Saravana's patch (patch 3) to ensure that probes are retried after the modification performed on the dangling consumers. This allows to fix issues reported by Matti and Geert [2] with the previous iteration patches. Those modification were not sufficient in our case and so, on top of that, patches 4 to 6 fix some more issues related to fw_devlink. Patches 7 to 12 introduce and use fw_devlink_set_device() in already existing code. Patches 13 and 14 are related also to fw_devlink but specific to PCI and the device-tree nodes created during enumeration. Patches 15, 16 and 17 are related fw_devlink too but specific to I2C muxes. Patches purpose is to correctly set a link between an adapter supplier and its consumer. Indeed, an i2c mux adapter's parent is not the i2c mux supplier but the adapter the i2c mux is connected to. Adding a new link between the adapter supplier involved when i2c muxes are used avoid a freeze observed during device removal. Patch 18 adds support for fw_delink on x86. fw_devlink is needed to have the consumer/supplier relationship between devices in order to ensure a correct device removal order. Adding fw_devlink support for x86 has been tried in the past but was reverted [1] because it broke some systems. Instead of enabling fw_devlink on *all* x86 system, enable it on *all* x86 except on those where it leads to issue. Patches 19 and 20 allow to build clock and i2c controller used by the LAN966x PCI device when the LAN966x PCI device is enabled. Patches 21 to 25 are specific to the LAN966x. They touch the current dtso, split it in dtsi/dtso files, rename the dtso and improve the driver to allow easier support for other boards. The next patch (patch 26) update the LAN966x device-tree overlay itself to have the SPF ports and devices they depends on described. The last two patches (patches 27 and 29) sort the existing drivers in the needed driver list available in the Kconfig help and add new drivers in this list keep the list up to date with the devices described in the device-tree overlay. We believe some items from the above list can be merged separately, with no build dependencies. We expect: - Patches 1 to 6 to be taken by driver core maintainers - Patches 7 to 12 to be taken by driver core maintainers - Patches 13 and 14 to be taken by driver core or PCI maintainers (depend on patch 7) - Patches 15 to 17 to be taken by I2C maintainers - Patch 18 to be taken by driver core or OF maintainers - Patch 19 to be taken by clock maintainers - Patch 20 to be taken by I2C maintainers - Patches 21 to 28 to be taken by misc maintainers Once again, this series gives the big picture and can be split if needed. Let me know. Compare to previous iteration, this v5 series mainly: - Handle Matti and Geert use cases [2] - Remove simple-platform-bus driver introduced in v4 and switch the simple-bus modification back to what was proposed in v3. In the v4 iteration, conclusion was to use v3 changes [3]. [0] https://lore.kernel.org/lkml/20240411235623.1260061-1-saravanak@google.com/ [1] https://lore.kernel.org/lkml/3c1f2473-92ad-bfc4-258e-a5a08ad73dd0@web.de/ [2] https://lore.kernel.org/all/072dde7c-a53c-4525-83ac-57ea38edc0b5@gmail.com/ [3] https://lore.kernel.org/lkml/20251114083056.31553866@bootlin.com/ Best regards, Hervé Changes: v4 -> v5 v4: https://lore.kernel.org/lkml/20251015071420.1173068-1-herve.codina@bootlin.com/ - Patch 2: Add 'Acked-by: Ulf Hansson' - Patch 3: Add a call to driver_deferred_probe_trigger() - Patch 5: (new patch) Depopulate devices at remove - Patch 6: Populate devices at probe. Switched back to modification proposed in v3 - Patch 7 in v3 removed - Patch 7 (8 in v4): Add 'Reviewed-by: Andy Shevchenko' Add 'Reviewed-by: Ulf Hansson' - Patch 8 (9 in v4): Add 'Reviewed-by: Ulf Hansson' - Patches 9 to 15 (10 to 16 in v3) No changes - Patch 16 (17 in v4): Add 'Reviewed-by: Andi Shyti' - Patch 17 (18 in v4): Change an error code from -EINVAL to -ENODEV Add a blank line and fix a typo in commit log - Patch 18 (19 in v4): Simplify of_is_fwnode_add_links_supported(). Move IS_ENABLED(CONFIG_X86) check in of_is_fwnode_add_links_supported(). - Patches 19 to 21 (20 to 22 in v4) No changes - Patch 22 (23 in v4) Update due to simple-platform-bus removal - Patches 23 to 28 (24 to 29 in v4) No changes v3 -> v4 v3: https://lore.kernel.org/lkml/20250613134817.681832-1-herve.codina@bootlin.com/ - Patch 1: No change - Patch 2: Update and fix conflicts. Indeed, since v3 iteration get_dev_from_fwnode() has been moved to device.h and used by pmdomain/core.c. - Patch 3: remove '#define get_device_from_fwnode()' - Patch 4: Fix conflict (rebase v6.17-rc6) Add 'Reviewed-by: Rafael J. Wysocki' Add 'Reviewed-by: Saravana Kannan' - Patch 5 (new in v4): Introduce simple-platform-bus (binding) - Patch 6 (5 in v3): Rework patch and introduce simple-platform-bus - Patch 7: (new) Use simple-platform-bus in LAN966x - Patch 8 (6 in v3): - No change - Patch 9 and 10 (7 and 8 in v3): Add 'Reviewed-by: Andy Shevchenko' - Patch 11 and 12 (9 and 10 in v3): Add 'Reviewed-by: Dave Jiang' - Patch 13 (11 in v3): Add 'Reviewed-by: Andy Shevchenko' - Patch 12 in v3: Patch removed. Adding __private tag in fwnode.dev is going to be handled in a dedicated series. Indeed a test robot reported an issue and more patches are needed (I have missed fwnode.dev users in several part in the kernel). - Patch 14 and 15 (13 and 14 in v3): No change - Patch 16 (14 in v3): Add 'Reviewed-by: Andi Shyti' - Patch 17 and 18 (16 and 17 in v3): No change - Patch 19 (18 in v3): Filter out support for fw_devlink on x86 based on some device-tree properties. Rewrite commit changelog Remove 'Reviewed-by: Andy Shevchenko' (significant modification) - Patch 20 (19 in v3): Add 'Acked-by: Stephen Boyd' - Patch 21 (20 in v3): Fix conflict (rebase v6.18-rc1) - Patches 22 to 24 (21 to 23 in v3): No change - Patch 25 (24 in v3): Fix conflict (rebase v6.18-rc1) Add 'Acked-by: Bjorn Helgaas' - Patches 26 to 29 (25 to 28 in v3): No change v2 -> v3 v2: https://lore.kernel.org/all/20250507071315.394857-1-herve.codina@bootlin.com/ - Patch 1: Add 'Acked-by: Mark Brown' - Patch 2 and 3: No changes - Patch 4: Rewrite the WARN_ON() condition to avoid an additional 'if' - Patch 5: Fix typos in commit log Update a comment Remove the unneeded check before calling of_platform_depopulate() - Patches 6 to 11: No changes - Patch 12 (new in v3) Tag the fwnode dev member as private - Patch 13 (12 in v2) Fix a typo in the commit log - Patches 14 to 16 (13 to 15 in v2) No changes - Patch 17 (16 in v2) Check parent_physdev for NULL - Patch 18 (17 in v2) Capitalize "Link:" Add 'Reviewed-by: Andy Shevchenko' - Patch 19 (18 in v2) No changes - Patch 20 (19 in v2) Add 'Acked-by: Andi Shyti' - Patch 21 (20 in v2) No changes - Patch 22 (21 in v2) Add 'Reviewed-by: Andrew Lunn' - Patch 23 (22 in v2) Add 'Reviewed-by: Andrew Lunn' - Patch 24 (new in v3) Introduce PCI_DEVICE_ID_EFAR_LAN9662, the LAN966x PCI device ID - Patch 25 (23 in v2) Add 'Reviewed-by: Andrew Lunn' Use PCI_DEVICE_DATA() with PCI_DEVICE_ID_EFAR_LAN9662 instead of PCI_VDEVICE() - Patch 26 to 28 (24 to 26 in v2) No changes v1 -> v2 v1: https://lore.kernel.org/lkml/20250407145546.270683-1-herve.codina@bootlin.com/ - Patch 1 and 3 Remove 'From' tag from the commit log - Patch 2 Add 'Reviewed-by: Andy Shevchenko' Add 'Reviewed-by: Saravana Kannan' Add 'Reviewed-by: Luca Ceresoli' - Patch 4 and 5 No changes - Patch 6 (new in v2) Introduce fw_devlink_set_device() - Patch 7 (new in v2) Use existing device_set_node() helper. - Patch 8 to 11 (new in v2) Use fw_devlink_set_device() in existing code. - Patch 12 (6 in v1) Use fw_devlink_add_device() - Patch 13 (7 in v1) No changes - Patch 14 (8 in v1) Update commit log Use 'physdev' instead of 'supplier' Minor fixes in i2c_get_adapter_physdev() kdoc - Patch 15 and 16 (9 and 10 in v1) Use 'physdev' instead of 'supplier' (commit log, title and code) - Patch 17 (11 in v2) Enable fw_devlink on x86 only if PCI_DYNAMIC_OF_NODES is enabled. Rework commit log. - Patch 18, 19 and 20 (12, 13 and 14 in v1) No changes - Patch 21 (new in v2) Split dtso in dtsi/dtso - Patch 22 (new in v2) Rename lan966x_pci.dtso using the specific board name - Patch 23 (new in v2) Improve the driver introducing board specific data to ease support for other boards (avoid the direct dtbo reference in the function loading the dtbo). - Patch 24 (15 in v1) Refactor due to dtso split in dtsi/dtso - Patch 25 (new in v2) Sort exist driver list in Kconfig help - Patch 26 (16 in v1) Keep alphanumeric order for new drivers added in Kconfig help Herve Codina (26): driver core: Rename get_dev_from_fwnode() wrapper to get_device_from_fwnode() driver core: Avoid warning when removing a device while its supplier is unbinding bus: simple-pm-bus: Remove child devices when the bus is unbound bus: simple-pm-bus: Populate child nodes at probe driver core: fw_devlink: Introduce fw_devlink_set_device() drivers: core: Use fw_devlink_set_device() pinctrl: cs42l43: Use fw_devlink_set_device() cxl/test: Use device_set_node() cxl/test: Use fw_devlink_set_device() PCI: of: Use fw_devlink_set_device() PCI: of: Set fwnode device of newly created PCI device nodes PCI: of: Remove fwnode_dev_initialized() call for a PCI root bridge node i2c: core: Introduce i2c_get_adapter_physdev() i2c: mux: Set adapter physical device i2c: mux: Create missing devlink between mux and adapter physical device of: property: Allow fw_devlink device-tree on x86 clk: lan966x: Add MCHP_LAN966X_PCI dependency i2c: busses: at91: Add MCHP_LAN966X_PCI dependency misc: lan966x_pci: Fix dtso nodes ordering misc: lan966x_pci: Split dtso in dtsi/dtso misc: lan966x_pci: Rename lan966x_pci.dtso to lan966x_evb_lan9662_nic.dtso PCI: Add Microchip LAN9662 PCI Device ID misc: lan966x_pci: Introduce board specific data misc: lan966x_pci: Add dtsi/dtso nodes in order to support SFPs misc: lan966x_pci: Sort the drivers list in Kconfig help misc: lan966x_pci: Add drivers needed to support SFPs in Kconfig help Saravana Kannan (2): Revert "treewide: Fix probing of devices in DT overlays" of: dynamic: Fix overlayed devices not probing because of fw_devlink MAINTAINERS | 3 +- drivers/base/core.c | 108 ++++++++++--- drivers/bus/imx-weim.c | 6 - drivers/bus/simple-pm-bus.c | 24 +-- drivers/clk/Kconfig | 2 +- drivers/i2c/busses/Kconfig | 2 +- drivers/i2c/i2c-core-base.c | 16 ++ drivers/i2c/i2c-core-of.c | 5 - drivers/i2c/i2c-mux.c | 26 ++++ drivers/misc/Kconfig | 11 +- drivers/misc/Makefile | 2 +- drivers/misc/lan966x_evb_lan9662_nic.dtso | 167 ++++++++++++++++++++ drivers/misc/lan966x_pci.c | 30 +++- drivers/misc/lan966x_pci.dtsi | 172 +++++++++++++++++++++ drivers/misc/lan966x_pci.dtso | 177 ---------------------- drivers/of/dynamic.c | 1 - drivers/of/overlay.c | 15 ++ drivers/of/platform.c | 5 - drivers/of/property.c | 26 +++- drivers/pci/of.c | 10 +- drivers/pci/quirks.c | 2 +- drivers/pinctrl/cirrus/pinctrl-cs42l43.c | 2 +- drivers/pmdomain/core.c | 4 +- drivers/spi/spi.c | 5 - include/linux/device.h | 2 +- include/linux/fwnode.h | 7 + include/linux/i2c.h | 3 + include/linux/pci_ids.h | 1 + tools/testing/cxl/test/cxl.c | 4 +- 29 files changed, 584 insertions(+), 254 deletions(-) create mode 100644 drivers/misc/lan966x_evb_lan9662_nic.dtso create mode 100644 drivers/misc/lan966x_pci.dtsi delete mode 100644 drivers/misc/lan966x_pci.dtso -- 2.53.0
null
null
null
[PATCH v5 00/28] lan966x pci device: Add support for SFPs
The code set directly fwnode.dev field. Use the dedicated fw_devlink_set_device() helper to perform this operation. Signed-off-by: Herve Codina <herve.codina@bootlin.com> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> --- drivers/pci/of.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/pci/of.c b/drivers/pci/of.c index 9f8eb5df279e..5fb7f501fd35 100644 --- a/drivers/pci/of.c +++ b/drivers/pci/of.c @@ -803,7 +803,7 @@ void of_pci_make_host_bridge_node(struct pci_host_bridge *bridge) * bus. Avoid any new device creation. */ of_node_set_flag(np, OF_POPULATED); - np->fwnode.dev = &bridge->dev; + fw_devlink_set_device(&np->fwnode, &bridge->dev); fwnode_dev_initialized(&np->fwnode, true); ret = of_changeset_apply(cset); -- 2.53.0
{ "author": "Herve Codina <herve.codina@bootlin.com>", "date": "Fri, 27 Feb 2026 14:54:09 +0100", "is_openbsd": false, "thread_id": "20260227135428.783983-1-herve.codina@bootlin.com.mbox.gz" }
lkml_critique
lkml
Hi, This series add support for SFPs ports available on the LAN966x PCI device. In order to have the SFPs supported, additional devices are needed such as clock controller and I2C. As a reminder, the LAN966x PCI device driver use a device-tree overlay to describe devices available on the PCI board. Adding support for SFPs ports consists in adding more devices in the already existing device-tree overlay. With those devices added, the device-tree overlay is more complex and some consumer/supplier relationship are needed in order to remove devices in correct order when the LAN966x PCI driver is removed. Those links are typically provided by fw_devlink and we faced some issues with fw_devlink and overlays. This series gives the big picture related to the SFPs support from fixing issues to adding new devices. Of course, it can be split if needed. The first part of the series (patch 1, 2 and 3) fixes fw_devlink when it is used with overlay. Patches 1 and 3 were previously sent by Saravana [0]. I rebased them on top of v7.0-rc1 and added patch 2 in order to take into account feedback received on the series sent by Saravana. Also I added a call to driver_deferred_probe_trigger() in Saravana's patch (patch 3) to ensure that probes are retried after the modification performed on the dangling consumers. This allows to fix issues reported by Matti and Geert [2] with the previous iteration patches. Those modification were not sufficient in our case and so, on top of that, patches 4 to 6 fix some more issues related to fw_devlink. Patches 7 to 12 introduce and use fw_devlink_set_device() in already existing code. Patches 13 and 14 are related also to fw_devlink but specific to PCI and the device-tree nodes created during enumeration. Patches 15, 16 and 17 are related fw_devlink too but specific to I2C muxes. Patches purpose is to correctly set a link between an adapter supplier and its consumer. Indeed, an i2c mux adapter's parent is not the i2c mux supplier but the adapter the i2c mux is connected to. Adding a new link between the adapter supplier involved when i2c muxes are used avoid a freeze observed during device removal. Patch 18 adds support for fw_delink on x86. fw_devlink is needed to have the consumer/supplier relationship between devices in order to ensure a correct device removal order. Adding fw_devlink support for x86 has been tried in the past but was reverted [1] because it broke some systems. Instead of enabling fw_devlink on *all* x86 system, enable it on *all* x86 except on those where it leads to issue. Patches 19 and 20 allow to build clock and i2c controller used by the LAN966x PCI device when the LAN966x PCI device is enabled. Patches 21 to 25 are specific to the LAN966x. They touch the current dtso, split it in dtsi/dtso files, rename the dtso and improve the driver to allow easier support for other boards. The next patch (patch 26) update the LAN966x device-tree overlay itself to have the SPF ports and devices they depends on described. The last two patches (patches 27 and 29) sort the existing drivers in the needed driver list available in the Kconfig help and add new drivers in this list keep the list up to date with the devices described in the device-tree overlay. We believe some items from the above list can be merged separately, with no build dependencies. We expect: - Patches 1 to 6 to be taken by driver core maintainers - Patches 7 to 12 to be taken by driver core maintainers - Patches 13 and 14 to be taken by driver core or PCI maintainers (depend on patch 7) - Patches 15 to 17 to be taken by I2C maintainers - Patch 18 to be taken by driver core or OF maintainers - Patch 19 to be taken by clock maintainers - Patch 20 to be taken by I2C maintainers - Patches 21 to 28 to be taken by misc maintainers Once again, this series gives the big picture and can be split if needed. Let me know. Compare to previous iteration, this v5 series mainly: - Handle Matti and Geert use cases [2] - Remove simple-platform-bus driver introduced in v4 and switch the simple-bus modification back to what was proposed in v3. In the v4 iteration, conclusion was to use v3 changes [3]. [0] https://lore.kernel.org/lkml/20240411235623.1260061-1-saravanak@google.com/ [1] https://lore.kernel.org/lkml/3c1f2473-92ad-bfc4-258e-a5a08ad73dd0@web.de/ [2] https://lore.kernel.org/all/072dde7c-a53c-4525-83ac-57ea38edc0b5@gmail.com/ [3] https://lore.kernel.org/lkml/20251114083056.31553866@bootlin.com/ Best regards, Hervé Changes: v4 -> v5 v4: https://lore.kernel.org/lkml/20251015071420.1173068-1-herve.codina@bootlin.com/ - Patch 2: Add 'Acked-by: Ulf Hansson' - Patch 3: Add a call to driver_deferred_probe_trigger() - Patch 5: (new patch) Depopulate devices at remove - Patch 6: Populate devices at probe. Switched back to modification proposed in v3 - Patch 7 in v3 removed - Patch 7 (8 in v4): Add 'Reviewed-by: Andy Shevchenko' Add 'Reviewed-by: Ulf Hansson' - Patch 8 (9 in v4): Add 'Reviewed-by: Ulf Hansson' - Patches 9 to 15 (10 to 16 in v3) No changes - Patch 16 (17 in v4): Add 'Reviewed-by: Andi Shyti' - Patch 17 (18 in v4): Change an error code from -EINVAL to -ENODEV Add a blank line and fix a typo in commit log - Patch 18 (19 in v4): Simplify of_is_fwnode_add_links_supported(). Move IS_ENABLED(CONFIG_X86) check in of_is_fwnode_add_links_supported(). - Patches 19 to 21 (20 to 22 in v4) No changes - Patch 22 (23 in v4) Update due to simple-platform-bus removal - Patches 23 to 28 (24 to 29 in v4) No changes v3 -> v4 v3: https://lore.kernel.org/lkml/20250613134817.681832-1-herve.codina@bootlin.com/ - Patch 1: No change - Patch 2: Update and fix conflicts. Indeed, since v3 iteration get_dev_from_fwnode() has been moved to device.h and used by pmdomain/core.c. - Patch 3: remove '#define get_device_from_fwnode()' - Patch 4: Fix conflict (rebase v6.17-rc6) Add 'Reviewed-by: Rafael J. Wysocki' Add 'Reviewed-by: Saravana Kannan' - Patch 5 (new in v4): Introduce simple-platform-bus (binding) - Patch 6 (5 in v3): Rework patch and introduce simple-platform-bus - Patch 7: (new) Use simple-platform-bus in LAN966x - Patch 8 (6 in v3): - No change - Patch 9 and 10 (7 and 8 in v3): Add 'Reviewed-by: Andy Shevchenko' - Patch 11 and 12 (9 and 10 in v3): Add 'Reviewed-by: Dave Jiang' - Patch 13 (11 in v3): Add 'Reviewed-by: Andy Shevchenko' - Patch 12 in v3: Patch removed. Adding __private tag in fwnode.dev is going to be handled in a dedicated series. Indeed a test robot reported an issue and more patches are needed (I have missed fwnode.dev users in several part in the kernel). - Patch 14 and 15 (13 and 14 in v3): No change - Patch 16 (14 in v3): Add 'Reviewed-by: Andi Shyti' - Patch 17 and 18 (16 and 17 in v3): No change - Patch 19 (18 in v3): Filter out support for fw_devlink on x86 based on some device-tree properties. Rewrite commit changelog Remove 'Reviewed-by: Andy Shevchenko' (significant modification) - Patch 20 (19 in v3): Add 'Acked-by: Stephen Boyd' - Patch 21 (20 in v3): Fix conflict (rebase v6.18-rc1) - Patches 22 to 24 (21 to 23 in v3): No change - Patch 25 (24 in v3): Fix conflict (rebase v6.18-rc1) Add 'Acked-by: Bjorn Helgaas' - Patches 26 to 29 (25 to 28 in v3): No change v2 -> v3 v2: https://lore.kernel.org/all/20250507071315.394857-1-herve.codina@bootlin.com/ - Patch 1: Add 'Acked-by: Mark Brown' - Patch 2 and 3: No changes - Patch 4: Rewrite the WARN_ON() condition to avoid an additional 'if' - Patch 5: Fix typos in commit log Update a comment Remove the unneeded check before calling of_platform_depopulate() - Patches 6 to 11: No changes - Patch 12 (new in v3) Tag the fwnode dev member as private - Patch 13 (12 in v2) Fix a typo in the commit log - Patches 14 to 16 (13 to 15 in v2) No changes - Patch 17 (16 in v2) Check parent_physdev for NULL - Patch 18 (17 in v2) Capitalize "Link:" Add 'Reviewed-by: Andy Shevchenko' - Patch 19 (18 in v2) No changes - Patch 20 (19 in v2) Add 'Acked-by: Andi Shyti' - Patch 21 (20 in v2) No changes - Patch 22 (21 in v2) Add 'Reviewed-by: Andrew Lunn' - Patch 23 (22 in v2) Add 'Reviewed-by: Andrew Lunn' - Patch 24 (new in v3) Introduce PCI_DEVICE_ID_EFAR_LAN9662, the LAN966x PCI device ID - Patch 25 (23 in v2) Add 'Reviewed-by: Andrew Lunn' Use PCI_DEVICE_DATA() with PCI_DEVICE_ID_EFAR_LAN9662 instead of PCI_VDEVICE() - Patch 26 to 28 (24 to 26 in v2) No changes v1 -> v2 v1: https://lore.kernel.org/lkml/20250407145546.270683-1-herve.codina@bootlin.com/ - Patch 1 and 3 Remove 'From' tag from the commit log - Patch 2 Add 'Reviewed-by: Andy Shevchenko' Add 'Reviewed-by: Saravana Kannan' Add 'Reviewed-by: Luca Ceresoli' - Patch 4 and 5 No changes - Patch 6 (new in v2) Introduce fw_devlink_set_device() - Patch 7 (new in v2) Use existing device_set_node() helper. - Patch 8 to 11 (new in v2) Use fw_devlink_set_device() in existing code. - Patch 12 (6 in v1) Use fw_devlink_add_device() - Patch 13 (7 in v1) No changes - Patch 14 (8 in v1) Update commit log Use 'physdev' instead of 'supplier' Minor fixes in i2c_get_adapter_physdev() kdoc - Patch 15 and 16 (9 and 10 in v1) Use 'physdev' instead of 'supplier' (commit log, title and code) - Patch 17 (11 in v2) Enable fw_devlink on x86 only if PCI_DYNAMIC_OF_NODES is enabled. Rework commit log. - Patch 18, 19 and 20 (12, 13 and 14 in v1) No changes - Patch 21 (new in v2) Split dtso in dtsi/dtso - Patch 22 (new in v2) Rename lan966x_pci.dtso using the specific board name - Patch 23 (new in v2) Improve the driver introducing board specific data to ease support for other boards (avoid the direct dtbo reference in the function loading the dtbo). - Patch 24 (15 in v1) Refactor due to dtso split in dtsi/dtso - Patch 25 (new in v2) Sort exist driver list in Kconfig help - Patch 26 (16 in v1) Keep alphanumeric order for new drivers added in Kconfig help Herve Codina (26): driver core: Rename get_dev_from_fwnode() wrapper to get_device_from_fwnode() driver core: Avoid warning when removing a device while its supplier is unbinding bus: simple-pm-bus: Remove child devices when the bus is unbound bus: simple-pm-bus: Populate child nodes at probe driver core: fw_devlink: Introduce fw_devlink_set_device() drivers: core: Use fw_devlink_set_device() pinctrl: cs42l43: Use fw_devlink_set_device() cxl/test: Use device_set_node() cxl/test: Use fw_devlink_set_device() PCI: of: Use fw_devlink_set_device() PCI: of: Set fwnode device of newly created PCI device nodes PCI: of: Remove fwnode_dev_initialized() call for a PCI root bridge node i2c: core: Introduce i2c_get_adapter_physdev() i2c: mux: Set adapter physical device i2c: mux: Create missing devlink between mux and adapter physical device of: property: Allow fw_devlink device-tree on x86 clk: lan966x: Add MCHP_LAN966X_PCI dependency i2c: busses: at91: Add MCHP_LAN966X_PCI dependency misc: lan966x_pci: Fix dtso nodes ordering misc: lan966x_pci: Split dtso in dtsi/dtso misc: lan966x_pci: Rename lan966x_pci.dtso to lan966x_evb_lan9662_nic.dtso PCI: Add Microchip LAN9662 PCI Device ID misc: lan966x_pci: Introduce board specific data misc: lan966x_pci: Add dtsi/dtso nodes in order to support SFPs misc: lan966x_pci: Sort the drivers list in Kconfig help misc: lan966x_pci: Add drivers needed to support SFPs in Kconfig help Saravana Kannan (2): Revert "treewide: Fix probing of devices in DT overlays" of: dynamic: Fix overlayed devices not probing because of fw_devlink MAINTAINERS | 3 +- drivers/base/core.c | 108 ++++++++++--- drivers/bus/imx-weim.c | 6 - drivers/bus/simple-pm-bus.c | 24 +-- drivers/clk/Kconfig | 2 +- drivers/i2c/busses/Kconfig | 2 +- drivers/i2c/i2c-core-base.c | 16 ++ drivers/i2c/i2c-core-of.c | 5 - drivers/i2c/i2c-mux.c | 26 ++++ drivers/misc/Kconfig | 11 +- drivers/misc/Makefile | 2 +- drivers/misc/lan966x_evb_lan9662_nic.dtso | 167 ++++++++++++++++++++ drivers/misc/lan966x_pci.c | 30 +++- drivers/misc/lan966x_pci.dtsi | 172 +++++++++++++++++++++ drivers/misc/lan966x_pci.dtso | 177 ---------------------- drivers/of/dynamic.c | 1 - drivers/of/overlay.c | 15 ++ drivers/of/platform.c | 5 - drivers/of/property.c | 26 +++- drivers/pci/of.c | 10 +- drivers/pci/quirks.c | 2 +- drivers/pinctrl/cirrus/pinctrl-cs42l43.c | 2 +- drivers/pmdomain/core.c | 4 +- drivers/spi/spi.c | 5 - include/linux/device.h | 2 +- include/linux/fwnode.h | 7 + include/linux/i2c.h | 3 + include/linux/pci_ids.h | 1 + tools/testing/cxl/test/cxl.c | 4 +- 29 files changed, 584 insertions(+), 254 deletions(-) create mode 100644 drivers/misc/lan966x_evb_lan9662_nic.dtso create mode 100644 drivers/misc/lan966x_pci.dtsi delete mode 100644 drivers/misc/lan966x_pci.dtso -- 2.53.0
null
null
null
[PATCH v5 00/28] lan966x pci device: Add support for SFPs
Device-tree node can be created when CONFIG_PCI_DYNAMIC_OF_NODES. Those node are created and filled based on PCI core information but the fwnode device field is not set. When later an overlay is applied, this confuses fw_devlink. Indeed, without any device attached to the node, fw_devlink considers that this node will never become a device. When this node is pointed as a supplier, devlink looks at its ancestors in order to find a node with a device that could be used as the supplier. In the PCI use case, this leads to links that wrongly use the PCI root bridge device as the supplier instead of the expected PCI device. Setting the fwnode device to the device of the PCI device allows devlink to use this device as a supplier and so, correct links are created. Signed-off-by: Herve Codina <herve.codina@bootlin.com> --- drivers/pci/of.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/pci/of.c b/drivers/pci/of.c index 5fb7f501fd35..b694fcda16b1 100644 --- a/drivers/pci/of.c +++ b/drivers/pci/of.c @@ -709,6 +709,13 @@ void of_pci_make_dev_node(struct pci_dev *pdev) if (ret) goto out_free_node; + /* + * Set the fwnode device in order to have fw_devlink creating links + * pointing to this PCI device instead of walking up to the PCI host + * bridge. + */ + fw_devlink_set_device(&np->fwnode, &pdev->dev); + ret = of_changeset_apply(cset); if (ret) goto out_free_node; -- 2.53.0
{ "author": "Herve Codina <herve.codina@bootlin.com>", "date": "Fri, 27 Feb 2026 14:54:10 +0100", "is_openbsd": false, "thread_id": "20260227135428.783983-1-herve.codina@bootlin.com.mbox.gz" }
lkml_critique
lkml
Hi, This series add support for SFPs ports available on the LAN966x PCI device. In order to have the SFPs supported, additional devices are needed such as clock controller and I2C. As a reminder, the LAN966x PCI device driver use a device-tree overlay to describe devices available on the PCI board. Adding support for SFPs ports consists in adding more devices in the already existing device-tree overlay. With those devices added, the device-tree overlay is more complex and some consumer/supplier relationship are needed in order to remove devices in correct order when the LAN966x PCI driver is removed. Those links are typically provided by fw_devlink and we faced some issues with fw_devlink and overlays. This series gives the big picture related to the SFPs support from fixing issues to adding new devices. Of course, it can be split if needed. The first part of the series (patch 1, 2 and 3) fixes fw_devlink when it is used with overlay. Patches 1 and 3 were previously sent by Saravana [0]. I rebased them on top of v7.0-rc1 and added patch 2 in order to take into account feedback received on the series sent by Saravana. Also I added a call to driver_deferred_probe_trigger() in Saravana's patch (patch 3) to ensure that probes are retried after the modification performed on the dangling consumers. This allows to fix issues reported by Matti and Geert [2] with the previous iteration patches. Those modification were not sufficient in our case and so, on top of that, patches 4 to 6 fix some more issues related to fw_devlink. Patches 7 to 12 introduce and use fw_devlink_set_device() in already existing code. Patches 13 and 14 are related also to fw_devlink but specific to PCI and the device-tree nodes created during enumeration. Patches 15, 16 and 17 are related fw_devlink too but specific to I2C muxes. Patches purpose is to correctly set a link between an adapter supplier and its consumer. Indeed, an i2c mux adapter's parent is not the i2c mux supplier but the adapter the i2c mux is connected to. Adding a new link between the adapter supplier involved when i2c muxes are used avoid a freeze observed during device removal. Patch 18 adds support for fw_delink on x86. fw_devlink is needed to have the consumer/supplier relationship between devices in order to ensure a correct device removal order. Adding fw_devlink support for x86 has been tried in the past but was reverted [1] because it broke some systems. Instead of enabling fw_devlink on *all* x86 system, enable it on *all* x86 except on those where it leads to issue. Patches 19 and 20 allow to build clock and i2c controller used by the LAN966x PCI device when the LAN966x PCI device is enabled. Patches 21 to 25 are specific to the LAN966x. They touch the current dtso, split it in dtsi/dtso files, rename the dtso and improve the driver to allow easier support for other boards. The next patch (patch 26) update the LAN966x device-tree overlay itself to have the SPF ports and devices they depends on described. The last two patches (patches 27 and 29) sort the existing drivers in the needed driver list available in the Kconfig help and add new drivers in this list keep the list up to date with the devices described in the device-tree overlay. We believe some items from the above list can be merged separately, with no build dependencies. We expect: - Patches 1 to 6 to be taken by driver core maintainers - Patches 7 to 12 to be taken by driver core maintainers - Patches 13 and 14 to be taken by driver core or PCI maintainers (depend on patch 7) - Patches 15 to 17 to be taken by I2C maintainers - Patch 18 to be taken by driver core or OF maintainers - Patch 19 to be taken by clock maintainers - Patch 20 to be taken by I2C maintainers - Patches 21 to 28 to be taken by misc maintainers Once again, this series gives the big picture and can be split if needed. Let me know. Compare to previous iteration, this v5 series mainly: - Handle Matti and Geert use cases [2] - Remove simple-platform-bus driver introduced in v4 and switch the simple-bus modification back to what was proposed in v3. In the v4 iteration, conclusion was to use v3 changes [3]. [0] https://lore.kernel.org/lkml/20240411235623.1260061-1-saravanak@google.com/ [1] https://lore.kernel.org/lkml/3c1f2473-92ad-bfc4-258e-a5a08ad73dd0@web.de/ [2] https://lore.kernel.org/all/072dde7c-a53c-4525-83ac-57ea38edc0b5@gmail.com/ [3] https://lore.kernel.org/lkml/20251114083056.31553866@bootlin.com/ Best regards, Hervé Changes: v4 -> v5 v4: https://lore.kernel.org/lkml/20251015071420.1173068-1-herve.codina@bootlin.com/ - Patch 2: Add 'Acked-by: Ulf Hansson' - Patch 3: Add a call to driver_deferred_probe_trigger() - Patch 5: (new patch) Depopulate devices at remove - Patch 6: Populate devices at probe. Switched back to modification proposed in v3 - Patch 7 in v3 removed - Patch 7 (8 in v4): Add 'Reviewed-by: Andy Shevchenko' Add 'Reviewed-by: Ulf Hansson' - Patch 8 (9 in v4): Add 'Reviewed-by: Ulf Hansson' - Patches 9 to 15 (10 to 16 in v3) No changes - Patch 16 (17 in v4): Add 'Reviewed-by: Andi Shyti' - Patch 17 (18 in v4): Change an error code from -EINVAL to -ENODEV Add a blank line and fix a typo in commit log - Patch 18 (19 in v4): Simplify of_is_fwnode_add_links_supported(). Move IS_ENABLED(CONFIG_X86) check in of_is_fwnode_add_links_supported(). - Patches 19 to 21 (20 to 22 in v4) No changes - Patch 22 (23 in v4) Update due to simple-platform-bus removal - Patches 23 to 28 (24 to 29 in v4) No changes v3 -> v4 v3: https://lore.kernel.org/lkml/20250613134817.681832-1-herve.codina@bootlin.com/ - Patch 1: No change - Patch 2: Update and fix conflicts. Indeed, since v3 iteration get_dev_from_fwnode() has been moved to device.h and used by pmdomain/core.c. - Patch 3: remove '#define get_device_from_fwnode()' - Patch 4: Fix conflict (rebase v6.17-rc6) Add 'Reviewed-by: Rafael J. Wysocki' Add 'Reviewed-by: Saravana Kannan' - Patch 5 (new in v4): Introduce simple-platform-bus (binding) - Patch 6 (5 in v3): Rework patch and introduce simple-platform-bus - Patch 7: (new) Use simple-platform-bus in LAN966x - Patch 8 (6 in v3): - No change - Patch 9 and 10 (7 and 8 in v3): Add 'Reviewed-by: Andy Shevchenko' - Patch 11 and 12 (9 and 10 in v3): Add 'Reviewed-by: Dave Jiang' - Patch 13 (11 in v3): Add 'Reviewed-by: Andy Shevchenko' - Patch 12 in v3: Patch removed. Adding __private tag in fwnode.dev is going to be handled in a dedicated series. Indeed a test robot reported an issue and more patches are needed (I have missed fwnode.dev users in several part in the kernel). - Patch 14 and 15 (13 and 14 in v3): No change - Patch 16 (14 in v3): Add 'Reviewed-by: Andi Shyti' - Patch 17 and 18 (16 and 17 in v3): No change - Patch 19 (18 in v3): Filter out support for fw_devlink on x86 based on some device-tree properties. Rewrite commit changelog Remove 'Reviewed-by: Andy Shevchenko' (significant modification) - Patch 20 (19 in v3): Add 'Acked-by: Stephen Boyd' - Patch 21 (20 in v3): Fix conflict (rebase v6.18-rc1) - Patches 22 to 24 (21 to 23 in v3): No change - Patch 25 (24 in v3): Fix conflict (rebase v6.18-rc1) Add 'Acked-by: Bjorn Helgaas' - Patches 26 to 29 (25 to 28 in v3): No change v2 -> v3 v2: https://lore.kernel.org/all/20250507071315.394857-1-herve.codina@bootlin.com/ - Patch 1: Add 'Acked-by: Mark Brown' - Patch 2 and 3: No changes - Patch 4: Rewrite the WARN_ON() condition to avoid an additional 'if' - Patch 5: Fix typos in commit log Update a comment Remove the unneeded check before calling of_platform_depopulate() - Patches 6 to 11: No changes - Patch 12 (new in v3) Tag the fwnode dev member as private - Patch 13 (12 in v2) Fix a typo in the commit log - Patches 14 to 16 (13 to 15 in v2) No changes - Patch 17 (16 in v2) Check parent_physdev for NULL - Patch 18 (17 in v2) Capitalize "Link:" Add 'Reviewed-by: Andy Shevchenko' - Patch 19 (18 in v2) No changes - Patch 20 (19 in v2) Add 'Acked-by: Andi Shyti' - Patch 21 (20 in v2) No changes - Patch 22 (21 in v2) Add 'Reviewed-by: Andrew Lunn' - Patch 23 (22 in v2) Add 'Reviewed-by: Andrew Lunn' - Patch 24 (new in v3) Introduce PCI_DEVICE_ID_EFAR_LAN9662, the LAN966x PCI device ID - Patch 25 (23 in v2) Add 'Reviewed-by: Andrew Lunn' Use PCI_DEVICE_DATA() with PCI_DEVICE_ID_EFAR_LAN9662 instead of PCI_VDEVICE() - Patch 26 to 28 (24 to 26 in v2) No changes v1 -> v2 v1: https://lore.kernel.org/lkml/20250407145546.270683-1-herve.codina@bootlin.com/ - Patch 1 and 3 Remove 'From' tag from the commit log - Patch 2 Add 'Reviewed-by: Andy Shevchenko' Add 'Reviewed-by: Saravana Kannan' Add 'Reviewed-by: Luca Ceresoli' - Patch 4 and 5 No changes - Patch 6 (new in v2) Introduce fw_devlink_set_device() - Patch 7 (new in v2) Use existing device_set_node() helper. - Patch 8 to 11 (new in v2) Use fw_devlink_set_device() in existing code. - Patch 12 (6 in v1) Use fw_devlink_add_device() - Patch 13 (7 in v1) No changes - Patch 14 (8 in v1) Update commit log Use 'physdev' instead of 'supplier' Minor fixes in i2c_get_adapter_physdev() kdoc - Patch 15 and 16 (9 and 10 in v1) Use 'physdev' instead of 'supplier' (commit log, title and code) - Patch 17 (11 in v2) Enable fw_devlink on x86 only if PCI_DYNAMIC_OF_NODES is enabled. Rework commit log. - Patch 18, 19 and 20 (12, 13 and 14 in v1) No changes - Patch 21 (new in v2) Split dtso in dtsi/dtso - Patch 22 (new in v2) Rename lan966x_pci.dtso using the specific board name - Patch 23 (new in v2) Improve the driver introducing board specific data to ease support for other boards (avoid the direct dtbo reference in the function loading the dtbo). - Patch 24 (15 in v1) Refactor due to dtso split in dtsi/dtso - Patch 25 (new in v2) Sort exist driver list in Kconfig help - Patch 26 (16 in v1) Keep alphanumeric order for new drivers added in Kconfig help Herve Codina (26): driver core: Rename get_dev_from_fwnode() wrapper to get_device_from_fwnode() driver core: Avoid warning when removing a device while its supplier is unbinding bus: simple-pm-bus: Remove child devices when the bus is unbound bus: simple-pm-bus: Populate child nodes at probe driver core: fw_devlink: Introduce fw_devlink_set_device() drivers: core: Use fw_devlink_set_device() pinctrl: cs42l43: Use fw_devlink_set_device() cxl/test: Use device_set_node() cxl/test: Use fw_devlink_set_device() PCI: of: Use fw_devlink_set_device() PCI: of: Set fwnode device of newly created PCI device nodes PCI: of: Remove fwnode_dev_initialized() call for a PCI root bridge node i2c: core: Introduce i2c_get_adapter_physdev() i2c: mux: Set adapter physical device i2c: mux: Create missing devlink between mux and adapter physical device of: property: Allow fw_devlink device-tree on x86 clk: lan966x: Add MCHP_LAN966X_PCI dependency i2c: busses: at91: Add MCHP_LAN966X_PCI dependency misc: lan966x_pci: Fix dtso nodes ordering misc: lan966x_pci: Split dtso in dtsi/dtso misc: lan966x_pci: Rename lan966x_pci.dtso to lan966x_evb_lan9662_nic.dtso PCI: Add Microchip LAN9662 PCI Device ID misc: lan966x_pci: Introduce board specific data misc: lan966x_pci: Add dtsi/dtso nodes in order to support SFPs misc: lan966x_pci: Sort the drivers list in Kconfig help misc: lan966x_pci: Add drivers needed to support SFPs in Kconfig help Saravana Kannan (2): Revert "treewide: Fix probing of devices in DT overlays" of: dynamic: Fix overlayed devices not probing because of fw_devlink MAINTAINERS | 3 +- drivers/base/core.c | 108 ++++++++++--- drivers/bus/imx-weim.c | 6 - drivers/bus/simple-pm-bus.c | 24 +-- drivers/clk/Kconfig | 2 +- drivers/i2c/busses/Kconfig | 2 +- drivers/i2c/i2c-core-base.c | 16 ++ drivers/i2c/i2c-core-of.c | 5 - drivers/i2c/i2c-mux.c | 26 ++++ drivers/misc/Kconfig | 11 +- drivers/misc/Makefile | 2 +- drivers/misc/lan966x_evb_lan9662_nic.dtso | 167 ++++++++++++++++++++ drivers/misc/lan966x_pci.c | 30 +++- drivers/misc/lan966x_pci.dtsi | 172 +++++++++++++++++++++ drivers/misc/lan966x_pci.dtso | 177 ---------------------- drivers/of/dynamic.c | 1 - drivers/of/overlay.c | 15 ++ drivers/of/platform.c | 5 - drivers/of/property.c | 26 +++- drivers/pci/of.c | 10 +- drivers/pci/quirks.c | 2 +- drivers/pinctrl/cirrus/pinctrl-cs42l43.c | 2 +- drivers/pmdomain/core.c | 4 +- drivers/spi/spi.c | 5 - include/linux/device.h | 2 +- include/linux/fwnode.h | 7 + include/linux/i2c.h | 3 + include/linux/pci_ids.h | 1 + tools/testing/cxl/test/cxl.c | 4 +- 29 files changed, 584 insertions(+), 254 deletions(-) create mode 100644 drivers/misc/lan966x_evb_lan9662_nic.dtso create mode 100644 drivers/misc/lan966x_pci.dtsi delete mode 100644 drivers/misc/lan966x_pci.dtso -- 2.53.0
null
null
null
[PATCH v5 00/28] lan966x pci device: Add support for SFPs
During the instantiation of devices described by a device-tree overlay applied on a PCI device, devlink displays the following kind of debug messages instead of creating the expected links: 'Not linking xxxx - might never become dev' Without those expected links, the device removal order cannot be correct. Those debug traces are printed by fw_devlink_create_devlink(). In our use case, they are all printed because the supplier of the link has at least one of its ancestor with its fwnode flag FWNODE_FLAG_INITIALIZED set. The culprit ancestor is the PCI root bridge. The fwnode related to the PCI root bridge is created dynamically by the of_pci_make_host_bridge_node() function. During this creation fwnode_dev_initialized() is called which set the FWNODE_FLAG_INITIALIZED flag. Calling fwnode_dev_initialized() tells devlink that the device related to this node is handled out of the driver core. This is not correct in our case. Indeed the device related to this firmware node is handled using driver core mechanisms and is fully compliant devlink expectations. Simply remove the fwnode_dev_initialized() call. With that done, the devlink debug messages are no more displayed and links that were missing are correctly created. Signed-off-by: Herve Codina <herve.codina@bootlin.com> --- drivers/pci/of.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/pci/of.c b/drivers/pci/of.c index b694fcda16b1..0993257fe025 100644 --- a/drivers/pci/of.c +++ b/drivers/pci/of.c @@ -811,7 +811,6 @@ void of_pci_make_host_bridge_node(struct pci_host_bridge *bridge) */ of_node_set_flag(np, OF_POPULATED); fw_devlink_set_device(&np->fwnode, &bridge->dev); - fwnode_dev_initialized(&np->fwnode, true); ret = of_changeset_apply(cset); if (ret) -- 2.53.0
{ "author": "Herve Codina <herve.codina@bootlin.com>", "date": "Fri, 27 Feb 2026 14:54:11 +0100", "is_openbsd": false, "thread_id": "20260227135428.783983-1-herve.codina@bootlin.com.mbox.gz" }
lkml_critique
lkml
Hi, This series add support for SFPs ports available on the LAN966x PCI device. In order to have the SFPs supported, additional devices are needed such as clock controller and I2C. As a reminder, the LAN966x PCI device driver use a device-tree overlay to describe devices available on the PCI board. Adding support for SFPs ports consists in adding more devices in the already existing device-tree overlay. With those devices added, the device-tree overlay is more complex and some consumer/supplier relationship are needed in order to remove devices in correct order when the LAN966x PCI driver is removed. Those links are typically provided by fw_devlink and we faced some issues with fw_devlink and overlays. This series gives the big picture related to the SFPs support from fixing issues to adding new devices. Of course, it can be split if needed. The first part of the series (patch 1, 2 and 3) fixes fw_devlink when it is used with overlay. Patches 1 and 3 were previously sent by Saravana [0]. I rebased them on top of v7.0-rc1 and added patch 2 in order to take into account feedback received on the series sent by Saravana. Also I added a call to driver_deferred_probe_trigger() in Saravana's patch (patch 3) to ensure that probes are retried after the modification performed on the dangling consumers. This allows to fix issues reported by Matti and Geert [2] with the previous iteration patches. Those modification were not sufficient in our case and so, on top of that, patches 4 to 6 fix some more issues related to fw_devlink. Patches 7 to 12 introduce and use fw_devlink_set_device() in already existing code. Patches 13 and 14 are related also to fw_devlink but specific to PCI and the device-tree nodes created during enumeration. Patches 15, 16 and 17 are related fw_devlink too but specific to I2C muxes. Patches purpose is to correctly set a link between an adapter supplier and its consumer. Indeed, an i2c mux adapter's parent is not the i2c mux supplier but the adapter the i2c mux is connected to. Adding a new link between the adapter supplier involved when i2c muxes are used avoid a freeze observed during device removal. Patch 18 adds support for fw_delink on x86. fw_devlink is needed to have the consumer/supplier relationship between devices in order to ensure a correct device removal order. Adding fw_devlink support for x86 has been tried in the past but was reverted [1] because it broke some systems. Instead of enabling fw_devlink on *all* x86 system, enable it on *all* x86 except on those where it leads to issue. Patches 19 and 20 allow to build clock and i2c controller used by the LAN966x PCI device when the LAN966x PCI device is enabled. Patches 21 to 25 are specific to the LAN966x. They touch the current dtso, split it in dtsi/dtso files, rename the dtso and improve the driver to allow easier support for other boards. The next patch (patch 26) update the LAN966x device-tree overlay itself to have the SPF ports and devices they depends on described. The last two patches (patches 27 and 29) sort the existing drivers in the needed driver list available in the Kconfig help and add new drivers in this list keep the list up to date with the devices described in the device-tree overlay. We believe some items from the above list can be merged separately, with no build dependencies. We expect: - Patches 1 to 6 to be taken by driver core maintainers - Patches 7 to 12 to be taken by driver core maintainers - Patches 13 and 14 to be taken by driver core or PCI maintainers (depend on patch 7) - Patches 15 to 17 to be taken by I2C maintainers - Patch 18 to be taken by driver core or OF maintainers - Patch 19 to be taken by clock maintainers - Patch 20 to be taken by I2C maintainers - Patches 21 to 28 to be taken by misc maintainers Once again, this series gives the big picture and can be split if needed. Let me know. Compare to previous iteration, this v5 series mainly: - Handle Matti and Geert use cases [2] - Remove simple-platform-bus driver introduced in v4 and switch the simple-bus modification back to what was proposed in v3. In the v4 iteration, conclusion was to use v3 changes [3]. [0] https://lore.kernel.org/lkml/20240411235623.1260061-1-saravanak@google.com/ [1] https://lore.kernel.org/lkml/3c1f2473-92ad-bfc4-258e-a5a08ad73dd0@web.de/ [2] https://lore.kernel.org/all/072dde7c-a53c-4525-83ac-57ea38edc0b5@gmail.com/ [3] https://lore.kernel.org/lkml/20251114083056.31553866@bootlin.com/ Best regards, Hervé Changes: v4 -> v5 v4: https://lore.kernel.org/lkml/20251015071420.1173068-1-herve.codina@bootlin.com/ - Patch 2: Add 'Acked-by: Ulf Hansson' - Patch 3: Add a call to driver_deferred_probe_trigger() - Patch 5: (new patch) Depopulate devices at remove - Patch 6: Populate devices at probe. Switched back to modification proposed in v3 - Patch 7 in v3 removed - Patch 7 (8 in v4): Add 'Reviewed-by: Andy Shevchenko' Add 'Reviewed-by: Ulf Hansson' - Patch 8 (9 in v4): Add 'Reviewed-by: Ulf Hansson' - Patches 9 to 15 (10 to 16 in v3) No changes - Patch 16 (17 in v4): Add 'Reviewed-by: Andi Shyti' - Patch 17 (18 in v4): Change an error code from -EINVAL to -ENODEV Add a blank line and fix a typo in commit log - Patch 18 (19 in v4): Simplify of_is_fwnode_add_links_supported(). Move IS_ENABLED(CONFIG_X86) check in of_is_fwnode_add_links_supported(). - Patches 19 to 21 (20 to 22 in v4) No changes - Patch 22 (23 in v4) Update due to simple-platform-bus removal - Patches 23 to 28 (24 to 29 in v4) No changes v3 -> v4 v3: https://lore.kernel.org/lkml/20250613134817.681832-1-herve.codina@bootlin.com/ - Patch 1: No change - Patch 2: Update and fix conflicts. Indeed, since v3 iteration get_dev_from_fwnode() has been moved to device.h and used by pmdomain/core.c. - Patch 3: remove '#define get_device_from_fwnode()' - Patch 4: Fix conflict (rebase v6.17-rc6) Add 'Reviewed-by: Rafael J. Wysocki' Add 'Reviewed-by: Saravana Kannan' - Patch 5 (new in v4): Introduce simple-platform-bus (binding) - Patch 6 (5 in v3): Rework patch and introduce simple-platform-bus - Patch 7: (new) Use simple-platform-bus in LAN966x - Patch 8 (6 in v3): - No change - Patch 9 and 10 (7 and 8 in v3): Add 'Reviewed-by: Andy Shevchenko' - Patch 11 and 12 (9 and 10 in v3): Add 'Reviewed-by: Dave Jiang' - Patch 13 (11 in v3): Add 'Reviewed-by: Andy Shevchenko' - Patch 12 in v3: Patch removed. Adding __private tag in fwnode.dev is going to be handled in a dedicated series. Indeed a test robot reported an issue and more patches are needed (I have missed fwnode.dev users in several part in the kernel). - Patch 14 and 15 (13 and 14 in v3): No change - Patch 16 (14 in v3): Add 'Reviewed-by: Andi Shyti' - Patch 17 and 18 (16 and 17 in v3): No change - Patch 19 (18 in v3): Filter out support for fw_devlink on x86 based on some device-tree properties. Rewrite commit changelog Remove 'Reviewed-by: Andy Shevchenko' (significant modification) - Patch 20 (19 in v3): Add 'Acked-by: Stephen Boyd' - Patch 21 (20 in v3): Fix conflict (rebase v6.18-rc1) - Patches 22 to 24 (21 to 23 in v3): No change - Patch 25 (24 in v3): Fix conflict (rebase v6.18-rc1) Add 'Acked-by: Bjorn Helgaas' - Patches 26 to 29 (25 to 28 in v3): No change v2 -> v3 v2: https://lore.kernel.org/all/20250507071315.394857-1-herve.codina@bootlin.com/ - Patch 1: Add 'Acked-by: Mark Brown' - Patch 2 and 3: No changes - Patch 4: Rewrite the WARN_ON() condition to avoid an additional 'if' - Patch 5: Fix typos in commit log Update a comment Remove the unneeded check before calling of_platform_depopulate() - Patches 6 to 11: No changes - Patch 12 (new in v3) Tag the fwnode dev member as private - Patch 13 (12 in v2) Fix a typo in the commit log - Patches 14 to 16 (13 to 15 in v2) No changes - Patch 17 (16 in v2) Check parent_physdev for NULL - Patch 18 (17 in v2) Capitalize "Link:" Add 'Reviewed-by: Andy Shevchenko' - Patch 19 (18 in v2) No changes - Patch 20 (19 in v2) Add 'Acked-by: Andi Shyti' - Patch 21 (20 in v2) No changes - Patch 22 (21 in v2) Add 'Reviewed-by: Andrew Lunn' - Patch 23 (22 in v2) Add 'Reviewed-by: Andrew Lunn' - Patch 24 (new in v3) Introduce PCI_DEVICE_ID_EFAR_LAN9662, the LAN966x PCI device ID - Patch 25 (23 in v2) Add 'Reviewed-by: Andrew Lunn' Use PCI_DEVICE_DATA() with PCI_DEVICE_ID_EFAR_LAN9662 instead of PCI_VDEVICE() - Patch 26 to 28 (24 to 26 in v2) No changes v1 -> v2 v1: https://lore.kernel.org/lkml/20250407145546.270683-1-herve.codina@bootlin.com/ - Patch 1 and 3 Remove 'From' tag from the commit log - Patch 2 Add 'Reviewed-by: Andy Shevchenko' Add 'Reviewed-by: Saravana Kannan' Add 'Reviewed-by: Luca Ceresoli' - Patch 4 and 5 No changes - Patch 6 (new in v2) Introduce fw_devlink_set_device() - Patch 7 (new in v2) Use existing device_set_node() helper. - Patch 8 to 11 (new in v2) Use fw_devlink_set_device() in existing code. - Patch 12 (6 in v1) Use fw_devlink_add_device() - Patch 13 (7 in v1) No changes - Patch 14 (8 in v1) Update commit log Use 'physdev' instead of 'supplier' Minor fixes in i2c_get_adapter_physdev() kdoc - Patch 15 and 16 (9 and 10 in v1) Use 'physdev' instead of 'supplier' (commit log, title and code) - Patch 17 (11 in v2) Enable fw_devlink on x86 only if PCI_DYNAMIC_OF_NODES is enabled. Rework commit log. - Patch 18, 19 and 20 (12, 13 and 14 in v1) No changes - Patch 21 (new in v2) Split dtso in dtsi/dtso - Patch 22 (new in v2) Rename lan966x_pci.dtso using the specific board name - Patch 23 (new in v2) Improve the driver introducing board specific data to ease support for other boards (avoid the direct dtbo reference in the function loading the dtbo). - Patch 24 (15 in v1) Refactor due to dtso split in dtsi/dtso - Patch 25 (new in v2) Sort exist driver list in Kconfig help - Patch 26 (16 in v1) Keep alphanumeric order for new drivers added in Kconfig help Herve Codina (26): driver core: Rename get_dev_from_fwnode() wrapper to get_device_from_fwnode() driver core: Avoid warning when removing a device while its supplier is unbinding bus: simple-pm-bus: Remove child devices when the bus is unbound bus: simple-pm-bus: Populate child nodes at probe driver core: fw_devlink: Introduce fw_devlink_set_device() drivers: core: Use fw_devlink_set_device() pinctrl: cs42l43: Use fw_devlink_set_device() cxl/test: Use device_set_node() cxl/test: Use fw_devlink_set_device() PCI: of: Use fw_devlink_set_device() PCI: of: Set fwnode device of newly created PCI device nodes PCI: of: Remove fwnode_dev_initialized() call for a PCI root bridge node i2c: core: Introduce i2c_get_adapter_physdev() i2c: mux: Set adapter physical device i2c: mux: Create missing devlink between mux and adapter physical device of: property: Allow fw_devlink device-tree on x86 clk: lan966x: Add MCHP_LAN966X_PCI dependency i2c: busses: at91: Add MCHP_LAN966X_PCI dependency misc: lan966x_pci: Fix dtso nodes ordering misc: lan966x_pci: Split dtso in dtsi/dtso misc: lan966x_pci: Rename lan966x_pci.dtso to lan966x_evb_lan9662_nic.dtso PCI: Add Microchip LAN9662 PCI Device ID misc: lan966x_pci: Introduce board specific data misc: lan966x_pci: Add dtsi/dtso nodes in order to support SFPs misc: lan966x_pci: Sort the drivers list in Kconfig help misc: lan966x_pci: Add drivers needed to support SFPs in Kconfig help Saravana Kannan (2): Revert "treewide: Fix probing of devices in DT overlays" of: dynamic: Fix overlayed devices not probing because of fw_devlink MAINTAINERS | 3 +- drivers/base/core.c | 108 ++++++++++--- drivers/bus/imx-weim.c | 6 - drivers/bus/simple-pm-bus.c | 24 +-- drivers/clk/Kconfig | 2 +- drivers/i2c/busses/Kconfig | 2 +- drivers/i2c/i2c-core-base.c | 16 ++ drivers/i2c/i2c-core-of.c | 5 - drivers/i2c/i2c-mux.c | 26 ++++ drivers/misc/Kconfig | 11 +- drivers/misc/Makefile | 2 +- drivers/misc/lan966x_evb_lan9662_nic.dtso | 167 ++++++++++++++++++++ drivers/misc/lan966x_pci.c | 30 +++- drivers/misc/lan966x_pci.dtsi | 172 +++++++++++++++++++++ drivers/misc/lan966x_pci.dtso | 177 ---------------------- drivers/of/dynamic.c | 1 - drivers/of/overlay.c | 15 ++ drivers/of/platform.c | 5 - drivers/of/property.c | 26 +++- drivers/pci/of.c | 10 +- drivers/pci/quirks.c | 2 +- drivers/pinctrl/cirrus/pinctrl-cs42l43.c | 2 +- drivers/pmdomain/core.c | 4 +- drivers/spi/spi.c | 5 - include/linux/device.h | 2 +- include/linux/fwnode.h | 7 + include/linux/i2c.h | 3 + include/linux/pci_ids.h | 1 + tools/testing/cxl/test/cxl.c | 4 +- 29 files changed, 584 insertions(+), 254 deletions(-) create mode 100644 drivers/misc/lan966x_evb_lan9662_nic.dtso create mode 100644 drivers/misc/lan966x_pci.dtsi delete mode 100644 drivers/misc/lan966x_pci.dtso -- 2.53.0
null
null
null
[PATCH v5 00/28] lan966x pci device: Add support for SFPs
The physical device providing an I2C adapter is the device that calls i2c_add_adapter() or variants and i2c_del_adapter(). Most of the time this physical device is the parent of the adapter device. Exceptions exist with i2c muxes. Indeed, in case of i2c muxes, the parent of the mux adapter device points to the adapter device the mux is connected to instead of the physical of this mux adapter. Introduce i2c_get_adapter_physdev() and a new physdev field in the adapter structure in order to ease the adapter physical device retrieval. Signed-off-by: Herve Codina <herve.codina@bootlin.com> Reviewed-by: Andi Shyti <andi.shyti@kernel.org> --- drivers/i2c/i2c-core-base.c | 16 ++++++++++++++++ include/linux/i2c.h | 3 +++ 2 files changed, 19 insertions(+) diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c index 9c46147e3506..59214f0c84ec 100644 --- a/drivers/i2c/i2c-core-base.c +++ b/drivers/i2c/i2c-core-base.c @@ -1919,6 +1919,22 @@ struct i2c_adapter *i2c_get_adapter_by_fwnode(struct fwnode_handle *fwnode) } EXPORT_SYMBOL(i2c_get_adapter_by_fwnode); +/** + * i2c_get_adapter_physdev() - Get the physical device of an adapter + * @adapter: the adapter to get the physical device from + * + * Return: + * Look up and return the &struct device corresponding to the device supplying + * this @adapter. + * + * The user must call put_device() once done with the physical device returned. + */ +struct device *i2c_get_adapter_physdev(struct i2c_adapter *adapter) +{ + return get_device(adapter->physdev ?: adapter->dev.parent); +} +EXPORT_SYMBOL(i2c_get_adapter_physdev); + static void i2c_parse_timing(struct device *dev, char *prop_name, u32 *cur_val_p, u32 def_val, bool use_def) { diff --git a/include/linux/i2c.h b/include/linux/i2c.h index 20fd41b51d5c..dff04d20cafe 100644 --- a/include/linux/i2c.h +++ b/include/linux/i2c.h @@ -744,6 +744,7 @@ struct i2c_adapter { int timeout; /* in jiffies */ int retries; struct device dev; /* the adapter device */ + struct device *physdev; /* the physical device */ unsigned long locked_flags; /* owned by the I2C core */ #define I2C_ALF_IS_SUSPENDED 0 #define I2C_ALF_SUSPEND_REPORTED 1 @@ -911,6 +912,8 @@ struct i2c_adapter *i2c_get_adapter(int nr); void i2c_put_adapter(struct i2c_adapter *adap); unsigned int i2c_adapter_depth(struct i2c_adapter *adapter); +struct device *i2c_get_adapter_physdev(struct i2c_adapter *adap); + void i2c_parse_fw_timings(struct device *dev, struct i2c_timings *t, bool use_defaults); /* Return the functionality mask */ -- 2.53.0
{ "author": "Herve Codina <herve.codina@bootlin.com>", "date": "Fri, 27 Feb 2026 14:54:12 +0100", "is_openbsd": false, "thread_id": "20260227135428.783983-1-herve.codina@bootlin.com.mbox.gz" }
lkml_critique
lkml
Hi, This series add support for SFPs ports available on the LAN966x PCI device. In order to have the SFPs supported, additional devices are needed such as clock controller and I2C. As a reminder, the LAN966x PCI device driver use a device-tree overlay to describe devices available on the PCI board. Adding support for SFPs ports consists in adding more devices in the already existing device-tree overlay. With those devices added, the device-tree overlay is more complex and some consumer/supplier relationship are needed in order to remove devices in correct order when the LAN966x PCI driver is removed. Those links are typically provided by fw_devlink and we faced some issues with fw_devlink and overlays. This series gives the big picture related to the SFPs support from fixing issues to adding new devices. Of course, it can be split if needed. The first part of the series (patch 1, 2 and 3) fixes fw_devlink when it is used with overlay. Patches 1 and 3 were previously sent by Saravana [0]. I rebased them on top of v7.0-rc1 and added patch 2 in order to take into account feedback received on the series sent by Saravana. Also I added a call to driver_deferred_probe_trigger() in Saravana's patch (patch 3) to ensure that probes are retried after the modification performed on the dangling consumers. This allows to fix issues reported by Matti and Geert [2] with the previous iteration patches. Those modification were not sufficient in our case and so, on top of that, patches 4 to 6 fix some more issues related to fw_devlink. Patches 7 to 12 introduce and use fw_devlink_set_device() in already existing code. Patches 13 and 14 are related also to fw_devlink but specific to PCI and the device-tree nodes created during enumeration. Patches 15, 16 and 17 are related fw_devlink too but specific to I2C muxes. Patches purpose is to correctly set a link between an adapter supplier and its consumer. Indeed, an i2c mux adapter's parent is not the i2c mux supplier but the adapter the i2c mux is connected to. Adding a new link between the adapter supplier involved when i2c muxes are used avoid a freeze observed during device removal. Patch 18 adds support for fw_delink on x86. fw_devlink is needed to have the consumer/supplier relationship between devices in order to ensure a correct device removal order. Adding fw_devlink support for x86 has been tried in the past but was reverted [1] because it broke some systems. Instead of enabling fw_devlink on *all* x86 system, enable it on *all* x86 except on those where it leads to issue. Patches 19 and 20 allow to build clock and i2c controller used by the LAN966x PCI device when the LAN966x PCI device is enabled. Patches 21 to 25 are specific to the LAN966x. They touch the current dtso, split it in dtsi/dtso files, rename the dtso and improve the driver to allow easier support for other boards. The next patch (patch 26) update the LAN966x device-tree overlay itself to have the SPF ports and devices they depends on described. The last two patches (patches 27 and 29) sort the existing drivers in the needed driver list available in the Kconfig help and add new drivers in this list keep the list up to date with the devices described in the device-tree overlay. We believe some items from the above list can be merged separately, with no build dependencies. We expect: - Patches 1 to 6 to be taken by driver core maintainers - Patches 7 to 12 to be taken by driver core maintainers - Patches 13 and 14 to be taken by driver core or PCI maintainers (depend on patch 7) - Patches 15 to 17 to be taken by I2C maintainers - Patch 18 to be taken by driver core or OF maintainers - Patch 19 to be taken by clock maintainers - Patch 20 to be taken by I2C maintainers - Patches 21 to 28 to be taken by misc maintainers Once again, this series gives the big picture and can be split if needed. Let me know. Compare to previous iteration, this v5 series mainly: - Handle Matti and Geert use cases [2] - Remove simple-platform-bus driver introduced in v4 and switch the simple-bus modification back to what was proposed in v3. In the v4 iteration, conclusion was to use v3 changes [3]. [0] https://lore.kernel.org/lkml/20240411235623.1260061-1-saravanak@google.com/ [1] https://lore.kernel.org/lkml/3c1f2473-92ad-bfc4-258e-a5a08ad73dd0@web.de/ [2] https://lore.kernel.org/all/072dde7c-a53c-4525-83ac-57ea38edc0b5@gmail.com/ [3] https://lore.kernel.org/lkml/20251114083056.31553866@bootlin.com/ Best regards, Hervé Changes: v4 -> v5 v4: https://lore.kernel.org/lkml/20251015071420.1173068-1-herve.codina@bootlin.com/ - Patch 2: Add 'Acked-by: Ulf Hansson' - Patch 3: Add a call to driver_deferred_probe_trigger() - Patch 5: (new patch) Depopulate devices at remove - Patch 6: Populate devices at probe. Switched back to modification proposed in v3 - Patch 7 in v3 removed - Patch 7 (8 in v4): Add 'Reviewed-by: Andy Shevchenko' Add 'Reviewed-by: Ulf Hansson' - Patch 8 (9 in v4): Add 'Reviewed-by: Ulf Hansson' - Patches 9 to 15 (10 to 16 in v3) No changes - Patch 16 (17 in v4): Add 'Reviewed-by: Andi Shyti' - Patch 17 (18 in v4): Change an error code from -EINVAL to -ENODEV Add a blank line and fix a typo in commit log - Patch 18 (19 in v4): Simplify of_is_fwnode_add_links_supported(). Move IS_ENABLED(CONFIG_X86) check in of_is_fwnode_add_links_supported(). - Patches 19 to 21 (20 to 22 in v4) No changes - Patch 22 (23 in v4) Update due to simple-platform-bus removal - Patches 23 to 28 (24 to 29 in v4) No changes v3 -> v4 v3: https://lore.kernel.org/lkml/20250613134817.681832-1-herve.codina@bootlin.com/ - Patch 1: No change - Patch 2: Update and fix conflicts. Indeed, since v3 iteration get_dev_from_fwnode() has been moved to device.h and used by pmdomain/core.c. - Patch 3: remove '#define get_device_from_fwnode()' - Patch 4: Fix conflict (rebase v6.17-rc6) Add 'Reviewed-by: Rafael J. Wysocki' Add 'Reviewed-by: Saravana Kannan' - Patch 5 (new in v4): Introduce simple-platform-bus (binding) - Patch 6 (5 in v3): Rework patch and introduce simple-platform-bus - Patch 7: (new) Use simple-platform-bus in LAN966x - Patch 8 (6 in v3): - No change - Patch 9 and 10 (7 and 8 in v3): Add 'Reviewed-by: Andy Shevchenko' - Patch 11 and 12 (9 and 10 in v3): Add 'Reviewed-by: Dave Jiang' - Patch 13 (11 in v3): Add 'Reviewed-by: Andy Shevchenko' - Patch 12 in v3: Patch removed. Adding __private tag in fwnode.dev is going to be handled in a dedicated series. Indeed a test robot reported an issue and more patches are needed (I have missed fwnode.dev users in several part in the kernel). - Patch 14 and 15 (13 and 14 in v3): No change - Patch 16 (14 in v3): Add 'Reviewed-by: Andi Shyti' - Patch 17 and 18 (16 and 17 in v3): No change - Patch 19 (18 in v3): Filter out support for fw_devlink on x86 based on some device-tree properties. Rewrite commit changelog Remove 'Reviewed-by: Andy Shevchenko' (significant modification) - Patch 20 (19 in v3): Add 'Acked-by: Stephen Boyd' - Patch 21 (20 in v3): Fix conflict (rebase v6.18-rc1) - Patches 22 to 24 (21 to 23 in v3): No change - Patch 25 (24 in v3): Fix conflict (rebase v6.18-rc1) Add 'Acked-by: Bjorn Helgaas' - Patches 26 to 29 (25 to 28 in v3): No change v2 -> v3 v2: https://lore.kernel.org/all/20250507071315.394857-1-herve.codina@bootlin.com/ - Patch 1: Add 'Acked-by: Mark Brown' - Patch 2 and 3: No changes - Patch 4: Rewrite the WARN_ON() condition to avoid an additional 'if' - Patch 5: Fix typos in commit log Update a comment Remove the unneeded check before calling of_platform_depopulate() - Patches 6 to 11: No changes - Patch 12 (new in v3) Tag the fwnode dev member as private - Patch 13 (12 in v2) Fix a typo in the commit log - Patches 14 to 16 (13 to 15 in v2) No changes - Patch 17 (16 in v2) Check parent_physdev for NULL - Patch 18 (17 in v2) Capitalize "Link:" Add 'Reviewed-by: Andy Shevchenko' - Patch 19 (18 in v2) No changes - Patch 20 (19 in v2) Add 'Acked-by: Andi Shyti' - Patch 21 (20 in v2) No changes - Patch 22 (21 in v2) Add 'Reviewed-by: Andrew Lunn' - Patch 23 (22 in v2) Add 'Reviewed-by: Andrew Lunn' - Patch 24 (new in v3) Introduce PCI_DEVICE_ID_EFAR_LAN9662, the LAN966x PCI device ID - Patch 25 (23 in v2) Add 'Reviewed-by: Andrew Lunn' Use PCI_DEVICE_DATA() with PCI_DEVICE_ID_EFAR_LAN9662 instead of PCI_VDEVICE() - Patch 26 to 28 (24 to 26 in v2) No changes v1 -> v2 v1: https://lore.kernel.org/lkml/20250407145546.270683-1-herve.codina@bootlin.com/ - Patch 1 and 3 Remove 'From' tag from the commit log - Patch 2 Add 'Reviewed-by: Andy Shevchenko' Add 'Reviewed-by: Saravana Kannan' Add 'Reviewed-by: Luca Ceresoli' - Patch 4 and 5 No changes - Patch 6 (new in v2) Introduce fw_devlink_set_device() - Patch 7 (new in v2) Use existing device_set_node() helper. - Patch 8 to 11 (new in v2) Use fw_devlink_set_device() in existing code. - Patch 12 (6 in v1) Use fw_devlink_add_device() - Patch 13 (7 in v1) No changes - Patch 14 (8 in v1) Update commit log Use 'physdev' instead of 'supplier' Minor fixes in i2c_get_adapter_physdev() kdoc - Patch 15 and 16 (9 and 10 in v1) Use 'physdev' instead of 'supplier' (commit log, title and code) - Patch 17 (11 in v2) Enable fw_devlink on x86 only if PCI_DYNAMIC_OF_NODES is enabled. Rework commit log. - Patch 18, 19 and 20 (12, 13 and 14 in v1) No changes - Patch 21 (new in v2) Split dtso in dtsi/dtso - Patch 22 (new in v2) Rename lan966x_pci.dtso using the specific board name - Patch 23 (new in v2) Improve the driver introducing board specific data to ease support for other boards (avoid the direct dtbo reference in the function loading the dtbo). - Patch 24 (15 in v1) Refactor due to dtso split in dtsi/dtso - Patch 25 (new in v2) Sort exist driver list in Kconfig help - Patch 26 (16 in v1) Keep alphanumeric order for new drivers added in Kconfig help Herve Codina (26): driver core: Rename get_dev_from_fwnode() wrapper to get_device_from_fwnode() driver core: Avoid warning when removing a device while its supplier is unbinding bus: simple-pm-bus: Remove child devices when the bus is unbound bus: simple-pm-bus: Populate child nodes at probe driver core: fw_devlink: Introduce fw_devlink_set_device() drivers: core: Use fw_devlink_set_device() pinctrl: cs42l43: Use fw_devlink_set_device() cxl/test: Use device_set_node() cxl/test: Use fw_devlink_set_device() PCI: of: Use fw_devlink_set_device() PCI: of: Set fwnode device of newly created PCI device nodes PCI: of: Remove fwnode_dev_initialized() call for a PCI root bridge node i2c: core: Introduce i2c_get_adapter_physdev() i2c: mux: Set adapter physical device i2c: mux: Create missing devlink between mux and adapter physical device of: property: Allow fw_devlink device-tree on x86 clk: lan966x: Add MCHP_LAN966X_PCI dependency i2c: busses: at91: Add MCHP_LAN966X_PCI dependency misc: lan966x_pci: Fix dtso nodes ordering misc: lan966x_pci: Split dtso in dtsi/dtso misc: lan966x_pci: Rename lan966x_pci.dtso to lan966x_evb_lan9662_nic.dtso PCI: Add Microchip LAN9662 PCI Device ID misc: lan966x_pci: Introduce board specific data misc: lan966x_pci: Add dtsi/dtso nodes in order to support SFPs misc: lan966x_pci: Sort the drivers list in Kconfig help misc: lan966x_pci: Add drivers needed to support SFPs in Kconfig help Saravana Kannan (2): Revert "treewide: Fix probing of devices in DT overlays" of: dynamic: Fix overlayed devices not probing because of fw_devlink MAINTAINERS | 3 +- drivers/base/core.c | 108 ++++++++++--- drivers/bus/imx-weim.c | 6 - drivers/bus/simple-pm-bus.c | 24 +-- drivers/clk/Kconfig | 2 +- drivers/i2c/busses/Kconfig | 2 +- drivers/i2c/i2c-core-base.c | 16 ++ drivers/i2c/i2c-core-of.c | 5 - drivers/i2c/i2c-mux.c | 26 ++++ drivers/misc/Kconfig | 11 +- drivers/misc/Makefile | 2 +- drivers/misc/lan966x_evb_lan9662_nic.dtso | 167 ++++++++++++++++++++ drivers/misc/lan966x_pci.c | 30 +++- drivers/misc/lan966x_pci.dtsi | 172 +++++++++++++++++++++ drivers/misc/lan966x_pci.dtso | 177 ---------------------- drivers/of/dynamic.c | 1 - drivers/of/overlay.c | 15 ++ drivers/of/platform.c | 5 - drivers/of/property.c | 26 +++- drivers/pci/of.c | 10 +- drivers/pci/quirks.c | 2 +- drivers/pinctrl/cirrus/pinctrl-cs42l43.c | 2 +- drivers/pmdomain/core.c | 4 +- drivers/spi/spi.c | 5 - include/linux/device.h | 2 +- include/linux/fwnode.h | 7 + include/linux/i2c.h | 3 + include/linux/pci_ids.h | 1 + tools/testing/cxl/test/cxl.c | 4 +- 29 files changed, 584 insertions(+), 254 deletions(-) create mode 100644 drivers/misc/lan966x_evb_lan9662_nic.dtso create mode 100644 drivers/misc/lan966x_pci.dtsi delete mode 100644 drivers/misc/lan966x_pci.dtso -- 2.53.0
null
null
null
[PATCH v5 00/28] lan966x pci device: Add support for SFPs
For i2c muxes, the parent of the mux adapter device is the adapter device the mux is connected to. This parent is not the physical device related to the mux adapter. Indeed, the physical device of the mux adapter is the mux device itself. Fill the adap.physdev with the mux device. Signed-off-by: Herve Codina <herve.codina@bootlin.com> Reviewed-by: Andi Shyti <andi.shyti@kernel.org> --- drivers/i2c/i2c-mux.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/i2c/i2c-mux.c b/drivers/i2c/i2c-mux.c index 681a201c239b..f4e73e7a0e33 100644 --- a/drivers/i2c/i2c-mux.c +++ b/drivers/i2c/i2c-mux.c @@ -315,6 +315,7 @@ int i2c_mux_add_adapter(struct i2c_mux_core *muxc, priv->adap.algo = &priv->algo; priv->adap.algo_data = priv; priv->adap.dev.parent = &parent->dev; + priv->adap.physdev = muxc->dev; priv->adap.retries = parent->retries; priv->adap.timeout = parent->timeout; priv->adap.quirks = parent->quirks; -- 2.53.0
{ "author": "Herve Codina <herve.codina@bootlin.com>", "date": "Fri, 27 Feb 2026 14:54:13 +0100", "is_openbsd": false, "thread_id": "20260227135428.783983-1-herve.codina@bootlin.com.mbox.gz" }
lkml_critique
lkml
Hi, This series add support for SFPs ports available on the LAN966x PCI device. In order to have the SFPs supported, additional devices are needed such as clock controller and I2C. As a reminder, the LAN966x PCI device driver use a device-tree overlay to describe devices available on the PCI board. Adding support for SFPs ports consists in adding more devices in the already existing device-tree overlay. With those devices added, the device-tree overlay is more complex and some consumer/supplier relationship are needed in order to remove devices in correct order when the LAN966x PCI driver is removed. Those links are typically provided by fw_devlink and we faced some issues with fw_devlink and overlays. This series gives the big picture related to the SFPs support from fixing issues to adding new devices. Of course, it can be split if needed. The first part of the series (patch 1, 2 and 3) fixes fw_devlink when it is used with overlay. Patches 1 and 3 were previously sent by Saravana [0]. I rebased them on top of v7.0-rc1 and added patch 2 in order to take into account feedback received on the series sent by Saravana. Also I added a call to driver_deferred_probe_trigger() in Saravana's patch (patch 3) to ensure that probes are retried after the modification performed on the dangling consumers. This allows to fix issues reported by Matti and Geert [2] with the previous iteration patches. Those modification were not sufficient in our case and so, on top of that, patches 4 to 6 fix some more issues related to fw_devlink. Patches 7 to 12 introduce and use fw_devlink_set_device() in already existing code. Patches 13 and 14 are related also to fw_devlink but specific to PCI and the device-tree nodes created during enumeration. Patches 15, 16 and 17 are related fw_devlink too but specific to I2C muxes. Patches purpose is to correctly set a link between an adapter supplier and its consumer. Indeed, an i2c mux adapter's parent is not the i2c mux supplier but the adapter the i2c mux is connected to. Adding a new link between the adapter supplier involved when i2c muxes are used avoid a freeze observed during device removal. Patch 18 adds support for fw_delink on x86. fw_devlink is needed to have the consumer/supplier relationship between devices in order to ensure a correct device removal order. Adding fw_devlink support for x86 has been tried in the past but was reverted [1] because it broke some systems. Instead of enabling fw_devlink on *all* x86 system, enable it on *all* x86 except on those where it leads to issue. Patches 19 and 20 allow to build clock and i2c controller used by the LAN966x PCI device when the LAN966x PCI device is enabled. Patches 21 to 25 are specific to the LAN966x. They touch the current dtso, split it in dtsi/dtso files, rename the dtso and improve the driver to allow easier support for other boards. The next patch (patch 26) update the LAN966x device-tree overlay itself to have the SPF ports and devices they depends on described. The last two patches (patches 27 and 29) sort the existing drivers in the needed driver list available in the Kconfig help and add new drivers in this list keep the list up to date with the devices described in the device-tree overlay. We believe some items from the above list can be merged separately, with no build dependencies. We expect: - Patches 1 to 6 to be taken by driver core maintainers - Patches 7 to 12 to be taken by driver core maintainers - Patches 13 and 14 to be taken by driver core or PCI maintainers (depend on patch 7) - Patches 15 to 17 to be taken by I2C maintainers - Patch 18 to be taken by driver core or OF maintainers - Patch 19 to be taken by clock maintainers - Patch 20 to be taken by I2C maintainers - Patches 21 to 28 to be taken by misc maintainers Once again, this series gives the big picture and can be split if needed. Let me know. Compare to previous iteration, this v5 series mainly: - Handle Matti and Geert use cases [2] - Remove simple-platform-bus driver introduced in v4 and switch the simple-bus modification back to what was proposed in v3. In the v4 iteration, conclusion was to use v3 changes [3]. [0] https://lore.kernel.org/lkml/20240411235623.1260061-1-saravanak@google.com/ [1] https://lore.kernel.org/lkml/3c1f2473-92ad-bfc4-258e-a5a08ad73dd0@web.de/ [2] https://lore.kernel.org/all/072dde7c-a53c-4525-83ac-57ea38edc0b5@gmail.com/ [3] https://lore.kernel.org/lkml/20251114083056.31553866@bootlin.com/ Best regards, Hervé Changes: v4 -> v5 v4: https://lore.kernel.org/lkml/20251015071420.1173068-1-herve.codina@bootlin.com/ - Patch 2: Add 'Acked-by: Ulf Hansson' - Patch 3: Add a call to driver_deferred_probe_trigger() - Patch 5: (new patch) Depopulate devices at remove - Patch 6: Populate devices at probe. Switched back to modification proposed in v3 - Patch 7 in v3 removed - Patch 7 (8 in v4): Add 'Reviewed-by: Andy Shevchenko' Add 'Reviewed-by: Ulf Hansson' - Patch 8 (9 in v4): Add 'Reviewed-by: Ulf Hansson' - Patches 9 to 15 (10 to 16 in v3) No changes - Patch 16 (17 in v4): Add 'Reviewed-by: Andi Shyti' - Patch 17 (18 in v4): Change an error code from -EINVAL to -ENODEV Add a blank line and fix a typo in commit log - Patch 18 (19 in v4): Simplify of_is_fwnode_add_links_supported(). Move IS_ENABLED(CONFIG_X86) check in of_is_fwnode_add_links_supported(). - Patches 19 to 21 (20 to 22 in v4) No changes - Patch 22 (23 in v4) Update due to simple-platform-bus removal - Patches 23 to 28 (24 to 29 in v4) No changes v3 -> v4 v3: https://lore.kernel.org/lkml/20250613134817.681832-1-herve.codina@bootlin.com/ - Patch 1: No change - Patch 2: Update and fix conflicts. Indeed, since v3 iteration get_dev_from_fwnode() has been moved to device.h and used by pmdomain/core.c. - Patch 3: remove '#define get_device_from_fwnode()' - Patch 4: Fix conflict (rebase v6.17-rc6) Add 'Reviewed-by: Rafael J. Wysocki' Add 'Reviewed-by: Saravana Kannan' - Patch 5 (new in v4): Introduce simple-platform-bus (binding) - Patch 6 (5 in v3): Rework patch and introduce simple-platform-bus - Patch 7: (new) Use simple-platform-bus in LAN966x - Patch 8 (6 in v3): - No change - Patch 9 and 10 (7 and 8 in v3): Add 'Reviewed-by: Andy Shevchenko' - Patch 11 and 12 (9 and 10 in v3): Add 'Reviewed-by: Dave Jiang' - Patch 13 (11 in v3): Add 'Reviewed-by: Andy Shevchenko' - Patch 12 in v3: Patch removed. Adding __private tag in fwnode.dev is going to be handled in a dedicated series. Indeed a test robot reported an issue and more patches are needed (I have missed fwnode.dev users in several part in the kernel). - Patch 14 and 15 (13 and 14 in v3): No change - Patch 16 (14 in v3): Add 'Reviewed-by: Andi Shyti' - Patch 17 and 18 (16 and 17 in v3): No change - Patch 19 (18 in v3): Filter out support for fw_devlink on x86 based on some device-tree properties. Rewrite commit changelog Remove 'Reviewed-by: Andy Shevchenko' (significant modification) - Patch 20 (19 in v3): Add 'Acked-by: Stephen Boyd' - Patch 21 (20 in v3): Fix conflict (rebase v6.18-rc1) - Patches 22 to 24 (21 to 23 in v3): No change - Patch 25 (24 in v3): Fix conflict (rebase v6.18-rc1) Add 'Acked-by: Bjorn Helgaas' - Patches 26 to 29 (25 to 28 in v3): No change v2 -> v3 v2: https://lore.kernel.org/all/20250507071315.394857-1-herve.codina@bootlin.com/ - Patch 1: Add 'Acked-by: Mark Brown' - Patch 2 and 3: No changes - Patch 4: Rewrite the WARN_ON() condition to avoid an additional 'if' - Patch 5: Fix typos in commit log Update a comment Remove the unneeded check before calling of_platform_depopulate() - Patches 6 to 11: No changes - Patch 12 (new in v3) Tag the fwnode dev member as private - Patch 13 (12 in v2) Fix a typo in the commit log - Patches 14 to 16 (13 to 15 in v2) No changes - Patch 17 (16 in v2) Check parent_physdev for NULL - Patch 18 (17 in v2) Capitalize "Link:" Add 'Reviewed-by: Andy Shevchenko' - Patch 19 (18 in v2) No changes - Patch 20 (19 in v2) Add 'Acked-by: Andi Shyti' - Patch 21 (20 in v2) No changes - Patch 22 (21 in v2) Add 'Reviewed-by: Andrew Lunn' - Patch 23 (22 in v2) Add 'Reviewed-by: Andrew Lunn' - Patch 24 (new in v3) Introduce PCI_DEVICE_ID_EFAR_LAN9662, the LAN966x PCI device ID - Patch 25 (23 in v2) Add 'Reviewed-by: Andrew Lunn' Use PCI_DEVICE_DATA() with PCI_DEVICE_ID_EFAR_LAN9662 instead of PCI_VDEVICE() - Patch 26 to 28 (24 to 26 in v2) No changes v1 -> v2 v1: https://lore.kernel.org/lkml/20250407145546.270683-1-herve.codina@bootlin.com/ - Patch 1 and 3 Remove 'From' tag from the commit log - Patch 2 Add 'Reviewed-by: Andy Shevchenko' Add 'Reviewed-by: Saravana Kannan' Add 'Reviewed-by: Luca Ceresoli' - Patch 4 and 5 No changes - Patch 6 (new in v2) Introduce fw_devlink_set_device() - Patch 7 (new in v2) Use existing device_set_node() helper. - Patch 8 to 11 (new in v2) Use fw_devlink_set_device() in existing code. - Patch 12 (6 in v1) Use fw_devlink_add_device() - Patch 13 (7 in v1) No changes - Patch 14 (8 in v1) Update commit log Use 'physdev' instead of 'supplier' Minor fixes in i2c_get_adapter_physdev() kdoc - Patch 15 and 16 (9 and 10 in v1) Use 'physdev' instead of 'supplier' (commit log, title and code) - Patch 17 (11 in v2) Enable fw_devlink on x86 only if PCI_DYNAMIC_OF_NODES is enabled. Rework commit log. - Patch 18, 19 and 20 (12, 13 and 14 in v1) No changes - Patch 21 (new in v2) Split dtso in dtsi/dtso - Patch 22 (new in v2) Rename lan966x_pci.dtso using the specific board name - Patch 23 (new in v2) Improve the driver introducing board specific data to ease support for other boards (avoid the direct dtbo reference in the function loading the dtbo). - Patch 24 (15 in v1) Refactor due to dtso split in dtsi/dtso - Patch 25 (new in v2) Sort exist driver list in Kconfig help - Patch 26 (16 in v1) Keep alphanumeric order for new drivers added in Kconfig help Herve Codina (26): driver core: Rename get_dev_from_fwnode() wrapper to get_device_from_fwnode() driver core: Avoid warning when removing a device while its supplier is unbinding bus: simple-pm-bus: Remove child devices when the bus is unbound bus: simple-pm-bus: Populate child nodes at probe driver core: fw_devlink: Introduce fw_devlink_set_device() drivers: core: Use fw_devlink_set_device() pinctrl: cs42l43: Use fw_devlink_set_device() cxl/test: Use device_set_node() cxl/test: Use fw_devlink_set_device() PCI: of: Use fw_devlink_set_device() PCI: of: Set fwnode device of newly created PCI device nodes PCI: of: Remove fwnode_dev_initialized() call for a PCI root bridge node i2c: core: Introduce i2c_get_adapter_physdev() i2c: mux: Set adapter physical device i2c: mux: Create missing devlink between mux and adapter physical device of: property: Allow fw_devlink device-tree on x86 clk: lan966x: Add MCHP_LAN966X_PCI dependency i2c: busses: at91: Add MCHP_LAN966X_PCI dependency misc: lan966x_pci: Fix dtso nodes ordering misc: lan966x_pci: Split dtso in dtsi/dtso misc: lan966x_pci: Rename lan966x_pci.dtso to lan966x_evb_lan9662_nic.dtso PCI: Add Microchip LAN9662 PCI Device ID misc: lan966x_pci: Introduce board specific data misc: lan966x_pci: Add dtsi/dtso nodes in order to support SFPs misc: lan966x_pci: Sort the drivers list in Kconfig help misc: lan966x_pci: Add drivers needed to support SFPs in Kconfig help Saravana Kannan (2): Revert "treewide: Fix probing of devices in DT overlays" of: dynamic: Fix overlayed devices not probing because of fw_devlink MAINTAINERS | 3 +- drivers/base/core.c | 108 ++++++++++--- drivers/bus/imx-weim.c | 6 - drivers/bus/simple-pm-bus.c | 24 +-- drivers/clk/Kconfig | 2 +- drivers/i2c/busses/Kconfig | 2 +- drivers/i2c/i2c-core-base.c | 16 ++ drivers/i2c/i2c-core-of.c | 5 - drivers/i2c/i2c-mux.c | 26 ++++ drivers/misc/Kconfig | 11 +- drivers/misc/Makefile | 2 +- drivers/misc/lan966x_evb_lan9662_nic.dtso | 167 ++++++++++++++++++++ drivers/misc/lan966x_pci.c | 30 +++- drivers/misc/lan966x_pci.dtsi | 172 +++++++++++++++++++++ drivers/misc/lan966x_pci.dtso | 177 ---------------------- drivers/of/dynamic.c | 1 - drivers/of/overlay.c | 15 ++ drivers/of/platform.c | 5 - drivers/of/property.c | 26 +++- drivers/pci/of.c | 10 +- drivers/pci/quirks.c | 2 +- drivers/pinctrl/cirrus/pinctrl-cs42l43.c | 2 +- drivers/pmdomain/core.c | 4 +- drivers/spi/spi.c | 5 - include/linux/device.h | 2 +- include/linux/fwnode.h | 7 + include/linux/i2c.h | 3 + include/linux/pci_ids.h | 1 + tools/testing/cxl/test/cxl.c | 4 +- 29 files changed, 584 insertions(+), 254 deletions(-) create mode 100644 drivers/misc/lan966x_evb_lan9662_nic.dtso create mode 100644 drivers/misc/lan966x_pci.dtsi delete mode 100644 drivers/misc/lan966x_pci.dtso -- 2.53.0
null
null
null
[PATCH v5 00/28] lan966x pci device: Add support for SFPs
When removing an i2c controller device handling an i2c bus where an i2c mux is connected to, the removal process hangs and is stuck in the wait_completion() call done in i2c_del_adapter(). The i2c_del_adapter() tries to removed the i2c adapter related to the i2c controller device and the wait_completion() is waiting for the i2c adapter device release. This release is performed when the device is no more used (i.e. refcount reaches zero). When an i2c mux is involved in an i2c path, the struct dev topology is the following: +----------------+ +-------------------+ | i2c controller | | i2c mux | | device | | device | | ^ | | | | | | | | | dev's parent | | | | | | | | | i2c adapter | | i2c adapter chanX | | device <---- dev's parent ------ device | | (no driver) | | (no driver) | +----------------+ +-------------------+ When an i2c mux device creates an i2c adapter for its downstream channel, a reference is taken to its adapter dev's parent. This parent is the i2c mux upstream adapter device. No relationship exists between the i2c mux device itself and the i2c controller device (physical device) in order to have the i2c mux device calling i2c_del_adapter() to remove its downstream adapters and so, release references taken to the upstream adapter. This consumer/supplier relationship is typically a devlink relationship. Also, i2c muxes can be chained and so, the upstream adapter can be supplied by either an i2c controller device or an other i2c mux device. In order to get the physical device of the adapter a mux is connected to, rely on the newly introduced i2c_adapter_get_physdev() and create the missing devlink between the i2c mux device and the physical device of the adapter the mux is connected to. With that done, the i2c mux device is removed before the device handling the upstream i2c adapter (i2c controller device or i2c mux device). All references are released and the i2c_del_adapter() call performed by driver handling the upstream adapter device is not blocking anymore. Signed-off-by: Herve Codina <herve.codina@bootlin.com> --- drivers/i2c/i2c-mux.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/drivers/i2c/i2c-mux.c b/drivers/i2c/i2c-mux.c index f4e73e7a0e33..26470a7c2eea 100644 --- a/drivers/i2c/i2c-mux.c +++ b/drivers/i2c/i2c-mux.c @@ -268,7 +268,9 @@ int i2c_mux_add_adapter(struct i2c_mux_core *muxc, u32 force_nr, u32 chan_id) { struct i2c_adapter *parent = muxc->parent; + struct device *parent_physdev; struct i2c_mux_priv *priv; + struct device_link *dl; char symlink_name[20]; int ret; @@ -375,6 +377,29 @@ int i2c_mux_add_adapter(struct i2c_mux_core *muxc, ACPI_COMPANION(muxc->dev), chan_id); + /* + * There is no relationship set between the mux device and the physical + * device handling the parent adapter. Create this missing relationship + * in order to remove the i2c mux device (consumer) and so the dowstream + * channel adapters before removing the physical device (supplier) which + * handles the i2c mux upstream adapter. + */ + parent_physdev = i2c_get_adapter_physdev(parent); + if (!parent_physdev) { + dev_err(muxc->dev, "failed to get the parent physical device\n"); + ret = -ENODEV; + goto err_free_priv; + } + dl = device_link_add(muxc->dev, parent_physdev, DL_FLAG_AUTOREMOVE_CONSUMER); + if (!dl) { + dev_err(muxc->dev, "failed to create device link to %s\n", + dev_name(parent_physdev)); + put_device(parent_physdev); + ret = -EINVAL; + goto err_free_priv; + } + put_device(parent_physdev); + if (force_nr) { priv->adap.nr = force_nr; ret = i2c_add_numbered_adapter(&priv->adap); -- 2.53.0
{ "author": "Herve Codina <herve.codina@bootlin.com>", "date": "Fri, 27 Feb 2026 14:54:14 +0100", "is_openbsd": false, "thread_id": "20260227135428.783983-1-herve.codina@bootlin.com.mbox.gz" }
lkml_critique
lkml
Hi, This series add support for SFPs ports available on the LAN966x PCI device. In order to have the SFPs supported, additional devices are needed such as clock controller and I2C. As a reminder, the LAN966x PCI device driver use a device-tree overlay to describe devices available on the PCI board. Adding support for SFPs ports consists in adding more devices in the already existing device-tree overlay. With those devices added, the device-tree overlay is more complex and some consumer/supplier relationship are needed in order to remove devices in correct order when the LAN966x PCI driver is removed. Those links are typically provided by fw_devlink and we faced some issues with fw_devlink and overlays. This series gives the big picture related to the SFPs support from fixing issues to adding new devices. Of course, it can be split if needed. The first part of the series (patch 1, 2 and 3) fixes fw_devlink when it is used with overlay. Patches 1 and 3 were previously sent by Saravana [0]. I rebased them on top of v7.0-rc1 and added patch 2 in order to take into account feedback received on the series sent by Saravana. Also I added a call to driver_deferred_probe_trigger() in Saravana's patch (patch 3) to ensure that probes are retried after the modification performed on the dangling consumers. This allows to fix issues reported by Matti and Geert [2] with the previous iteration patches. Those modification were not sufficient in our case and so, on top of that, patches 4 to 6 fix some more issues related to fw_devlink. Patches 7 to 12 introduce and use fw_devlink_set_device() in already existing code. Patches 13 and 14 are related also to fw_devlink but specific to PCI and the device-tree nodes created during enumeration. Patches 15, 16 and 17 are related fw_devlink too but specific to I2C muxes. Patches purpose is to correctly set a link between an adapter supplier and its consumer. Indeed, an i2c mux adapter's parent is not the i2c mux supplier but the adapter the i2c mux is connected to. Adding a new link between the adapter supplier involved when i2c muxes are used avoid a freeze observed during device removal. Patch 18 adds support for fw_delink on x86. fw_devlink is needed to have the consumer/supplier relationship between devices in order to ensure a correct device removal order. Adding fw_devlink support for x86 has been tried in the past but was reverted [1] because it broke some systems. Instead of enabling fw_devlink on *all* x86 system, enable it on *all* x86 except on those where it leads to issue. Patches 19 and 20 allow to build clock and i2c controller used by the LAN966x PCI device when the LAN966x PCI device is enabled. Patches 21 to 25 are specific to the LAN966x. They touch the current dtso, split it in dtsi/dtso files, rename the dtso and improve the driver to allow easier support for other boards. The next patch (patch 26) update the LAN966x device-tree overlay itself to have the SPF ports and devices they depends on described. The last two patches (patches 27 and 29) sort the existing drivers in the needed driver list available in the Kconfig help and add new drivers in this list keep the list up to date with the devices described in the device-tree overlay. We believe some items from the above list can be merged separately, with no build dependencies. We expect: - Patches 1 to 6 to be taken by driver core maintainers - Patches 7 to 12 to be taken by driver core maintainers - Patches 13 and 14 to be taken by driver core or PCI maintainers (depend on patch 7) - Patches 15 to 17 to be taken by I2C maintainers - Patch 18 to be taken by driver core or OF maintainers - Patch 19 to be taken by clock maintainers - Patch 20 to be taken by I2C maintainers - Patches 21 to 28 to be taken by misc maintainers Once again, this series gives the big picture and can be split if needed. Let me know. Compare to previous iteration, this v5 series mainly: - Handle Matti and Geert use cases [2] - Remove simple-platform-bus driver introduced in v4 and switch the simple-bus modification back to what was proposed in v3. In the v4 iteration, conclusion was to use v3 changes [3]. [0] https://lore.kernel.org/lkml/20240411235623.1260061-1-saravanak@google.com/ [1] https://lore.kernel.org/lkml/3c1f2473-92ad-bfc4-258e-a5a08ad73dd0@web.de/ [2] https://lore.kernel.org/all/072dde7c-a53c-4525-83ac-57ea38edc0b5@gmail.com/ [3] https://lore.kernel.org/lkml/20251114083056.31553866@bootlin.com/ Best regards, Hervé Changes: v4 -> v5 v4: https://lore.kernel.org/lkml/20251015071420.1173068-1-herve.codina@bootlin.com/ - Patch 2: Add 'Acked-by: Ulf Hansson' - Patch 3: Add a call to driver_deferred_probe_trigger() - Patch 5: (new patch) Depopulate devices at remove - Patch 6: Populate devices at probe. Switched back to modification proposed in v3 - Patch 7 in v3 removed - Patch 7 (8 in v4): Add 'Reviewed-by: Andy Shevchenko' Add 'Reviewed-by: Ulf Hansson' - Patch 8 (9 in v4): Add 'Reviewed-by: Ulf Hansson' - Patches 9 to 15 (10 to 16 in v3) No changes - Patch 16 (17 in v4): Add 'Reviewed-by: Andi Shyti' - Patch 17 (18 in v4): Change an error code from -EINVAL to -ENODEV Add a blank line and fix a typo in commit log - Patch 18 (19 in v4): Simplify of_is_fwnode_add_links_supported(). Move IS_ENABLED(CONFIG_X86) check in of_is_fwnode_add_links_supported(). - Patches 19 to 21 (20 to 22 in v4) No changes - Patch 22 (23 in v4) Update due to simple-platform-bus removal - Patches 23 to 28 (24 to 29 in v4) No changes v3 -> v4 v3: https://lore.kernel.org/lkml/20250613134817.681832-1-herve.codina@bootlin.com/ - Patch 1: No change - Patch 2: Update and fix conflicts. Indeed, since v3 iteration get_dev_from_fwnode() has been moved to device.h and used by pmdomain/core.c. - Patch 3: remove '#define get_device_from_fwnode()' - Patch 4: Fix conflict (rebase v6.17-rc6) Add 'Reviewed-by: Rafael J. Wysocki' Add 'Reviewed-by: Saravana Kannan' - Patch 5 (new in v4): Introduce simple-platform-bus (binding) - Patch 6 (5 in v3): Rework patch and introduce simple-platform-bus - Patch 7: (new) Use simple-platform-bus in LAN966x - Patch 8 (6 in v3): - No change - Patch 9 and 10 (7 and 8 in v3): Add 'Reviewed-by: Andy Shevchenko' - Patch 11 and 12 (9 and 10 in v3): Add 'Reviewed-by: Dave Jiang' - Patch 13 (11 in v3): Add 'Reviewed-by: Andy Shevchenko' - Patch 12 in v3: Patch removed. Adding __private tag in fwnode.dev is going to be handled in a dedicated series. Indeed a test robot reported an issue and more patches are needed (I have missed fwnode.dev users in several part in the kernel). - Patch 14 and 15 (13 and 14 in v3): No change - Patch 16 (14 in v3): Add 'Reviewed-by: Andi Shyti' - Patch 17 and 18 (16 and 17 in v3): No change - Patch 19 (18 in v3): Filter out support for fw_devlink on x86 based on some device-tree properties. Rewrite commit changelog Remove 'Reviewed-by: Andy Shevchenko' (significant modification) - Patch 20 (19 in v3): Add 'Acked-by: Stephen Boyd' - Patch 21 (20 in v3): Fix conflict (rebase v6.18-rc1) - Patches 22 to 24 (21 to 23 in v3): No change - Patch 25 (24 in v3): Fix conflict (rebase v6.18-rc1) Add 'Acked-by: Bjorn Helgaas' - Patches 26 to 29 (25 to 28 in v3): No change v2 -> v3 v2: https://lore.kernel.org/all/20250507071315.394857-1-herve.codina@bootlin.com/ - Patch 1: Add 'Acked-by: Mark Brown' - Patch 2 and 3: No changes - Patch 4: Rewrite the WARN_ON() condition to avoid an additional 'if' - Patch 5: Fix typos in commit log Update a comment Remove the unneeded check before calling of_platform_depopulate() - Patches 6 to 11: No changes - Patch 12 (new in v3) Tag the fwnode dev member as private - Patch 13 (12 in v2) Fix a typo in the commit log - Patches 14 to 16 (13 to 15 in v2) No changes - Patch 17 (16 in v2) Check parent_physdev for NULL - Patch 18 (17 in v2) Capitalize "Link:" Add 'Reviewed-by: Andy Shevchenko' - Patch 19 (18 in v2) No changes - Patch 20 (19 in v2) Add 'Acked-by: Andi Shyti' - Patch 21 (20 in v2) No changes - Patch 22 (21 in v2) Add 'Reviewed-by: Andrew Lunn' - Patch 23 (22 in v2) Add 'Reviewed-by: Andrew Lunn' - Patch 24 (new in v3) Introduce PCI_DEVICE_ID_EFAR_LAN9662, the LAN966x PCI device ID - Patch 25 (23 in v2) Add 'Reviewed-by: Andrew Lunn' Use PCI_DEVICE_DATA() with PCI_DEVICE_ID_EFAR_LAN9662 instead of PCI_VDEVICE() - Patch 26 to 28 (24 to 26 in v2) No changes v1 -> v2 v1: https://lore.kernel.org/lkml/20250407145546.270683-1-herve.codina@bootlin.com/ - Patch 1 and 3 Remove 'From' tag from the commit log - Patch 2 Add 'Reviewed-by: Andy Shevchenko' Add 'Reviewed-by: Saravana Kannan' Add 'Reviewed-by: Luca Ceresoli' - Patch 4 and 5 No changes - Patch 6 (new in v2) Introduce fw_devlink_set_device() - Patch 7 (new in v2) Use existing device_set_node() helper. - Patch 8 to 11 (new in v2) Use fw_devlink_set_device() in existing code. - Patch 12 (6 in v1) Use fw_devlink_add_device() - Patch 13 (7 in v1) No changes - Patch 14 (8 in v1) Update commit log Use 'physdev' instead of 'supplier' Minor fixes in i2c_get_adapter_physdev() kdoc - Patch 15 and 16 (9 and 10 in v1) Use 'physdev' instead of 'supplier' (commit log, title and code) - Patch 17 (11 in v2) Enable fw_devlink on x86 only if PCI_DYNAMIC_OF_NODES is enabled. Rework commit log. - Patch 18, 19 and 20 (12, 13 and 14 in v1) No changes - Patch 21 (new in v2) Split dtso in dtsi/dtso - Patch 22 (new in v2) Rename lan966x_pci.dtso using the specific board name - Patch 23 (new in v2) Improve the driver introducing board specific data to ease support for other boards (avoid the direct dtbo reference in the function loading the dtbo). - Patch 24 (15 in v1) Refactor due to dtso split in dtsi/dtso - Patch 25 (new in v2) Sort exist driver list in Kconfig help - Patch 26 (16 in v1) Keep alphanumeric order for new drivers added in Kconfig help Herve Codina (26): driver core: Rename get_dev_from_fwnode() wrapper to get_device_from_fwnode() driver core: Avoid warning when removing a device while its supplier is unbinding bus: simple-pm-bus: Remove child devices when the bus is unbound bus: simple-pm-bus: Populate child nodes at probe driver core: fw_devlink: Introduce fw_devlink_set_device() drivers: core: Use fw_devlink_set_device() pinctrl: cs42l43: Use fw_devlink_set_device() cxl/test: Use device_set_node() cxl/test: Use fw_devlink_set_device() PCI: of: Use fw_devlink_set_device() PCI: of: Set fwnode device of newly created PCI device nodes PCI: of: Remove fwnode_dev_initialized() call for a PCI root bridge node i2c: core: Introduce i2c_get_adapter_physdev() i2c: mux: Set adapter physical device i2c: mux: Create missing devlink between mux and adapter physical device of: property: Allow fw_devlink device-tree on x86 clk: lan966x: Add MCHP_LAN966X_PCI dependency i2c: busses: at91: Add MCHP_LAN966X_PCI dependency misc: lan966x_pci: Fix dtso nodes ordering misc: lan966x_pci: Split dtso in dtsi/dtso misc: lan966x_pci: Rename lan966x_pci.dtso to lan966x_evb_lan9662_nic.dtso PCI: Add Microchip LAN9662 PCI Device ID misc: lan966x_pci: Introduce board specific data misc: lan966x_pci: Add dtsi/dtso nodes in order to support SFPs misc: lan966x_pci: Sort the drivers list in Kconfig help misc: lan966x_pci: Add drivers needed to support SFPs in Kconfig help Saravana Kannan (2): Revert "treewide: Fix probing of devices in DT overlays" of: dynamic: Fix overlayed devices not probing because of fw_devlink MAINTAINERS | 3 +- drivers/base/core.c | 108 ++++++++++--- drivers/bus/imx-weim.c | 6 - drivers/bus/simple-pm-bus.c | 24 +-- drivers/clk/Kconfig | 2 +- drivers/i2c/busses/Kconfig | 2 +- drivers/i2c/i2c-core-base.c | 16 ++ drivers/i2c/i2c-core-of.c | 5 - drivers/i2c/i2c-mux.c | 26 ++++ drivers/misc/Kconfig | 11 +- drivers/misc/Makefile | 2 +- drivers/misc/lan966x_evb_lan9662_nic.dtso | 167 ++++++++++++++++++++ drivers/misc/lan966x_pci.c | 30 +++- drivers/misc/lan966x_pci.dtsi | 172 +++++++++++++++++++++ drivers/misc/lan966x_pci.dtso | 177 ---------------------- drivers/of/dynamic.c | 1 - drivers/of/overlay.c | 15 ++ drivers/of/platform.c | 5 - drivers/of/property.c | 26 +++- drivers/pci/of.c | 10 +- drivers/pci/quirks.c | 2 +- drivers/pinctrl/cirrus/pinctrl-cs42l43.c | 2 +- drivers/pmdomain/core.c | 4 +- drivers/spi/spi.c | 5 - include/linux/device.h | 2 +- include/linux/fwnode.h | 7 + include/linux/i2c.h | 3 + include/linux/pci_ids.h | 1 + tools/testing/cxl/test/cxl.c | 4 +- 29 files changed, 584 insertions(+), 254 deletions(-) create mode 100644 drivers/misc/lan966x_evb_lan9662_nic.dtso create mode 100644 drivers/misc/lan966x_pci.dtsi delete mode 100644 drivers/misc/lan966x_pci.dtso -- 2.53.0
null
null
null
[PATCH v5 00/28] lan966x pci device: Add support for SFPs
PCI drivers can use a device-tree overlay to describe the hardware available on the PCI board. This is the case, for instance, of the LAN966x PCI device driver. Adding some more nodes in the device-tree overlay adds some more consumer/supplier relationship between devices instantiated from this overlay. Those fw_node consumer/supplier relationships are handled by fw_devlink and are created based on the device-tree parsing done by the of_fwnode_add_links() function. Those consumer/supplier links are needed in order to ensure a correct PM runtime management and a correct removal order between devices. For instance, without those links a supplier can be removed before its consumers is removed leading to all kind of issue if this consumer still want the use the already removed supplier. The support for the usage of an overlay from a PCI driver has been added on x86 systems in commit 1f340724419ed ("PCI: of: Create device tree PCI host bridge node"). In the past, support for fw_devlink on x86 had been tried but this support has been removed in commit 4a48b66b3f52 ("of: property: Disable fw_devlink DT support for X86"). Indeed, this support was breaking some x86 systems such as OLPC system and the regression was reported in [0]. Instead of disabling this support for all x86 system, use a finer grain and disable this support only for the possible problematic subset of x86 systems (at least OLPC and CE4100). Those systems use a device-tree to describe their hardware. Identify those systems using key properties in the device-tree. Signed-off-by: Herve Codina <herve.codina@bootlin.com> Link: https://lore.kernel.org/lkml/3c1f2473-92ad-bfc4-258e-a5a08ad73dd0@web.de/ [0] --- drivers/of/property.c | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/drivers/of/property.c b/drivers/of/property.c index 50d95d512bf5..80800a20d1ac 100644 --- a/drivers/of/property.c +++ b/drivers/of/property.c @@ -1620,12 +1620,36 @@ static int of_fwnode_irq_get(const struct fwnode_handle *fwnode, return of_irq_get(to_of_node(fwnode), index); } +static int match_property_by_path(const char *node_path, const char *prop_name, + const char *value) +{ + struct device_node *np __free(device_node) = of_find_node_by_path(node_path); + + return of_property_match_string(np, prop_name, value); +} + +static bool of_is_fwnode_add_links_supported(void) +{ + static int is_supported = -1; + + if (!IS_ENABLED(CONFIG_X86)) + return true; + + if (is_supported != -1) + return !!is_supported; + + is_supported = !((match_property_by_path("/soc", "compatible", "intel,ce4100-cp") >= 0) || + (match_property_by_path("/", "architecture", "OLPC") >= 0)); + + return !!is_supported; +} + static int of_fwnode_add_links(struct fwnode_handle *fwnode) { const struct property *p; struct device_node *con_np = to_of_node(fwnode); - if (IS_ENABLED(CONFIG_X86)) + if (!of_is_fwnode_add_links_supported()) return 0; if (!con_np) -- 2.53.0
{ "author": "Herve Codina <herve.codina@bootlin.com>", "date": "Fri, 27 Feb 2026 14:54:15 +0100", "is_openbsd": false, "thread_id": "20260227135428.783983-1-herve.codina@bootlin.com.mbox.gz" }
lkml_critique
lkml
Hi, This series add support for SFPs ports available on the LAN966x PCI device. In order to have the SFPs supported, additional devices are needed such as clock controller and I2C. As a reminder, the LAN966x PCI device driver use a device-tree overlay to describe devices available on the PCI board. Adding support for SFPs ports consists in adding more devices in the already existing device-tree overlay. With those devices added, the device-tree overlay is more complex and some consumer/supplier relationship are needed in order to remove devices in correct order when the LAN966x PCI driver is removed. Those links are typically provided by fw_devlink and we faced some issues with fw_devlink and overlays. This series gives the big picture related to the SFPs support from fixing issues to adding new devices. Of course, it can be split if needed. The first part of the series (patch 1, 2 and 3) fixes fw_devlink when it is used with overlay. Patches 1 and 3 were previously sent by Saravana [0]. I rebased them on top of v7.0-rc1 and added patch 2 in order to take into account feedback received on the series sent by Saravana. Also I added a call to driver_deferred_probe_trigger() in Saravana's patch (patch 3) to ensure that probes are retried after the modification performed on the dangling consumers. This allows to fix issues reported by Matti and Geert [2] with the previous iteration patches. Those modification were not sufficient in our case and so, on top of that, patches 4 to 6 fix some more issues related to fw_devlink. Patches 7 to 12 introduce and use fw_devlink_set_device() in already existing code. Patches 13 and 14 are related also to fw_devlink but specific to PCI and the device-tree nodes created during enumeration. Patches 15, 16 and 17 are related fw_devlink too but specific to I2C muxes. Patches purpose is to correctly set a link between an adapter supplier and its consumer. Indeed, an i2c mux adapter's parent is not the i2c mux supplier but the adapter the i2c mux is connected to. Adding a new link between the adapter supplier involved when i2c muxes are used avoid a freeze observed during device removal. Patch 18 adds support for fw_delink on x86. fw_devlink is needed to have the consumer/supplier relationship between devices in order to ensure a correct device removal order. Adding fw_devlink support for x86 has been tried in the past but was reverted [1] because it broke some systems. Instead of enabling fw_devlink on *all* x86 system, enable it on *all* x86 except on those where it leads to issue. Patches 19 and 20 allow to build clock and i2c controller used by the LAN966x PCI device when the LAN966x PCI device is enabled. Patches 21 to 25 are specific to the LAN966x. They touch the current dtso, split it in dtsi/dtso files, rename the dtso and improve the driver to allow easier support for other boards. The next patch (patch 26) update the LAN966x device-tree overlay itself to have the SPF ports and devices they depends on described. The last two patches (patches 27 and 29) sort the existing drivers in the needed driver list available in the Kconfig help and add new drivers in this list keep the list up to date with the devices described in the device-tree overlay. We believe some items from the above list can be merged separately, with no build dependencies. We expect: - Patches 1 to 6 to be taken by driver core maintainers - Patches 7 to 12 to be taken by driver core maintainers - Patches 13 and 14 to be taken by driver core or PCI maintainers (depend on patch 7) - Patches 15 to 17 to be taken by I2C maintainers - Patch 18 to be taken by driver core or OF maintainers - Patch 19 to be taken by clock maintainers - Patch 20 to be taken by I2C maintainers - Patches 21 to 28 to be taken by misc maintainers Once again, this series gives the big picture and can be split if needed. Let me know. Compare to previous iteration, this v5 series mainly: - Handle Matti and Geert use cases [2] - Remove simple-platform-bus driver introduced in v4 and switch the simple-bus modification back to what was proposed in v3. In the v4 iteration, conclusion was to use v3 changes [3]. [0] https://lore.kernel.org/lkml/20240411235623.1260061-1-saravanak@google.com/ [1] https://lore.kernel.org/lkml/3c1f2473-92ad-bfc4-258e-a5a08ad73dd0@web.de/ [2] https://lore.kernel.org/all/072dde7c-a53c-4525-83ac-57ea38edc0b5@gmail.com/ [3] https://lore.kernel.org/lkml/20251114083056.31553866@bootlin.com/ Best regards, Hervé Changes: v4 -> v5 v4: https://lore.kernel.org/lkml/20251015071420.1173068-1-herve.codina@bootlin.com/ - Patch 2: Add 'Acked-by: Ulf Hansson' - Patch 3: Add a call to driver_deferred_probe_trigger() - Patch 5: (new patch) Depopulate devices at remove - Patch 6: Populate devices at probe. Switched back to modification proposed in v3 - Patch 7 in v3 removed - Patch 7 (8 in v4): Add 'Reviewed-by: Andy Shevchenko' Add 'Reviewed-by: Ulf Hansson' - Patch 8 (9 in v4): Add 'Reviewed-by: Ulf Hansson' - Patches 9 to 15 (10 to 16 in v3) No changes - Patch 16 (17 in v4): Add 'Reviewed-by: Andi Shyti' - Patch 17 (18 in v4): Change an error code from -EINVAL to -ENODEV Add a blank line and fix a typo in commit log - Patch 18 (19 in v4): Simplify of_is_fwnode_add_links_supported(). Move IS_ENABLED(CONFIG_X86) check in of_is_fwnode_add_links_supported(). - Patches 19 to 21 (20 to 22 in v4) No changes - Patch 22 (23 in v4) Update due to simple-platform-bus removal - Patches 23 to 28 (24 to 29 in v4) No changes v3 -> v4 v3: https://lore.kernel.org/lkml/20250613134817.681832-1-herve.codina@bootlin.com/ - Patch 1: No change - Patch 2: Update and fix conflicts. Indeed, since v3 iteration get_dev_from_fwnode() has been moved to device.h and used by pmdomain/core.c. - Patch 3: remove '#define get_device_from_fwnode()' - Patch 4: Fix conflict (rebase v6.17-rc6) Add 'Reviewed-by: Rafael J. Wysocki' Add 'Reviewed-by: Saravana Kannan' - Patch 5 (new in v4): Introduce simple-platform-bus (binding) - Patch 6 (5 in v3): Rework patch and introduce simple-platform-bus - Patch 7: (new) Use simple-platform-bus in LAN966x - Patch 8 (6 in v3): - No change - Patch 9 and 10 (7 and 8 in v3): Add 'Reviewed-by: Andy Shevchenko' - Patch 11 and 12 (9 and 10 in v3): Add 'Reviewed-by: Dave Jiang' - Patch 13 (11 in v3): Add 'Reviewed-by: Andy Shevchenko' - Patch 12 in v3: Patch removed. Adding __private tag in fwnode.dev is going to be handled in a dedicated series. Indeed a test robot reported an issue and more patches are needed (I have missed fwnode.dev users in several part in the kernel). - Patch 14 and 15 (13 and 14 in v3): No change - Patch 16 (14 in v3): Add 'Reviewed-by: Andi Shyti' - Patch 17 and 18 (16 and 17 in v3): No change - Patch 19 (18 in v3): Filter out support for fw_devlink on x86 based on some device-tree properties. Rewrite commit changelog Remove 'Reviewed-by: Andy Shevchenko' (significant modification) - Patch 20 (19 in v3): Add 'Acked-by: Stephen Boyd' - Patch 21 (20 in v3): Fix conflict (rebase v6.18-rc1) - Patches 22 to 24 (21 to 23 in v3): No change - Patch 25 (24 in v3): Fix conflict (rebase v6.18-rc1) Add 'Acked-by: Bjorn Helgaas' - Patches 26 to 29 (25 to 28 in v3): No change v2 -> v3 v2: https://lore.kernel.org/all/20250507071315.394857-1-herve.codina@bootlin.com/ - Patch 1: Add 'Acked-by: Mark Brown' - Patch 2 and 3: No changes - Patch 4: Rewrite the WARN_ON() condition to avoid an additional 'if' - Patch 5: Fix typos in commit log Update a comment Remove the unneeded check before calling of_platform_depopulate() - Patches 6 to 11: No changes - Patch 12 (new in v3) Tag the fwnode dev member as private - Patch 13 (12 in v2) Fix a typo in the commit log - Patches 14 to 16 (13 to 15 in v2) No changes - Patch 17 (16 in v2) Check parent_physdev for NULL - Patch 18 (17 in v2) Capitalize "Link:" Add 'Reviewed-by: Andy Shevchenko' - Patch 19 (18 in v2) No changes - Patch 20 (19 in v2) Add 'Acked-by: Andi Shyti' - Patch 21 (20 in v2) No changes - Patch 22 (21 in v2) Add 'Reviewed-by: Andrew Lunn' - Patch 23 (22 in v2) Add 'Reviewed-by: Andrew Lunn' - Patch 24 (new in v3) Introduce PCI_DEVICE_ID_EFAR_LAN9662, the LAN966x PCI device ID - Patch 25 (23 in v2) Add 'Reviewed-by: Andrew Lunn' Use PCI_DEVICE_DATA() with PCI_DEVICE_ID_EFAR_LAN9662 instead of PCI_VDEVICE() - Patch 26 to 28 (24 to 26 in v2) No changes v1 -> v2 v1: https://lore.kernel.org/lkml/20250407145546.270683-1-herve.codina@bootlin.com/ - Patch 1 and 3 Remove 'From' tag from the commit log - Patch 2 Add 'Reviewed-by: Andy Shevchenko' Add 'Reviewed-by: Saravana Kannan' Add 'Reviewed-by: Luca Ceresoli' - Patch 4 and 5 No changes - Patch 6 (new in v2) Introduce fw_devlink_set_device() - Patch 7 (new in v2) Use existing device_set_node() helper. - Patch 8 to 11 (new in v2) Use fw_devlink_set_device() in existing code. - Patch 12 (6 in v1) Use fw_devlink_add_device() - Patch 13 (7 in v1) No changes - Patch 14 (8 in v1) Update commit log Use 'physdev' instead of 'supplier' Minor fixes in i2c_get_adapter_physdev() kdoc - Patch 15 and 16 (9 and 10 in v1) Use 'physdev' instead of 'supplier' (commit log, title and code) - Patch 17 (11 in v2) Enable fw_devlink on x86 only if PCI_DYNAMIC_OF_NODES is enabled. Rework commit log. - Patch 18, 19 and 20 (12, 13 and 14 in v1) No changes - Patch 21 (new in v2) Split dtso in dtsi/dtso - Patch 22 (new in v2) Rename lan966x_pci.dtso using the specific board name - Patch 23 (new in v2) Improve the driver introducing board specific data to ease support for other boards (avoid the direct dtbo reference in the function loading the dtbo). - Patch 24 (15 in v1) Refactor due to dtso split in dtsi/dtso - Patch 25 (new in v2) Sort exist driver list in Kconfig help - Patch 26 (16 in v1) Keep alphanumeric order for new drivers added in Kconfig help Herve Codina (26): driver core: Rename get_dev_from_fwnode() wrapper to get_device_from_fwnode() driver core: Avoid warning when removing a device while its supplier is unbinding bus: simple-pm-bus: Remove child devices when the bus is unbound bus: simple-pm-bus: Populate child nodes at probe driver core: fw_devlink: Introduce fw_devlink_set_device() drivers: core: Use fw_devlink_set_device() pinctrl: cs42l43: Use fw_devlink_set_device() cxl/test: Use device_set_node() cxl/test: Use fw_devlink_set_device() PCI: of: Use fw_devlink_set_device() PCI: of: Set fwnode device of newly created PCI device nodes PCI: of: Remove fwnode_dev_initialized() call for a PCI root bridge node i2c: core: Introduce i2c_get_adapter_physdev() i2c: mux: Set adapter physical device i2c: mux: Create missing devlink between mux and adapter physical device of: property: Allow fw_devlink device-tree on x86 clk: lan966x: Add MCHP_LAN966X_PCI dependency i2c: busses: at91: Add MCHP_LAN966X_PCI dependency misc: lan966x_pci: Fix dtso nodes ordering misc: lan966x_pci: Split dtso in dtsi/dtso misc: lan966x_pci: Rename lan966x_pci.dtso to lan966x_evb_lan9662_nic.dtso PCI: Add Microchip LAN9662 PCI Device ID misc: lan966x_pci: Introduce board specific data misc: lan966x_pci: Add dtsi/dtso nodes in order to support SFPs misc: lan966x_pci: Sort the drivers list in Kconfig help misc: lan966x_pci: Add drivers needed to support SFPs in Kconfig help Saravana Kannan (2): Revert "treewide: Fix probing of devices in DT overlays" of: dynamic: Fix overlayed devices not probing because of fw_devlink MAINTAINERS | 3 +- drivers/base/core.c | 108 ++++++++++--- drivers/bus/imx-weim.c | 6 - drivers/bus/simple-pm-bus.c | 24 +-- drivers/clk/Kconfig | 2 +- drivers/i2c/busses/Kconfig | 2 +- drivers/i2c/i2c-core-base.c | 16 ++ drivers/i2c/i2c-core-of.c | 5 - drivers/i2c/i2c-mux.c | 26 ++++ drivers/misc/Kconfig | 11 +- drivers/misc/Makefile | 2 +- drivers/misc/lan966x_evb_lan9662_nic.dtso | 167 ++++++++++++++++++++ drivers/misc/lan966x_pci.c | 30 +++- drivers/misc/lan966x_pci.dtsi | 172 +++++++++++++++++++++ drivers/misc/lan966x_pci.dtso | 177 ---------------------- drivers/of/dynamic.c | 1 - drivers/of/overlay.c | 15 ++ drivers/of/platform.c | 5 - drivers/of/property.c | 26 +++- drivers/pci/of.c | 10 +- drivers/pci/quirks.c | 2 +- drivers/pinctrl/cirrus/pinctrl-cs42l43.c | 2 +- drivers/pmdomain/core.c | 4 +- drivers/spi/spi.c | 5 - include/linux/device.h | 2 +- include/linux/fwnode.h | 7 + include/linux/i2c.h | 3 + include/linux/pci_ids.h | 1 + tools/testing/cxl/test/cxl.c | 4 +- 29 files changed, 584 insertions(+), 254 deletions(-) create mode 100644 drivers/misc/lan966x_evb_lan9662_nic.dtso create mode 100644 drivers/misc/lan966x_pci.dtsi delete mode 100644 drivers/misc/lan966x_pci.dtso -- 2.53.0
null
null
null
[PATCH v5 00/28] lan966x pci device: Add support for SFPs
The lan966x clock controller depends on the LAN969x architecture or the LAN966x SoC. This clock controller can be used by the LAN966x PCI device and so it needs to be available when the LAN966x PCI device is enabled. Signed-off-by: Herve Codina <herve.codina@bootlin.com> Acked-by: Stephen Boyd <sboyd@kernel.org> --- drivers/clk/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/clk/Kconfig b/drivers/clk/Kconfig index 3d803b4cf5c1..0231dd449134 100644 --- a/drivers/clk/Kconfig +++ b/drivers/clk/Kconfig @@ -278,7 +278,7 @@ config COMMON_CLK_LAN966X tristate "Generic Clock Controller driver for LAN966X SoC" depends on HAS_IOMEM depends on OF - depends on SOC_LAN966 || ARCH_LAN969X || COMPILE_TEST + depends on SOC_LAN966 || ARCH_LAN969X || MCHP_LAN966X_PCI || COMPILE_TEST help This driver provides support for Generic Clock Controller(GCK) on LAN966X SoC. GCK generates and supplies clock to various peripherals -- 2.53.0
{ "author": "Herve Codina <herve.codina@bootlin.com>", "date": "Fri, 27 Feb 2026 14:54:16 +0100", "is_openbsd": false, "thread_id": "20260227135428.783983-1-herve.codina@bootlin.com.mbox.gz" }
lkml_critique
lkml
Hi, This series add support for SFPs ports available on the LAN966x PCI device. In order to have the SFPs supported, additional devices are needed such as clock controller and I2C. As a reminder, the LAN966x PCI device driver use a device-tree overlay to describe devices available on the PCI board. Adding support for SFPs ports consists in adding more devices in the already existing device-tree overlay. With those devices added, the device-tree overlay is more complex and some consumer/supplier relationship are needed in order to remove devices in correct order when the LAN966x PCI driver is removed. Those links are typically provided by fw_devlink and we faced some issues with fw_devlink and overlays. This series gives the big picture related to the SFPs support from fixing issues to adding new devices. Of course, it can be split if needed. The first part of the series (patch 1, 2 and 3) fixes fw_devlink when it is used with overlay. Patches 1 and 3 were previously sent by Saravana [0]. I rebased them on top of v7.0-rc1 and added patch 2 in order to take into account feedback received on the series sent by Saravana. Also I added a call to driver_deferred_probe_trigger() in Saravana's patch (patch 3) to ensure that probes are retried after the modification performed on the dangling consumers. This allows to fix issues reported by Matti and Geert [2] with the previous iteration patches. Those modification were not sufficient in our case and so, on top of that, patches 4 to 6 fix some more issues related to fw_devlink. Patches 7 to 12 introduce and use fw_devlink_set_device() in already existing code. Patches 13 and 14 are related also to fw_devlink but specific to PCI and the device-tree nodes created during enumeration. Patches 15, 16 and 17 are related fw_devlink too but specific to I2C muxes. Patches purpose is to correctly set a link between an adapter supplier and its consumer. Indeed, an i2c mux adapter's parent is not the i2c mux supplier but the adapter the i2c mux is connected to. Adding a new link between the adapter supplier involved when i2c muxes are used avoid a freeze observed during device removal. Patch 18 adds support for fw_delink on x86. fw_devlink is needed to have the consumer/supplier relationship between devices in order to ensure a correct device removal order. Adding fw_devlink support for x86 has been tried in the past but was reverted [1] because it broke some systems. Instead of enabling fw_devlink on *all* x86 system, enable it on *all* x86 except on those where it leads to issue. Patches 19 and 20 allow to build clock and i2c controller used by the LAN966x PCI device when the LAN966x PCI device is enabled. Patches 21 to 25 are specific to the LAN966x. They touch the current dtso, split it in dtsi/dtso files, rename the dtso and improve the driver to allow easier support for other boards. The next patch (patch 26) update the LAN966x device-tree overlay itself to have the SPF ports and devices they depends on described. The last two patches (patches 27 and 29) sort the existing drivers in the needed driver list available in the Kconfig help and add new drivers in this list keep the list up to date with the devices described in the device-tree overlay. We believe some items from the above list can be merged separately, with no build dependencies. We expect: - Patches 1 to 6 to be taken by driver core maintainers - Patches 7 to 12 to be taken by driver core maintainers - Patches 13 and 14 to be taken by driver core or PCI maintainers (depend on patch 7) - Patches 15 to 17 to be taken by I2C maintainers - Patch 18 to be taken by driver core or OF maintainers - Patch 19 to be taken by clock maintainers - Patch 20 to be taken by I2C maintainers - Patches 21 to 28 to be taken by misc maintainers Once again, this series gives the big picture and can be split if needed. Let me know. Compare to previous iteration, this v5 series mainly: - Handle Matti and Geert use cases [2] - Remove simple-platform-bus driver introduced in v4 and switch the simple-bus modification back to what was proposed in v3. In the v4 iteration, conclusion was to use v3 changes [3]. [0] https://lore.kernel.org/lkml/20240411235623.1260061-1-saravanak@google.com/ [1] https://lore.kernel.org/lkml/3c1f2473-92ad-bfc4-258e-a5a08ad73dd0@web.de/ [2] https://lore.kernel.org/all/072dde7c-a53c-4525-83ac-57ea38edc0b5@gmail.com/ [3] https://lore.kernel.org/lkml/20251114083056.31553866@bootlin.com/ Best regards, Hervé Changes: v4 -> v5 v4: https://lore.kernel.org/lkml/20251015071420.1173068-1-herve.codina@bootlin.com/ - Patch 2: Add 'Acked-by: Ulf Hansson' - Patch 3: Add a call to driver_deferred_probe_trigger() - Patch 5: (new patch) Depopulate devices at remove - Patch 6: Populate devices at probe. Switched back to modification proposed in v3 - Patch 7 in v3 removed - Patch 7 (8 in v4): Add 'Reviewed-by: Andy Shevchenko' Add 'Reviewed-by: Ulf Hansson' - Patch 8 (9 in v4): Add 'Reviewed-by: Ulf Hansson' - Patches 9 to 15 (10 to 16 in v3) No changes - Patch 16 (17 in v4): Add 'Reviewed-by: Andi Shyti' - Patch 17 (18 in v4): Change an error code from -EINVAL to -ENODEV Add a blank line and fix a typo in commit log - Patch 18 (19 in v4): Simplify of_is_fwnode_add_links_supported(). Move IS_ENABLED(CONFIG_X86) check in of_is_fwnode_add_links_supported(). - Patches 19 to 21 (20 to 22 in v4) No changes - Patch 22 (23 in v4) Update due to simple-platform-bus removal - Patches 23 to 28 (24 to 29 in v4) No changes v3 -> v4 v3: https://lore.kernel.org/lkml/20250613134817.681832-1-herve.codina@bootlin.com/ - Patch 1: No change - Patch 2: Update and fix conflicts. Indeed, since v3 iteration get_dev_from_fwnode() has been moved to device.h and used by pmdomain/core.c. - Patch 3: remove '#define get_device_from_fwnode()' - Patch 4: Fix conflict (rebase v6.17-rc6) Add 'Reviewed-by: Rafael J. Wysocki' Add 'Reviewed-by: Saravana Kannan' - Patch 5 (new in v4): Introduce simple-platform-bus (binding) - Patch 6 (5 in v3): Rework patch and introduce simple-platform-bus - Patch 7: (new) Use simple-platform-bus in LAN966x - Patch 8 (6 in v3): - No change - Patch 9 and 10 (7 and 8 in v3): Add 'Reviewed-by: Andy Shevchenko' - Patch 11 and 12 (9 and 10 in v3): Add 'Reviewed-by: Dave Jiang' - Patch 13 (11 in v3): Add 'Reviewed-by: Andy Shevchenko' - Patch 12 in v3: Patch removed. Adding __private tag in fwnode.dev is going to be handled in a dedicated series. Indeed a test robot reported an issue and more patches are needed (I have missed fwnode.dev users in several part in the kernel). - Patch 14 and 15 (13 and 14 in v3): No change - Patch 16 (14 in v3): Add 'Reviewed-by: Andi Shyti' - Patch 17 and 18 (16 and 17 in v3): No change - Patch 19 (18 in v3): Filter out support for fw_devlink on x86 based on some device-tree properties. Rewrite commit changelog Remove 'Reviewed-by: Andy Shevchenko' (significant modification) - Patch 20 (19 in v3): Add 'Acked-by: Stephen Boyd' - Patch 21 (20 in v3): Fix conflict (rebase v6.18-rc1) - Patches 22 to 24 (21 to 23 in v3): No change - Patch 25 (24 in v3): Fix conflict (rebase v6.18-rc1) Add 'Acked-by: Bjorn Helgaas' - Patches 26 to 29 (25 to 28 in v3): No change v2 -> v3 v2: https://lore.kernel.org/all/20250507071315.394857-1-herve.codina@bootlin.com/ - Patch 1: Add 'Acked-by: Mark Brown' - Patch 2 and 3: No changes - Patch 4: Rewrite the WARN_ON() condition to avoid an additional 'if' - Patch 5: Fix typos in commit log Update a comment Remove the unneeded check before calling of_platform_depopulate() - Patches 6 to 11: No changes - Patch 12 (new in v3) Tag the fwnode dev member as private - Patch 13 (12 in v2) Fix a typo in the commit log - Patches 14 to 16 (13 to 15 in v2) No changes - Patch 17 (16 in v2) Check parent_physdev for NULL - Patch 18 (17 in v2) Capitalize "Link:" Add 'Reviewed-by: Andy Shevchenko' - Patch 19 (18 in v2) No changes - Patch 20 (19 in v2) Add 'Acked-by: Andi Shyti' - Patch 21 (20 in v2) No changes - Patch 22 (21 in v2) Add 'Reviewed-by: Andrew Lunn' - Patch 23 (22 in v2) Add 'Reviewed-by: Andrew Lunn' - Patch 24 (new in v3) Introduce PCI_DEVICE_ID_EFAR_LAN9662, the LAN966x PCI device ID - Patch 25 (23 in v2) Add 'Reviewed-by: Andrew Lunn' Use PCI_DEVICE_DATA() with PCI_DEVICE_ID_EFAR_LAN9662 instead of PCI_VDEVICE() - Patch 26 to 28 (24 to 26 in v2) No changes v1 -> v2 v1: https://lore.kernel.org/lkml/20250407145546.270683-1-herve.codina@bootlin.com/ - Patch 1 and 3 Remove 'From' tag from the commit log - Patch 2 Add 'Reviewed-by: Andy Shevchenko' Add 'Reviewed-by: Saravana Kannan' Add 'Reviewed-by: Luca Ceresoli' - Patch 4 and 5 No changes - Patch 6 (new in v2) Introduce fw_devlink_set_device() - Patch 7 (new in v2) Use existing device_set_node() helper. - Patch 8 to 11 (new in v2) Use fw_devlink_set_device() in existing code. - Patch 12 (6 in v1) Use fw_devlink_add_device() - Patch 13 (7 in v1) No changes - Patch 14 (8 in v1) Update commit log Use 'physdev' instead of 'supplier' Minor fixes in i2c_get_adapter_physdev() kdoc - Patch 15 and 16 (9 and 10 in v1) Use 'physdev' instead of 'supplier' (commit log, title and code) - Patch 17 (11 in v2) Enable fw_devlink on x86 only if PCI_DYNAMIC_OF_NODES is enabled. Rework commit log. - Patch 18, 19 and 20 (12, 13 and 14 in v1) No changes - Patch 21 (new in v2) Split dtso in dtsi/dtso - Patch 22 (new in v2) Rename lan966x_pci.dtso using the specific board name - Patch 23 (new in v2) Improve the driver introducing board specific data to ease support for other boards (avoid the direct dtbo reference in the function loading the dtbo). - Patch 24 (15 in v1) Refactor due to dtso split in dtsi/dtso - Patch 25 (new in v2) Sort exist driver list in Kconfig help - Patch 26 (16 in v1) Keep alphanumeric order for new drivers added in Kconfig help Herve Codina (26): driver core: Rename get_dev_from_fwnode() wrapper to get_device_from_fwnode() driver core: Avoid warning when removing a device while its supplier is unbinding bus: simple-pm-bus: Remove child devices when the bus is unbound bus: simple-pm-bus: Populate child nodes at probe driver core: fw_devlink: Introduce fw_devlink_set_device() drivers: core: Use fw_devlink_set_device() pinctrl: cs42l43: Use fw_devlink_set_device() cxl/test: Use device_set_node() cxl/test: Use fw_devlink_set_device() PCI: of: Use fw_devlink_set_device() PCI: of: Set fwnode device of newly created PCI device nodes PCI: of: Remove fwnode_dev_initialized() call for a PCI root bridge node i2c: core: Introduce i2c_get_adapter_physdev() i2c: mux: Set adapter physical device i2c: mux: Create missing devlink between mux and adapter physical device of: property: Allow fw_devlink device-tree on x86 clk: lan966x: Add MCHP_LAN966X_PCI dependency i2c: busses: at91: Add MCHP_LAN966X_PCI dependency misc: lan966x_pci: Fix dtso nodes ordering misc: lan966x_pci: Split dtso in dtsi/dtso misc: lan966x_pci: Rename lan966x_pci.dtso to lan966x_evb_lan9662_nic.dtso PCI: Add Microchip LAN9662 PCI Device ID misc: lan966x_pci: Introduce board specific data misc: lan966x_pci: Add dtsi/dtso nodes in order to support SFPs misc: lan966x_pci: Sort the drivers list in Kconfig help misc: lan966x_pci: Add drivers needed to support SFPs in Kconfig help Saravana Kannan (2): Revert "treewide: Fix probing of devices in DT overlays" of: dynamic: Fix overlayed devices not probing because of fw_devlink MAINTAINERS | 3 +- drivers/base/core.c | 108 ++++++++++--- drivers/bus/imx-weim.c | 6 - drivers/bus/simple-pm-bus.c | 24 +-- drivers/clk/Kconfig | 2 +- drivers/i2c/busses/Kconfig | 2 +- drivers/i2c/i2c-core-base.c | 16 ++ drivers/i2c/i2c-core-of.c | 5 - drivers/i2c/i2c-mux.c | 26 ++++ drivers/misc/Kconfig | 11 +- drivers/misc/Makefile | 2 +- drivers/misc/lan966x_evb_lan9662_nic.dtso | 167 ++++++++++++++++++++ drivers/misc/lan966x_pci.c | 30 +++- drivers/misc/lan966x_pci.dtsi | 172 +++++++++++++++++++++ drivers/misc/lan966x_pci.dtso | 177 ---------------------- drivers/of/dynamic.c | 1 - drivers/of/overlay.c | 15 ++ drivers/of/platform.c | 5 - drivers/of/property.c | 26 +++- drivers/pci/of.c | 10 +- drivers/pci/quirks.c | 2 +- drivers/pinctrl/cirrus/pinctrl-cs42l43.c | 2 +- drivers/pmdomain/core.c | 4 +- drivers/spi/spi.c | 5 - include/linux/device.h | 2 +- include/linux/fwnode.h | 7 + include/linux/i2c.h | 3 + include/linux/pci_ids.h | 1 + tools/testing/cxl/test/cxl.c | 4 +- 29 files changed, 584 insertions(+), 254 deletions(-) create mode 100644 drivers/misc/lan966x_evb_lan9662_nic.dtso create mode 100644 drivers/misc/lan966x_pci.dtsi delete mode 100644 drivers/misc/lan966x_pci.dtso -- 2.53.0
null
null
null
[PATCH v5 00/28] lan966x pci device: Add support for SFPs
The AT91 I2C driver depends on ARCH_MICROCHIP. This I2C controller can be used by the LAN966x PCI device and so it needs to be available when the LAN966x PCI device is enabled. Signed-off-by: Herve Codina <herve.codina@bootlin.com> Acked-by: Andi Shyti <andi.shyti@kernel.org> --- drivers/i2c/busses/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig index e11d50750e63..f43b3e8ca317 100644 --- a/drivers/i2c/busses/Kconfig +++ b/drivers/i2c/busses/Kconfig @@ -417,7 +417,7 @@ config I2C_ASPEED config I2C_AT91 tristate "Atmel AT91 I2C Two-Wire interface (TWI)" - depends on ARCH_MICROCHIP || COMPILE_TEST + depends on ARCH_MICROCHIP || MCHP_LAN966X_PCI || COMPILE_TEST help This supports the use of the I2C interface on Atmel AT91 processors. -- 2.53.0
{ "author": "Herve Codina <herve.codina@bootlin.com>", "date": "Fri, 27 Feb 2026 14:54:17 +0100", "is_openbsd": false, "thread_id": "20260227135428.783983-1-herve.codina@bootlin.com.mbox.gz" }
lkml_critique
lkml
Hi, This series add support for SFPs ports available on the LAN966x PCI device. In order to have the SFPs supported, additional devices are needed such as clock controller and I2C. As a reminder, the LAN966x PCI device driver use a device-tree overlay to describe devices available on the PCI board. Adding support for SFPs ports consists in adding more devices in the already existing device-tree overlay. With those devices added, the device-tree overlay is more complex and some consumer/supplier relationship are needed in order to remove devices in correct order when the LAN966x PCI driver is removed. Those links are typically provided by fw_devlink and we faced some issues with fw_devlink and overlays. This series gives the big picture related to the SFPs support from fixing issues to adding new devices. Of course, it can be split if needed. The first part of the series (patch 1, 2 and 3) fixes fw_devlink when it is used with overlay. Patches 1 and 3 were previously sent by Saravana [0]. I rebased them on top of v7.0-rc1 and added patch 2 in order to take into account feedback received on the series sent by Saravana. Also I added a call to driver_deferred_probe_trigger() in Saravana's patch (patch 3) to ensure that probes are retried after the modification performed on the dangling consumers. This allows to fix issues reported by Matti and Geert [2] with the previous iteration patches. Those modification were not sufficient in our case and so, on top of that, patches 4 to 6 fix some more issues related to fw_devlink. Patches 7 to 12 introduce and use fw_devlink_set_device() in already existing code. Patches 13 and 14 are related also to fw_devlink but specific to PCI and the device-tree nodes created during enumeration. Patches 15, 16 and 17 are related fw_devlink too but specific to I2C muxes. Patches purpose is to correctly set a link between an adapter supplier and its consumer. Indeed, an i2c mux adapter's parent is not the i2c mux supplier but the adapter the i2c mux is connected to. Adding a new link between the adapter supplier involved when i2c muxes are used avoid a freeze observed during device removal. Patch 18 adds support for fw_delink on x86. fw_devlink is needed to have the consumer/supplier relationship between devices in order to ensure a correct device removal order. Adding fw_devlink support for x86 has been tried in the past but was reverted [1] because it broke some systems. Instead of enabling fw_devlink on *all* x86 system, enable it on *all* x86 except on those where it leads to issue. Patches 19 and 20 allow to build clock and i2c controller used by the LAN966x PCI device when the LAN966x PCI device is enabled. Patches 21 to 25 are specific to the LAN966x. They touch the current dtso, split it in dtsi/dtso files, rename the dtso and improve the driver to allow easier support for other boards. The next patch (patch 26) update the LAN966x device-tree overlay itself to have the SPF ports and devices they depends on described. The last two patches (patches 27 and 29) sort the existing drivers in the needed driver list available in the Kconfig help and add new drivers in this list keep the list up to date with the devices described in the device-tree overlay. We believe some items from the above list can be merged separately, with no build dependencies. We expect: - Patches 1 to 6 to be taken by driver core maintainers - Patches 7 to 12 to be taken by driver core maintainers - Patches 13 and 14 to be taken by driver core or PCI maintainers (depend on patch 7) - Patches 15 to 17 to be taken by I2C maintainers - Patch 18 to be taken by driver core or OF maintainers - Patch 19 to be taken by clock maintainers - Patch 20 to be taken by I2C maintainers - Patches 21 to 28 to be taken by misc maintainers Once again, this series gives the big picture and can be split if needed. Let me know. Compare to previous iteration, this v5 series mainly: - Handle Matti and Geert use cases [2] - Remove simple-platform-bus driver introduced in v4 and switch the simple-bus modification back to what was proposed in v3. In the v4 iteration, conclusion was to use v3 changes [3]. [0] https://lore.kernel.org/lkml/20240411235623.1260061-1-saravanak@google.com/ [1] https://lore.kernel.org/lkml/3c1f2473-92ad-bfc4-258e-a5a08ad73dd0@web.de/ [2] https://lore.kernel.org/all/072dde7c-a53c-4525-83ac-57ea38edc0b5@gmail.com/ [3] https://lore.kernel.org/lkml/20251114083056.31553866@bootlin.com/ Best regards, Hervé Changes: v4 -> v5 v4: https://lore.kernel.org/lkml/20251015071420.1173068-1-herve.codina@bootlin.com/ - Patch 2: Add 'Acked-by: Ulf Hansson' - Patch 3: Add a call to driver_deferred_probe_trigger() - Patch 5: (new patch) Depopulate devices at remove - Patch 6: Populate devices at probe. Switched back to modification proposed in v3 - Patch 7 in v3 removed - Patch 7 (8 in v4): Add 'Reviewed-by: Andy Shevchenko' Add 'Reviewed-by: Ulf Hansson' - Patch 8 (9 in v4): Add 'Reviewed-by: Ulf Hansson' - Patches 9 to 15 (10 to 16 in v3) No changes - Patch 16 (17 in v4): Add 'Reviewed-by: Andi Shyti' - Patch 17 (18 in v4): Change an error code from -EINVAL to -ENODEV Add a blank line and fix a typo in commit log - Patch 18 (19 in v4): Simplify of_is_fwnode_add_links_supported(). Move IS_ENABLED(CONFIG_X86) check in of_is_fwnode_add_links_supported(). - Patches 19 to 21 (20 to 22 in v4) No changes - Patch 22 (23 in v4) Update due to simple-platform-bus removal - Patches 23 to 28 (24 to 29 in v4) No changes v3 -> v4 v3: https://lore.kernel.org/lkml/20250613134817.681832-1-herve.codina@bootlin.com/ - Patch 1: No change - Patch 2: Update and fix conflicts. Indeed, since v3 iteration get_dev_from_fwnode() has been moved to device.h and used by pmdomain/core.c. - Patch 3: remove '#define get_device_from_fwnode()' - Patch 4: Fix conflict (rebase v6.17-rc6) Add 'Reviewed-by: Rafael J. Wysocki' Add 'Reviewed-by: Saravana Kannan' - Patch 5 (new in v4): Introduce simple-platform-bus (binding) - Patch 6 (5 in v3): Rework patch and introduce simple-platform-bus - Patch 7: (new) Use simple-platform-bus in LAN966x - Patch 8 (6 in v3): - No change - Patch 9 and 10 (7 and 8 in v3): Add 'Reviewed-by: Andy Shevchenko' - Patch 11 and 12 (9 and 10 in v3): Add 'Reviewed-by: Dave Jiang' - Patch 13 (11 in v3): Add 'Reviewed-by: Andy Shevchenko' - Patch 12 in v3: Patch removed. Adding __private tag in fwnode.dev is going to be handled in a dedicated series. Indeed a test robot reported an issue and more patches are needed (I have missed fwnode.dev users in several part in the kernel). - Patch 14 and 15 (13 and 14 in v3): No change - Patch 16 (14 in v3): Add 'Reviewed-by: Andi Shyti' - Patch 17 and 18 (16 and 17 in v3): No change - Patch 19 (18 in v3): Filter out support for fw_devlink on x86 based on some device-tree properties. Rewrite commit changelog Remove 'Reviewed-by: Andy Shevchenko' (significant modification) - Patch 20 (19 in v3): Add 'Acked-by: Stephen Boyd' - Patch 21 (20 in v3): Fix conflict (rebase v6.18-rc1) - Patches 22 to 24 (21 to 23 in v3): No change - Patch 25 (24 in v3): Fix conflict (rebase v6.18-rc1) Add 'Acked-by: Bjorn Helgaas' - Patches 26 to 29 (25 to 28 in v3): No change v2 -> v3 v2: https://lore.kernel.org/all/20250507071315.394857-1-herve.codina@bootlin.com/ - Patch 1: Add 'Acked-by: Mark Brown' - Patch 2 and 3: No changes - Patch 4: Rewrite the WARN_ON() condition to avoid an additional 'if' - Patch 5: Fix typos in commit log Update a comment Remove the unneeded check before calling of_platform_depopulate() - Patches 6 to 11: No changes - Patch 12 (new in v3) Tag the fwnode dev member as private - Patch 13 (12 in v2) Fix a typo in the commit log - Patches 14 to 16 (13 to 15 in v2) No changes - Patch 17 (16 in v2) Check parent_physdev for NULL - Patch 18 (17 in v2) Capitalize "Link:" Add 'Reviewed-by: Andy Shevchenko' - Patch 19 (18 in v2) No changes - Patch 20 (19 in v2) Add 'Acked-by: Andi Shyti' - Patch 21 (20 in v2) No changes - Patch 22 (21 in v2) Add 'Reviewed-by: Andrew Lunn' - Patch 23 (22 in v2) Add 'Reviewed-by: Andrew Lunn' - Patch 24 (new in v3) Introduce PCI_DEVICE_ID_EFAR_LAN9662, the LAN966x PCI device ID - Patch 25 (23 in v2) Add 'Reviewed-by: Andrew Lunn' Use PCI_DEVICE_DATA() with PCI_DEVICE_ID_EFAR_LAN9662 instead of PCI_VDEVICE() - Patch 26 to 28 (24 to 26 in v2) No changes v1 -> v2 v1: https://lore.kernel.org/lkml/20250407145546.270683-1-herve.codina@bootlin.com/ - Patch 1 and 3 Remove 'From' tag from the commit log - Patch 2 Add 'Reviewed-by: Andy Shevchenko' Add 'Reviewed-by: Saravana Kannan' Add 'Reviewed-by: Luca Ceresoli' - Patch 4 and 5 No changes - Patch 6 (new in v2) Introduce fw_devlink_set_device() - Patch 7 (new in v2) Use existing device_set_node() helper. - Patch 8 to 11 (new in v2) Use fw_devlink_set_device() in existing code. - Patch 12 (6 in v1) Use fw_devlink_add_device() - Patch 13 (7 in v1) No changes - Patch 14 (8 in v1) Update commit log Use 'physdev' instead of 'supplier' Minor fixes in i2c_get_adapter_physdev() kdoc - Patch 15 and 16 (9 and 10 in v1) Use 'physdev' instead of 'supplier' (commit log, title and code) - Patch 17 (11 in v2) Enable fw_devlink on x86 only if PCI_DYNAMIC_OF_NODES is enabled. Rework commit log. - Patch 18, 19 and 20 (12, 13 and 14 in v1) No changes - Patch 21 (new in v2) Split dtso in dtsi/dtso - Patch 22 (new in v2) Rename lan966x_pci.dtso using the specific board name - Patch 23 (new in v2) Improve the driver introducing board specific data to ease support for other boards (avoid the direct dtbo reference in the function loading the dtbo). - Patch 24 (15 in v1) Refactor due to dtso split in dtsi/dtso - Patch 25 (new in v2) Sort exist driver list in Kconfig help - Patch 26 (16 in v1) Keep alphanumeric order for new drivers added in Kconfig help Herve Codina (26): driver core: Rename get_dev_from_fwnode() wrapper to get_device_from_fwnode() driver core: Avoid warning when removing a device while its supplier is unbinding bus: simple-pm-bus: Remove child devices when the bus is unbound bus: simple-pm-bus: Populate child nodes at probe driver core: fw_devlink: Introduce fw_devlink_set_device() drivers: core: Use fw_devlink_set_device() pinctrl: cs42l43: Use fw_devlink_set_device() cxl/test: Use device_set_node() cxl/test: Use fw_devlink_set_device() PCI: of: Use fw_devlink_set_device() PCI: of: Set fwnode device of newly created PCI device nodes PCI: of: Remove fwnode_dev_initialized() call for a PCI root bridge node i2c: core: Introduce i2c_get_adapter_physdev() i2c: mux: Set adapter physical device i2c: mux: Create missing devlink between mux and adapter physical device of: property: Allow fw_devlink device-tree on x86 clk: lan966x: Add MCHP_LAN966X_PCI dependency i2c: busses: at91: Add MCHP_LAN966X_PCI dependency misc: lan966x_pci: Fix dtso nodes ordering misc: lan966x_pci: Split dtso in dtsi/dtso misc: lan966x_pci: Rename lan966x_pci.dtso to lan966x_evb_lan9662_nic.dtso PCI: Add Microchip LAN9662 PCI Device ID misc: lan966x_pci: Introduce board specific data misc: lan966x_pci: Add dtsi/dtso nodes in order to support SFPs misc: lan966x_pci: Sort the drivers list in Kconfig help misc: lan966x_pci: Add drivers needed to support SFPs in Kconfig help Saravana Kannan (2): Revert "treewide: Fix probing of devices in DT overlays" of: dynamic: Fix overlayed devices not probing because of fw_devlink MAINTAINERS | 3 +- drivers/base/core.c | 108 ++++++++++--- drivers/bus/imx-weim.c | 6 - drivers/bus/simple-pm-bus.c | 24 +-- drivers/clk/Kconfig | 2 +- drivers/i2c/busses/Kconfig | 2 +- drivers/i2c/i2c-core-base.c | 16 ++ drivers/i2c/i2c-core-of.c | 5 - drivers/i2c/i2c-mux.c | 26 ++++ drivers/misc/Kconfig | 11 +- drivers/misc/Makefile | 2 +- drivers/misc/lan966x_evb_lan9662_nic.dtso | 167 ++++++++++++++++++++ drivers/misc/lan966x_pci.c | 30 +++- drivers/misc/lan966x_pci.dtsi | 172 +++++++++++++++++++++ drivers/misc/lan966x_pci.dtso | 177 ---------------------- drivers/of/dynamic.c | 1 - drivers/of/overlay.c | 15 ++ drivers/of/platform.c | 5 - drivers/of/property.c | 26 +++- drivers/pci/of.c | 10 +- drivers/pci/quirks.c | 2 +- drivers/pinctrl/cirrus/pinctrl-cs42l43.c | 2 +- drivers/pmdomain/core.c | 4 +- drivers/spi/spi.c | 5 - include/linux/device.h | 2 +- include/linux/fwnode.h | 7 + include/linux/i2c.h | 3 + include/linux/pci_ids.h | 1 + tools/testing/cxl/test/cxl.c | 4 +- 29 files changed, 584 insertions(+), 254 deletions(-) create mode 100644 drivers/misc/lan966x_evb_lan9662_nic.dtso create mode 100644 drivers/misc/lan966x_pci.dtsi delete mode 100644 drivers/misc/lan966x_pci.dtso -- 2.53.0
null
null
null
[PATCH v5 00/28] lan966x pci device: Add support for SFPs
Nodes available in the dtso are not ordered by their unit address. Fix that re-ordering them according to their unit address. Signed-off-by: Herve Codina <herve.codina@bootlin.com> --- drivers/misc/lan966x_pci.dtso | 99 +++++++++++++++++------------------ 1 file changed, 49 insertions(+), 50 deletions(-) diff --git a/drivers/misc/lan966x_pci.dtso b/drivers/misc/lan966x_pci.dtso index 7b196b0a0eb6..94a967b384f3 100644 --- a/drivers/misc/lan966x_pci.dtso +++ b/drivers/misc/lan966x_pci.dtso @@ -59,6 +59,50 @@ pci-ep-bus@0 { ranges = <0xe2000000 0x00 0x00 0x00 0x2000000 0xe0000000 0x01 0x00 0x00 0x1000000>; + switch: switch@e0000000 { + compatible = "microchip,lan966x-switch"; + reg = <0xe0000000 0x0100000>, + <0xe2000000 0x0800000>; + reg-names = "cpu", "gcb"; + + interrupt-parent = <&oic>; + interrupts = <12 IRQ_TYPE_LEVEL_HIGH>, + <9 IRQ_TYPE_LEVEL_HIGH>; + interrupt-names = "xtr", "ana"; + + resets = <&reset 0>; + reset-names = "switch"; + + pinctrl-names = "default"; + pinctrl-0 = <&tod_pins>; + + ethernet-ports { + #address-cells = <1>; + #size-cells = <0>; + + port0: port@0 { + phy-handle = <&lan966x_phy0>; + + reg = <0>; + phy-mode = "gmii"; + phys = <&serdes 0 CU(0)>; + }; + + port1: port@1 { + phy-handle = <&lan966x_phy1>; + + reg = <1>; + phy-mode = "gmii"; + phys = <&serdes 1 CU(1)>; + }; + }; + }; + + cpu_ctrl: syscon@e00c0000 { + compatible = "microchip,lan966x-cpu-syscon", "syscon"; + reg = <0xe00c0000 0xa8>; + }; + oic: oic@e00c0120 { compatible = "microchip,lan966x-oic"; #interrupt-cells = <2>; @@ -67,11 +111,6 @@ oic: oic@e00c0120 { reg = <0xe00c0120 0x190>; }; - cpu_ctrl: syscon@e00c0000 { - compatible = "microchip,lan966x-cpu-syscon", "syscon"; - reg = <0xe00c0000 0xa8>; - }; - reset: reset@e200400c { compatible = "microchip,lan966x-switch-reset"; reg = <0xe200400c 0x4>, <0xe00c0000 0xa8>; @@ -104,14 +143,6 @@ fc0_a_pins: fcb4-i2c-pins { pins = "GPIO_9", "GPIO_10"; function = "fc0_a"; }; - - }; - - serdes: serdes@e202c000 { - compatible = "microchip,lan966x-serdes"; - reg = <0xe202c000 0x9c>, - <0xe2004010 0x4>; - #phy-cells = <2>; }; mdio1: mdio@e200413c { @@ -133,43 +164,11 @@ lan966x_phy1: ethernet-lan966x_phy@2 { }; }; - switch: switch@e0000000 { - compatible = "microchip,lan966x-switch"; - reg = <0xe0000000 0x0100000>, - <0xe2000000 0x0800000>; - reg-names = "cpu", "gcb"; - - interrupt-parent = <&oic>; - interrupts = <12 IRQ_TYPE_LEVEL_HIGH>, - <9 IRQ_TYPE_LEVEL_HIGH>; - interrupt-names = "xtr", "ana"; - - resets = <&reset 0>; - reset-names = "switch"; - - pinctrl-names = "default"; - pinctrl-0 = <&tod_pins>; - - ethernet-ports { - #address-cells = <1>; - #size-cells = <0>; - - port0: port@0 { - phy-handle = <&lan966x_phy0>; - - reg = <0>; - phy-mode = "gmii"; - phys = <&serdes 0 CU(0)>; - }; - - port1: port@1 { - phy-handle = <&lan966x_phy1>; - - reg = <1>; - phy-mode = "gmii"; - phys = <&serdes 1 CU(1)>; - }; - }; + serdes: serdes@e202c000 { + compatible = "microchip,lan966x-serdes"; + reg = <0xe202c000 0x9c>, + <0xe2004010 0x4>; + #phy-cells = <2>; }; }; }; -- 2.53.0
{ "author": "Herve Codina <herve.codina@bootlin.com>", "date": "Fri, 27 Feb 2026 14:54:18 +0100", "is_openbsd": false, "thread_id": "20260227135428.783983-1-herve.codina@bootlin.com.mbox.gz" }
lkml_critique
lkml
Hi, This series add support for SFPs ports available on the LAN966x PCI device. In order to have the SFPs supported, additional devices are needed such as clock controller and I2C. As a reminder, the LAN966x PCI device driver use a device-tree overlay to describe devices available on the PCI board. Adding support for SFPs ports consists in adding more devices in the already existing device-tree overlay. With those devices added, the device-tree overlay is more complex and some consumer/supplier relationship are needed in order to remove devices in correct order when the LAN966x PCI driver is removed. Those links are typically provided by fw_devlink and we faced some issues with fw_devlink and overlays. This series gives the big picture related to the SFPs support from fixing issues to adding new devices. Of course, it can be split if needed. The first part of the series (patch 1, 2 and 3) fixes fw_devlink when it is used with overlay. Patches 1 and 3 were previously sent by Saravana [0]. I rebased them on top of v7.0-rc1 and added patch 2 in order to take into account feedback received on the series sent by Saravana. Also I added a call to driver_deferred_probe_trigger() in Saravana's patch (patch 3) to ensure that probes are retried after the modification performed on the dangling consumers. This allows to fix issues reported by Matti and Geert [2] with the previous iteration patches. Those modification were not sufficient in our case and so, on top of that, patches 4 to 6 fix some more issues related to fw_devlink. Patches 7 to 12 introduce and use fw_devlink_set_device() in already existing code. Patches 13 and 14 are related also to fw_devlink but specific to PCI and the device-tree nodes created during enumeration. Patches 15, 16 and 17 are related fw_devlink too but specific to I2C muxes. Patches purpose is to correctly set a link between an adapter supplier and its consumer. Indeed, an i2c mux adapter's parent is not the i2c mux supplier but the adapter the i2c mux is connected to. Adding a new link between the adapter supplier involved when i2c muxes are used avoid a freeze observed during device removal. Patch 18 adds support for fw_delink on x86. fw_devlink is needed to have the consumer/supplier relationship between devices in order to ensure a correct device removal order. Adding fw_devlink support for x86 has been tried in the past but was reverted [1] because it broke some systems. Instead of enabling fw_devlink on *all* x86 system, enable it on *all* x86 except on those where it leads to issue. Patches 19 and 20 allow to build clock and i2c controller used by the LAN966x PCI device when the LAN966x PCI device is enabled. Patches 21 to 25 are specific to the LAN966x. They touch the current dtso, split it in dtsi/dtso files, rename the dtso and improve the driver to allow easier support for other boards. The next patch (patch 26) update the LAN966x device-tree overlay itself to have the SPF ports and devices they depends on described. The last two patches (patches 27 and 29) sort the existing drivers in the needed driver list available in the Kconfig help and add new drivers in this list keep the list up to date with the devices described in the device-tree overlay. We believe some items from the above list can be merged separately, with no build dependencies. We expect: - Patches 1 to 6 to be taken by driver core maintainers - Patches 7 to 12 to be taken by driver core maintainers - Patches 13 and 14 to be taken by driver core or PCI maintainers (depend on patch 7) - Patches 15 to 17 to be taken by I2C maintainers - Patch 18 to be taken by driver core or OF maintainers - Patch 19 to be taken by clock maintainers - Patch 20 to be taken by I2C maintainers - Patches 21 to 28 to be taken by misc maintainers Once again, this series gives the big picture and can be split if needed. Let me know. Compare to previous iteration, this v5 series mainly: - Handle Matti and Geert use cases [2] - Remove simple-platform-bus driver introduced in v4 and switch the simple-bus modification back to what was proposed in v3. In the v4 iteration, conclusion was to use v3 changes [3]. [0] https://lore.kernel.org/lkml/20240411235623.1260061-1-saravanak@google.com/ [1] https://lore.kernel.org/lkml/3c1f2473-92ad-bfc4-258e-a5a08ad73dd0@web.de/ [2] https://lore.kernel.org/all/072dde7c-a53c-4525-83ac-57ea38edc0b5@gmail.com/ [3] https://lore.kernel.org/lkml/20251114083056.31553866@bootlin.com/ Best regards, Hervé Changes: v4 -> v5 v4: https://lore.kernel.org/lkml/20251015071420.1173068-1-herve.codina@bootlin.com/ - Patch 2: Add 'Acked-by: Ulf Hansson' - Patch 3: Add a call to driver_deferred_probe_trigger() - Patch 5: (new patch) Depopulate devices at remove - Patch 6: Populate devices at probe. Switched back to modification proposed in v3 - Patch 7 in v3 removed - Patch 7 (8 in v4): Add 'Reviewed-by: Andy Shevchenko' Add 'Reviewed-by: Ulf Hansson' - Patch 8 (9 in v4): Add 'Reviewed-by: Ulf Hansson' - Patches 9 to 15 (10 to 16 in v3) No changes - Patch 16 (17 in v4): Add 'Reviewed-by: Andi Shyti' - Patch 17 (18 in v4): Change an error code from -EINVAL to -ENODEV Add a blank line and fix a typo in commit log - Patch 18 (19 in v4): Simplify of_is_fwnode_add_links_supported(). Move IS_ENABLED(CONFIG_X86) check in of_is_fwnode_add_links_supported(). - Patches 19 to 21 (20 to 22 in v4) No changes - Patch 22 (23 in v4) Update due to simple-platform-bus removal - Patches 23 to 28 (24 to 29 in v4) No changes v3 -> v4 v3: https://lore.kernel.org/lkml/20250613134817.681832-1-herve.codina@bootlin.com/ - Patch 1: No change - Patch 2: Update and fix conflicts. Indeed, since v3 iteration get_dev_from_fwnode() has been moved to device.h and used by pmdomain/core.c. - Patch 3: remove '#define get_device_from_fwnode()' - Patch 4: Fix conflict (rebase v6.17-rc6) Add 'Reviewed-by: Rafael J. Wysocki' Add 'Reviewed-by: Saravana Kannan' - Patch 5 (new in v4): Introduce simple-platform-bus (binding) - Patch 6 (5 in v3): Rework patch and introduce simple-platform-bus - Patch 7: (new) Use simple-platform-bus in LAN966x - Patch 8 (6 in v3): - No change - Patch 9 and 10 (7 and 8 in v3): Add 'Reviewed-by: Andy Shevchenko' - Patch 11 and 12 (9 and 10 in v3): Add 'Reviewed-by: Dave Jiang' - Patch 13 (11 in v3): Add 'Reviewed-by: Andy Shevchenko' - Patch 12 in v3: Patch removed. Adding __private tag in fwnode.dev is going to be handled in a dedicated series. Indeed a test robot reported an issue and more patches are needed (I have missed fwnode.dev users in several part in the kernel). - Patch 14 and 15 (13 and 14 in v3): No change - Patch 16 (14 in v3): Add 'Reviewed-by: Andi Shyti' - Patch 17 and 18 (16 and 17 in v3): No change - Patch 19 (18 in v3): Filter out support for fw_devlink on x86 based on some device-tree properties. Rewrite commit changelog Remove 'Reviewed-by: Andy Shevchenko' (significant modification) - Patch 20 (19 in v3): Add 'Acked-by: Stephen Boyd' - Patch 21 (20 in v3): Fix conflict (rebase v6.18-rc1) - Patches 22 to 24 (21 to 23 in v3): No change - Patch 25 (24 in v3): Fix conflict (rebase v6.18-rc1) Add 'Acked-by: Bjorn Helgaas' - Patches 26 to 29 (25 to 28 in v3): No change v2 -> v3 v2: https://lore.kernel.org/all/20250507071315.394857-1-herve.codina@bootlin.com/ - Patch 1: Add 'Acked-by: Mark Brown' - Patch 2 and 3: No changes - Patch 4: Rewrite the WARN_ON() condition to avoid an additional 'if' - Patch 5: Fix typos in commit log Update a comment Remove the unneeded check before calling of_platform_depopulate() - Patches 6 to 11: No changes - Patch 12 (new in v3) Tag the fwnode dev member as private - Patch 13 (12 in v2) Fix a typo in the commit log - Patches 14 to 16 (13 to 15 in v2) No changes - Patch 17 (16 in v2) Check parent_physdev for NULL - Patch 18 (17 in v2) Capitalize "Link:" Add 'Reviewed-by: Andy Shevchenko' - Patch 19 (18 in v2) No changes - Patch 20 (19 in v2) Add 'Acked-by: Andi Shyti' - Patch 21 (20 in v2) No changes - Patch 22 (21 in v2) Add 'Reviewed-by: Andrew Lunn' - Patch 23 (22 in v2) Add 'Reviewed-by: Andrew Lunn' - Patch 24 (new in v3) Introduce PCI_DEVICE_ID_EFAR_LAN9662, the LAN966x PCI device ID - Patch 25 (23 in v2) Add 'Reviewed-by: Andrew Lunn' Use PCI_DEVICE_DATA() with PCI_DEVICE_ID_EFAR_LAN9662 instead of PCI_VDEVICE() - Patch 26 to 28 (24 to 26 in v2) No changes v1 -> v2 v1: https://lore.kernel.org/lkml/20250407145546.270683-1-herve.codina@bootlin.com/ - Patch 1 and 3 Remove 'From' tag from the commit log - Patch 2 Add 'Reviewed-by: Andy Shevchenko' Add 'Reviewed-by: Saravana Kannan' Add 'Reviewed-by: Luca Ceresoli' - Patch 4 and 5 No changes - Patch 6 (new in v2) Introduce fw_devlink_set_device() - Patch 7 (new in v2) Use existing device_set_node() helper. - Patch 8 to 11 (new in v2) Use fw_devlink_set_device() in existing code. - Patch 12 (6 in v1) Use fw_devlink_add_device() - Patch 13 (7 in v1) No changes - Patch 14 (8 in v1) Update commit log Use 'physdev' instead of 'supplier' Minor fixes in i2c_get_adapter_physdev() kdoc - Patch 15 and 16 (9 and 10 in v1) Use 'physdev' instead of 'supplier' (commit log, title and code) - Patch 17 (11 in v2) Enable fw_devlink on x86 only if PCI_DYNAMIC_OF_NODES is enabled. Rework commit log. - Patch 18, 19 and 20 (12, 13 and 14 in v1) No changes - Patch 21 (new in v2) Split dtso in dtsi/dtso - Patch 22 (new in v2) Rename lan966x_pci.dtso using the specific board name - Patch 23 (new in v2) Improve the driver introducing board specific data to ease support for other boards (avoid the direct dtbo reference in the function loading the dtbo). - Patch 24 (15 in v1) Refactor due to dtso split in dtsi/dtso - Patch 25 (new in v2) Sort exist driver list in Kconfig help - Patch 26 (16 in v1) Keep alphanumeric order for new drivers added in Kconfig help Herve Codina (26): driver core: Rename get_dev_from_fwnode() wrapper to get_device_from_fwnode() driver core: Avoid warning when removing a device while its supplier is unbinding bus: simple-pm-bus: Remove child devices when the bus is unbound bus: simple-pm-bus: Populate child nodes at probe driver core: fw_devlink: Introduce fw_devlink_set_device() drivers: core: Use fw_devlink_set_device() pinctrl: cs42l43: Use fw_devlink_set_device() cxl/test: Use device_set_node() cxl/test: Use fw_devlink_set_device() PCI: of: Use fw_devlink_set_device() PCI: of: Set fwnode device of newly created PCI device nodes PCI: of: Remove fwnode_dev_initialized() call for a PCI root bridge node i2c: core: Introduce i2c_get_adapter_physdev() i2c: mux: Set adapter physical device i2c: mux: Create missing devlink between mux and adapter physical device of: property: Allow fw_devlink device-tree on x86 clk: lan966x: Add MCHP_LAN966X_PCI dependency i2c: busses: at91: Add MCHP_LAN966X_PCI dependency misc: lan966x_pci: Fix dtso nodes ordering misc: lan966x_pci: Split dtso in dtsi/dtso misc: lan966x_pci: Rename lan966x_pci.dtso to lan966x_evb_lan9662_nic.dtso PCI: Add Microchip LAN9662 PCI Device ID misc: lan966x_pci: Introduce board specific data misc: lan966x_pci: Add dtsi/dtso nodes in order to support SFPs misc: lan966x_pci: Sort the drivers list in Kconfig help misc: lan966x_pci: Add drivers needed to support SFPs in Kconfig help Saravana Kannan (2): Revert "treewide: Fix probing of devices in DT overlays" of: dynamic: Fix overlayed devices not probing because of fw_devlink MAINTAINERS | 3 +- drivers/base/core.c | 108 ++++++++++--- drivers/bus/imx-weim.c | 6 - drivers/bus/simple-pm-bus.c | 24 +-- drivers/clk/Kconfig | 2 +- drivers/i2c/busses/Kconfig | 2 +- drivers/i2c/i2c-core-base.c | 16 ++ drivers/i2c/i2c-core-of.c | 5 - drivers/i2c/i2c-mux.c | 26 ++++ drivers/misc/Kconfig | 11 +- drivers/misc/Makefile | 2 +- drivers/misc/lan966x_evb_lan9662_nic.dtso | 167 ++++++++++++++++++++ drivers/misc/lan966x_pci.c | 30 +++- drivers/misc/lan966x_pci.dtsi | 172 +++++++++++++++++++++ drivers/misc/lan966x_pci.dtso | 177 ---------------------- drivers/of/dynamic.c | 1 - drivers/of/overlay.c | 15 ++ drivers/of/platform.c | 5 - drivers/of/property.c | 26 +++- drivers/pci/of.c | 10 +- drivers/pci/quirks.c | 2 +- drivers/pinctrl/cirrus/pinctrl-cs42l43.c | 2 +- drivers/pmdomain/core.c | 4 +- drivers/spi/spi.c | 5 - include/linux/device.h | 2 +- include/linux/fwnode.h | 7 + include/linux/i2c.h | 3 + include/linux/pci_ids.h | 1 + tools/testing/cxl/test/cxl.c | 4 +- 29 files changed, 584 insertions(+), 254 deletions(-) create mode 100644 drivers/misc/lan966x_evb_lan9662_nic.dtso create mode 100644 drivers/misc/lan966x_pci.dtsi delete mode 100644 drivers/misc/lan966x_pci.dtso -- 2.53.0
null
null
null
[PATCH v5 00/28] lan966x pci device: Add support for SFPs
The lan966x_pci.dtso file contains descriptions related to both the LAN966x PCI device chip and the LAN966x PCI device board where the chip is soldered. Split the file in order to have: - lan966x_pci.dtsi The description related to the PCI chip. - lan966x_pci.dtso The description of the PCI board. Signed-off-by: Herve Codina <herve.codina@bootlin.com> Reviewed-by: Andrew Lunn <andrew@lunn.ch> --- MAINTAINERS | 1 + drivers/misc/lan966x_pci.dtsi | 130 +++++++++++++++++++++++++ drivers/misc/lan966x_pci.dtso | 175 +++++++--------------------------- 3 files changed, 166 insertions(+), 140 deletions(-) create mode 100644 drivers/misc/lan966x_pci.dtsi diff --git a/MAINTAINERS b/MAINTAINERS index 55af015174a5..441fe74e7ef7 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -17305,6 +17305,7 @@ MICROCHIP LAN966X PCI DRIVER M: Herve Codina <herve.codina@bootlin.com> S: Maintained F: drivers/misc/lan966x_pci.c +F: drivers/misc/lan966x_pci.dtsi F: drivers/misc/lan966x_pci.dtso MICROCHIP LAN969X ETHERNET DRIVER diff --git a/drivers/misc/lan966x_pci.dtsi b/drivers/misc/lan966x_pci.dtsi new file mode 100644 index 000000000000..170298084fa5 --- /dev/null +++ b/drivers/misc/lan966x_pci.dtsi @@ -0,0 +1,130 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) 2025 Microchip UNG + */ + +#include <dt-bindings/interrupt-controller/irq.h> + +cpu_clk: clock-600000000 { + compatible = "fixed-clock"; + #clock-cells = <0>; + clock-frequency = <600000000>; /* CPU clock = 600MHz */ +}; + +ddr_clk: clock-30000000 { + compatible = "fixed-clock"; + #clock-cells = <0>; + clock-frequency = <30000000>; /* Fabric clock = 30MHz */ +}; + +sys_clk: clock-15625000 { + compatible = "fixed-clock"; + #clock-cells = <0>; + clock-frequency = <15625000>; /* System clock = 15.625MHz */ +}; + +pci-ep-bus@0 { + compatible = "simple-bus"; + #address-cells = <1>; + #size-cells = <1>; + + /* + * map @0xe2000000 (32MB) to BAR0 (CPU) + * map @0xe0000000 (16MB) to BAR1 (AMBA) + */ + ranges = <0xe2000000 0x00 0x00 0x00 0x2000000 + 0xe0000000 0x01 0x00 0x00 0x1000000>; + + switch: switch@e0000000 { + compatible = "microchip,lan966x-switch"; + reg = <0xe0000000 0x0100000>, + <0xe2000000 0x0800000>; + reg-names = "cpu", "gcb"; + interrupt-parent = <&oic>; + interrupts = <12 IRQ_TYPE_LEVEL_HIGH>, + <9 IRQ_TYPE_LEVEL_HIGH>; + interrupt-names = "xtr", "ana"; + resets = <&reset 0>; + reset-names = "switch"; + status = "disabled"; + + ethernet-ports { + #address-cells = <1>; + #size-cells = <0>; + + port0: port@0 { + reg = <0>; + status = "disabled"; + }; + + port1: port@1 { + reg = <1>; + status = "disabled"; + }; + }; + }; + + cpu_ctrl: syscon@e00c0000 { + compatible = "microchip,lan966x-cpu-syscon", "syscon"; + reg = <0xe00c0000 0xa8>; + }; + + oic: oic@e00c0120 { + compatible = "microchip,lan966x-oic"; + #interrupt-cells = <2>; + interrupt-controller; + interrupts = <0>; /* PCI INTx assigned interrupt */ + reg = <0xe00c0120 0x190>; + }; + + reset: reset@e200400c { + compatible = "microchip,lan966x-switch-reset"; + reg = <0xe200400c 0x4>, <0xe00c0000 0xa8>; + reg-names = "gcb","cpu"; + #reset-cells = <1>; + cpu-syscon = <&cpu_ctrl>; + }; + + gpio: pinctrl@e2004064 { + compatible = "microchip,lan966x-pinctrl"; + reg = <0xe2004064 0xb4>, + <0xe2010024 0x138>; + resets = <&reset 0>; + reset-names = "switch"; + gpio-controller; + #gpio-cells = <2>; + gpio-ranges = <&gpio 0 0 78>; + interrupt-parent = <&oic>; + interrupt-controller; + interrupts = <17 IRQ_TYPE_LEVEL_HIGH>; + #interrupt-cells = <2>; + }; + + mdio1: mdio@e200413c { + #address-cells = <1>; + #size-cells = <0>; + compatible = "microchip,lan966x-miim"; + reg = <0xe200413c 0x24>, + <0xe2010020 0x4>; + resets = <&reset 0>; + reset-names = "switch"; + status = "disabled"; + + lan966x_phy0: ethernet-lan966x_phy@1 { + reg = <1>; + status = "disabled"; + }; + + lan966x_phy1: ethernet-lan966x_phy@2 { + reg = <2>; + status = "disabled"; + }; + }; + + serdes: serdes@e202c000 { + compatible = "microchip,lan966x-serdes"; + reg = <0xe202c000 0x9c>, + <0xe2004010 0x4>; + #phy-cells = <2>; + }; +}; diff --git a/drivers/misc/lan966x_pci.dtso b/drivers/misc/lan966x_pci.dtso index 94a967b384f3..3ad50abee72d 100644 --- a/drivers/misc/lan966x_pci.dtso +++ b/drivers/misc/lan966x_pci.dtso @@ -3,10 +3,7 @@ * Copyright (C) 2022 Microchip UNG */ -#include <dt-bindings/clock/microchip,lan966x.h> #include <dt-bindings/gpio/gpio.h> -#include <dt-bindings/interrupt-controller/irq.h> -#include <dt-bindings/mfd/atmel-flexcom.h> #include <dt-bindings/phy/phy-lan966x-serdes.h> /dts-v1/; @@ -29,148 +26,46 @@ __overlay__ { #address-cells = <3>; #size-cells = <2>; - cpu_clk: clock-600000000 { - compatible = "fixed-clock"; - #clock-cells = <0>; - clock-frequency = <600000000>; /* CPU clock = 600MHz */ - }; - - ddr_clk: clock-30000000 { - compatible = "fixed-clock"; - #clock-cells = <0>; - clock-frequency = <30000000>; /* Fabric clock = 30MHz */ - }; - - sys_clk: clock-15625000 { - compatible = "fixed-clock"; - #clock-cells = <0>; - clock-frequency = <15625000>; /* System clock = 15.625MHz */ - }; - - pci-ep-bus@0 { - compatible = "simple-bus"; - #address-cells = <1>; - #size-cells = <1>; - - /* - * map @0xe2000000 (32MB) to BAR0 (CPU) - * map @0xe0000000 (16MB) to BAR1 (AMBA) - */ - ranges = <0xe2000000 0x00 0x00 0x00 0x2000000 - 0xe0000000 0x01 0x00 0x00 0x1000000>; - - switch: switch@e0000000 { - compatible = "microchip,lan966x-switch"; - reg = <0xe0000000 0x0100000>, - <0xe2000000 0x0800000>; - reg-names = "cpu", "gcb"; - - interrupt-parent = <&oic>; - interrupts = <12 IRQ_TYPE_LEVEL_HIGH>, - <9 IRQ_TYPE_LEVEL_HIGH>; - interrupt-names = "xtr", "ana"; - - resets = <&reset 0>; - reset-names = "switch"; - - pinctrl-names = "default"; - pinctrl-0 = <&tod_pins>; - - ethernet-ports { - #address-cells = <1>; - #size-cells = <0>; - - port0: port@0 { - phy-handle = <&lan966x_phy0>; - - reg = <0>; - phy-mode = "gmii"; - phys = <&serdes 0 CU(0)>; - }; - - port1: port@1 { - phy-handle = <&lan966x_phy1>; - - reg = <1>; - phy-mode = "gmii"; - phys = <&serdes 1 CU(1)>; - }; - }; - }; - - cpu_ctrl: syscon@e00c0000 { - compatible = "microchip,lan966x-cpu-syscon", "syscon"; - reg = <0xe00c0000 0xa8>; - }; - - oic: oic@e00c0120 { - compatible = "microchip,lan966x-oic"; - #interrupt-cells = <2>; - interrupt-controller; - interrupts = <0>; /* PCI INTx assigned interrupt */ - reg = <0xe00c0120 0x190>; - }; - - reset: reset@e200400c { - compatible = "microchip,lan966x-switch-reset"; - reg = <0xe200400c 0x4>, <0xe00c0000 0xa8>; - reg-names = "gcb","cpu"; - #reset-cells = <1>; - cpu-syscon = <&cpu_ctrl>; - }; - - gpio: pinctrl@e2004064 { - compatible = "microchip,lan966x-pinctrl"; - reg = <0xe2004064 0xb4>, - <0xe2010024 0x138>; - resets = <&reset 0>; - reset-names = "switch"; - gpio-controller; - #gpio-cells = <2>; - gpio-ranges = <&gpio 0 0 78>; - interrupt-parent = <&oic>; - interrupt-controller; - interrupts = <17 IRQ_TYPE_LEVEL_HIGH>; - #interrupt-cells = <2>; + #include "lan966x_pci.dtsi" + }; + }; +}; - tod_pins: tod_pins { - pins = "GPIO_36"; - function = "ptpsync_1"; - }; +&gpio { + tod_pins: tod_pins { + pins = "GPIO_36"; + function = "ptpsync_1"; + }; +}; - fc0_a_pins: fcb4-i2c-pins { - /* RXD, TXD */ - pins = "GPIO_9", "GPIO_10"; - function = "fc0_a"; - }; - }; +&lan966x_phy0 { + status = "okay"; +}; - mdio1: mdio@e200413c { - #address-cells = <1>; - #size-cells = <0>; - compatible = "microchip,lan966x-miim"; - reg = <0xe200413c 0x24>, - <0xe2010020 0x4>; +&lan966x_phy1 { + status = "okay"; +}; - resets = <&reset 0>; - reset-names = "switch"; +&mdio1 { + status = "okay"; +}; - lan966x_phy0: ethernet-lan966x_phy@1 { - reg = <1>; - }; +&port0 { + phy-handle = <&lan966x_phy0>; + phy-mode = "gmii"; + phys = <&serdes 0 CU(0)>; + status = "okay"; +}; - lan966x_phy1: ethernet-lan966x_phy@2 { - reg = <2>; - }; - }; +&port1 { + phy-handle = <&lan966x_phy1>; + phy-mode = "gmii"; + phys = <&serdes 1 CU(1)>; + status = "okay"; +}; - serdes: serdes@e202c000 { - compatible = "microchip,lan966x-serdes"; - reg = <0xe202c000 0x9c>, - <0xe2004010 0x4>; - #phy-cells = <2>; - }; - }; - }; - }; +&switch { + pinctrl-names = "default"; + pinctrl-0 = <&tod_pins>; + status = "okay"; }; -- 2.53.0
{ "author": "Herve Codina <herve.codina@bootlin.com>", "date": "Fri, 27 Feb 2026 14:54:19 +0100", "is_openbsd": false, "thread_id": "20260227135428.783983-1-herve.codina@bootlin.com.mbox.gz" }
lkml_critique
lkml
Hi, This series add support for SFPs ports available on the LAN966x PCI device. In order to have the SFPs supported, additional devices are needed such as clock controller and I2C. As a reminder, the LAN966x PCI device driver use a device-tree overlay to describe devices available on the PCI board. Adding support for SFPs ports consists in adding more devices in the already existing device-tree overlay. With those devices added, the device-tree overlay is more complex and some consumer/supplier relationship are needed in order to remove devices in correct order when the LAN966x PCI driver is removed. Those links are typically provided by fw_devlink and we faced some issues with fw_devlink and overlays. This series gives the big picture related to the SFPs support from fixing issues to adding new devices. Of course, it can be split if needed. The first part of the series (patch 1, 2 and 3) fixes fw_devlink when it is used with overlay. Patches 1 and 3 were previously sent by Saravana [0]. I rebased them on top of v7.0-rc1 and added patch 2 in order to take into account feedback received on the series sent by Saravana. Also I added a call to driver_deferred_probe_trigger() in Saravana's patch (patch 3) to ensure that probes are retried after the modification performed on the dangling consumers. This allows to fix issues reported by Matti and Geert [2] with the previous iteration patches. Those modification were not sufficient in our case and so, on top of that, patches 4 to 6 fix some more issues related to fw_devlink. Patches 7 to 12 introduce and use fw_devlink_set_device() in already existing code. Patches 13 and 14 are related also to fw_devlink but specific to PCI and the device-tree nodes created during enumeration. Patches 15, 16 and 17 are related fw_devlink too but specific to I2C muxes. Patches purpose is to correctly set a link between an adapter supplier and its consumer. Indeed, an i2c mux adapter's parent is not the i2c mux supplier but the adapter the i2c mux is connected to. Adding a new link between the adapter supplier involved when i2c muxes are used avoid a freeze observed during device removal. Patch 18 adds support for fw_delink on x86. fw_devlink is needed to have the consumer/supplier relationship between devices in order to ensure a correct device removal order. Adding fw_devlink support for x86 has been tried in the past but was reverted [1] because it broke some systems. Instead of enabling fw_devlink on *all* x86 system, enable it on *all* x86 except on those where it leads to issue. Patches 19 and 20 allow to build clock and i2c controller used by the LAN966x PCI device when the LAN966x PCI device is enabled. Patches 21 to 25 are specific to the LAN966x. They touch the current dtso, split it in dtsi/dtso files, rename the dtso and improve the driver to allow easier support for other boards. The next patch (patch 26) update the LAN966x device-tree overlay itself to have the SPF ports and devices they depends on described. The last two patches (patches 27 and 29) sort the existing drivers in the needed driver list available in the Kconfig help and add new drivers in this list keep the list up to date with the devices described in the device-tree overlay. We believe some items from the above list can be merged separately, with no build dependencies. We expect: - Patches 1 to 6 to be taken by driver core maintainers - Patches 7 to 12 to be taken by driver core maintainers - Patches 13 and 14 to be taken by driver core or PCI maintainers (depend on patch 7) - Patches 15 to 17 to be taken by I2C maintainers - Patch 18 to be taken by driver core or OF maintainers - Patch 19 to be taken by clock maintainers - Patch 20 to be taken by I2C maintainers - Patches 21 to 28 to be taken by misc maintainers Once again, this series gives the big picture and can be split if needed. Let me know. Compare to previous iteration, this v5 series mainly: - Handle Matti and Geert use cases [2] - Remove simple-platform-bus driver introduced in v4 and switch the simple-bus modification back to what was proposed in v3. In the v4 iteration, conclusion was to use v3 changes [3]. [0] https://lore.kernel.org/lkml/20240411235623.1260061-1-saravanak@google.com/ [1] https://lore.kernel.org/lkml/3c1f2473-92ad-bfc4-258e-a5a08ad73dd0@web.de/ [2] https://lore.kernel.org/all/072dde7c-a53c-4525-83ac-57ea38edc0b5@gmail.com/ [3] https://lore.kernel.org/lkml/20251114083056.31553866@bootlin.com/ Best regards, Hervé Changes: v4 -> v5 v4: https://lore.kernel.org/lkml/20251015071420.1173068-1-herve.codina@bootlin.com/ - Patch 2: Add 'Acked-by: Ulf Hansson' - Patch 3: Add a call to driver_deferred_probe_trigger() - Patch 5: (new patch) Depopulate devices at remove - Patch 6: Populate devices at probe. Switched back to modification proposed in v3 - Patch 7 in v3 removed - Patch 7 (8 in v4): Add 'Reviewed-by: Andy Shevchenko' Add 'Reviewed-by: Ulf Hansson' - Patch 8 (9 in v4): Add 'Reviewed-by: Ulf Hansson' - Patches 9 to 15 (10 to 16 in v3) No changes - Patch 16 (17 in v4): Add 'Reviewed-by: Andi Shyti' - Patch 17 (18 in v4): Change an error code from -EINVAL to -ENODEV Add a blank line and fix a typo in commit log - Patch 18 (19 in v4): Simplify of_is_fwnode_add_links_supported(). Move IS_ENABLED(CONFIG_X86) check in of_is_fwnode_add_links_supported(). - Patches 19 to 21 (20 to 22 in v4) No changes - Patch 22 (23 in v4) Update due to simple-platform-bus removal - Patches 23 to 28 (24 to 29 in v4) No changes v3 -> v4 v3: https://lore.kernel.org/lkml/20250613134817.681832-1-herve.codina@bootlin.com/ - Patch 1: No change - Patch 2: Update and fix conflicts. Indeed, since v3 iteration get_dev_from_fwnode() has been moved to device.h and used by pmdomain/core.c. - Patch 3: remove '#define get_device_from_fwnode()' - Patch 4: Fix conflict (rebase v6.17-rc6) Add 'Reviewed-by: Rafael J. Wysocki' Add 'Reviewed-by: Saravana Kannan' - Patch 5 (new in v4): Introduce simple-platform-bus (binding) - Patch 6 (5 in v3): Rework patch and introduce simple-platform-bus - Patch 7: (new) Use simple-platform-bus in LAN966x - Patch 8 (6 in v3): - No change - Patch 9 and 10 (7 and 8 in v3): Add 'Reviewed-by: Andy Shevchenko' - Patch 11 and 12 (9 and 10 in v3): Add 'Reviewed-by: Dave Jiang' - Patch 13 (11 in v3): Add 'Reviewed-by: Andy Shevchenko' - Patch 12 in v3: Patch removed. Adding __private tag in fwnode.dev is going to be handled in a dedicated series. Indeed a test robot reported an issue and more patches are needed (I have missed fwnode.dev users in several part in the kernel). - Patch 14 and 15 (13 and 14 in v3): No change - Patch 16 (14 in v3): Add 'Reviewed-by: Andi Shyti' - Patch 17 and 18 (16 and 17 in v3): No change - Patch 19 (18 in v3): Filter out support for fw_devlink on x86 based on some device-tree properties. Rewrite commit changelog Remove 'Reviewed-by: Andy Shevchenko' (significant modification) - Patch 20 (19 in v3): Add 'Acked-by: Stephen Boyd' - Patch 21 (20 in v3): Fix conflict (rebase v6.18-rc1) - Patches 22 to 24 (21 to 23 in v3): No change - Patch 25 (24 in v3): Fix conflict (rebase v6.18-rc1) Add 'Acked-by: Bjorn Helgaas' - Patches 26 to 29 (25 to 28 in v3): No change v2 -> v3 v2: https://lore.kernel.org/all/20250507071315.394857-1-herve.codina@bootlin.com/ - Patch 1: Add 'Acked-by: Mark Brown' - Patch 2 and 3: No changes - Patch 4: Rewrite the WARN_ON() condition to avoid an additional 'if' - Patch 5: Fix typos in commit log Update a comment Remove the unneeded check before calling of_platform_depopulate() - Patches 6 to 11: No changes - Patch 12 (new in v3) Tag the fwnode dev member as private - Patch 13 (12 in v2) Fix a typo in the commit log - Patches 14 to 16 (13 to 15 in v2) No changes - Patch 17 (16 in v2) Check parent_physdev for NULL - Patch 18 (17 in v2) Capitalize "Link:" Add 'Reviewed-by: Andy Shevchenko' - Patch 19 (18 in v2) No changes - Patch 20 (19 in v2) Add 'Acked-by: Andi Shyti' - Patch 21 (20 in v2) No changes - Patch 22 (21 in v2) Add 'Reviewed-by: Andrew Lunn' - Patch 23 (22 in v2) Add 'Reviewed-by: Andrew Lunn' - Patch 24 (new in v3) Introduce PCI_DEVICE_ID_EFAR_LAN9662, the LAN966x PCI device ID - Patch 25 (23 in v2) Add 'Reviewed-by: Andrew Lunn' Use PCI_DEVICE_DATA() with PCI_DEVICE_ID_EFAR_LAN9662 instead of PCI_VDEVICE() - Patch 26 to 28 (24 to 26 in v2) No changes v1 -> v2 v1: https://lore.kernel.org/lkml/20250407145546.270683-1-herve.codina@bootlin.com/ - Patch 1 and 3 Remove 'From' tag from the commit log - Patch 2 Add 'Reviewed-by: Andy Shevchenko' Add 'Reviewed-by: Saravana Kannan' Add 'Reviewed-by: Luca Ceresoli' - Patch 4 and 5 No changes - Patch 6 (new in v2) Introduce fw_devlink_set_device() - Patch 7 (new in v2) Use existing device_set_node() helper. - Patch 8 to 11 (new in v2) Use fw_devlink_set_device() in existing code. - Patch 12 (6 in v1) Use fw_devlink_add_device() - Patch 13 (7 in v1) No changes - Patch 14 (8 in v1) Update commit log Use 'physdev' instead of 'supplier' Minor fixes in i2c_get_adapter_physdev() kdoc - Patch 15 and 16 (9 and 10 in v1) Use 'physdev' instead of 'supplier' (commit log, title and code) - Patch 17 (11 in v2) Enable fw_devlink on x86 only if PCI_DYNAMIC_OF_NODES is enabled. Rework commit log. - Patch 18, 19 and 20 (12, 13 and 14 in v1) No changes - Patch 21 (new in v2) Split dtso in dtsi/dtso - Patch 22 (new in v2) Rename lan966x_pci.dtso using the specific board name - Patch 23 (new in v2) Improve the driver introducing board specific data to ease support for other boards (avoid the direct dtbo reference in the function loading the dtbo). - Patch 24 (15 in v1) Refactor due to dtso split in dtsi/dtso - Patch 25 (new in v2) Sort exist driver list in Kconfig help - Patch 26 (16 in v1) Keep alphanumeric order for new drivers added in Kconfig help Herve Codina (26): driver core: Rename get_dev_from_fwnode() wrapper to get_device_from_fwnode() driver core: Avoid warning when removing a device while its supplier is unbinding bus: simple-pm-bus: Remove child devices when the bus is unbound bus: simple-pm-bus: Populate child nodes at probe driver core: fw_devlink: Introduce fw_devlink_set_device() drivers: core: Use fw_devlink_set_device() pinctrl: cs42l43: Use fw_devlink_set_device() cxl/test: Use device_set_node() cxl/test: Use fw_devlink_set_device() PCI: of: Use fw_devlink_set_device() PCI: of: Set fwnode device of newly created PCI device nodes PCI: of: Remove fwnode_dev_initialized() call for a PCI root bridge node i2c: core: Introduce i2c_get_adapter_physdev() i2c: mux: Set adapter physical device i2c: mux: Create missing devlink between mux and adapter physical device of: property: Allow fw_devlink device-tree on x86 clk: lan966x: Add MCHP_LAN966X_PCI dependency i2c: busses: at91: Add MCHP_LAN966X_PCI dependency misc: lan966x_pci: Fix dtso nodes ordering misc: lan966x_pci: Split dtso in dtsi/dtso misc: lan966x_pci: Rename lan966x_pci.dtso to lan966x_evb_lan9662_nic.dtso PCI: Add Microchip LAN9662 PCI Device ID misc: lan966x_pci: Introduce board specific data misc: lan966x_pci: Add dtsi/dtso nodes in order to support SFPs misc: lan966x_pci: Sort the drivers list in Kconfig help misc: lan966x_pci: Add drivers needed to support SFPs in Kconfig help Saravana Kannan (2): Revert "treewide: Fix probing of devices in DT overlays" of: dynamic: Fix overlayed devices not probing because of fw_devlink MAINTAINERS | 3 +- drivers/base/core.c | 108 ++++++++++--- drivers/bus/imx-weim.c | 6 - drivers/bus/simple-pm-bus.c | 24 +-- drivers/clk/Kconfig | 2 +- drivers/i2c/busses/Kconfig | 2 +- drivers/i2c/i2c-core-base.c | 16 ++ drivers/i2c/i2c-core-of.c | 5 - drivers/i2c/i2c-mux.c | 26 ++++ drivers/misc/Kconfig | 11 +- drivers/misc/Makefile | 2 +- drivers/misc/lan966x_evb_lan9662_nic.dtso | 167 ++++++++++++++++++++ drivers/misc/lan966x_pci.c | 30 +++- drivers/misc/lan966x_pci.dtsi | 172 +++++++++++++++++++++ drivers/misc/lan966x_pci.dtso | 177 ---------------------- drivers/of/dynamic.c | 1 - drivers/of/overlay.c | 15 ++ drivers/of/platform.c | 5 - drivers/of/property.c | 26 +++- drivers/pci/of.c | 10 +- drivers/pci/quirks.c | 2 +- drivers/pinctrl/cirrus/pinctrl-cs42l43.c | 2 +- drivers/pmdomain/core.c | 4 +- drivers/spi/spi.c | 5 - include/linux/device.h | 2 +- include/linux/fwnode.h | 7 + include/linux/i2c.h | 3 + include/linux/pci_ids.h | 1 + tools/testing/cxl/test/cxl.c | 4 +- 29 files changed, 584 insertions(+), 254 deletions(-) create mode 100644 drivers/misc/lan966x_evb_lan9662_nic.dtso create mode 100644 drivers/misc/lan966x_pci.dtsi delete mode 100644 drivers/misc/lan966x_pci.dtso -- 2.53.0
null
null
null
[PATCH v5 00/28] lan966x pci device: Add support for SFPs
The lan966x_pci.dtso describes the Microchip EVB-LAN9662-NIC board [0] This PCI board embeds a LAN9962 PCI device chip, part of the LAN966x family. Rename the lan966x_pci.dtso accordingly. Link: https://www.microchip.com/en-us/development-tool/EV53U25A [0] Signed-off-by: Herve Codina <herve.codina@bootlin.com> Reviewed-by: Andrew Lunn <andrew@lunn.ch> --- MAINTAINERS | 2 +- drivers/misc/Makefile | 2 +- .../{lan966x_pci.dtso => lan966x_evb_lan9662_nic.dtso} | 0 drivers/misc/lan966x_pci.c | 8 ++++---- 4 files changed, 6 insertions(+), 6 deletions(-) rename drivers/misc/{lan966x_pci.dtso => lan966x_evb_lan9662_nic.dtso} (100%) diff --git a/MAINTAINERS b/MAINTAINERS index 441fe74e7ef7..2c5537891071 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -17304,9 +17304,9 @@ F: drivers/irqchip/irq-lan966x-oic.c MICROCHIP LAN966X PCI DRIVER M: Herve Codina <herve.codina@bootlin.com> S: Maintained +F: drivers/misc/lan966x_evb_lan9662_nic.dtso F: drivers/misc/lan966x_pci.c F: drivers/misc/lan966x_pci.dtsi -F: drivers/misc/lan966x_pci.dtso MICROCHIP LAN969X ETHERNET DRIVER M: Daniel Machon <daniel.machon@microchip.com> diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile index b32a2597d246..3b3a61f45ee9 100644 --- a/drivers/misc/Makefile +++ b/drivers/misc/Makefile @@ -70,7 +70,7 @@ obj-$(CONFIG_TPS6594_PFSM) += tps6594-pfsm.o obj-$(CONFIG_NSM) += nsm.o obj-$(CONFIG_MARVELL_CN10K_DPI) += mrvl_cn10k_dpi.o lan966x-pci-objs := lan966x_pci.o -lan966x-pci-objs += lan966x_pci.dtbo.o +lan966x-pci-objs += lan966x_evb_lan9662_nic.dtbo.o obj-$(CONFIG_MCHP_LAN966X_PCI) += lan966x-pci.o obj-y += keba/ obj-y += amd-sbi/ diff --git a/drivers/misc/lan966x_pci.dtso b/drivers/misc/lan966x_evb_lan9662_nic.dtso similarity index 100% rename from drivers/misc/lan966x_pci.dtso rename to drivers/misc/lan966x_evb_lan9662_nic.dtso diff --git a/drivers/misc/lan966x_pci.c b/drivers/misc/lan966x_pci.c index 0bb90c0943bf..bbd87c89663d 100644 --- a/drivers/misc/lan966x_pci.c +++ b/drivers/misc/lan966x_pci.c @@ -19,8 +19,8 @@ #include <linux/slab.h> /* Embedded dtbo symbols created by cmd_wrap_S_dtb in scripts/Makefile.lib */ -extern char __dtbo_lan966x_pci_begin[]; -extern char __dtbo_lan966x_pci_end[]; +extern char __dtbo_lan966x_evb_lan9662_nic_begin[]; +extern char __dtbo_lan966x_evb_lan9662_nic_end[]; struct pci_dev_intr_ctrl { struct pci_dev *pci_dev; @@ -125,8 +125,8 @@ struct lan966x_pci { static int lan966x_pci_load_overlay(struct lan966x_pci *data) { - u32 dtbo_size = __dtbo_lan966x_pci_end - __dtbo_lan966x_pci_begin; - void *dtbo_start = __dtbo_lan966x_pci_begin; + u32 dtbo_size = __dtbo_lan966x_evb_lan9662_nic_end - __dtbo_lan966x_evb_lan9662_nic_begin; + void *dtbo_start = __dtbo_lan966x_evb_lan9662_nic_begin; return of_overlay_fdt_apply(dtbo_start, dtbo_size, &data->ovcs_id, dev_of_node(data->dev)); } -- 2.53.0
{ "author": "Herve Codina <herve.codina@bootlin.com>", "date": "Fri, 27 Feb 2026 14:54:20 +0100", "is_openbsd": false, "thread_id": "20260227135428.783983-1-herve.codina@bootlin.com.mbox.gz" }
lkml_critique
lkml
Hi, This series add support for SFPs ports available on the LAN966x PCI device. In order to have the SFPs supported, additional devices are needed such as clock controller and I2C. As a reminder, the LAN966x PCI device driver use a device-tree overlay to describe devices available on the PCI board. Adding support for SFPs ports consists in adding more devices in the already existing device-tree overlay. With those devices added, the device-tree overlay is more complex and some consumer/supplier relationship are needed in order to remove devices in correct order when the LAN966x PCI driver is removed. Those links are typically provided by fw_devlink and we faced some issues with fw_devlink and overlays. This series gives the big picture related to the SFPs support from fixing issues to adding new devices. Of course, it can be split if needed. The first part of the series (patch 1, 2 and 3) fixes fw_devlink when it is used with overlay. Patches 1 and 3 were previously sent by Saravana [0]. I rebased them on top of v7.0-rc1 and added patch 2 in order to take into account feedback received on the series sent by Saravana. Also I added a call to driver_deferred_probe_trigger() in Saravana's patch (patch 3) to ensure that probes are retried after the modification performed on the dangling consumers. This allows to fix issues reported by Matti and Geert [2] with the previous iteration patches. Those modification were not sufficient in our case and so, on top of that, patches 4 to 6 fix some more issues related to fw_devlink. Patches 7 to 12 introduce and use fw_devlink_set_device() in already existing code. Patches 13 and 14 are related also to fw_devlink but specific to PCI and the device-tree nodes created during enumeration. Patches 15, 16 and 17 are related fw_devlink too but specific to I2C muxes. Patches purpose is to correctly set a link between an adapter supplier and its consumer. Indeed, an i2c mux adapter's parent is not the i2c mux supplier but the adapter the i2c mux is connected to. Adding a new link between the adapter supplier involved when i2c muxes are used avoid a freeze observed during device removal. Patch 18 adds support for fw_delink on x86. fw_devlink is needed to have the consumer/supplier relationship between devices in order to ensure a correct device removal order. Adding fw_devlink support for x86 has been tried in the past but was reverted [1] because it broke some systems. Instead of enabling fw_devlink on *all* x86 system, enable it on *all* x86 except on those where it leads to issue. Patches 19 and 20 allow to build clock and i2c controller used by the LAN966x PCI device when the LAN966x PCI device is enabled. Patches 21 to 25 are specific to the LAN966x. They touch the current dtso, split it in dtsi/dtso files, rename the dtso and improve the driver to allow easier support for other boards. The next patch (patch 26) update the LAN966x device-tree overlay itself to have the SPF ports and devices they depends on described. The last two patches (patches 27 and 29) sort the existing drivers in the needed driver list available in the Kconfig help and add new drivers in this list keep the list up to date with the devices described in the device-tree overlay. We believe some items from the above list can be merged separately, with no build dependencies. We expect: - Patches 1 to 6 to be taken by driver core maintainers - Patches 7 to 12 to be taken by driver core maintainers - Patches 13 and 14 to be taken by driver core or PCI maintainers (depend on patch 7) - Patches 15 to 17 to be taken by I2C maintainers - Patch 18 to be taken by driver core or OF maintainers - Patch 19 to be taken by clock maintainers - Patch 20 to be taken by I2C maintainers - Patches 21 to 28 to be taken by misc maintainers Once again, this series gives the big picture and can be split if needed. Let me know. Compare to previous iteration, this v5 series mainly: - Handle Matti and Geert use cases [2] - Remove simple-platform-bus driver introduced in v4 and switch the simple-bus modification back to what was proposed in v3. In the v4 iteration, conclusion was to use v3 changes [3]. [0] https://lore.kernel.org/lkml/20240411235623.1260061-1-saravanak@google.com/ [1] https://lore.kernel.org/lkml/3c1f2473-92ad-bfc4-258e-a5a08ad73dd0@web.de/ [2] https://lore.kernel.org/all/072dde7c-a53c-4525-83ac-57ea38edc0b5@gmail.com/ [3] https://lore.kernel.org/lkml/20251114083056.31553866@bootlin.com/ Best regards, Hervé Changes: v4 -> v5 v4: https://lore.kernel.org/lkml/20251015071420.1173068-1-herve.codina@bootlin.com/ - Patch 2: Add 'Acked-by: Ulf Hansson' - Patch 3: Add a call to driver_deferred_probe_trigger() - Patch 5: (new patch) Depopulate devices at remove - Patch 6: Populate devices at probe. Switched back to modification proposed in v3 - Patch 7 in v3 removed - Patch 7 (8 in v4): Add 'Reviewed-by: Andy Shevchenko' Add 'Reviewed-by: Ulf Hansson' - Patch 8 (9 in v4): Add 'Reviewed-by: Ulf Hansson' - Patches 9 to 15 (10 to 16 in v3) No changes - Patch 16 (17 in v4): Add 'Reviewed-by: Andi Shyti' - Patch 17 (18 in v4): Change an error code from -EINVAL to -ENODEV Add a blank line and fix a typo in commit log - Patch 18 (19 in v4): Simplify of_is_fwnode_add_links_supported(). Move IS_ENABLED(CONFIG_X86) check in of_is_fwnode_add_links_supported(). - Patches 19 to 21 (20 to 22 in v4) No changes - Patch 22 (23 in v4) Update due to simple-platform-bus removal - Patches 23 to 28 (24 to 29 in v4) No changes v3 -> v4 v3: https://lore.kernel.org/lkml/20250613134817.681832-1-herve.codina@bootlin.com/ - Patch 1: No change - Patch 2: Update and fix conflicts. Indeed, since v3 iteration get_dev_from_fwnode() has been moved to device.h and used by pmdomain/core.c. - Patch 3: remove '#define get_device_from_fwnode()' - Patch 4: Fix conflict (rebase v6.17-rc6) Add 'Reviewed-by: Rafael J. Wysocki' Add 'Reviewed-by: Saravana Kannan' - Patch 5 (new in v4): Introduce simple-platform-bus (binding) - Patch 6 (5 in v3): Rework patch and introduce simple-platform-bus - Patch 7: (new) Use simple-platform-bus in LAN966x - Patch 8 (6 in v3): - No change - Patch 9 and 10 (7 and 8 in v3): Add 'Reviewed-by: Andy Shevchenko' - Patch 11 and 12 (9 and 10 in v3): Add 'Reviewed-by: Dave Jiang' - Patch 13 (11 in v3): Add 'Reviewed-by: Andy Shevchenko' - Patch 12 in v3: Patch removed. Adding __private tag in fwnode.dev is going to be handled in a dedicated series. Indeed a test robot reported an issue and more patches are needed (I have missed fwnode.dev users in several part in the kernel). - Patch 14 and 15 (13 and 14 in v3): No change - Patch 16 (14 in v3): Add 'Reviewed-by: Andi Shyti' - Patch 17 and 18 (16 and 17 in v3): No change - Patch 19 (18 in v3): Filter out support for fw_devlink on x86 based on some device-tree properties. Rewrite commit changelog Remove 'Reviewed-by: Andy Shevchenko' (significant modification) - Patch 20 (19 in v3): Add 'Acked-by: Stephen Boyd' - Patch 21 (20 in v3): Fix conflict (rebase v6.18-rc1) - Patches 22 to 24 (21 to 23 in v3): No change - Patch 25 (24 in v3): Fix conflict (rebase v6.18-rc1) Add 'Acked-by: Bjorn Helgaas' - Patches 26 to 29 (25 to 28 in v3): No change v2 -> v3 v2: https://lore.kernel.org/all/20250507071315.394857-1-herve.codina@bootlin.com/ - Patch 1: Add 'Acked-by: Mark Brown' - Patch 2 and 3: No changes - Patch 4: Rewrite the WARN_ON() condition to avoid an additional 'if' - Patch 5: Fix typos in commit log Update a comment Remove the unneeded check before calling of_platform_depopulate() - Patches 6 to 11: No changes - Patch 12 (new in v3) Tag the fwnode dev member as private - Patch 13 (12 in v2) Fix a typo in the commit log - Patches 14 to 16 (13 to 15 in v2) No changes - Patch 17 (16 in v2) Check parent_physdev for NULL - Patch 18 (17 in v2) Capitalize "Link:" Add 'Reviewed-by: Andy Shevchenko' - Patch 19 (18 in v2) No changes - Patch 20 (19 in v2) Add 'Acked-by: Andi Shyti' - Patch 21 (20 in v2) No changes - Patch 22 (21 in v2) Add 'Reviewed-by: Andrew Lunn' - Patch 23 (22 in v2) Add 'Reviewed-by: Andrew Lunn' - Patch 24 (new in v3) Introduce PCI_DEVICE_ID_EFAR_LAN9662, the LAN966x PCI device ID - Patch 25 (23 in v2) Add 'Reviewed-by: Andrew Lunn' Use PCI_DEVICE_DATA() with PCI_DEVICE_ID_EFAR_LAN9662 instead of PCI_VDEVICE() - Patch 26 to 28 (24 to 26 in v2) No changes v1 -> v2 v1: https://lore.kernel.org/lkml/20250407145546.270683-1-herve.codina@bootlin.com/ - Patch 1 and 3 Remove 'From' tag from the commit log - Patch 2 Add 'Reviewed-by: Andy Shevchenko' Add 'Reviewed-by: Saravana Kannan' Add 'Reviewed-by: Luca Ceresoli' - Patch 4 and 5 No changes - Patch 6 (new in v2) Introduce fw_devlink_set_device() - Patch 7 (new in v2) Use existing device_set_node() helper. - Patch 8 to 11 (new in v2) Use fw_devlink_set_device() in existing code. - Patch 12 (6 in v1) Use fw_devlink_add_device() - Patch 13 (7 in v1) No changes - Patch 14 (8 in v1) Update commit log Use 'physdev' instead of 'supplier' Minor fixes in i2c_get_adapter_physdev() kdoc - Patch 15 and 16 (9 and 10 in v1) Use 'physdev' instead of 'supplier' (commit log, title and code) - Patch 17 (11 in v2) Enable fw_devlink on x86 only if PCI_DYNAMIC_OF_NODES is enabled. Rework commit log. - Patch 18, 19 and 20 (12, 13 and 14 in v1) No changes - Patch 21 (new in v2) Split dtso in dtsi/dtso - Patch 22 (new in v2) Rename lan966x_pci.dtso using the specific board name - Patch 23 (new in v2) Improve the driver introducing board specific data to ease support for other boards (avoid the direct dtbo reference in the function loading the dtbo). - Patch 24 (15 in v1) Refactor due to dtso split in dtsi/dtso - Patch 25 (new in v2) Sort exist driver list in Kconfig help - Patch 26 (16 in v1) Keep alphanumeric order for new drivers added in Kconfig help Herve Codina (26): driver core: Rename get_dev_from_fwnode() wrapper to get_device_from_fwnode() driver core: Avoid warning when removing a device while its supplier is unbinding bus: simple-pm-bus: Remove child devices when the bus is unbound bus: simple-pm-bus: Populate child nodes at probe driver core: fw_devlink: Introduce fw_devlink_set_device() drivers: core: Use fw_devlink_set_device() pinctrl: cs42l43: Use fw_devlink_set_device() cxl/test: Use device_set_node() cxl/test: Use fw_devlink_set_device() PCI: of: Use fw_devlink_set_device() PCI: of: Set fwnode device of newly created PCI device nodes PCI: of: Remove fwnode_dev_initialized() call for a PCI root bridge node i2c: core: Introduce i2c_get_adapter_physdev() i2c: mux: Set adapter physical device i2c: mux: Create missing devlink between mux and adapter physical device of: property: Allow fw_devlink device-tree on x86 clk: lan966x: Add MCHP_LAN966X_PCI dependency i2c: busses: at91: Add MCHP_LAN966X_PCI dependency misc: lan966x_pci: Fix dtso nodes ordering misc: lan966x_pci: Split dtso in dtsi/dtso misc: lan966x_pci: Rename lan966x_pci.dtso to lan966x_evb_lan9662_nic.dtso PCI: Add Microchip LAN9662 PCI Device ID misc: lan966x_pci: Introduce board specific data misc: lan966x_pci: Add dtsi/dtso nodes in order to support SFPs misc: lan966x_pci: Sort the drivers list in Kconfig help misc: lan966x_pci: Add drivers needed to support SFPs in Kconfig help Saravana Kannan (2): Revert "treewide: Fix probing of devices in DT overlays" of: dynamic: Fix overlayed devices not probing because of fw_devlink MAINTAINERS | 3 +- drivers/base/core.c | 108 ++++++++++--- drivers/bus/imx-weim.c | 6 - drivers/bus/simple-pm-bus.c | 24 +-- drivers/clk/Kconfig | 2 +- drivers/i2c/busses/Kconfig | 2 +- drivers/i2c/i2c-core-base.c | 16 ++ drivers/i2c/i2c-core-of.c | 5 - drivers/i2c/i2c-mux.c | 26 ++++ drivers/misc/Kconfig | 11 +- drivers/misc/Makefile | 2 +- drivers/misc/lan966x_evb_lan9662_nic.dtso | 167 ++++++++++++++++++++ drivers/misc/lan966x_pci.c | 30 +++- drivers/misc/lan966x_pci.dtsi | 172 +++++++++++++++++++++ drivers/misc/lan966x_pci.dtso | 177 ---------------------- drivers/of/dynamic.c | 1 - drivers/of/overlay.c | 15 ++ drivers/of/platform.c | 5 - drivers/of/property.c | 26 +++- drivers/pci/of.c | 10 +- drivers/pci/quirks.c | 2 +- drivers/pinctrl/cirrus/pinctrl-cs42l43.c | 2 +- drivers/pmdomain/core.c | 4 +- drivers/spi/spi.c | 5 - include/linux/device.h | 2 +- include/linux/fwnode.h | 7 + include/linux/i2c.h | 3 + include/linux/pci_ids.h | 1 + tools/testing/cxl/test/cxl.c | 4 +- 29 files changed, 584 insertions(+), 254 deletions(-) create mode 100644 drivers/misc/lan966x_evb_lan9662_nic.dtso create mode 100644 drivers/misc/lan966x_pci.dtsi delete mode 100644 drivers/misc/lan966x_pci.dtso -- 2.53.0
null
null
null
[PATCH v5 00/28] lan966x pci device: Add support for SFPs
Existing code uses the 0x9660 value (LAN9662 PCI Device ID) in several places. Avoid this direct use of the 0x9660 value replacing it by defined PCI Device ID. Signed-off-by: Herve Codina <herve.codina@bootlin.com> Acked-by: Bjorn Helgaas <bhelgaas@google.com> --- drivers/misc/lan966x_pci.c | 2 +- drivers/pci/quirks.c | 2 +- include/linux/pci_ids.h | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/misc/lan966x_pci.c b/drivers/misc/lan966x_pci.c index bbd87c89663d..e6d1fce0b116 100644 --- a/drivers/misc/lan966x_pci.c +++ b/drivers/misc/lan966x_pci.c @@ -197,7 +197,7 @@ static void lan966x_pci_remove(struct pci_dev *pdev) } static struct pci_device_id lan966x_pci_ids[] = { - { PCI_DEVICE(PCI_VENDOR_ID_EFAR, 0x9660) }, + { PCI_DEVICE(PCI_VENDOR_ID_EFAR, PCI_DEVICE_ID_EFAR_LAN9662) }, { } }; MODULE_DEVICE_TABLE(pci, lan966x_pci_ids); diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c index a63c24d3901d..cdb81f90f91f 100644 --- a/drivers/pci/quirks.c +++ b/drivers/pci/quirks.c @@ -6358,7 +6358,7 @@ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0xa76e, dpc_log_size); DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_XILINX, 0x5020, of_pci_make_dev_node); DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_XILINX, 0x5021, of_pci_make_dev_node); DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_REDHAT, 0x0005, of_pci_make_dev_node); -DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_EFAR, 0x9660, of_pci_make_dev_node); +DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_EFAR, PCI_DEVICE_ID_EFAR_LAN9662, of_pci_make_dev_node); /* * Devices known to require a longer delay before first config space access diff --git a/include/linux/pci_ids.h b/include/linux/pci_ids.h index 406abf629be2..766684176a51 100644 --- a/include/linux/pci_ids.h +++ b/include/linux/pci_ids.h @@ -934,6 +934,7 @@ #define PCI_VENDOR_ID_EFAR 0x1055 #define PCI_DEVICE_ID_EFAR_SLC90E66_1 0x9130 #define PCI_DEVICE_ID_EFAR_SLC90E66_3 0x9463 +#define PCI_DEVICE_ID_EFAR_LAN9662 0x9660 #define PCI_VENDOR_ID_MOTOROLA 0x1057 #define PCI_DEVICE_ID_MOTOROLA_MPC105 0x0001 -- 2.53.0
{ "author": "Herve Codina <herve.codina@bootlin.com>", "date": "Fri, 27 Feb 2026 14:54:21 +0100", "is_openbsd": false, "thread_id": "20260227135428.783983-1-herve.codina@bootlin.com.mbox.gz" }
lkml_critique
lkml
Hi, This series add support for SFPs ports available on the LAN966x PCI device. In order to have the SFPs supported, additional devices are needed such as clock controller and I2C. As a reminder, the LAN966x PCI device driver use a device-tree overlay to describe devices available on the PCI board. Adding support for SFPs ports consists in adding more devices in the already existing device-tree overlay. With those devices added, the device-tree overlay is more complex and some consumer/supplier relationship are needed in order to remove devices in correct order when the LAN966x PCI driver is removed. Those links are typically provided by fw_devlink and we faced some issues with fw_devlink and overlays. This series gives the big picture related to the SFPs support from fixing issues to adding new devices. Of course, it can be split if needed. The first part of the series (patch 1, 2 and 3) fixes fw_devlink when it is used with overlay. Patches 1 and 3 were previously sent by Saravana [0]. I rebased them on top of v7.0-rc1 and added patch 2 in order to take into account feedback received on the series sent by Saravana. Also I added a call to driver_deferred_probe_trigger() in Saravana's patch (patch 3) to ensure that probes are retried after the modification performed on the dangling consumers. This allows to fix issues reported by Matti and Geert [2] with the previous iteration patches. Those modification were not sufficient in our case and so, on top of that, patches 4 to 6 fix some more issues related to fw_devlink. Patches 7 to 12 introduce and use fw_devlink_set_device() in already existing code. Patches 13 and 14 are related also to fw_devlink but specific to PCI and the device-tree nodes created during enumeration. Patches 15, 16 and 17 are related fw_devlink too but specific to I2C muxes. Patches purpose is to correctly set a link between an adapter supplier and its consumer. Indeed, an i2c mux adapter's parent is not the i2c mux supplier but the adapter the i2c mux is connected to. Adding a new link between the adapter supplier involved when i2c muxes are used avoid a freeze observed during device removal. Patch 18 adds support for fw_delink on x86. fw_devlink is needed to have the consumer/supplier relationship between devices in order to ensure a correct device removal order. Adding fw_devlink support for x86 has been tried in the past but was reverted [1] because it broke some systems. Instead of enabling fw_devlink on *all* x86 system, enable it on *all* x86 except on those where it leads to issue. Patches 19 and 20 allow to build clock and i2c controller used by the LAN966x PCI device when the LAN966x PCI device is enabled. Patches 21 to 25 are specific to the LAN966x. They touch the current dtso, split it in dtsi/dtso files, rename the dtso and improve the driver to allow easier support for other boards. The next patch (patch 26) update the LAN966x device-tree overlay itself to have the SPF ports and devices they depends on described. The last two patches (patches 27 and 29) sort the existing drivers in the needed driver list available in the Kconfig help and add new drivers in this list keep the list up to date with the devices described in the device-tree overlay. We believe some items from the above list can be merged separately, with no build dependencies. We expect: - Patches 1 to 6 to be taken by driver core maintainers - Patches 7 to 12 to be taken by driver core maintainers - Patches 13 and 14 to be taken by driver core or PCI maintainers (depend on patch 7) - Patches 15 to 17 to be taken by I2C maintainers - Patch 18 to be taken by driver core or OF maintainers - Patch 19 to be taken by clock maintainers - Patch 20 to be taken by I2C maintainers - Patches 21 to 28 to be taken by misc maintainers Once again, this series gives the big picture and can be split if needed. Let me know. Compare to previous iteration, this v5 series mainly: - Handle Matti and Geert use cases [2] - Remove simple-platform-bus driver introduced in v4 and switch the simple-bus modification back to what was proposed in v3. In the v4 iteration, conclusion was to use v3 changes [3]. [0] https://lore.kernel.org/lkml/20240411235623.1260061-1-saravanak@google.com/ [1] https://lore.kernel.org/lkml/3c1f2473-92ad-bfc4-258e-a5a08ad73dd0@web.de/ [2] https://lore.kernel.org/all/072dde7c-a53c-4525-83ac-57ea38edc0b5@gmail.com/ [3] https://lore.kernel.org/lkml/20251114083056.31553866@bootlin.com/ Best regards, Hervé Changes: v4 -> v5 v4: https://lore.kernel.org/lkml/20251015071420.1173068-1-herve.codina@bootlin.com/ - Patch 2: Add 'Acked-by: Ulf Hansson' - Patch 3: Add a call to driver_deferred_probe_trigger() - Patch 5: (new patch) Depopulate devices at remove - Patch 6: Populate devices at probe. Switched back to modification proposed in v3 - Patch 7 in v3 removed - Patch 7 (8 in v4): Add 'Reviewed-by: Andy Shevchenko' Add 'Reviewed-by: Ulf Hansson' - Patch 8 (9 in v4): Add 'Reviewed-by: Ulf Hansson' - Patches 9 to 15 (10 to 16 in v3) No changes - Patch 16 (17 in v4): Add 'Reviewed-by: Andi Shyti' - Patch 17 (18 in v4): Change an error code from -EINVAL to -ENODEV Add a blank line and fix a typo in commit log - Patch 18 (19 in v4): Simplify of_is_fwnode_add_links_supported(). Move IS_ENABLED(CONFIG_X86) check in of_is_fwnode_add_links_supported(). - Patches 19 to 21 (20 to 22 in v4) No changes - Patch 22 (23 in v4) Update due to simple-platform-bus removal - Patches 23 to 28 (24 to 29 in v4) No changes v3 -> v4 v3: https://lore.kernel.org/lkml/20250613134817.681832-1-herve.codina@bootlin.com/ - Patch 1: No change - Patch 2: Update and fix conflicts. Indeed, since v3 iteration get_dev_from_fwnode() has been moved to device.h and used by pmdomain/core.c. - Patch 3: remove '#define get_device_from_fwnode()' - Patch 4: Fix conflict (rebase v6.17-rc6) Add 'Reviewed-by: Rafael J. Wysocki' Add 'Reviewed-by: Saravana Kannan' - Patch 5 (new in v4): Introduce simple-platform-bus (binding) - Patch 6 (5 in v3): Rework patch and introduce simple-platform-bus - Patch 7: (new) Use simple-platform-bus in LAN966x - Patch 8 (6 in v3): - No change - Patch 9 and 10 (7 and 8 in v3): Add 'Reviewed-by: Andy Shevchenko' - Patch 11 and 12 (9 and 10 in v3): Add 'Reviewed-by: Dave Jiang' - Patch 13 (11 in v3): Add 'Reviewed-by: Andy Shevchenko' - Patch 12 in v3: Patch removed. Adding __private tag in fwnode.dev is going to be handled in a dedicated series. Indeed a test robot reported an issue and more patches are needed (I have missed fwnode.dev users in several part in the kernel). - Patch 14 and 15 (13 and 14 in v3): No change - Patch 16 (14 in v3): Add 'Reviewed-by: Andi Shyti' - Patch 17 and 18 (16 and 17 in v3): No change - Patch 19 (18 in v3): Filter out support for fw_devlink on x86 based on some device-tree properties. Rewrite commit changelog Remove 'Reviewed-by: Andy Shevchenko' (significant modification) - Patch 20 (19 in v3): Add 'Acked-by: Stephen Boyd' - Patch 21 (20 in v3): Fix conflict (rebase v6.18-rc1) - Patches 22 to 24 (21 to 23 in v3): No change - Patch 25 (24 in v3): Fix conflict (rebase v6.18-rc1) Add 'Acked-by: Bjorn Helgaas' - Patches 26 to 29 (25 to 28 in v3): No change v2 -> v3 v2: https://lore.kernel.org/all/20250507071315.394857-1-herve.codina@bootlin.com/ - Patch 1: Add 'Acked-by: Mark Brown' - Patch 2 and 3: No changes - Patch 4: Rewrite the WARN_ON() condition to avoid an additional 'if' - Patch 5: Fix typos in commit log Update a comment Remove the unneeded check before calling of_platform_depopulate() - Patches 6 to 11: No changes - Patch 12 (new in v3) Tag the fwnode dev member as private - Patch 13 (12 in v2) Fix a typo in the commit log - Patches 14 to 16 (13 to 15 in v2) No changes - Patch 17 (16 in v2) Check parent_physdev for NULL - Patch 18 (17 in v2) Capitalize "Link:" Add 'Reviewed-by: Andy Shevchenko' - Patch 19 (18 in v2) No changes - Patch 20 (19 in v2) Add 'Acked-by: Andi Shyti' - Patch 21 (20 in v2) No changes - Patch 22 (21 in v2) Add 'Reviewed-by: Andrew Lunn' - Patch 23 (22 in v2) Add 'Reviewed-by: Andrew Lunn' - Patch 24 (new in v3) Introduce PCI_DEVICE_ID_EFAR_LAN9662, the LAN966x PCI device ID - Patch 25 (23 in v2) Add 'Reviewed-by: Andrew Lunn' Use PCI_DEVICE_DATA() with PCI_DEVICE_ID_EFAR_LAN9662 instead of PCI_VDEVICE() - Patch 26 to 28 (24 to 26 in v2) No changes v1 -> v2 v1: https://lore.kernel.org/lkml/20250407145546.270683-1-herve.codina@bootlin.com/ - Patch 1 and 3 Remove 'From' tag from the commit log - Patch 2 Add 'Reviewed-by: Andy Shevchenko' Add 'Reviewed-by: Saravana Kannan' Add 'Reviewed-by: Luca Ceresoli' - Patch 4 and 5 No changes - Patch 6 (new in v2) Introduce fw_devlink_set_device() - Patch 7 (new in v2) Use existing device_set_node() helper. - Patch 8 to 11 (new in v2) Use fw_devlink_set_device() in existing code. - Patch 12 (6 in v1) Use fw_devlink_add_device() - Patch 13 (7 in v1) No changes - Patch 14 (8 in v1) Update commit log Use 'physdev' instead of 'supplier' Minor fixes in i2c_get_adapter_physdev() kdoc - Patch 15 and 16 (9 and 10 in v1) Use 'physdev' instead of 'supplier' (commit log, title and code) - Patch 17 (11 in v2) Enable fw_devlink on x86 only if PCI_DYNAMIC_OF_NODES is enabled. Rework commit log. - Patch 18, 19 and 20 (12, 13 and 14 in v1) No changes - Patch 21 (new in v2) Split dtso in dtsi/dtso - Patch 22 (new in v2) Rename lan966x_pci.dtso using the specific board name - Patch 23 (new in v2) Improve the driver introducing board specific data to ease support for other boards (avoid the direct dtbo reference in the function loading the dtbo). - Patch 24 (15 in v1) Refactor due to dtso split in dtsi/dtso - Patch 25 (new in v2) Sort exist driver list in Kconfig help - Patch 26 (16 in v1) Keep alphanumeric order for new drivers added in Kconfig help Herve Codina (26): driver core: Rename get_dev_from_fwnode() wrapper to get_device_from_fwnode() driver core: Avoid warning when removing a device while its supplier is unbinding bus: simple-pm-bus: Remove child devices when the bus is unbound bus: simple-pm-bus: Populate child nodes at probe driver core: fw_devlink: Introduce fw_devlink_set_device() drivers: core: Use fw_devlink_set_device() pinctrl: cs42l43: Use fw_devlink_set_device() cxl/test: Use device_set_node() cxl/test: Use fw_devlink_set_device() PCI: of: Use fw_devlink_set_device() PCI: of: Set fwnode device of newly created PCI device nodes PCI: of: Remove fwnode_dev_initialized() call for a PCI root bridge node i2c: core: Introduce i2c_get_adapter_physdev() i2c: mux: Set adapter physical device i2c: mux: Create missing devlink between mux and adapter physical device of: property: Allow fw_devlink device-tree on x86 clk: lan966x: Add MCHP_LAN966X_PCI dependency i2c: busses: at91: Add MCHP_LAN966X_PCI dependency misc: lan966x_pci: Fix dtso nodes ordering misc: lan966x_pci: Split dtso in dtsi/dtso misc: lan966x_pci: Rename lan966x_pci.dtso to lan966x_evb_lan9662_nic.dtso PCI: Add Microchip LAN9662 PCI Device ID misc: lan966x_pci: Introduce board specific data misc: lan966x_pci: Add dtsi/dtso nodes in order to support SFPs misc: lan966x_pci: Sort the drivers list in Kconfig help misc: lan966x_pci: Add drivers needed to support SFPs in Kconfig help Saravana Kannan (2): Revert "treewide: Fix probing of devices in DT overlays" of: dynamic: Fix overlayed devices not probing because of fw_devlink MAINTAINERS | 3 +- drivers/base/core.c | 108 ++++++++++--- drivers/bus/imx-weim.c | 6 - drivers/bus/simple-pm-bus.c | 24 +-- drivers/clk/Kconfig | 2 +- drivers/i2c/busses/Kconfig | 2 +- drivers/i2c/i2c-core-base.c | 16 ++ drivers/i2c/i2c-core-of.c | 5 - drivers/i2c/i2c-mux.c | 26 ++++ drivers/misc/Kconfig | 11 +- drivers/misc/Makefile | 2 +- drivers/misc/lan966x_evb_lan9662_nic.dtso | 167 ++++++++++++++++++++ drivers/misc/lan966x_pci.c | 30 +++- drivers/misc/lan966x_pci.dtsi | 172 +++++++++++++++++++++ drivers/misc/lan966x_pci.dtso | 177 ---------------------- drivers/of/dynamic.c | 1 - drivers/of/overlay.c | 15 ++ drivers/of/platform.c | 5 - drivers/of/property.c | 26 +++- drivers/pci/of.c | 10 +- drivers/pci/quirks.c | 2 +- drivers/pinctrl/cirrus/pinctrl-cs42l43.c | 2 +- drivers/pmdomain/core.c | 4 +- drivers/spi/spi.c | 5 - include/linux/device.h | 2 +- include/linux/fwnode.h | 7 + include/linux/i2c.h | 3 + include/linux/pci_ids.h | 1 + tools/testing/cxl/test/cxl.c | 4 +- 29 files changed, 584 insertions(+), 254 deletions(-) create mode 100644 drivers/misc/lan966x_evb_lan9662_nic.dtso create mode 100644 drivers/misc/lan966x_pci.dtsi delete mode 100644 drivers/misc/lan966x_pci.dtso -- 2.53.0
null
null
null
[PATCH v5 00/28] lan966x pci device: Add support for SFPs
Only one device-tree overlay (lan966x_evb_lan9662_nic.dtbo) is handled and this overlay is directly referenced in lan966x_pci_load_overlay(). This avoid to use the code for an other board. In order to be more generic and to allow support for other boards (PCI Vendor/Device IDs), introduce the lan966x_pci_info structure and attach it to PCI Vendor/Device IDs handled by the driver. This structure contains information related to the PCI board such as information related to the dtbo describing the board we have to load. Signed-off-by: Herve Codina <herve.codina@bootlin.com> Reviewed-by: Andrew Lunn <andrew@lunn.ch> --- drivers/misc/lan966x_pci.c | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/drivers/misc/lan966x_pci.c b/drivers/misc/lan966x_pci.c index e6d1fce0b116..041e92f924c4 100644 --- a/drivers/misc/lan966x_pci.c +++ b/drivers/misc/lan966x_pci.c @@ -18,10 +18,6 @@ #include <linux/pci_ids.h> #include <linux/slab.h> -/* Embedded dtbo symbols created by cmd_wrap_S_dtb in scripts/Makefile.lib */ -extern char __dtbo_lan966x_evb_lan9662_nic_begin[]; -extern char __dtbo_lan966x_evb_lan9662_nic_end[]; - struct pci_dev_intr_ctrl { struct pci_dev *pci_dev; struct irq_domain *irq_domain; @@ -118,17 +114,23 @@ static int devm_pci_dev_create_intr_ctrl(struct pci_dev *pdev) return devm_add_action_or_reset(&pdev->dev, devm_pci_dev_remove_intr_ctrl, intr_ctrl); } +struct lan966x_pci_info { + void *dtbo_begin; + void *dtbo_end; +}; + struct lan966x_pci { struct device *dev; int ovcs_id; + const struct lan966x_pci_info *info; }; static int lan966x_pci_load_overlay(struct lan966x_pci *data) { - u32 dtbo_size = __dtbo_lan966x_evb_lan9662_nic_end - __dtbo_lan966x_evb_lan9662_nic_begin; - void *dtbo_start = __dtbo_lan966x_evb_lan9662_nic_begin; + const struct lan966x_pci_info *info = data->info; - return of_overlay_fdt_apply(dtbo_start, dtbo_size, &data->ovcs_id, dev_of_node(data->dev)); + return of_overlay_fdt_apply(info->dtbo_begin, info->dtbo_end - info->dtbo_begin, + &data->ovcs_id, dev_of_node(data->dev)); } static void lan966x_pci_unload_overlay(struct lan966x_pci *data) @@ -169,6 +171,9 @@ static int lan966x_pci_probe(struct pci_dev *pdev, const struct pci_device_id *i pci_set_drvdata(pdev, data); data->dev = dev; + data->info = (const struct lan966x_pci_info *)id->driver_data; + if (!data->info) + return -EINVAL; ret = lan966x_pci_load_overlay(data); if (ret) @@ -196,8 +201,17 @@ static void lan966x_pci_remove(struct pci_dev *pdev) lan966x_pci_unload_overlay(data); } +/* Embedded dtbo symbols created by cmd_wrap_S_dtb in scripts/Makefile.lib */ +extern char __dtbo_lan966x_evb_lan9662_nic_begin[]; +extern char __dtbo_lan966x_evb_lan9662_nic_end[]; + +static struct lan966x_pci_info evb_lan9662_nic_info = { + .dtbo_begin = __dtbo_lan966x_evb_lan9662_nic_begin, + .dtbo_end = __dtbo_lan966x_evb_lan9662_nic_end, +}; + static struct pci_device_id lan966x_pci_ids[] = { - { PCI_DEVICE(PCI_VENDOR_ID_EFAR, PCI_DEVICE_ID_EFAR_LAN9662) }, + { PCI_DEVICE_DATA(EFAR, LAN9662, &evb_lan9662_nic_info) }, { } }; MODULE_DEVICE_TABLE(pci, lan966x_pci_ids); -- 2.53.0
{ "author": "Herve Codina <herve.codina@bootlin.com>", "date": "Fri, 27 Feb 2026 14:54:22 +0100", "is_openbsd": false, "thread_id": "20260227135428.783983-1-herve.codina@bootlin.com.mbox.gz" }
lkml_critique
lkml
Hi, This series add support for SFPs ports available on the LAN966x PCI device. In order to have the SFPs supported, additional devices are needed such as clock controller and I2C. As a reminder, the LAN966x PCI device driver use a device-tree overlay to describe devices available on the PCI board. Adding support for SFPs ports consists in adding more devices in the already existing device-tree overlay. With those devices added, the device-tree overlay is more complex and some consumer/supplier relationship are needed in order to remove devices in correct order when the LAN966x PCI driver is removed. Those links are typically provided by fw_devlink and we faced some issues with fw_devlink and overlays. This series gives the big picture related to the SFPs support from fixing issues to adding new devices. Of course, it can be split if needed. The first part of the series (patch 1, 2 and 3) fixes fw_devlink when it is used with overlay. Patches 1 and 3 were previously sent by Saravana [0]. I rebased them on top of v7.0-rc1 and added patch 2 in order to take into account feedback received on the series sent by Saravana. Also I added a call to driver_deferred_probe_trigger() in Saravana's patch (patch 3) to ensure that probes are retried after the modification performed on the dangling consumers. This allows to fix issues reported by Matti and Geert [2] with the previous iteration patches. Those modification were not sufficient in our case and so, on top of that, patches 4 to 6 fix some more issues related to fw_devlink. Patches 7 to 12 introduce and use fw_devlink_set_device() in already existing code. Patches 13 and 14 are related also to fw_devlink but specific to PCI and the device-tree nodes created during enumeration. Patches 15, 16 and 17 are related fw_devlink too but specific to I2C muxes. Patches purpose is to correctly set a link between an adapter supplier and its consumer. Indeed, an i2c mux adapter's parent is not the i2c mux supplier but the adapter the i2c mux is connected to. Adding a new link between the adapter supplier involved when i2c muxes are used avoid a freeze observed during device removal. Patch 18 adds support for fw_delink on x86. fw_devlink is needed to have the consumer/supplier relationship between devices in order to ensure a correct device removal order. Adding fw_devlink support for x86 has been tried in the past but was reverted [1] because it broke some systems. Instead of enabling fw_devlink on *all* x86 system, enable it on *all* x86 except on those where it leads to issue. Patches 19 and 20 allow to build clock and i2c controller used by the LAN966x PCI device when the LAN966x PCI device is enabled. Patches 21 to 25 are specific to the LAN966x. They touch the current dtso, split it in dtsi/dtso files, rename the dtso and improve the driver to allow easier support for other boards. The next patch (patch 26) update the LAN966x device-tree overlay itself to have the SPF ports and devices they depends on described. The last two patches (patches 27 and 29) sort the existing drivers in the needed driver list available in the Kconfig help and add new drivers in this list keep the list up to date with the devices described in the device-tree overlay. We believe some items from the above list can be merged separately, with no build dependencies. We expect: - Patches 1 to 6 to be taken by driver core maintainers - Patches 7 to 12 to be taken by driver core maintainers - Patches 13 and 14 to be taken by driver core or PCI maintainers (depend on patch 7) - Patches 15 to 17 to be taken by I2C maintainers - Patch 18 to be taken by driver core or OF maintainers - Patch 19 to be taken by clock maintainers - Patch 20 to be taken by I2C maintainers - Patches 21 to 28 to be taken by misc maintainers Once again, this series gives the big picture and can be split if needed. Let me know. Compare to previous iteration, this v5 series mainly: - Handle Matti and Geert use cases [2] - Remove simple-platform-bus driver introduced in v4 and switch the simple-bus modification back to what was proposed in v3. In the v4 iteration, conclusion was to use v3 changes [3]. [0] https://lore.kernel.org/lkml/20240411235623.1260061-1-saravanak@google.com/ [1] https://lore.kernel.org/lkml/3c1f2473-92ad-bfc4-258e-a5a08ad73dd0@web.de/ [2] https://lore.kernel.org/all/072dde7c-a53c-4525-83ac-57ea38edc0b5@gmail.com/ [3] https://lore.kernel.org/lkml/20251114083056.31553866@bootlin.com/ Best regards, Hervé Changes: v4 -> v5 v4: https://lore.kernel.org/lkml/20251015071420.1173068-1-herve.codina@bootlin.com/ - Patch 2: Add 'Acked-by: Ulf Hansson' - Patch 3: Add a call to driver_deferred_probe_trigger() - Patch 5: (new patch) Depopulate devices at remove - Patch 6: Populate devices at probe. Switched back to modification proposed in v3 - Patch 7 in v3 removed - Patch 7 (8 in v4): Add 'Reviewed-by: Andy Shevchenko' Add 'Reviewed-by: Ulf Hansson' - Patch 8 (9 in v4): Add 'Reviewed-by: Ulf Hansson' - Patches 9 to 15 (10 to 16 in v3) No changes - Patch 16 (17 in v4): Add 'Reviewed-by: Andi Shyti' - Patch 17 (18 in v4): Change an error code from -EINVAL to -ENODEV Add a blank line and fix a typo in commit log - Patch 18 (19 in v4): Simplify of_is_fwnode_add_links_supported(). Move IS_ENABLED(CONFIG_X86) check in of_is_fwnode_add_links_supported(). - Patches 19 to 21 (20 to 22 in v4) No changes - Patch 22 (23 in v4) Update due to simple-platform-bus removal - Patches 23 to 28 (24 to 29 in v4) No changes v3 -> v4 v3: https://lore.kernel.org/lkml/20250613134817.681832-1-herve.codina@bootlin.com/ - Patch 1: No change - Patch 2: Update and fix conflicts. Indeed, since v3 iteration get_dev_from_fwnode() has been moved to device.h and used by pmdomain/core.c. - Patch 3: remove '#define get_device_from_fwnode()' - Patch 4: Fix conflict (rebase v6.17-rc6) Add 'Reviewed-by: Rafael J. Wysocki' Add 'Reviewed-by: Saravana Kannan' - Patch 5 (new in v4): Introduce simple-platform-bus (binding) - Patch 6 (5 in v3): Rework patch and introduce simple-platform-bus - Patch 7: (new) Use simple-platform-bus in LAN966x - Patch 8 (6 in v3): - No change - Patch 9 and 10 (7 and 8 in v3): Add 'Reviewed-by: Andy Shevchenko' - Patch 11 and 12 (9 and 10 in v3): Add 'Reviewed-by: Dave Jiang' - Patch 13 (11 in v3): Add 'Reviewed-by: Andy Shevchenko' - Patch 12 in v3: Patch removed. Adding __private tag in fwnode.dev is going to be handled in a dedicated series. Indeed a test robot reported an issue and more patches are needed (I have missed fwnode.dev users in several part in the kernel). - Patch 14 and 15 (13 and 14 in v3): No change - Patch 16 (14 in v3): Add 'Reviewed-by: Andi Shyti' - Patch 17 and 18 (16 and 17 in v3): No change - Patch 19 (18 in v3): Filter out support for fw_devlink on x86 based on some device-tree properties. Rewrite commit changelog Remove 'Reviewed-by: Andy Shevchenko' (significant modification) - Patch 20 (19 in v3): Add 'Acked-by: Stephen Boyd' - Patch 21 (20 in v3): Fix conflict (rebase v6.18-rc1) - Patches 22 to 24 (21 to 23 in v3): No change - Patch 25 (24 in v3): Fix conflict (rebase v6.18-rc1) Add 'Acked-by: Bjorn Helgaas' - Patches 26 to 29 (25 to 28 in v3): No change v2 -> v3 v2: https://lore.kernel.org/all/20250507071315.394857-1-herve.codina@bootlin.com/ - Patch 1: Add 'Acked-by: Mark Brown' - Patch 2 and 3: No changes - Patch 4: Rewrite the WARN_ON() condition to avoid an additional 'if' - Patch 5: Fix typos in commit log Update a comment Remove the unneeded check before calling of_platform_depopulate() - Patches 6 to 11: No changes - Patch 12 (new in v3) Tag the fwnode dev member as private - Patch 13 (12 in v2) Fix a typo in the commit log - Patches 14 to 16 (13 to 15 in v2) No changes - Patch 17 (16 in v2) Check parent_physdev for NULL - Patch 18 (17 in v2) Capitalize "Link:" Add 'Reviewed-by: Andy Shevchenko' - Patch 19 (18 in v2) No changes - Patch 20 (19 in v2) Add 'Acked-by: Andi Shyti' - Patch 21 (20 in v2) No changes - Patch 22 (21 in v2) Add 'Reviewed-by: Andrew Lunn' - Patch 23 (22 in v2) Add 'Reviewed-by: Andrew Lunn' - Patch 24 (new in v3) Introduce PCI_DEVICE_ID_EFAR_LAN9662, the LAN966x PCI device ID - Patch 25 (23 in v2) Add 'Reviewed-by: Andrew Lunn' Use PCI_DEVICE_DATA() with PCI_DEVICE_ID_EFAR_LAN9662 instead of PCI_VDEVICE() - Patch 26 to 28 (24 to 26 in v2) No changes v1 -> v2 v1: https://lore.kernel.org/lkml/20250407145546.270683-1-herve.codina@bootlin.com/ - Patch 1 and 3 Remove 'From' tag from the commit log - Patch 2 Add 'Reviewed-by: Andy Shevchenko' Add 'Reviewed-by: Saravana Kannan' Add 'Reviewed-by: Luca Ceresoli' - Patch 4 and 5 No changes - Patch 6 (new in v2) Introduce fw_devlink_set_device() - Patch 7 (new in v2) Use existing device_set_node() helper. - Patch 8 to 11 (new in v2) Use fw_devlink_set_device() in existing code. - Patch 12 (6 in v1) Use fw_devlink_add_device() - Patch 13 (7 in v1) No changes - Patch 14 (8 in v1) Update commit log Use 'physdev' instead of 'supplier' Minor fixes in i2c_get_adapter_physdev() kdoc - Patch 15 and 16 (9 and 10 in v1) Use 'physdev' instead of 'supplier' (commit log, title and code) - Patch 17 (11 in v2) Enable fw_devlink on x86 only if PCI_DYNAMIC_OF_NODES is enabled. Rework commit log. - Patch 18, 19 and 20 (12, 13 and 14 in v1) No changes - Patch 21 (new in v2) Split dtso in dtsi/dtso - Patch 22 (new in v2) Rename lan966x_pci.dtso using the specific board name - Patch 23 (new in v2) Improve the driver introducing board specific data to ease support for other boards (avoid the direct dtbo reference in the function loading the dtbo). - Patch 24 (15 in v1) Refactor due to dtso split in dtsi/dtso - Patch 25 (new in v2) Sort exist driver list in Kconfig help - Patch 26 (16 in v1) Keep alphanumeric order for new drivers added in Kconfig help Herve Codina (26): driver core: Rename get_dev_from_fwnode() wrapper to get_device_from_fwnode() driver core: Avoid warning when removing a device while its supplier is unbinding bus: simple-pm-bus: Remove child devices when the bus is unbound bus: simple-pm-bus: Populate child nodes at probe driver core: fw_devlink: Introduce fw_devlink_set_device() drivers: core: Use fw_devlink_set_device() pinctrl: cs42l43: Use fw_devlink_set_device() cxl/test: Use device_set_node() cxl/test: Use fw_devlink_set_device() PCI: of: Use fw_devlink_set_device() PCI: of: Set fwnode device of newly created PCI device nodes PCI: of: Remove fwnode_dev_initialized() call for a PCI root bridge node i2c: core: Introduce i2c_get_adapter_physdev() i2c: mux: Set adapter physical device i2c: mux: Create missing devlink between mux and adapter physical device of: property: Allow fw_devlink device-tree on x86 clk: lan966x: Add MCHP_LAN966X_PCI dependency i2c: busses: at91: Add MCHP_LAN966X_PCI dependency misc: lan966x_pci: Fix dtso nodes ordering misc: lan966x_pci: Split dtso in dtsi/dtso misc: lan966x_pci: Rename lan966x_pci.dtso to lan966x_evb_lan9662_nic.dtso PCI: Add Microchip LAN9662 PCI Device ID misc: lan966x_pci: Introduce board specific data misc: lan966x_pci: Add dtsi/dtso nodes in order to support SFPs misc: lan966x_pci: Sort the drivers list in Kconfig help misc: lan966x_pci: Add drivers needed to support SFPs in Kconfig help Saravana Kannan (2): Revert "treewide: Fix probing of devices in DT overlays" of: dynamic: Fix overlayed devices not probing because of fw_devlink MAINTAINERS | 3 +- drivers/base/core.c | 108 ++++++++++--- drivers/bus/imx-weim.c | 6 - drivers/bus/simple-pm-bus.c | 24 +-- drivers/clk/Kconfig | 2 +- drivers/i2c/busses/Kconfig | 2 +- drivers/i2c/i2c-core-base.c | 16 ++ drivers/i2c/i2c-core-of.c | 5 - drivers/i2c/i2c-mux.c | 26 ++++ drivers/misc/Kconfig | 11 +- drivers/misc/Makefile | 2 +- drivers/misc/lan966x_evb_lan9662_nic.dtso | 167 ++++++++++++++++++++ drivers/misc/lan966x_pci.c | 30 +++- drivers/misc/lan966x_pci.dtsi | 172 +++++++++++++++++++++ drivers/misc/lan966x_pci.dtso | 177 ---------------------- drivers/of/dynamic.c | 1 - drivers/of/overlay.c | 15 ++ drivers/of/platform.c | 5 - drivers/of/property.c | 26 +++- drivers/pci/of.c | 10 +- drivers/pci/quirks.c | 2 +- drivers/pinctrl/cirrus/pinctrl-cs42l43.c | 2 +- drivers/pmdomain/core.c | 4 +- drivers/spi/spi.c | 5 - include/linux/device.h | 2 +- include/linux/fwnode.h | 7 + include/linux/i2c.h | 3 + include/linux/pci_ids.h | 1 + tools/testing/cxl/test/cxl.c | 4 +- 29 files changed, 584 insertions(+), 254 deletions(-) create mode 100644 drivers/misc/lan966x_evb_lan9662_nic.dtso create mode 100644 drivers/misc/lan966x_pci.dtsi delete mode 100644 drivers/misc/lan966x_pci.dtso -- 2.53.0
null
null
null
[PATCH v5 00/28] lan966x pci device: Add support for SFPs
Add device-tree nodes needed to support SFPs. Those nodes are: - the clock controller - the i2c controller - the i2c mux - the SFPs themselves and their related ports in the switch Signed-off-by: Herve Codina <herve.codina@bootlin.com> --- drivers/misc/lan966x_evb_lan9662_nic.dtso | 96 +++++++++++++++++++++++ drivers/misc/lan966x_pci.dtsi | 42 ++++++++++ 2 files changed, 138 insertions(+) diff --git a/drivers/misc/lan966x_evb_lan9662_nic.dtso b/drivers/misc/lan966x_evb_lan9662_nic.dtso index 3ad50abee72d..20e1fe4f78bf 100644 --- a/drivers/misc/lan966x_evb_lan9662_nic.dtso +++ b/drivers/misc/lan966x_evb_lan9662_nic.dtso @@ -4,6 +4,7 @@ */ #include <dt-bindings/gpio/gpio.h> +#include <dt-bindings/mfd/atmel-flexcom.h> #include <dt-bindings/phy/phy-lan966x-serdes.h> /dts-v1/; @@ -27,15 +28,94 @@ __overlay__ { #size-cells = <2>; #include "lan966x_pci.dtsi" + + i2c0_emux: i2c0-emux { + compatible = "i2c-mux-pinctrl"; + #address-cells = <1>; + #size-cells = <0>; + i2c-parent = <&i2c0>; + pinctrl-names = "i2c102", "i2c103", "idle"; + pinctrl-0 = <&i2cmux_0>; + pinctrl-1 = <&i2cmux_1>; + pinctrl-2 = <&i2cmux_pins>; + + i2c102: i2c@0 { + reg = <0>; + #address-cells = <1>; + #size-cells = <0>; + }; + + i2c103: i2c@1 { + reg = <1>; + #address-cells = <1>; + #size-cells = <0>; + }; + }; + + sfp2: sfp2 { + compatible = "sff,sfp"; + i2c-bus = <&i2c102>; + tx-disable-gpios = <&gpio 0 GPIO_ACTIVE_HIGH>; + los-gpios = <&gpio 25 GPIO_ACTIVE_HIGH>; + mod-def0-gpios = <&gpio 18 GPIO_ACTIVE_LOW>; + tx-fault-gpios = <&gpio 2 GPIO_ACTIVE_HIGH>; + }; + + sfp3: sfp3 { + compatible = "sff,sfp"; + i2c-bus = <&i2c103>; + tx-disable-gpios = <&gpio 1 GPIO_ACTIVE_HIGH>; + los-gpios = <&gpio 26 GPIO_ACTIVE_HIGH>; + mod-def0-gpios = <&gpio 19 GPIO_ACTIVE_LOW>; + tx-fault-gpios = <&gpio 3 GPIO_ACTIVE_HIGH>; + }; }; }; }; +&flx0 { + atmel,flexcom-mode = <ATMEL_FLEXCOM_MODE_TWI>; + status = "okay"; +}; + +&i2c0 { + pinctrl-0 = <&fc0_a_pins>; + pinctrl-names = "default"; + i2c-analog-filter; + i2c-digital-filter; + i2c-digital-filter-width-ns = <35>; + status = "okay"; +}; + &gpio { tod_pins: tod_pins { pins = "GPIO_36"; function = "ptpsync_1"; }; + + fc0_a_pins: fcb4-i2c-pins { + /* RXD, TXD */ + pins = "GPIO_9", "GPIO_10"; + function = "fc0_a"; + }; + + i2cmux_pins: i2cmux-pins { + pins = "GPIO_76", "GPIO_77"; + function = "twi_slc_gate"; + output-low; + }; + + i2cmux_0: i2cmux-0 { + pins = "GPIO_76"; + function = "twi_slc_gate"; + output-high; + }; + + i2cmux_1: i2cmux-1 { + pins = "GPIO_77"; + function = "twi_slc_gate"; + output-high; + }; }; &lan966x_phy0 { @@ -64,6 +144,22 @@ &port1 { status = "okay"; }; +&port2 { + phy-mode = "sgmii"; + phys = <&serdes 2 SERDES6G(0)>; + sfp = <&sfp2>; + managed = "in-band-status"; + status = "okay"; +}; + +&port3 { + phy-mode = "sgmii"; + phys = <&serdes 3 SERDES6G(1)>; + sfp = <&sfp3>; + managed = "in-band-status"; + status = "okay"; +}; + &switch { pinctrl-names = "default"; pinctrl-0 = <&tod_pins>; diff --git a/drivers/misc/lan966x_pci.dtsi b/drivers/misc/lan966x_pci.dtsi index 170298084fa5..d5c2056e4e5c 100644 --- a/drivers/misc/lan966x_pci.dtsi +++ b/drivers/misc/lan966x_pci.dtsi @@ -3,6 +3,7 @@ * Copyright (C) 2025 Microchip UNG */ +#include <dt-bindings/clock/microchip,lan966x.h> #include <dt-bindings/interrupt-controller/irq.h> cpu_clk: clock-600000000 { @@ -61,6 +62,39 @@ port1: port@1 { reg = <1>; status = "disabled"; }; + + port2: port@2 { + reg = <2>; + status = "disabled"; + }; + + port3: port@3 { + reg = <3>; + status = "disabled"; + }; + }; + }; + + flx0: flexcom@e0040000 { + compatible = "atmel,sama5d2-flexcom"; + reg = <0xe0040000 0x100>; + clocks = <&clks GCK_ID_FLEXCOM0>; + #address-cells = <1>; + #size-cells = <1>; + ranges = <0x0 0xe0040000 0x800>; + status = "disabled"; + + i2c0: i2c@600 { + compatible = "microchip,sam9x60-i2c"; + reg = <0x600 0x200>; + interrupt-parent = <&oic>; + interrupts = <48 IRQ_TYPE_LEVEL_HIGH>; + #address-cells = <1>; + #size-cells = <0>; + clocks = <&clks GCK_ID_FLEXCOM0>; + assigned-clocks = <&clks GCK_ID_FLEXCOM0>; + assigned-clock-rates = <20000000>; + status = "disabled"; }; }; @@ -69,6 +103,14 @@ cpu_ctrl: syscon@e00c0000 { reg = <0xe00c0000 0xa8>; }; + clks: clock-controller@e00c00a8 { + compatible = "microchip,lan966x-gck"; + #clock-cells = <1>; + clocks = <&cpu_clk>, <&ddr_clk>, <&sys_clk>; + clock-names = "cpu", "ddr", "sys"; + reg = <0xe00c00a8 0x38>, <0xe00c02cc 0x4>; + }; + oic: oic@e00c0120 { compatible = "microchip,lan966x-oic"; #interrupt-cells = <2>; -- 2.53.0
{ "author": "Herve Codina <herve.codina@bootlin.com>", "date": "Fri, 27 Feb 2026 14:54:23 +0100", "is_openbsd": false, "thread_id": "20260227135428.783983-1-herve.codina@bootlin.com.mbox.gz" }
lkml_critique
lkml
Hi, This series add support for SFPs ports available on the LAN966x PCI device. In order to have the SFPs supported, additional devices are needed such as clock controller and I2C. As a reminder, the LAN966x PCI device driver use a device-tree overlay to describe devices available on the PCI board. Adding support for SFPs ports consists in adding more devices in the already existing device-tree overlay. With those devices added, the device-tree overlay is more complex and some consumer/supplier relationship are needed in order to remove devices in correct order when the LAN966x PCI driver is removed. Those links are typically provided by fw_devlink and we faced some issues with fw_devlink and overlays. This series gives the big picture related to the SFPs support from fixing issues to adding new devices. Of course, it can be split if needed. The first part of the series (patch 1, 2 and 3) fixes fw_devlink when it is used with overlay. Patches 1 and 3 were previously sent by Saravana [0]. I rebased them on top of v7.0-rc1 and added patch 2 in order to take into account feedback received on the series sent by Saravana. Also I added a call to driver_deferred_probe_trigger() in Saravana's patch (patch 3) to ensure that probes are retried after the modification performed on the dangling consumers. This allows to fix issues reported by Matti and Geert [2] with the previous iteration patches. Those modification were not sufficient in our case and so, on top of that, patches 4 to 6 fix some more issues related to fw_devlink. Patches 7 to 12 introduce and use fw_devlink_set_device() in already existing code. Patches 13 and 14 are related also to fw_devlink but specific to PCI and the device-tree nodes created during enumeration. Patches 15, 16 and 17 are related fw_devlink too but specific to I2C muxes. Patches purpose is to correctly set a link between an adapter supplier and its consumer. Indeed, an i2c mux adapter's parent is not the i2c mux supplier but the adapter the i2c mux is connected to. Adding a new link between the adapter supplier involved when i2c muxes are used avoid a freeze observed during device removal. Patch 18 adds support for fw_delink on x86. fw_devlink is needed to have the consumer/supplier relationship between devices in order to ensure a correct device removal order. Adding fw_devlink support for x86 has been tried in the past but was reverted [1] because it broke some systems. Instead of enabling fw_devlink on *all* x86 system, enable it on *all* x86 except on those where it leads to issue. Patches 19 and 20 allow to build clock and i2c controller used by the LAN966x PCI device when the LAN966x PCI device is enabled. Patches 21 to 25 are specific to the LAN966x. They touch the current dtso, split it in dtsi/dtso files, rename the dtso and improve the driver to allow easier support for other boards. The next patch (patch 26) update the LAN966x device-tree overlay itself to have the SPF ports and devices they depends on described. The last two patches (patches 27 and 29) sort the existing drivers in the needed driver list available in the Kconfig help and add new drivers in this list keep the list up to date with the devices described in the device-tree overlay. We believe some items from the above list can be merged separately, with no build dependencies. We expect: - Patches 1 to 6 to be taken by driver core maintainers - Patches 7 to 12 to be taken by driver core maintainers - Patches 13 and 14 to be taken by driver core or PCI maintainers (depend on patch 7) - Patches 15 to 17 to be taken by I2C maintainers - Patch 18 to be taken by driver core or OF maintainers - Patch 19 to be taken by clock maintainers - Patch 20 to be taken by I2C maintainers - Patches 21 to 28 to be taken by misc maintainers Once again, this series gives the big picture and can be split if needed. Let me know. Compare to previous iteration, this v5 series mainly: - Handle Matti and Geert use cases [2] - Remove simple-platform-bus driver introduced in v4 and switch the simple-bus modification back to what was proposed in v3. In the v4 iteration, conclusion was to use v3 changes [3]. [0] https://lore.kernel.org/lkml/20240411235623.1260061-1-saravanak@google.com/ [1] https://lore.kernel.org/lkml/3c1f2473-92ad-bfc4-258e-a5a08ad73dd0@web.de/ [2] https://lore.kernel.org/all/072dde7c-a53c-4525-83ac-57ea38edc0b5@gmail.com/ [3] https://lore.kernel.org/lkml/20251114083056.31553866@bootlin.com/ Best regards, Hervé Changes: v4 -> v5 v4: https://lore.kernel.org/lkml/20251015071420.1173068-1-herve.codina@bootlin.com/ - Patch 2: Add 'Acked-by: Ulf Hansson' - Patch 3: Add a call to driver_deferred_probe_trigger() - Patch 5: (new patch) Depopulate devices at remove - Patch 6: Populate devices at probe. Switched back to modification proposed in v3 - Patch 7 in v3 removed - Patch 7 (8 in v4): Add 'Reviewed-by: Andy Shevchenko' Add 'Reviewed-by: Ulf Hansson' - Patch 8 (9 in v4): Add 'Reviewed-by: Ulf Hansson' - Patches 9 to 15 (10 to 16 in v3) No changes - Patch 16 (17 in v4): Add 'Reviewed-by: Andi Shyti' - Patch 17 (18 in v4): Change an error code from -EINVAL to -ENODEV Add a blank line and fix a typo in commit log - Patch 18 (19 in v4): Simplify of_is_fwnode_add_links_supported(). Move IS_ENABLED(CONFIG_X86) check in of_is_fwnode_add_links_supported(). - Patches 19 to 21 (20 to 22 in v4) No changes - Patch 22 (23 in v4) Update due to simple-platform-bus removal - Patches 23 to 28 (24 to 29 in v4) No changes v3 -> v4 v3: https://lore.kernel.org/lkml/20250613134817.681832-1-herve.codina@bootlin.com/ - Patch 1: No change - Patch 2: Update and fix conflicts. Indeed, since v3 iteration get_dev_from_fwnode() has been moved to device.h and used by pmdomain/core.c. - Patch 3: remove '#define get_device_from_fwnode()' - Patch 4: Fix conflict (rebase v6.17-rc6) Add 'Reviewed-by: Rafael J. Wysocki' Add 'Reviewed-by: Saravana Kannan' - Patch 5 (new in v4): Introduce simple-platform-bus (binding) - Patch 6 (5 in v3): Rework patch and introduce simple-platform-bus - Patch 7: (new) Use simple-platform-bus in LAN966x - Patch 8 (6 in v3): - No change - Patch 9 and 10 (7 and 8 in v3): Add 'Reviewed-by: Andy Shevchenko' - Patch 11 and 12 (9 and 10 in v3): Add 'Reviewed-by: Dave Jiang' - Patch 13 (11 in v3): Add 'Reviewed-by: Andy Shevchenko' - Patch 12 in v3: Patch removed. Adding __private tag in fwnode.dev is going to be handled in a dedicated series. Indeed a test robot reported an issue and more patches are needed (I have missed fwnode.dev users in several part in the kernel). - Patch 14 and 15 (13 and 14 in v3): No change - Patch 16 (14 in v3): Add 'Reviewed-by: Andi Shyti' - Patch 17 and 18 (16 and 17 in v3): No change - Patch 19 (18 in v3): Filter out support for fw_devlink on x86 based on some device-tree properties. Rewrite commit changelog Remove 'Reviewed-by: Andy Shevchenko' (significant modification) - Patch 20 (19 in v3): Add 'Acked-by: Stephen Boyd' - Patch 21 (20 in v3): Fix conflict (rebase v6.18-rc1) - Patches 22 to 24 (21 to 23 in v3): No change - Patch 25 (24 in v3): Fix conflict (rebase v6.18-rc1) Add 'Acked-by: Bjorn Helgaas' - Patches 26 to 29 (25 to 28 in v3): No change v2 -> v3 v2: https://lore.kernel.org/all/20250507071315.394857-1-herve.codina@bootlin.com/ - Patch 1: Add 'Acked-by: Mark Brown' - Patch 2 and 3: No changes - Patch 4: Rewrite the WARN_ON() condition to avoid an additional 'if' - Patch 5: Fix typos in commit log Update a comment Remove the unneeded check before calling of_platform_depopulate() - Patches 6 to 11: No changes - Patch 12 (new in v3) Tag the fwnode dev member as private - Patch 13 (12 in v2) Fix a typo in the commit log - Patches 14 to 16 (13 to 15 in v2) No changes - Patch 17 (16 in v2) Check parent_physdev for NULL - Patch 18 (17 in v2) Capitalize "Link:" Add 'Reviewed-by: Andy Shevchenko' - Patch 19 (18 in v2) No changes - Patch 20 (19 in v2) Add 'Acked-by: Andi Shyti' - Patch 21 (20 in v2) No changes - Patch 22 (21 in v2) Add 'Reviewed-by: Andrew Lunn' - Patch 23 (22 in v2) Add 'Reviewed-by: Andrew Lunn' - Patch 24 (new in v3) Introduce PCI_DEVICE_ID_EFAR_LAN9662, the LAN966x PCI device ID - Patch 25 (23 in v2) Add 'Reviewed-by: Andrew Lunn' Use PCI_DEVICE_DATA() with PCI_DEVICE_ID_EFAR_LAN9662 instead of PCI_VDEVICE() - Patch 26 to 28 (24 to 26 in v2) No changes v1 -> v2 v1: https://lore.kernel.org/lkml/20250407145546.270683-1-herve.codina@bootlin.com/ - Patch 1 and 3 Remove 'From' tag from the commit log - Patch 2 Add 'Reviewed-by: Andy Shevchenko' Add 'Reviewed-by: Saravana Kannan' Add 'Reviewed-by: Luca Ceresoli' - Patch 4 and 5 No changes - Patch 6 (new in v2) Introduce fw_devlink_set_device() - Patch 7 (new in v2) Use existing device_set_node() helper. - Patch 8 to 11 (new in v2) Use fw_devlink_set_device() in existing code. - Patch 12 (6 in v1) Use fw_devlink_add_device() - Patch 13 (7 in v1) No changes - Patch 14 (8 in v1) Update commit log Use 'physdev' instead of 'supplier' Minor fixes in i2c_get_adapter_physdev() kdoc - Patch 15 and 16 (9 and 10 in v1) Use 'physdev' instead of 'supplier' (commit log, title and code) - Patch 17 (11 in v2) Enable fw_devlink on x86 only if PCI_DYNAMIC_OF_NODES is enabled. Rework commit log. - Patch 18, 19 and 20 (12, 13 and 14 in v1) No changes - Patch 21 (new in v2) Split dtso in dtsi/dtso - Patch 22 (new in v2) Rename lan966x_pci.dtso using the specific board name - Patch 23 (new in v2) Improve the driver introducing board specific data to ease support for other boards (avoid the direct dtbo reference in the function loading the dtbo). - Patch 24 (15 in v1) Refactor due to dtso split in dtsi/dtso - Patch 25 (new in v2) Sort exist driver list in Kconfig help - Patch 26 (16 in v1) Keep alphanumeric order for new drivers added in Kconfig help Herve Codina (26): driver core: Rename get_dev_from_fwnode() wrapper to get_device_from_fwnode() driver core: Avoid warning when removing a device while its supplier is unbinding bus: simple-pm-bus: Remove child devices when the bus is unbound bus: simple-pm-bus: Populate child nodes at probe driver core: fw_devlink: Introduce fw_devlink_set_device() drivers: core: Use fw_devlink_set_device() pinctrl: cs42l43: Use fw_devlink_set_device() cxl/test: Use device_set_node() cxl/test: Use fw_devlink_set_device() PCI: of: Use fw_devlink_set_device() PCI: of: Set fwnode device of newly created PCI device nodes PCI: of: Remove fwnode_dev_initialized() call for a PCI root bridge node i2c: core: Introduce i2c_get_adapter_physdev() i2c: mux: Set adapter physical device i2c: mux: Create missing devlink between mux and adapter physical device of: property: Allow fw_devlink device-tree on x86 clk: lan966x: Add MCHP_LAN966X_PCI dependency i2c: busses: at91: Add MCHP_LAN966X_PCI dependency misc: lan966x_pci: Fix dtso nodes ordering misc: lan966x_pci: Split dtso in dtsi/dtso misc: lan966x_pci: Rename lan966x_pci.dtso to lan966x_evb_lan9662_nic.dtso PCI: Add Microchip LAN9662 PCI Device ID misc: lan966x_pci: Introduce board specific data misc: lan966x_pci: Add dtsi/dtso nodes in order to support SFPs misc: lan966x_pci: Sort the drivers list in Kconfig help misc: lan966x_pci: Add drivers needed to support SFPs in Kconfig help Saravana Kannan (2): Revert "treewide: Fix probing of devices in DT overlays" of: dynamic: Fix overlayed devices not probing because of fw_devlink MAINTAINERS | 3 +- drivers/base/core.c | 108 ++++++++++--- drivers/bus/imx-weim.c | 6 - drivers/bus/simple-pm-bus.c | 24 +-- drivers/clk/Kconfig | 2 +- drivers/i2c/busses/Kconfig | 2 +- drivers/i2c/i2c-core-base.c | 16 ++ drivers/i2c/i2c-core-of.c | 5 - drivers/i2c/i2c-mux.c | 26 ++++ drivers/misc/Kconfig | 11 +- drivers/misc/Makefile | 2 +- drivers/misc/lan966x_evb_lan9662_nic.dtso | 167 ++++++++++++++++++++ drivers/misc/lan966x_pci.c | 30 +++- drivers/misc/lan966x_pci.dtsi | 172 +++++++++++++++++++++ drivers/misc/lan966x_pci.dtso | 177 ---------------------- drivers/of/dynamic.c | 1 - drivers/of/overlay.c | 15 ++ drivers/of/platform.c | 5 - drivers/of/property.c | 26 +++- drivers/pci/of.c | 10 +- drivers/pci/quirks.c | 2 +- drivers/pinctrl/cirrus/pinctrl-cs42l43.c | 2 +- drivers/pmdomain/core.c | 4 +- drivers/spi/spi.c | 5 - include/linux/device.h | 2 +- include/linux/fwnode.h | 7 + include/linux/i2c.h | 3 + include/linux/pci_ids.h | 1 + tools/testing/cxl/test/cxl.c | 4 +- 29 files changed, 584 insertions(+), 254 deletions(-) create mode 100644 drivers/misc/lan966x_evb_lan9662_nic.dtso create mode 100644 drivers/misc/lan966x_pci.dtsi delete mode 100644 drivers/misc/lan966x_pci.dtso -- 2.53.0
null
null
null
[PATCH v5 00/28] lan966x pci device: Add support for SFPs
The LAN966X Kconfig help section mentions drivers related to devices. Sort this list alphabetically. Signed-off-by: Herve Codina <herve.codina@bootlin.com> --- drivers/misc/Kconfig | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig index 5cc79d1517af..9c285a7c88ba 100644 --- a/drivers/misc/Kconfig +++ b/drivers/misc/Kconfig @@ -635,13 +635,13 @@ config MCHP_LAN966X_PCI Even if this driver does not depend on those other drivers, in order to have a fully functional board, the following drivers are needed: - fixed-clock (COMMON_CLK) - - lan966x-oic (LAN966X_OIC) - lan966x-cpu-syscon (MFD_SYSCON) - - lan966x-switch-reset (RESET_MCHP_SPARX5) + - lan966x-miim (MDIO_MSCC_MIIM) + - lan966x-oic (LAN966X_OIC) - lan966x-pinctrl (PINCTRL_OCELOT) - lan966x-serdes (PHY_LAN966X_SERDES) - - lan966x-miim (MDIO_MSCC_MIIM) - lan966x-switch (LAN966X_SWITCH) + - lan966x-switch-reset (RESET_MCHP_SPARX5) source "drivers/misc/c2port/Kconfig" source "drivers/misc/eeprom/Kconfig" -- 2.53.0
{ "author": "Herve Codina <herve.codina@bootlin.com>", "date": "Fri, 27 Feb 2026 14:54:24 +0100", "is_openbsd": false, "thread_id": "20260227135428.783983-1-herve.codina@bootlin.com.mbox.gz" }
lkml_critique
lkml
Hi, This series add support for SFPs ports available on the LAN966x PCI device. In order to have the SFPs supported, additional devices are needed such as clock controller and I2C. As a reminder, the LAN966x PCI device driver use a device-tree overlay to describe devices available on the PCI board. Adding support for SFPs ports consists in adding more devices in the already existing device-tree overlay. With those devices added, the device-tree overlay is more complex and some consumer/supplier relationship are needed in order to remove devices in correct order when the LAN966x PCI driver is removed. Those links are typically provided by fw_devlink and we faced some issues with fw_devlink and overlays. This series gives the big picture related to the SFPs support from fixing issues to adding new devices. Of course, it can be split if needed. The first part of the series (patch 1, 2 and 3) fixes fw_devlink when it is used with overlay. Patches 1 and 3 were previously sent by Saravana [0]. I rebased them on top of v7.0-rc1 and added patch 2 in order to take into account feedback received on the series sent by Saravana. Also I added a call to driver_deferred_probe_trigger() in Saravana's patch (patch 3) to ensure that probes are retried after the modification performed on the dangling consumers. This allows to fix issues reported by Matti and Geert [2] with the previous iteration patches. Those modification were not sufficient in our case and so, on top of that, patches 4 to 6 fix some more issues related to fw_devlink. Patches 7 to 12 introduce and use fw_devlink_set_device() in already existing code. Patches 13 and 14 are related also to fw_devlink but specific to PCI and the device-tree nodes created during enumeration. Patches 15, 16 and 17 are related fw_devlink too but specific to I2C muxes. Patches purpose is to correctly set a link between an adapter supplier and its consumer. Indeed, an i2c mux adapter's parent is not the i2c mux supplier but the adapter the i2c mux is connected to. Adding a new link between the adapter supplier involved when i2c muxes are used avoid a freeze observed during device removal. Patch 18 adds support for fw_delink on x86. fw_devlink is needed to have the consumer/supplier relationship between devices in order to ensure a correct device removal order. Adding fw_devlink support for x86 has been tried in the past but was reverted [1] because it broke some systems. Instead of enabling fw_devlink on *all* x86 system, enable it on *all* x86 except on those where it leads to issue. Patches 19 and 20 allow to build clock and i2c controller used by the LAN966x PCI device when the LAN966x PCI device is enabled. Patches 21 to 25 are specific to the LAN966x. They touch the current dtso, split it in dtsi/dtso files, rename the dtso and improve the driver to allow easier support for other boards. The next patch (patch 26) update the LAN966x device-tree overlay itself to have the SPF ports and devices they depends on described. The last two patches (patches 27 and 29) sort the existing drivers in the needed driver list available in the Kconfig help and add new drivers in this list keep the list up to date with the devices described in the device-tree overlay. We believe some items from the above list can be merged separately, with no build dependencies. We expect: - Patches 1 to 6 to be taken by driver core maintainers - Patches 7 to 12 to be taken by driver core maintainers - Patches 13 and 14 to be taken by driver core or PCI maintainers (depend on patch 7) - Patches 15 to 17 to be taken by I2C maintainers - Patch 18 to be taken by driver core or OF maintainers - Patch 19 to be taken by clock maintainers - Patch 20 to be taken by I2C maintainers - Patches 21 to 28 to be taken by misc maintainers Once again, this series gives the big picture and can be split if needed. Let me know. Compare to previous iteration, this v5 series mainly: - Handle Matti and Geert use cases [2] - Remove simple-platform-bus driver introduced in v4 and switch the simple-bus modification back to what was proposed in v3. In the v4 iteration, conclusion was to use v3 changes [3]. [0] https://lore.kernel.org/lkml/20240411235623.1260061-1-saravanak@google.com/ [1] https://lore.kernel.org/lkml/3c1f2473-92ad-bfc4-258e-a5a08ad73dd0@web.de/ [2] https://lore.kernel.org/all/072dde7c-a53c-4525-83ac-57ea38edc0b5@gmail.com/ [3] https://lore.kernel.org/lkml/20251114083056.31553866@bootlin.com/ Best regards, Hervé Changes: v4 -> v5 v4: https://lore.kernel.org/lkml/20251015071420.1173068-1-herve.codina@bootlin.com/ - Patch 2: Add 'Acked-by: Ulf Hansson' - Patch 3: Add a call to driver_deferred_probe_trigger() - Patch 5: (new patch) Depopulate devices at remove - Patch 6: Populate devices at probe. Switched back to modification proposed in v3 - Patch 7 in v3 removed - Patch 7 (8 in v4): Add 'Reviewed-by: Andy Shevchenko' Add 'Reviewed-by: Ulf Hansson' - Patch 8 (9 in v4): Add 'Reviewed-by: Ulf Hansson' - Patches 9 to 15 (10 to 16 in v3) No changes - Patch 16 (17 in v4): Add 'Reviewed-by: Andi Shyti' - Patch 17 (18 in v4): Change an error code from -EINVAL to -ENODEV Add a blank line and fix a typo in commit log - Patch 18 (19 in v4): Simplify of_is_fwnode_add_links_supported(). Move IS_ENABLED(CONFIG_X86) check in of_is_fwnode_add_links_supported(). - Patches 19 to 21 (20 to 22 in v4) No changes - Patch 22 (23 in v4) Update due to simple-platform-bus removal - Patches 23 to 28 (24 to 29 in v4) No changes v3 -> v4 v3: https://lore.kernel.org/lkml/20250613134817.681832-1-herve.codina@bootlin.com/ - Patch 1: No change - Patch 2: Update and fix conflicts. Indeed, since v3 iteration get_dev_from_fwnode() has been moved to device.h and used by pmdomain/core.c. - Patch 3: remove '#define get_device_from_fwnode()' - Patch 4: Fix conflict (rebase v6.17-rc6) Add 'Reviewed-by: Rafael J. Wysocki' Add 'Reviewed-by: Saravana Kannan' - Patch 5 (new in v4): Introduce simple-platform-bus (binding) - Patch 6 (5 in v3): Rework patch and introduce simple-platform-bus - Patch 7: (new) Use simple-platform-bus in LAN966x - Patch 8 (6 in v3): - No change - Patch 9 and 10 (7 and 8 in v3): Add 'Reviewed-by: Andy Shevchenko' - Patch 11 and 12 (9 and 10 in v3): Add 'Reviewed-by: Dave Jiang' - Patch 13 (11 in v3): Add 'Reviewed-by: Andy Shevchenko' - Patch 12 in v3: Patch removed. Adding __private tag in fwnode.dev is going to be handled in a dedicated series. Indeed a test robot reported an issue and more patches are needed (I have missed fwnode.dev users in several part in the kernel). - Patch 14 and 15 (13 and 14 in v3): No change - Patch 16 (14 in v3): Add 'Reviewed-by: Andi Shyti' - Patch 17 and 18 (16 and 17 in v3): No change - Patch 19 (18 in v3): Filter out support for fw_devlink on x86 based on some device-tree properties. Rewrite commit changelog Remove 'Reviewed-by: Andy Shevchenko' (significant modification) - Patch 20 (19 in v3): Add 'Acked-by: Stephen Boyd' - Patch 21 (20 in v3): Fix conflict (rebase v6.18-rc1) - Patches 22 to 24 (21 to 23 in v3): No change - Patch 25 (24 in v3): Fix conflict (rebase v6.18-rc1) Add 'Acked-by: Bjorn Helgaas' - Patches 26 to 29 (25 to 28 in v3): No change v2 -> v3 v2: https://lore.kernel.org/all/20250507071315.394857-1-herve.codina@bootlin.com/ - Patch 1: Add 'Acked-by: Mark Brown' - Patch 2 and 3: No changes - Patch 4: Rewrite the WARN_ON() condition to avoid an additional 'if' - Patch 5: Fix typos in commit log Update a comment Remove the unneeded check before calling of_platform_depopulate() - Patches 6 to 11: No changes - Patch 12 (new in v3) Tag the fwnode dev member as private - Patch 13 (12 in v2) Fix a typo in the commit log - Patches 14 to 16 (13 to 15 in v2) No changes - Patch 17 (16 in v2) Check parent_physdev for NULL - Patch 18 (17 in v2) Capitalize "Link:" Add 'Reviewed-by: Andy Shevchenko' - Patch 19 (18 in v2) No changes - Patch 20 (19 in v2) Add 'Acked-by: Andi Shyti' - Patch 21 (20 in v2) No changes - Patch 22 (21 in v2) Add 'Reviewed-by: Andrew Lunn' - Patch 23 (22 in v2) Add 'Reviewed-by: Andrew Lunn' - Patch 24 (new in v3) Introduce PCI_DEVICE_ID_EFAR_LAN9662, the LAN966x PCI device ID - Patch 25 (23 in v2) Add 'Reviewed-by: Andrew Lunn' Use PCI_DEVICE_DATA() with PCI_DEVICE_ID_EFAR_LAN9662 instead of PCI_VDEVICE() - Patch 26 to 28 (24 to 26 in v2) No changes v1 -> v2 v1: https://lore.kernel.org/lkml/20250407145546.270683-1-herve.codina@bootlin.com/ - Patch 1 and 3 Remove 'From' tag from the commit log - Patch 2 Add 'Reviewed-by: Andy Shevchenko' Add 'Reviewed-by: Saravana Kannan' Add 'Reviewed-by: Luca Ceresoli' - Patch 4 and 5 No changes - Patch 6 (new in v2) Introduce fw_devlink_set_device() - Patch 7 (new in v2) Use existing device_set_node() helper. - Patch 8 to 11 (new in v2) Use fw_devlink_set_device() in existing code. - Patch 12 (6 in v1) Use fw_devlink_add_device() - Patch 13 (7 in v1) No changes - Patch 14 (8 in v1) Update commit log Use 'physdev' instead of 'supplier' Minor fixes in i2c_get_adapter_physdev() kdoc - Patch 15 and 16 (9 and 10 in v1) Use 'physdev' instead of 'supplier' (commit log, title and code) - Patch 17 (11 in v2) Enable fw_devlink on x86 only if PCI_DYNAMIC_OF_NODES is enabled. Rework commit log. - Patch 18, 19 and 20 (12, 13 and 14 in v1) No changes - Patch 21 (new in v2) Split dtso in dtsi/dtso - Patch 22 (new in v2) Rename lan966x_pci.dtso using the specific board name - Patch 23 (new in v2) Improve the driver introducing board specific data to ease support for other boards (avoid the direct dtbo reference in the function loading the dtbo). - Patch 24 (15 in v1) Refactor due to dtso split in dtsi/dtso - Patch 25 (new in v2) Sort exist driver list in Kconfig help - Patch 26 (16 in v1) Keep alphanumeric order for new drivers added in Kconfig help Herve Codina (26): driver core: Rename get_dev_from_fwnode() wrapper to get_device_from_fwnode() driver core: Avoid warning when removing a device while its supplier is unbinding bus: simple-pm-bus: Remove child devices when the bus is unbound bus: simple-pm-bus: Populate child nodes at probe driver core: fw_devlink: Introduce fw_devlink_set_device() drivers: core: Use fw_devlink_set_device() pinctrl: cs42l43: Use fw_devlink_set_device() cxl/test: Use device_set_node() cxl/test: Use fw_devlink_set_device() PCI: of: Use fw_devlink_set_device() PCI: of: Set fwnode device of newly created PCI device nodes PCI: of: Remove fwnode_dev_initialized() call for a PCI root bridge node i2c: core: Introduce i2c_get_adapter_physdev() i2c: mux: Set adapter physical device i2c: mux: Create missing devlink between mux and adapter physical device of: property: Allow fw_devlink device-tree on x86 clk: lan966x: Add MCHP_LAN966X_PCI dependency i2c: busses: at91: Add MCHP_LAN966X_PCI dependency misc: lan966x_pci: Fix dtso nodes ordering misc: lan966x_pci: Split dtso in dtsi/dtso misc: lan966x_pci: Rename lan966x_pci.dtso to lan966x_evb_lan9662_nic.dtso PCI: Add Microchip LAN9662 PCI Device ID misc: lan966x_pci: Introduce board specific data misc: lan966x_pci: Add dtsi/dtso nodes in order to support SFPs misc: lan966x_pci: Sort the drivers list in Kconfig help misc: lan966x_pci: Add drivers needed to support SFPs in Kconfig help Saravana Kannan (2): Revert "treewide: Fix probing of devices in DT overlays" of: dynamic: Fix overlayed devices not probing because of fw_devlink MAINTAINERS | 3 +- drivers/base/core.c | 108 ++++++++++--- drivers/bus/imx-weim.c | 6 - drivers/bus/simple-pm-bus.c | 24 +-- drivers/clk/Kconfig | 2 +- drivers/i2c/busses/Kconfig | 2 +- drivers/i2c/i2c-core-base.c | 16 ++ drivers/i2c/i2c-core-of.c | 5 - drivers/i2c/i2c-mux.c | 26 ++++ drivers/misc/Kconfig | 11 +- drivers/misc/Makefile | 2 +- drivers/misc/lan966x_evb_lan9662_nic.dtso | 167 ++++++++++++++++++++ drivers/misc/lan966x_pci.c | 30 +++- drivers/misc/lan966x_pci.dtsi | 172 +++++++++++++++++++++ drivers/misc/lan966x_pci.dtso | 177 ---------------------- drivers/of/dynamic.c | 1 - drivers/of/overlay.c | 15 ++ drivers/of/platform.c | 5 - drivers/of/property.c | 26 +++- drivers/pci/of.c | 10 +- drivers/pci/quirks.c | 2 +- drivers/pinctrl/cirrus/pinctrl-cs42l43.c | 2 +- drivers/pmdomain/core.c | 4 +- drivers/spi/spi.c | 5 - include/linux/device.h | 2 +- include/linux/fwnode.h | 7 + include/linux/i2c.h | 3 + include/linux/pci_ids.h | 1 + tools/testing/cxl/test/cxl.c | 4 +- 29 files changed, 584 insertions(+), 254 deletions(-) create mode 100644 drivers/misc/lan966x_evb_lan9662_nic.dtso create mode 100644 drivers/misc/lan966x_pci.dtsi delete mode 100644 drivers/misc/lan966x_pci.dtso -- 2.53.0
null
null
null
[PATCH v5 00/28] lan966x pci device: Add support for SFPs
Recently, new device-tree nodes were added in the overlay to add support for SFPs on LAN966x PCI device. The LAN966X Kconfig help section mentions drivers related to devices added based on the overlay description. Add drivers related to devices described by those new nodes in the already existing driver list. Signed-off-by: Herve Codina <herve.codina@bootlin.com> --- drivers/misc/Kconfig | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig index 9c285a7c88ba..69825dc0f85e 100644 --- a/drivers/misc/Kconfig +++ b/drivers/misc/Kconfig @@ -635,13 +635,18 @@ config MCHP_LAN966X_PCI Even if this driver does not depend on those other drivers, in order to have a fully functional board, the following drivers are needed: - fixed-clock (COMMON_CLK) + - i2c-mux-pinctrl (I2C_MUX_PINCTRL) - lan966x-cpu-syscon (MFD_SYSCON) + - lan966x-gck (COMMON_CLK_LAN966X) - lan966x-miim (MDIO_MSCC_MIIM) - lan966x-oic (LAN966X_OIC) - lan966x-pinctrl (PINCTRL_OCELOT) - lan966x-serdes (PHY_LAN966X_SERDES) - lan966x-switch (LAN966X_SWITCH) - lan966x-switch-reset (RESET_MCHP_SPARX5) + - sam9x60-i2c (I2C_AT91) + - sama5d2-flexcom (MFD_ATMEL_FLEXCOM) + - sfp (SFP) source "drivers/misc/c2port/Kconfig" source "drivers/misc/eeprom/Kconfig" -- 2.53.0
{ "author": "Herve Codina <herve.codina@bootlin.com>", "date": "Fri, 27 Feb 2026 14:54:25 +0100", "is_openbsd": false, "thread_id": "20260227135428.783983-1-herve.codina@bootlin.com.mbox.gz" }
lkml_critique
lkml
Hi, This series add support for SFPs ports available on the LAN966x PCI device. In order to have the SFPs supported, additional devices are needed such as clock controller and I2C. As a reminder, the LAN966x PCI device driver use a device-tree overlay to describe devices available on the PCI board. Adding support for SFPs ports consists in adding more devices in the already existing device-tree overlay. With those devices added, the device-tree overlay is more complex and some consumer/supplier relationship are needed in order to remove devices in correct order when the LAN966x PCI driver is removed. Those links are typically provided by fw_devlink and we faced some issues with fw_devlink and overlays. This series gives the big picture related to the SFPs support from fixing issues to adding new devices. Of course, it can be split if needed. The first part of the series (patch 1, 2 and 3) fixes fw_devlink when it is used with overlay. Patches 1 and 3 were previously sent by Saravana [0]. I rebased them on top of v7.0-rc1 and added patch 2 in order to take into account feedback received on the series sent by Saravana. Also I added a call to driver_deferred_probe_trigger() in Saravana's patch (patch 3) to ensure that probes are retried after the modification performed on the dangling consumers. This allows to fix issues reported by Matti and Geert [2] with the previous iteration patches. Those modification were not sufficient in our case and so, on top of that, patches 4 to 6 fix some more issues related to fw_devlink. Patches 7 to 12 introduce and use fw_devlink_set_device() in already existing code. Patches 13 and 14 are related also to fw_devlink but specific to PCI and the device-tree nodes created during enumeration. Patches 15, 16 and 17 are related fw_devlink too but specific to I2C muxes. Patches purpose is to correctly set a link between an adapter supplier and its consumer. Indeed, an i2c mux adapter's parent is not the i2c mux supplier but the adapter the i2c mux is connected to. Adding a new link between the adapter supplier involved when i2c muxes are used avoid a freeze observed during device removal. Patch 18 adds support for fw_delink on x86. fw_devlink is needed to have the consumer/supplier relationship between devices in order to ensure a correct device removal order. Adding fw_devlink support for x86 has been tried in the past but was reverted [1] because it broke some systems. Instead of enabling fw_devlink on *all* x86 system, enable it on *all* x86 except on those where it leads to issue. Patches 19 and 20 allow to build clock and i2c controller used by the LAN966x PCI device when the LAN966x PCI device is enabled. Patches 21 to 25 are specific to the LAN966x. They touch the current dtso, split it in dtsi/dtso files, rename the dtso and improve the driver to allow easier support for other boards. The next patch (patch 26) update the LAN966x device-tree overlay itself to have the SPF ports and devices they depends on described. The last two patches (patches 27 and 29) sort the existing drivers in the needed driver list available in the Kconfig help and add new drivers in this list keep the list up to date with the devices described in the device-tree overlay. We believe some items from the above list can be merged separately, with no build dependencies. We expect: - Patches 1 to 6 to be taken by driver core maintainers - Patches 7 to 12 to be taken by driver core maintainers - Patches 13 and 14 to be taken by driver core or PCI maintainers (depend on patch 7) - Patches 15 to 17 to be taken by I2C maintainers - Patch 18 to be taken by driver core or OF maintainers - Patch 19 to be taken by clock maintainers - Patch 20 to be taken by I2C maintainers - Patches 21 to 28 to be taken by misc maintainers Once again, this series gives the big picture and can be split if needed. Let me know. Compare to previous iteration, this v5 series mainly: - Handle Matti and Geert use cases [2] - Remove simple-platform-bus driver introduced in v4 and switch the simple-bus modification back to what was proposed in v3. In the v4 iteration, conclusion was to use v3 changes [3]. [0] https://lore.kernel.org/lkml/20240411235623.1260061-1-saravanak@google.com/ [1] https://lore.kernel.org/lkml/3c1f2473-92ad-bfc4-258e-a5a08ad73dd0@web.de/ [2] https://lore.kernel.org/all/072dde7c-a53c-4525-83ac-57ea38edc0b5@gmail.com/ [3] https://lore.kernel.org/lkml/20251114083056.31553866@bootlin.com/ Best regards, Hervé Changes: v4 -> v5 v4: https://lore.kernel.org/lkml/20251015071420.1173068-1-herve.codina@bootlin.com/ - Patch 2: Add 'Acked-by: Ulf Hansson' - Patch 3: Add a call to driver_deferred_probe_trigger() - Patch 5: (new patch) Depopulate devices at remove - Patch 6: Populate devices at probe. Switched back to modification proposed in v3 - Patch 7 in v3 removed - Patch 7 (8 in v4): Add 'Reviewed-by: Andy Shevchenko' Add 'Reviewed-by: Ulf Hansson' - Patch 8 (9 in v4): Add 'Reviewed-by: Ulf Hansson' - Patches 9 to 15 (10 to 16 in v3) No changes - Patch 16 (17 in v4): Add 'Reviewed-by: Andi Shyti' - Patch 17 (18 in v4): Change an error code from -EINVAL to -ENODEV Add a blank line and fix a typo in commit log - Patch 18 (19 in v4): Simplify of_is_fwnode_add_links_supported(). Move IS_ENABLED(CONFIG_X86) check in of_is_fwnode_add_links_supported(). - Patches 19 to 21 (20 to 22 in v4) No changes - Patch 22 (23 in v4) Update due to simple-platform-bus removal - Patches 23 to 28 (24 to 29 in v4) No changes v3 -> v4 v3: https://lore.kernel.org/lkml/20250613134817.681832-1-herve.codina@bootlin.com/ - Patch 1: No change - Patch 2: Update and fix conflicts. Indeed, since v3 iteration get_dev_from_fwnode() has been moved to device.h and used by pmdomain/core.c. - Patch 3: remove '#define get_device_from_fwnode()' - Patch 4: Fix conflict (rebase v6.17-rc6) Add 'Reviewed-by: Rafael J. Wysocki' Add 'Reviewed-by: Saravana Kannan' - Patch 5 (new in v4): Introduce simple-platform-bus (binding) - Patch 6 (5 in v3): Rework patch and introduce simple-platform-bus - Patch 7: (new) Use simple-platform-bus in LAN966x - Patch 8 (6 in v3): - No change - Patch 9 and 10 (7 and 8 in v3): Add 'Reviewed-by: Andy Shevchenko' - Patch 11 and 12 (9 and 10 in v3): Add 'Reviewed-by: Dave Jiang' - Patch 13 (11 in v3): Add 'Reviewed-by: Andy Shevchenko' - Patch 12 in v3: Patch removed. Adding __private tag in fwnode.dev is going to be handled in a dedicated series. Indeed a test robot reported an issue and more patches are needed (I have missed fwnode.dev users in several part in the kernel). - Patch 14 and 15 (13 and 14 in v3): No change - Patch 16 (14 in v3): Add 'Reviewed-by: Andi Shyti' - Patch 17 and 18 (16 and 17 in v3): No change - Patch 19 (18 in v3): Filter out support for fw_devlink on x86 based on some device-tree properties. Rewrite commit changelog Remove 'Reviewed-by: Andy Shevchenko' (significant modification) - Patch 20 (19 in v3): Add 'Acked-by: Stephen Boyd' - Patch 21 (20 in v3): Fix conflict (rebase v6.18-rc1) - Patches 22 to 24 (21 to 23 in v3): No change - Patch 25 (24 in v3): Fix conflict (rebase v6.18-rc1) Add 'Acked-by: Bjorn Helgaas' - Patches 26 to 29 (25 to 28 in v3): No change v2 -> v3 v2: https://lore.kernel.org/all/20250507071315.394857-1-herve.codina@bootlin.com/ - Patch 1: Add 'Acked-by: Mark Brown' - Patch 2 and 3: No changes - Patch 4: Rewrite the WARN_ON() condition to avoid an additional 'if' - Patch 5: Fix typos in commit log Update a comment Remove the unneeded check before calling of_platform_depopulate() - Patches 6 to 11: No changes - Patch 12 (new in v3) Tag the fwnode dev member as private - Patch 13 (12 in v2) Fix a typo in the commit log - Patches 14 to 16 (13 to 15 in v2) No changes - Patch 17 (16 in v2) Check parent_physdev for NULL - Patch 18 (17 in v2) Capitalize "Link:" Add 'Reviewed-by: Andy Shevchenko' - Patch 19 (18 in v2) No changes - Patch 20 (19 in v2) Add 'Acked-by: Andi Shyti' - Patch 21 (20 in v2) No changes - Patch 22 (21 in v2) Add 'Reviewed-by: Andrew Lunn' - Patch 23 (22 in v2) Add 'Reviewed-by: Andrew Lunn' - Patch 24 (new in v3) Introduce PCI_DEVICE_ID_EFAR_LAN9662, the LAN966x PCI device ID - Patch 25 (23 in v2) Add 'Reviewed-by: Andrew Lunn' Use PCI_DEVICE_DATA() with PCI_DEVICE_ID_EFAR_LAN9662 instead of PCI_VDEVICE() - Patch 26 to 28 (24 to 26 in v2) No changes v1 -> v2 v1: https://lore.kernel.org/lkml/20250407145546.270683-1-herve.codina@bootlin.com/ - Patch 1 and 3 Remove 'From' tag from the commit log - Patch 2 Add 'Reviewed-by: Andy Shevchenko' Add 'Reviewed-by: Saravana Kannan' Add 'Reviewed-by: Luca Ceresoli' - Patch 4 and 5 No changes - Patch 6 (new in v2) Introduce fw_devlink_set_device() - Patch 7 (new in v2) Use existing device_set_node() helper. - Patch 8 to 11 (new in v2) Use fw_devlink_set_device() in existing code. - Patch 12 (6 in v1) Use fw_devlink_add_device() - Patch 13 (7 in v1) No changes - Patch 14 (8 in v1) Update commit log Use 'physdev' instead of 'supplier' Minor fixes in i2c_get_adapter_physdev() kdoc - Patch 15 and 16 (9 and 10 in v1) Use 'physdev' instead of 'supplier' (commit log, title and code) - Patch 17 (11 in v2) Enable fw_devlink on x86 only if PCI_DYNAMIC_OF_NODES is enabled. Rework commit log. - Patch 18, 19 and 20 (12, 13 and 14 in v1) No changes - Patch 21 (new in v2) Split dtso in dtsi/dtso - Patch 22 (new in v2) Rename lan966x_pci.dtso using the specific board name - Patch 23 (new in v2) Improve the driver introducing board specific data to ease support for other boards (avoid the direct dtbo reference in the function loading the dtbo). - Patch 24 (15 in v1) Refactor due to dtso split in dtsi/dtso - Patch 25 (new in v2) Sort exist driver list in Kconfig help - Patch 26 (16 in v1) Keep alphanumeric order for new drivers added in Kconfig help Herve Codina (26): driver core: Rename get_dev_from_fwnode() wrapper to get_device_from_fwnode() driver core: Avoid warning when removing a device while its supplier is unbinding bus: simple-pm-bus: Remove child devices when the bus is unbound bus: simple-pm-bus: Populate child nodes at probe driver core: fw_devlink: Introduce fw_devlink_set_device() drivers: core: Use fw_devlink_set_device() pinctrl: cs42l43: Use fw_devlink_set_device() cxl/test: Use device_set_node() cxl/test: Use fw_devlink_set_device() PCI: of: Use fw_devlink_set_device() PCI: of: Set fwnode device of newly created PCI device nodes PCI: of: Remove fwnode_dev_initialized() call for a PCI root bridge node i2c: core: Introduce i2c_get_adapter_physdev() i2c: mux: Set adapter physical device i2c: mux: Create missing devlink between mux and adapter physical device of: property: Allow fw_devlink device-tree on x86 clk: lan966x: Add MCHP_LAN966X_PCI dependency i2c: busses: at91: Add MCHP_LAN966X_PCI dependency misc: lan966x_pci: Fix dtso nodes ordering misc: lan966x_pci: Split dtso in dtsi/dtso misc: lan966x_pci: Rename lan966x_pci.dtso to lan966x_evb_lan9662_nic.dtso PCI: Add Microchip LAN9662 PCI Device ID misc: lan966x_pci: Introduce board specific data misc: lan966x_pci: Add dtsi/dtso nodes in order to support SFPs misc: lan966x_pci: Sort the drivers list in Kconfig help misc: lan966x_pci: Add drivers needed to support SFPs in Kconfig help Saravana Kannan (2): Revert "treewide: Fix probing of devices in DT overlays" of: dynamic: Fix overlayed devices not probing because of fw_devlink MAINTAINERS | 3 +- drivers/base/core.c | 108 ++++++++++--- drivers/bus/imx-weim.c | 6 - drivers/bus/simple-pm-bus.c | 24 +-- drivers/clk/Kconfig | 2 +- drivers/i2c/busses/Kconfig | 2 +- drivers/i2c/i2c-core-base.c | 16 ++ drivers/i2c/i2c-core-of.c | 5 - drivers/i2c/i2c-mux.c | 26 ++++ drivers/misc/Kconfig | 11 +- drivers/misc/Makefile | 2 +- drivers/misc/lan966x_evb_lan9662_nic.dtso | 167 ++++++++++++++++++++ drivers/misc/lan966x_pci.c | 30 +++- drivers/misc/lan966x_pci.dtsi | 172 +++++++++++++++++++++ drivers/misc/lan966x_pci.dtso | 177 ---------------------- drivers/of/dynamic.c | 1 - drivers/of/overlay.c | 15 ++ drivers/of/platform.c | 5 - drivers/of/property.c | 26 +++- drivers/pci/of.c | 10 +- drivers/pci/quirks.c | 2 +- drivers/pinctrl/cirrus/pinctrl-cs42l43.c | 2 +- drivers/pmdomain/core.c | 4 +- drivers/spi/spi.c | 5 - include/linux/device.h | 2 +- include/linux/fwnode.h | 7 + include/linux/i2c.h | 3 + include/linux/pci_ids.h | 1 + tools/testing/cxl/test/cxl.c | 4 +- 29 files changed, 584 insertions(+), 254 deletions(-) create mode 100644 drivers/misc/lan966x_evb_lan9662_nic.dtso create mode 100644 drivers/misc/lan966x_pci.dtsi delete mode 100644 drivers/misc/lan966x_pci.dtso -- 2.53.0
null
null
null
[PATCH v5 00/28] lan966x pci device: Add support for SFPs
On Fri, Feb 27, 2026 at 2:57 PM Herve Codina <herve.codina@bootlin.com> wrote: Acked-by: Linus Walleij <linusw@kernel.org> Tell me if I should apply this directly to the pinctrl tree, right now I'm under the impression that all patches need to go in together? Yours, Linus Walleij
{ "author": "Linus Walleij <linusw@kernel.org>", "date": "Fri, 27 Feb 2026 15:11:13 +0100", "is_openbsd": false, "thread_id": "20260227135428.783983-1-herve.codina@bootlin.com.mbox.gz" }
lkml_critique
lkml
Hi, This series add support for SFPs ports available on the LAN966x PCI device. In order to have the SFPs supported, additional devices are needed such as clock controller and I2C. As a reminder, the LAN966x PCI device driver use a device-tree overlay to describe devices available on the PCI board. Adding support for SFPs ports consists in adding more devices in the already existing device-tree overlay. With those devices added, the device-tree overlay is more complex and some consumer/supplier relationship are needed in order to remove devices in correct order when the LAN966x PCI driver is removed. Those links are typically provided by fw_devlink and we faced some issues with fw_devlink and overlays. This series gives the big picture related to the SFPs support from fixing issues to adding new devices. Of course, it can be split if needed. The first part of the series (patch 1, 2 and 3) fixes fw_devlink when it is used with overlay. Patches 1 and 3 were previously sent by Saravana [0]. I rebased them on top of v7.0-rc1 and added patch 2 in order to take into account feedback received on the series sent by Saravana. Also I added a call to driver_deferred_probe_trigger() in Saravana's patch (patch 3) to ensure that probes are retried after the modification performed on the dangling consumers. This allows to fix issues reported by Matti and Geert [2] with the previous iteration patches. Those modification were not sufficient in our case and so, on top of that, patches 4 to 6 fix some more issues related to fw_devlink. Patches 7 to 12 introduce and use fw_devlink_set_device() in already existing code. Patches 13 and 14 are related also to fw_devlink but specific to PCI and the device-tree nodes created during enumeration. Patches 15, 16 and 17 are related fw_devlink too but specific to I2C muxes. Patches purpose is to correctly set a link between an adapter supplier and its consumer. Indeed, an i2c mux adapter's parent is not the i2c mux supplier but the adapter the i2c mux is connected to. Adding a new link between the adapter supplier involved when i2c muxes are used avoid a freeze observed during device removal. Patch 18 adds support for fw_delink on x86. fw_devlink is needed to have the consumer/supplier relationship between devices in order to ensure a correct device removal order. Adding fw_devlink support for x86 has been tried in the past but was reverted [1] because it broke some systems. Instead of enabling fw_devlink on *all* x86 system, enable it on *all* x86 except on those where it leads to issue. Patches 19 and 20 allow to build clock and i2c controller used by the LAN966x PCI device when the LAN966x PCI device is enabled. Patches 21 to 25 are specific to the LAN966x. They touch the current dtso, split it in dtsi/dtso files, rename the dtso and improve the driver to allow easier support for other boards. The next patch (patch 26) update the LAN966x device-tree overlay itself to have the SPF ports and devices they depends on described. The last two patches (patches 27 and 29) sort the existing drivers in the needed driver list available in the Kconfig help and add new drivers in this list keep the list up to date with the devices described in the device-tree overlay. We believe some items from the above list can be merged separately, with no build dependencies. We expect: - Patches 1 to 6 to be taken by driver core maintainers - Patches 7 to 12 to be taken by driver core maintainers - Patches 13 and 14 to be taken by driver core or PCI maintainers (depend on patch 7) - Patches 15 to 17 to be taken by I2C maintainers - Patch 18 to be taken by driver core or OF maintainers - Patch 19 to be taken by clock maintainers - Patch 20 to be taken by I2C maintainers - Patches 21 to 28 to be taken by misc maintainers Once again, this series gives the big picture and can be split if needed. Let me know. Compare to previous iteration, this v5 series mainly: - Handle Matti and Geert use cases [2] - Remove simple-platform-bus driver introduced in v4 and switch the simple-bus modification back to what was proposed in v3. In the v4 iteration, conclusion was to use v3 changes [3]. [0] https://lore.kernel.org/lkml/20240411235623.1260061-1-saravanak@google.com/ [1] https://lore.kernel.org/lkml/3c1f2473-92ad-bfc4-258e-a5a08ad73dd0@web.de/ [2] https://lore.kernel.org/all/072dde7c-a53c-4525-83ac-57ea38edc0b5@gmail.com/ [3] https://lore.kernel.org/lkml/20251114083056.31553866@bootlin.com/ Best regards, Hervé Changes: v4 -> v5 v4: https://lore.kernel.org/lkml/20251015071420.1173068-1-herve.codina@bootlin.com/ - Patch 2: Add 'Acked-by: Ulf Hansson' - Patch 3: Add a call to driver_deferred_probe_trigger() - Patch 5: (new patch) Depopulate devices at remove - Patch 6: Populate devices at probe. Switched back to modification proposed in v3 - Patch 7 in v3 removed - Patch 7 (8 in v4): Add 'Reviewed-by: Andy Shevchenko' Add 'Reviewed-by: Ulf Hansson' - Patch 8 (9 in v4): Add 'Reviewed-by: Ulf Hansson' - Patches 9 to 15 (10 to 16 in v3) No changes - Patch 16 (17 in v4): Add 'Reviewed-by: Andi Shyti' - Patch 17 (18 in v4): Change an error code from -EINVAL to -ENODEV Add a blank line and fix a typo in commit log - Patch 18 (19 in v4): Simplify of_is_fwnode_add_links_supported(). Move IS_ENABLED(CONFIG_X86) check in of_is_fwnode_add_links_supported(). - Patches 19 to 21 (20 to 22 in v4) No changes - Patch 22 (23 in v4) Update due to simple-platform-bus removal - Patches 23 to 28 (24 to 29 in v4) No changes v3 -> v4 v3: https://lore.kernel.org/lkml/20250613134817.681832-1-herve.codina@bootlin.com/ - Patch 1: No change - Patch 2: Update and fix conflicts. Indeed, since v3 iteration get_dev_from_fwnode() has been moved to device.h and used by pmdomain/core.c. - Patch 3: remove '#define get_device_from_fwnode()' - Patch 4: Fix conflict (rebase v6.17-rc6) Add 'Reviewed-by: Rafael J. Wysocki' Add 'Reviewed-by: Saravana Kannan' - Patch 5 (new in v4): Introduce simple-platform-bus (binding) - Patch 6 (5 in v3): Rework patch and introduce simple-platform-bus - Patch 7: (new) Use simple-platform-bus in LAN966x - Patch 8 (6 in v3): - No change - Patch 9 and 10 (7 and 8 in v3): Add 'Reviewed-by: Andy Shevchenko' - Patch 11 and 12 (9 and 10 in v3): Add 'Reviewed-by: Dave Jiang' - Patch 13 (11 in v3): Add 'Reviewed-by: Andy Shevchenko' - Patch 12 in v3: Patch removed. Adding __private tag in fwnode.dev is going to be handled in a dedicated series. Indeed a test robot reported an issue and more patches are needed (I have missed fwnode.dev users in several part in the kernel). - Patch 14 and 15 (13 and 14 in v3): No change - Patch 16 (14 in v3): Add 'Reviewed-by: Andi Shyti' - Patch 17 and 18 (16 and 17 in v3): No change - Patch 19 (18 in v3): Filter out support for fw_devlink on x86 based on some device-tree properties. Rewrite commit changelog Remove 'Reviewed-by: Andy Shevchenko' (significant modification) - Patch 20 (19 in v3): Add 'Acked-by: Stephen Boyd' - Patch 21 (20 in v3): Fix conflict (rebase v6.18-rc1) - Patches 22 to 24 (21 to 23 in v3): No change - Patch 25 (24 in v3): Fix conflict (rebase v6.18-rc1) Add 'Acked-by: Bjorn Helgaas' - Patches 26 to 29 (25 to 28 in v3): No change v2 -> v3 v2: https://lore.kernel.org/all/20250507071315.394857-1-herve.codina@bootlin.com/ - Patch 1: Add 'Acked-by: Mark Brown' - Patch 2 and 3: No changes - Patch 4: Rewrite the WARN_ON() condition to avoid an additional 'if' - Patch 5: Fix typos in commit log Update a comment Remove the unneeded check before calling of_platform_depopulate() - Patches 6 to 11: No changes - Patch 12 (new in v3) Tag the fwnode dev member as private - Patch 13 (12 in v2) Fix a typo in the commit log - Patches 14 to 16 (13 to 15 in v2) No changes - Patch 17 (16 in v2) Check parent_physdev for NULL - Patch 18 (17 in v2) Capitalize "Link:" Add 'Reviewed-by: Andy Shevchenko' - Patch 19 (18 in v2) No changes - Patch 20 (19 in v2) Add 'Acked-by: Andi Shyti' - Patch 21 (20 in v2) No changes - Patch 22 (21 in v2) Add 'Reviewed-by: Andrew Lunn' - Patch 23 (22 in v2) Add 'Reviewed-by: Andrew Lunn' - Patch 24 (new in v3) Introduce PCI_DEVICE_ID_EFAR_LAN9662, the LAN966x PCI device ID - Patch 25 (23 in v2) Add 'Reviewed-by: Andrew Lunn' Use PCI_DEVICE_DATA() with PCI_DEVICE_ID_EFAR_LAN9662 instead of PCI_VDEVICE() - Patch 26 to 28 (24 to 26 in v2) No changes v1 -> v2 v1: https://lore.kernel.org/lkml/20250407145546.270683-1-herve.codina@bootlin.com/ - Patch 1 and 3 Remove 'From' tag from the commit log - Patch 2 Add 'Reviewed-by: Andy Shevchenko' Add 'Reviewed-by: Saravana Kannan' Add 'Reviewed-by: Luca Ceresoli' - Patch 4 and 5 No changes - Patch 6 (new in v2) Introduce fw_devlink_set_device() - Patch 7 (new in v2) Use existing device_set_node() helper. - Patch 8 to 11 (new in v2) Use fw_devlink_set_device() in existing code. - Patch 12 (6 in v1) Use fw_devlink_add_device() - Patch 13 (7 in v1) No changes - Patch 14 (8 in v1) Update commit log Use 'physdev' instead of 'supplier' Minor fixes in i2c_get_adapter_physdev() kdoc - Patch 15 and 16 (9 and 10 in v1) Use 'physdev' instead of 'supplier' (commit log, title and code) - Patch 17 (11 in v2) Enable fw_devlink on x86 only if PCI_DYNAMIC_OF_NODES is enabled. Rework commit log. - Patch 18, 19 and 20 (12, 13 and 14 in v1) No changes - Patch 21 (new in v2) Split dtso in dtsi/dtso - Patch 22 (new in v2) Rename lan966x_pci.dtso using the specific board name - Patch 23 (new in v2) Improve the driver introducing board specific data to ease support for other boards (avoid the direct dtbo reference in the function loading the dtbo). - Patch 24 (15 in v1) Refactor due to dtso split in dtsi/dtso - Patch 25 (new in v2) Sort exist driver list in Kconfig help - Patch 26 (16 in v1) Keep alphanumeric order for new drivers added in Kconfig help Herve Codina (26): driver core: Rename get_dev_from_fwnode() wrapper to get_device_from_fwnode() driver core: Avoid warning when removing a device while its supplier is unbinding bus: simple-pm-bus: Remove child devices when the bus is unbound bus: simple-pm-bus: Populate child nodes at probe driver core: fw_devlink: Introduce fw_devlink_set_device() drivers: core: Use fw_devlink_set_device() pinctrl: cs42l43: Use fw_devlink_set_device() cxl/test: Use device_set_node() cxl/test: Use fw_devlink_set_device() PCI: of: Use fw_devlink_set_device() PCI: of: Set fwnode device of newly created PCI device nodes PCI: of: Remove fwnode_dev_initialized() call for a PCI root bridge node i2c: core: Introduce i2c_get_adapter_physdev() i2c: mux: Set adapter physical device i2c: mux: Create missing devlink between mux and adapter physical device of: property: Allow fw_devlink device-tree on x86 clk: lan966x: Add MCHP_LAN966X_PCI dependency i2c: busses: at91: Add MCHP_LAN966X_PCI dependency misc: lan966x_pci: Fix dtso nodes ordering misc: lan966x_pci: Split dtso in dtsi/dtso misc: lan966x_pci: Rename lan966x_pci.dtso to lan966x_evb_lan9662_nic.dtso PCI: Add Microchip LAN9662 PCI Device ID misc: lan966x_pci: Introduce board specific data misc: lan966x_pci: Add dtsi/dtso nodes in order to support SFPs misc: lan966x_pci: Sort the drivers list in Kconfig help misc: lan966x_pci: Add drivers needed to support SFPs in Kconfig help Saravana Kannan (2): Revert "treewide: Fix probing of devices in DT overlays" of: dynamic: Fix overlayed devices not probing because of fw_devlink MAINTAINERS | 3 +- drivers/base/core.c | 108 ++++++++++--- drivers/bus/imx-weim.c | 6 - drivers/bus/simple-pm-bus.c | 24 +-- drivers/clk/Kconfig | 2 +- drivers/i2c/busses/Kconfig | 2 +- drivers/i2c/i2c-core-base.c | 16 ++ drivers/i2c/i2c-core-of.c | 5 - drivers/i2c/i2c-mux.c | 26 ++++ drivers/misc/Kconfig | 11 +- drivers/misc/Makefile | 2 +- drivers/misc/lan966x_evb_lan9662_nic.dtso | 167 ++++++++++++++++++++ drivers/misc/lan966x_pci.c | 30 +++- drivers/misc/lan966x_pci.dtsi | 172 +++++++++++++++++++++ drivers/misc/lan966x_pci.dtso | 177 ---------------------- drivers/of/dynamic.c | 1 - drivers/of/overlay.c | 15 ++ drivers/of/platform.c | 5 - drivers/of/property.c | 26 +++- drivers/pci/of.c | 10 +- drivers/pci/quirks.c | 2 +- drivers/pinctrl/cirrus/pinctrl-cs42l43.c | 2 +- drivers/pmdomain/core.c | 4 +- drivers/spi/spi.c | 5 - include/linux/device.h | 2 +- include/linux/fwnode.h | 7 + include/linux/i2c.h | 3 + include/linux/pci_ids.h | 1 + tools/testing/cxl/test/cxl.c | 4 +- 29 files changed, 584 insertions(+), 254 deletions(-) create mode 100644 drivers/misc/lan966x_evb_lan9662_nic.dtso create mode 100644 drivers/misc/lan966x_pci.dtsi delete mode 100644 drivers/misc/lan966x_pci.dtso -- 2.53.0
null
null
null
[PATCH v5 00/28] lan966x pci device: Add support for SFPs
Hi Linus, On Fri, 27 Feb 2026 15:11:13 +0100 Linus Walleij <linusw@kernel.org> wrote: This patch depends on patch 7. I think it could make sense to have patches 7 to 12 applied by the same maintainer. Best regards, Hervé
{ "author": "Herve Codina <herve.codina@bootlin.com>", "date": "Fri, 27 Feb 2026 15:22:49 +0100", "is_openbsd": false, "thread_id": "20260227135428.783983-1-herve.codina@bootlin.com.mbox.gz" }
lkml_critique
lkml
Enhance the readability of IOMUXC_SW_PAD_CTL_PAD configuration by using symbolic macros instead of magic values. First patch makes MX8MP_I2C_DEFAULT independent of DS so it can be re-used in multiple places. Second patch makes uses on the macros introduce with: 31ff1060175c458 ("arm64: dts: imx8mp: Add pinctrl config definitions") in order to make code easier to read and understand. This is just an RFC to get your opinin on the idea. If this gets positive feedback will continue to update the rest of the dts files. Daniel Baluta (2): arm64: dts: imx8mp: Make MX8MP_I2C_DEFAULT independent on drive strength arm64: dts: imx8mp-frdm: Use symbolic macros for IOMUXC_SW_PAD_CTL_PAD arch/arm64/boot/dts/freescale/imx8mp-frdm.dts | 132 +++++++++++------- .../arm64/boot/dts/freescale/imx8mp-pinfunc.h | 4 +- .../imx8mp-tx8p-ml81-moduline-display-106.dts | 16 +-- .../boot/dts/freescale/imx8mp-tx8p-ml81.dtsi | 8 +- 4 files changed, 99 insertions(+), 61 deletions(-) -- 2.45.2
null
null
null
[RFC PATCH 0/2] imx8mp-frdm: Enhance code readability
Currently MX8MP_I2C_DEFAULT macro includes a fixed drive strength (MX8MP_DSE_X6) thus limiting its use to only I2C pins that require X6 drive. There are many pinctrl configurations for I2C that use different drive strength while still using the common I2C default configurations (pull-up, Schmitt input, pull enable, SION). So make the MX8MP_I2C_DEFAULT macro more flexible and reusable by removing DSE_X6 drive strength from it's definition but add it in all places it is necessary. Signed-off-by: Daniel Baluta <daniel.baluta@nxp.com> --- arch/arm64/boot/dts/freescale/imx8mp-pinfunc.h | 2 +- .../imx8mp-tx8p-ml81-moduline-display-106.dts | 16 ++++++++-------- .../boot/dts/freescale/imx8mp-tx8p-ml81.dtsi | 8 ++++---- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/arch/arm64/boot/dts/freescale/imx8mp-pinfunc.h b/arch/arm64/boot/dts/freescale/imx8mp-pinfunc.h index 16f5899de4152..26e7a9428c4c7 100644 --- a/arch/arm64/boot/dts/freescale/imx8mp-pinfunc.h +++ b/arch/arm64/boot/dts/freescale/imx8mp-pinfunc.h @@ -36,7 +36,7 @@ /* long defaults */ #define MX8MP_USDHC_DATA_DEFAULT (MX8MP_FSEL_FAST | MX8MP_PULL_UP | \ MX8MP_HYS_SCHMITT | MX8MP_PULL_ENABLE) -#define MX8MP_I2C_DEFAULT (MX8MP_DSE_X6 | MX8MP_PULL_UP | MX8MP_HYS_SCHMITT | \ +#define MX8MP_I2C_DEFAULT (MX8MP_PULL_UP | MX8MP_HYS_SCHMITT | \ MX8MP_PULL_ENABLE | MX8MP_SION) /* diff --git a/arch/arm64/boot/dts/freescale/imx8mp-tx8p-ml81-moduline-display-106.dts b/arch/arm64/boot/dts/freescale/imx8mp-tx8p-ml81-moduline-display-106.dts index 399230144ce39..87b20b8564583 100644 --- a/arch/arm64/boot/dts/freescale/imx8mp-tx8p-ml81-moduline-display-106.dts +++ b/arch/arm64/boot/dts/freescale/imx8mp-tx8p-ml81-moduline-display-106.dts @@ -302,36 +302,36 @@ MX8MP_IOMUXC_ECSPI1_SS0__GPIO5_IO09 pinctrl_i2c2: i2c2grp { fsl,pins = < MX8MP_IOMUXC_I2C2_SCL__I2C2_SCL - MX8MP_I2C_DEFAULT + (MX8MP_DSE_X6 | MX8MP_I2C_DEFAULT) MX8MP_IOMUXC_I2C2_SDA__I2C2_SDA - MX8MP_I2C_DEFAULT + (MX8MP_DSE_X6 | MX8MP_I2C_DEFAULT) }; pinctrl_i2c2_gpio: i2c2-gpiogrp { fsl,pins = < MX8MP_IOMUXC_I2C2_SCL__GPIO5_IO16 - MX8MP_I2C_DEFAULT + (MX8MP_DSE_X6 | MX8MP_I2C_DEFAULT) MX8MP_IOMUXC_I2C2_SDA__GPIO5_IO17 - MX8MP_I2C_DEFAULT + (MX8MP_DSE_X6 | MX8MP_I2C_DEFAULT) }; pinctrl_i2c4: i2c4grp { fsl,pins = < MX8MP_IOMUXC_ECSPI2_MISO__I2C4_SCL - MX8MP_I2C_DEFAULT + (MX8MP_DSE_X6 | MX8MP_I2C_DEFAULT) MX8MP_IOMUXC_ECSPI2_SS0__I2C4_SDA - MX8MP_I2C_DEFAULT + (MX8MP_DSE_X6 | MX8MP_I2C_DEFAULT) }; pinctrl_i2c4_gpio: i2c4-gpiogrp { fsl,pins = < MX8MP_IOMUXC_ECSPI2_MISO__GPIO5_IO12 - MX8MP_I2C_DEFAULT + (MX8MP_DSE_X6 | MX8MP_I2C_DEFAULT) MX8MP_IOMUXC_ECSPI2_SS0__GPIO5_IO13 - MX8MP_I2C_DEFAULT + (MX8MP_DSE_X6 | MX8MP_I2C_DEFAULT) }; diff --git a/arch/arm64/boot/dts/freescale/imx8mp-tx8p-ml81.dtsi b/arch/arm64/boot/dts/freescale/imx8mp-tx8p-ml81.dtsi index 761ee046eb72e..bf49ae942d411 100644 --- a/arch/arm64/boot/dts/freescale/imx8mp-tx8p-ml81.dtsi +++ b/arch/arm64/boot/dts/freescale/imx8mp-tx8p-ml81.dtsi @@ -425,18 +425,18 @@ MX8MP_IOMUXC_SAI2_RXC__GPIO4_IO22 pinctrl_i2c1: i2c1grp { fsl,pins = < MX8MP_IOMUXC_I2C1_SCL__I2C1_SCL - MX8MP_I2C_DEFAULT + (MX8MP_DSE_X6 | MX8MP_I2C_DEFAULT) MX8MP_IOMUXC_I2C1_SDA__I2C1_SDA - MX8MP_I2C_DEFAULT + (MX8MP_DSE_X6 | MX8MP_I2C_DEFAULT) }; pinctrl_i2c1_gpio: i2c1-gpiogrp { fsl,pins = < MX8MP_IOMUXC_I2C1_SCL__GPIO5_IO14 - MX8MP_I2C_DEFAULT + (MX8MP_DSE_X6 | MX8MP_I2C_DEFAULT) MX8MP_IOMUXC_I2C1_SDA__GPIO5_IO15 - MX8MP_I2C_DEFAULT + (MX8MP_DSE_X6 | MX8MP_I2C_DEFAULT) }; -- 2.45.2
{ "author": "Daniel Baluta <daniel.baluta@nxp.com>", "date": "Fri, 27 Feb 2026 15:02:41 +0200", "is_openbsd": false, "thread_id": "aaGzj11fjemaKLrQ@lizhi-Precision-Tower-5810.mbox.gz" }
lkml_critique
lkml
Enhance the readability of IOMUXC_SW_PAD_CTL_PAD configuration by using symbolic macros instead of magic values. First patch makes MX8MP_I2C_DEFAULT independent of DS so it can be re-used in multiple places. Second patch makes uses on the macros introduce with: 31ff1060175c458 ("arm64: dts: imx8mp: Add pinctrl config definitions") in order to make code easier to read and understand. This is just an RFC to get your opinin on the idea. If this gets positive feedback will continue to update the rest of the dts files. Daniel Baluta (2): arm64: dts: imx8mp: Make MX8MP_I2C_DEFAULT independent on drive strength arm64: dts: imx8mp-frdm: Use symbolic macros for IOMUXC_SW_PAD_CTL_PAD arch/arm64/boot/dts/freescale/imx8mp-frdm.dts | 132 +++++++++++------- .../arm64/boot/dts/freescale/imx8mp-pinfunc.h | 4 +- .../imx8mp-tx8p-ml81-moduline-display-106.dts | 16 +-- .../boot/dts/freescale/imx8mp-tx8p-ml81.dtsi | 8 +- 4 files changed, 99 insertions(+), 61 deletions(-) -- 2.45.2
null
null
null
[RFC PATCH 0/2] imx8mp-frdm: Enhance code readability
Currently, in order to configure IOMUXC_SW_PAD_CTL_PAD a magic raw value is written in this register. This makes code not obvious to read and modify. So, to help with code readability instead of the magic values use symbolic macros. Signed-off-by: Daniel Baluta <daniel.baluta@nxp.com> --- arch/arm64/boot/dts/freescale/imx8mp-frdm.dts | 132 +++++++++++------- .../arm64/boot/dts/freescale/imx8mp-pinfunc.h | 2 + 2 files changed, 86 insertions(+), 48 deletions(-) diff --git a/arch/arm64/boot/dts/freescale/imx8mp-frdm.dts b/arch/arm64/boot/dts/freescale/imx8mp-frdm.dts index 55690f5e53d7e..206c8d939796e 100644 --- a/arch/arm64/boot/dts/freescale/imx8mp-frdm.dts +++ b/arch/arm64/boot/dts/freescale/imx8mp-frdm.dts @@ -252,104 +252,140 @@ &usdhc3 { &iomuxc { pinctrl_i2c1: i2c1grp { fsl,pins = < - MX8MP_IOMUXC_I2C1_SCL__I2C1_SCL 0x400001c2 - MX8MP_IOMUXC_I2C1_SDA__I2C1_SDA 0x400001c2 + MX8MP_IOMUXC_I2C1_SCL__I2C1_SCL (MX8MP_DSE_X4 | MX8MP_I2C_DEFAULT) + MX8MP_IOMUXC_I2C1_SDA__I2C1_SDA (MX8MP_DSE_X4 | MX8MP_I2C_DEFAULT) }; pinctrl_i2c2: i2c2grp { fsl,pins = < - MX8MP_IOMUXC_I2C2_SCL__I2C2_SCL 0x400001c2 - MX8MP_IOMUXC_I2C2_SDA__I2C2_SDA 0x400001c2 + MX8MP_IOMUXC_I2C2_SCL__I2C2_SCL (MX8MP_DSE_X4 | MX8MP_I2C_DEFAULT) + MX8MP_IOMUXC_I2C2_SDA__I2C2_SDA (MX8MP_DSE_X4 | MX8MP_I2C_DEFAULT) }; pinctrl_i2c3: i2c3grp { fsl,pins = < - MX8MP_IOMUXC_I2C3_SCL__I2C3_SCL 0x400001c2 - MX8MP_IOMUXC_I2C3_SDA__I2C3_SDA 0x400001c2 + MX8MP_IOMUXC_I2C3_SCL__I2C3_SCL (MX8MP_DSE_X4 | MX8MP_I2C_DEFAULT) + MX8MP_IOMUXC_I2C3_SDA__I2C3_SDA (MX8MP_DSE_X4 | MX8MP_I2C_DEFAULT) }; pinctrl_pmic: pmicgrp { fsl,pins = < - MX8MP_IOMUXC_GPIO1_IO03__GPIO1_IO03 0x000001c0 + MX8MP_IOMUXC_GPIO1_IO03__GPIO1_IO03 + (MX8MP_PULL_UP | MX8MP_HYS_SCHMITT | MX8MP_PULL_ENABLE) }; pinctrl_pcal6416_0_int: pcal6416-0-int-grp { fsl,pins = < - MX8MP_IOMUXC_NAND_READY_B__GPIO3_IO16 0x146 + MX8MP_IOMUXC_NAND_READY_B__GPIO3_IO16 + (MX8MP_DSE_X6 | MX8MP_PULL_UP | MX8MP_PULL_ENABLE) }; pinctrl_pcal6416_1_int: pcal6416-1-int-grp { fsl,pins = < - MX8MP_IOMUXC_SD1_STROBE__GPIO2_IO11 0x146 + MX8MP_IOMUXC_SD1_STROBE__GPIO2_IO11 + (MX8MP_DSE_X6 | MX8MP_PULL_UP | MX8MP_PULL_ENABLE) + }; pinctrl_uart2: uart2grp { fsl,pins = < - MX8MP_IOMUXC_UART2_RXD__UART2_DCE_RX 0x140 - MX8MP_IOMUXC_UART2_TXD__UART2_DCE_TX 0x140 + MX8MP_IOMUXC_UART2_RXD__UART2_DCE_RX (MX8MP_PULL_UP | MX8MP_PULL_ENABLE) + MX8MP_IOMUXC_UART2_TXD__UART2_DCE_TX (MX8MP_PULL_UP | MX8MP_PULL_ENABLE) + }; pinctrl_uart3: uart3grp { fsl,pins = < - MX8MP_IOMUXC_ECSPI1_SCLK__UART3_DCE_RX 0x140 - MX8MP_IOMUXC_ECSPI1_MOSI__UART3_DCE_TX 0x140 - MX8MP_IOMUXC_ECSPI1_SS0__UART3_DCE_RTS 0x140 - MX8MP_IOMUXC_ECSPI1_MISO__UART3_DCE_CTS 0x140 + MX8MP_IOMUXC_ECSPI1_SCLK__UART3_DCE_RX (MX8MP_PULL_UP | MX8MP_PULL_ENABLE) + MX8MP_IOMUXC_ECSPI1_MOSI__UART3_DCE_TX (MX8MP_PULL_UP | MX8MP_PULL_ENABLE) + MX8MP_IOMUXC_ECSPI1_SS0__UART3_DCE_RTS (MX8MP_PULL_UP | MX8MP_PULL_ENABLE) + MX8MP_IOMUXC_ECSPI1_MISO__UART3_DCE_CTS (MX8MP_PULL_UP | MX8MP_PULL_ENABLE) }; pinctrl_usdhc3: usdhc3grp { fsl,pins = < - MX8MP_IOMUXC_NAND_WE_B__USDHC3_CLK 0x190 - MX8MP_IOMUXC_NAND_WP_B__USDHC3_CMD 0x1d0 - MX8MP_IOMUXC_NAND_DATA04__USDHC3_DATA0 0x1d0 - MX8MP_IOMUXC_NAND_DATA05__USDHC3_DATA1 0x1d0 - MX8MP_IOMUXC_NAND_DATA06__USDHC3_DATA2 0x1d0 - MX8MP_IOMUXC_NAND_DATA07__USDHC3_DATA3 0x1d0 - MX8MP_IOMUXC_NAND_RE_B__USDHC3_DATA4 0x1d0 - MX8MP_IOMUXC_NAND_CE2_B__USDHC3_DATA5 0x1d0 - MX8MP_IOMUXC_NAND_CE3_B__USDHC3_DATA6 0x1d0 - MX8MP_IOMUXC_NAND_CLE__USDHC3_DATA7 0x1d0 - MX8MP_IOMUXC_NAND_CE1_B__USDHC3_STROBE 0x190 + MX8MP_IOMUXC_NAND_WE_B__USDHC3_CLK + (MX8MP_FSEL_FAST | MX8MP_HYS_SCHMITT | MX8MP_PULL_ENABLE) + MX8MP_IOMUXC_NAND_WP_B__USDHC3_CMD + (MX8MP_FSEL_FAST | MX8MP_PULL_UP | + MX8MP_HYS_SCHMITT | MX8MP_PULL_ENABLE) + MX8MP_IOMUXC_NAND_DATA04__USDHC3_DATA0 MX8MP_NAND_DATA_DEFAULT + MX8MP_IOMUXC_NAND_DATA05__USDHC3_DATA1 MX8MP_NAND_DATA_DEFAULT + MX8MP_IOMUXC_NAND_DATA06__USDHC3_DATA2 MX8MP_NAND_DATA_DEFAULT + MX8MP_IOMUXC_NAND_DATA07__USDHC3_DATA3 MX8MP_NAND_DATA_DEFAULT + MX8MP_IOMUXC_NAND_RE_B__USDHC3_DATA4 MX8MP_NAND_DATA_DEFAULT + MX8MP_IOMUXC_NAND_CE2_B__USDHC3_DATA5 MX8MP_NAND_DATA_DEFAULT + MX8MP_IOMUXC_NAND_CE3_B__USDHC3_DATA6 MX8MP_NAND_DATA_DEFAULT + MX8MP_IOMUXC_NAND_CLE__USDHC3_DATA7 MX8MP_NAND_DATA_DEFAULT + MX8MP_IOMUXC_NAND_CE1_B__USDHC3_STROBE + (MX8MP_FSEL_FAST | MX8MP_HYS_SCHMITT | MX8MP_PULL_ENABLE) }; pinctrl_usdhc3_100mhz: usdhc3-100mhzgrp { fsl,pins = < - MX8MP_IOMUXC_NAND_WE_B__USDHC3_CLK 0x194 - MX8MP_IOMUXC_NAND_WP_B__USDHC3_CMD 0x1d4 - MX8MP_IOMUXC_NAND_DATA04__USDHC3_DATA0 0x1d4 - MX8MP_IOMUXC_NAND_DATA05__USDHC3_DATA1 0x1d4 - MX8MP_IOMUXC_NAND_DATA06__USDHC3_DATA2 0x1d4 - MX8MP_IOMUXC_NAND_DATA07__USDHC3_DATA3 0x1d4 - MX8MP_IOMUXC_NAND_RE_B__USDHC3_DATA4 0x1d4 - MX8MP_IOMUXC_NAND_CE2_B__USDHC3_DATA5 0x1d4 - MX8MP_IOMUXC_NAND_CE3_B__USDHC3_DATA6 0x1d4 - MX8MP_IOMUXC_NAND_CLE__USDHC3_DATA7 0x1d4 - MX8MP_IOMUXC_NAND_CE1_B__USDHC3_STROBE 0x194 + MX8MP_IOMUXC_NAND_WE_B__USDHC3_CLK + (MX8MP_DSE_X2 | MX8MP_FSEL_FAST | + MX8MP_HYS_SCHMITT | MX8MP_PULL_ENABLE) + MX8MP_IOMUXC_NAND_WP_B__USDHC3_CMD + (MX8MP_DSE_X2 | MX8MP_NAND_DATA_DEFAULT) + MX8MP_IOMUXC_NAND_DATA04__USDHC3_DATA0 + (MX8MP_DSE_X2 | MX8MP_NAND_DATA_DEFAULT) + MX8MP_IOMUXC_NAND_DATA05__USDHC3_DATA1 + (MX8MP_DSE_X2 | MX8MP_NAND_DATA_DEFAULT) + MX8MP_IOMUXC_NAND_DATA06__USDHC3_DATA2 + (MX8MP_DSE_X2 | MX8MP_NAND_DATA_DEFAULT) + MX8MP_IOMUXC_NAND_DATA07__USDHC3_DATA3 + (MX8MP_DSE_X2 | MX8MP_NAND_DATA_DEFAULT) + MX8MP_IOMUXC_NAND_RE_B__USDHC3_DATA4 + (MX8MP_DSE_X2 | MX8MP_NAND_DATA_DEFAULT) + MX8MP_IOMUXC_NAND_CE2_B__USDHC3_DATA5 + (MX8MP_DSE_X2 | MX8MP_NAND_DATA_DEFAULT) + MX8MP_IOMUXC_NAND_CE3_B__USDHC3_DATA6 + (MX8MP_DSE_X2 | MX8MP_NAND_DATA_DEFAULT) + MX8MP_IOMUXC_NAND_CLE__USDHC3_DATA7 + (MX8MP_DSE_X2 | MX8MP_NAND_DATA_DEFAULT) + MX8MP_IOMUXC_NAND_CE1_B__USDHC3_STROBE + (MX8MP_DSE_X2 | MX8MP_FSEL_FAST | + MX8MP_HYS_SCHMITT | MX8MP_PULL_ENABLE) }; pinctrl_usdhc3_200mhz: usdhc3-200mhzgrp { fsl,pins = < - MX8MP_IOMUXC_NAND_WE_B__USDHC3_CLK 0x196 - MX8MP_IOMUXC_NAND_WP_B__USDHC3_CMD 0x1d6 - MX8MP_IOMUXC_NAND_DATA04__USDHC3_DATA0 0x1d6 - MX8MP_IOMUXC_NAND_DATA05__USDHC3_DATA1 0x1d6 - MX8MP_IOMUXC_NAND_DATA06__USDHC3_DATA2 0x1d6 - MX8MP_IOMUXC_NAND_DATA07__USDHC3_DATA3 0x1d6 - MX8MP_IOMUXC_NAND_RE_B__USDHC3_DATA4 0x1d6 - MX8MP_IOMUXC_NAND_CE2_B__USDHC3_DATA5 0x1d6 - MX8MP_IOMUXC_NAND_CE3_B__USDHC3_DATA6 0x1d6 - MX8MP_IOMUXC_NAND_CLE__USDHC3_DATA7 0x1d6 - MX8MP_IOMUXC_NAND_CE1_B__USDHC3_STROBE 0x196 + MX8MP_IOMUXC_NAND_WE_B__USDHC3_CLK + (MX8MP_DSE_X6 | MX8MP_FSEL_FAST | + MX8MP_HYS_SCHMITT | MX8MP_PULL_ENABLE) + MX8MP_IOMUXC_NAND_WP_B__USDHC3_CMD + (MX8MP_DSE_X6 | MX8MP_FSEL_FAST | MX8MP_PULL_UP | + MX8MP_HYS_SCHMITT | MX8MP_PULL_ENABLE) + MX8MP_IOMUXC_NAND_DATA04__USDHC3_DATA0 + (MX8MP_DSE_X6 | MX8MP_NAND_DATA_DEFAULT) + MX8MP_IOMUXC_NAND_DATA05__USDHC3_DATA1 + (MX8MP_DSE_X6 | MX8MP_NAND_DATA_DEFAULT) + MX8MP_IOMUXC_NAND_DATA06__USDHC3_DATA2 + (MX8MP_DSE_X6 | MX8MP_NAND_DATA_DEFAULT) + MX8MP_IOMUXC_NAND_DATA07__USDHC3_DATA3 + (MX8MP_DSE_X6 | MX8MP_NAND_DATA_DEFAULT) + MX8MP_IOMUXC_NAND_RE_B__USDHC3_DATA4 + (MX8MP_DSE_X6 | MX8MP_NAND_DATA_DEFAULT) + MX8MP_IOMUXC_NAND_CE2_B__USDHC3_DATA5 + (MX8MP_DSE_X6 | MX8MP_NAND_DATA_DEFAULT) + MX8MP_IOMUXC_NAND_CE3_B__USDHC3_DATA6 + (MX8MP_DSE_X6 | MX8MP_NAND_DATA_DEFAULT) + MX8MP_IOMUXC_NAND_CLE__USDHC3_DATA7 + (MX8MP_DSE_X6 | MX8MP_NAND_DATA_DEFAULT) + MX8MP_IOMUXC_NAND_CE1_B__USDHC3_STROBE + (MX8MP_DSE_X6 | MX8MP_FSEL_FAST | + MX8MP_HYS_SCHMITT | MX8MP_PULL_ENABLE) }; }; diff --git a/arch/arm64/boot/dts/freescale/imx8mp-pinfunc.h b/arch/arm64/boot/dts/freescale/imx8mp-pinfunc.h index 26e7a9428c4c7..c963913e3c626 100644 --- a/arch/arm64/boot/dts/freescale/imx8mp-pinfunc.h +++ b/arch/arm64/boot/dts/freescale/imx8mp-pinfunc.h @@ -38,6 +38,8 @@ MX8MP_HYS_SCHMITT | MX8MP_PULL_ENABLE) #define MX8MP_I2C_DEFAULT (MX8MP_PULL_UP | MX8MP_HYS_SCHMITT | \ MX8MP_PULL_ENABLE | MX8MP_SION) +#define MX8MP_NAND_DATA_DEFAULT (MX8MP_FSEL_FAST | MX8MP_PULL_UP | \ + MX8MP_HYS_SCHMITT | MX8MP_PULL_ENABLE) /* * The pin function ID is a tuple of -- 2.45.2
{ "author": "Daniel Baluta <daniel.baluta@nxp.com>", "date": "Fri, 27 Feb 2026 15:02:42 +0200", "is_openbsd": false, "thread_id": "aaGzj11fjemaKLrQ@lizhi-Precision-Tower-5810.mbox.gz" }
lkml_critique
lkml
Enhance the readability of IOMUXC_SW_PAD_CTL_PAD configuration by using symbolic macros instead of magic values. First patch makes MX8MP_I2C_DEFAULT independent of DS so it can be re-used in multiple places. Second patch makes uses on the macros introduce with: 31ff1060175c458 ("arm64: dts: imx8mp: Add pinctrl config definitions") in order to make code easier to read and understand. This is just an RFC to get your opinin on the idea. If this gets positive feedback will continue to update the rest of the dts files. Daniel Baluta (2): arm64: dts: imx8mp: Make MX8MP_I2C_DEFAULT independent on drive strength arm64: dts: imx8mp-frdm: Use symbolic macros for IOMUXC_SW_PAD_CTL_PAD arch/arm64/boot/dts/freescale/imx8mp-frdm.dts | 132 +++++++++++------- .../arm64/boot/dts/freescale/imx8mp-pinfunc.h | 4 +- .../imx8mp-tx8p-ml81-moduline-display-106.dts | 16 +-- .../boot/dts/freescale/imx8mp-tx8p-ml81.dtsi | 8 +- 4 files changed, 99 insertions(+), 61 deletions(-) -- 2.45.2
null
null
null
[RFC PATCH 0/2] imx8mp-frdm: Enhance code readability
Hi Daniel, Glad to see others using them :) Reviewed-by: Maud Spierings <maudspierings@gocontroll.com> On 2/27/26 14:02, Daniel Baluta wrote:
{ "author": "Maud Spierings <maudspierings@gocontroll.com>", "date": "Fri, 27 Feb 2026 14:31:48 +0100", "is_openbsd": false, "thread_id": "aaGzj11fjemaKLrQ@lizhi-Precision-Tower-5810.mbox.gz" }
lkml_critique
lkml
Enhance the readability of IOMUXC_SW_PAD_CTL_PAD configuration by using symbolic macros instead of magic values. First patch makes MX8MP_I2C_DEFAULT independent of DS so it can be re-used in multiple places. Second patch makes uses on the macros introduce with: 31ff1060175c458 ("arm64: dts: imx8mp: Add pinctrl config definitions") in order to make code easier to read and understand. This is just an RFC to get your opinin on the idea. If this gets positive feedback will continue to update the rest of the dts files. Daniel Baluta (2): arm64: dts: imx8mp: Make MX8MP_I2C_DEFAULT independent on drive strength arm64: dts: imx8mp-frdm: Use symbolic macros for IOMUXC_SW_PAD_CTL_PAD arch/arm64/boot/dts/freescale/imx8mp-frdm.dts | 132 +++++++++++------- .../arm64/boot/dts/freescale/imx8mp-pinfunc.h | 4 +- .../imx8mp-tx8p-ml81-moduline-display-106.dts | 16 +-- .../boot/dts/freescale/imx8mp-tx8p-ml81.dtsi | 8 +- 4 files changed, 99 insertions(+), 61 deletions(-) -- 2.45.2
null
null
null
[RFC PATCH 0/2] imx8mp-frdm: Enhance code readability
Hi Daniel, On 2/27/26 14:02, Daniel Baluta wrote: [snip] Isn't this the same as the USDHC default that is above the i2c one? Kind regards, Maud
{ "author": "Maud Spierings <maudspierings@gocontroll.com>", "date": "Fri, 27 Feb 2026 14:33:37 +0100", "is_openbsd": false, "thread_id": "aaGzj11fjemaKLrQ@lizhi-Precision-Tower-5810.mbox.gz" }
lkml_critique
lkml
Enhance the readability of IOMUXC_SW_PAD_CTL_PAD configuration by using symbolic macros instead of magic values. First patch makes MX8MP_I2C_DEFAULT independent of DS so it can be re-used in multiple places. Second patch makes uses on the macros introduce with: 31ff1060175c458 ("arm64: dts: imx8mp: Add pinctrl config definitions") in order to make code easier to read and understand. This is just an RFC to get your opinin on the idea. If this gets positive feedback will continue to update the rest of the dts files. Daniel Baluta (2): arm64: dts: imx8mp: Make MX8MP_I2C_DEFAULT independent on drive strength arm64: dts: imx8mp-frdm: Use symbolic macros for IOMUXC_SW_PAD_CTL_PAD arch/arm64/boot/dts/freescale/imx8mp-frdm.dts | 132 +++++++++++------- .../arm64/boot/dts/freescale/imx8mp-pinfunc.h | 4 +- .../imx8mp-tx8p-ml81-moduline-display-106.dts | 16 +-- .../boot/dts/freescale/imx8mp-tx8p-ml81.dtsi | 8 +- 4 files changed, 99 insertions(+), 61 deletions(-) -- 2.45.2
null
null
null
[RFC PATCH 0/2] imx8mp-frdm: Enhance code readability
On Fri, Feb 27, 2026 at 03:02:42PM +0200, Daniel Baluta wrote: Use symbolic macros instead of the magic values to improve code readability. ... It is not NAND, should be MX8MP_USDHC_DATA_DEFAULT Frank
{ "author": "Frank Li <Frank.li@nxp.com>", "date": "Fri, 27 Feb 2026 10:09:03 -0500", "is_openbsd": false, "thread_id": "aaGzj11fjemaKLrQ@lizhi-Precision-Tower-5810.mbox.gz" }
lkml_critique
lkml
Minor cleanups I saw when I was working on [1]. Both commits are related to a pattern where two pointers were being initialized and checked after that. [1] https://lore.kernel.org/linux-btrfs/20260223234451.277369-1-mssola@mssola.com/ Miquel Sabaté Solà (2): btrfs: return early if allocations fail on add_block_entry() btrfs: return early if allocations fail on raid56 fs/btrfs/raid56.c | 29 ++++++++++++++++++----------- fs/btrfs/ref-verify.c | 10 ++++++---- 2 files changed, 24 insertions(+), 15 deletions(-) -- 2.53.0
null
null
null
[PATCH 0/2] btrfs: return early in allocation failures
In both the recover_sectors() and the recover_scrub_rbio() functions we initialized two pointers by allocating them, and then returned early if either of them failed. But we can simply allocate the first one and do the check, and repeat for the second pointer. This way we return earlier on allocation failures, and we don't perform unneeded kfree() calls. Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com> --- fs/btrfs/raid56.c | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/fs/btrfs/raid56.c b/fs/btrfs/raid56.c index e31d57d6ab1e..c8ece97259e3 100644 --- a/fs/btrfs/raid56.c +++ b/fs/btrfs/raid56.c @@ -2094,8 +2094,8 @@ static int recover_vertical(struct btrfs_raid_bio *rbio, int sector_nr, static int recover_sectors(struct btrfs_raid_bio *rbio) { - void **pointers = NULL; - void **unmap_array = NULL; + void **pointers; + void **unmap_array; int sectornr; int ret = 0; @@ -2105,11 +2105,15 @@ static int recover_sectors(struct btrfs_raid_bio *rbio) * @unmap_array stores copy of pointers that does not get reordered * during reconstruction so that kunmap_local works. */ + pointers = kzalloc_objs(void *, rbio->real_stripes, GFP_NOFS); + if (!pointers) + return -ENOMEM; + unmap_array = kzalloc_objs(void *, rbio->real_stripes, GFP_NOFS); - if (!pointers || !unmap_array) { - ret = -ENOMEM; - goto out; + if (!unmap_array) { + kfree(pointers); + return -ENOMEM; } if (rbio->operation == BTRFS_RBIO_READ_REBUILD) { @@ -2126,7 +2130,6 @@ static int recover_sectors(struct btrfs_raid_bio *rbio) break; } -out: kfree(pointers); kfree(unmap_array); return ret; @@ -2828,8 +2831,8 @@ static inline int is_data_stripe(struct btrfs_raid_bio *rbio, int stripe) static int recover_scrub_rbio(struct btrfs_raid_bio *rbio) { - void **pointers = NULL; - void **unmap_array = NULL; + void **pointers; + void **unmap_array; int sector_nr; int ret = 0; @@ -2839,11 +2842,15 @@ static int recover_scrub_rbio(struct btrfs_raid_bio *rbio) * @unmap_array stores copy of pointers that does not get reordered * during reconstruction so that kunmap_local works. */ + pointers = kzalloc_objs(void *, rbio->real_stripes, GFP_NOFS); + if (!pointers) + return -ENOMEM; + unmap_array = kzalloc_objs(void *, rbio->real_stripes, GFP_NOFS); - if (!pointers || !unmap_array) { - ret = -ENOMEM; - goto out; + if (!unmap_array) { + kfree(pointers); + return -ENOMEM; } for (sector_nr = 0; sector_nr < rbio->stripe_nsectors; sector_nr++) { -- 2.53.0
{ "author": "=?UTF-8?q?Miquel=20Sabat=C3=A9=20Sol=C3=A0?= <mssola@mssola.com>", "date": "Fri, 27 Feb 2026 16:17:59 +0100", "is_openbsd": false, "thread_id": "20260227151759.704838-3-mssola@mssola.com.mbox.gz" }
lkml_critique
lkml
Minor cleanups I saw when I was working on [1]. Both commits are related to a pattern where two pointers were being initialized and checked after that. [1] https://lore.kernel.org/linux-btrfs/20260223234451.277369-1-mssola@mssola.com/ Miquel Sabaté Solà (2): btrfs: return early if allocations fail on add_block_entry() btrfs: return early if allocations fail on raid56 fs/btrfs/raid56.c | 29 ++++++++++++++++++----------- fs/btrfs/ref-verify.c | 10 ++++++---- 2 files changed, 24 insertions(+), 15 deletions(-) -- 2.53.0
null
null
null
[PATCH 0/2] btrfs: return early in allocation failures
In add_block_entry(), if the allocation of 're' fails, return right away instead of trying to allocate 'be' next. This also removes a useless kfree() call. Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com> --- fs/btrfs/ref-verify.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/fs/btrfs/ref-verify.c b/fs/btrfs/ref-verify.c index f78369ff2a66..7b4d52db7897 100644 --- a/fs/btrfs/ref-verify.c +++ b/fs/btrfs/ref-verify.c @@ -246,14 +246,16 @@ static struct block_entry *add_block_entry(struct btrfs_fs_info *fs_info, u64 bytenr, u64 len, u64 root_objectid) { - struct block_entry *be = NULL, *exist; - struct root_entry *re = NULL; + struct block_entry *be, *exist; + struct root_entry *re; re = kzalloc_obj(struct root_entry, GFP_NOFS); + if (!re) + return ERR_PTR(-ENOMEM); + be = kzalloc_obj(struct block_entry, GFP_NOFS); - if (!be || !re) { + if (!be) { kfree(re); - kfree(be); return ERR_PTR(-ENOMEM); } be->bytenr = bytenr; -- 2.53.0
{ "author": "=?UTF-8?q?Miquel=20Sabat=C3=A9=20Sol=C3=A0?= <mssola@mssola.com>", "date": "Fri, 27 Feb 2026 16:17:58 +0100", "is_openbsd": false, "thread_id": "20260227151759.704838-3-mssola@mssola.com.mbox.gz" }
lkml_critique
lkml
Register P1:0x33 is written twice with the same value in the 'lane_2_mode_1632x1224' sequence. Remove one unnecessary write access. Signed-off-by: Matthias Fend <matthias.fend@emfend.at> --- drivers/media/i2c/ov08d10.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/media/i2c/ov08d10.c b/drivers/media/i2c/ov08d10.c index ee193ba44f17d5659b3e22329b5e0ee421e3668f..fa8d29a62fbfa956dff6b57ccd6c9b7777967731 100644 --- a/drivers/media/i2c/ov08d10.c +++ b/drivers/media/i2c/ov08d10.c @@ -410,7 +410,6 @@ static const struct ov08d10_reg lane_2_mode_1632x1224[] = { {0x07, 0x05}, {0x21, 0x02}, {0x24, 0x30}, - {0x33, 0x03}, {0x31, 0x06}, {0x33, 0x03}, {0x01, 0x03}, -- 2.34.1
null
null
null
[PATCH 6/8] media: i2c: ov08d10: remove duplicate register write
The sensor supports an input clock in the range of 6 to 27 MHz. Currently, the driver only supports a 19.2 MHz clock. Extend the driver so that at least 24 MHz, which is a typical frequency for this sensor, can also be used. Signed-off-by: Matthias Fend <matthias.fend@emfend.at> --- drivers/media/i2c/ov08d10.c | 80 ++++++++++++++++++++++++++++++++++++--------- 1 file changed, 64 insertions(+), 16 deletions(-) diff --git a/drivers/media/i2c/ov08d10.c b/drivers/media/i2c/ov08d10.c index 4dba264488b3e1950016deb3fa34732871cc34fc..254ed22350e5ede021964d92e0fb350e7a397297 100644 --- a/drivers/media/i2c/ov08d10.c +++ b/drivers/media/i2c/ov08d10.c @@ -14,7 +14,6 @@ #include <media/v4l2-fwnode.h> #define OV08D10_SCLK 144000000ULL -#define OV08D10_XVCLK_19_2 19200000 #define OV08D10_ROWCLK 36000 #define OV08D10_DATA_LANES 2 #define OV08D10_RGB_DEPTH 10 @@ -78,8 +77,13 @@ struct ov08d10_reg_list { const struct ov08d10_reg *regs; }; +static const u32 ov08d10_xvclk_freqs[] = { + 19200000, + 24000000 +}; + struct ov08d10_link_freq_config { - const struct ov08d10_reg_list reg_list; + const struct ov08d10_reg_list reg_list[ARRAY_SIZE(ov08d10_xvclk_freqs)]; }; struct ov08d10_mode { @@ -108,8 +112,8 @@ struct ov08d10_mode { u8 data_lanes; }; -/* 3280x2460, 3264x2448 need 720Mbps/lane, 2 lanes */ -static const struct ov08d10_reg mipi_data_rate_720mbps[] = { +/* 3280x2460, 3264x2448 need 720Mbps/lane, 2 lanes - 19.2 MHz */ +static const struct ov08d10_reg mipi_data_rate_720mbps_19_2[] = { {0xfd, 0x00}, {0x11, 0x2a}, {0x14, 0x43}, @@ -119,8 +123,8 @@ static const struct ov08d10_reg mipi_data_rate_720mbps[] = { {0xb7, 0x02} }; -/* 1632x1224 needs 360Mbps/lane, 2 lanes */ -static const struct ov08d10_reg mipi_data_rate_360mbps[] = { +/* 1632x1224 needs 360Mbps/lane, 2 lanes - 19.2 MHz */ +static const struct ov08d10_reg mipi_data_rate_360mbps_19_2[] = { {0xfd, 0x00}, {0x1a, 0x04}, {0x1b, 0xe1}, @@ -132,6 +136,30 @@ static const struct ov08d10_reg mipi_data_rate_360mbps[] = { {0xb7, 0x02} }; +/* 3280x2460, 3264x2448 need 720Mbps/lane, 2 lanes - 24 MHz */ +static const struct ov08d10_reg mipi_data_rate_720mbps_24_0[] = { + {0xfd, 0x00}, + {0x11, 0x2a}, + {0x14, 0x43}, + {0x1a, 0x04}, + {0x1b, 0xb4}, + {0x1e, 0x13}, + {0xb7, 0x02} +}; + +/* 1632x1224 needs 360Mbps/lane, 2 lanes - 24 MHz */ +static const struct ov08d10_reg mipi_data_rate_360mbps_24_0[] = { + {0xfd, 0x00}, + {0x1a, 0x04}, + {0x1b, 0xb4}, + {0x1d, 0x00}, + {0x1c, 0x19}, + {0x11, 0x2a}, + {0x14, 0x54}, + {0x1e, 0x13}, + {0xb7, 0x02} +}; + static const struct ov08d10_reg lane_2_mode_3280x2460[] = { /* 3280x2460 resolution */ {0xfd, 0x01}, @@ -526,6 +554,7 @@ struct ov08d10 { struct clk *clk; struct reset_control *reset; struct regulator_bulk_data supplies[ARRAY_SIZE(ov08d10_supply_names)]; + u8 xvclk_index; struct v4l2_subdev sd; struct media_pad pad; @@ -566,17 +595,29 @@ static const struct ov08d10_lane_cfg lane_cfg_2 = { }, {{ .reg_list = { + { .num_of_regs = - ARRAY_SIZE(mipi_data_rate_720mbps), - .regs = mipi_data_rate_720mbps, - } + ARRAY_SIZE(mipi_data_rate_720mbps_19_2), + .regs = mipi_data_rate_720mbps_19_2, + }, + { + .num_of_regs = + ARRAY_SIZE(mipi_data_rate_720mbps_24_0), + .regs = mipi_data_rate_720mbps_24_0, + }} }, { .reg_list = { + { .num_of_regs = - ARRAY_SIZE(mipi_data_rate_360mbps), - .regs = mipi_data_rate_360mbps, - } + ARRAY_SIZE(mipi_data_rate_360mbps_19_2), + .regs = mipi_data_rate_360mbps_19_2, + }, + { + .num_of_regs = + ARRAY_SIZE(mipi_data_rate_360mbps_24_0), + .regs = mipi_data_rate_360mbps_24_0, + }} }}, {{ .width = 3280, @@ -1029,7 +1070,8 @@ static int ov08d10_start_streaming(struct ov08d10 *ov08d10) link_freq_index = ov08d10->cur_mode->link_freq_index; reg_list = - &ov08d10->priv_lane->link_freq_configs[link_freq_index].reg_list; + &ov08d10->priv_lane->link_freq_configs[link_freq_index] + .reg_list[ov08d10->xvclk_index]; /* soft reset */ ret = i2c_smbus_write_byte_data(client, OV08D10_REG_PAGE, 0x00); @@ -1457,9 +1499,15 @@ static int ov08d10_probe(struct i2c_client *client) "failed to get clock\n"); freq = clk_get_rate(ov08d10->clk); - if (freq != OV08D10_XVCLK_19_2) - dev_warn(ov08d10->dev, - "external clock rate %lu is not supported\n", freq); + for (i = 0; i < ARRAY_SIZE(ov08d10_xvclk_freqs); i++) { + if (freq == ov08d10_xvclk_freqs[i]) + break; + } + if (i >= ARRAY_SIZE(ov08d10_xvclk_freqs)) + return dev_err_probe(ov08d10->dev, -EINVAL, + "external clock rate %lu is not supported\n", + freq); + ov08d10->xvclk_index = i; ret = ov08d10_get_hwcfg(ov08d10); if (ret) { -- 2.34.1
{ "author": "Matthias Fend <matthias.fend@emfend.at>", "date": "Thu, 26 Feb 2026 09:56:04 +0100", "is_openbsd": false, "thread_id": "20260226-ov08d10-v1-0-c3a916368123@emfend.at.mbox.gz" }
lkml_critique
lkml
Register P1:0x33 is written twice with the same value in the 'lane_2_mode_1632x1224' sequence. Remove one unnecessary write access. Signed-off-by: Matthias Fend <matthias.fend@emfend.at> --- drivers/media/i2c/ov08d10.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/media/i2c/ov08d10.c b/drivers/media/i2c/ov08d10.c index ee193ba44f17d5659b3e22329b5e0ee421e3668f..fa8d29a62fbfa956dff6b57ccd6c9b7777967731 100644 --- a/drivers/media/i2c/ov08d10.c +++ b/drivers/media/i2c/ov08d10.c @@ -410,7 +410,6 @@ static const struct ov08d10_reg lane_2_mode_1632x1224[] = { {0x07, 0x05}, {0x21, 0x02}, {0x24, 0x30}, - {0x33, 0x03}, {0x31, 0x06}, {0x33, 0x03}, {0x01, 0x03}, -- 2.34.1
null
null
null
[PATCH 6/8] media: i2c: ov08d10: remove duplicate register write
Add YAML bindings for the Omnivision OV08D10 CMOS image sensor. Signed-off-by: Matthias Fend <matthias.fend@emfend.at> --- .../bindings/media/i2c/ovti,ov08d10.yaml | 101 +++++++++++++++++++++ MAINTAINERS | 1 + 2 files changed, 102 insertions(+) diff --git a/Documentation/devicetree/bindings/media/i2c/ovti,ov08d10.yaml b/Documentation/devicetree/bindings/media/i2c/ovti,ov08d10.yaml new file mode 100644 index 0000000000000000000000000000000000000000..96dbf61cf7c188544f4120216ae2b8e0155128b7 --- /dev/null +++ b/Documentation/devicetree/bindings/media/i2c/ovti,ov08d10.yaml @@ -0,0 +1,101 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/media/i2c/ovti,ov08d10.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Omnivision OV08D10 1/4-Inch 8MP CMOS color image sensor + +maintainers: + - Jimmy Su <jimmy.su@intel.com> + +description: + The Omnivision OV08D10 is a 1/4-Inch 8MP CMOS color image sensor with an + active array size of 3280 x 2464. It is programmable through I2C + interface. Image data is transmitted via MIPI CSI-2 using 2 lanes. + +allOf: + - $ref: /schemas/media/video-interface-devices.yaml# + +properties: + compatible: + const: ovti,ov08d10 + + reg: + maxItems: 1 + + clocks: + description: MCLK input clock (6 - 27 MHz) + maxItems: 1 + + reset-gpios: + description: Active low XSHUTDN pin + maxItems: 1 + + dovdd-supply: + description: IO power supply (1.8V) + + avdd-supply: + description: Analog power supply (2.8V) + + dvdd-supply: + description: Core power supply (1.2V) + + port: + $ref: /schemas/graph.yaml#/$defs/port-base + additionalProperties: false + + properties: + endpoint: + $ref: /schemas/media/video-interfaces.yaml# + unevaluatedProperties: false + + required: + - data-lanes + - link-frequencies + + required: + - endpoint + +required: + - compatible + - reg + - clocks + - port + +unevaluatedProperties: false + +examples: + - | + #include <dt-bindings/gpio/gpio.h> + #include <dt-bindings/media/video-interfaces.h> + + i2c { + #address-cells = <1>; + #size-cells = <0>; + + sensor@36 { + compatible = "ovti,ov08d10"; + reg = <0x36>; + + clocks = <&ov08d10_clk>; + + dovdd-supply = <&ov08d10_vdddo_1v8>; + avdd-supply = <&ov08d10_vdda_2v8>; + dvdd-supply = <&ov08d10_vddd_1v2>; + + orientation = <2>; + rotation = <0>; + + reset-gpios = <&gpio 1 GPIO_ACTIVE_LOW>; + + port { + ov08d10_output: endpoint { + data-lanes = <1 2>; + link-frequencies = /bits/ 64 <360000000 720000000>; + remote-endpoint = <&csi_input>; + }; + }; + }; + }; +... diff --git a/MAINTAINERS b/MAINTAINERS index 55af015174a54e17cc7449e5a80b6cdc83aa6fde..2484d0bcc1f09582828cafbdb7d45dd12b55af60 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -19505,6 +19505,7 @@ M: Jimmy Su <jimmy.su@intel.com> L: linux-media@vger.kernel.org S: Maintained T: git git://linuxtv.org/media.git +F: Documentation/devicetree/bindings/media/i2c/ovti,ov08d10.yaml F: drivers/media/i2c/ov08d10.c OMNIVISION OV08X40 SENSOR DRIVER -- 2.34.1
{ "author": "Matthias Fend <matthias.fend@emfend.at>", "date": "Thu, 26 Feb 2026 09:56:01 +0100", "is_openbsd": false, "thread_id": "20260226-ov08d10-v1-0-c3a916368123@emfend.at.mbox.gz" }
lkml_critique
lkml
Register P1:0x33 is written twice with the same value in the 'lane_2_mode_1632x1224' sequence. Remove one unnecessary write access. Signed-off-by: Matthias Fend <matthias.fend@emfend.at> --- drivers/media/i2c/ov08d10.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/media/i2c/ov08d10.c b/drivers/media/i2c/ov08d10.c index ee193ba44f17d5659b3e22329b5e0ee421e3668f..fa8d29a62fbfa956dff6b57ccd6c9b7777967731 100644 --- a/drivers/media/i2c/ov08d10.c +++ b/drivers/media/i2c/ov08d10.c @@ -410,7 +410,6 @@ static const struct ov08d10_reg lane_2_mode_1632x1224[] = { {0x07, 0x05}, {0x21, 0x02}, {0x24, 0x30}, - {0x33, 0x03}, {0x31, 0x06}, {0x33, 0x03}, {0x01, 0x03}, -- 2.34.1
null
null
null
[PATCH 6/8] media: i2c: ov08d10: remove duplicate register write
This series provides basic device tree support and handling for power supplies, an optional reset, and the option to use a 24MHz input clock. In addition to a few minor fixes, a major problem with the configuration of the sensor modes has also been resolved. The changes have been tested on an i.MX8MP platform. Originally, the sensor was apparently only used with ACPI - unfortunately, I do not have such a hardware setup available. Signed-off-by: Matthias Fend <matthias.fend@emfend.at> --- Matthias Fend (8): dt-bindings: media: i2c: document Omnivision OV08D10 CMOS image sensor media: i2c: ov08d10: add support for binding via device tree media: i2c: ov08d10: add support for reset and power management media: i2c: ov08d10: add support for 24 MHz input clock media: i2c: ov08d10: fix image vertical start setting media: i2c: ov08d10: remove duplicate register write media: i2c: ov08d10: fix some typos in comments media: i2c: ov08d10: add missing newline to prints .../bindings/media/i2c/ovti,ov08d10.yaml | 101 +++++++++ MAINTAINERS | 1 + drivers/media/i2c/ov08d10.c | 246 ++++++++++++++++----- 3 files changed, 297 insertions(+), 51 deletions(-) --- base-commit: 6de23f81a5e08be8fbf5e8d7e9febc72a5b5f27f change-id: 20260225-ov08d10-7b198f492bd4 Best regards, -- Matthias Fend <matthias.fend@emfend.at>
{ "author": "Matthias Fend <matthias.fend@emfend.at>", "date": "Thu, 26 Feb 2026 09:56:00 +0100", "is_openbsd": false, "thread_id": "20260226-ov08d10-v1-0-c3a916368123@emfend.at.mbox.gz" }
lkml_critique
lkml
Register P1:0x33 is written twice with the same value in the 'lane_2_mode_1632x1224' sequence. Remove one unnecessary write access. Signed-off-by: Matthias Fend <matthias.fend@emfend.at> --- drivers/media/i2c/ov08d10.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/media/i2c/ov08d10.c b/drivers/media/i2c/ov08d10.c index ee193ba44f17d5659b3e22329b5e0ee421e3668f..fa8d29a62fbfa956dff6b57ccd6c9b7777967731 100644 --- a/drivers/media/i2c/ov08d10.c +++ b/drivers/media/i2c/ov08d10.c @@ -410,7 +410,6 @@ static const struct ov08d10_reg lane_2_mode_1632x1224[] = { {0x07, 0x05}, {0x21, 0x02}, {0x24, 0x30}, - {0x33, 0x03}, {0x31, 0x06}, {0x33, 0x03}, {0x01, 0x03}, -- 2.34.1
null
null
null
[PATCH 6/8] media: i2c: ov08d10: remove duplicate register write
Fix some spelling errors in comments. Signed-off-by: Matthias Fend <matthias.fend@emfend.at> --- drivers/media/i2c/ov08d10.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/media/i2c/ov08d10.c b/drivers/media/i2c/ov08d10.c index fa8d29a62fbfa956dff6b57ccd6c9b7777967731..f5c187d763c4264056100b904ab9585b25909e95 100644 --- a/drivers/media/i2c/ov08d10.c +++ b/drivers/media/i2c/ov08d10.c @@ -93,13 +93,13 @@ struct ov08d10_mode { /* Frame height in pixels */ u32 height; - /* Horizontal timining size */ + /* Horizontal timing size */ u32 hts; - /* Default vertical timining size */ + /* Default vertical timing size */ u32 vts_def; - /* Min vertical timining size */ + /* Min vertical timing size */ u32 vts_min; /* Link frequency needed for this resolution */ @@ -571,7 +571,7 @@ struct ov08d10 { /* Current mode */ const struct ov08d10_mode *cur_mode; - /* To serialize asynchronus callbacks */ + /* To serialize asynchronous callbacks */ struct mutex mutex; /* lanes index */ @@ -913,7 +913,7 @@ static int ov08d10_set_ctrl(struct v4l2_ctrl *ctrl) exposure_max); } - /* V4L2 controls values will be applied only when power is already up */ + /* V4L2 control values will be applied only when power is already up */ if (!pm_runtime_get_if_in_use(ov08d10->dev)) return 0; -- 2.34.1
{ "author": "Matthias Fend <matthias.fend@emfend.at>", "date": "Thu, 26 Feb 2026 09:56:07 +0100", "is_openbsd": false, "thread_id": "20260226-ov08d10-v1-0-c3a916368123@emfend.at.mbox.gz" }
lkml_critique
lkml
Register P1:0x33 is written twice with the same value in the 'lane_2_mode_1632x1224' sequence. Remove one unnecessary write access. Signed-off-by: Matthias Fend <matthias.fend@emfend.at> --- drivers/media/i2c/ov08d10.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/media/i2c/ov08d10.c b/drivers/media/i2c/ov08d10.c index ee193ba44f17d5659b3e22329b5e0ee421e3668f..fa8d29a62fbfa956dff6b57ccd6c9b7777967731 100644 --- a/drivers/media/i2c/ov08d10.c +++ b/drivers/media/i2c/ov08d10.c @@ -410,7 +410,6 @@ static const struct ov08d10_reg lane_2_mode_1632x1224[] = { {0x07, 0x05}, {0x21, 0x02}, {0x24, 0x30}, - {0x33, 0x03}, {0x31, 0x06}, {0x33, 0x03}, {0x01, 0x03}, -- 2.34.1
null
null
null
[PATCH 6/8] media: i2c: ov08d10: remove duplicate register write
The current settings for the "image vertical start" register appear to be incorrect. While this only results in an incorrect start line for native modes, this faulty setting causes actual problems in binning mode. At least on an i.MX8MP test system, only corrupted frames could be received. To correct this, the recommended settings from the reference register sets are used for all modes. Since this shifts the start by one line, the Bayer pattern also changes, which has also been corrected. Signed-off-by: Matthias Fend <matthias.fend@emfend.at> --- drivers/media/i2c/ov08d10.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/media/i2c/ov08d10.c b/drivers/media/i2c/ov08d10.c index 254ed22350e5ede021964d92e0fb350e7a397297..ee193ba44f17d5659b3e22329b5e0ee421e3668f 100644 --- a/drivers/media/i2c/ov08d10.c +++ b/drivers/media/i2c/ov08d10.c @@ -246,7 +246,7 @@ static const struct ov08d10_reg lane_2_mode_3280x2460[] = { {0x9a, 0x30}, {0xa8, 0x02}, {0xfd, 0x02}, - {0xa1, 0x01}, + {0xa1, 0x00}, {0xa2, 0x09}, {0xa3, 0x9c}, {0xa5, 0x00}, @@ -364,7 +364,7 @@ static const struct ov08d10_reg lane_2_mode_3264x2448[] = { {0x9a, 0x30}, {0xa8, 0x02}, {0xfd, 0x02}, - {0xa1, 0x09}, + {0xa1, 0x08}, {0xa2, 0x09}, {0xa3, 0x90}, {0xa5, 0x08}, @@ -496,7 +496,7 @@ static const struct ov08d10_reg lane_2_mode_1632x1224[] = { {0xaa, 0xd0}, {0xab, 0x06}, {0xac, 0x68}, - {0xa1, 0x09}, + {0xa1, 0x04}, {0xa2, 0x04}, {0xa3, 0xc8}, {0xa5, 0x04}, @@ -663,8 +663,8 @@ static const struct ov08d10_lane_cfg lane_cfg_2 = { static u32 ov08d10_get_format_code(struct ov08d10 *ov08d10) { static const u32 codes[2][2] = { - { MEDIA_BUS_FMT_SGRBG10_1X10, MEDIA_BUS_FMT_SRGGB10_1X10}, - { MEDIA_BUS_FMT_SBGGR10_1X10, MEDIA_BUS_FMT_SGBRG10_1X10}, + { MEDIA_BUS_FMT_SBGGR10_1X10, MEDIA_BUS_FMT_SGBRG10_1X10 }, + { MEDIA_BUS_FMT_SGRBG10_1X10, MEDIA_BUS_FMT_SRGGB10_1X10 }, }; return codes[ov08d10->vflip->val][ov08d10->hflip->val]; -- 2.34.1
{ "author": "Matthias Fend <matthias.fend@emfend.at>", "date": "Thu, 26 Feb 2026 09:56:05 +0100", "is_openbsd": false, "thread_id": "20260226-ov08d10-v1-0-c3a916368123@emfend.at.mbox.gz" }
lkml_critique
lkml
Register P1:0x33 is written twice with the same value in the 'lane_2_mode_1632x1224' sequence. Remove one unnecessary write access. Signed-off-by: Matthias Fend <matthias.fend@emfend.at> --- drivers/media/i2c/ov08d10.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/media/i2c/ov08d10.c b/drivers/media/i2c/ov08d10.c index ee193ba44f17d5659b3e22329b5e0ee421e3668f..fa8d29a62fbfa956dff6b57ccd6c9b7777967731 100644 --- a/drivers/media/i2c/ov08d10.c +++ b/drivers/media/i2c/ov08d10.c @@ -410,7 +410,6 @@ static const struct ov08d10_reg lane_2_mode_1632x1224[] = { {0x07, 0x05}, {0x21, 0x02}, {0x24, 0x30}, - {0x33, 0x03}, {0x31, 0x06}, {0x33, 0x03}, {0x01, 0x03}, -- 2.34.1
null
null
null
[PATCH 6/8] media: i2c: ov08d10: remove duplicate register write
Add support for the required power supplies as well as the control of an optional sensor reset. Signed-off-by: Matthias Fend <matthias.fend@emfend.at> --- drivers/media/i2c/ov08d10.c | 104 +++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 97 insertions(+), 7 deletions(-) diff --git a/drivers/media/i2c/ov08d10.c b/drivers/media/i2c/ov08d10.c index cfe18dcde174ddc1f198cb2aaa6b4a3b34045508..4dba264488b3e1950016deb3fa34732871cc34fc 100644 --- a/drivers/media/i2c/ov08d10.c +++ b/drivers/media/i2c/ov08d10.c @@ -8,6 +8,7 @@ #include <linux/module.h> #include <linux/pm_runtime.h> #include <linux/regulator/consumer.h> +#include <linux/reset.h> #include <media/v4l2-ctrls.h> #include <media/v4l2-device.h> #include <media/v4l2-fwnode.h> @@ -514,9 +515,17 @@ static const char * const ov08d10_test_pattern_menu[] = { "Standard Color Bar", }; +static const char *const ov08d10_supply_names[] = { + "dovdd", /* Digital I/O power */ + "avdd", /* Analog power */ + "dvdd", /* Digital core power */ +}; + struct ov08d10 { struct device *dev; struct clk *clk; + struct reset_control *reset; + struct regulator_bulk_data supplies[ARRAY_SIZE(ov08d10_supply_names)]; struct v4l2_subdev sd; struct media_pad pad; @@ -1266,6 +1275,56 @@ static const struct v4l2_subdev_internal_ops ov08d10_internal_ops = { .open = ov08d10_open, }; +static int ov08d10_power_off(struct device *dev) +{ + struct v4l2_subdev *sd = dev_get_drvdata(dev); + struct ov08d10 *ov08d10 = to_ov08d10(sd); + + reset_control_assert(ov08d10->reset); + + regulator_bulk_disable(ARRAY_SIZE(ov08d10->supplies), + ov08d10->supplies); + + clk_disable_unprepare(ov08d10->clk); + + return 0; +} + +static int ov08d10_power_on(struct device *dev) +{ + struct v4l2_subdev *sd = dev_get_drvdata(dev); + struct ov08d10 *ov08d10 = to_ov08d10(sd); + int ret; + + ret = regulator_bulk_enable(ARRAY_SIZE(ov08d10->supplies), + ov08d10->supplies); + if (ret < 0) { + dev_err(dev, "failed to enable regulators: %d\n", ret); + return ret; + } + + ret = clk_prepare_enable(ov08d10->clk); + if (ret < 0) { + regulator_bulk_disable(ARRAY_SIZE(ov08d10->supplies), + ov08d10->supplies); + + dev_err(dev, "failed to enable imaging clock: %d\n", ret); + return ret; + } + + if (ov08d10->reset) { + /* Delay from DVDD stable to sensor XSHUTDN pull up: 5ms */ + fsleep(5 * USEC_PER_MSEC); + + reset_control_deassert(ov08d10->reset); + + /* Delay from XSHUTDN pull up to SCCB start: 8ms */ + fsleep(8 * USEC_PER_MSEC); + } + + return 0; +} + static int ov08d10_identify_module(struct ov08d10 *ov08d10) { struct i2c_client *client = v4l2_get_subdevdata(&ov08d10->sd); @@ -1372,6 +1431,10 @@ static void ov08d10_remove(struct i2c_client *client) media_entity_cleanup(&sd->entity); v4l2_ctrl_handler_free(sd->ctrl_handler); pm_runtime_disable(ov08d10->dev); + if (!pm_runtime_status_suspended(ov08d10->dev)) { + ov08d10_power_off(ov08d10->dev); + pm_runtime_set_suspended(ov08d10->dev); + } mutex_destroy(&ov08d10->mutex); } @@ -1379,6 +1442,7 @@ static int ov08d10_probe(struct i2c_client *client) { struct ov08d10 *ov08d10; unsigned long freq; + unsigned int i; int ret; ov08d10 = devm_kzalloc(&client->dev, sizeof(*ov08d10), GFP_KERNEL); @@ -1404,12 +1468,32 @@ static int ov08d10_probe(struct i2c_client *client) return ret; } + ov08d10->reset = devm_reset_control_get_optional(ov08d10->dev, NULL); + if (IS_ERR(ov08d10->reset)) + return dev_err_probe(ov08d10->dev, PTR_ERR(ov08d10->reset), + "failed to get reset\n"); + reset_control_assert(ov08d10->reset); + + for (i = 0; i < ARRAY_SIZE(ov08d10_supply_names); i++) + ov08d10->supplies[i].supply = ov08d10_supply_names[i]; + + ret = devm_regulator_bulk_get(ov08d10->dev, + ARRAY_SIZE(ov08d10->supplies), + ov08d10->supplies); + if (ret) + return dev_err_probe(ov08d10->dev, ret, + "failed to get regulators\n"); + v4l2_i2c_subdev_init(&ov08d10->sd, client, &ov08d10_subdev_ops); + ret = ov08d10_power_on(ov08d10->dev); + if (ret) + return dev_err_probe(ov08d10->dev, ret, "failed to power on\n"); + ret = ov08d10_identify_module(ov08d10); if (ret) { dev_err(ov08d10->dev, "failed to find sensor: %d", ret); - return ret; + goto probe_error_power_off; } mutex_init(&ov08d10->mutex); @@ -1430,6 +1514,9 @@ static int ov08d10_probe(struct i2c_client *client) goto probe_error_v4l2_ctrl_handler_free; } + pm_runtime_set_active(ov08d10->dev); + pm_runtime_enable(ov08d10->dev); + ret = v4l2_async_register_subdev_sensor(&ov08d10->sd); if (ret < 0) { dev_err(ov08d10->dev, "failed to register V4L2 subdev: %d", @@ -1437,26 +1524,28 @@ static int ov08d10_probe(struct i2c_client *client) goto probe_error_media_entity_cleanup; } - /* - * Device is already turned on by i2c-core with ACPI domain PM. - * Enable runtime PM and turn off the device. - */ - pm_runtime_set_active(ov08d10->dev); - pm_runtime_enable(ov08d10->dev); pm_runtime_idle(ov08d10->dev); return 0; probe_error_media_entity_cleanup: + pm_runtime_disable(ov08d10->dev); + pm_runtime_set_suspended(ov08d10->dev); media_entity_cleanup(&ov08d10->sd.entity); probe_error_v4l2_ctrl_handler_free: v4l2_ctrl_handler_free(ov08d10->sd.ctrl_handler); mutex_destroy(&ov08d10->mutex); +probe_error_power_off: + ov08d10_power_off(ov08d10->dev); + return ret; } +static DEFINE_RUNTIME_DEV_PM_OPS(ov08d10_pm_ops, + ov08d10_power_off, ov08d10_power_on, NULL); + #ifdef CONFIG_ACPI static const struct acpi_device_id ov08d10_acpi_ids[] = { { "OVTI08D1" }, @@ -1475,6 +1564,7 @@ MODULE_DEVICE_TABLE(of, ov08d10_of_match); static struct i2c_driver ov08d10_i2c_driver = { .driver = { .name = "ov08d10", + .pm = pm_ptr(&ov08d10_pm_ops), .acpi_match_table = ACPI_PTR(ov08d10_acpi_ids), .of_match_table = ov08d10_of_match, }, -- 2.34.1
{ "author": "Matthias Fend <matthias.fend@emfend.at>", "date": "Thu, 26 Feb 2026 09:56:03 +0100", "is_openbsd": false, "thread_id": "20260226-ov08d10-v1-0-c3a916368123@emfend.at.mbox.gz" }
lkml_critique
lkml
Register P1:0x33 is written twice with the same value in the 'lane_2_mode_1632x1224' sequence. Remove one unnecessary write access. Signed-off-by: Matthias Fend <matthias.fend@emfend.at> --- drivers/media/i2c/ov08d10.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/media/i2c/ov08d10.c b/drivers/media/i2c/ov08d10.c index ee193ba44f17d5659b3e22329b5e0ee421e3668f..fa8d29a62fbfa956dff6b57ccd6c9b7777967731 100644 --- a/drivers/media/i2c/ov08d10.c +++ b/drivers/media/i2c/ov08d10.c @@ -410,7 +410,6 @@ static const struct ov08d10_reg lane_2_mode_1632x1224[] = { {0x07, 0x05}, {0x21, 0x02}, {0x24, 0x30}, - {0x33, 0x03}, {0x31, 0x06}, {0x33, 0x03}, {0x01, 0x03}, -- 2.34.1
null
null
null
[PATCH 6/8] media: i2c: ov08d10: remove duplicate register write
The OV08D10 can be used also on embedded designs using device tree so allow the sensor to bind to a device tree node. Signed-off-by: Matthias Fend <matthias.fend@emfend.at> --- drivers/media/i2c/ov08d10.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/media/i2c/ov08d10.c b/drivers/media/i2c/ov08d10.c index 43ec2a1f2fcffb7fa11a6268af3c2edc4df129f3..cfe18dcde174ddc1f198cb2aaa6b4a3b34045508 100644 --- a/drivers/media/i2c/ov08d10.c +++ b/drivers/media/i2c/ov08d10.c @@ -1466,10 +1466,17 @@ static const struct acpi_device_id ov08d10_acpi_ids[] = { MODULE_DEVICE_TABLE(acpi, ov08d10_acpi_ids); #endif +static const struct of_device_id ov08d10_of_match[] = { + { .compatible = "ovti,ov08d10" }, + { /* sentinel */ } +}; +MODULE_DEVICE_TABLE(of, ov08d10_of_match); + static struct i2c_driver ov08d10_i2c_driver = { .driver = { .name = "ov08d10", .acpi_match_table = ACPI_PTR(ov08d10_acpi_ids), + .of_match_table = ov08d10_of_match, }, .probe = ov08d10_probe, .remove = ov08d10_remove, -- 2.34.1
{ "author": "Matthias Fend <matthias.fend@emfend.at>", "date": "Thu, 26 Feb 2026 09:56:02 +0100", "is_openbsd": false, "thread_id": "20260226-ov08d10-v1-0-c3a916368123@emfend.at.mbox.gz" }
lkml_critique
lkml
Register P1:0x33 is written twice with the same value in the 'lane_2_mode_1632x1224' sequence. Remove one unnecessary write access. Signed-off-by: Matthias Fend <matthias.fend@emfend.at> --- drivers/media/i2c/ov08d10.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/media/i2c/ov08d10.c b/drivers/media/i2c/ov08d10.c index ee193ba44f17d5659b3e22329b5e0ee421e3668f..fa8d29a62fbfa956dff6b57ccd6c9b7777967731 100644 --- a/drivers/media/i2c/ov08d10.c +++ b/drivers/media/i2c/ov08d10.c @@ -410,7 +410,6 @@ static const struct ov08d10_reg lane_2_mode_1632x1224[] = { {0x07, 0x05}, {0x21, 0x02}, {0x24, 0x30}, - {0x33, 0x03}, {0x31, 0x06}, {0x33, 0x03}, {0x01, 0x03}, -- 2.34.1
null
null
null
[PATCH 6/8] media: i2c: ov08d10: remove duplicate register write
Add trailing \n to dev_* prints where missing. Signed-off-by: Matthias Fend <matthias.fend@emfend.at> --- drivers/media/i2c/ov08d10.c | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/drivers/media/i2c/ov08d10.c b/drivers/media/i2c/ov08d10.c index f5c187d763c4264056100b904ab9585b25909e95..6eab9a899726aaacdddb12d2861e7b0f8d5e5fd7 100644 --- a/drivers/media/i2c/ov08d10.c +++ b/drivers/media/i2c/ov08d10.c @@ -714,7 +714,7 @@ static int ov08d10_write_reg_list(struct ov08d10 *ov08d10, r_list->regs[i].val); if (ret) { dev_err_ratelimited(ov08d10->dev, - "failed to write reg 0x%2.2x. error = %d", + "failed to write reg 0x%2.2x. error = %d\n", r_list->regs[i].address, ret); return ret; } @@ -1075,32 +1075,32 @@ static int ov08d10_start_streaming(struct ov08d10 *ov08d10) /* soft reset */ ret = i2c_smbus_write_byte_data(client, OV08D10_REG_PAGE, 0x00); if (ret < 0) { - dev_err(ov08d10->dev, "failed to reset sensor"); + dev_err(ov08d10->dev, "failed to reset sensor\n"); return ret; } ret = i2c_smbus_write_byte_data(client, 0x20, 0x0e); if (ret < 0) { - dev_err(ov08d10->dev, "failed to reset sensor"); + dev_err(ov08d10->dev, "failed to reset sensor\n"); return ret; } usleep_range(3000, 4000); ret = i2c_smbus_write_byte_data(client, 0x20, 0x0b); if (ret < 0) { - dev_err(ov08d10->dev, "failed to reset sensor"); + dev_err(ov08d10->dev, "failed to reset sensor\n"); return ret; } /* update sensor setting */ ret = ov08d10_write_reg_list(ov08d10, reg_list); if (ret) { - dev_err(ov08d10->dev, "failed to set plls"); + dev_err(ov08d10->dev, "failed to set plls\n"); return ret; } reg_list = &ov08d10->cur_mode->reg_list; ret = ov08d10_write_reg_list(ov08d10, reg_list); if (ret) { - dev_err(ov08d10->dev, "failed to set mode"); + dev_err(ov08d10->dev, "failed to set mode\n"); return ret; } @@ -1127,19 +1127,19 @@ static void ov08d10_stop_streaming(struct ov08d10 *ov08d10) ret = i2c_smbus_write_byte_data(client, OV08D10_REG_PAGE, 0x00); if (ret < 0) { - dev_err(ov08d10->dev, "failed to stop streaming"); + dev_err(ov08d10->dev, "failed to stop streaming\n"); return; } ret = i2c_smbus_write_byte_data(client, OV08D10_REG_MODE_SELECT, OV08D10_MODE_STANDBY); if (ret < 0) { - dev_err(ov08d10->dev, "failed to stop streaming"); + dev_err(ov08d10->dev, "failed to stop streaming\n"); return; } ret = i2c_smbus_write_byte_data(client, OV08D10_REG_PAGE, 0x01); if (ret < 0) { - dev_err(ov08d10->dev, "failed to stop streaming"); + dev_err(ov08d10->dev, "failed to stop streaming\n"); return; } } @@ -1425,7 +1425,7 @@ static int ov08d10_get_hwcfg(struct ov08d10 *ov08d10) /* Get number of data lanes */ if (bus_cfg.bus.mipi_csi2.num_data_lanes != 2) { - dev_err(dev, "number of CSI2 data lanes %d is not supported", + dev_err(dev, "number of CSI2 data lanes %d is not supported\n", bus_cfg.bus.mipi_csi2.num_data_lanes); ret = -EINVAL; goto check_hwcfg_error; @@ -1437,7 +1437,7 @@ static int ov08d10_get_hwcfg(struct ov08d10 *ov08d10) ov08d10->modes_size = ov08d10_modes_num(ov08d10); if (!bus_cfg.nr_of_link_frequencies) { - dev_err(dev, "no link frequencies defined"); + dev_err(dev, "no link frequencies defined\n"); ret = -EINVAL; goto check_hwcfg_error; } @@ -1450,7 +1450,7 @@ static int ov08d10_get_hwcfg(struct ov08d10 *ov08d10) } if (j == bus_cfg.nr_of_link_frequencies) { - dev_err(dev, "no link frequency %lld supported", + dev_err(dev, "no link frequency %lld supported\n", ov08d10->priv_lane->link_freq_menu[i]); ret = -EINVAL; goto check_hwcfg_error; @@ -1510,7 +1510,7 @@ static int ov08d10_probe(struct i2c_client *client) ret = ov08d10_get_hwcfg(ov08d10); if (ret) { - dev_err(ov08d10->dev, "failed to get HW configuration: %d", + dev_err(ov08d10->dev, "failed to get HW configuration: %d\n", ret); return ret; } @@ -1539,7 +1539,7 @@ static int ov08d10_probe(struct i2c_client *client) ret = ov08d10_identify_module(ov08d10); if (ret) { - dev_err(ov08d10->dev, "failed to find sensor: %d", ret); + dev_err(ov08d10->dev, "failed to find sensor: %d\n", ret); goto probe_error_power_off; } @@ -1547,7 +1547,7 @@ static int ov08d10_probe(struct i2c_client *client) ov08d10->cur_mode = &ov08d10->priv_lane->sp_modes[0]; ret = ov08d10_init_controls(ov08d10); if (ret) { - dev_err(ov08d10->dev, "failed to init controls: %d", ret); + dev_err(ov08d10->dev, "failed to init controls: %d\n", ret); goto probe_error_v4l2_ctrl_handler_free; } @@ -1557,7 +1557,7 @@ static int ov08d10_probe(struct i2c_client *client) ov08d10->pad.flags = MEDIA_PAD_FL_SOURCE; ret = media_entity_pads_init(&ov08d10->sd.entity, 1, &ov08d10->pad); if (ret) { - dev_err(ov08d10->dev, "failed to init entity pads: %d", ret); + dev_err(ov08d10->dev, "failed to init entity pads: %d\n", ret); goto probe_error_v4l2_ctrl_handler_free; } @@ -1566,7 +1566,7 @@ static int ov08d10_probe(struct i2c_client *client) ret = v4l2_async_register_subdev_sensor(&ov08d10->sd); if (ret < 0) { - dev_err(ov08d10->dev, "failed to register V4L2 subdev: %d", + dev_err(ov08d10->dev, "failed to register V4L2 subdev: %d\n", ret); goto probe_error_media_entity_cleanup; } -- 2.34.1
{ "author": "Matthias Fend <matthias.fend@emfend.at>", "date": "Thu, 26 Feb 2026 09:56:08 +0100", "is_openbsd": false, "thread_id": "20260226-ov08d10-v1-0-c3a916368123@emfend.at.mbox.gz" }
lkml_critique
lkml
Register P1:0x33 is written twice with the same value in the 'lane_2_mode_1632x1224' sequence. Remove one unnecessary write access. Signed-off-by: Matthias Fend <matthias.fend@emfend.at> --- drivers/media/i2c/ov08d10.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/media/i2c/ov08d10.c b/drivers/media/i2c/ov08d10.c index ee193ba44f17d5659b3e22329b5e0ee421e3668f..fa8d29a62fbfa956dff6b57ccd6c9b7777967731 100644 --- a/drivers/media/i2c/ov08d10.c +++ b/drivers/media/i2c/ov08d10.c @@ -410,7 +410,6 @@ static const struct ov08d10_reg lane_2_mode_1632x1224[] = { {0x07, 0x05}, {0x21, 0x02}, {0x24, 0x30}, - {0x33, 0x03}, {0x31, 0x06}, {0x33, 0x03}, {0x01, 0x03}, -- 2.34.1
null
null
null
[PATCH 6/8] media: i2c: ov08d10: remove duplicate register write
On Do, 2026-02-26 at 09:56 +0100, Matthias Fend wrote: [...] Please use devm_reset_control_get_optional_exclusive() directly. The commit message does not explain why this comment is dropped. Does this do the correct thing if v4l2_async_register_subdev_sensor() returns -EPROBE_DEFER (for example via privacy led) and then it probes a second time? It looks like the assumption pm_runtime_set_active() doesn't hold then. regards Philipp
{ "author": "Philipp Zabel <p.zabel@pengutronix.de>", "date": "Thu, 26 Feb 2026 11:13:34 +0100", "is_openbsd": false, "thread_id": "20260226-ov08d10-v1-0-c3a916368123@emfend.at.mbox.gz" }
lkml_critique
lkml
Register P1:0x33 is written twice with the same value in the 'lane_2_mode_1632x1224' sequence. Remove one unnecessary write access. Signed-off-by: Matthias Fend <matthias.fend@emfend.at> --- drivers/media/i2c/ov08d10.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/media/i2c/ov08d10.c b/drivers/media/i2c/ov08d10.c index ee193ba44f17d5659b3e22329b5e0ee421e3668f..fa8d29a62fbfa956dff6b57ccd6c9b7777967731 100644 --- a/drivers/media/i2c/ov08d10.c +++ b/drivers/media/i2c/ov08d10.c @@ -410,7 +410,6 @@ static const struct ov08d10_reg lane_2_mode_1632x1224[] = { {0x07, 0x05}, {0x21, 0x02}, {0x24, 0x30}, - {0x33, 0x03}, {0x31, 0x06}, {0x33, 0x03}, {0x01, 0x03}, -- 2.34.1
null
null
null
[PATCH 6/8] media: i2c: ov08d10: remove duplicate register write
On Do, 2026-02-26 at 09:56 +0100, Matthias Fend wrote: Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de> regards Philipp
{ "author": "Philipp Zabel <p.zabel@pengutronix.de>", "date": "Thu, 26 Feb 2026 11:15:18 +0100", "is_openbsd": false, "thread_id": "20260226-ov08d10-v1-0-c3a916368123@emfend.at.mbox.gz" }
lkml_critique
lkml
Register P1:0x33 is written twice with the same value in the 'lane_2_mode_1632x1224' sequence. Remove one unnecessary write access. Signed-off-by: Matthias Fend <matthias.fend@emfend.at> --- drivers/media/i2c/ov08d10.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/media/i2c/ov08d10.c b/drivers/media/i2c/ov08d10.c index ee193ba44f17d5659b3e22329b5e0ee421e3668f..fa8d29a62fbfa956dff6b57ccd6c9b7777967731 100644 --- a/drivers/media/i2c/ov08d10.c +++ b/drivers/media/i2c/ov08d10.c @@ -410,7 +410,6 @@ static const struct ov08d10_reg lane_2_mode_1632x1224[] = { {0x07, 0x05}, {0x21, 0x02}, {0x24, 0x30}, - {0x33, 0x03}, {0x31, 0x06}, {0x33, 0x03}, {0x01, 0x03}, -- 2.34.1
null
null
null
[PATCH 6/8] media: i2c: ov08d10: remove duplicate register write
Hi Philipp, thanks for your feedback. Am 26.02.2026 um 11:13 schrieb Philipp Zabel: ACK I didn't find the comment particularly helpful and since other sensors manage without it and there's now more than just ACPI, and "turn off" happens later, I thought it was fine to just drop the comment. If you think it should still be included, I'd be happy to change it. At least it works as expected for me. But as mentioned, I don't have an ACPI hardware setup available. Does your point maybe refer to ACPI, or what exactly do you mean? To me, it now looks very similar to other Omnivision ACPI drivers – do you perhaps have a specific suggestion for what should be changed? Thanks a lot ~Matthias
{ "author": "Matthias Fend <matthias.fend@emfend.at>", "date": "Thu, 26 Feb 2026 21:30:08 +0100", "is_openbsd": false, "thread_id": "20260226-ov08d10-v1-0-c3a916368123@emfend.at.mbox.gz" }
lkml_critique
lkml
Register P1:0x33 is written twice with the same value in the 'lane_2_mode_1632x1224' sequence. Remove one unnecessary write access. Signed-off-by: Matthias Fend <matthias.fend@emfend.at> --- drivers/media/i2c/ov08d10.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/media/i2c/ov08d10.c b/drivers/media/i2c/ov08d10.c index ee193ba44f17d5659b3e22329b5e0ee421e3668f..fa8d29a62fbfa956dff6b57ccd6c9b7777967731 100644 --- a/drivers/media/i2c/ov08d10.c +++ b/drivers/media/i2c/ov08d10.c @@ -410,7 +410,6 @@ static const struct ov08d10_reg lane_2_mode_1632x1224[] = { {0x07, 0x05}, {0x21, 0x02}, {0x24, 0x30}, - {0x33, 0x03}, {0x31, 0x06}, {0x33, 0x03}, {0x01, 0x03}, -- 2.34.1
null
null
null
[PATCH 6/8] media: i2c: ov08d10: remove duplicate register write
On Thu, Feb 26, 2026 at 09:56:01AM +0100, Matthias Fend wrote: Drop YAML. You add DT bindings, not YAML. No YAML is bound here to anything. So maybe rather powerdown-gpios, see gpio-consumer-common.yaml? Best regards, Krzysztof
{ "author": "Krzysztof Kozlowski <krzk@kernel.org>", "date": "Fri, 27 Feb 2026 11:45:03 +0100", "is_openbsd": false, "thread_id": "20260226-ov08d10-v1-0-c3a916368123@emfend.at.mbox.gz" }
lkml_critique
lkml
Register P1:0x33 is written twice with the same value in the 'lane_2_mode_1632x1224' sequence. Remove one unnecessary write access. Signed-off-by: Matthias Fend <matthias.fend@emfend.at> --- drivers/media/i2c/ov08d10.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/media/i2c/ov08d10.c b/drivers/media/i2c/ov08d10.c index ee193ba44f17d5659b3e22329b5e0ee421e3668f..fa8d29a62fbfa956dff6b57ccd6c9b7777967731 100644 --- a/drivers/media/i2c/ov08d10.c +++ b/drivers/media/i2c/ov08d10.c @@ -410,7 +410,6 @@ static const struct ov08d10_reg lane_2_mode_1632x1224[] = { {0x07, 0x05}, {0x21, 0x02}, {0x24, 0x30}, - {0x33, 0x03}, {0x31, 0x06}, {0x33, 0x03}, {0x01, 0x03}, -- 2.34.1
null
null
null
[PATCH 6/8] media: i2c: ov08d10: remove duplicate register write
Hi Krzysztof, thanks for your comments. Am 27.02.2026 um 11:45 schrieb Krzysztof Kozlowski: ACK As activating the XSHUTDN pin on this sensor works like a reset, I guess it's okay as it is. From what I've seen, it's also common practice for some other Omnivision sensors to designate the XSHUTDN pin as the reset pin. This is also the case, for example, with the recently added OS05B10. During a review for another sensor, I was asked to use the reset controller framework instead of the GPIO pin for the reset function, which I did in this case as well. To my knowledge, the fallback from the reset controller to a simple reset pin only works with the 'reset-gpios' property. Thanks ~Matthias
{ "author": "Matthias Fend <matthias.fend@emfend.at>", "date": "Fri, 27 Feb 2026 16:10:50 +0100", "is_openbsd": false, "thread_id": "20260226-ov08d10-v1-0-c3a916368123@emfend.at.mbox.gz" }
lkml_critique
lkml
From: "Mike Rapoport (Microsoft)" <rppt@kernel.org> Hi, Order in which early memory reservation for hugetlb happens depends on architecture, on configuration options and on command line parameters. Some architectures rely on the core MM to call hugetlb_bootmem_alloc() while others call it very early to allow pre-allocation of HVO-style vmemmap. When hugetlb_cma is supported by an architecture it is initialized during setup_arch() and then later hugetlb_init code needs to understand did it happen or not. To make everything consistent and unified, both reservation of hugetlb memory from bootmem and creation of CMA areas for hugetlb must be called from core MM initialization and it would have been a simple change. However, HVO-style pre-initialization ordering requirements slightly complicate things and for HVO pre-init to work sparse and memory map should be initialized after hugetlb reservations. This required pulling out the call to free_area_init() out of setup_arch() path and moving it MM initialization and this is what the first 23 patches do. These changes are deliberately split into per-arch patches that change how the zone limits are calculated for each architecture and the patches 22 and 23 just remove the calls to free_area_init() and sprase_init() from arch/*. Patch 24 is a simple cleanup for MIPS. Patches 25 and 26 actually consolidate hugetlb reservations and patches 27 and 28 perform some aftermath cleanups. I tried to trim the distribution list and although it's still quite long if you feel that someone was wrongly excluded please add them back. The changes also available in git: https://git.kernel.org/pub/scm/linux/kernel/git/rppt/linux.git/log/?h=hugetlb-init/v3 v3 changes: * fix empty_zero_page initialization on arm * fix ZONE_DMA limit calculation on powerpc * add Acks v2: https://lore.kernel.org/all/20260102070005.65328-1-rppt@kernel.org * move the hugetlb and memory map initializaion to mm_core_init_early() * add Acks v1: https://lore.kernel.org/all/20251228124001.3624742-1-rppt@kernel.org Klara Modin (1): arm: make initialization of zero page independent of the memory map Mike Rapoport (Microsoft) (28): alpha: introduce arch_zone_limits_init() arc: introduce arch_zone_limits_init() arm: introduce arch_zone_limits_init() arm64: introduce arch_zone_limits_init() csky: introduce arch_zone_limits_init() hexagon: introduce arch_zone_limits_init() loongarch: introduce arch_zone_limits_init() m68k: introduce arch_zone_limits_init() microblaze: introduce arch_zone_limits_init() mips: introduce arch_zone_limits_init() nios2: introduce arch_zone_limits_init() openrisc: introduce arch_zone_limits_init() parisc: introduce arch_zone_limits_init() powerpc: introduce arch_zone_limits_init() riscv: introduce arch_zone_limits_init() s390: introduce arch_zone_limits_init() sh: introduce arch_zone_limits_init() sparc: introduce arch_zone_limits_init() um: introduce arch_zone_limits_init() x86: introduce arch_zone_limits_init() xtensa: introduce arch_zone_limits_init() arch, mm: consolidate initialization of nodes, zones and memory map arch, mm: consolidate initialization of SPARSE memory model mips: drop paging_init() x86: don't reserve hugetlb memory in setup_arch() mm, arch: consolidate hugetlb CMA reservation mm/hugetlb: drop hugetlb_cma_check() Revert "mm/hugetlb: deal with multiple calls to hugetlb_bootmem_alloc" .../driver-api/cxl/linux/early-boot.rst | 2 +- Documentation/mm/memory-model.rst | 3 -- .../translations/zh_CN/mm/memory-model.rst | 2 - arch/alpha/kernel/setup.c | 1 - arch/alpha/mm/init.c | 16 ++++---- arch/arc/mm/init.c | 37 +++++++++--------- arch/arm/include/asm/pgtable.h | 4 +- arch/arm/mm/init.c | 25 ++---------- arch/arm/mm/mmu.c | 10 +---- arch/arm/mm/nommu.c | 10 +---- arch/arm64/include/asm/hugetlb.h | 2 - arch/arm64/mm/hugetlbpage.c | 10 ++--- arch/arm64/mm/init.c | 39 ++++++++----------- arch/csky/kernel/setup.c | 16 ++++---- arch/hexagon/mm/init.c | 19 +++------ arch/loongarch/include/asm/pgtable.h | 2 - arch/loongarch/kernel/setup.c | 10 ----- arch/loongarch/mm/init.c | 6 +-- arch/m68k/mm/init.c | 8 ++-- arch/m68k/mm/mcfmmu.c | 3 -- arch/m68k/mm/motorola.c | 6 +-- arch/m68k/mm/sun3mmu.c | 9 ----- arch/microblaze/mm/init.c | 22 +++++------ arch/mips/include/asm/pgalloc.h | 2 - arch/mips/include/asm/pgtable.h | 2 +- arch/mips/kernel/setup.c | 15 +------ arch/mips/loongson64/numa.c | 10 ++--- arch/mips/mm/init.c | 8 +--- arch/mips/sgi-ip27/ip27-memory.c | 8 +--- arch/nios2/mm/init.c | 12 +++--- arch/openrisc/mm/init.c | 10 +---- arch/parisc/mm/init.c | 11 +----- arch/powerpc/include/asm/hugetlb.h | 5 --- arch/powerpc/include/asm/setup.h | 4 ++ arch/powerpc/kernel/setup-common.c | 1 - arch/powerpc/mm/hugetlbpage.c | 11 ++---- arch/powerpc/mm/mem.c | 27 +++++-------- arch/powerpc/mm/numa.c | 2 - arch/riscv/mm/hugetlbpage.c | 8 ++++ arch/riscv/mm/init.c | 10 +---- arch/s390/kernel/setup.c | 2 - arch/s390/mm/hugetlbpage.c | 8 ++++ arch/s390/mm/init.c | 13 +++---- arch/sh/mm/init.c | 12 +++--- arch/sparc/mm/init_64.c | 17 +++----- arch/sparc/mm/srmmu.c | 17 ++++---- arch/um/kernel/mem.c | 10 ++--- arch/x86/kernel/setup.c | 5 --- arch/x86/mm/hugetlbpage.c | 8 ++++ arch/x86/mm/init.c | 8 +--- arch/x86/mm/init_32.c | 2 - arch/x86/mm/init_64.c | 4 -- arch/x86/mm/mm_internal.h | 1 - arch/xtensa/mm/init.c | 14 +++---- include/linux/hugetlb.h | 12 ++---- include/linux/mm.h | 5 ++- include/linux/mmzone.h | 2 - init/main.c | 1 + mm/hugetlb.c | 13 ------- mm/hugetlb_cma.c | 33 ++++++++-------- mm/hugetlb_cma.h | 5 --- mm/hugetlb_vmemmap.c | 11 ------ mm/internal.h | 6 +++ mm/mm_init.c | 20 ++++++---- 64 files changed, 223 insertions(+), 414 deletions(-) base-commit: 8f0b4cce4481fb22653697cced8d0d04027cb1e8 -- 2.51.0
null
null
null
[PATCH v3 00/29] arch, mm: consolidate hugetlb early reservation
From: "Mike Rapoport (Microsoft)" <rppt@kernel.org> Move calculations of zone limits to a dedicated arch_zone_limits_init() function. Later MM core will use this function as an architecture specific callback during nodes and zones initialization and thus there won't be a need to call free_area_init() from every architecture. Signed-off-by: Mike Rapoport (Microsoft) <rppt@kernel.org> Acked-by: Magnus Lindholm <linmag7@gmail.com> --- arch/alpha/mm/init.c | 15 ++++++++++----- include/linux/mm.h | 1 + 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/arch/alpha/mm/init.c b/arch/alpha/mm/init.c index 4c5ab9cd8a0a..cd0cb1abde5f 100644 --- a/arch/alpha/mm/init.c +++ b/arch/alpha/mm/init.c @@ -208,12 +208,8 @@ callback_init(void * kernel_end) return kernel_end; } -/* - * paging_init() sets up the memory map. - */ -void __init paging_init(void) +void __init arch_zone_limits_init(unsigned long *max_zone_pfn) { - unsigned long max_zone_pfn[MAX_NR_ZONES] = {0, }; unsigned long dma_pfn; dma_pfn = virt_to_phys((char *)MAX_DMA_ADDRESS) >> PAGE_SHIFT; @@ -221,8 +217,17 @@ void __init paging_init(void) max_zone_pfn[ZONE_DMA] = dma_pfn; max_zone_pfn[ZONE_NORMAL] = max_pfn; +} + +/* + * paging_init() sets up the memory map. + */ +void __init paging_init(void) +{ + unsigned long max_zone_pfn[MAX_NR_ZONES] = {0, }; /* Initialize mem_map[]. */ + arch_zone_limits_init(max_zone_pfn); free_area_init(max_zone_pfn); /* Initialize the kernel's ZERO_PGE. */ diff --git a/include/linux/mm.h b/include/linux/mm.h index 15076261d0c2..628c0e0ac313 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -3552,6 +3552,7 @@ static inline unsigned long get_num_physpages(void) * free_area_init(max_zone_pfns); */ void free_area_init(unsigned long *max_zone_pfn); +void arch_zone_limits_init(unsigned long *max_zone_pfn); unsigned long node_map_pfn_alignment(void); extern unsigned long absent_pages_in_range(unsigned long start_pfn, unsigned long end_pfn); -- 2.51.0
{ "author": "Mike Rapoport <rppt@kernel.org>", "date": "Sun, 11 Jan 2026 10:20:35 +0200", "is_openbsd": false, "thread_id": "b9527ed4-7a5c-42e9-8814-b276b3741f63@suse.cz.mbox.gz" }
lkml_critique
lkml
From: "Mike Rapoport (Microsoft)" <rppt@kernel.org> Hi, Order in which early memory reservation for hugetlb happens depends on architecture, on configuration options and on command line parameters. Some architectures rely on the core MM to call hugetlb_bootmem_alloc() while others call it very early to allow pre-allocation of HVO-style vmemmap. When hugetlb_cma is supported by an architecture it is initialized during setup_arch() and then later hugetlb_init code needs to understand did it happen or not. To make everything consistent and unified, both reservation of hugetlb memory from bootmem and creation of CMA areas for hugetlb must be called from core MM initialization and it would have been a simple change. However, HVO-style pre-initialization ordering requirements slightly complicate things and for HVO pre-init to work sparse and memory map should be initialized after hugetlb reservations. This required pulling out the call to free_area_init() out of setup_arch() path and moving it MM initialization and this is what the first 23 patches do. These changes are deliberately split into per-arch patches that change how the zone limits are calculated for each architecture and the patches 22 and 23 just remove the calls to free_area_init() and sprase_init() from arch/*. Patch 24 is a simple cleanup for MIPS. Patches 25 and 26 actually consolidate hugetlb reservations and patches 27 and 28 perform some aftermath cleanups. I tried to trim the distribution list and although it's still quite long if you feel that someone was wrongly excluded please add them back. The changes also available in git: https://git.kernel.org/pub/scm/linux/kernel/git/rppt/linux.git/log/?h=hugetlb-init/v3 v3 changes: * fix empty_zero_page initialization on arm * fix ZONE_DMA limit calculation on powerpc * add Acks v2: https://lore.kernel.org/all/20260102070005.65328-1-rppt@kernel.org * move the hugetlb and memory map initializaion to mm_core_init_early() * add Acks v1: https://lore.kernel.org/all/20251228124001.3624742-1-rppt@kernel.org Klara Modin (1): arm: make initialization of zero page independent of the memory map Mike Rapoport (Microsoft) (28): alpha: introduce arch_zone_limits_init() arc: introduce arch_zone_limits_init() arm: introduce arch_zone_limits_init() arm64: introduce arch_zone_limits_init() csky: introduce arch_zone_limits_init() hexagon: introduce arch_zone_limits_init() loongarch: introduce arch_zone_limits_init() m68k: introduce arch_zone_limits_init() microblaze: introduce arch_zone_limits_init() mips: introduce arch_zone_limits_init() nios2: introduce arch_zone_limits_init() openrisc: introduce arch_zone_limits_init() parisc: introduce arch_zone_limits_init() powerpc: introduce arch_zone_limits_init() riscv: introduce arch_zone_limits_init() s390: introduce arch_zone_limits_init() sh: introduce arch_zone_limits_init() sparc: introduce arch_zone_limits_init() um: introduce arch_zone_limits_init() x86: introduce arch_zone_limits_init() xtensa: introduce arch_zone_limits_init() arch, mm: consolidate initialization of nodes, zones and memory map arch, mm: consolidate initialization of SPARSE memory model mips: drop paging_init() x86: don't reserve hugetlb memory in setup_arch() mm, arch: consolidate hugetlb CMA reservation mm/hugetlb: drop hugetlb_cma_check() Revert "mm/hugetlb: deal with multiple calls to hugetlb_bootmem_alloc" .../driver-api/cxl/linux/early-boot.rst | 2 +- Documentation/mm/memory-model.rst | 3 -- .../translations/zh_CN/mm/memory-model.rst | 2 - arch/alpha/kernel/setup.c | 1 - arch/alpha/mm/init.c | 16 ++++---- arch/arc/mm/init.c | 37 +++++++++--------- arch/arm/include/asm/pgtable.h | 4 +- arch/arm/mm/init.c | 25 ++---------- arch/arm/mm/mmu.c | 10 +---- arch/arm/mm/nommu.c | 10 +---- arch/arm64/include/asm/hugetlb.h | 2 - arch/arm64/mm/hugetlbpage.c | 10 ++--- arch/arm64/mm/init.c | 39 ++++++++----------- arch/csky/kernel/setup.c | 16 ++++---- arch/hexagon/mm/init.c | 19 +++------ arch/loongarch/include/asm/pgtable.h | 2 - arch/loongarch/kernel/setup.c | 10 ----- arch/loongarch/mm/init.c | 6 +-- arch/m68k/mm/init.c | 8 ++-- arch/m68k/mm/mcfmmu.c | 3 -- arch/m68k/mm/motorola.c | 6 +-- arch/m68k/mm/sun3mmu.c | 9 ----- arch/microblaze/mm/init.c | 22 +++++------ arch/mips/include/asm/pgalloc.h | 2 - arch/mips/include/asm/pgtable.h | 2 +- arch/mips/kernel/setup.c | 15 +------ arch/mips/loongson64/numa.c | 10 ++--- arch/mips/mm/init.c | 8 +--- arch/mips/sgi-ip27/ip27-memory.c | 8 +--- arch/nios2/mm/init.c | 12 +++--- arch/openrisc/mm/init.c | 10 +---- arch/parisc/mm/init.c | 11 +----- arch/powerpc/include/asm/hugetlb.h | 5 --- arch/powerpc/include/asm/setup.h | 4 ++ arch/powerpc/kernel/setup-common.c | 1 - arch/powerpc/mm/hugetlbpage.c | 11 ++---- arch/powerpc/mm/mem.c | 27 +++++-------- arch/powerpc/mm/numa.c | 2 - arch/riscv/mm/hugetlbpage.c | 8 ++++ arch/riscv/mm/init.c | 10 +---- arch/s390/kernel/setup.c | 2 - arch/s390/mm/hugetlbpage.c | 8 ++++ arch/s390/mm/init.c | 13 +++---- arch/sh/mm/init.c | 12 +++--- arch/sparc/mm/init_64.c | 17 +++----- arch/sparc/mm/srmmu.c | 17 ++++---- arch/um/kernel/mem.c | 10 ++--- arch/x86/kernel/setup.c | 5 --- arch/x86/mm/hugetlbpage.c | 8 ++++ arch/x86/mm/init.c | 8 +--- arch/x86/mm/init_32.c | 2 - arch/x86/mm/init_64.c | 4 -- arch/x86/mm/mm_internal.h | 1 - arch/xtensa/mm/init.c | 14 +++---- include/linux/hugetlb.h | 12 ++---- include/linux/mm.h | 5 ++- include/linux/mmzone.h | 2 - init/main.c | 1 + mm/hugetlb.c | 13 ------- mm/hugetlb_cma.c | 33 ++++++++-------- mm/hugetlb_cma.h | 5 --- mm/hugetlb_vmemmap.c | 11 ------ mm/internal.h | 6 +++ mm/mm_init.c | 20 ++++++---- 64 files changed, 223 insertions(+), 414 deletions(-) base-commit: 8f0b4cce4481fb22653697cced8d0d04027cb1e8 -- 2.51.0
null
null
null
[PATCH v3 00/29] arch, mm: consolidate hugetlb early reservation
From: "Mike Rapoport (Microsoft)" <rppt@kernel.org> Move calculations of zone limits to a dedicated arch_zone_limits_init() function. Later MM core will use this function as an architecture specific callback during nodes and zones initialization and thus there won't be a need to call free_area_init() from every architecture. Signed-off-by: Mike Rapoport (Microsoft) <rppt@kernel.org> Acked-by: Vineet Gupta <vgupta@kernel.org> --- arch/arc/mm/init.c | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/arch/arc/mm/init.c b/arch/arc/mm/init.c index a73cc94f806e..ff7974d38011 100644 --- a/arch/arc/mm/init.c +++ b/arch/arc/mm/init.c @@ -75,6 +75,25 @@ void __init early_init_dt_add_memory_arch(u64 base, u64 size) base, TO_MB(size), !in_use ? "Not used":""); } +void __init arch_zone_limits_init(unsigned long *max_zone_pfn) +{ + /*----------------- node/zones setup --------------------------*/ + max_zone_pfn[ZONE_NORMAL] = max_low_pfn; + +#ifdef CONFIG_HIGHMEM + /* + * max_high_pfn should be ok here for both HIGHMEM and HIGHMEM+PAE. + * For HIGHMEM without PAE max_high_pfn should be less than + * min_low_pfn to guarantee that these two regions don't overlap. + * For PAE case highmem is greater than lowmem, so it is natural + * to use max_high_pfn. + * + * In both cases, holes should be handled by pfn_valid(). + */ + max_zone_pfn[ZONE_HIGHMEM] = max_high_pfn; +#endif +} + /* * First memory setup routine called from setup_arch() * 1. setup swapper's mm @init_mm @@ -122,9 +141,6 @@ void __init setup_arch_memory(void) memblock_dump_all(); - /*----------------- node/zones setup --------------------------*/ - max_zone_pfn[ZONE_NORMAL] = max_low_pfn; - #ifdef CONFIG_HIGHMEM /* * On ARC (w/o PAE) HIGHMEM addresses are actually smaller (0 based) @@ -139,21 +155,11 @@ void __init setup_arch_memory(void) min_high_pfn = PFN_DOWN(high_mem_start); max_high_pfn = PFN_DOWN(high_mem_start + high_mem_sz); - /* - * max_high_pfn should be ok here for both HIGHMEM and HIGHMEM+PAE. - * For HIGHMEM without PAE max_high_pfn should be less than - * min_low_pfn to guarantee that these two regions don't overlap. - * For PAE case highmem is greater than lowmem, so it is natural - * to use max_high_pfn. - * - * In both cases, holes should be handled by pfn_valid(). - */ - max_zone_pfn[ZONE_HIGHMEM] = max_high_pfn; - arch_pfn_offset = min(min_low_pfn, min_high_pfn); kmap_init(); #endif /* CONFIG_HIGHMEM */ + arch_zone_limits_init(max_zone_pfn); free_area_init(max_zone_pfn); } -- 2.51.0
{ "author": "Mike Rapoport <rppt@kernel.org>", "date": "Sun, 11 Jan 2026 10:20:36 +0200", "is_openbsd": false, "thread_id": "b9527ed4-7a5c-42e9-8814-b276b3741f63@suse.cz.mbox.gz" }
lkml_critique
lkml
From: "Mike Rapoport (Microsoft)" <rppt@kernel.org> Hi, Order in which early memory reservation for hugetlb happens depends on architecture, on configuration options and on command line parameters. Some architectures rely on the core MM to call hugetlb_bootmem_alloc() while others call it very early to allow pre-allocation of HVO-style vmemmap. When hugetlb_cma is supported by an architecture it is initialized during setup_arch() and then later hugetlb_init code needs to understand did it happen or not. To make everything consistent and unified, both reservation of hugetlb memory from bootmem and creation of CMA areas for hugetlb must be called from core MM initialization and it would have been a simple change. However, HVO-style pre-initialization ordering requirements slightly complicate things and for HVO pre-init to work sparse and memory map should be initialized after hugetlb reservations. This required pulling out the call to free_area_init() out of setup_arch() path and moving it MM initialization and this is what the first 23 patches do. These changes are deliberately split into per-arch patches that change how the zone limits are calculated for each architecture and the patches 22 and 23 just remove the calls to free_area_init() and sprase_init() from arch/*. Patch 24 is a simple cleanup for MIPS. Patches 25 and 26 actually consolidate hugetlb reservations and patches 27 and 28 perform some aftermath cleanups. I tried to trim the distribution list and although it's still quite long if you feel that someone was wrongly excluded please add them back. The changes also available in git: https://git.kernel.org/pub/scm/linux/kernel/git/rppt/linux.git/log/?h=hugetlb-init/v3 v3 changes: * fix empty_zero_page initialization on arm * fix ZONE_DMA limit calculation on powerpc * add Acks v2: https://lore.kernel.org/all/20260102070005.65328-1-rppt@kernel.org * move the hugetlb and memory map initializaion to mm_core_init_early() * add Acks v1: https://lore.kernel.org/all/20251228124001.3624742-1-rppt@kernel.org Klara Modin (1): arm: make initialization of zero page independent of the memory map Mike Rapoport (Microsoft) (28): alpha: introduce arch_zone_limits_init() arc: introduce arch_zone_limits_init() arm: introduce arch_zone_limits_init() arm64: introduce arch_zone_limits_init() csky: introduce arch_zone_limits_init() hexagon: introduce arch_zone_limits_init() loongarch: introduce arch_zone_limits_init() m68k: introduce arch_zone_limits_init() microblaze: introduce arch_zone_limits_init() mips: introduce arch_zone_limits_init() nios2: introduce arch_zone_limits_init() openrisc: introduce arch_zone_limits_init() parisc: introduce arch_zone_limits_init() powerpc: introduce arch_zone_limits_init() riscv: introduce arch_zone_limits_init() s390: introduce arch_zone_limits_init() sh: introduce arch_zone_limits_init() sparc: introduce arch_zone_limits_init() um: introduce arch_zone_limits_init() x86: introduce arch_zone_limits_init() xtensa: introduce arch_zone_limits_init() arch, mm: consolidate initialization of nodes, zones and memory map arch, mm: consolidate initialization of SPARSE memory model mips: drop paging_init() x86: don't reserve hugetlb memory in setup_arch() mm, arch: consolidate hugetlb CMA reservation mm/hugetlb: drop hugetlb_cma_check() Revert "mm/hugetlb: deal with multiple calls to hugetlb_bootmem_alloc" .../driver-api/cxl/linux/early-boot.rst | 2 +- Documentation/mm/memory-model.rst | 3 -- .../translations/zh_CN/mm/memory-model.rst | 2 - arch/alpha/kernel/setup.c | 1 - arch/alpha/mm/init.c | 16 ++++---- arch/arc/mm/init.c | 37 +++++++++--------- arch/arm/include/asm/pgtable.h | 4 +- arch/arm/mm/init.c | 25 ++---------- arch/arm/mm/mmu.c | 10 +---- arch/arm/mm/nommu.c | 10 +---- arch/arm64/include/asm/hugetlb.h | 2 - arch/arm64/mm/hugetlbpage.c | 10 ++--- arch/arm64/mm/init.c | 39 ++++++++----------- arch/csky/kernel/setup.c | 16 ++++---- arch/hexagon/mm/init.c | 19 +++------ arch/loongarch/include/asm/pgtable.h | 2 - arch/loongarch/kernel/setup.c | 10 ----- arch/loongarch/mm/init.c | 6 +-- arch/m68k/mm/init.c | 8 ++-- arch/m68k/mm/mcfmmu.c | 3 -- arch/m68k/mm/motorola.c | 6 +-- arch/m68k/mm/sun3mmu.c | 9 ----- arch/microblaze/mm/init.c | 22 +++++------ arch/mips/include/asm/pgalloc.h | 2 - arch/mips/include/asm/pgtable.h | 2 +- arch/mips/kernel/setup.c | 15 +------ arch/mips/loongson64/numa.c | 10 ++--- arch/mips/mm/init.c | 8 +--- arch/mips/sgi-ip27/ip27-memory.c | 8 +--- arch/nios2/mm/init.c | 12 +++--- arch/openrisc/mm/init.c | 10 +---- arch/parisc/mm/init.c | 11 +----- arch/powerpc/include/asm/hugetlb.h | 5 --- arch/powerpc/include/asm/setup.h | 4 ++ arch/powerpc/kernel/setup-common.c | 1 - arch/powerpc/mm/hugetlbpage.c | 11 ++---- arch/powerpc/mm/mem.c | 27 +++++-------- arch/powerpc/mm/numa.c | 2 - arch/riscv/mm/hugetlbpage.c | 8 ++++ arch/riscv/mm/init.c | 10 +---- arch/s390/kernel/setup.c | 2 - arch/s390/mm/hugetlbpage.c | 8 ++++ arch/s390/mm/init.c | 13 +++---- arch/sh/mm/init.c | 12 +++--- arch/sparc/mm/init_64.c | 17 +++----- arch/sparc/mm/srmmu.c | 17 ++++---- arch/um/kernel/mem.c | 10 ++--- arch/x86/kernel/setup.c | 5 --- arch/x86/mm/hugetlbpage.c | 8 ++++ arch/x86/mm/init.c | 8 +--- arch/x86/mm/init_32.c | 2 - arch/x86/mm/init_64.c | 4 -- arch/x86/mm/mm_internal.h | 1 - arch/xtensa/mm/init.c | 14 +++---- include/linux/hugetlb.h | 12 ++---- include/linux/mm.h | 5 ++- include/linux/mmzone.h | 2 - init/main.c | 1 + mm/hugetlb.c | 13 ------- mm/hugetlb_cma.c | 33 ++++++++-------- mm/hugetlb_cma.h | 5 --- mm/hugetlb_vmemmap.c | 11 ------ mm/internal.h | 6 +++ mm/mm_init.c | 20 ++++++---- 64 files changed, 223 insertions(+), 414 deletions(-) base-commit: 8f0b4cce4481fb22653697cced8d0d04027cb1e8 -- 2.51.0
null
null
null
[PATCH v3 00/29] arch, mm: consolidate hugetlb early reservation
From: "Mike Rapoport (Microsoft)" <rppt@kernel.org> Move calculations of zone limits to a dedicated arch_zone_limits_init() function. Later MM core will use this function as an architecture specific callback during nodes and zones initialization and thus there won't be a need to call free_area_init() from every architecture. Signed-off-by: Mike Rapoport (Microsoft) <rppt@kernel.org> --- arch/arm/mm/init.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c index 54bdca025c9f..bdcc3639681f 100644 --- a/arch/arm/mm/init.c +++ b/arch/arm/mm/init.c @@ -107,18 +107,23 @@ void __init setup_dma_zone(const struct machine_desc *mdesc) #endif } -static void __init zone_sizes_init(unsigned long min, unsigned long max_low, - unsigned long max_high) +void __init arch_zone_limits_init(unsigned long *max_zone_pfn) { - unsigned long max_zone_pfn[MAX_NR_ZONES] = { 0 }; - #ifdef CONFIG_ZONE_DMA - max_zone_pfn[ZONE_DMA] = min(arm_dma_pfn_limit, max_low); + max_zone_pfn[ZONE_DMA] = min(arm_dma_pfn_limit, max_low_pfn); #endif - max_zone_pfn[ZONE_NORMAL] = max_low; + max_zone_pfn[ZONE_NORMAL] = max_low_pfn; #ifdef CONFIG_HIGHMEM - max_zone_pfn[ZONE_HIGHMEM] = max_high; + max_zone_pfn[ZONE_HIGHMEM] = max_pfn; #endif +} + +static void __init zone_sizes_init(unsigned long min, unsigned long max_low, + unsigned long max_high) +{ + unsigned long max_zone_pfn[MAX_NR_ZONES] = { 0 }; + + arch_zone_limits_init(max_zone_pfn); free_area_init(max_zone_pfn); } -- 2.51.0
{ "author": "Mike Rapoport <rppt@kernel.org>", "date": "Sun, 11 Jan 2026 10:20:37 +0200", "is_openbsd": false, "thread_id": "b9527ed4-7a5c-42e9-8814-b276b3741f63@suse.cz.mbox.gz" }
lkml_critique
lkml
From: "Mike Rapoport (Microsoft)" <rppt@kernel.org> Hi, Order in which early memory reservation for hugetlb happens depends on architecture, on configuration options and on command line parameters. Some architectures rely on the core MM to call hugetlb_bootmem_alloc() while others call it very early to allow pre-allocation of HVO-style vmemmap. When hugetlb_cma is supported by an architecture it is initialized during setup_arch() and then later hugetlb_init code needs to understand did it happen or not. To make everything consistent and unified, both reservation of hugetlb memory from bootmem and creation of CMA areas for hugetlb must be called from core MM initialization and it would have been a simple change. However, HVO-style pre-initialization ordering requirements slightly complicate things and for HVO pre-init to work sparse and memory map should be initialized after hugetlb reservations. This required pulling out the call to free_area_init() out of setup_arch() path and moving it MM initialization and this is what the first 23 patches do. These changes are deliberately split into per-arch patches that change how the zone limits are calculated for each architecture and the patches 22 and 23 just remove the calls to free_area_init() and sprase_init() from arch/*. Patch 24 is a simple cleanup for MIPS. Patches 25 and 26 actually consolidate hugetlb reservations and patches 27 and 28 perform some aftermath cleanups. I tried to trim the distribution list and although it's still quite long if you feel that someone was wrongly excluded please add them back. The changes also available in git: https://git.kernel.org/pub/scm/linux/kernel/git/rppt/linux.git/log/?h=hugetlb-init/v3 v3 changes: * fix empty_zero_page initialization on arm * fix ZONE_DMA limit calculation on powerpc * add Acks v2: https://lore.kernel.org/all/20260102070005.65328-1-rppt@kernel.org * move the hugetlb and memory map initializaion to mm_core_init_early() * add Acks v1: https://lore.kernel.org/all/20251228124001.3624742-1-rppt@kernel.org Klara Modin (1): arm: make initialization of zero page independent of the memory map Mike Rapoport (Microsoft) (28): alpha: introduce arch_zone_limits_init() arc: introduce arch_zone_limits_init() arm: introduce arch_zone_limits_init() arm64: introduce arch_zone_limits_init() csky: introduce arch_zone_limits_init() hexagon: introduce arch_zone_limits_init() loongarch: introduce arch_zone_limits_init() m68k: introduce arch_zone_limits_init() microblaze: introduce arch_zone_limits_init() mips: introduce arch_zone_limits_init() nios2: introduce arch_zone_limits_init() openrisc: introduce arch_zone_limits_init() parisc: introduce arch_zone_limits_init() powerpc: introduce arch_zone_limits_init() riscv: introduce arch_zone_limits_init() s390: introduce arch_zone_limits_init() sh: introduce arch_zone_limits_init() sparc: introduce arch_zone_limits_init() um: introduce arch_zone_limits_init() x86: introduce arch_zone_limits_init() xtensa: introduce arch_zone_limits_init() arch, mm: consolidate initialization of nodes, zones and memory map arch, mm: consolidate initialization of SPARSE memory model mips: drop paging_init() x86: don't reserve hugetlb memory in setup_arch() mm, arch: consolidate hugetlb CMA reservation mm/hugetlb: drop hugetlb_cma_check() Revert "mm/hugetlb: deal with multiple calls to hugetlb_bootmem_alloc" .../driver-api/cxl/linux/early-boot.rst | 2 +- Documentation/mm/memory-model.rst | 3 -- .../translations/zh_CN/mm/memory-model.rst | 2 - arch/alpha/kernel/setup.c | 1 - arch/alpha/mm/init.c | 16 ++++---- arch/arc/mm/init.c | 37 +++++++++--------- arch/arm/include/asm/pgtable.h | 4 +- arch/arm/mm/init.c | 25 ++---------- arch/arm/mm/mmu.c | 10 +---- arch/arm/mm/nommu.c | 10 +---- arch/arm64/include/asm/hugetlb.h | 2 - arch/arm64/mm/hugetlbpage.c | 10 ++--- arch/arm64/mm/init.c | 39 ++++++++----------- arch/csky/kernel/setup.c | 16 ++++---- arch/hexagon/mm/init.c | 19 +++------ arch/loongarch/include/asm/pgtable.h | 2 - arch/loongarch/kernel/setup.c | 10 ----- arch/loongarch/mm/init.c | 6 +-- arch/m68k/mm/init.c | 8 ++-- arch/m68k/mm/mcfmmu.c | 3 -- arch/m68k/mm/motorola.c | 6 +-- arch/m68k/mm/sun3mmu.c | 9 ----- arch/microblaze/mm/init.c | 22 +++++------ arch/mips/include/asm/pgalloc.h | 2 - arch/mips/include/asm/pgtable.h | 2 +- arch/mips/kernel/setup.c | 15 +------ arch/mips/loongson64/numa.c | 10 ++--- arch/mips/mm/init.c | 8 +--- arch/mips/sgi-ip27/ip27-memory.c | 8 +--- arch/nios2/mm/init.c | 12 +++--- arch/openrisc/mm/init.c | 10 +---- arch/parisc/mm/init.c | 11 +----- arch/powerpc/include/asm/hugetlb.h | 5 --- arch/powerpc/include/asm/setup.h | 4 ++ arch/powerpc/kernel/setup-common.c | 1 - arch/powerpc/mm/hugetlbpage.c | 11 ++---- arch/powerpc/mm/mem.c | 27 +++++-------- arch/powerpc/mm/numa.c | 2 - arch/riscv/mm/hugetlbpage.c | 8 ++++ arch/riscv/mm/init.c | 10 +---- arch/s390/kernel/setup.c | 2 - arch/s390/mm/hugetlbpage.c | 8 ++++ arch/s390/mm/init.c | 13 +++---- arch/sh/mm/init.c | 12 +++--- arch/sparc/mm/init_64.c | 17 +++----- arch/sparc/mm/srmmu.c | 17 ++++---- arch/um/kernel/mem.c | 10 ++--- arch/x86/kernel/setup.c | 5 --- arch/x86/mm/hugetlbpage.c | 8 ++++ arch/x86/mm/init.c | 8 +--- arch/x86/mm/init_32.c | 2 - arch/x86/mm/init_64.c | 4 -- arch/x86/mm/mm_internal.h | 1 - arch/xtensa/mm/init.c | 14 +++---- include/linux/hugetlb.h | 12 ++---- include/linux/mm.h | 5 ++- include/linux/mmzone.h | 2 - init/main.c | 1 + mm/hugetlb.c | 13 ------- mm/hugetlb_cma.c | 33 ++++++++-------- mm/hugetlb_cma.h | 5 --- mm/hugetlb_vmemmap.c | 11 ------ mm/internal.h | 6 +++ mm/mm_init.c | 20 ++++++---- 64 files changed, 223 insertions(+), 414 deletions(-) base-commit: 8f0b4cce4481fb22653697cced8d0d04027cb1e8 -- 2.51.0
null
null
null
[PATCH v3 00/29] arch, mm: consolidate hugetlb early reservation
From: Klara Modin <klarasmodin@gmail.com> Unlike most architectures, arm keeps a struct page pointer to the empty_zero_page and to initialize it requires conversion of a virtual address to page which makes it necessary to have memory map initialized before creating the empty_zero_page. Make empty_zero_page a stataic array in BSS to decouple it's initialization from the initialization of the memory map. This also aligns arm with vast majorty of architectures. Signed-off-by: Klara Modin <klarasmodin@gmail.com> Signed-off-by: Mike Rapoport (Microsoft) <rppt@kernel.org> --- arch/arm/include/asm/pgtable.h | 4 ++-- arch/arm/mm/mmu.c | 10 +--------- arch/arm/mm/nommu.c | 10 +--------- 3 files changed, 4 insertions(+), 20 deletions(-) diff --git a/arch/arm/include/asm/pgtable.h b/arch/arm/include/asm/pgtable.h index 86378eec7757..6fa9acd6a7f5 100644 --- a/arch/arm/include/asm/pgtable.h +++ b/arch/arm/include/asm/pgtable.h @@ -15,8 +15,8 @@ * ZERO_PAGE is a global shared page that is always zero: used * for zero-mapped memory areas etc.. */ -extern struct page *empty_zero_page; -#define ZERO_PAGE(vaddr) (empty_zero_page) +extern unsigned long empty_zero_page[PAGE_SIZE / sizeof(unsigned long)]; +#define ZERO_PAGE(vaddr) (virt_to_page(empty_zero_page)) #endif #include <asm-generic/pgtable-nopud.h> diff --git a/arch/arm/mm/mmu.c b/arch/arm/mm/mmu.c index 8bac96e205ac..518def8314e7 100644 --- a/arch/arm/mm/mmu.c +++ b/arch/arm/mm/mmu.c @@ -45,7 +45,7 @@ extern unsigned long __atags_pointer; * empty_zero_page is a special page that is used for * zero-initialized data and COW. */ -struct page *empty_zero_page; +unsigned long empty_zero_page[PAGE_SIZE / sizeof(unsigned long)] __page_aligned_bss; EXPORT_SYMBOL(empty_zero_page); /* @@ -1754,8 +1754,6 @@ static void __init early_fixmap_shutdown(void) */ void __init paging_init(const struct machine_desc *mdesc) { - void *zero_page; - #ifdef CONFIG_XIP_KERNEL /* Store the kernel RW RAM region start/end in these variables */ kernel_sec_start = CONFIG_PHYS_OFFSET & SECTION_MASK; @@ -1781,13 +1779,7 @@ void __init paging_init(const struct machine_desc *mdesc) top_pmd = pmd_off_k(0xffff0000); - /* allocate the zero page. */ - zero_page = early_alloc(PAGE_SIZE); - bootmem_init(); - - empty_zero_page = virt_to_page(zero_page); - __flush_dcache_folio(NULL, page_folio(empty_zero_page)); } void __init early_mm_init(const struct machine_desc *mdesc) diff --git a/arch/arm/mm/nommu.c b/arch/arm/mm/nommu.c index d638cc87807e..7e42d8accec6 100644 --- a/arch/arm/mm/nommu.c +++ b/arch/arm/mm/nommu.c @@ -31,7 +31,7 @@ unsigned long vectors_base; * empty_zero_page is a special page that is used for * zero-initialized data and COW. */ -struct page *empty_zero_page; +unsigned long empty_zero_page[PAGE_SIZE / sizeof(unsigned long)] __page_aligned_bss; EXPORT_SYMBOL(empty_zero_page); #ifdef CONFIG_ARM_MPU @@ -156,18 +156,10 @@ void __init adjust_lowmem_bounds(void) */ void __init paging_init(const struct machine_desc *mdesc) { - void *zero_page; - early_trap_init((void *)vectors_base); mpu_setup(); - /* allocate the zero page. */ - zero_page = (void *)memblock_alloc_or_panic(PAGE_SIZE, PAGE_SIZE); - bootmem_init(); - - empty_zero_page = virt_to_page(zero_page); - flush_dcache_page(empty_zero_page); } /* -- 2.51.0
{ "author": "Mike Rapoport <rppt@kernel.org>", "date": "Sun, 11 Jan 2026 10:20:38 +0200", "is_openbsd": false, "thread_id": "b9527ed4-7a5c-42e9-8814-b276b3741f63@suse.cz.mbox.gz" }
lkml_critique
lkml
From: "Mike Rapoport (Microsoft)" <rppt@kernel.org> Hi, Order in which early memory reservation for hugetlb happens depends on architecture, on configuration options and on command line parameters. Some architectures rely on the core MM to call hugetlb_bootmem_alloc() while others call it very early to allow pre-allocation of HVO-style vmemmap. When hugetlb_cma is supported by an architecture it is initialized during setup_arch() and then later hugetlb_init code needs to understand did it happen or not. To make everything consistent and unified, both reservation of hugetlb memory from bootmem and creation of CMA areas for hugetlb must be called from core MM initialization and it would have been a simple change. However, HVO-style pre-initialization ordering requirements slightly complicate things and for HVO pre-init to work sparse and memory map should be initialized after hugetlb reservations. This required pulling out the call to free_area_init() out of setup_arch() path and moving it MM initialization and this is what the first 23 patches do. These changes are deliberately split into per-arch patches that change how the zone limits are calculated for each architecture and the patches 22 and 23 just remove the calls to free_area_init() and sprase_init() from arch/*. Patch 24 is a simple cleanup for MIPS. Patches 25 and 26 actually consolidate hugetlb reservations and patches 27 and 28 perform some aftermath cleanups. I tried to trim the distribution list and although it's still quite long if you feel that someone was wrongly excluded please add them back. The changes also available in git: https://git.kernel.org/pub/scm/linux/kernel/git/rppt/linux.git/log/?h=hugetlb-init/v3 v3 changes: * fix empty_zero_page initialization on arm * fix ZONE_DMA limit calculation on powerpc * add Acks v2: https://lore.kernel.org/all/20260102070005.65328-1-rppt@kernel.org * move the hugetlb and memory map initializaion to mm_core_init_early() * add Acks v1: https://lore.kernel.org/all/20251228124001.3624742-1-rppt@kernel.org Klara Modin (1): arm: make initialization of zero page independent of the memory map Mike Rapoport (Microsoft) (28): alpha: introduce arch_zone_limits_init() arc: introduce arch_zone_limits_init() arm: introduce arch_zone_limits_init() arm64: introduce arch_zone_limits_init() csky: introduce arch_zone_limits_init() hexagon: introduce arch_zone_limits_init() loongarch: introduce arch_zone_limits_init() m68k: introduce arch_zone_limits_init() microblaze: introduce arch_zone_limits_init() mips: introduce arch_zone_limits_init() nios2: introduce arch_zone_limits_init() openrisc: introduce arch_zone_limits_init() parisc: introduce arch_zone_limits_init() powerpc: introduce arch_zone_limits_init() riscv: introduce arch_zone_limits_init() s390: introduce arch_zone_limits_init() sh: introduce arch_zone_limits_init() sparc: introduce arch_zone_limits_init() um: introduce arch_zone_limits_init() x86: introduce arch_zone_limits_init() xtensa: introduce arch_zone_limits_init() arch, mm: consolidate initialization of nodes, zones and memory map arch, mm: consolidate initialization of SPARSE memory model mips: drop paging_init() x86: don't reserve hugetlb memory in setup_arch() mm, arch: consolidate hugetlb CMA reservation mm/hugetlb: drop hugetlb_cma_check() Revert "mm/hugetlb: deal with multiple calls to hugetlb_bootmem_alloc" .../driver-api/cxl/linux/early-boot.rst | 2 +- Documentation/mm/memory-model.rst | 3 -- .../translations/zh_CN/mm/memory-model.rst | 2 - arch/alpha/kernel/setup.c | 1 - arch/alpha/mm/init.c | 16 ++++---- arch/arc/mm/init.c | 37 +++++++++--------- arch/arm/include/asm/pgtable.h | 4 +- arch/arm/mm/init.c | 25 ++---------- arch/arm/mm/mmu.c | 10 +---- arch/arm/mm/nommu.c | 10 +---- arch/arm64/include/asm/hugetlb.h | 2 - arch/arm64/mm/hugetlbpage.c | 10 ++--- arch/arm64/mm/init.c | 39 ++++++++----------- arch/csky/kernel/setup.c | 16 ++++---- arch/hexagon/mm/init.c | 19 +++------ arch/loongarch/include/asm/pgtable.h | 2 - arch/loongarch/kernel/setup.c | 10 ----- arch/loongarch/mm/init.c | 6 +-- arch/m68k/mm/init.c | 8 ++-- arch/m68k/mm/mcfmmu.c | 3 -- arch/m68k/mm/motorola.c | 6 +-- arch/m68k/mm/sun3mmu.c | 9 ----- arch/microblaze/mm/init.c | 22 +++++------ arch/mips/include/asm/pgalloc.h | 2 - arch/mips/include/asm/pgtable.h | 2 +- arch/mips/kernel/setup.c | 15 +------ arch/mips/loongson64/numa.c | 10 ++--- arch/mips/mm/init.c | 8 +--- arch/mips/sgi-ip27/ip27-memory.c | 8 +--- arch/nios2/mm/init.c | 12 +++--- arch/openrisc/mm/init.c | 10 +---- arch/parisc/mm/init.c | 11 +----- arch/powerpc/include/asm/hugetlb.h | 5 --- arch/powerpc/include/asm/setup.h | 4 ++ arch/powerpc/kernel/setup-common.c | 1 - arch/powerpc/mm/hugetlbpage.c | 11 ++---- arch/powerpc/mm/mem.c | 27 +++++-------- arch/powerpc/mm/numa.c | 2 - arch/riscv/mm/hugetlbpage.c | 8 ++++ arch/riscv/mm/init.c | 10 +---- arch/s390/kernel/setup.c | 2 - arch/s390/mm/hugetlbpage.c | 8 ++++ arch/s390/mm/init.c | 13 +++---- arch/sh/mm/init.c | 12 +++--- arch/sparc/mm/init_64.c | 17 +++----- arch/sparc/mm/srmmu.c | 17 ++++---- arch/um/kernel/mem.c | 10 ++--- arch/x86/kernel/setup.c | 5 --- arch/x86/mm/hugetlbpage.c | 8 ++++ arch/x86/mm/init.c | 8 +--- arch/x86/mm/init_32.c | 2 - arch/x86/mm/init_64.c | 4 -- arch/x86/mm/mm_internal.h | 1 - arch/xtensa/mm/init.c | 14 +++---- include/linux/hugetlb.h | 12 ++---- include/linux/mm.h | 5 ++- include/linux/mmzone.h | 2 - init/main.c | 1 + mm/hugetlb.c | 13 ------- mm/hugetlb_cma.c | 33 ++++++++-------- mm/hugetlb_cma.h | 5 --- mm/hugetlb_vmemmap.c | 11 ------ mm/internal.h | 6 +++ mm/mm_init.c | 20 ++++++---- 64 files changed, 223 insertions(+), 414 deletions(-) base-commit: 8f0b4cce4481fb22653697cced8d0d04027cb1e8 -- 2.51.0
null
null
null
[PATCH v3 00/29] arch, mm: consolidate hugetlb early reservation
From: "Mike Rapoport (Microsoft)" <rppt@kernel.org> Move calculations of zone limits to a dedicated arch_zone_limits_init() function. Later MM core will use this function as an architecture specific callback during nodes and zones initialization and thus there won't be a need to call free_area_init() from every architecture. While on it rename zone_sizes_init() to dma_limits_init() to better reflect what that function does. Signed-off-by: Mike Rapoport (Microsoft) <rppt@kernel.org> --- arch/arm64/mm/init.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c index 524d34a0e921..06815d34cc11 100644 --- a/arch/arm64/mm/init.c +++ b/arch/arm64/mm/init.c @@ -118,7 +118,21 @@ static phys_addr_t __init max_zone_phys(phys_addr_t zone_limit) return min(zone_limit, memblock_end_of_DRAM() - 1) + 1; } -static void __init zone_sizes_init(void) +void __init arch_zone_limits_init(unsigned long *max_zone_pfns) +{ + phys_addr_t __maybe_unused dma32_phys_limit = + max_zone_phys(DMA_BIT_MASK(32)); + +#ifdef CONFIG_ZONE_DMA + max_zone_pfns[ZONE_DMA] = PFN_DOWN(max_zone_phys(zone_dma_limit)); +#endif +#ifdef CONFIG_ZONE_DMA32 + max_zone_pfns[ZONE_DMA32] = PFN_DOWN(dma32_phys_limit); +#endif + max_zone_pfns[ZONE_NORMAL] = max_pfn; +} + +static void __init dma_limits_init(void) { unsigned long max_zone_pfns[MAX_NR_ZONES] = {0}; phys_addr_t __maybe_unused acpi_zone_dma_limit; @@ -139,17 +153,15 @@ static void __init zone_sizes_init(void) if (memblock_start_of_DRAM() < U32_MAX) zone_dma_limit = min(zone_dma_limit, U32_MAX); arm64_dma_phys_limit = max_zone_phys(zone_dma_limit); - max_zone_pfns[ZONE_DMA] = PFN_DOWN(arm64_dma_phys_limit); #endif #ifdef CONFIG_ZONE_DMA32 - max_zone_pfns[ZONE_DMA32] = PFN_DOWN(dma32_phys_limit); if (!arm64_dma_phys_limit) arm64_dma_phys_limit = dma32_phys_limit; #endif if (!arm64_dma_phys_limit) arm64_dma_phys_limit = PHYS_MASK + 1; - max_zone_pfns[ZONE_NORMAL] = max_pfn; + arch_zone_limits_init(max_zone_pfns); free_area_init(max_zone_pfns); } @@ -319,7 +331,7 @@ void __init bootmem_init(void) * done after the fixed reservations */ sparse_init(); - zone_sizes_init(); + dma_limits_init(); /* * Reserve the CMA area after arm64_dma_phys_limit was initialised. -- 2.51.0
{ "author": "Mike Rapoport <rppt@kernel.org>", "date": "Sun, 11 Jan 2026 10:20:39 +0200", "is_openbsd": false, "thread_id": "b9527ed4-7a5c-42e9-8814-b276b3741f63@suse.cz.mbox.gz" }
lkml_critique
lkml
From: "Mike Rapoport (Microsoft)" <rppt@kernel.org> Hi, Order in which early memory reservation for hugetlb happens depends on architecture, on configuration options and on command line parameters. Some architectures rely on the core MM to call hugetlb_bootmem_alloc() while others call it very early to allow pre-allocation of HVO-style vmemmap. When hugetlb_cma is supported by an architecture it is initialized during setup_arch() and then later hugetlb_init code needs to understand did it happen or not. To make everything consistent and unified, both reservation of hugetlb memory from bootmem and creation of CMA areas for hugetlb must be called from core MM initialization and it would have been a simple change. However, HVO-style pre-initialization ordering requirements slightly complicate things and for HVO pre-init to work sparse and memory map should be initialized after hugetlb reservations. This required pulling out the call to free_area_init() out of setup_arch() path and moving it MM initialization and this is what the first 23 patches do. These changes are deliberately split into per-arch patches that change how the zone limits are calculated for each architecture and the patches 22 and 23 just remove the calls to free_area_init() and sprase_init() from arch/*. Patch 24 is a simple cleanup for MIPS. Patches 25 and 26 actually consolidate hugetlb reservations and patches 27 and 28 perform some aftermath cleanups. I tried to trim the distribution list and although it's still quite long if you feel that someone was wrongly excluded please add them back. The changes also available in git: https://git.kernel.org/pub/scm/linux/kernel/git/rppt/linux.git/log/?h=hugetlb-init/v3 v3 changes: * fix empty_zero_page initialization on arm * fix ZONE_DMA limit calculation on powerpc * add Acks v2: https://lore.kernel.org/all/20260102070005.65328-1-rppt@kernel.org * move the hugetlb and memory map initializaion to mm_core_init_early() * add Acks v1: https://lore.kernel.org/all/20251228124001.3624742-1-rppt@kernel.org Klara Modin (1): arm: make initialization of zero page independent of the memory map Mike Rapoport (Microsoft) (28): alpha: introduce arch_zone_limits_init() arc: introduce arch_zone_limits_init() arm: introduce arch_zone_limits_init() arm64: introduce arch_zone_limits_init() csky: introduce arch_zone_limits_init() hexagon: introduce arch_zone_limits_init() loongarch: introduce arch_zone_limits_init() m68k: introduce arch_zone_limits_init() microblaze: introduce arch_zone_limits_init() mips: introduce arch_zone_limits_init() nios2: introduce arch_zone_limits_init() openrisc: introduce arch_zone_limits_init() parisc: introduce arch_zone_limits_init() powerpc: introduce arch_zone_limits_init() riscv: introduce arch_zone_limits_init() s390: introduce arch_zone_limits_init() sh: introduce arch_zone_limits_init() sparc: introduce arch_zone_limits_init() um: introduce arch_zone_limits_init() x86: introduce arch_zone_limits_init() xtensa: introduce arch_zone_limits_init() arch, mm: consolidate initialization of nodes, zones and memory map arch, mm: consolidate initialization of SPARSE memory model mips: drop paging_init() x86: don't reserve hugetlb memory in setup_arch() mm, arch: consolidate hugetlb CMA reservation mm/hugetlb: drop hugetlb_cma_check() Revert "mm/hugetlb: deal with multiple calls to hugetlb_bootmem_alloc" .../driver-api/cxl/linux/early-boot.rst | 2 +- Documentation/mm/memory-model.rst | 3 -- .../translations/zh_CN/mm/memory-model.rst | 2 - arch/alpha/kernel/setup.c | 1 - arch/alpha/mm/init.c | 16 ++++---- arch/arc/mm/init.c | 37 +++++++++--------- arch/arm/include/asm/pgtable.h | 4 +- arch/arm/mm/init.c | 25 ++---------- arch/arm/mm/mmu.c | 10 +---- arch/arm/mm/nommu.c | 10 +---- arch/arm64/include/asm/hugetlb.h | 2 - arch/arm64/mm/hugetlbpage.c | 10 ++--- arch/arm64/mm/init.c | 39 ++++++++----------- arch/csky/kernel/setup.c | 16 ++++---- arch/hexagon/mm/init.c | 19 +++------ arch/loongarch/include/asm/pgtable.h | 2 - arch/loongarch/kernel/setup.c | 10 ----- arch/loongarch/mm/init.c | 6 +-- arch/m68k/mm/init.c | 8 ++-- arch/m68k/mm/mcfmmu.c | 3 -- arch/m68k/mm/motorola.c | 6 +-- arch/m68k/mm/sun3mmu.c | 9 ----- arch/microblaze/mm/init.c | 22 +++++------ arch/mips/include/asm/pgalloc.h | 2 - arch/mips/include/asm/pgtable.h | 2 +- arch/mips/kernel/setup.c | 15 +------ arch/mips/loongson64/numa.c | 10 ++--- arch/mips/mm/init.c | 8 +--- arch/mips/sgi-ip27/ip27-memory.c | 8 +--- arch/nios2/mm/init.c | 12 +++--- arch/openrisc/mm/init.c | 10 +---- arch/parisc/mm/init.c | 11 +----- arch/powerpc/include/asm/hugetlb.h | 5 --- arch/powerpc/include/asm/setup.h | 4 ++ arch/powerpc/kernel/setup-common.c | 1 - arch/powerpc/mm/hugetlbpage.c | 11 ++---- arch/powerpc/mm/mem.c | 27 +++++-------- arch/powerpc/mm/numa.c | 2 - arch/riscv/mm/hugetlbpage.c | 8 ++++ arch/riscv/mm/init.c | 10 +---- arch/s390/kernel/setup.c | 2 - arch/s390/mm/hugetlbpage.c | 8 ++++ arch/s390/mm/init.c | 13 +++---- arch/sh/mm/init.c | 12 +++--- arch/sparc/mm/init_64.c | 17 +++----- arch/sparc/mm/srmmu.c | 17 ++++---- arch/um/kernel/mem.c | 10 ++--- arch/x86/kernel/setup.c | 5 --- arch/x86/mm/hugetlbpage.c | 8 ++++ arch/x86/mm/init.c | 8 +--- arch/x86/mm/init_32.c | 2 - arch/x86/mm/init_64.c | 4 -- arch/x86/mm/mm_internal.h | 1 - arch/xtensa/mm/init.c | 14 +++---- include/linux/hugetlb.h | 12 ++---- include/linux/mm.h | 5 ++- include/linux/mmzone.h | 2 - init/main.c | 1 + mm/hugetlb.c | 13 ------- mm/hugetlb_cma.c | 33 ++++++++-------- mm/hugetlb_cma.h | 5 --- mm/hugetlb_vmemmap.c | 11 ------ mm/internal.h | 6 +++ mm/mm_init.c | 20 ++++++---- 64 files changed, 223 insertions(+), 414 deletions(-) base-commit: 8f0b4cce4481fb22653697cced8d0d04027cb1e8 -- 2.51.0
null
null
null
[PATCH v3 00/29] arch, mm: consolidate hugetlb early reservation
From: "Mike Rapoport (Microsoft)" <rppt@kernel.org> Move calculations of zone limits to a dedicated arch_zone_limits_init() function. Later MM core will use this function as an architecture specific callback during nodes and zones initialization and thus there won't be a need to call free_area_init() from every architecture. Signed-off-by: Mike Rapoport (Microsoft) <rppt@kernel.org> Acked-by: Guo Ren <guoren@kernel.org> --- arch/csky/kernel/setup.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/arch/csky/kernel/setup.c b/arch/csky/kernel/setup.c index e0d6ca86ea8c..8968815d93e6 100644 --- a/arch/csky/kernel/setup.c +++ b/arch/csky/kernel/setup.c @@ -51,6 +51,14 @@ static void __init setup_initrd(void) } #endif +void __init arch_zone_limits_init(unsigned long *max_zone_pfns) +{ + max_zone_pfns[ZONE_NORMAL] = max_low_pfn; +#ifdef CONFIG_HIGHMEM + max_zone_pfns[ZONE_HIGHMEM] = max_pfn; +#endif +} + static void __init csky_memblock_init(void) { unsigned long lowmem_size = PFN_DOWN(LOWMEM_LIMIT - PHYS_OFFSET_OFFSET); @@ -83,12 +91,9 @@ static void __init csky_memblock_init(void) setup_initrd(); #endif - max_zone_pfn[ZONE_NORMAL] = max_low_pfn; - mmu_init(min_low_pfn, max_low_pfn); #ifdef CONFIG_HIGHMEM - max_zone_pfn[ZONE_HIGHMEM] = max_pfn; highstart_pfn = max_low_pfn; highend_pfn = max_pfn; @@ -97,6 +102,7 @@ static void __init csky_memblock_init(void) dma_contiguous_reserve(0); + arch_zone_limits_init(max_zone_pfn); free_area_init(max_zone_pfn); } -- 2.51.0
{ "author": "Mike Rapoport <rppt@kernel.org>", "date": "Sun, 11 Jan 2026 10:20:40 +0200", "is_openbsd": false, "thread_id": "b9527ed4-7a5c-42e9-8814-b276b3741f63@suse.cz.mbox.gz" }
lkml_critique
lkml
From: "Mike Rapoport (Microsoft)" <rppt@kernel.org> Hi, Order in which early memory reservation for hugetlb happens depends on architecture, on configuration options and on command line parameters. Some architectures rely on the core MM to call hugetlb_bootmem_alloc() while others call it very early to allow pre-allocation of HVO-style vmemmap. When hugetlb_cma is supported by an architecture it is initialized during setup_arch() and then later hugetlb_init code needs to understand did it happen or not. To make everything consistent and unified, both reservation of hugetlb memory from bootmem and creation of CMA areas for hugetlb must be called from core MM initialization and it would have been a simple change. However, HVO-style pre-initialization ordering requirements slightly complicate things and for HVO pre-init to work sparse and memory map should be initialized after hugetlb reservations. This required pulling out the call to free_area_init() out of setup_arch() path and moving it MM initialization and this is what the first 23 patches do. These changes are deliberately split into per-arch patches that change how the zone limits are calculated for each architecture and the patches 22 and 23 just remove the calls to free_area_init() and sprase_init() from arch/*. Patch 24 is a simple cleanup for MIPS. Patches 25 and 26 actually consolidate hugetlb reservations and patches 27 and 28 perform some aftermath cleanups. I tried to trim the distribution list and although it's still quite long if you feel that someone was wrongly excluded please add them back. The changes also available in git: https://git.kernel.org/pub/scm/linux/kernel/git/rppt/linux.git/log/?h=hugetlb-init/v3 v3 changes: * fix empty_zero_page initialization on arm * fix ZONE_DMA limit calculation on powerpc * add Acks v2: https://lore.kernel.org/all/20260102070005.65328-1-rppt@kernel.org * move the hugetlb and memory map initializaion to mm_core_init_early() * add Acks v1: https://lore.kernel.org/all/20251228124001.3624742-1-rppt@kernel.org Klara Modin (1): arm: make initialization of zero page independent of the memory map Mike Rapoport (Microsoft) (28): alpha: introduce arch_zone_limits_init() arc: introduce arch_zone_limits_init() arm: introduce arch_zone_limits_init() arm64: introduce arch_zone_limits_init() csky: introduce arch_zone_limits_init() hexagon: introduce arch_zone_limits_init() loongarch: introduce arch_zone_limits_init() m68k: introduce arch_zone_limits_init() microblaze: introduce arch_zone_limits_init() mips: introduce arch_zone_limits_init() nios2: introduce arch_zone_limits_init() openrisc: introduce arch_zone_limits_init() parisc: introduce arch_zone_limits_init() powerpc: introduce arch_zone_limits_init() riscv: introduce arch_zone_limits_init() s390: introduce arch_zone_limits_init() sh: introduce arch_zone_limits_init() sparc: introduce arch_zone_limits_init() um: introduce arch_zone_limits_init() x86: introduce arch_zone_limits_init() xtensa: introduce arch_zone_limits_init() arch, mm: consolidate initialization of nodes, zones and memory map arch, mm: consolidate initialization of SPARSE memory model mips: drop paging_init() x86: don't reserve hugetlb memory in setup_arch() mm, arch: consolidate hugetlb CMA reservation mm/hugetlb: drop hugetlb_cma_check() Revert "mm/hugetlb: deal with multiple calls to hugetlb_bootmem_alloc" .../driver-api/cxl/linux/early-boot.rst | 2 +- Documentation/mm/memory-model.rst | 3 -- .../translations/zh_CN/mm/memory-model.rst | 2 - arch/alpha/kernel/setup.c | 1 - arch/alpha/mm/init.c | 16 ++++---- arch/arc/mm/init.c | 37 +++++++++--------- arch/arm/include/asm/pgtable.h | 4 +- arch/arm/mm/init.c | 25 ++---------- arch/arm/mm/mmu.c | 10 +---- arch/arm/mm/nommu.c | 10 +---- arch/arm64/include/asm/hugetlb.h | 2 - arch/arm64/mm/hugetlbpage.c | 10 ++--- arch/arm64/mm/init.c | 39 ++++++++----------- arch/csky/kernel/setup.c | 16 ++++---- arch/hexagon/mm/init.c | 19 +++------ arch/loongarch/include/asm/pgtable.h | 2 - arch/loongarch/kernel/setup.c | 10 ----- arch/loongarch/mm/init.c | 6 +-- arch/m68k/mm/init.c | 8 ++-- arch/m68k/mm/mcfmmu.c | 3 -- arch/m68k/mm/motorola.c | 6 +-- arch/m68k/mm/sun3mmu.c | 9 ----- arch/microblaze/mm/init.c | 22 +++++------ arch/mips/include/asm/pgalloc.h | 2 - arch/mips/include/asm/pgtable.h | 2 +- arch/mips/kernel/setup.c | 15 +------ arch/mips/loongson64/numa.c | 10 ++--- arch/mips/mm/init.c | 8 +--- arch/mips/sgi-ip27/ip27-memory.c | 8 +--- arch/nios2/mm/init.c | 12 +++--- arch/openrisc/mm/init.c | 10 +---- arch/parisc/mm/init.c | 11 +----- arch/powerpc/include/asm/hugetlb.h | 5 --- arch/powerpc/include/asm/setup.h | 4 ++ arch/powerpc/kernel/setup-common.c | 1 - arch/powerpc/mm/hugetlbpage.c | 11 ++---- arch/powerpc/mm/mem.c | 27 +++++-------- arch/powerpc/mm/numa.c | 2 - arch/riscv/mm/hugetlbpage.c | 8 ++++ arch/riscv/mm/init.c | 10 +---- arch/s390/kernel/setup.c | 2 - arch/s390/mm/hugetlbpage.c | 8 ++++ arch/s390/mm/init.c | 13 +++---- arch/sh/mm/init.c | 12 +++--- arch/sparc/mm/init_64.c | 17 +++----- arch/sparc/mm/srmmu.c | 17 ++++---- arch/um/kernel/mem.c | 10 ++--- arch/x86/kernel/setup.c | 5 --- arch/x86/mm/hugetlbpage.c | 8 ++++ arch/x86/mm/init.c | 8 +--- arch/x86/mm/init_32.c | 2 - arch/x86/mm/init_64.c | 4 -- arch/x86/mm/mm_internal.h | 1 - arch/xtensa/mm/init.c | 14 +++---- include/linux/hugetlb.h | 12 ++---- include/linux/mm.h | 5 ++- include/linux/mmzone.h | 2 - init/main.c | 1 + mm/hugetlb.c | 13 ------- mm/hugetlb_cma.c | 33 ++++++++-------- mm/hugetlb_cma.h | 5 --- mm/hugetlb_vmemmap.c | 11 ------ mm/internal.h | 6 +++ mm/mm_init.c | 20 ++++++---- 64 files changed, 223 insertions(+), 414 deletions(-) base-commit: 8f0b4cce4481fb22653697cced8d0d04027cb1e8 -- 2.51.0
null
null
null
[PATCH v3 00/29] arch, mm: consolidate hugetlb early reservation
From: "Mike Rapoport (Microsoft)" <rppt@kernel.org> Move calculations of zone limits to a dedicated arch_zone_limits_init() function. Later MM core will use this function as an architecture specific callback during nodes and zones initialization and thus there won't be a need to call free_area_init() from every architecture. Signed-off-by: Mike Rapoport (Microsoft) <rppt@kernel.org> --- arch/hexagon/mm/init.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/arch/hexagon/mm/init.c b/arch/hexagon/mm/init.c index 34eb9d424b96..e2c9487d8d34 100644 --- a/arch/hexagon/mm/init.c +++ b/arch/hexagon/mm/init.c @@ -54,6 +54,18 @@ void sync_icache_dcache(pte_t pte) __vmcache_idsync(addr, PAGE_SIZE); } +void __init arch_zone_limits_init(unsigned long *max_zone_pfns) +{ + /* + * This is not particularly well documented anywhere, but + * give ZONE_NORMAL all the memory, including the big holes + * left by the kernel+bootmem_map which are already left as reserved + * in the bootmem_map; free_area_init should see those bits and + * adjust accordingly. + */ + max_zone_pfns[ZONE_NORMAL] = max_low_pfn; +} + /* * In order to set up page allocator "nodes", * somebody has to call free_area_init() for UMA. @@ -65,16 +77,7 @@ static void __init paging_init(void) { unsigned long max_zone_pfn[MAX_NR_ZONES] = {0, }; - /* - * This is not particularly well documented anywhere, but - * give ZONE_NORMAL all the memory, including the big holes - * left by the kernel+bootmem_map which are already left as reserved - * in the bootmem_map; free_area_init should see those bits and - * adjust accordingly. - */ - - max_zone_pfn[ZONE_NORMAL] = max_low_pfn; - + arch_zone_limits_init(max_zone_pfn); free_area_init(max_zone_pfn); /* sets up the zonelists and mem_map */ /* -- 2.51.0
{ "author": "Mike Rapoport <rppt@kernel.org>", "date": "Sun, 11 Jan 2026 10:20:41 +0200", "is_openbsd": false, "thread_id": "b9527ed4-7a5c-42e9-8814-b276b3741f63@suse.cz.mbox.gz" }
lkml_critique
lkml
From: "Mike Rapoport (Microsoft)" <rppt@kernel.org> Hi, Order in which early memory reservation for hugetlb happens depends on architecture, on configuration options and on command line parameters. Some architectures rely on the core MM to call hugetlb_bootmem_alloc() while others call it very early to allow pre-allocation of HVO-style vmemmap. When hugetlb_cma is supported by an architecture it is initialized during setup_arch() and then later hugetlb_init code needs to understand did it happen or not. To make everything consistent and unified, both reservation of hugetlb memory from bootmem and creation of CMA areas for hugetlb must be called from core MM initialization and it would have been a simple change. However, HVO-style pre-initialization ordering requirements slightly complicate things and for HVO pre-init to work sparse and memory map should be initialized after hugetlb reservations. This required pulling out the call to free_area_init() out of setup_arch() path and moving it MM initialization and this is what the first 23 patches do. These changes are deliberately split into per-arch patches that change how the zone limits are calculated for each architecture and the patches 22 and 23 just remove the calls to free_area_init() and sprase_init() from arch/*. Patch 24 is a simple cleanup for MIPS. Patches 25 and 26 actually consolidate hugetlb reservations and patches 27 and 28 perform some aftermath cleanups. I tried to trim the distribution list and although it's still quite long if you feel that someone was wrongly excluded please add them back. The changes also available in git: https://git.kernel.org/pub/scm/linux/kernel/git/rppt/linux.git/log/?h=hugetlb-init/v3 v3 changes: * fix empty_zero_page initialization on arm * fix ZONE_DMA limit calculation on powerpc * add Acks v2: https://lore.kernel.org/all/20260102070005.65328-1-rppt@kernel.org * move the hugetlb and memory map initializaion to mm_core_init_early() * add Acks v1: https://lore.kernel.org/all/20251228124001.3624742-1-rppt@kernel.org Klara Modin (1): arm: make initialization of zero page independent of the memory map Mike Rapoport (Microsoft) (28): alpha: introduce arch_zone_limits_init() arc: introduce arch_zone_limits_init() arm: introduce arch_zone_limits_init() arm64: introduce arch_zone_limits_init() csky: introduce arch_zone_limits_init() hexagon: introduce arch_zone_limits_init() loongarch: introduce arch_zone_limits_init() m68k: introduce arch_zone_limits_init() microblaze: introduce arch_zone_limits_init() mips: introduce arch_zone_limits_init() nios2: introduce arch_zone_limits_init() openrisc: introduce arch_zone_limits_init() parisc: introduce arch_zone_limits_init() powerpc: introduce arch_zone_limits_init() riscv: introduce arch_zone_limits_init() s390: introduce arch_zone_limits_init() sh: introduce arch_zone_limits_init() sparc: introduce arch_zone_limits_init() um: introduce arch_zone_limits_init() x86: introduce arch_zone_limits_init() xtensa: introduce arch_zone_limits_init() arch, mm: consolidate initialization of nodes, zones and memory map arch, mm: consolidate initialization of SPARSE memory model mips: drop paging_init() x86: don't reserve hugetlb memory in setup_arch() mm, arch: consolidate hugetlb CMA reservation mm/hugetlb: drop hugetlb_cma_check() Revert "mm/hugetlb: deal with multiple calls to hugetlb_bootmem_alloc" .../driver-api/cxl/linux/early-boot.rst | 2 +- Documentation/mm/memory-model.rst | 3 -- .../translations/zh_CN/mm/memory-model.rst | 2 - arch/alpha/kernel/setup.c | 1 - arch/alpha/mm/init.c | 16 ++++---- arch/arc/mm/init.c | 37 +++++++++--------- arch/arm/include/asm/pgtable.h | 4 +- arch/arm/mm/init.c | 25 ++---------- arch/arm/mm/mmu.c | 10 +---- arch/arm/mm/nommu.c | 10 +---- arch/arm64/include/asm/hugetlb.h | 2 - arch/arm64/mm/hugetlbpage.c | 10 ++--- arch/arm64/mm/init.c | 39 ++++++++----------- arch/csky/kernel/setup.c | 16 ++++---- arch/hexagon/mm/init.c | 19 +++------ arch/loongarch/include/asm/pgtable.h | 2 - arch/loongarch/kernel/setup.c | 10 ----- arch/loongarch/mm/init.c | 6 +-- arch/m68k/mm/init.c | 8 ++-- arch/m68k/mm/mcfmmu.c | 3 -- arch/m68k/mm/motorola.c | 6 +-- arch/m68k/mm/sun3mmu.c | 9 ----- arch/microblaze/mm/init.c | 22 +++++------ arch/mips/include/asm/pgalloc.h | 2 - arch/mips/include/asm/pgtable.h | 2 +- arch/mips/kernel/setup.c | 15 +------ arch/mips/loongson64/numa.c | 10 ++--- arch/mips/mm/init.c | 8 +--- arch/mips/sgi-ip27/ip27-memory.c | 8 +--- arch/nios2/mm/init.c | 12 +++--- arch/openrisc/mm/init.c | 10 +---- arch/parisc/mm/init.c | 11 +----- arch/powerpc/include/asm/hugetlb.h | 5 --- arch/powerpc/include/asm/setup.h | 4 ++ arch/powerpc/kernel/setup-common.c | 1 - arch/powerpc/mm/hugetlbpage.c | 11 ++---- arch/powerpc/mm/mem.c | 27 +++++-------- arch/powerpc/mm/numa.c | 2 - arch/riscv/mm/hugetlbpage.c | 8 ++++ arch/riscv/mm/init.c | 10 +---- arch/s390/kernel/setup.c | 2 - arch/s390/mm/hugetlbpage.c | 8 ++++ arch/s390/mm/init.c | 13 +++---- arch/sh/mm/init.c | 12 +++--- arch/sparc/mm/init_64.c | 17 +++----- arch/sparc/mm/srmmu.c | 17 ++++---- arch/um/kernel/mem.c | 10 ++--- arch/x86/kernel/setup.c | 5 --- arch/x86/mm/hugetlbpage.c | 8 ++++ arch/x86/mm/init.c | 8 +--- arch/x86/mm/init_32.c | 2 - arch/x86/mm/init_64.c | 4 -- arch/x86/mm/mm_internal.h | 1 - arch/xtensa/mm/init.c | 14 +++---- include/linux/hugetlb.h | 12 ++---- include/linux/mm.h | 5 ++- include/linux/mmzone.h | 2 - init/main.c | 1 + mm/hugetlb.c | 13 ------- mm/hugetlb_cma.c | 33 ++++++++-------- mm/hugetlb_cma.h | 5 --- mm/hugetlb_vmemmap.c | 11 ------ mm/internal.h | 6 +++ mm/mm_init.c | 20 ++++++---- 64 files changed, 223 insertions(+), 414 deletions(-) base-commit: 8f0b4cce4481fb22653697cced8d0d04027cb1e8 -- 2.51.0
null
null
null
[PATCH v3 00/29] arch, mm: consolidate hugetlb early reservation
From: "Mike Rapoport (Microsoft)" <rppt@kernel.org> Move calculations of zone limits to a dedicated arch_zone_limits_init() function. Later MM core will use this function as an architecture specific callback during nodes and zones initialization and thus there won't be a need to call free_area_init() from every architecture. Signed-off-by: Mike Rapoport (Microsoft) <rppt@kernel.org> --- arch/loongarch/mm/init.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/arch/loongarch/mm/init.c b/arch/loongarch/mm/init.c index 0946662afdd6..17235f87eafb 100644 --- a/arch/loongarch/mm/init.c +++ b/arch/loongarch/mm/init.c @@ -60,15 +60,19 @@ int __ref page_is_ram(unsigned long pfn) return memblock_is_memory(addr) && !memblock_is_reserved(addr); } -void __init paging_init(void) +void __init arch_zone_limits_init(unsigned long *max_zone_pfns) { - unsigned long max_zone_pfns[MAX_NR_ZONES]; - #ifdef CONFIG_ZONE_DMA32 max_zone_pfns[ZONE_DMA32] = MAX_DMA32_PFN; #endif max_zone_pfns[ZONE_NORMAL] = max_low_pfn; +} + +void __init paging_init(void) +{ + unsigned long max_zone_pfns[MAX_NR_ZONES]; + arch_zone_limits_init(max_zone_pfns); free_area_init(max_zone_pfns); } -- 2.51.0
{ "author": "Mike Rapoport <rppt@kernel.org>", "date": "Sun, 11 Jan 2026 10:20:42 +0200", "is_openbsd": false, "thread_id": "b9527ed4-7a5c-42e9-8814-b276b3741f63@suse.cz.mbox.gz" }
lkml_critique
lkml
From: "Mike Rapoport (Microsoft)" <rppt@kernel.org> Hi, Order in which early memory reservation for hugetlb happens depends on architecture, on configuration options and on command line parameters. Some architectures rely on the core MM to call hugetlb_bootmem_alloc() while others call it very early to allow pre-allocation of HVO-style vmemmap. When hugetlb_cma is supported by an architecture it is initialized during setup_arch() and then later hugetlb_init code needs to understand did it happen or not. To make everything consistent and unified, both reservation of hugetlb memory from bootmem and creation of CMA areas for hugetlb must be called from core MM initialization and it would have been a simple change. However, HVO-style pre-initialization ordering requirements slightly complicate things and for HVO pre-init to work sparse and memory map should be initialized after hugetlb reservations. This required pulling out the call to free_area_init() out of setup_arch() path and moving it MM initialization and this is what the first 23 patches do. These changes are deliberately split into per-arch patches that change how the zone limits are calculated for each architecture and the patches 22 and 23 just remove the calls to free_area_init() and sprase_init() from arch/*. Patch 24 is a simple cleanup for MIPS. Patches 25 and 26 actually consolidate hugetlb reservations and patches 27 and 28 perform some aftermath cleanups. I tried to trim the distribution list and although it's still quite long if you feel that someone was wrongly excluded please add them back. The changes also available in git: https://git.kernel.org/pub/scm/linux/kernel/git/rppt/linux.git/log/?h=hugetlb-init/v3 v3 changes: * fix empty_zero_page initialization on arm * fix ZONE_DMA limit calculation on powerpc * add Acks v2: https://lore.kernel.org/all/20260102070005.65328-1-rppt@kernel.org * move the hugetlb and memory map initializaion to mm_core_init_early() * add Acks v1: https://lore.kernel.org/all/20251228124001.3624742-1-rppt@kernel.org Klara Modin (1): arm: make initialization of zero page independent of the memory map Mike Rapoport (Microsoft) (28): alpha: introduce arch_zone_limits_init() arc: introduce arch_zone_limits_init() arm: introduce arch_zone_limits_init() arm64: introduce arch_zone_limits_init() csky: introduce arch_zone_limits_init() hexagon: introduce arch_zone_limits_init() loongarch: introduce arch_zone_limits_init() m68k: introduce arch_zone_limits_init() microblaze: introduce arch_zone_limits_init() mips: introduce arch_zone_limits_init() nios2: introduce arch_zone_limits_init() openrisc: introduce arch_zone_limits_init() parisc: introduce arch_zone_limits_init() powerpc: introduce arch_zone_limits_init() riscv: introduce arch_zone_limits_init() s390: introduce arch_zone_limits_init() sh: introduce arch_zone_limits_init() sparc: introduce arch_zone_limits_init() um: introduce arch_zone_limits_init() x86: introduce arch_zone_limits_init() xtensa: introduce arch_zone_limits_init() arch, mm: consolidate initialization of nodes, zones and memory map arch, mm: consolidate initialization of SPARSE memory model mips: drop paging_init() x86: don't reserve hugetlb memory in setup_arch() mm, arch: consolidate hugetlb CMA reservation mm/hugetlb: drop hugetlb_cma_check() Revert "mm/hugetlb: deal with multiple calls to hugetlb_bootmem_alloc" .../driver-api/cxl/linux/early-boot.rst | 2 +- Documentation/mm/memory-model.rst | 3 -- .../translations/zh_CN/mm/memory-model.rst | 2 - arch/alpha/kernel/setup.c | 1 - arch/alpha/mm/init.c | 16 ++++---- arch/arc/mm/init.c | 37 +++++++++--------- arch/arm/include/asm/pgtable.h | 4 +- arch/arm/mm/init.c | 25 ++---------- arch/arm/mm/mmu.c | 10 +---- arch/arm/mm/nommu.c | 10 +---- arch/arm64/include/asm/hugetlb.h | 2 - arch/arm64/mm/hugetlbpage.c | 10 ++--- arch/arm64/mm/init.c | 39 ++++++++----------- arch/csky/kernel/setup.c | 16 ++++---- arch/hexagon/mm/init.c | 19 +++------ arch/loongarch/include/asm/pgtable.h | 2 - arch/loongarch/kernel/setup.c | 10 ----- arch/loongarch/mm/init.c | 6 +-- arch/m68k/mm/init.c | 8 ++-- arch/m68k/mm/mcfmmu.c | 3 -- arch/m68k/mm/motorola.c | 6 +-- arch/m68k/mm/sun3mmu.c | 9 ----- arch/microblaze/mm/init.c | 22 +++++------ arch/mips/include/asm/pgalloc.h | 2 - arch/mips/include/asm/pgtable.h | 2 +- arch/mips/kernel/setup.c | 15 +------ arch/mips/loongson64/numa.c | 10 ++--- arch/mips/mm/init.c | 8 +--- arch/mips/sgi-ip27/ip27-memory.c | 8 +--- arch/nios2/mm/init.c | 12 +++--- arch/openrisc/mm/init.c | 10 +---- arch/parisc/mm/init.c | 11 +----- arch/powerpc/include/asm/hugetlb.h | 5 --- arch/powerpc/include/asm/setup.h | 4 ++ arch/powerpc/kernel/setup-common.c | 1 - arch/powerpc/mm/hugetlbpage.c | 11 ++---- arch/powerpc/mm/mem.c | 27 +++++-------- arch/powerpc/mm/numa.c | 2 - arch/riscv/mm/hugetlbpage.c | 8 ++++ arch/riscv/mm/init.c | 10 +---- arch/s390/kernel/setup.c | 2 - arch/s390/mm/hugetlbpage.c | 8 ++++ arch/s390/mm/init.c | 13 +++---- arch/sh/mm/init.c | 12 +++--- arch/sparc/mm/init_64.c | 17 +++----- arch/sparc/mm/srmmu.c | 17 ++++---- arch/um/kernel/mem.c | 10 ++--- arch/x86/kernel/setup.c | 5 --- arch/x86/mm/hugetlbpage.c | 8 ++++ arch/x86/mm/init.c | 8 +--- arch/x86/mm/init_32.c | 2 - arch/x86/mm/init_64.c | 4 -- arch/x86/mm/mm_internal.h | 1 - arch/xtensa/mm/init.c | 14 +++---- include/linux/hugetlb.h | 12 ++---- include/linux/mm.h | 5 ++- include/linux/mmzone.h | 2 - init/main.c | 1 + mm/hugetlb.c | 13 ------- mm/hugetlb_cma.c | 33 ++++++++-------- mm/hugetlb_cma.h | 5 --- mm/hugetlb_vmemmap.c | 11 ------ mm/internal.h | 6 +++ mm/mm_init.c | 20 ++++++---- 64 files changed, 223 insertions(+), 414 deletions(-) base-commit: 8f0b4cce4481fb22653697cced8d0d04027cb1e8 -- 2.51.0
null
null
null
[PATCH v3 00/29] arch, mm: consolidate hugetlb early reservation
From: "Mike Rapoport (Microsoft)" <rppt@kernel.org> Move calculations of zone limits to a dedicated arch_zone_limits_init() function. Later MM core will use this function as an architecture specific callback during nodes and zones initialization and thus there won't be a need to call free_area_init() from every architecture. Since all variants of m68k add all memory to ZONE_DMA, it is possible to use unified implementation for arch_zone_limits_init() that sets the end of ZONE_DMA to memblock_end_of_DRAM(). Signed-off-by: Mike Rapoport (Microsoft) <rppt@kernel.org> --- arch/m68k/mm/init.c | 7 ++++++- arch/m68k/mm/mcfmmu.c | 2 +- arch/m68k/mm/motorola.c | 2 +- arch/m68k/mm/sun3mmu.c | 2 +- 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/arch/m68k/mm/init.c b/arch/m68k/mm/init.c index 488411af1b3f..6b1d9d2434b5 100644 --- a/arch/m68k/mm/init.c +++ b/arch/m68k/mm/init.c @@ -40,6 +40,11 @@ void *empty_zero_page; EXPORT_SYMBOL(empty_zero_page); +void __init arch_zone_limits_init(unsigned long *max_zone_pfns) +{ + max_zone_pfns[ZONE_DMA] = PFN_DOWN(memblock_end_of_DRAM()); +} + #ifdef CONFIG_MMU int m68k_virt_to_node_shift; @@ -69,7 +74,7 @@ void __init paging_init(void) high_memory = (void *) end_mem; empty_zero_page = memblock_alloc_or_panic(PAGE_SIZE, PAGE_SIZE); - max_zone_pfn[ZONE_DMA] = end_mem >> PAGE_SHIFT; + arch_zone_limits_init(max_zone_pfn); free_area_init(max_zone_pfn); } diff --git a/arch/m68k/mm/mcfmmu.c b/arch/m68k/mm/mcfmmu.c index 19a75029036c..24a6f7bbd1ce 100644 --- a/arch/m68k/mm/mcfmmu.c +++ b/arch/m68k/mm/mcfmmu.c @@ -73,7 +73,7 @@ void __init paging_init(void) } current->mm = NULL; - max_zone_pfn[ZONE_DMA] = PFN_DOWN(_ramend); + arch_zone_limits_init(max_zone_pfn); free_area_init(max_zone_pfn); } diff --git a/arch/m68k/mm/motorola.c b/arch/m68k/mm/motorola.c index 62283bc2ed79..d6ccd23caf61 100644 --- a/arch/m68k/mm/motorola.c +++ b/arch/m68k/mm/motorola.c @@ -517,6 +517,6 @@ void __init paging_init(void) if (node_present_pages(i)) node_set_state(i, N_NORMAL_MEMORY); - max_zone_pfn[ZONE_DMA] = memblock_end_of_DRAM(); + arch_zone_limits_init(max_zone_pfn); free_area_init(max_zone_pfn); } diff --git a/arch/m68k/mm/sun3mmu.c b/arch/m68k/mm/sun3mmu.c index 1ecf6bdd08bf..fdd69cc4240c 100644 --- a/arch/m68k/mm/sun3mmu.c +++ b/arch/m68k/mm/sun3mmu.c @@ -82,7 +82,7 @@ void __init paging_init(void) current->mm = NULL; /* memory sizing is a hack stolen from motorola.c.. hope it works for us */ - max_zone_pfn[ZONE_DMA] = ((unsigned long)high_memory) >> PAGE_SHIFT; + arch_zone_limits_init(max_zone_pfn); /* I really wish I knew why the following change made things better... -- Sam */ free_area_init(max_zone_pfn); -- 2.51.0
{ "author": "Mike Rapoport <rppt@kernel.org>", "date": "Sun, 11 Jan 2026 10:20:43 +0200", "is_openbsd": false, "thread_id": "b9527ed4-7a5c-42e9-8814-b276b3741f63@suse.cz.mbox.gz" }
lkml_critique
lkml
From: "Mike Rapoport (Microsoft)" <rppt@kernel.org> Hi, Order in which early memory reservation for hugetlb happens depends on architecture, on configuration options and on command line parameters. Some architectures rely on the core MM to call hugetlb_bootmem_alloc() while others call it very early to allow pre-allocation of HVO-style vmemmap. When hugetlb_cma is supported by an architecture it is initialized during setup_arch() and then later hugetlb_init code needs to understand did it happen or not. To make everything consistent and unified, both reservation of hugetlb memory from bootmem and creation of CMA areas for hugetlb must be called from core MM initialization and it would have been a simple change. However, HVO-style pre-initialization ordering requirements slightly complicate things and for HVO pre-init to work sparse and memory map should be initialized after hugetlb reservations. This required pulling out the call to free_area_init() out of setup_arch() path and moving it MM initialization and this is what the first 23 patches do. These changes are deliberately split into per-arch patches that change how the zone limits are calculated for each architecture and the patches 22 and 23 just remove the calls to free_area_init() and sprase_init() from arch/*. Patch 24 is a simple cleanup for MIPS. Patches 25 and 26 actually consolidate hugetlb reservations and patches 27 and 28 perform some aftermath cleanups. I tried to trim the distribution list and although it's still quite long if you feel that someone was wrongly excluded please add them back. The changes also available in git: https://git.kernel.org/pub/scm/linux/kernel/git/rppt/linux.git/log/?h=hugetlb-init/v3 v3 changes: * fix empty_zero_page initialization on arm * fix ZONE_DMA limit calculation on powerpc * add Acks v2: https://lore.kernel.org/all/20260102070005.65328-1-rppt@kernel.org * move the hugetlb and memory map initializaion to mm_core_init_early() * add Acks v1: https://lore.kernel.org/all/20251228124001.3624742-1-rppt@kernel.org Klara Modin (1): arm: make initialization of zero page independent of the memory map Mike Rapoport (Microsoft) (28): alpha: introduce arch_zone_limits_init() arc: introduce arch_zone_limits_init() arm: introduce arch_zone_limits_init() arm64: introduce arch_zone_limits_init() csky: introduce arch_zone_limits_init() hexagon: introduce arch_zone_limits_init() loongarch: introduce arch_zone_limits_init() m68k: introduce arch_zone_limits_init() microblaze: introduce arch_zone_limits_init() mips: introduce arch_zone_limits_init() nios2: introduce arch_zone_limits_init() openrisc: introduce arch_zone_limits_init() parisc: introduce arch_zone_limits_init() powerpc: introduce arch_zone_limits_init() riscv: introduce arch_zone_limits_init() s390: introduce arch_zone_limits_init() sh: introduce arch_zone_limits_init() sparc: introduce arch_zone_limits_init() um: introduce arch_zone_limits_init() x86: introduce arch_zone_limits_init() xtensa: introduce arch_zone_limits_init() arch, mm: consolidate initialization of nodes, zones and memory map arch, mm: consolidate initialization of SPARSE memory model mips: drop paging_init() x86: don't reserve hugetlb memory in setup_arch() mm, arch: consolidate hugetlb CMA reservation mm/hugetlb: drop hugetlb_cma_check() Revert "mm/hugetlb: deal with multiple calls to hugetlb_bootmem_alloc" .../driver-api/cxl/linux/early-boot.rst | 2 +- Documentation/mm/memory-model.rst | 3 -- .../translations/zh_CN/mm/memory-model.rst | 2 - arch/alpha/kernel/setup.c | 1 - arch/alpha/mm/init.c | 16 ++++---- arch/arc/mm/init.c | 37 +++++++++--------- arch/arm/include/asm/pgtable.h | 4 +- arch/arm/mm/init.c | 25 ++---------- arch/arm/mm/mmu.c | 10 +---- arch/arm/mm/nommu.c | 10 +---- arch/arm64/include/asm/hugetlb.h | 2 - arch/arm64/mm/hugetlbpage.c | 10 ++--- arch/arm64/mm/init.c | 39 ++++++++----------- arch/csky/kernel/setup.c | 16 ++++---- arch/hexagon/mm/init.c | 19 +++------ arch/loongarch/include/asm/pgtable.h | 2 - arch/loongarch/kernel/setup.c | 10 ----- arch/loongarch/mm/init.c | 6 +-- arch/m68k/mm/init.c | 8 ++-- arch/m68k/mm/mcfmmu.c | 3 -- arch/m68k/mm/motorola.c | 6 +-- arch/m68k/mm/sun3mmu.c | 9 ----- arch/microblaze/mm/init.c | 22 +++++------ arch/mips/include/asm/pgalloc.h | 2 - arch/mips/include/asm/pgtable.h | 2 +- arch/mips/kernel/setup.c | 15 +------ arch/mips/loongson64/numa.c | 10 ++--- arch/mips/mm/init.c | 8 +--- arch/mips/sgi-ip27/ip27-memory.c | 8 +--- arch/nios2/mm/init.c | 12 +++--- arch/openrisc/mm/init.c | 10 +---- arch/parisc/mm/init.c | 11 +----- arch/powerpc/include/asm/hugetlb.h | 5 --- arch/powerpc/include/asm/setup.h | 4 ++ arch/powerpc/kernel/setup-common.c | 1 - arch/powerpc/mm/hugetlbpage.c | 11 ++---- arch/powerpc/mm/mem.c | 27 +++++-------- arch/powerpc/mm/numa.c | 2 - arch/riscv/mm/hugetlbpage.c | 8 ++++ arch/riscv/mm/init.c | 10 +---- arch/s390/kernel/setup.c | 2 - arch/s390/mm/hugetlbpage.c | 8 ++++ arch/s390/mm/init.c | 13 +++---- arch/sh/mm/init.c | 12 +++--- arch/sparc/mm/init_64.c | 17 +++----- arch/sparc/mm/srmmu.c | 17 ++++---- arch/um/kernel/mem.c | 10 ++--- arch/x86/kernel/setup.c | 5 --- arch/x86/mm/hugetlbpage.c | 8 ++++ arch/x86/mm/init.c | 8 +--- arch/x86/mm/init_32.c | 2 - arch/x86/mm/init_64.c | 4 -- arch/x86/mm/mm_internal.h | 1 - arch/xtensa/mm/init.c | 14 +++---- include/linux/hugetlb.h | 12 ++---- include/linux/mm.h | 5 ++- include/linux/mmzone.h | 2 - init/main.c | 1 + mm/hugetlb.c | 13 ------- mm/hugetlb_cma.c | 33 ++++++++-------- mm/hugetlb_cma.h | 5 --- mm/hugetlb_vmemmap.c | 11 ------ mm/internal.h | 6 +++ mm/mm_init.c | 20 ++++++---- 64 files changed, 223 insertions(+), 414 deletions(-) base-commit: 8f0b4cce4481fb22653697cced8d0d04027cb1e8 -- 2.51.0
null
null
null
[PATCH v3 00/29] arch, mm: consolidate hugetlb early reservation
From: "Mike Rapoport (Microsoft)" <rppt@kernel.org> Move calculations of zone limits to a dedicated arch_zone_limits_init() function. Later MM core will use this function as an architecture specific callback during nodes and zones initialization and thus there won't be a need to call free_area_init() from every architecture. Signed-off-by: Mike Rapoport (Microsoft) <rppt@kernel.org> --- arch/microblaze/mm/init.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/arch/microblaze/mm/init.c b/arch/microblaze/mm/init.c index 31d475cdb1c5..54da60b81094 100644 --- a/arch/microblaze/mm/init.c +++ b/arch/microblaze/mm/init.c @@ -54,6 +54,16 @@ static void __init highmem_init(void) } #endif /* CONFIG_HIGHMEM */ +void __init arch_zone_limits_init(unsigned long *max_zone_pfns) +{ +#ifdef CONFIG_HIGHMEM + max_zone_pfns[ZONE_DMA] = max_low_pfn; + max_zone_pfns[ZONE_HIGHMEM] = max_pfn; +#else + max_zone_pfns[ZONE_DMA] = max_pfn; +#endif +} + /* * paging_init() sets up the page tables - in fact we've already done this. */ @@ -71,13 +81,8 @@ static void __init paging_init(void) #ifdef CONFIG_HIGHMEM highmem_init(); - - zones_size[ZONE_DMA] = max_low_pfn; - zones_size[ZONE_HIGHMEM] = max_pfn; -#else - zones_size[ZONE_DMA] = max_pfn; #endif - + arch_zone_limits_init(zones_size); /* We don't have holes in memory map */ free_area_init(zones_size); } -- 2.51.0
{ "author": "Mike Rapoport <rppt@kernel.org>", "date": "Sun, 11 Jan 2026 10:20:44 +0200", "is_openbsd": false, "thread_id": "b9527ed4-7a5c-42e9-8814-b276b3741f63@suse.cz.mbox.gz" }
lkml_critique
lkml
From: "Mike Rapoport (Microsoft)" <rppt@kernel.org> Hi, Order in which early memory reservation for hugetlb happens depends on architecture, on configuration options and on command line parameters. Some architectures rely on the core MM to call hugetlb_bootmem_alloc() while others call it very early to allow pre-allocation of HVO-style vmemmap. When hugetlb_cma is supported by an architecture it is initialized during setup_arch() and then later hugetlb_init code needs to understand did it happen or not. To make everything consistent and unified, both reservation of hugetlb memory from bootmem and creation of CMA areas for hugetlb must be called from core MM initialization and it would have been a simple change. However, HVO-style pre-initialization ordering requirements slightly complicate things and for HVO pre-init to work sparse and memory map should be initialized after hugetlb reservations. This required pulling out the call to free_area_init() out of setup_arch() path and moving it MM initialization and this is what the first 23 patches do. These changes are deliberately split into per-arch patches that change how the zone limits are calculated for each architecture and the patches 22 and 23 just remove the calls to free_area_init() and sprase_init() from arch/*. Patch 24 is a simple cleanup for MIPS. Patches 25 and 26 actually consolidate hugetlb reservations and patches 27 and 28 perform some aftermath cleanups. I tried to trim the distribution list and although it's still quite long if you feel that someone was wrongly excluded please add them back. The changes also available in git: https://git.kernel.org/pub/scm/linux/kernel/git/rppt/linux.git/log/?h=hugetlb-init/v3 v3 changes: * fix empty_zero_page initialization on arm * fix ZONE_DMA limit calculation on powerpc * add Acks v2: https://lore.kernel.org/all/20260102070005.65328-1-rppt@kernel.org * move the hugetlb and memory map initializaion to mm_core_init_early() * add Acks v1: https://lore.kernel.org/all/20251228124001.3624742-1-rppt@kernel.org Klara Modin (1): arm: make initialization of zero page independent of the memory map Mike Rapoport (Microsoft) (28): alpha: introduce arch_zone_limits_init() arc: introduce arch_zone_limits_init() arm: introduce arch_zone_limits_init() arm64: introduce arch_zone_limits_init() csky: introduce arch_zone_limits_init() hexagon: introduce arch_zone_limits_init() loongarch: introduce arch_zone_limits_init() m68k: introduce arch_zone_limits_init() microblaze: introduce arch_zone_limits_init() mips: introduce arch_zone_limits_init() nios2: introduce arch_zone_limits_init() openrisc: introduce arch_zone_limits_init() parisc: introduce arch_zone_limits_init() powerpc: introduce arch_zone_limits_init() riscv: introduce arch_zone_limits_init() s390: introduce arch_zone_limits_init() sh: introduce arch_zone_limits_init() sparc: introduce arch_zone_limits_init() um: introduce arch_zone_limits_init() x86: introduce arch_zone_limits_init() xtensa: introduce arch_zone_limits_init() arch, mm: consolidate initialization of nodes, zones and memory map arch, mm: consolidate initialization of SPARSE memory model mips: drop paging_init() x86: don't reserve hugetlb memory in setup_arch() mm, arch: consolidate hugetlb CMA reservation mm/hugetlb: drop hugetlb_cma_check() Revert "mm/hugetlb: deal with multiple calls to hugetlb_bootmem_alloc" .../driver-api/cxl/linux/early-boot.rst | 2 +- Documentation/mm/memory-model.rst | 3 -- .../translations/zh_CN/mm/memory-model.rst | 2 - arch/alpha/kernel/setup.c | 1 - arch/alpha/mm/init.c | 16 ++++---- arch/arc/mm/init.c | 37 +++++++++--------- arch/arm/include/asm/pgtable.h | 4 +- arch/arm/mm/init.c | 25 ++---------- arch/arm/mm/mmu.c | 10 +---- arch/arm/mm/nommu.c | 10 +---- arch/arm64/include/asm/hugetlb.h | 2 - arch/arm64/mm/hugetlbpage.c | 10 ++--- arch/arm64/mm/init.c | 39 ++++++++----------- arch/csky/kernel/setup.c | 16 ++++---- arch/hexagon/mm/init.c | 19 +++------ arch/loongarch/include/asm/pgtable.h | 2 - arch/loongarch/kernel/setup.c | 10 ----- arch/loongarch/mm/init.c | 6 +-- arch/m68k/mm/init.c | 8 ++-- arch/m68k/mm/mcfmmu.c | 3 -- arch/m68k/mm/motorola.c | 6 +-- arch/m68k/mm/sun3mmu.c | 9 ----- arch/microblaze/mm/init.c | 22 +++++------ arch/mips/include/asm/pgalloc.h | 2 - arch/mips/include/asm/pgtable.h | 2 +- arch/mips/kernel/setup.c | 15 +------ arch/mips/loongson64/numa.c | 10 ++--- arch/mips/mm/init.c | 8 +--- arch/mips/sgi-ip27/ip27-memory.c | 8 +--- arch/nios2/mm/init.c | 12 +++--- arch/openrisc/mm/init.c | 10 +---- arch/parisc/mm/init.c | 11 +----- arch/powerpc/include/asm/hugetlb.h | 5 --- arch/powerpc/include/asm/setup.h | 4 ++ arch/powerpc/kernel/setup-common.c | 1 - arch/powerpc/mm/hugetlbpage.c | 11 ++---- arch/powerpc/mm/mem.c | 27 +++++-------- arch/powerpc/mm/numa.c | 2 - arch/riscv/mm/hugetlbpage.c | 8 ++++ arch/riscv/mm/init.c | 10 +---- arch/s390/kernel/setup.c | 2 - arch/s390/mm/hugetlbpage.c | 8 ++++ arch/s390/mm/init.c | 13 +++---- arch/sh/mm/init.c | 12 +++--- arch/sparc/mm/init_64.c | 17 +++----- arch/sparc/mm/srmmu.c | 17 ++++---- arch/um/kernel/mem.c | 10 ++--- arch/x86/kernel/setup.c | 5 --- arch/x86/mm/hugetlbpage.c | 8 ++++ arch/x86/mm/init.c | 8 +--- arch/x86/mm/init_32.c | 2 - arch/x86/mm/init_64.c | 4 -- arch/x86/mm/mm_internal.h | 1 - arch/xtensa/mm/init.c | 14 +++---- include/linux/hugetlb.h | 12 ++---- include/linux/mm.h | 5 ++- include/linux/mmzone.h | 2 - init/main.c | 1 + mm/hugetlb.c | 13 ------- mm/hugetlb_cma.c | 33 ++++++++-------- mm/hugetlb_cma.h | 5 --- mm/hugetlb_vmemmap.c | 11 ------ mm/internal.h | 6 +++ mm/mm_init.c | 20 ++++++---- 64 files changed, 223 insertions(+), 414 deletions(-) base-commit: 8f0b4cce4481fb22653697cced8d0d04027cb1e8 -- 2.51.0
null
null
null
[PATCH v3 00/29] arch, mm: consolidate hugetlb early reservation
From: "Mike Rapoport (Microsoft)" <rppt@kernel.org> Move calculations of zone limits to a dedicated arch_zone_limits_init() function. Later MM core will use this function as an architecture specific callback during nodes and zones initialization and thus there won't be a need to call free_area_init() from every architecture. Signed-off-by: Mike Rapoport (Microsoft) <rppt@kernel.org> --- arch/mips/loongson64/numa.c | 9 +++++++-- arch/mips/mm/init.c | 14 +++++++++----- arch/mips/sgi-ip27/ip27-memory.c | 7 ++++++- 3 files changed, 22 insertions(+), 8 deletions(-) diff --git a/arch/mips/loongson64/numa.c b/arch/mips/loongson64/numa.c index 95d5f553ce19..f72a58f87878 100644 --- a/arch/mips/loongson64/numa.c +++ b/arch/mips/loongson64/numa.c @@ -154,13 +154,18 @@ static __init void prom_meminit(void) } } +void __init arch_zone_limits_init(unsigned long *max_zone_pfns) +{ + max_zone_pfns[ZONE_DMA32] = MAX_DMA32_PFN; + max_zone_pfns[ZONE_NORMAL] = max_low_pfn; +} + void __init paging_init(void) { unsigned long zones_size[MAX_NR_ZONES] = {0, }; pagetable_init(); - zones_size[ZONE_DMA32] = MAX_DMA32_PFN; - zones_size[ZONE_NORMAL] = max_low_pfn; + arch_zone_limits_init(zones_size); free_area_init(zones_size); } diff --git a/arch/mips/mm/init.c b/arch/mips/mm/init.c index a673d3d68254..ab08249cfede 100644 --- a/arch/mips/mm/init.c +++ b/arch/mips/mm/init.c @@ -394,12 +394,8 @@ void maar_init(void) } #ifndef CONFIG_NUMA -void __init paging_init(void) +void __init arch_zone_limits_init(unsigned long *max_zone_pfns) { - unsigned long max_zone_pfns[MAX_NR_ZONES]; - - pagetable_init(); - #ifdef CONFIG_ZONE_DMA max_zone_pfns[ZONE_DMA] = MAX_DMA_PFN; #endif @@ -417,7 +413,15 @@ void __init paging_init(void) max_zone_pfns[ZONE_HIGHMEM] = max_low_pfn; } #endif +} + +void __init paging_init(void) +{ + unsigned long max_zone_pfns[MAX_NR_ZONES]; + + pagetable_init(); + arch_zone_limits_init(max_zone_pfns); free_area_init(max_zone_pfns); } diff --git a/arch/mips/sgi-ip27/ip27-memory.c b/arch/mips/sgi-ip27/ip27-memory.c index 2b3e46e2e607..babeb0e07687 100644 --- a/arch/mips/sgi-ip27/ip27-memory.c +++ b/arch/mips/sgi-ip27/ip27-memory.c @@ -406,11 +406,16 @@ void __init prom_meminit(void) } } +void __init arch_zone_limits_init(unsigned long *max_zone_pfns) +{ + max_zone_pfns[ZONE_NORMAL] = max_low_pfn; +} + void __init paging_init(void) { unsigned long zones_size[MAX_NR_ZONES] = {0, }; pagetable_init(); - zones_size[ZONE_NORMAL] = max_low_pfn; + arch_zone_limits_init(zones_size); free_area_init(zones_size); } -- 2.51.0
{ "author": "Mike Rapoport <rppt@kernel.org>", "date": "Sun, 11 Jan 2026 10:20:45 +0200", "is_openbsd": false, "thread_id": "b9527ed4-7a5c-42e9-8814-b276b3741f63@suse.cz.mbox.gz" }
lkml_critique
lkml
From: "Mike Rapoport (Microsoft)" <rppt@kernel.org> Hi, Order in which early memory reservation for hugetlb happens depends on architecture, on configuration options and on command line parameters. Some architectures rely on the core MM to call hugetlb_bootmem_alloc() while others call it very early to allow pre-allocation of HVO-style vmemmap. When hugetlb_cma is supported by an architecture it is initialized during setup_arch() and then later hugetlb_init code needs to understand did it happen or not. To make everything consistent and unified, both reservation of hugetlb memory from bootmem and creation of CMA areas for hugetlb must be called from core MM initialization and it would have been a simple change. However, HVO-style pre-initialization ordering requirements slightly complicate things and for HVO pre-init to work sparse and memory map should be initialized after hugetlb reservations. This required pulling out the call to free_area_init() out of setup_arch() path and moving it MM initialization and this is what the first 23 patches do. These changes are deliberately split into per-arch patches that change how the zone limits are calculated for each architecture and the patches 22 and 23 just remove the calls to free_area_init() and sprase_init() from arch/*. Patch 24 is a simple cleanup for MIPS. Patches 25 and 26 actually consolidate hugetlb reservations and patches 27 and 28 perform some aftermath cleanups. I tried to trim the distribution list and although it's still quite long if you feel that someone was wrongly excluded please add them back. The changes also available in git: https://git.kernel.org/pub/scm/linux/kernel/git/rppt/linux.git/log/?h=hugetlb-init/v3 v3 changes: * fix empty_zero_page initialization on arm * fix ZONE_DMA limit calculation on powerpc * add Acks v2: https://lore.kernel.org/all/20260102070005.65328-1-rppt@kernel.org * move the hugetlb and memory map initializaion to mm_core_init_early() * add Acks v1: https://lore.kernel.org/all/20251228124001.3624742-1-rppt@kernel.org Klara Modin (1): arm: make initialization of zero page independent of the memory map Mike Rapoport (Microsoft) (28): alpha: introduce arch_zone_limits_init() arc: introduce arch_zone_limits_init() arm: introduce arch_zone_limits_init() arm64: introduce arch_zone_limits_init() csky: introduce arch_zone_limits_init() hexagon: introduce arch_zone_limits_init() loongarch: introduce arch_zone_limits_init() m68k: introduce arch_zone_limits_init() microblaze: introduce arch_zone_limits_init() mips: introduce arch_zone_limits_init() nios2: introduce arch_zone_limits_init() openrisc: introduce arch_zone_limits_init() parisc: introduce arch_zone_limits_init() powerpc: introduce arch_zone_limits_init() riscv: introduce arch_zone_limits_init() s390: introduce arch_zone_limits_init() sh: introduce arch_zone_limits_init() sparc: introduce arch_zone_limits_init() um: introduce arch_zone_limits_init() x86: introduce arch_zone_limits_init() xtensa: introduce arch_zone_limits_init() arch, mm: consolidate initialization of nodes, zones and memory map arch, mm: consolidate initialization of SPARSE memory model mips: drop paging_init() x86: don't reserve hugetlb memory in setup_arch() mm, arch: consolidate hugetlb CMA reservation mm/hugetlb: drop hugetlb_cma_check() Revert "mm/hugetlb: deal with multiple calls to hugetlb_bootmem_alloc" .../driver-api/cxl/linux/early-boot.rst | 2 +- Documentation/mm/memory-model.rst | 3 -- .../translations/zh_CN/mm/memory-model.rst | 2 - arch/alpha/kernel/setup.c | 1 - arch/alpha/mm/init.c | 16 ++++---- arch/arc/mm/init.c | 37 +++++++++--------- arch/arm/include/asm/pgtable.h | 4 +- arch/arm/mm/init.c | 25 ++---------- arch/arm/mm/mmu.c | 10 +---- arch/arm/mm/nommu.c | 10 +---- arch/arm64/include/asm/hugetlb.h | 2 - arch/arm64/mm/hugetlbpage.c | 10 ++--- arch/arm64/mm/init.c | 39 ++++++++----------- arch/csky/kernel/setup.c | 16 ++++---- arch/hexagon/mm/init.c | 19 +++------ arch/loongarch/include/asm/pgtable.h | 2 - arch/loongarch/kernel/setup.c | 10 ----- arch/loongarch/mm/init.c | 6 +-- arch/m68k/mm/init.c | 8 ++-- arch/m68k/mm/mcfmmu.c | 3 -- arch/m68k/mm/motorola.c | 6 +-- arch/m68k/mm/sun3mmu.c | 9 ----- arch/microblaze/mm/init.c | 22 +++++------ arch/mips/include/asm/pgalloc.h | 2 - arch/mips/include/asm/pgtable.h | 2 +- arch/mips/kernel/setup.c | 15 +------ arch/mips/loongson64/numa.c | 10 ++--- arch/mips/mm/init.c | 8 +--- arch/mips/sgi-ip27/ip27-memory.c | 8 +--- arch/nios2/mm/init.c | 12 +++--- arch/openrisc/mm/init.c | 10 +---- arch/parisc/mm/init.c | 11 +----- arch/powerpc/include/asm/hugetlb.h | 5 --- arch/powerpc/include/asm/setup.h | 4 ++ arch/powerpc/kernel/setup-common.c | 1 - arch/powerpc/mm/hugetlbpage.c | 11 ++---- arch/powerpc/mm/mem.c | 27 +++++-------- arch/powerpc/mm/numa.c | 2 - arch/riscv/mm/hugetlbpage.c | 8 ++++ arch/riscv/mm/init.c | 10 +---- arch/s390/kernel/setup.c | 2 - arch/s390/mm/hugetlbpage.c | 8 ++++ arch/s390/mm/init.c | 13 +++---- arch/sh/mm/init.c | 12 +++--- arch/sparc/mm/init_64.c | 17 +++----- arch/sparc/mm/srmmu.c | 17 ++++---- arch/um/kernel/mem.c | 10 ++--- arch/x86/kernel/setup.c | 5 --- arch/x86/mm/hugetlbpage.c | 8 ++++ arch/x86/mm/init.c | 8 +--- arch/x86/mm/init_32.c | 2 - arch/x86/mm/init_64.c | 4 -- arch/x86/mm/mm_internal.h | 1 - arch/xtensa/mm/init.c | 14 +++---- include/linux/hugetlb.h | 12 ++---- include/linux/mm.h | 5 ++- include/linux/mmzone.h | 2 - init/main.c | 1 + mm/hugetlb.c | 13 ------- mm/hugetlb_cma.c | 33 ++++++++-------- mm/hugetlb_cma.h | 5 --- mm/hugetlb_vmemmap.c | 11 ------ mm/internal.h | 6 +++ mm/mm_init.c | 20 ++++++---- 64 files changed, 223 insertions(+), 414 deletions(-) base-commit: 8f0b4cce4481fb22653697cced8d0d04027cb1e8 -- 2.51.0
null
null
null
[PATCH v3 00/29] arch, mm: consolidate hugetlb early reservation
From: "Mike Rapoport (Microsoft)" <rppt@kernel.org> Move calculations of zone limits to a dedicated arch_zone_limits_init() function. Later MM core will use this function as an architecture specific callback during nodes and zones initialization and thus there won't be a need to call free_area_init() from every architecture. Signed-off-by: Mike Rapoport (Microsoft) <rppt@kernel.org> Acked-by: Dinh Nguyen <dinguyen@kernel.org> --- arch/nios2/mm/init.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/arch/nios2/mm/init.c b/arch/nios2/mm/init.c index 94efa3de3933..2cb666a65d9e 100644 --- a/arch/nios2/mm/init.c +++ b/arch/nios2/mm/init.c @@ -38,6 +38,11 @@ pgd_t *pgd_current; +void __init arch_zone_limits_init(unsigned long *max_zone_pfns) +{ + max_zone_pfns[ZONE_NORMAL] = max_low_pfn; +} + /* * paging_init() continues the virtual memory environment setup which * was begun by the code in arch/head.S. @@ -51,8 +56,7 @@ void __init paging_init(void) pagetable_init(); pgd_current = swapper_pg_dir; - max_zone_pfn[ZONE_NORMAL] = max_low_pfn; - + arch_zone_limits_init(max_zone_pfn); /* pass the memory from the bootmem allocator to the main allocator */ free_area_init(max_zone_pfn); -- 2.51.0
{ "author": "Mike Rapoport <rppt@kernel.org>", "date": "Sun, 11 Jan 2026 10:20:46 +0200", "is_openbsd": false, "thread_id": "b9527ed4-7a5c-42e9-8814-b276b3741f63@suse.cz.mbox.gz" }
lkml_critique
lkml
From: "Mike Rapoport (Microsoft)" <rppt@kernel.org> Hi, Order in which early memory reservation for hugetlb happens depends on architecture, on configuration options and on command line parameters. Some architectures rely on the core MM to call hugetlb_bootmem_alloc() while others call it very early to allow pre-allocation of HVO-style vmemmap. When hugetlb_cma is supported by an architecture it is initialized during setup_arch() and then later hugetlb_init code needs to understand did it happen or not. To make everything consistent and unified, both reservation of hugetlb memory from bootmem and creation of CMA areas for hugetlb must be called from core MM initialization and it would have been a simple change. However, HVO-style pre-initialization ordering requirements slightly complicate things and for HVO pre-init to work sparse and memory map should be initialized after hugetlb reservations. This required pulling out the call to free_area_init() out of setup_arch() path and moving it MM initialization and this is what the first 23 patches do. These changes are deliberately split into per-arch patches that change how the zone limits are calculated for each architecture and the patches 22 and 23 just remove the calls to free_area_init() and sprase_init() from arch/*. Patch 24 is a simple cleanup for MIPS. Patches 25 and 26 actually consolidate hugetlb reservations and patches 27 and 28 perform some aftermath cleanups. I tried to trim the distribution list and although it's still quite long if you feel that someone was wrongly excluded please add them back. The changes also available in git: https://git.kernel.org/pub/scm/linux/kernel/git/rppt/linux.git/log/?h=hugetlb-init/v3 v3 changes: * fix empty_zero_page initialization on arm * fix ZONE_DMA limit calculation on powerpc * add Acks v2: https://lore.kernel.org/all/20260102070005.65328-1-rppt@kernel.org * move the hugetlb and memory map initializaion to mm_core_init_early() * add Acks v1: https://lore.kernel.org/all/20251228124001.3624742-1-rppt@kernel.org Klara Modin (1): arm: make initialization of zero page independent of the memory map Mike Rapoport (Microsoft) (28): alpha: introduce arch_zone_limits_init() arc: introduce arch_zone_limits_init() arm: introduce arch_zone_limits_init() arm64: introduce arch_zone_limits_init() csky: introduce arch_zone_limits_init() hexagon: introduce arch_zone_limits_init() loongarch: introduce arch_zone_limits_init() m68k: introduce arch_zone_limits_init() microblaze: introduce arch_zone_limits_init() mips: introduce arch_zone_limits_init() nios2: introduce arch_zone_limits_init() openrisc: introduce arch_zone_limits_init() parisc: introduce arch_zone_limits_init() powerpc: introduce arch_zone_limits_init() riscv: introduce arch_zone_limits_init() s390: introduce arch_zone_limits_init() sh: introduce arch_zone_limits_init() sparc: introduce arch_zone_limits_init() um: introduce arch_zone_limits_init() x86: introduce arch_zone_limits_init() xtensa: introduce arch_zone_limits_init() arch, mm: consolidate initialization of nodes, zones and memory map arch, mm: consolidate initialization of SPARSE memory model mips: drop paging_init() x86: don't reserve hugetlb memory in setup_arch() mm, arch: consolidate hugetlb CMA reservation mm/hugetlb: drop hugetlb_cma_check() Revert "mm/hugetlb: deal with multiple calls to hugetlb_bootmem_alloc" .../driver-api/cxl/linux/early-boot.rst | 2 +- Documentation/mm/memory-model.rst | 3 -- .../translations/zh_CN/mm/memory-model.rst | 2 - arch/alpha/kernel/setup.c | 1 - arch/alpha/mm/init.c | 16 ++++---- arch/arc/mm/init.c | 37 +++++++++--------- arch/arm/include/asm/pgtable.h | 4 +- arch/arm/mm/init.c | 25 ++---------- arch/arm/mm/mmu.c | 10 +---- arch/arm/mm/nommu.c | 10 +---- arch/arm64/include/asm/hugetlb.h | 2 - arch/arm64/mm/hugetlbpage.c | 10 ++--- arch/arm64/mm/init.c | 39 ++++++++----------- arch/csky/kernel/setup.c | 16 ++++---- arch/hexagon/mm/init.c | 19 +++------ arch/loongarch/include/asm/pgtable.h | 2 - arch/loongarch/kernel/setup.c | 10 ----- arch/loongarch/mm/init.c | 6 +-- arch/m68k/mm/init.c | 8 ++-- arch/m68k/mm/mcfmmu.c | 3 -- arch/m68k/mm/motorola.c | 6 +-- arch/m68k/mm/sun3mmu.c | 9 ----- arch/microblaze/mm/init.c | 22 +++++------ arch/mips/include/asm/pgalloc.h | 2 - arch/mips/include/asm/pgtable.h | 2 +- arch/mips/kernel/setup.c | 15 +------ arch/mips/loongson64/numa.c | 10 ++--- arch/mips/mm/init.c | 8 +--- arch/mips/sgi-ip27/ip27-memory.c | 8 +--- arch/nios2/mm/init.c | 12 +++--- arch/openrisc/mm/init.c | 10 +---- arch/parisc/mm/init.c | 11 +----- arch/powerpc/include/asm/hugetlb.h | 5 --- arch/powerpc/include/asm/setup.h | 4 ++ arch/powerpc/kernel/setup-common.c | 1 - arch/powerpc/mm/hugetlbpage.c | 11 ++---- arch/powerpc/mm/mem.c | 27 +++++-------- arch/powerpc/mm/numa.c | 2 - arch/riscv/mm/hugetlbpage.c | 8 ++++ arch/riscv/mm/init.c | 10 +---- arch/s390/kernel/setup.c | 2 - arch/s390/mm/hugetlbpage.c | 8 ++++ arch/s390/mm/init.c | 13 +++---- arch/sh/mm/init.c | 12 +++--- arch/sparc/mm/init_64.c | 17 +++----- arch/sparc/mm/srmmu.c | 17 ++++---- arch/um/kernel/mem.c | 10 ++--- arch/x86/kernel/setup.c | 5 --- arch/x86/mm/hugetlbpage.c | 8 ++++ arch/x86/mm/init.c | 8 +--- arch/x86/mm/init_32.c | 2 - arch/x86/mm/init_64.c | 4 -- arch/x86/mm/mm_internal.h | 1 - arch/xtensa/mm/init.c | 14 +++---- include/linux/hugetlb.h | 12 ++---- include/linux/mm.h | 5 ++- include/linux/mmzone.h | 2 - init/main.c | 1 + mm/hugetlb.c | 13 ------- mm/hugetlb_cma.c | 33 ++++++++-------- mm/hugetlb_cma.h | 5 --- mm/hugetlb_vmemmap.c | 11 ------ mm/internal.h | 6 +++ mm/mm_init.c | 20 ++++++---- 64 files changed, 223 insertions(+), 414 deletions(-) base-commit: 8f0b4cce4481fb22653697cced8d0d04027cb1e8 -- 2.51.0
null
null
null
[PATCH v3 00/29] arch, mm: consolidate hugetlb early reservation
From: "Mike Rapoport (Microsoft)" <rppt@kernel.org> Move calculations of zone limits to a dedicated arch_zone_limits_init() function. Later MM core will use this function as an architecture specific callback during nodes and zones initialization and thus there won't be a need to call free_area_init() from every architecture. Signed-off-by: Mike Rapoport (Microsoft) <rppt@kernel.org> Acked-by: Stafford Horne <shorne@gmail.com> --- arch/openrisc/mm/init.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/arch/openrisc/mm/init.c b/arch/openrisc/mm/init.c index 9382d9a0ec78..67de93e7a685 100644 --- a/arch/openrisc/mm/init.c +++ b/arch/openrisc/mm/init.c @@ -39,15 +39,19 @@ int mem_init_done; -static void __init zone_sizes_init(void) +void __init arch_zone_limits_init(unsigned long *max_zone_pfns) { - unsigned long max_zone_pfn[MAX_NR_ZONES] = { 0 }; - /* * We use only ZONE_NORMAL */ - max_zone_pfn[ZONE_NORMAL] = max_low_pfn; + max_zone_pfns[ZONE_NORMAL] = max_low_pfn; +} + +static void __init zone_sizes_init(void) +{ + unsigned long max_zone_pfn[MAX_NR_ZONES] = { 0 }; + arch_zone_limits_init(max_zone_pfn); free_area_init(max_zone_pfn); } -- 2.51.0
{ "author": "Mike Rapoport <rppt@kernel.org>", "date": "Sun, 11 Jan 2026 10:20:47 +0200", "is_openbsd": false, "thread_id": "b9527ed4-7a5c-42e9-8814-b276b3741f63@suse.cz.mbox.gz" }
lkml_critique
lkml
From: "Mike Rapoport (Microsoft)" <rppt@kernel.org> Hi, Order in which early memory reservation for hugetlb happens depends on architecture, on configuration options and on command line parameters. Some architectures rely on the core MM to call hugetlb_bootmem_alloc() while others call it very early to allow pre-allocation of HVO-style vmemmap. When hugetlb_cma is supported by an architecture it is initialized during setup_arch() and then later hugetlb_init code needs to understand did it happen or not. To make everything consistent and unified, both reservation of hugetlb memory from bootmem and creation of CMA areas for hugetlb must be called from core MM initialization and it would have been a simple change. However, HVO-style pre-initialization ordering requirements slightly complicate things and for HVO pre-init to work sparse and memory map should be initialized after hugetlb reservations. This required pulling out the call to free_area_init() out of setup_arch() path and moving it MM initialization and this is what the first 23 patches do. These changes are deliberately split into per-arch patches that change how the zone limits are calculated for each architecture and the patches 22 and 23 just remove the calls to free_area_init() and sprase_init() from arch/*. Patch 24 is a simple cleanup for MIPS. Patches 25 and 26 actually consolidate hugetlb reservations and patches 27 and 28 perform some aftermath cleanups. I tried to trim the distribution list and although it's still quite long if you feel that someone was wrongly excluded please add them back. The changes also available in git: https://git.kernel.org/pub/scm/linux/kernel/git/rppt/linux.git/log/?h=hugetlb-init/v3 v3 changes: * fix empty_zero_page initialization on arm * fix ZONE_DMA limit calculation on powerpc * add Acks v2: https://lore.kernel.org/all/20260102070005.65328-1-rppt@kernel.org * move the hugetlb and memory map initializaion to mm_core_init_early() * add Acks v1: https://lore.kernel.org/all/20251228124001.3624742-1-rppt@kernel.org Klara Modin (1): arm: make initialization of zero page independent of the memory map Mike Rapoport (Microsoft) (28): alpha: introduce arch_zone_limits_init() arc: introduce arch_zone_limits_init() arm: introduce arch_zone_limits_init() arm64: introduce arch_zone_limits_init() csky: introduce arch_zone_limits_init() hexagon: introduce arch_zone_limits_init() loongarch: introduce arch_zone_limits_init() m68k: introduce arch_zone_limits_init() microblaze: introduce arch_zone_limits_init() mips: introduce arch_zone_limits_init() nios2: introduce arch_zone_limits_init() openrisc: introduce arch_zone_limits_init() parisc: introduce arch_zone_limits_init() powerpc: introduce arch_zone_limits_init() riscv: introduce arch_zone_limits_init() s390: introduce arch_zone_limits_init() sh: introduce arch_zone_limits_init() sparc: introduce arch_zone_limits_init() um: introduce arch_zone_limits_init() x86: introduce arch_zone_limits_init() xtensa: introduce arch_zone_limits_init() arch, mm: consolidate initialization of nodes, zones and memory map arch, mm: consolidate initialization of SPARSE memory model mips: drop paging_init() x86: don't reserve hugetlb memory in setup_arch() mm, arch: consolidate hugetlb CMA reservation mm/hugetlb: drop hugetlb_cma_check() Revert "mm/hugetlb: deal with multiple calls to hugetlb_bootmem_alloc" .../driver-api/cxl/linux/early-boot.rst | 2 +- Documentation/mm/memory-model.rst | 3 -- .../translations/zh_CN/mm/memory-model.rst | 2 - arch/alpha/kernel/setup.c | 1 - arch/alpha/mm/init.c | 16 ++++---- arch/arc/mm/init.c | 37 +++++++++--------- arch/arm/include/asm/pgtable.h | 4 +- arch/arm/mm/init.c | 25 ++---------- arch/arm/mm/mmu.c | 10 +---- arch/arm/mm/nommu.c | 10 +---- arch/arm64/include/asm/hugetlb.h | 2 - arch/arm64/mm/hugetlbpage.c | 10 ++--- arch/arm64/mm/init.c | 39 ++++++++----------- arch/csky/kernel/setup.c | 16 ++++---- arch/hexagon/mm/init.c | 19 +++------ arch/loongarch/include/asm/pgtable.h | 2 - arch/loongarch/kernel/setup.c | 10 ----- arch/loongarch/mm/init.c | 6 +-- arch/m68k/mm/init.c | 8 ++-- arch/m68k/mm/mcfmmu.c | 3 -- arch/m68k/mm/motorola.c | 6 +-- arch/m68k/mm/sun3mmu.c | 9 ----- arch/microblaze/mm/init.c | 22 +++++------ arch/mips/include/asm/pgalloc.h | 2 - arch/mips/include/asm/pgtable.h | 2 +- arch/mips/kernel/setup.c | 15 +------ arch/mips/loongson64/numa.c | 10 ++--- arch/mips/mm/init.c | 8 +--- arch/mips/sgi-ip27/ip27-memory.c | 8 +--- arch/nios2/mm/init.c | 12 +++--- arch/openrisc/mm/init.c | 10 +---- arch/parisc/mm/init.c | 11 +----- arch/powerpc/include/asm/hugetlb.h | 5 --- arch/powerpc/include/asm/setup.h | 4 ++ arch/powerpc/kernel/setup-common.c | 1 - arch/powerpc/mm/hugetlbpage.c | 11 ++---- arch/powerpc/mm/mem.c | 27 +++++-------- arch/powerpc/mm/numa.c | 2 - arch/riscv/mm/hugetlbpage.c | 8 ++++ arch/riscv/mm/init.c | 10 +---- arch/s390/kernel/setup.c | 2 - arch/s390/mm/hugetlbpage.c | 8 ++++ arch/s390/mm/init.c | 13 +++---- arch/sh/mm/init.c | 12 +++--- arch/sparc/mm/init_64.c | 17 +++----- arch/sparc/mm/srmmu.c | 17 ++++---- arch/um/kernel/mem.c | 10 ++--- arch/x86/kernel/setup.c | 5 --- arch/x86/mm/hugetlbpage.c | 8 ++++ arch/x86/mm/init.c | 8 +--- arch/x86/mm/init_32.c | 2 - arch/x86/mm/init_64.c | 4 -- arch/x86/mm/mm_internal.h | 1 - arch/xtensa/mm/init.c | 14 +++---- include/linux/hugetlb.h | 12 ++---- include/linux/mm.h | 5 ++- include/linux/mmzone.h | 2 - init/main.c | 1 + mm/hugetlb.c | 13 ------- mm/hugetlb_cma.c | 33 ++++++++-------- mm/hugetlb_cma.h | 5 --- mm/hugetlb_vmemmap.c | 11 ------ mm/internal.h | 6 +++ mm/mm_init.c | 20 ++++++---- 64 files changed, 223 insertions(+), 414 deletions(-) base-commit: 8f0b4cce4481fb22653697cced8d0d04027cb1e8 -- 2.51.0
null
null
null
[PATCH v3 00/29] arch, mm: consolidate hugetlb early reservation
From: "Mike Rapoport (Microsoft)" <rppt@kernel.org> Move calculations of zone limits to a dedicated arch_zone_limits_init() function. Later MM core will use this function as an architecture specific callback during nodes and zones initialization and thus there won't be a need to call free_area_init() from every architecture. Signed-off-by: Mike Rapoport (Microsoft) <rppt@kernel.org> Acked-by: Helge Deller <deller@gmx.de> --- arch/parisc/mm/init.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/arch/parisc/mm/init.c b/arch/parisc/mm/init.c index 14270715d754..dc5bd3efe738 100644 --- a/arch/parisc/mm/init.c +++ b/arch/parisc/mm/init.c @@ -693,12 +693,16 @@ static void __init fixmap_init(void) } while (addr < end); } +void __init arch_zone_limits_init(unsigned long *max_zone_pfns) +{ + max_zone_pfns[ZONE_NORMAL] = PFN_DOWN(memblock_end_of_DRAM()); +} + static void __init parisc_bootmem_free(void) { unsigned long max_zone_pfn[MAX_NR_ZONES] = { 0, }; - max_zone_pfn[0] = memblock_end_of_DRAM(); - + arch_zone_limits_init(max_zone_pfn); free_area_init(max_zone_pfn); } -- 2.51.0
{ "author": "Mike Rapoport <rppt@kernel.org>", "date": "Sun, 11 Jan 2026 10:20:48 +0200", "is_openbsd": false, "thread_id": "b9527ed4-7a5c-42e9-8814-b276b3741f63@suse.cz.mbox.gz" }
lkml_critique
lkml
From: "Mike Rapoport (Microsoft)" <rppt@kernel.org> Hi, Order in which early memory reservation for hugetlb happens depends on architecture, on configuration options and on command line parameters. Some architectures rely on the core MM to call hugetlb_bootmem_alloc() while others call it very early to allow pre-allocation of HVO-style vmemmap. When hugetlb_cma is supported by an architecture it is initialized during setup_arch() and then later hugetlb_init code needs to understand did it happen or not. To make everything consistent and unified, both reservation of hugetlb memory from bootmem and creation of CMA areas for hugetlb must be called from core MM initialization and it would have been a simple change. However, HVO-style pre-initialization ordering requirements slightly complicate things and for HVO pre-init to work sparse and memory map should be initialized after hugetlb reservations. This required pulling out the call to free_area_init() out of setup_arch() path and moving it MM initialization and this is what the first 23 patches do. These changes are deliberately split into per-arch patches that change how the zone limits are calculated for each architecture and the patches 22 and 23 just remove the calls to free_area_init() and sprase_init() from arch/*. Patch 24 is a simple cleanup for MIPS. Patches 25 and 26 actually consolidate hugetlb reservations and patches 27 and 28 perform some aftermath cleanups. I tried to trim the distribution list and although it's still quite long if you feel that someone was wrongly excluded please add them back. The changes also available in git: https://git.kernel.org/pub/scm/linux/kernel/git/rppt/linux.git/log/?h=hugetlb-init/v3 v3 changes: * fix empty_zero_page initialization on arm * fix ZONE_DMA limit calculation on powerpc * add Acks v2: https://lore.kernel.org/all/20260102070005.65328-1-rppt@kernel.org * move the hugetlb and memory map initializaion to mm_core_init_early() * add Acks v1: https://lore.kernel.org/all/20251228124001.3624742-1-rppt@kernel.org Klara Modin (1): arm: make initialization of zero page independent of the memory map Mike Rapoport (Microsoft) (28): alpha: introduce arch_zone_limits_init() arc: introduce arch_zone_limits_init() arm: introduce arch_zone_limits_init() arm64: introduce arch_zone_limits_init() csky: introduce arch_zone_limits_init() hexagon: introduce arch_zone_limits_init() loongarch: introduce arch_zone_limits_init() m68k: introduce arch_zone_limits_init() microblaze: introduce arch_zone_limits_init() mips: introduce arch_zone_limits_init() nios2: introduce arch_zone_limits_init() openrisc: introduce arch_zone_limits_init() parisc: introduce arch_zone_limits_init() powerpc: introduce arch_zone_limits_init() riscv: introduce arch_zone_limits_init() s390: introduce arch_zone_limits_init() sh: introduce arch_zone_limits_init() sparc: introduce arch_zone_limits_init() um: introduce arch_zone_limits_init() x86: introduce arch_zone_limits_init() xtensa: introduce arch_zone_limits_init() arch, mm: consolidate initialization of nodes, zones and memory map arch, mm: consolidate initialization of SPARSE memory model mips: drop paging_init() x86: don't reserve hugetlb memory in setup_arch() mm, arch: consolidate hugetlb CMA reservation mm/hugetlb: drop hugetlb_cma_check() Revert "mm/hugetlb: deal with multiple calls to hugetlb_bootmem_alloc" .../driver-api/cxl/linux/early-boot.rst | 2 +- Documentation/mm/memory-model.rst | 3 -- .../translations/zh_CN/mm/memory-model.rst | 2 - arch/alpha/kernel/setup.c | 1 - arch/alpha/mm/init.c | 16 ++++---- arch/arc/mm/init.c | 37 +++++++++--------- arch/arm/include/asm/pgtable.h | 4 +- arch/arm/mm/init.c | 25 ++---------- arch/arm/mm/mmu.c | 10 +---- arch/arm/mm/nommu.c | 10 +---- arch/arm64/include/asm/hugetlb.h | 2 - arch/arm64/mm/hugetlbpage.c | 10 ++--- arch/arm64/mm/init.c | 39 ++++++++----------- arch/csky/kernel/setup.c | 16 ++++---- arch/hexagon/mm/init.c | 19 +++------ arch/loongarch/include/asm/pgtable.h | 2 - arch/loongarch/kernel/setup.c | 10 ----- arch/loongarch/mm/init.c | 6 +-- arch/m68k/mm/init.c | 8 ++-- arch/m68k/mm/mcfmmu.c | 3 -- arch/m68k/mm/motorola.c | 6 +-- arch/m68k/mm/sun3mmu.c | 9 ----- arch/microblaze/mm/init.c | 22 +++++------ arch/mips/include/asm/pgalloc.h | 2 - arch/mips/include/asm/pgtable.h | 2 +- arch/mips/kernel/setup.c | 15 +------ arch/mips/loongson64/numa.c | 10 ++--- arch/mips/mm/init.c | 8 +--- arch/mips/sgi-ip27/ip27-memory.c | 8 +--- arch/nios2/mm/init.c | 12 +++--- arch/openrisc/mm/init.c | 10 +---- arch/parisc/mm/init.c | 11 +----- arch/powerpc/include/asm/hugetlb.h | 5 --- arch/powerpc/include/asm/setup.h | 4 ++ arch/powerpc/kernel/setup-common.c | 1 - arch/powerpc/mm/hugetlbpage.c | 11 ++---- arch/powerpc/mm/mem.c | 27 +++++-------- arch/powerpc/mm/numa.c | 2 - arch/riscv/mm/hugetlbpage.c | 8 ++++ arch/riscv/mm/init.c | 10 +---- arch/s390/kernel/setup.c | 2 - arch/s390/mm/hugetlbpage.c | 8 ++++ arch/s390/mm/init.c | 13 +++---- arch/sh/mm/init.c | 12 +++--- arch/sparc/mm/init_64.c | 17 +++----- arch/sparc/mm/srmmu.c | 17 ++++---- arch/um/kernel/mem.c | 10 ++--- arch/x86/kernel/setup.c | 5 --- arch/x86/mm/hugetlbpage.c | 8 ++++ arch/x86/mm/init.c | 8 +--- arch/x86/mm/init_32.c | 2 - arch/x86/mm/init_64.c | 4 -- arch/x86/mm/mm_internal.h | 1 - arch/xtensa/mm/init.c | 14 +++---- include/linux/hugetlb.h | 12 ++---- include/linux/mm.h | 5 ++- include/linux/mmzone.h | 2 - init/main.c | 1 + mm/hugetlb.c | 13 ------- mm/hugetlb_cma.c | 33 ++++++++-------- mm/hugetlb_cma.h | 5 --- mm/hugetlb_vmemmap.c | 11 ------ mm/internal.h | 6 +++ mm/mm_init.c | 20 ++++++---- 64 files changed, 223 insertions(+), 414 deletions(-) base-commit: 8f0b4cce4481fb22653697cced8d0d04027cb1e8 -- 2.51.0
null
null
null
[PATCH v3 00/29] arch, mm: consolidate hugetlb early reservation
From: "Mike Rapoport (Microsoft)" <rppt@kernel.org> Move calculations of zone limits to a dedicated arch_zone_limits_init() function. Later MM core will use this function as an architecture specific callback during nodes and zones initialization and thus there won't be a need to call free_area_init() from every architecture. Signed-off-by: Mike Rapoport (Microsoft) <rppt@kernel.org> --- arch/powerpc/mm/mem.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/arch/powerpc/mm/mem.c b/arch/powerpc/mm/mem.c index 3ddbfdbfa941..03c05ec56041 100644 --- a/arch/powerpc/mm/mem.c +++ b/arch/powerpc/mm/mem.c @@ -221,13 +221,23 @@ static int __init mark_nonram_nosave(void) * anyway) will take a first dip into ZONE_NORMAL and get otherwise served by * ZONE_DMA. */ -static unsigned long max_zone_pfns[MAX_NR_ZONES]; +void __init arch_zone_limits_init(unsigned long *max_zone_pfns) +{ +#ifdef CONFIG_ZONE_DMA + max_zone_pfns[ZONE_DMA] = min((zone_dma_limit >> PAGE_SHIFT) + 1, max_low_pfn); +#endif + max_zone_pfns[ZONE_NORMAL] = max_low_pfn; +#ifdef CONFIG_HIGHMEM + max_zone_pfns[ZONE_HIGHMEM] = max_pfn; +#endif +} /* * paging_init() sets up the page tables - in fact we've already done this. */ void __init paging_init(void) { + unsigned long max_zone_pfns[MAX_NR_ZONES] = { 0 }; unsigned long long total_ram = memblock_phys_mem_size(); phys_addr_t top_of_ram = memblock_end_of_DRAM(); int zone_dma_bits; @@ -259,15 +269,7 @@ void __init paging_init(void) zone_dma_limit = DMA_BIT_MASK(zone_dma_bits); -#ifdef CONFIG_ZONE_DMA - max_zone_pfns[ZONE_DMA] = min(max_low_pfn, - 1UL << (zone_dma_bits - PAGE_SHIFT)); -#endif - max_zone_pfns[ZONE_NORMAL] = max_low_pfn; -#ifdef CONFIG_HIGHMEM - max_zone_pfns[ZONE_HIGHMEM] = max_pfn; -#endif - + arch_zone_limits_init(max_zone_pfns); free_area_init(max_zone_pfns); mark_nonram_nosave(); -- 2.51.0
{ "author": "Mike Rapoport <rppt@kernel.org>", "date": "Sun, 11 Jan 2026 10:20:49 +0200", "is_openbsd": false, "thread_id": "b9527ed4-7a5c-42e9-8814-b276b3741f63@suse.cz.mbox.gz" }
lkml_critique
lkml
From: "Mike Rapoport (Microsoft)" <rppt@kernel.org> Hi, Order in which early memory reservation for hugetlb happens depends on architecture, on configuration options and on command line parameters. Some architectures rely on the core MM to call hugetlb_bootmem_alloc() while others call it very early to allow pre-allocation of HVO-style vmemmap. When hugetlb_cma is supported by an architecture it is initialized during setup_arch() and then later hugetlb_init code needs to understand did it happen or not. To make everything consistent and unified, both reservation of hugetlb memory from bootmem and creation of CMA areas for hugetlb must be called from core MM initialization and it would have been a simple change. However, HVO-style pre-initialization ordering requirements slightly complicate things and for HVO pre-init to work sparse and memory map should be initialized after hugetlb reservations. This required pulling out the call to free_area_init() out of setup_arch() path and moving it MM initialization and this is what the first 23 patches do. These changes are deliberately split into per-arch patches that change how the zone limits are calculated for each architecture and the patches 22 and 23 just remove the calls to free_area_init() and sprase_init() from arch/*. Patch 24 is a simple cleanup for MIPS. Patches 25 and 26 actually consolidate hugetlb reservations and patches 27 and 28 perform some aftermath cleanups. I tried to trim the distribution list and although it's still quite long if you feel that someone was wrongly excluded please add them back. The changes also available in git: https://git.kernel.org/pub/scm/linux/kernel/git/rppt/linux.git/log/?h=hugetlb-init/v3 v3 changes: * fix empty_zero_page initialization on arm * fix ZONE_DMA limit calculation on powerpc * add Acks v2: https://lore.kernel.org/all/20260102070005.65328-1-rppt@kernel.org * move the hugetlb and memory map initializaion to mm_core_init_early() * add Acks v1: https://lore.kernel.org/all/20251228124001.3624742-1-rppt@kernel.org Klara Modin (1): arm: make initialization of zero page independent of the memory map Mike Rapoport (Microsoft) (28): alpha: introduce arch_zone_limits_init() arc: introduce arch_zone_limits_init() arm: introduce arch_zone_limits_init() arm64: introduce arch_zone_limits_init() csky: introduce arch_zone_limits_init() hexagon: introduce arch_zone_limits_init() loongarch: introduce arch_zone_limits_init() m68k: introduce arch_zone_limits_init() microblaze: introduce arch_zone_limits_init() mips: introduce arch_zone_limits_init() nios2: introduce arch_zone_limits_init() openrisc: introduce arch_zone_limits_init() parisc: introduce arch_zone_limits_init() powerpc: introduce arch_zone_limits_init() riscv: introduce arch_zone_limits_init() s390: introduce arch_zone_limits_init() sh: introduce arch_zone_limits_init() sparc: introduce arch_zone_limits_init() um: introduce arch_zone_limits_init() x86: introduce arch_zone_limits_init() xtensa: introduce arch_zone_limits_init() arch, mm: consolidate initialization of nodes, zones and memory map arch, mm: consolidate initialization of SPARSE memory model mips: drop paging_init() x86: don't reserve hugetlb memory in setup_arch() mm, arch: consolidate hugetlb CMA reservation mm/hugetlb: drop hugetlb_cma_check() Revert "mm/hugetlb: deal with multiple calls to hugetlb_bootmem_alloc" .../driver-api/cxl/linux/early-boot.rst | 2 +- Documentation/mm/memory-model.rst | 3 -- .../translations/zh_CN/mm/memory-model.rst | 2 - arch/alpha/kernel/setup.c | 1 - arch/alpha/mm/init.c | 16 ++++---- arch/arc/mm/init.c | 37 +++++++++--------- arch/arm/include/asm/pgtable.h | 4 +- arch/arm/mm/init.c | 25 ++---------- arch/arm/mm/mmu.c | 10 +---- arch/arm/mm/nommu.c | 10 +---- arch/arm64/include/asm/hugetlb.h | 2 - arch/arm64/mm/hugetlbpage.c | 10 ++--- arch/arm64/mm/init.c | 39 ++++++++----------- arch/csky/kernel/setup.c | 16 ++++---- arch/hexagon/mm/init.c | 19 +++------ arch/loongarch/include/asm/pgtable.h | 2 - arch/loongarch/kernel/setup.c | 10 ----- arch/loongarch/mm/init.c | 6 +-- arch/m68k/mm/init.c | 8 ++-- arch/m68k/mm/mcfmmu.c | 3 -- arch/m68k/mm/motorola.c | 6 +-- arch/m68k/mm/sun3mmu.c | 9 ----- arch/microblaze/mm/init.c | 22 +++++------ arch/mips/include/asm/pgalloc.h | 2 - arch/mips/include/asm/pgtable.h | 2 +- arch/mips/kernel/setup.c | 15 +------ arch/mips/loongson64/numa.c | 10 ++--- arch/mips/mm/init.c | 8 +--- arch/mips/sgi-ip27/ip27-memory.c | 8 +--- arch/nios2/mm/init.c | 12 +++--- arch/openrisc/mm/init.c | 10 +---- arch/parisc/mm/init.c | 11 +----- arch/powerpc/include/asm/hugetlb.h | 5 --- arch/powerpc/include/asm/setup.h | 4 ++ arch/powerpc/kernel/setup-common.c | 1 - arch/powerpc/mm/hugetlbpage.c | 11 ++---- arch/powerpc/mm/mem.c | 27 +++++-------- arch/powerpc/mm/numa.c | 2 - arch/riscv/mm/hugetlbpage.c | 8 ++++ arch/riscv/mm/init.c | 10 +---- arch/s390/kernel/setup.c | 2 - arch/s390/mm/hugetlbpage.c | 8 ++++ arch/s390/mm/init.c | 13 +++---- arch/sh/mm/init.c | 12 +++--- arch/sparc/mm/init_64.c | 17 +++----- arch/sparc/mm/srmmu.c | 17 ++++---- arch/um/kernel/mem.c | 10 ++--- arch/x86/kernel/setup.c | 5 --- arch/x86/mm/hugetlbpage.c | 8 ++++ arch/x86/mm/init.c | 8 +--- arch/x86/mm/init_32.c | 2 - arch/x86/mm/init_64.c | 4 -- arch/x86/mm/mm_internal.h | 1 - arch/xtensa/mm/init.c | 14 +++---- include/linux/hugetlb.h | 12 ++---- include/linux/mm.h | 5 ++- include/linux/mmzone.h | 2 - init/main.c | 1 + mm/hugetlb.c | 13 ------- mm/hugetlb_cma.c | 33 ++++++++-------- mm/hugetlb_cma.h | 5 --- mm/hugetlb_vmemmap.c | 11 ------ mm/internal.h | 6 +++ mm/mm_init.c | 20 ++++++---- 64 files changed, 223 insertions(+), 414 deletions(-) base-commit: 8f0b4cce4481fb22653697cced8d0d04027cb1e8 -- 2.51.0
null
null
null
[PATCH v3 00/29] arch, mm: consolidate hugetlb early reservation
From: "Mike Rapoport (Microsoft)" <rppt@kernel.org> Move calculations of zone limits to a dedicated arch_zone_limits_init() function. Later MM core will use this function as an architecture specific callback during nodes and zones initialization and thus there won't be a need to call free_area_init() from every architecture. Signed-off-by: Mike Rapoport (Microsoft) <rppt@kernel.org> --- arch/riscv/mm/init.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c index addb8a9305be..97e8661fbcff 100644 --- a/arch/riscv/mm/init.c +++ b/arch/riscv/mm/init.c @@ -79,15 +79,19 @@ uintptr_t _dtb_early_pa __initdata; phys_addr_t dma32_phys_limit __initdata; -static void __init zone_sizes_init(void) +void __init arch_zone_limits_init(unsigned long *max_zone_pfns) { - unsigned long max_zone_pfns[MAX_NR_ZONES] = { 0, }; - #ifdef CONFIG_ZONE_DMA32 max_zone_pfns[ZONE_DMA32] = PFN_DOWN(dma32_phys_limit); #endif max_zone_pfns[ZONE_NORMAL] = max_low_pfn; +} + +static void __init zone_sizes_init(void) +{ + unsigned long max_zone_pfns[MAX_NR_ZONES] = { 0, }; + arch_zone_limits_init(max_zone_pfns); free_area_init(max_zone_pfns); } -- 2.51.0
{ "author": "Mike Rapoport <rppt@kernel.org>", "date": "Sun, 11 Jan 2026 10:20:50 +0200", "is_openbsd": false, "thread_id": "b9527ed4-7a5c-42e9-8814-b276b3741f63@suse.cz.mbox.gz" }
lkml_critique
lkml
From: "Mike Rapoport (Microsoft)" <rppt@kernel.org> Hi, Order in which early memory reservation for hugetlb happens depends on architecture, on configuration options and on command line parameters. Some architectures rely on the core MM to call hugetlb_bootmem_alloc() while others call it very early to allow pre-allocation of HVO-style vmemmap. When hugetlb_cma is supported by an architecture it is initialized during setup_arch() and then later hugetlb_init code needs to understand did it happen or not. To make everything consistent and unified, both reservation of hugetlb memory from bootmem and creation of CMA areas for hugetlb must be called from core MM initialization and it would have been a simple change. However, HVO-style pre-initialization ordering requirements slightly complicate things and for HVO pre-init to work sparse and memory map should be initialized after hugetlb reservations. This required pulling out the call to free_area_init() out of setup_arch() path and moving it MM initialization and this is what the first 23 patches do. These changes are deliberately split into per-arch patches that change how the zone limits are calculated for each architecture and the patches 22 and 23 just remove the calls to free_area_init() and sprase_init() from arch/*. Patch 24 is a simple cleanup for MIPS. Patches 25 and 26 actually consolidate hugetlb reservations and patches 27 and 28 perform some aftermath cleanups. I tried to trim the distribution list and although it's still quite long if you feel that someone was wrongly excluded please add them back. The changes also available in git: https://git.kernel.org/pub/scm/linux/kernel/git/rppt/linux.git/log/?h=hugetlb-init/v3 v3 changes: * fix empty_zero_page initialization on arm * fix ZONE_DMA limit calculation on powerpc * add Acks v2: https://lore.kernel.org/all/20260102070005.65328-1-rppt@kernel.org * move the hugetlb and memory map initializaion to mm_core_init_early() * add Acks v1: https://lore.kernel.org/all/20251228124001.3624742-1-rppt@kernel.org Klara Modin (1): arm: make initialization of zero page independent of the memory map Mike Rapoport (Microsoft) (28): alpha: introduce arch_zone_limits_init() arc: introduce arch_zone_limits_init() arm: introduce arch_zone_limits_init() arm64: introduce arch_zone_limits_init() csky: introduce arch_zone_limits_init() hexagon: introduce arch_zone_limits_init() loongarch: introduce arch_zone_limits_init() m68k: introduce arch_zone_limits_init() microblaze: introduce arch_zone_limits_init() mips: introduce arch_zone_limits_init() nios2: introduce arch_zone_limits_init() openrisc: introduce arch_zone_limits_init() parisc: introduce arch_zone_limits_init() powerpc: introduce arch_zone_limits_init() riscv: introduce arch_zone_limits_init() s390: introduce arch_zone_limits_init() sh: introduce arch_zone_limits_init() sparc: introduce arch_zone_limits_init() um: introduce arch_zone_limits_init() x86: introduce arch_zone_limits_init() xtensa: introduce arch_zone_limits_init() arch, mm: consolidate initialization of nodes, zones and memory map arch, mm: consolidate initialization of SPARSE memory model mips: drop paging_init() x86: don't reserve hugetlb memory in setup_arch() mm, arch: consolidate hugetlb CMA reservation mm/hugetlb: drop hugetlb_cma_check() Revert "mm/hugetlb: deal with multiple calls to hugetlb_bootmem_alloc" .../driver-api/cxl/linux/early-boot.rst | 2 +- Documentation/mm/memory-model.rst | 3 -- .../translations/zh_CN/mm/memory-model.rst | 2 - arch/alpha/kernel/setup.c | 1 - arch/alpha/mm/init.c | 16 ++++---- arch/arc/mm/init.c | 37 +++++++++--------- arch/arm/include/asm/pgtable.h | 4 +- arch/arm/mm/init.c | 25 ++---------- arch/arm/mm/mmu.c | 10 +---- arch/arm/mm/nommu.c | 10 +---- arch/arm64/include/asm/hugetlb.h | 2 - arch/arm64/mm/hugetlbpage.c | 10 ++--- arch/arm64/mm/init.c | 39 ++++++++----------- arch/csky/kernel/setup.c | 16 ++++---- arch/hexagon/mm/init.c | 19 +++------ arch/loongarch/include/asm/pgtable.h | 2 - arch/loongarch/kernel/setup.c | 10 ----- arch/loongarch/mm/init.c | 6 +-- arch/m68k/mm/init.c | 8 ++-- arch/m68k/mm/mcfmmu.c | 3 -- arch/m68k/mm/motorola.c | 6 +-- arch/m68k/mm/sun3mmu.c | 9 ----- arch/microblaze/mm/init.c | 22 +++++------ arch/mips/include/asm/pgalloc.h | 2 - arch/mips/include/asm/pgtable.h | 2 +- arch/mips/kernel/setup.c | 15 +------ arch/mips/loongson64/numa.c | 10 ++--- arch/mips/mm/init.c | 8 +--- arch/mips/sgi-ip27/ip27-memory.c | 8 +--- arch/nios2/mm/init.c | 12 +++--- arch/openrisc/mm/init.c | 10 +---- arch/parisc/mm/init.c | 11 +----- arch/powerpc/include/asm/hugetlb.h | 5 --- arch/powerpc/include/asm/setup.h | 4 ++ arch/powerpc/kernel/setup-common.c | 1 - arch/powerpc/mm/hugetlbpage.c | 11 ++---- arch/powerpc/mm/mem.c | 27 +++++-------- arch/powerpc/mm/numa.c | 2 - arch/riscv/mm/hugetlbpage.c | 8 ++++ arch/riscv/mm/init.c | 10 +---- arch/s390/kernel/setup.c | 2 - arch/s390/mm/hugetlbpage.c | 8 ++++ arch/s390/mm/init.c | 13 +++---- arch/sh/mm/init.c | 12 +++--- arch/sparc/mm/init_64.c | 17 +++----- arch/sparc/mm/srmmu.c | 17 ++++---- arch/um/kernel/mem.c | 10 ++--- arch/x86/kernel/setup.c | 5 --- arch/x86/mm/hugetlbpage.c | 8 ++++ arch/x86/mm/init.c | 8 +--- arch/x86/mm/init_32.c | 2 - arch/x86/mm/init_64.c | 4 -- arch/x86/mm/mm_internal.h | 1 - arch/xtensa/mm/init.c | 14 +++---- include/linux/hugetlb.h | 12 ++---- include/linux/mm.h | 5 ++- include/linux/mmzone.h | 2 - init/main.c | 1 + mm/hugetlb.c | 13 ------- mm/hugetlb_cma.c | 33 ++++++++-------- mm/hugetlb_cma.h | 5 --- mm/hugetlb_vmemmap.c | 11 ------ mm/internal.h | 6 +++ mm/mm_init.c | 20 ++++++---- 64 files changed, 223 insertions(+), 414 deletions(-) base-commit: 8f0b4cce4481fb22653697cced8d0d04027cb1e8 -- 2.51.0
null
null
null
[PATCH v3 00/29] arch, mm: consolidate hugetlb early reservation
From: "Mike Rapoport (Microsoft)" <rppt@kernel.org> Move calculations of zone limits to a dedicated arch_zone_limits_init() function. Later MM core will use this function as an architecture specific callback during nodes and zones initialization and thus there won't be a need to call free_area_init() from every architecture. Signed-off-by: Mike Rapoport (Microsoft) <rppt@kernel.org> --- arch/s390/mm/init.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/arch/s390/mm/init.c b/arch/s390/mm/init.c index e4953453d254..1c11ad84dddb 100644 --- a/arch/s390/mm/init.c +++ b/arch/s390/mm/init.c @@ -86,6 +86,12 @@ static void __init setup_zero_pages(void) zero_page_mask = ((PAGE_SIZE << order) - 1) & PAGE_MASK; } +void __init arch_zone_limits_init(unsigned long *max_zone_pfns) +{ + max_zone_pfns[ZONE_DMA] = virt_to_pfn(MAX_DMA_ADDRESS); + max_zone_pfns[ZONE_NORMAL] = max_low_pfn; +} + /* * paging_init() sets up the page tables */ @@ -97,8 +103,7 @@ void __init paging_init(void) sparse_init(); zone_dma_limit = DMA_BIT_MASK(31); memset(max_zone_pfns, 0, sizeof(max_zone_pfns)); - max_zone_pfns[ZONE_DMA] = virt_to_pfn(MAX_DMA_ADDRESS); - max_zone_pfns[ZONE_NORMAL] = max_low_pfn; + arch_zone_limits_init(max_zone_pfns); free_area_init(max_zone_pfns); } -- 2.51.0
{ "author": "Mike Rapoport <rppt@kernel.org>", "date": "Sun, 11 Jan 2026 10:20:51 +0200", "is_openbsd": false, "thread_id": "b9527ed4-7a5c-42e9-8814-b276b3741f63@suse.cz.mbox.gz" }
lkml_critique
lkml
From: "Mike Rapoport (Microsoft)" <rppt@kernel.org> Hi, Order in which early memory reservation for hugetlb happens depends on architecture, on configuration options and on command line parameters. Some architectures rely on the core MM to call hugetlb_bootmem_alloc() while others call it very early to allow pre-allocation of HVO-style vmemmap. When hugetlb_cma is supported by an architecture it is initialized during setup_arch() and then later hugetlb_init code needs to understand did it happen or not. To make everything consistent and unified, both reservation of hugetlb memory from bootmem and creation of CMA areas for hugetlb must be called from core MM initialization and it would have been a simple change. However, HVO-style pre-initialization ordering requirements slightly complicate things and for HVO pre-init to work sparse and memory map should be initialized after hugetlb reservations. This required pulling out the call to free_area_init() out of setup_arch() path and moving it MM initialization and this is what the first 23 patches do. These changes are deliberately split into per-arch patches that change how the zone limits are calculated for each architecture and the patches 22 and 23 just remove the calls to free_area_init() and sprase_init() from arch/*. Patch 24 is a simple cleanup for MIPS. Patches 25 and 26 actually consolidate hugetlb reservations and patches 27 and 28 perform some aftermath cleanups. I tried to trim the distribution list and although it's still quite long if you feel that someone was wrongly excluded please add them back. The changes also available in git: https://git.kernel.org/pub/scm/linux/kernel/git/rppt/linux.git/log/?h=hugetlb-init/v3 v3 changes: * fix empty_zero_page initialization on arm * fix ZONE_DMA limit calculation on powerpc * add Acks v2: https://lore.kernel.org/all/20260102070005.65328-1-rppt@kernel.org * move the hugetlb and memory map initializaion to mm_core_init_early() * add Acks v1: https://lore.kernel.org/all/20251228124001.3624742-1-rppt@kernel.org Klara Modin (1): arm: make initialization of zero page independent of the memory map Mike Rapoport (Microsoft) (28): alpha: introduce arch_zone_limits_init() arc: introduce arch_zone_limits_init() arm: introduce arch_zone_limits_init() arm64: introduce arch_zone_limits_init() csky: introduce arch_zone_limits_init() hexagon: introduce arch_zone_limits_init() loongarch: introduce arch_zone_limits_init() m68k: introduce arch_zone_limits_init() microblaze: introduce arch_zone_limits_init() mips: introduce arch_zone_limits_init() nios2: introduce arch_zone_limits_init() openrisc: introduce arch_zone_limits_init() parisc: introduce arch_zone_limits_init() powerpc: introduce arch_zone_limits_init() riscv: introduce arch_zone_limits_init() s390: introduce arch_zone_limits_init() sh: introduce arch_zone_limits_init() sparc: introduce arch_zone_limits_init() um: introduce arch_zone_limits_init() x86: introduce arch_zone_limits_init() xtensa: introduce arch_zone_limits_init() arch, mm: consolidate initialization of nodes, zones and memory map arch, mm: consolidate initialization of SPARSE memory model mips: drop paging_init() x86: don't reserve hugetlb memory in setup_arch() mm, arch: consolidate hugetlb CMA reservation mm/hugetlb: drop hugetlb_cma_check() Revert "mm/hugetlb: deal with multiple calls to hugetlb_bootmem_alloc" .../driver-api/cxl/linux/early-boot.rst | 2 +- Documentation/mm/memory-model.rst | 3 -- .../translations/zh_CN/mm/memory-model.rst | 2 - arch/alpha/kernel/setup.c | 1 - arch/alpha/mm/init.c | 16 ++++---- arch/arc/mm/init.c | 37 +++++++++--------- arch/arm/include/asm/pgtable.h | 4 +- arch/arm/mm/init.c | 25 ++---------- arch/arm/mm/mmu.c | 10 +---- arch/arm/mm/nommu.c | 10 +---- arch/arm64/include/asm/hugetlb.h | 2 - arch/arm64/mm/hugetlbpage.c | 10 ++--- arch/arm64/mm/init.c | 39 ++++++++----------- arch/csky/kernel/setup.c | 16 ++++---- arch/hexagon/mm/init.c | 19 +++------ arch/loongarch/include/asm/pgtable.h | 2 - arch/loongarch/kernel/setup.c | 10 ----- arch/loongarch/mm/init.c | 6 +-- arch/m68k/mm/init.c | 8 ++-- arch/m68k/mm/mcfmmu.c | 3 -- arch/m68k/mm/motorola.c | 6 +-- arch/m68k/mm/sun3mmu.c | 9 ----- arch/microblaze/mm/init.c | 22 +++++------ arch/mips/include/asm/pgalloc.h | 2 - arch/mips/include/asm/pgtable.h | 2 +- arch/mips/kernel/setup.c | 15 +------ arch/mips/loongson64/numa.c | 10 ++--- arch/mips/mm/init.c | 8 +--- arch/mips/sgi-ip27/ip27-memory.c | 8 +--- arch/nios2/mm/init.c | 12 +++--- arch/openrisc/mm/init.c | 10 +---- arch/parisc/mm/init.c | 11 +----- arch/powerpc/include/asm/hugetlb.h | 5 --- arch/powerpc/include/asm/setup.h | 4 ++ arch/powerpc/kernel/setup-common.c | 1 - arch/powerpc/mm/hugetlbpage.c | 11 ++---- arch/powerpc/mm/mem.c | 27 +++++-------- arch/powerpc/mm/numa.c | 2 - arch/riscv/mm/hugetlbpage.c | 8 ++++ arch/riscv/mm/init.c | 10 +---- arch/s390/kernel/setup.c | 2 - arch/s390/mm/hugetlbpage.c | 8 ++++ arch/s390/mm/init.c | 13 +++---- arch/sh/mm/init.c | 12 +++--- arch/sparc/mm/init_64.c | 17 +++----- arch/sparc/mm/srmmu.c | 17 ++++---- arch/um/kernel/mem.c | 10 ++--- arch/x86/kernel/setup.c | 5 --- arch/x86/mm/hugetlbpage.c | 8 ++++ arch/x86/mm/init.c | 8 +--- arch/x86/mm/init_32.c | 2 - arch/x86/mm/init_64.c | 4 -- arch/x86/mm/mm_internal.h | 1 - arch/xtensa/mm/init.c | 14 +++---- include/linux/hugetlb.h | 12 ++---- include/linux/mm.h | 5 ++- include/linux/mmzone.h | 2 - init/main.c | 1 + mm/hugetlb.c | 13 ------- mm/hugetlb_cma.c | 33 ++++++++-------- mm/hugetlb_cma.h | 5 --- mm/hugetlb_vmemmap.c | 11 ------ mm/internal.h | 6 +++ mm/mm_init.c | 20 ++++++---- 64 files changed, 223 insertions(+), 414 deletions(-) base-commit: 8f0b4cce4481fb22653697cced8d0d04027cb1e8 -- 2.51.0
null
null
null
[PATCH v3 00/29] arch, mm: consolidate hugetlb early reservation
From: "Mike Rapoport (Microsoft)" <rppt@kernel.org> Move calculations of zone limits to a dedicated arch_zone_limits_init() function. Later MM core will use this function as an architecture specific callback during nodes and zones initialization and thus there won't be a need to call free_area_init() from every architecture. Signed-off-by: Mike Rapoport (Microsoft) <rppt@kernel.org> --- arch/sh/mm/init.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/arch/sh/mm/init.c b/arch/sh/mm/init.c index 99e302eeeec1..5e7e63642611 100644 --- a/arch/sh/mm/init.c +++ b/arch/sh/mm/init.c @@ -264,6 +264,11 @@ static void __init early_reserve_mem(void) reserve_crashkernel(); } +void __init arch_zone_limits_init(unsigned long *max_zone_pfns) +{ + max_zone_pfns[ZONE_NORMAL] = max_low_pfn; +} + void __init paging_init(void) { unsigned long max_zone_pfns[MAX_NR_ZONES]; @@ -322,7 +327,7 @@ void __init paging_init(void) kmap_coherent_init(); memset(max_zone_pfns, 0, sizeof(max_zone_pfns)); - max_zone_pfns[ZONE_NORMAL] = max_low_pfn; + arch_zone_limits_init(max_zone_pfns); free_area_init(max_zone_pfns); } -- 2.51.0
{ "author": "Mike Rapoport <rppt@kernel.org>", "date": "Sun, 11 Jan 2026 10:20:52 +0200", "is_openbsd": false, "thread_id": "b9527ed4-7a5c-42e9-8814-b276b3741f63@suse.cz.mbox.gz" }
lkml_critique
lkml
From: "Mike Rapoport (Microsoft)" <rppt@kernel.org> Hi, Order in which early memory reservation for hugetlb happens depends on architecture, on configuration options and on command line parameters. Some architectures rely on the core MM to call hugetlb_bootmem_alloc() while others call it very early to allow pre-allocation of HVO-style vmemmap. When hugetlb_cma is supported by an architecture it is initialized during setup_arch() and then later hugetlb_init code needs to understand did it happen or not. To make everything consistent and unified, both reservation of hugetlb memory from bootmem and creation of CMA areas for hugetlb must be called from core MM initialization and it would have been a simple change. However, HVO-style pre-initialization ordering requirements slightly complicate things and for HVO pre-init to work sparse and memory map should be initialized after hugetlb reservations. This required pulling out the call to free_area_init() out of setup_arch() path and moving it MM initialization and this is what the first 23 patches do. These changes are deliberately split into per-arch patches that change how the zone limits are calculated for each architecture and the patches 22 and 23 just remove the calls to free_area_init() and sprase_init() from arch/*. Patch 24 is a simple cleanup for MIPS. Patches 25 and 26 actually consolidate hugetlb reservations and patches 27 and 28 perform some aftermath cleanups. I tried to trim the distribution list and although it's still quite long if you feel that someone was wrongly excluded please add them back. The changes also available in git: https://git.kernel.org/pub/scm/linux/kernel/git/rppt/linux.git/log/?h=hugetlb-init/v3 v3 changes: * fix empty_zero_page initialization on arm * fix ZONE_DMA limit calculation on powerpc * add Acks v2: https://lore.kernel.org/all/20260102070005.65328-1-rppt@kernel.org * move the hugetlb and memory map initializaion to mm_core_init_early() * add Acks v1: https://lore.kernel.org/all/20251228124001.3624742-1-rppt@kernel.org Klara Modin (1): arm: make initialization of zero page independent of the memory map Mike Rapoport (Microsoft) (28): alpha: introduce arch_zone_limits_init() arc: introduce arch_zone_limits_init() arm: introduce arch_zone_limits_init() arm64: introduce arch_zone_limits_init() csky: introduce arch_zone_limits_init() hexagon: introduce arch_zone_limits_init() loongarch: introduce arch_zone_limits_init() m68k: introduce arch_zone_limits_init() microblaze: introduce arch_zone_limits_init() mips: introduce arch_zone_limits_init() nios2: introduce arch_zone_limits_init() openrisc: introduce arch_zone_limits_init() parisc: introduce arch_zone_limits_init() powerpc: introduce arch_zone_limits_init() riscv: introduce arch_zone_limits_init() s390: introduce arch_zone_limits_init() sh: introduce arch_zone_limits_init() sparc: introduce arch_zone_limits_init() um: introduce arch_zone_limits_init() x86: introduce arch_zone_limits_init() xtensa: introduce arch_zone_limits_init() arch, mm: consolidate initialization of nodes, zones and memory map arch, mm: consolidate initialization of SPARSE memory model mips: drop paging_init() x86: don't reserve hugetlb memory in setup_arch() mm, arch: consolidate hugetlb CMA reservation mm/hugetlb: drop hugetlb_cma_check() Revert "mm/hugetlb: deal with multiple calls to hugetlb_bootmem_alloc" .../driver-api/cxl/linux/early-boot.rst | 2 +- Documentation/mm/memory-model.rst | 3 -- .../translations/zh_CN/mm/memory-model.rst | 2 - arch/alpha/kernel/setup.c | 1 - arch/alpha/mm/init.c | 16 ++++---- arch/arc/mm/init.c | 37 +++++++++--------- arch/arm/include/asm/pgtable.h | 4 +- arch/arm/mm/init.c | 25 ++---------- arch/arm/mm/mmu.c | 10 +---- arch/arm/mm/nommu.c | 10 +---- arch/arm64/include/asm/hugetlb.h | 2 - arch/arm64/mm/hugetlbpage.c | 10 ++--- arch/arm64/mm/init.c | 39 ++++++++----------- arch/csky/kernel/setup.c | 16 ++++---- arch/hexagon/mm/init.c | 19 +++------ arch/loongarch/include/asm/pgtable.h | 2 - arch/loongarch/kernel/setup.c | 10 ----- arch/loongarch/mm/init.c | 6 +-- arch/m68k/mm/init.c | 8 ++-- arch/m68k/mm/mcfmmu.c | 3 -- arch/m68k/mm/motorola.c | 6 +-- arch/m68k/mm/sun3mmu.c | 9 ----- arch/microblaze/mm/init.c | 22 +++++------ arch/mips/include/asm/pgalloc.h | 2 - arch/mips/include/asm/pgtable.h | 2 +- arch/mips/kernel/setup.c | 15 +------ arch/mips/loongson64/numa.c | 10 ++--- arch/mips/mm/init.c | 8 +--- arch/mips/sgi-ip27/ip27-memory.c | 8 +--- arch/nios2/mm/init.c | 12 +++--- arch/openrisc/mm/init.c | 10 +---- arch/parisc/mm/init.c | 11 +----- arch/powerpc/include/asm/hugetlb.h | 5 --- arch/powerpc/include/asm/setup.h | 4 ++ arch/powerpc/kernel/setup-common.c | 1 - arch/powerpc/mm/hugetlbpage.c | 11 ++---- arch/powerpc/mm/mem.c | 27 +++++-------- arch/powerpc/mm/numa.c | 2 - arch/riscv/mm/hugetlbpage.c | 8 ++++ arch/riscv/mm/init.c | 10 +---- arch/s390/kernel/setup.c | 2 - arch/s390/mm/hugetlbpage.c | 8 ++++ arch/s390/mm/init.c | 13 +++---- arch/sh/mm/init.c | 12 +++--- arch/sparc/mm/init_64.c | 17 +++----- arch/sparc/mm/srmmu.c | 17 ++++---- arch/um/kernel/mem.c | 10 ++--- arch/x86/kernel/setup.c | 5 --- arch/x86/mm/hugetlbpage.c | 8 ++++ arch/x86/mm/init.c | 8 +--- arch/x86/mm/init_32.c | 2 - arch/x86/mm/init_64.c | 4 -- arch/x86/mm/mm_internal.h | 1 - arch/xtensa/mm/init.c | 14 +++---- include/linux/hugetlb.h | 12 ++---- include/linux/mm.h | 5 ++- include/linux/mmzone.h | 2 - init/main.c | 1 + mm/hugetlb.c | 13 ------- mm/hugetlb_cma.c | 33 ++++++++-------- mm/hugetlb_cma.h | 5 --- mm/hugetlb_vmemmap.c | 11 ------ mm/internal.h | 6 +++ mm/mm_init.c | 20 ++++++---- 64 files changed, 223 insertions(+), 414 deletions(-) base-commit: 8f0b4cce4481fb22653697cced8d0d04027cb1e8 -- 2.51.0
null
null
null
[PATCH v3 00/29] arch, mm: consolidate hugetlb early reservation
From: "Mike Rapoport (Microsoft)" <rppt@kernel.org> Move calculations of zone limits to a dedicated arch_zone_limits_init() function. Later MM core will use this function as an architecture specific callback during nodes and zones initialization and thus there won't be a need to call free_area_init() from every architecture. Signed-off-by: Mike Rapoport (Microsoft) <rppt@kernel.org> --- arch/sparc/mm/init_64.c | 6 ++++++ arch/sparc/mm/srmmu.c | 12 ++++++++---- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/arch/sparc/mm/init_64.c b/arch/sparc/mm/init_64.c index df9f7c444c39..fbaad449dfc9 100644 --- a/arch/sparc/mm/init_64.c +++ b/arch/sparc/mm/init_64.c @@ -2279,6 +2279,11 @@ static void __init reduce_memory(phys_addr_t limit_ram) memblock_enforce_memory_limit(limit_ram); } +void __init arch_zone_limits_init(unsigned long *max_zone_pfns) +{ + max_zone_pfns[ZONE_NORMAL] = last_valid_pfn; +} + void __init paging_init(void) { unsigned long end_pfn, shift, phys_base; @@ -2461,6 +2466,7 @@ void __init paging_init(void) max_zone_pfns[ZONE_NORMAL] = end_pfn; + arch_zone_limits_init(max_zone_pfns); free_area_init(max_zone_pfns); } diff --git a/arch/sparc/mm/srmmu.c b/arch/sparc/mm/srmmu.c index f8fb4911d360..81e90151db90 100644 --- a/arch/sparc/mm/srmmu.c +++ b/arch/sparc/mm/srmmu.c @@ -884,6 +884,13 @@ static void __init map_kernel(void) void (*poke_srmmu)(void) = NULL; +void __init arch_zone_limits_init(unsigned long *max_zone_pfns) +{ + max_zone_pfns[ZONE_DMA] = max_low_pfn; + max_zone_pfns[ZONE_NORMAL] = max_low_pfn; + max_zone_pfns[ZONE_HIGHMEM] = highend_pfn; +} + void __init srmmu_paging_init(void) { int i; @@ -967,10 +974,7 @@ void __init srmmu_paging_init(void) { unsigned long max_zone_pfn[MAX_NR_ZONES] = { 0 }; - max_zone_pfn[ZONE_DMA] = max_low_pfn; - max_zone_pfn[ZONE_NORMAL] = max_low_pfn; - max_zone_pfn[ZONE_HIGHMEM] = highend_pfn; - + arch_zone_limits_init(max_zone_pfn); free_area_init(max_zone_pfn); } } -- 2.51.0
{ "author": "Mike Rapoport <rppt@kernel.org>", "date": "Sun, 11 Jan 2026 10:20:53 +0200", "is_openbsd": false, "thread_id": "b9527ed4-7a5c-42e9-8814-b276b3741f63@suse.cz.mbox.gz" }
lkml_critique
lkml
From: "Mike Rapoport (Microsoft)" <rppt@kernel.org> Hi, Order in which early memory reservation for hugetlb happens depends on architecture, on configuration options and on command line parameters. Some architectures rely on the core MM to call hugetlb_bootmem_alloc() while others call it very early to allow pre-allocation of HVO-style vmemmap. When hugetlb_cma is supported by an architecture it is initialized during setup_arch() and then later hugetlb_init code needs to understand did it happen or not. To make everything consistent and unified, both reservation of hugetlb memory from bootmem and creation of CMA areas for hugetlb must be called from core MM initialization and it would have been a simple change. However, HVO-style pre-initialization ordering requirements slightly complicate things and for HVO pre-init to work sparse and memory map should be initialized after hugetlb reservations. This required pulling out the call to free_area_init() out of setup_arch() path and moving it MM initialization and this is what the first 23 patches do. These changes are deliberately split into per-arch patches that change how the zone limits are calculated for each architecture and the patches 22 and 23 just remove the calls to free_area_init() and sprase_init() from arch/*. Patch 24 is a simple cleanup for MIPS. Patches 25 and 26 actually consolidate hugetlb reservations and patches 27 and 28 perform some aftermath cleanups. I tried to trim the distribution list and although it's still quite long if you feel that someone was wrongly excluded please add them back. The changes also available in git: https://git.kernel.org/pub/scm/linux/kernel/git/rppt/linux.git/log/?h=hugetlb-init/v3 v3 changes: * fix empty_zero_page initialization on arm * fix ZONE_DMA limit calculation on powerpc * add Acks v2: https://lore.kernel.org/all/20260102070005.65328-1-rppt@kernel.org * move the hugetlb and memory map initializaion to mm_core_init_early() * add Acks v1: https://lore.kernel.org/all/20251228124001.3624742-1-rppt@kernel.org Klara Modin (1): arm: make initialization of zero page independent of the memory map Mike Rapoport (Microsoft) (28): alpha: introduce arch_zone_limits_init() arc: introduce arch_zone_limits_init() arm: introduce arch_zone_limits_init() arm64: introduce arch_zone_limits_init() csky: introduce arch_zone_limits_init() hexagon: introduce arch_zone_limits_init() loongarch: introduce arch_zone_limits_init() m68k: introduce arch_zone_limits_init() microblaze: introduce arch_zone_limits_init() mips: introduce arch_zone_limits_init() nios2: introduce arch_zone_limits_init() openrisc: introduce arch_zone_limits_init() parisc: introduce arch_zone_limits_init() powerpc: introduce arch_zone_limits_init() riscv: introduce arch_zone_limits_init() s390: introduce arch_zone_limits_init() sh: introduce arch_zone_limits_init() sparc: introduce arch_zone_limits_init() um: introduce arch_zone_limits_init() x86: introduce arch_zone_limits_init() xtensa: introduce arch_zone_limits_init() arch, mm: consolidate initialization of nodes, zones and memory map arch, mm: consolidate initialization of SPARSE memory model mips: drop paging_init() x86: don't reserve hugetlb memory in setup_arch() mm, arch: consolidate hugetlb CMA reservation mm/hugetlb: drop hugetlb_cma_check() Revert "mm/hugetlb: deal with multiple calls to hugetlb_bootmem_alloc" .../driver-api/cxl/linux/early-boot.rst | 2 +- Documentation/mm/memory-model.rst | 3 -- .../translations/zh_CN/mm/memory-model.rst | 2 - arch/alpha/kernel/setup.c | 1 - arch/alpha/mm/init.c | 16 ++++---- arch/arc/mm/init.c | 37 +++++++++--------- arch/arm/include/asm/pgtable.h | 4 +- arch/arm/mm/init.c | 25 ++---------- arch/arm/mm/mmu.c | 10 +---- arch/arm/mm/nommu.c | 10 +---- arch/arm64/include/asm/hugetlb.h | 2 - arch/arm64/mm/hugetlbpage.c | 10 ++--- arch/arm64/mm/init.c | 39 ++++++++----------- arch/csky/kernel/setup.c | 16 ++++---- arch/hexagon/mm/init.c | 19 +++------ arch/loongarch/include/asm/pgtable.h | 2 - arch/loongarch/kernel/setup.c | 10 ----- arch/loongarch/mm/init.c | 6 +-- arch/m68k/mm/init.c | 8 ++-- arch/m68k/mm/mcfmmu.c | 3 -- arch/m68k/mm/motorola.c | 6 +-- arch/m68k/mm/sun3mmu.c | 9 ----- arch/microblaze/mm/init.c | 22 +++++------ arch/mips/include/asm/pgalloc.h | 2 - arch/mips/include/asm/pgtable.h | 2 +- arch/mips/kernel/setup.c | 15 +------ arch/mips/loongson64/numa.c | 10 ++--- arch/mips/mm/init.c | 8 +--- arch/mips/sgi-ip27/ip27-memory.c | 8 +--- arch/nios2/mm/init.c | 12 +++--- arch/openrisc/mm/init.c | 10 +---- arch/parisc/mm/init.c | 11 +----- arch/powerpc/include/asm/hugetlb.h | 5 --- arch/powerpc/include/asm/setup.h | 4 ++ arch/powerpc/kernel/setup-common.c | 1 - arch/powerpc/mm/hugetlbpage.c | 11 ++---- arch/powerpc/mm/mem.c | 27 +++++-------- arch/powerpc/mm/numa.c | 2 - arch/riscv/mm/hugetlbpage.c | 8 ++++ arch/riscv/mm/init.c | 10 +---- arch/s390/kernel/setup.c | 2 - arch/s390/mm/hugetlbpage.c | 8 ++++ arch/s390/mm/init.c | 13 +++---- arch/sh/mm/init.c | 12 +++--- arch/sparc/mm/init_64.c | 17 +++----- arch/sparc/mm/srmmu.c | 17 ++++---- arch/um/kernel/mem.c | 10 ++--- arch/x86/kernel/setup.c | 5 --- arch/x86/mm/hugetlbpage.c | 8 ++++ arch/x86/mm/init.c | 8 +--- arch/x86/mm/init_32.c | 2 - arch/x86/mm/init_64.c | 4 -- arch/x86/mm/mm_internal.h | 1 - arch/xtensa/mm/init.c | 14 +++---- include/linux/hugetlb.h | 12 ++---- include/linux/mm.h | 5 ++- include/linux/mmzone.h | 2 - init/main.c | 1 + mm/hugetlb.c | 13 ------- mm/hugetlb_cma.c | 33 ++++++++-------- mm/hugetlb_cma.h | 5 --- mm/hugetlb_vmemmap.c | 11 ------ mm/internal.h | 6 +++ mm/mm_init.c | 20 ++++++---- 64 files changed, 223 insertions(+), 414 deletions(-) base-commit: 8f0b4cce4481fb22653697cced8d0d04027cb1e8 -- 2.51.0
null
null
null
[PATCH v3 00/29] arch, mm: consolidate hugetlb early reservation
From: "Mike Rapoport (Microsoft)" <rppt@kernel.org> Move calculations of zone limits to a dedicated arch_zone_limits_init() function. Later MM core will use this function as an architecture specific callback during nodes and zones initialization and thus there won't be a need to call free_area_init() from every architecture. Signed-off-by: Mike Rapoport (Microsoft) <rppt@kernel.org> --- arch/um/kernel/mem.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/arch/um/kernel/mem.c b/arch/um/kernel/mem.c index 39c4a7e21c6f..2ac4e9debedd 100644 --- a/arch/um/kernel/mem.c +++ b/arch/um/kernel/mem.c @@ -84,6 +84,11 @@ void __init mem_init(void) kmalloc_ok = 1; } +void __init arch_zone_limits_init(unsigned long *max_zone_pfns) +{ + max_zone_pfns[ZONE_NORMAL] = high_physmem >> PAGE_SHIFT; +} + void __init paging_init(void) { unsigned long max_zone_pfn[MAX_NR_ZONES] = { 0 }; @@ -94,7 +99,7 @@ void __init paging_init(void) panic("%s: Failed to allocate %lu bytes align=%lx\n", __func__, PAGE_SIZE, PAGE_SIZE); - max_zone_pfn[ZONE_NORMAL] = high_physmem >> PAGE_SHIFT; + arch_zone_limits_init(max_zone_pfn); free_area_init(max_zone_pfn); } -- 2.51.0
{ "author": "Mike Rapoport <rppt@kernel.org>", "date": "Sun, 11 Jan 2026 10:20:54 +0200", "is_openbsd": false, "thread_id": "b9527ed4-7a5c-42e9-8814-b276b3741f63@suse.cz.mbox.gz" }
lkml_critique
lkml
From: "Mike Rapoport (Microsoft)" <rppt@kernel.org> Hi, Order in which early memory reservation for hugetlb happens depends on architecture, on configuration options and on command line parameters. Some architectures rely on the core MM to call hugetlb_bootmem_alloc() while others call it very early to allow pre-allocation of HVO-style vmemmap. When hugetlb_cma is supported by an architecture it is initialized during setup_arch() and then later hugetlb_init code needs to understand did it happen or not. To make everything consistent and unified, both reservation of hugetlb memory from bootmem and creation of CMA areas for hugetlb must be called from core MM initialization and it would have been a simple change. However, HVO-style pre-initialization ordering requirements slightly complicate things and for HVO pre-init to work sparse and memory map should be initialized after hugetlb reservations. This required pulling out the call to free_area_init() out of setup_arch() path and moving it MM initialization and this is what the first 23 patches do. These changes are deliberately split into per-arch patches that change how the zone limits are calculated for each architecture and the patches 22 and 23 just remove the calls to free_area_init() and sprase_init() from arch/*. Patch 24 is a simple cleanup for MIPS. Patches 25 and 26 actually consolidate hugetlb reservations and patches 27 and 28 perform some aftermath cleanups. I tried to trim the distribution list and although it's still quite long if you feel that someone was wrongly excluded please add them back. The changes also available in git: https://git.kernel.org/pub/scm/linux/kernel/git/rppt/linux.git/log/?h=hugetlb-init/v3 v3 changes: * fix empty_zero_page initialization on arm * fix ZONE_DMA limit calculation on powerpc * add Acks v2: https://lore.kernel.org/all/20260102070005.65328-1-rppt@kernel.org * move the hugetlb and memory map initializaion to mm_core_init_early() * add Acks v1: https://lore.kernel.org/all/20251228124001.3624742-1-rppt@kernel.org Klara Modin (1): arm: make initialization of zero page independent of the memory map Mike Rapoport (Microsoft) (28): alpha: introduce arch_zone_limits_init() arc: introduce arch_zone_limits_init() arm: introduce arch_zone_limits_init() arm64: introduce arch_zone_limits_init() csky: introduce arch_zone_limits_init() hexagon: introduce arch_zone_limits_init() loongarch: introduce arch_zone_limits_init() m68k: introduce arch_zone_limits_init() microblaze: introduce arch_zone_limits_init() mips: introduce arch_zone_limits_init() nios2: introduce arch_zone_limits_init() openrisc: introduce arch_zone_limits_init() parisc: introduce arch_zone_limits_init() powerpc: introduce arch_zone_limits_init() riscv: introduce arch_zone_limits_init() s390: introduce arch_zone_limits_init() sh: introduce arch_zone_limits_init() sparc: introduce arch_zone_limits_init() um: introduce arch_zone_limits_init() x86: introduce arch_zone_limits_init() xtensa: introduce arch_zone_limits_init() arch, mm: consolidate initialization of nodes, zones and memory map arch, mm: consolidate initialization of SPARSE memory model mips: drop paging_init() x86: don't reserve hugetlb memory in setup_arch() mm, arch: consolidate hugetlb CMA reservation mm/hugetlb: drop hugetlb_cma_check() Revert "mm/hugetlb: deal with multiple calls to hugetlb_bootmem_alloc" .../driver-api/cxl/linux/early-boot.rst | 2 +- Documentation/mm/memory-model.rst | 3 -- .../translations/zh_CN/mm/memory-model.rst | 2 - arch/alpha/kernel/setup.c | 1 - arch/alpha/mm/init.c | 16 ++++---- arch/arc/mm/init.c | 37 +++++++++--------- arch/arm/include/asm/pgtable.h | 4 +- arch/arm/mm/init.c | 25 ++---------- arch/arm/mm/mmu.c | 10 +---- arch/arm/mm/nommu.c | 10 +---- arch/arm64/include/asm/hugetlb.h | 2 - arch/arm64/mm/hugetlbpage.c | 10 ++--- arch/arm64/mm/init.c | 39 ++++++++----------- arch/csky/kernel/setup.c | 16 ++++---- arch/hexagon/mm/init.c | 19 +++------ arch/loongarch/include/asm/pgtable.h | 2 - arch/loongarch/kernel/setup.c | 10 ----- arch/loongarch/mm/init.c | 6 +-- arch/m68k/mm/init.c | 8 ++-- arch/m68k/mm/mcfmmu.c | 3 -- arch/m68k/mm/motorola.c | 6 +-- arch/m68k/mm/sun3mmu.c | 9 ----- arch/microblaze/mm/init.c | 22 +++++------ arch/mips/include/asm/pgalloc.h | 2 - arch/mips/include/asm/pgtable.h | 2 +- arch/mips/kernel/setup.c | 15 +------ arch/mips/loongson64/numa.c | 10 ++--- arch/mips/mm/init.c | 8 +--- arch/mips/sgi-ip27/ip27-memory.c | 8 +--- arch/nios2/mm/init.c | 12 +++--- arch/openrisc/mm/init.c | 10 +---- arch/parisc/mm/init.c | 11 +----- arch/powerpc/include/asm/hugetlb.h | 5 --- arch/powerpc/include/asm/setup.h | 4 ++ arch/powerpc/kernel/setup-common.c | 1 - arch/powerpc/mm/hugetlbpage.c | 11 ++---- arch/powerpc/mm/mem.c | 27 +++++-------- arch/powerpc/mm/numa.c | 2 - arch/riscv/mm/hugetlbpage.c | 8 ++++ arch/riscv/mm/init.c | 10 +---- arch/s390/kernel/setup.c | 2 - arch/s390/mm/hugetlbpage.c | 8 ++++ arch/s390/mm/init.c | 13 +++---- arch/sh/mm/init.c | 12 +++--- arch/sparc/mm/init_64.c | 17 +++----- arch/sparc/mm/srmmu.c | 17 ++++---- arch/um/kernel/mem.c | 10 ++--- arch/x86/kernel/setup.c | 5 --- arch/x86/mm/hugetlbpage.c | 8 ++++ arch/x86/mm/init.c | 8 +--- arch/x86/mm/init_32.c | 2 - arch/x86/mm/init_64.c | 4 -- arch/x86/mm/mm_internal.h | 1 - arch/xtensa/mm/init.c | 14 +++---- include/linux/hugetlb.h | 12 ++---- include/linux/mm.h | 5 ++- include/linux/mmzone.h | 2 - init/main.c | 1 + mm/hugetlb.c | 13 ------- mm/hugetlb_cma.c | 33 ++++++++-------- mm/hugetlb_cma.h | 5 --- mm/hugetlb_vmemmap.c | 11 ------ mm/internal.h | 6 +++ mm/mm_init.c | 20 ++++++---- 64 files changed, 223 insertions(+), 414 deletions(-) base-commit: 8f0b4cce4481fb22653697cced8d0d04027cb1e8 -- 2.51.0
null
null
null
[PATCH v3 00/29] arch, mm: consolidate hugetlb early reservation
From: "Mike Rapoport (Microsoft)" <rppt@kernel.org> Move calculations of zone limits to a dedicated arch_zone_limits_init() function. Later MM core will use this function as an architecture specific callback during nodes and zones initialization and thus there won't be a need to call free_area_init() from every architecture. Signed-off-by: Mike Rapoport (Microsoft) <rppt@kernel.org> --- arch/x86/mm/init.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c index 8bf6ad4b9400..e7ef605a18d6 100644 --- a/arch/x86/mm/init.c +++ b/arch/x86/mm/init.c @@ -997,12 +997,8 @@ void __init free_initrd_mem(unsigned long start, unsigned long end) } #endif -void __init zone_sizes_init(void) +void __init arch_zone_limits_init(unsigned long *max_zone_pfns) { - unsigned long max_zone_pfns[MAX_NR_ZONES]; - - memset(max_zone_pfns, 0, sizeof(max_zone_pfns)); - #ifdef CONFIG_ZONE_DMA max_zone_pfns[ZONE_DMA] = min(MAX_DMA_PFN, max_low_pfn); #endif @@ -1013,7 +1009,15 @@ void __init zone_sizes_init(void) #ifdef CONFIG_HIGHMEM max_zone_pfns[ZONE_HIGHMEM] = max_pfn; #endif +} + +void __init zone_sizes_init(void) +{ + unsigned long max_zone_pfns[MAX_NR_ZONES]; + + memset(max_zone_pfns, 0, sizeof(max_zone_pfns)); + arch_zone_limits_init(max_zone_pfns); free_area_init(max_zone_pfns); } -- 2.51.0
{ "author": "Mike Rapoport <rppt@kernel.org>", "date": "Sun, 11 Jan 2026 10:20:55 +0200", "is_openbsd": false, "thread_id": "b9527ed4-7a5c-42e9-8814-b276b3741f63@suse.cz.mbox.gz" }
lkml_critique
lkml
From: "Mike Rapoport (Microsoft)" <rppt@kernel.org> Hi, Order in which early memory reservation for hugetlb happens depends on architecture, on configuration options and on command line parameters. Some architectures rely on the core MM to call hugetlb_bootmem_alloc() while others call it very early to allow pre-allocation of HVO-style vmemmap. When hugetlb_cma is supported by an architecture it is initialized during setup_arch() and then later hugetlb_init code needs to understand did it happen or not. To make everything consistent and unified, both reservation of hugetlb memory from bootmem and creation of CMA areas for hugetlb must be called from core MM initialization and it would have been a simple change. However, HVO-style pre-initialization ordering requirements slightly complicate things and for HVO pre-init to work sparse and memory map should be initialized after hugetlb reservations. This required pulling out the call to free_area_init() out of setup_arch() path and moving it MM initialization and this is what the first 23 patches do. These changes are deliberately split into per-arch patches that change how the zone limits are calculated for each architecture and the patches 22 and 23 just remove the calls to free_area_init() and sprase_init() from arch/*. Patch 24 is a simple cleanup for MIPS. Patches 25 and 26 actually consolidate hugetlb reservations and patches 27 and 28 perform some aftermath cleanups. I tried to trim the distribution list and although it's still quite long if you feel that someone was wrongly excluded please add them back. The changes also available in git: https://git.kernel.org/pub/scm/linux/kernel/git/rppt/linux.git/log/?h=hugetlb-init/v3 v3 changes: * fix empty_zero_page initialization on arm * fix ZONE_DMA limit calculation on powerpc * add Acks v2: https://lore.kernel.org/all/20260102070005.65328-1-rppt@kernel.org * move the hugetlb and memory map initializaion to mm_core_init_early() * add Acks v1: https://lore.kernel.org/all/20251228124001.3624742-1-rppt@kernel.org Klara Modin (1): arm: make initialization of zero page independent of the memory map Mike Rapoport (Microsoft) (28): alpha: introduce arch_zone_limits_init() arc: introduce arch_zone_limits_init() arm: introduce arch_zone_limits_init() arm64: introduce arch_zone_limits_init() csky: introduce arch_zone_limits_init() hexagon: introduce arch_zone_limits_init() loongarch: introduce arch_zone_limits_init() m68k: introduce arch_zone_limits_init() microblaze: introduce arch_zone_limits_init() mips: introduce arch_zone_limits_init() nios2: introduce arch_zone_limits_init() openrisc: introduce arch_zone_limits_init() parisc: introduce arch_zone_limits_init() powerpc: introduce arch_zone_limits_init() riscv: introduce arch_zone_limits_init() s390: introduce arch_zone_limits_init() sh: introduce arch_zone_limits_init() sparc: introduce arch_zone_limits_init() um: introduce arch_zone_limits_init() x86: introduce arch_zone_limits_init() xtensa: introduce arch_zone_limits_init() arch, mm: consolidate initialization of nodes, zones and memory map arch, mm: consolidate initialization of SPARSE memory model mips: drop paging_init() x86: don't reserve hugetlb memory in setup_arch() mm, arch: consolidate hugetlb CMA reservation mm/hugetlb: drop hugetlb_cma_check() Revert "mm/hugetlb: deal with multiple calls to hugetlb_bootmem_alloc" .../driver-api/cxl/linux/early-boot.rst | 2 +- Documentation/mm/memory-model.rst | 3 -- .../translations/zh_CN/mm/memory-model.rst | 2 - arch/alpha/kernel/setup.c | 1 - arch/alpha/mm/init.c | 16 ++++---- arch/arc/mm/init.c | 37 +++++++++--------- arch/arm/include/asm/pgtable.h | 4 +- arch/arm/mm/init.c | 25 ++---------- arch/arm/mm/mmu.c | 10 +---- arch/arm/mm/nommu.c | 10 +---- arch/arm64/include/asm/hugetlb.h | 2 - arch/arm64/mm/hugetlbpage.c | 10 ++--- arch/arm64/mm/init.c | 39 ++++++++----------- arch/csky/kernel/setup.c | 16 ++++---- arch/hexagon/mm/init.c | 19 +++------ arch/loongarch/include/asm/pgtable.h | 2 - arch/loongarch/kernel/setup.c | 10 ----- arch/loongarch/mm/init.c | 6 +-- arch/m68k/mm/init.c | 8 ++-- arch/m68k/mm/mcfmmu.c | 3 -- arch/m68k/mm/motorola.c | 6 +-- arch/m68k/mm/sun3mmu.c | 9 ----- arch/microblaze/mm/init.c | 22 +++++------ arch/mips/include/asm/pgalloc.h | 2 - arch/mips/include/asm/pgtable.h | 2 +- arch/mips/kernel/setup.c | 15 +------ arch/mips/loongson64/numa.c | 10 ++--- arch/mips/mm/init.c | 8 +--- arch/mips/sgi-ip27/ip27-memory.c | 8 +--- arch/nios2/mm/init.c | 12 +++--- arch/openrisc/mm/init.c | 10 +---- arch/parisc/mm/init.c | 11 +----- arch/powerpc/include/asm/hugetlb.h | 5 --- arch/powerpc/include/asm/setup.h | 4 ++ arch/powerpc/kernel/setup-common.c | 1 - arch/powerpc/mm/hugetlbpage.c | 11 ++---- arch/powerpc/mm/mem.c | 27 +++++-------- arch/powerpc/mm/numa.c | 2 - arch/riscv/mm/hugetlbpage.c | 8 ++++ arch/riscv/mm/init.c | 10 +---- arch/s390/kernel/setup.c | 2 - arch/s390/mm/hugetlbpage.c | 8 ++++ arch/s390/mm/init.c | 13 +++---- arch/sh/mm/init.c | 12 +++--- arch/sparc/mm/init_64.c | 17 +++----- arch/sparc/mm/srmmu.c | 17 ++++---- arch/um/kernel/mem.c | 10 ++--- arch/x86/kernel/setup.c | 5 --- arch/x86/mm/hugetlbpage.c | 8 ++++ arch/x86/mm/init.c | 8 +--- arch/x86/mm/init_32.c | 2 - arch/x86/mm/init_64.c | 4 -- arch/x86/mm/mm_internal.h | 1 - arch/xtensa/mm/init.c | 14 +++---- include/linux/hugetlb.h | 12 ++---- include/linux/mm.h | 5 ++- include/linux/mmzone.h | 2 - init/main.c | 1 + mm/hugetlb.c | 13 ------- mm/hugetlb_cma.c | 33 ++++++++-------- mm/hugetlb_cma.h | 5 --- mm/hugetlb_vmemmap.c | 11 ------ mm/internal.h | 6 +++ mm/mm_init.c | 20 ++++++---- 64 files changed, 223 insertions(+), 414 deletions(-) base-commit: 8f0b4cce4481fb22653697cced8d0d04027cb1e8 -- 2.51.0
null
null
null
[PATCH v3 00/29] arch, mm: consolidate hugetlb early reservation
From: "Mike Rapoport (Microsoft)" <rppt@kernel.org> Move calculations of zone limits to a dedicated arch_zone_limits_init() function. Later MM core will use this function as an architecture specific callback during nodes and zones initialization and thus there won't be a need to call free_area_init() from every architecture. Signed-off-by: Mike Rapoport (Microsoft) <rppt@kernel.org> --- arch/xtensa/mm/init.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/arch/xtensa/mm/init.c b/arch/xtensa/mm/init.c index cc52733a0649..60299f359a3c 100644 --- a/arch/xtensa/mm/init.c +++ b/arch/xtensa/mm/init.c @@ -116,15 +116,19 @@ static void __init print_vm_layout(void) (unsigned long)(__bss_stop - __bss_start) >> 10); } -void __init zones_init(void) +void __init arch_zone_limits_init(unsigned long *max_zone_pfns) { - /* All pages are DMA-able, so we put them all in the DMA zone. */ - unsigned long max_zone_pfn[MAX_NR_ZONES] = { - [ZONE_NORMAL] = max_low_pfn, + max_zone_pfns[ZONE_NORMAL] = max_low_pfn; #ifdef CONFIG_HIGHMEM - [ZONE_HIGHMEM] = max_pfn, + max_zone_pfns[ZONE_HIGHMEM] = max_pfn; #endif - }; +} + +void __init zones_init(void) +{ + unsigned long max_zone_pfn[MAX_NR_ZONES] = { 0, }; + + arch_zone_limits_init(max_zone_pfn); free_area_init(max_zone_pfn); print_vm_layout(); } -- 2.51.0
{ "author": "Mike Rapoport <rppt@kernel.org>", "date": "Sun, 11 Jan 2026 10:20:56 +0200", "is_openbsd": false, "thread_id": "b9527ed4-7a5c-42e9-8814-b276b3741f63@suse.cz.mbox.gz" }
lkml_critique
lkml
From: "Mike Rapoport (Microsoft)" <rppt@kernel.org> Hi, Order in which early memory reservation for hugetlb happens depends on architecture, on configuration options and on command line parameters. Some architectures rely on the core MM to call hugetlb_bootmem_alloc() while others call it very early to allow pre-allocation of HVO-style vmemmap. When hugetlb_cma is supported by an architecture it is initialized during setup_arch() and then later hugetlb_init code needs to understand did it happen or not. To make everything consistent and unified, both reservation of hugetlb memory from bootmem and creation of CMA areas for hugetlb must be called from core MM initialization and it would have been a simple change. However, HVO-style pre-initialization ordering requirements slightly complicate things and for HVO pre-init to work sparse and memory map should be initialized after hugetlb reservations. This required pulling out the call to free_area_init() out of setup_arch() path and moving it MM initialization and this is what the first 23 patches do. These changes are deliberately split into per-arch patches that change how the zone limits are calculated for each architecture and the patches 22 and 23 just remove the calls to free_area_init() and sprase_init() from arch/*. Patch 24 is a simple cleanup for MIPS. Patches 25 and 26 actually consolidate hugetlb reservations and patches 27 and 28 perform some aftermath cleanups. I tried to trim the distribution list and although it's still quite long if you feel that someone was wrongly excluded please add them back. The changes also available in git: https://git.kernel.org/pub/scm/linux/kernel/git/rppt/linux.git/log/?h=hugetlb-init/v3 v3 changes: * fix empty_zero_page initialization on arm * fix ZONE_DMA limit calculation on powerpc * add Acks v2: https://lore.kernel.org/all/20260102070005.65328-1-rppt@kernel.org * move the hugetlb and memory map initializaion to mm_core_init_early() * add Acks v1: https://lore.kernel.org/all/20251228124001.3624742-1-rppt@kernel.org Klara Modin (1): arm: make initialization of zero page independent of the memory map Mike Rapoport (Microsoft) (28): alpha: introduce arch_zone_limits_init() arc: introduce arch_zone_limits_init() arm: introduce arch_zone_limits_init() arm64: introduce arch_zone_limits_init() csky: introduce arch_zone_limits_init() hexagon: introduce arch_zone_limits_init() loongarch: introduce arch_zone_limits_init() m68k: introduce arch_zone_limits_init() microblaze: introduce arch_zone_limits_init() mips: introduce arch_zone_limits_init() nios2: introduce arch_zone_limits_init() openrisc: introduce arch_zone_limits_init() parisc: introduce arch_zone_limits_init() powerpc: introduce arch_zone_limits_init() riscv: introduce arch_zone_limits_init() s390: introduce arch_zone_limits_init() sh: introduce arch_zone_limits_init() sparc: introduce arch_zone_limits_init() um: introduce arch_zone_limits_init() x86: introduce arch_zone_limits_init() xtensa: introduce arch_zone_limits_init() arch, mm: consolidate initialization of nodes, zones and memory map arch, mm: consolidate initialization of SPARSE memory model mips: drop paging_init() x86: don't reserve hugetlb memory in setup_arch() mm, arch: consolidate hugetlb CMA reservation mm/hugetlb: drop hugetlb_cma_check() Revert "mm/hugetlb: deal with multiple calls to hugetlb_bootmem_alloc" .../driver-api/cxl/linux/early-boot.rst | 2 +- Documentation/mm/memory-model.rst | 3 -- .../translations/zh_CN/mm/memory-model.rst | 2 - arch/alpha/kernel/setup.c | 1 - arch/alpha/mm/init.c | 16 ++++---- arch/arc/mm/init.c | 37 +++++++++--------- arch/arm/include/asm/pgtable.h | 4 +- arch/arm/mm/init.c | 25 ++---------- arch/arm/mm/mmu.c | 10 +---- arch/arm/mm/nommu.c | 10 +---- arch/arm64/include/asm/hugetlb.h | 2 - arch/arm64/mm/hugetlbpage.c | 10 ++--- arch/arm64/mm/init.c | 39 ++++++++----------- arch/csky/kernel/setup.c | 16 ++++---- arch/hexagon/mm/init.c | 19 +++------ arch/loongarch/include/asm/pgtable.h | 2 - arch/loongarch/kernel/setup.c | 10 ----- arch/loongarch/mm/init.c | 6 +-- arch/m68k/mm/init.c | 8 ++-- arch/m68k/mm/mcfmmu.c | 3 -- arch/m68k/mm/motorola.c | 6 +-- arch/m68k/mm/sun3mmu.c | 9 ----- arch/microblaze/mm/init.c | 22 +++++------ arch/mips/include/asm/pgalloc.h | 2 - arch/mips/include/asm/pgtable.h | 2 +- arch/mips/kernel/setup.c | 15 +------ arch/mips/loongson64/numa.c | 10 ++--- arch/mips/mm/init.c | 8 +--- arch/mips/sgi-ip27/ip27-memory.c | 8 +--- arch/nios2/mm/init.c | 12 +++--- arch/openrisc/mm/init.c | 10 +---- arch/parisc/mm/init.c | 11 +----- arch/powerpc/include/asm/hugetlb.h | 5 --- arch/powerpc/include/asm/setup.h | 4 ++ arch/powerpc/kernel/setup-common.c | 1 - arch/powerpc/mm/hugetlbpage.c | 11 ++---- arch/powerpc/mm/mem.c | 27 +++++-------- arch/powerpc/mm/numa.c | 2 - arch/riscv/mm/hugetlbpage.c | 8 ++++ arch/riscv/mm/init.c | 10 +---- arch/s390/kernel/setup.c | 2 - arch/s390/mm/hugetlbpage.c | 8 ++++ arch/s390/mm/init.c | 13 +++---- arch/sh/mm/init.c | 12 +++--- arch/sparc/mm/init_64.c | 17 +++----- arch/sparc/mm/srmmu.c | 17 ++++---- arch/um/kernel/mem.c | 10 ++--- arch/x86/kernel/setup.c | 5 --- arch/x86/mm/hugetlbpage.c | 8 ++++ arch/x86/mm/init.c | 8 +--- arch/x86/mm/init_32.c | 2 - arch/x86/mm/init_64.c | 4 -- arch/x86/mm/mm_internal.h | 1 - arch/xtensa/mm/init.c | 14 +++---- include/linux/hugetlb.h | 12 ++---- include/linux/mm.h | 5 ++- include/linux/mmzone.h | 2 - init/main.c | 1 + mm/hugetlb.c | 13 ------- mm/hugetlb_cma.c | 33 ++++++++-------- mm/hugetlb_cma.h | 5 --- mm/hugetlb_vmemmap.c | 11 ------ mm/internal.h | 6 +++ mm/mm_init.c | 20 ++++++---- 64 files changed, 223 insertions(+), 414 deletions(-) base-commit: 8f0b4cce4481fb22653697cced8d0d04027cb1e8 -- 2.51.0
null
null
null
[PATCH v3 00/29] arch, mm: consolidate hugetlb early reservation
From: "Mike Rapoport (Microsoft)" <rppt@kernel.org> To initialize node, zone and memory map data structures every architecture calls free_area_init() during setup_arch() and passes it an array of zone limits. Beside code duplication it creates "interesting" ordering cases between allocation and initialization of hugetlb and the memory map. Some architectures allocate hugetlb pages very early in setup_arch() in certain cases, some only create hugetlb CMA areas in setup_arch() and sometimes hugetlb allocations happen mm_core_init(). With arch_zone_limits_init() helper available now on all architectures it is no longer necessary to call free_area_init() from architecture setup code. Rather core MM initialization can call arch_zone_limits_init() in a single place. This allows to unify ordering of hugetlb vs memory map allocation and initialization. Remove the call to free_area_init() from architecture specific code and place it in a new mm_core_init_early() function that is called immediately after setup_arch(). After this refactoring it is possible to consolidate hugetlb allocations and eliminate differences in ordering of hugetlb and memory map initialization among different architectures. As the first step of this consolidation move hugetlb_bootmem_alloc() to mm_core_early_init(). Signed-off-by: Mike Rapoport (Microsoft) <rppt@kernel.org> --- arch/alpha/mm/init.c | 9 +-------- arch/arc/mm/init.c | 5 ----- arch/arm/mm/init.c | 16 ---------------- arch/arm64/mm/init.c | 4 ---- arch/csky/kernel/setup.c | 4 ---- arch/hexagon/mm/init.c | 12 ------------ arch/loongarch/include/asm/pgtable.h | 2 -- arch/loongarch/kernel/setup.c | 2 -- arch/loongarch/mm/init.c | 8 -------- arch/m68k/mm/init.c | 3 --- arch/m68k/mm/mcfmmu.c | 3 --- arch/m68k/mm/motorola.c | 6 +----- arch/m68k/mm/sun3mmu.c | 9 --------- arch/microblaze/mm/init.c | 7 ------- arch/mips/loongson64/numa.c | 4 ---- arch/mips/mm/init.c | 5 ----- arch/mips/sgi-ip27/ip27-memory.c | 4 ---- arch/nios2/mm/init.c | 6 ------ arch/openrisc/mm/init.c | 10 ---------- arch/parisc/mm/init.c | 9 --------- arch/powerpc/mm/mem.c | 4 ---- arch/riscv/mm/init.c | 9 --------- arch/s390/mm/init.c | 5 ----- arch/sh/mm/init.c | 5 ----- arch/sparc/mm/init_64.c | 11 ----------- arch/sparc/mm/srmmu.c | 7 ------- arch/um/kernel/mem.c | 5 ----- arch/x86/mm/init.c | 10 ---------- arch/x86/mm/init_32.c | 1 - arch/x86/mm/init_64.c | 2 -- arch/x86/mm/mm_internal.h | 1 - arch/xtensa/mm/init.c | 4 ---- include/linux/mm.h | 4 ++-- init/main.c | 1 + mm/mm_init.c | 18 ++++++++++-------- 35 files changed, 15 insertions(+), 200 deletions(-) diff --git a/arch/alpha/mm/init.c b/arch/alpha/mm/init.c index cd0cb1abde5f..9531cbc761c0 100644 --- a/arch/alpha/mm/init.c +++ b/arch/alpha/mm/init.c @@ -220,17 +220,10 @@ void __init arch_zone_limits_init(unsigned long *max_zone_pfn) } /* - * paging_init() sets up the memory map. + * paging_init() initializes the kernel's ZERO_PGE. */ void __init paging_init(void) { - unsigned long max_zone_pfn[MAX_NR_ZONES] = {0, }; - - /* Initialize mem_map[]. */ - arch_zone_limits_init(max_zone_pfn); - free_area_init(max_zone_pfn); - - /* Initialize the kernel's ZERO_PGE. */ memset(absolute_pointer(ZERO_PGE), 0, PAGE_SIZE); } diff --git a/arch/arc/mm/init.c b/arch/arc/mm/init.c index ff7974d38011..a5e92f46e5d1 100644 --- a/arch/arc/mm/init.c +++ b/arch/arc/mm/init.c @@ -102,8 +102,6 @@ void __init arch_zone_limits_init(unsigned long *max_zone_pfn) */ void __init setup_arch_memory(void) { - unsigned long max_zone_pfn[MAX_NR_ZONES] = { 0 }; - setup_initial_init_mm(_text, _etext, _edata, _end); /* first page of system - kernel .vector starts here */ @@ -158,9 +156,6 @@ void __init setup_arch_memory(void) arch_pfn_offset = min(min_low_pfn, min_high_pfn); kmap_init(); #endif /* CONFIG_HIGHMEM */ - - arch_zone_limits_init(max_zone_pfn); - free_area_init(max_zone_pfn); } void __init arch_mm_preinit(void) diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c index bdcc3639681f..a8f7b4084715 100644 --- a/arch/arm/mm/init.c +++ b/arch/arm/mm/init.c @@ -118,15 +118,6 @@ void __init arch_zone_limits_init(unsigned long *max_zone_pfn) #endif } -static void __init zone_sizes_init(unsigned long min, unsigned long max_low, - unsigned long max_high) -{ - unsigned long max_zone_pfn[MAX_NR_ZONES] = { 0 }; - - arch_zone_limits_init(max_zone_pfn); - free_area_init(max_zone_pfn); -} - #ifdef CONFIG_HAVE_ARCH_PFN_VALID int pfn_valid(unsigned long pfn) { @@ -222,13 +213,6 @@ void __init bootmem_init(void) * done after the fixed reservations */ sparse_init(); - - /* - * Now free the memory - free_area_init needs - * the sparse mem_map arrays initialized by sparse_init() - * for memmap_init_zone(), otherwise all PFNs are invalid. - */ - zone_sizes_init(min_low_pfn, max_low_pfn, max_pfn); } /* diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c index 06815d34cc11..3641e88ea871 100644 --- a/arch/arm64/mm/init.c +++ b/arch/arm64/mm/init.c @@ -134,7 +134,6 @@ void __init arch_zone_limits_init(unsigned long *max_zone_pfns) static void __init dma_limits_init(void) { - unsigned long max_zone_pfns[MAX_NR_ZONES] = {0}; phys_addr_t __maybe_unused acpi_zone_dma_limit; phys_addr_t __maybe_unused dt_zone_dma_limit; phys_addr_t __maybe_unused dma32_phys_limit = @@ -160,9 +159,6 @@ static void __init dma_limits_init(void) #endif if (!arm64_dma_phys_limit) arm64_dma_phys_limit = PHYS_MASK + 1; - - arch_zone_limits_init(max_zone_pfns); - free_area_init(max_zone_pfns); } int pfn_is_map_memory(unsigned long pfn) diff --git a/arch/csky/kernel/setup.c b/arch/csky/kernel/setup.c index 8968815d93e6..4bf3c01ead3a 100644 --- a/arch/csky/kernel/setup.c +++ b/arch/csky/kernel/setup.c @@ -63,7 +63,6 @@ static void __init csky_memblock_init(void) { unsigned long lowmem_size = PFN_DOWN(LOWMEM_LIMIT - PHYS_OFFSET_OFFSET); unsigned long sseg_size = PFN_DOWN(SSEG_SIZE - PHYS_OFFSET_OFFSET); - unsigned long max_zone_pfn[MAX_NR_ZONES] = { 0 }; signed long size; memblock_reserve(__pa(_start), _end - _start); @@ -101,9 +100,6 @@ static void __init csky_memblock_init(void) memblock_set_current_limit(PFN_PHYS(max_low_pfn)); dma_contiguous_reserve(0); - - arch_zone_limits_init(max_zone_pfn); - free_area_init(max_zone_pfn); } void __init setup_arch(char **cmdline_p) diff --git a/arch/hexagon/mm/init.c b/arch/hexagon/mm/init.c index e2c9487d8d34..07086dbd33fd 100644 --- a/arch/hexagon/mm/init.c +++ b/arch/hexagon/mm/init.c @@ -66,20 +66,8 @@ void __init arch_zone_limits_init(unsigned long *max_zone_pfns) max_zone_pfns[ZONE_NORMAL] = max_low_pfn; } -/* - * In order to set up page allocator "nodes", - * somebody has to call free_area_init() for UMA. - * - * In this mode, we only have one pg_data_t - * structure: contig_mem_data. - */ static void __init paging_init(void) { - unsigned long max_zone_pfn[MAX_NR_ZONES] = {0, }; - - arch_zone_limits_init(max_zone_pfn); - free_area_init(max_zone_pfn); /* sets up the zonelists and mem_map */ - /* * Set the init_mm descriptors "context" value to point to the * initial kernel segment table's physical address. diff --git a/arch/loongarch/include/asm/pgtable.h b/arch/loongarch/include/asm/pgtable.h index f41a648a3d9e..c33b3bcb733e 100644 --- a/arch/loongarch/include/asm/pgtable.h +++ b/arch/loongarch/include/asm/pgtable.h @@ -353,8 +353,6 @@ static inline pte_t pte_swp_clear_exclusive(pte_t pte) return pte; } -extern void paging_init(void); - #define pte_none(pte) (!(pte_val(pte) & ~_PAGE_GLOBAL)) #define pte_present(pte) (pte_val(pte) & (_PAGE_PRESENT | _PAGE_PROTNONE)) #define pte_no_exec(pte) (pte_val(pte) & _PAGE_NO_EXEC) diff --git a/arch/loongarch/kernel/setup.c b/arch/loongarch/kernel/setup.c index 20cb6f306456..708ac025db71 100644 --- a/arch/loongarch/kernel/setup.c +++ b/arch/loongarch/kernel/setup.c @@ -621,8 +621,6 @@ void __init setup_arch(char **cmdline_p) prefill_possible_map(); #endif - paging_init(); - #ifdef CONFIG_KASAN kasan_init(); #endif diff --git a/arch/loongarch/mm/init.c b/arch/loongarch/mm/init.c index 17235f87eafb..c331bf69d2ec 100644 --- a/arch/loongarch/mm/init.c +++ b/arch/loongarch/mm/init.c @@ -68,14 +68,6 @@ void __init arch_zone_limits_init(unsigned long *max_zone_pfns) max_zone_pfns[ZONE_NORMAL] = max_low_pfn; } -void __init paging_init(void) -{ - unsigned long max_zone_pfns[MAX_NR_ZONES]; - - arch_zone_limits_init(max_zone_pfns); - free_area_init(max_zone_pfns); -} - void __ref free_initmem(void) { free_initmem_default(POISON_FREE_INITMEM); diff --git a/arch/m68k/mm/init.c b/arch/m68k/mm/init.c index 6b1d9d2434b5..53b71f786c27 100644 --- a/arch/m68k/mm/init.c +++ b/arch/m68k/mm/init.c @@ -69,13 +69,10 @@ void __init paging_init(void) * page_alloc get different views of the world. */ unsigned long end_mem = memory_end & PAGE_MASK; - unsigned long max_zone_pfn[MAX_NR_ZONES] = { 0, }; high_memory = (void *) end_mem; empty_zero_page = memblock_alloc_or_panic(PAGE_SIZE, PAGE_SIZE); - arch_zone_limits_init(max_zone_pfn); - free_area_init(max_zone_pfn); } #endif /* CONFIG_MMU */ diff --git a/arch/m68k/mm/mcfmmu.c b/arch/m68k/mm/mcfmmu.c index 24a6f7bbd1ce..3418fd864237 100644 --- a/arch/m68k/mm/mcfmmu.c +++ b/arch/m68k/mm/mcfmmu.c @@ -39,7 +39,6 @@ void __init paging_init(void) pte_t *pg_table; unsigned long address, size; unsigned long next_pgtable; - unsigned long max_zone_pfn[MAX_NR_ZONES] = { 0 }; int i; empty_zero_page = memblock_alloc_or_panic(PAGE_SIZE, PAGE_SIZE); @@ -73,8 +72,6 @@ void __init paging_init(void) } current->mm = NULL; - arch_zone_limits_init(max_zone_pfn); - free_area_init(max_zone_pfn); } int cf_tlb_miss(struct pt_regs *regs, int write, int dtlb, int extension_word) diff --git a/arch/m68k/mm/motorola.c b/arch/m68k/mm/motorola.c index d6ccd23caf61..127a3fa69f4c 100644 --- a/arch/m68k/mm/motorola.c +++ b/arch/m68k/mm/motorola.c @@ -429,7 +429,6 @@ DECLARE_VM_GET_PAGE_PROT */ void __init paging_init(void) { - unsigned long max_zone_pfn[MAX_NR_ZONES] = { 0, }; unsigned long min_addr, max_addr; unsigned long addr; int i; @@ -511,12 +510,9 @@ void __init paging_init(void) set_fc(USER_DATA); #ifdef DEBUG - printk ("before free_area_init\n"); + printk ("before node_set_state\n"); #endif for (i = 0; i < m68k_num_memory; i++) if (node_present_pages(i)) node_set_state(i, N_NORMAL_MEMORY); - - arch_zone_limits_init(max_zone_pfn); - free_area_init(max_zone_pfn); } diff --git a/arch/m68k/mm/sun3mmu.c b/arch/m68k/mm/sun3mmu.c index fdd69cc4240c..c801677f7df8 100644 --- a/arch/m68k/mm/sun3mmu.c +++ b/arch/m68k/mm/sun3mmu.c @@ -41,7 +41,6 @@ void __init paging_init(void) unsigned long address; unsigned long next_pgtable; unsigned long bootmem_end; - unsigned long max_zone_pfn[MAX_NR_ZONES] = { 0, }; unsigned long size; empty_zero_page = memblock_alloc_or_panic(PAGE_SIZE, PAGE_SIZE); @@ -80,14 +79,6 @@ void __init paging_init(void) mmu_emu_init(bootmem_end); current->mm = NULL; - - /* memory sizing is a hack stolen from motorola.c.. hope it works for us */ - arch_zone_limits_init(max_zone_pfn); - - /* I really wish I knew why the following change made things better... -- Sam */ - free_area_init(max_zone_pfn); - - } static const pgprot_t protection_map[16] = { diff --git a/arch/microblaze/mm/init.c b/arch/microblaze/mm/init.c index 54da60b81094..848cdee1380c 100644 --- a/arch/microblaze/mm/init.c +++ b/arch/microblaze/mm/init.c @@ -69,22 +69,15 @@ void __init arch_zone_limits_init(unsigned long *max_zone_pfns) */ static void __init paging_init(void) { - unsigned long zones_size[MAX_NR_ZONES]; int idx; /* Setup fixmaps */ for (idx = 0; idx < __end_of_fixed_addresses; idx++) clear_fixmap(idx); - /* Clean every zones */ - memset(zones_size, 0, sizeof(zones_size)); - #ifdef CONFIG_HIGHMEM highmem_init(); #endif - arch_zone_limits_init(zones_size); - /* We don't have holes in memory map */ - free_area_init(zones_size); } void __init setup_memory(void) diff --git a/arch/mips/loongson64/numa.c b/arch/mips/loongson64/numa.c index f72a58f87878..2cd95020df08 100644 --- a/arch/mips/loongson64/numa.c +++ b/arch/mips/loongson64/numa.c @@ -162,11 +162,7 @@ void __init arch_zone_limits_init(unsigned long *max_zone_pfns) void __init paging_init(void) { - unsigned long zones_size[MAX_NR_ZONES] = {0, }; - pagetable_init(); - arch_zone_limits_init(zones_size); - free_area_init(zones_size); } /* All PCI device belongs to logical Node-0 */ diff --git a/arch/mips/mm/init.c b/arch/mips/mm/init.c index ab08249cfede..c479c42141c3 100644 --- a/arch/mips/mm/init.c +++ b/arch/mips/mm/init.c @@ -417,12 +417,7 @@ void __init arch_zone_limits_init(unsigned long *max_zone_pfns) void __init paging_init(void) { - unsigned long max_zone_pfns[MAX_NR_ZONES]; - pagetable_init(); - - arch_zone_limits_init(max_zone_pfns); - free_area_init(max_zone_pfns); } #ifdef CONFIG_64BIT diff --git a/arch/mips/sgi-ip27/ip27-memory.c b/arch/mips/sgi-ip27/ip27-memory.c index babeb0e07687..082651facf4f 100644 --- a/arch/mips/sgi-ip27/ip27-memory.c +++ b/arch/mips/sgi-ip27/ip27-memory.c @@ -413,9 +413,5 @@ void __init arch_zone_limits_init(unsigned long *max_zone_pfns) void __init paging_init(void) { - unsigned long zones_size[MAX_NR_ZONES] = {0, }; - pagetable_init(); - arch_zone_limits_init(zones_size); - free_area_init(zones_size); } diff --git a/arch/nios2/mm/init.c b/arch/nios2/mm/init.c index 2cb666a65d9e..6b22f1995c16 100644 --- a/arch/nios2/mm/init.c +++ b/arch/nios2/mm/init.c @@ -51,15 +51,9 @@ void __init arch_zone_limits_init(unsigned long *max_zone_pfns) */ void __init paging_init(void) { - unsigned long max_zone_pfn[MAX_NR_ZONES] = { 0 }; - pagetable_init(); pgd_current = swapper_pg_dir; - arch_zone_limits_init(max_zone_pfn); - /* pass the memory from the bootmem allocator to the main allocator */ - free_area_init(max_zone_pfn); - flush_dcache_range((unsigned long)empty_zero_page, (unsigned long)empty_zero_page + PAGE_SIZE); } diff --git a/arch/openrisc/mm/init.c b/arch/openrisc/mm/init.c index 67de93e7a685..78fb0734cdbc 100644 --- a/arch/openrisc/mm/init.c +++ b/arch/openrisc/mm/init.c @@ -47,14 +47,6 @@ void __init arch_zone_limits_init(unsigned long *max_zone_pfns) max_zone_pfns[ZONE_NORMAL] = max_low_pfn; } -static void __init zone_sizes_init(void) -{ - unsigned long max_zone_pfn[MAX_NR_ZONES] = { 0 }; - - arch_zone_limits_init(max_zone_pfn); - free_area_init(max_zone_pfn); -} - extern const char _s_kernel_ro[], _e_kernel_ro[]; /* @@ -145,8 +137,6 @@ void __init paging_init(void) map_ram(); - zone_sizes_init(); - /* self modifying code ;) */ /* Since the old TLB miss handler has been running up until now, * the kernel pages are still all RW, so we can still modify the diff --git a/arch/parisc/mm/init.c b/arch/parisc/mm/init.c index dc5bd3efe738..ce6f09ab7a90 100644 --- a/arch/parisc/mm/init.c +++ b/arch/parisc/mm/init.c @@ -698,14 +698,6 @@ void __init arch_zone_limits_init(unsigned long *max_zone_pfns) max_zone_pfns[ZONE_NORMAL] = PFN_DOWN(memblock_end_of_DRAM()); } -static void __init parisc_bootmem_free(void) -{ - unsigned long max_zone_pfn[MAX_NR_ZONES] = { 0, }; - - arch_zone_limits_init(max_zone_pfn); - free_area_init(max_zone_pfn); -} - void __init paging_init(void) { setup_bootmem(); @@ -716,7 +708,6 @@ void __init paging_init(void) flush_tlb_all_local(NULL); sparse_init(); - parisc_bootmem_free(); } static void alloc_btlb(unsigned long start, unsigned long end, int *slot, diff --git a/arch/powerpc/mm/mem.c b/arch/powerpc/mm/mem.c index 03c05ec56041..b716c9cd141c 100644 --- a/arch/powerpc/mm/mem.c +++ b/arch/powerpc/mm/mem.c @@ -237,7 +237,6 @@ void __init arch_zone_limits_init(unsigned long *max_zone_pfns) */ void __init paging_init(void) { - unsigned long max_zone_pfns[MAX_NR_ZONES] = { 0 }; unsigned long long total_ram = memblock_phys_mem_size(); phys_addr_t top_of_ram = memblock_end_of_DRAM(); int zone_dma_bits; @@ -269,9 +268,6 @@ void __init paging_init(void) zone_dma_limit = DMA_BIT_MASK(zone_dma_bits); - arch_zone_limits_init(max_zone_pfns); - free_area_init(max_zone_pfns); - mark_nonram_nosave(); } diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c index 97e8661fbcff..79b4792578c4 100644 --- a/arch/riscv/mm/init.c +++ b/arch/riscv/mm/init.c @@ -87,14 +87,6 @@ void __init arch_zone_limits_init(unsigned long *max_zone_pfns) max_zone_pfns[ZONE_NORMAL] = max_low_pfn; } -static void __init zone_sizes_init(void) -{ - unsigned long max_zone_pfns[MAX_NR_ZONES] = { 0, }; - - arch_zone_limits_init(max_zone_pfns); - free_area_init(max_zone_pfns); -} - #if defined(CONFIG_MMU) && defined(CONFIG_DEBUG_VM) #define LOG2_SZ_1K ilog2(SZ_1K) @@ -1443,7 +1435,6 @@ void __init misc_mem_init(void) /* The entire VMEMMAP region has been populated. Flush TLB for this region */ local_flush_tlb_kernel_range(VMEMMAP_START, VMEMMAP_END); #endif - zone_sizes_init(); arch_reserve_crashkernel(); memblock_dump_all(); } diff --git a/arch/s390/mm/init.c b/arch/s390/mm/init.c index 1c11ad84dddb..9ec608b5cbb1 100644 --- a/arch/s390/mm/init.c +++ b/arch/s390/mm/init.c @@ -97,14 +97,9 @@ void __init arch_zone_limits_init(unsigned long *max_zone_pfns) */ void __init paging_init(void) { - unsigned long max_zone_pfns[MAX_NR_ZONES]; - vmem_map_init(); sparse_init(); zone_dma_limit = DMA_BIT_MASK(31); - memset(max_zone_pfns, 0, sizeof(max_zone_pfns)); - arch_zone_limits_init(max_zone_pfns); - free_area_init(max_zone_pfns); } void mark_rodata_ro(void) diff --git a/arch/sh/mm/init.c b/arch/sh/mm/init.c index 5e7e63642611..3edee854b755 100644 --- a/arch/sh/mm/init.c +++ b/arch/sh/mm/init.c @@ -271,7 +271,6 @@ void __init arch_zone_limits_init(unsigned long *max_zone_pfns) void __init paging_init(void) { - unsigned long max_zone_pfns[MAX_NR_ZONES]; unsigned long vaddr, end; sh_mv.mv_mem_init(); @@ -325,10 +324,6 @@ void __init paging_init(void) page_table_range_init(vaddr, end, swapper_pg_dir); kmap_coherent_init(); - - memset(max_zone_pfns, 0, sizeof(max_zone_pfns)); - arch_zone_limits_init(max_zone_pfns); - free_area_init(max_zone_pfns); } unsigned int mem_init_done = 0; diff --git a/arch/sparc/mm/init_64.c b/arch/sparc/mm/init_64.c index fbaad449dfc9..931f872ce84a 100644 --- a/arch/sparc/mm/init_64.c +++ b/arch/sparc/mm/init_64.c @@ -2459,17 +2459,6 @@ void __init paging_init(void) kernel_physical_mapping_init(); - { - unsigned long max_zone_pfns[MAX_NR_ZONES]; - - memset(max_zone_pfns, 0, sizeof(max_zone_pfns)); - - max_zone_pfns[ZONE_NORMAL] = end_pfn; - - arch_zone_limits_init(max_zone_pfns); - free_area_init(max_zone_pfns); - } - printk("Booting Linux...\n"); } diff --git a/arch/sparc/mm/srmmu.c b/arch/sparc/mm/srmmu.c index 81e90151db90..1b24c5e8d73d 100644 --- a/arch/sparc/mm/srmmu.c +++ b/arch/sparc/mm/srmmu.c @@ -970,13 +970,6 @@ void __init srmmu_paging_init(void) flush_tlb_all(); sparc_context_init(num_contexts); - - { - unsigned long max_zone_pfn[MAX_NR_ZONES] = { 0 }; - - arch_zone_limits_init(max_zone_pfn); - free_area_init(max_zone_pfn); - } } void mmu_info(struct seq_file *m) diff --git a/arch/um/kernel/mem.c b/arch/um/kernel/mem.c index 2ac4e9debedd..89c8c8b94a79 100644 --- a/arch/um/kernel/mem.c +++ b/arch/um/kernel/mem.c @@ -91,16 +91,11 @@ void __init arch_zone_limits_init(unsigned long *max_zone_pfns) void __init paging_init(void) { - unsigned long max_zone_pfn[MAX_NR_ZONES] = { 0 }; - empty_zero_page = (unsigned long *) memblock_alloc_low(PAGE_SIZE, PAGE_SIZE); if (!empty_zero_page) panic("%s: Failed to allocate %lu bytes align=%lx\n", __func__, PAGE_SIZE, PAGE_SIZE); - - arch_zone_limits_init(max_zone_pfn); - free_area_init(max_zone_pfn); } /* diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c index e7ef605a18d6..e52a262d3207 100644 --- a/arch/x86/mm/init.c +++ b/arch/x86/mm/init.c @@ -1011,16 +1011,6 @@ void __init arch_zone_limits_init(unsigned long *max_zone_pfns) #endif } -void __init zone_sizes_init(void) -{ - unsigned long max_zone_pfns[MAX_NR_ZONES]; - - memset(max_zone_pfns, 0, sizeof(max_zone_pfns)); - - arch_zone_limits_init(max_zone_pfns); - free_area_init(max_zone_pfns); -} - __visible DEFINE_PER_CPU_ALIGNED(struct tlb_state, cpu_tlbstate) = { .loaded_mm = &init_mm, .next_asid = 1, diff --git a/arch/x86/mm/init_32.c b/arch/x86/mm/init_32.c index 8a34fff6ab2b..b55172118c91 100644 --- a/arch/x86/mm/init_32.c +++ b/arch/x86/mm/init_32.c @@ -655,7 +655,6 @@ void __init paging_init(void) */ olpc_dt_build_devicetree(); sparse_init(); - zone_sizes_init(); } /* diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c index 9983017ecbe0..4daa40071c9f 100644 --- a/arch/x86/mm/init_64.c +++ b/arch/x86/mm/init_64.c @@ -843,8 +843,6 @@ void __init paging_init(void) */ node_clear_state(0, N_MEMORY); node_clear_state(0, N_NORMAL_MEMORY); - - zone_sizes_init(); } #define PAGE_UNUSED 0xFD diff --git a/arch/x86/mm/mm_internal.h b/arch/x86/mm/mm_internal.h index 097aadc250f7..7c4a41235323 100644 --- a/arch/x86/mm/mm_internal.h +++ b/arch/x86/mm/mm_internal.h @@ -17,7 +17,6 @@ unsigned long kernel_physical_mapping_init(unsigned long start, unsigned long kernel_physical_mapping_change(unsigned long start, unsigned long end, unsigned long page_size_mask); -void zone_sizes_init(void); extern int after_bootmem; diff --git a/arch/xtensa/mm/init.c b/arch/xtensa/mm/init.c index 60299f359a3c..fe83a68335da 100644 --- a/arch/xtensa/mm/init.c +++ b/arch/xtensa/mm/init.c @@ -126,10 +126,6 @@ void __init arch_zone_limits_init(unsigned long *max_zone_pfns) void __init zones_init(void) { - unsigned long max_zone_pfn[MAX_NR_ZONES] = { 0, }; - - arch_zone_limits_init(max_zone_pfn); - free_area_init(max_zone_pfn); print_vm_layout(); } diff --git a/include/linux/mm.h b/include/linux/mm.h index 628c0e0ac313..64d6f9c15ef1 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -45,6 +45,7 @@ struct pt_regs; struct folio_batch; void arch_mm_preinit(void); +void mm_core_init_early(void); void mm_core_init(void); void init_mm_internals(void); @@ -3536,7 +3537,7 @@ static inline unsigned long get_num_physpages(void) } /* - * Using memblock node mappings, an architecture may initialise its + * FIXME: Using memblock node mappings, an architecture may initialise its * zones, allocate the backing mem_map and account for memory holes in an * architecture independent manner. * @@ -3551,7 +3552,6 @@ static inline unsigned long get_num_physpages(void) * memblock_add_node(base, size, nid, MEMBLOCK_NONE) * free_area_init(max_zone_pfns); */ -void free_area_init(unsigned long *max_zone_pfn); void arch_zone_limits_init(unsigned long *max_zone_pfn); unsigned long node_map_pfn_alignment(void); extern unsigned long absent_pages_in_range(unsigned long start_pfn, diff --git a/init/main.c b/init/main.c index b84818ad9685..445b5643ecec 100644 --- a/init/main.c +++ b/init/main.c @@ -1025,6 +1025,7 @@ void start_kernel(void) page_address_init(); pr_notice("%s", linux_banner); setup_arch(&command_line); + mm_core_init_early(); /* Static keys and static calls are needed by LSMs */ jump_label_init(); static_call_init(); diff --git a/mm/mm_init.c b/mm/mm_init.c index fc2a6f1e518f..ffc4a0f1fee9 100644 --- a/mm/mm_init.c +++ b/mm/mm_init.c @@ -1810,7 +1810,6 @@ static void __init set_high_memory(void) /** * free_area_init - Initialise all pg_data_t and zone data - * @max_zone_pfn: an array of max PFNs for each zone * * This will call free_area_init_node() for each active node in the system. * Using the page ranges provided by memblock_set_node(), the size of each @@ -1821,17 +1820,14 @@ static void __init set_high_memory(void) * starts where the previous one ended. For example, ZONE_DMA32 starts * at arch_max_dma_pfn. */ -void __init free_area_init(unsigned long *max_zone_pfn) +static void __init free_area_init(void) { + unsigned long max_zone_pfn[MAX_NR_ZONES] = { 0 }; unsigned long start_pfn, end_pfn; int i, nid, zone; bool descending; - /* Record where the zone boundaries are */ - memset(arch_zone_lowest_possible_pfn, 0, - sizeof(arch_zone_lowest_possible_pfn)); - memset(arch_zone_highest_possible_pfn, 0, - sizeof(arch_zone_highest_possible_pfn)); + arch_zone_limits_init(max_zone_pfn); start_pfn = PHYS_PFN(memblock_start_of_DRAM()); descending = arch_has_descending_max_zone_pfns(); @@ -2681,13 +2677,19 @@ void __init __weak mem_init(void) { } +void __init mm_core_init_early(void) +{ + hugetlb_bootmem_alloc(); + + free_area_init(); +} + /* * Set up kernel memory allocators */ void __init mm_core_init(void) { arch_mm_preinit(); - hugetlb_bootmem_alloc(); /* Initializations relying on SMP setup */ BUILD_BUG_ON(MAX_ZONELISTS > 2); -- 2.51.0
{ "author": "Mike Rapoport <rppt@kernel.org>", "date": "Sun, 11 Jan 2026 10:20:57 +0200", "is_openbsd": false, "thread_id": "b9527ed4-7a5c-42e9-8814-b276b3741f63@suse.cz.mbox.gz" }
lkml_critique
lkml
From: "Mike Rapoport (Microsoft)" <rppt@kernel.org> Hi, Order in which early memory reservation for hugetlb happens depends on architecture, on configuration options and on command line parameters. Some architectures rely on the core MM to call hugetlb_bootmem_alloc() while others call it very early to allow pre-allocation of HVO-style vmemmap. When hugetlb_cma is supported by an architecture it is initialized during setup_arch() and then later hugetlb_init code needs to understand did it happen or not. To make everything consistent and unified, both reservation of hugetlb memory from bootmem and creation of CMA areas for hugetlb must be called from core MM initialization and it would have been a simple change. However, HVO-style pre-initialization ordering requirements slightly complicate things and for HVO pre-init to work sparse and memory map should be initialized after hugetlb reservations. This required pulling out the call to free_area_init() out of setup_arch() path and moving it MM initialization and this is what the first 23 patches do. These changes are deliberately split into per-arch patches that change how the zone limits are calculated for each architecture and the patches 22 and 23 just remove the calls to free_area_init() and sprase_init() from arch/*. Patch 24 is a simple cleanup for MIPS. Patches 25 and 26 actually consolidate hugetlb reservations and patches 27 and 28 perform some aftermath cleanups. I tried to trim the distribution list and although it's still quite long if you feel that someone was wrongly excluded please add them back. The changes also available in git: https://git.kernel.org/pub/scm/linux/kernel/git/rppt/linux.git/log/?h=hugetlb-init/v3 v3 changes: * fix empty_zero_page initialization on arm * fix ZONE_DMA limit calculation on powerpc * add Acks v2: https://lore.kernel.org/all/20260102070005.65328-1-rppt@kernel.org * move the hugetlb and memory map initializaion to mm_core_init_early() * add Acks v1: https://lore.kernel.org/all/20251228124001.3624742-1-rppt@kernel.org Klara Modin (1): arm: make initialization of zero page independent of the memory map Mike Rapoport (Microsoft) (28): alpha: introduce arch_zone_limits_init() arc: introduce arch_zone_limits_init() arm: introduce arch_zone_limits_init() arm64: introduce arch_zone_limits_init() csky: introduce arch_zone_limits_init() hexagon: introduce arch_zone_limits_init() loongarch: introduce arch_zone_limits_init() m68k: introduce arch_zone_limits_init() microblaze: introduce arch_zone_limits_init() mips: introduce arch_zone_limits_init() nios2: introduce arch_zone_limits_init() openrisc: introduce arch_zone_limits_init() parisc: introduce arch_zone_limits_init() powerpc: introduce arch_zone_limits_init() riscv: introduce arch_zone_limits_init() s390: introduce arch_zone_limits_init() sh: introduce arch_zone_limits_init() sparc: introduce arch_zone_limits_init() um: introduce arch_zone_limits_init() x86: introduce arch_zone_limits_init() xtensa: introduce arch_zone_limits_init() arch, mm: consolidate initialization of nodes, zones and memory map arch, mm: consolidate initialization of SPARSE memory model mips: drop paging_init() x86: don't reserve hugetlb memory in setup_arch() mm, arch: consolidate hugetlb CMA reservation mm/hugetlb: drop hugetlb_cma_check() Revert "mm/hugetlb: deal with multiple calls to hugetlb_bootmem_alloc" .../driver-api/cxl/linux/early-boot.rst | 2 +- Documentation/mm/memory-model.rst | 3 -- .../translations/zh_CN/mm/memory-model.rst | 2 - arch/alpha/kernel/setup.c | 1 - arch/alpha/mm/init.c | 16 ++++---- arch/arc/mm/init.c | 37 +++++++++--------- arch/arm/include/asm/pgtable.h | 4 +- arch/arm/mm/init.c | 25 ++---------- arch/arm/mm/mmu.c | 10 +---- arch/arm/mm/nommu.c | 10 +---- arch/arm64/include/asm/hugetlb.h | 2 - arch/arm64/mm/hugetlbpage.c | 10 ++--- arch/arm64/mm/init.c | 39 ++++++++----------- arch/csky/kernel/setup.c | 16 ++++---- arch/hexagon/mm/init.c | 19 +++------ arch/loongarch/include/asm/pgtable.h | 2 - arch/loongarch/kernel/setup.c | 10 ----- arch/loongarch/mm/init.c | 6 +-- arch/m68k/mm/init.c | 8 ++-- arch/m68k/mm/mcfmmu.c | 3 -- arch/m68k/mm/motorola.c | 6 +-- arch/m68k/mm/sun3mmu.c | 9 ----- arch/microblaze/mm/init.c | 22 +++++------ arch/mips/include/asm/pgalloc.h | 2 - arch/mips/include/asm/pgtable.h | 2 +- arch/mips/kernel/setup.c | 15 +------ arch/mips/loongson64/numa.c | 10 ++--- arch/mips/mm/init.c | 8 +--- arch/mips/sgi-ip27/ip27-memory.c | 8 +--- arch/nios2/mm/init.c | 12 +++--- arch/openrisc/mm/init.c | 10 +---- arch/parisc/mm/init.c | 11 +----- arch/powerpc/include/asm/hugetlb.h | 5 --- arch/powerpc/include/asm/setup.h | 4 ++ arch/powerpc/kernel/setup-common.c | 1 - arch/powerpc/mm/hugetlbpage.c | 11 ++---- arch/powerpc/mm/mem.c | 27 +++++-------- arch/powerpc/mm/numa.c | 2 - arch/riscv/mm/hugetlbpage.c | 8 ++++ arch/riscv/mm/init.c | 10 +---- arch/s390/kernel/setup.c | 2 - arch/s390/mm/hugetlbpage.c | 8 ++++ arch/s390/mm/init.c | 13 +++---- arch/sh/mm/init.c | 12 +++--- arch/sparc/mm/init_64.c | 17 +++----- arch/sparc/mm/srmmu.c | 17 ++++---- arch/um/kernel/mem.c | 10 ++--- arch/x86/kernel/setup.c | 5 --- arch/x86/mm/hugetlbpage.c | 8 ++++ arch/x86/mm/init.c | 8 +--- arch/x86/mm/init_32.c | 2 - arch/x86/mm/init_64.c | 4 -- arch/x86/mm/mm_internal.h | 1 - arch/xtensa/mm/init.c | 14 +++---- include/linux/hugetlb.h | 12 ++---- include/linux/mm.h | 5 ++- include/linux/mmzone.h | 2 - init/main.c | 1 + mm/hugetlb.c | 13 ------- mm/hugetlb_cma.c | 33 ++++++++-------- mm/hugetlb_cma.h | 5 --- mm/hugetlb_vmemmap.c | 11 ------ mm/internal.h | 6 +++ mm/mm_init.c | 20 ++++++---- 64 files changed, 223 insertions(+), 414 deletions(-) base-commit: 8f0b4cce4481fb22653697cced8d0d04027cb1e8 -- 2.51.0
null
null
null
[PATCH v3 00/29] arch, mm: consolidate hugetlb early reservation
From: "Mike Rapoport (Microsoft)" <rppt@kernel.org> Every architecture calls sparse_init() during setup_arch() although the data structures created by sparse_init() are not used until the initialization of the core MM. Beside the code duplication, calling sparse_init() from architecture specific code causes ordering differences of vmemmap and HVO initialization on different architectures. Move the call to sparse_init() from architecture specific code to free_area_init() to ensure that vmemmap and HVO initialization order is always the same. Signed-off-by: Mike Rapoport (Microsoft) <rppt@kernel.org> --- Documentation/mm/memory-model.rst | 3 --- Documentation/translations/zh_CN/mm/memory-model.rst | 2 -- arch/alpha/kernel/setup.c | 1 - arch/arm/mm/init.c | 6 ------ arch/arm64/mm/init.c | 6 ------ arch/csky/kernel/setup.c | 2 -- arch/loongarch/kernel/setup.c | 8 -------- arch/mips/kernel/setup.c | 11 ----------- arch/parisc/mm/init.c | 2 -- arch/powerpc/include/asm/setup.h | 4 ++++ arch/powerpc/mm/mem.c | 5 ----- arch/powerpc/mm/numa.c | 2 -- arch/riscv/mm/init.c | 1 - arch/s390/mm/init.c | 1 - arch/sh/mm/init.c | 2 -- arch/sparc/mm/init_64.c | 2 -- arch/x86/mm/init_32.c | 1 - arch/x86/mm/init_64.c | 2 -- include/linux/mmzone.h | 2 -- mm/internal.h | 6 ++++++ mm/mm_init.c | 1 + 21 files changed, 11 insertions(+), 59 deletions(-) diff --git a/Documentation/mm/memory-model.rst b/Documentation/mm/memory-model.rst index 7957122039e8..199b11328f4f 100644 --- a/Documentation/mm/memory-model.rst +++ b/Documentation/mm/memory-model.rst @@ -97,9 +97,6 @@ sections: `mem_section` objects and the number of rows is calculated to fit all the memory sections. -The architecture setup code should call sparse_init() to -initialize the memory sections and the memory maps. - With SPARSEMEM there are two possible ways to convert a PFN to the corresponding `struct page` - a "classic sparse" and "sparse vmemmap". The selection is made at build time and it is determined by diff --git a/Documentation/translations/zh_CN/mm/memory-model.rst b/Documentation/translations/zh_CN/mm/memory-model.rst index 77ec149a970c..c0c5d8ecd880 100644 --- a/Documentation/translations/zh_CN/mm/memory-model.rst +++ b/Documentation/translations/zh_CN/mm/memory-model.rst @@ -83,8 +83,6 @@ SPARSEMEM模型将物理内存显示为一个部分的集合。一个区段用me 每一行包含价值 `PAGE_SIZE` 的 `mem_section` 对象,行数的计算是为了适应所有的 内存区。 -架构设置代码应该调用sparse_init()来初始化内存区和内存映射。 - 通过SPARSEMEM,有两种可能的方式将PFN转换为相应的 `struct page` --"classic sparse"和 "sparse vmemmap"。选择是在构建时进行的,它由 `CONFIG_SPARSEMEM_VMEMMAP` 的 值决定。 diff --git a/arch/alpha/kernel/setup.c b/arch/alpha/kernel/setup.c index bebdffafaee8..f0af444a69a4 100644 --- a/arch/alpha/kernel/setup.c +++ b/arch/alpha/kernel/setup.c @@ -607,7 +607,6 @@ setup_arch(char **cmdline_p) /* Find our memory. */ setup_memory(kernel_end); memblock_set_bottom_up(true); - sparse_init(); /* First guess at cpu cache sizes. Do this before init_arch. */ determine_cpu_caches(cpu->type); diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c index a8f7b4084715..0cc1bf04686d 100644 --- a/arch/arm/mm/init.c +++ b/arch/arm/mm/init.c @@ -207,12 +207,6 @@ void __init bootmem_init(void) early_memtest((phys_addr_t)min_low_pfn << PAGE_SHIFT, (phys_addr_t)max_low_pfn << PAGE_SHIFT); - - /* - * sparse_init() tries to allocate memory from memblock, so must be - * done after the fixed reservations - */ - sparse_init(); } /* diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c index 3641e88ea871..9d271aff7652 100644 --- a/arch/arm64/mm/init.c +++ b/arch/arm64/mm/init.c @@ -321,12 +321,6 @@ void __init bootmem_init(void) #endif kvm_hyp_reserve(); - - /* - * sparse_init() tries to allocate memory from memblock, so must be - * done after the fixed reservations - */ - sparse_init(); dma_limits_init(); /* diff --git a/arch/csky/kernel/setup.c b/arch/csky/kernel/setup.c index 4bf3c01ead3a..45c98dcf7f50 100644 --- a/arch/csky/kernel/setup.c +++ b/arch/csky/kernel/setup.c @@ -123,8 +123,6 @@ void __init setup_arch(char **cmdline_p) setup_smp(); #endif - sparse_init(); - fixaddr_init(); #ifdef CONFIG_HIGHMEM diff --git a/arch/loongarch/kernel/setup.c b/arch/loongarch/kernel/setup.c index 708ac025db71..d6a1ff0e16f1 100644 --- a/arch/loongarch/kernel/setup.c +++ b/arch/loongarch/kernel/setup.c @@ -402,14 +402,6 @@ static void __init arch_mem_init(char **cmdline_p) check_kernel_sections_mem(); - /* - * In order to reduce the possibility of kernel panic when failed to - * get IO TLB memory under CONFIG_SWIOTLB, it is better to allocate - * low memory as small as possible before swiotlb_init(), so make - * sparse_init() using top-down allocation. - */ - memblock_set_bottom_up(false); - sparse_init(); memblock_set_bottom_up(true); swiotlb_init(true, SWIOTLB_VERBOSE); diff --git a/arch/mips/kernel/setup.c b/arch/mips/kernel/setup.c index 11b9b6b63e19..d36d89d01fa4 100644 --- a/arch/mips/kernel/setup.c +++ b/arch/mips/kernel/setup.c @@ -614,7 +614,6 @@ static void __init bootcmdline_init(void) * kernel but generic memory management system is still entirely uninitialized. * * o bootmem_init() - * o sparse_init() * o paging_init() * o dma_contiguous_reserve() * @@ -665,16 +664,6 @@ static void __init arch_mem_init(char **cmdline_p) mips_parse_crashkernel(); device_tree_init(); - /* - * In order to reduce the possibility of kernel panic when failed to - * get IO TLB memory under CONFIG_SWIOTLB, it is better to allocate - * low memory as small as possible before plat_swiotlb_setup(), so - * make sparse_init() using top-down allocation. - */ - memblock_set_bottom_up(false); - sparse_init(); - memblock_set_bottom_up(true); - plat_swiotlb_setup(); dma_contiguous_reserve(PFN_PHYS(max_low_pfn)); diff --git a/arch/parisc/mm/init.c b/arch/parisc/mm/init.c index ce6f09ab7a90..6a39e031e5ff 100644 --- a/arch/parisc/mm/init.c +++ b/arch/parisc/mm/init.c @@ -706,8 +706,6 @@ void __init paging_init(void) fixmap_init(); flush_cache_all_local(); /* start with known state */ flush_tlb_all_local(NULL); - - sparse_init(); } static void alloc_btlb(unsigned long start, unsigned long end, int *slot, diff --git a/arch/powerpc/include/asm/setup.h b/arch/powerpc/include/asm/setup.h index 50a92b24628d..6d60ea4868ab 100644 --- a/arch/powerpc/include/asm/setup.h +++ b/arch/powerpc/include/asm/setup.h @@ -20,7 +20,11 @@ extern void reloc_got2(unsigned long); void check_for_initrd(void); void mem_topology_setup(void); +#ifdef CONFIG_NUMA void initmem_init(void); +#else +static inline void initmem_init(void) {} +#endif void setup_panic(void); #define ARCH_PANIC_TIMEOUT 180 diff --git a/arch/powerpc/mm/mem.c b/arch/powerpc/mm/mem.c index b716c9cd141c..3789a51bdaae 100644 --- a/arch/powerpc/mm/mem.c +++ b/arch/powerpc/mm/mem.c @@ -182,11 +182,6 @@ void __init mem_topology_setup(void) memblock_set_node(0, PHYS_ADDR_MAX, &memblock.memory, 0); } -void __init initmem_init(void) -{ - sparse_init(); -} - /* mark pages that don't exist as nosave */ static int __init mark_nonram_nosave(void) { diff --git a/arch/powerpc/mm/numa.c b/arch/powerpc/mm/numa.c index 603a0f652ba6..f4cf3ae036de 100644 --- a/arch/powerpc/mm/numa.c +++ b/arch/powerpc/mm/numa.c @@ -1213,8 +1213,6 @@ void __init initmem_init(void) setup_node_data(nid, start_pfn, end_pfn); } - sparse_init(); - /* * We need the numa_cpu_lookup_table to be accurate for all CPUs, * even before we online them, so that we can use cpu_to_{node,mem} diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c index 79b4792578c4..11ac4041afc0 100644 --- a/arch/riscv/mm/init.c +++ b/arch/riscv/mm/init.c @@ -1430,7 +1430,6 @@ void __init misc_mem_init(void) { early_memtest(min_low_pfn << PAGE_SHIFT, max_low_pfn << PAGE_SHIFT); arch_numa_init(); - sparse_init(); #ifdef CONFIG_SPARSEMEM_VMEMMAP /* The entire VMEMMAP region has been populated. Flush TLB for this region */ local_flush_tlb_kernel_range(VMEMMAP_START, VMEMMAP_END); diff --git a/arch/s390/mm/init.c b/arch/s390/mm/init.c index 9ec608b5cbb1..3c20475cbee2 100644 --- a/arch/s390/mm/init.c +++ b/arch/s390/mm/init.c @@ -98,7 +98,6 @@ void __init arch_zone_limits_init(unsigned long *max_zone_pfns) void __init paging_init(void) { vmem_map_init(); - sparse_init(); zone_dma_limit = DMA_BIT_MASK(31); } diff --git a/arch/sh/mm/init.c b/arch/sh/mm/init.c index 3edee854b755..464a3a63e2fa 100644 --- a/arch/sh/mm/init.c +++ b/arch/sh/mm/init.c @@ -227,8 +227,6 @@ static void __init do_init_bootmem(void) node_set_online(0); plat_mem_setup(); - - sparse_init(); } static void __init early_reserve_mem(void) diff --git a/arch/sparc/mm/init_64.c b/arch/sparc/mm/init_64.c index 931f872ce84a..4f7bdb18774b 100644 --- a/arch/sparc/mm/init_64.c +++ b/arch/sparc/mm/init_64.c @@ -1615,8 +1615,6 @@ static unsigned long __init bootmem_init(unsigned long phys_base) /* XXX cpu notifier XXX */ - sparse_init(); - return end_pfn; } diff --git a/arch/x86/mm/init_32.c b/arch/x86/mm/init_32.c index b55172118c91..0908c44d51e6 100644 --- a/arch/x86/mm/init_32.c +++ b/arch/x86/mm/init_32.c @@ -654,7 +654,6 @@ void __init paging_init(void) * NOTE: at this point the bootmem allocator is fully available. */ olpc_dt_build_devicetree(); - sparse_init(); } /* diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c index 4daa40071c9f..df2261fa4f98 100644 --- a/arch/x86/mm/init_64.c +++ b/arch/x86/mm/init_64.c @@ -833,8 +833,6 @@ void __init initmem_init(void) void __init paging_init(void) { - sparse_init(); - /* * clear the default setting with node 0 * note: don't use nodes_clear here, that is really clearing when diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h index 75ef7c9f9307..6a7db0fee54a 100644 --- a/include/linux/mmzone.h +++ b/include/linux/mmzone.h @@ -2285,9 +2285,7 @@ static inline unsigned long next_present_section_nr(unsigned long section_nr) #define pfn_to_nid(pfn) (0) #endif -void sparse_init(void); #else -#define sparse_init() do {} while (0) #define sparse_index_init(_sec, _nid) do {} while (0) #define sparse_vmemmap_init_nid_early(_nid) do {} while (0) #define sparse_vmemmap_init_nid_late(_nid) do {} while (0) diff --git a/mm/internal.h b/mm/internal.h index e430da900430..dc5316c68664 100644 --- a/mm/internal.h +++ b/mm/internal.h @@ -860,6 +860,12 @@ void memmap_init_range(unsigned long, int, unsigned long, unsigned long, unsigned long, enum meminit_context, struct vmem_altmap *, int, bool); +#ifdef CONFIG_SPARSEMEM +void sparse_init(void); +#else +static inline void sparse_init(void) {} +#endif /* CONFIG_SPARSEMEM */ + #if defined CONFIG_COMPACTION || defined CONFIG_CMA /* diff --git a/mm/mm_init.c b/mm/mm_init.c index ffc4a0f1fee9..4cfe722da062 100644 --- a/mm/mm_init.c +++ b/mm/mm_init.c @@ -1828,6 +1828,7 @@ static void __init free_area_init(void) bool descending; arch_zone_limits_init(max_zone_pfn); + sparse_init(); start_pfn = PHYS_PFN(memblock_start_of_DRAM()); descending = arch_has_descending_max_zone_pfns(); -- 2.51.0
{ "author": "Mike Rapoport <rppt@kernel.org>", "date": "Sun, 11 Jan 2026 10:20:58 +0200", "is_openbsd": false, "thread_id": "b9527ed4-7a5c-42e9-8814-b276b3741f63@suse.cz.mbox.gz" }
lkml_critique
lkml
From: "Mike Rapoport (Microsoft)" <rppt@kernel.org> Hi, Order in which early memory reservation for hugetlb happens depends on architecture, on configuration options and on command line parameters. Some architectures rely on the core MM to call hugetlb_bootmem_alloc() while others call it very early to allow pre-allocation of HVO-style vmemmap. When hugetlb_cma is supported by an architecture it is initialized during setup_arch() and then later hugetlb_init code needs to understand did it happen or not. To make everything consistent and unified, both reservation of hugetlb memory from bootmem and creation of CMA areas for hugetlb must be called from core MM initialization and it would have been a simple change. However, HVO-style pre-initialization ordering requirements slightly complicate things and for HVO pre-init to work sparse and memory map should be initialized after hugetlb reservations. This required pulling out the call to free_area_init() out of setup_arch() path and moving it MM initialization and this is what the first 23 patches do. These changes are deliberately split into per-arch patches that change how the zone limits are calculated for each architecture and the patches 22 and 23 just remove the calls to free_area_init() and sprase_init() from arch/*. Patch 24 is a simple cleanup for MIPS. Patches 25 and 26 actually consolidate hugetlb reservations and patches 27 and 28 perform some aftermath cleanups. I tried to trim the distribution list and although it's still quite long if you feel that someone was wrongly excluded please add them back. The changes also available in git: https://git.kernel.org/pub/scm/linux/kernel/git/rppt/linux.git/log/?h=hugetlb-init/v3 v3 changes: * fix empty_zero_page initialization on arm * fix ZONE_DMA limit calculation on powerpc * add Acks v2: https://lore.kernel.org/all/20260102070005.65328-1-rppt@kernel.org * move the hugetlb and memory map initializaion to mm_core_init_early() * add Acks v1: https://lore.kernel.org/all/20251228124001.3624742-1-rppt@kernel.org Klara Modin (1): arm: make initialization of zero page independent of the memory map Mike Rapoport (Microsoft) (28): alpha: introduce arch_zone_limits_init() arc: introduce arch_zone_limits_init() arm: introduce arch_zone_limits_init() arm64: introduce arch_zone_limits_init() csky: introduce arch_zone_limits_init() hexagon: introduce arch_zone_limits_init() loongarch: introduce arch_zone_limits_init() m68k: introduce arch_zone_limits_init() microblaze: introduce arch_zone_limits_init() mips: introduce arch_zone_limits_init() nios2: introduce arch_zone_limits_init() openrisc: introduce arch_zone_limits_init() parisc: introduce arch_zone_limits_init() powerpc: introduce arch_zone_limits_init() riscv: introduce arch_zone_limits_init() s390: introduce arch_zone_limits_init() sh: introduce arch_zone_limits_init() sparc: introduce arch_zone_limits_init() um: introduce arch_zone_limits_init() x86: introduce arch_zone_limits_init() xtensa: introduce arch_zone_limits_init() arch, mm: consolidate initialization of nodes, zones and memory map arch, mm: consolidate initialization of SPARSE memory model mips: drop paging_init() x86: don't reserve hugetlb memory in setup_arch() mm, arch: consolidate hugetlb CMA reservation mm/hugetlb: drop hugetlb_cma_check() Revert "mm/hugetlb: deal with multiple calls to hugetlb_bootmem_alloc" .../driver-api/cxl/linux/early-boot.rst | 2 +- Documentation/mm/memory-model.rst | 3 -- .../translations/zh_CN/mm/memory-model.rst | 2 - arch/alpha/kernel/setup.c | 1 - arch/alpha/mm/init.c | 16 ++++---- arch/arc/mm/init.c | 37 +++++++++--------- arch/arm/include/asm/pgtable.h | 4 +- arch/arm/mm/init.c | 25 ++---------- arch/arm/mm/mmu.c | 10 +---- arch/arm/mm/nommu.c | 10 +---- arch/arm64/include/asm/hugetlb.h | 2 - arch/arm64/mm/hugetlbpage.c | 10 ++--- arch/arm64/mm/init.c | 39 ++++++++----------- arch/csky/kernel/setup.c | 16 ++++---- arch/hexagon/mm/init.c | 19 +++------ arch/loongarch/include/asm/pgtable.h | 2 - arch/loongarch/kernel/setup.c | 10 ----- arch/loongarch/mm/init.c | 6 +-- arch/m68k/mm/init.c | 8 ++-- arch/m68k/mm/mcfmmu.c | 3 -- arch/m68k/mm/motorola.c | 6 +-- arch/m68k/mm/sun3mmu.c | 9 ----- arch/microblaze/mm/init.c | 22 +++++------ arch/mips/include/asm/pgalloc.h | 2 - arch/mips/include/asm/pgtable.h | 2 +- arch/mips/kernel/setup.c | 15 +------ arch/mips/loongson64/numa.c | 10 ++--- arch/mips/mm/init.c | 8 +--- arch/mips/sgi-ip27/ip27-memory.c | 8 +--- arch/nios2/mm/init.c | 12 +++--- arch/openrisc/mm/init.c | 10 +---- arch/parisc/mm/init.c | 11 +----- arch/powerpc/include/asm/hugetlb.h | 5 --- arch/powerpc/include/asm/setup.h | 4 ++ arch/powerpc/kernel/setup-common.c | 1 - arch/powerpc/mm/hugetlbpage.c | 11 ++---- arch/powerpc/mm/mem.c | 27 +++++-------- arch/powerpc/mm/numa.c | 2 - arch/riscv/mm/hugetlbpage.c | 8 ++++ arch/riscv/mm/init.c | 10 +---- arch/s390/kernel/setup.c | 2 - arch/s390/mm/hugetlbpage.c | 8 ++++ arch/s390/mm/init.c | 13 +++---- arch/sh/mm/init.c | 12 +++--- arch/sparc/mm/init_64.c | 17 +++----- arch/sparc/mm/srmmu.c | 17 ++++---- arch/um/kernel/mem.c | 10 ++--- arch/x86/kernel/setup.c | 5 --- arch/x86/mm/hugetlbpage.c | 8 ++++ arch/x86/mm/init.c | 8 +--- arch/x86/mm/init_32.c | 2 - arch/x86/mm/init_64.c | 4 -- arch/x86/mm/mm_internal.h | 1 - arch/xtensa/mm/init.c | 14 +++---- include/linux/hugetlb.h | 12 ++---- include/linux/mm.h | 5 ++- include/linux/mmzone.h | 2 - init/main.c | 1 + mm/hugetlb.c | 13 ------- mm/hugetlb_cma.c | 33 ++++++++-------- mm/hugetlb_cma.h | 5 --- mm/hugetlb_vmemmap.c | 11 ------ mm/internal.h | 6 +++ mm/mm_init.c | 20 ++++++---- 64 files changed, 223 insertions(+), 414 deletions(-) base-commit: 8f0b4cce4481fb22653697cced8d0d04027cb1e8 -- 2.51.0
null
null
null
[PATCH v3 00/29] arch, mm: consolidate hugetlb early reservation
From: "Mike Rapoport (Microsoft)" <rppt@kernel.org> All three variants of paging_init() on MIPS are wrappers for pagetable_init(). Instead of having three identical wrappers, call pagetable_init() directly from setup_arch() and remove the unnecessary paging_init() functions. Signed-off-by: Mike Rapoport (Microsoft) <rppt@kernel.org> --- arch/mips/include/asm/pgalloc.h | 2 -- arch/mips/include/asm/pgtable.h | 2 +- arch/mips/kernel/setup.c | 4 ++-- arch/mips/loongson64/numa.c | 5 ----- arch/mips/mm/init.c | 5 ----- arch/mips/sgi-ip27/ip27-memory.c | 5 ----- 6 files changed, 3 insertions(+), 20 deletions(-) diff --git a/arch/mips/include/asm/pgalloc.h b/arch/mips/include/asm/pgalloc.h index 7a04381efa0b..6efd4a58bf10 100644 --- a/arch/mips/include/asm/pgalloc.h +++ b/arch/mips/include/asm/pgalloc.h @@ -101,6 +101,4 @@ static inline void p4d_populate(struct mm_struct *mm, p4d_t *p4d, pud_t *pud) #endif /* __PAGETABLE_PUD_FOLDED */ -extern void pagetable_init(void); - #endif /* _ASM_PGALLOC_H */ diff --git a/arch/mips/include/asm/pgtable.h b/arch/mips/include/asm/pgtable.h index 9c06a612d33a..fa7b935f947c 100644 --- a/arch/mips/include/asm/pgtable.h +++ b/arch/mips/include/asm/pgtable.h @@ -56,7 +56,7 @@ extern unsigned long zero_page_mask; (virt_to_page((void *)(empty_zero_page + (((unsigned long)(vaddr)) & zero_page_mask)))) #define __HAVE_COLOR_ZERO_PAGE -extern void paging_init(void); +extern void pagetable_init(void); /* * Conversion functions: convert a page and protection to a page entry, diff --git a/arch/mips/kernel/setup.c b/arch/mips/kernel/setup.c index d36d89d01fa4..7622aad0f0b3 100644 --- a/arch/mips/kernel/setup.c +++ b/arch/mips/kernel/setup.c @@ -614,7 +614,7 @@ static void __init bootcmdline_init(void) * kernel but generic memory management system is still entirely uninitialized. * * o bootmem_init() - * o paging_init() + * o pagetable_init() * o dma_contiguous_reserve() * * At this stage the bootmem allocator is ready to use. @@ -778,7 +778,7 @@ void __init setup_arch(char **cmdline_p) prefill_possible_map(); cpu_cache_init(); - paging_init(); + pagetable_init(); memblock_dump_all(); diff --git a/arch/mips/loongson64/numa.c b/arch/mips/loongson64/numa.c index 2cd95020df08..16ffb32cca50 100644 --- a/arch/mips/loongson64/numa.c +++ b/arch/mips/loongson64/numa.c @@ -160,11 +160,6 @@ void __init arch_zone_limits_init(unsigned long *max_zone_pfns) max_zone_pfns[ZONE_NORMAL] = max_low_pfn; } -void __init paging_init(void) -{ - pagetable_init(); -} - /* All PCI device belongs to logical Node-0 */ int pcibus_to_node(struct pci_bus *bus) { diff --git a/arch/mips/mm/init.c b/arch/mips/mm/init.c index c479c42141c3..cd04200d0573 100644 --- a/arch/mips/mm/init.c +++ b/arch/mips/mm/init.c @@ -415,11 +415,6 @@ void __init arch_zone_limits_init(unsigned long *max_zone_pfns) #endif } -void __init paging_init(void) -{ - pagetable_init(); -} - #ifdef CONFIG_64BIT static struct kcore_list kcore_kseg0; #endif diff --git a/arch/mips/sgi-ip27/ip27-memory.c b/arch/mips/sgi-ip27/ip27-memory.c index 082651facf4f..4317f5ae1fd1 100644 --- a/arch/mips/sgi-ip27/ip27-memory.c +++ b/arch/mips/sgi-ip27/ip27-memory.c @@ -410,8 +410,3 @@ void __init arch_zone_limits_init(unsigned long *max_zone_pfns) { max_zone_pfns[ZONE_NORMAL] = max_low_pfn; } - -void __init paging_init(void) -{ - pagetable_init(); -} -- 2.51.0
{ "author": "Mike Rapoport <rppt@kernel.org>", "date": "Sun, 11 Jan 2026 10:20:59 +0200", "is_openbsd": false, "thread_id": "b9527ed4-7a5c-42e9-8814-b276b3741f63@suse.cz.mbox.gz" }
lkml_critique
lkml
From: "Mike Rapoport (Microsoft)" <rppt@kernel.org> Hi, Order in which early memory reservation for hugetlb happens depends on architecture, on configuration options and on command line parameters. Some architectures rely on the core MM to call hugetlb_bootmem_alloc() while others call it very early to allow pre-allocation of HVO-style vmemmap. When hugetlb_cma is supported by an architecture it is initialized during setup_arch() and then later hugetlb_init code needs to understand did it happen or not. To make everything consistent and unified, both reservation of hugetlb memory from bootmem and creation of CMA areas for hugetlb must be called from core MM initialization and it would have been a simple change. However, HVO-style pre-initialization ordering requirements slightly complicate things and for HVO pre-init to work sparse and memory map should be initialized after hugetlb reservations. This required pulling out the call to free_area_init() out of setup_arch() path and moving it MM initialization and this is what the first 23 patches do. These changes are deliberately split into per-arch patches that change how the zone limits are calculated for each architecture and the patches 22 and 23 just remove the calls to free_area_init() and sprase_init() from arch/*. Patch 24 is a simple cleanup for MIPS. Patches 25 and 26 actually consolidate hugetlb reservations and patches 27 and 28 perform some aftermath cleanups. I tried to trim the distribution list and although it's still quite long if you feel that someone was wrongly excluded please add them back. The changes also available in git: https://git.kernel.org/pub/scm/linux/kernel/git/rppt/linux.git/log/?h=hugetlb-init/v3 v3 changes: * fix empty_zero_page initialization on arm * fix ZONE_DMA limit calculation on powerpc * add Acks v2: https://lore.kernel.org/all/20260102070005.65328-1-rppt@kernel.org * move the hugetlb and memory map initializaion to mm_core_init_early() * add Acks v1: https://lore.kernel.org/all/20251228124001.3624742-1-rppt@kernel.org Klara Modin (1): arm: make initialization of zero page independent of the memory map Mike Rapoport (Microsoft) (28): alpha: introduce arch_zone_limits_init() arc: introduce arch_zone_limits_init() arm: introduce arch_zone_limits_init() arm64: introduce arch_zone_limits_init() csky: introduce arch_zone_limits_init() hexagon: introduce arch_zone_limits_init() loongarch: introduce arch_zone_limits_init() m68k: introduce arch_zone_limits_init() microblaze: introduce arch_zone_limits_init() mips: introduce arch_zone_limits_init() nios2: introduce arch_zone_limits_init() openrisc: introduce arch_zone_limits_init() parisc: introduce arch_zone_limits_init() powerpc: introduce arch_zone_limits_init() riscv: introduce arch_zone_limits_init() s390: introduce arch_zone_limits_init() sh: introduce arch_zone_limits_init() sparc: introduce arch_zone_limits_init() um: introduce arch_zone_limits_init() x86: introduce arch_zone_limits_init() xtensa: introduce arch_zone_limits_init() arch, mm: consolidate initialization of nodes, zones and memory map arch, mm: consolidate initialization of SPARSE memory model mips: drop paging_init() x86: don't reserve hugetlb memory in setup_arch() mm, arch: consolidate hugetlb CMA reservation mm/hugetlb: drop hugetlb_cma_check() Revert "mm/hugetlb: deal with multiple calls to hugetlb_bootmem_alloc" .../driver-api/cxl/linux/early-boot.rst | 2 +- Documentation/mm/memory-model.rst | 3 -- .../translations/zh_CN/mm/memory-model.rst | 2 - arch/alpha/kernel/setup.c | 1 - arch/alpha/mm/init.c | 16 ++++---- arch/arc/mm/init.c | 37 +++++++++--------- arch/arm/include/asm/pgtable.h | 4 +- arch/arm/mm/init.c | 25 ++---------- arch/arm/mm/mmu.c | 10 +---- arch/arm/mm/nommu.c | 10 +---- arch/arm64/include/asm/hugetlb.h | 2 - arch/arm64/mm/hugetlbpage.c | 10 ++--- arch/arm64/mm/init.c | 39 ++++++++----------- arch/csky/kernel/setup.c | 16 ++++---- arch/hexagon/mm/init.c | 19 +++------ arch/loongarch/include/asm/pgtable.h | 2 - arch/loongarch/kernel/setup.c | 10 ----- arch/loongarch/mm/init.c | 6 +-- arch/m68k/mm/init.c | 8 ++-- arch/m68k/mm/mcfmmu.c | 3 -- arch/m68k/mm/motorola.c | 6 +-- arch/m68k/mm/sun3mmu.c | 9 ----- arch/microblaze/mm/init.c | 22 +++++------ arch/mips/include/asm/pgalloc.h | 2 - arch/mips/include/asm/pgtable.h | 2 +- arch/mips/kernel/setup.c | 15 +------ arch/mips/loongson64/numa.c | 10 ++--- arch/mips/mm/init.c | 8 +--- arch/mips/sgi-ip27/ip27-memory.c | 8 +--- arch/nios2/mm/init.c | 12 +++--- arch/openrisc/mm/init.c | 10 +---- arch/parisc/mm/init.c | 11 +----- arch/powerpc/include/asm/hugetlb.h | 5 --- arch/powerpc/include/asm/setup.h | 4 ++ arch/powerpc/kernel/setup-common.c | 1 - arch/powerpc/mm/hugetlbpage.c | 11 ++---- arch/powerpc/mm/mem.c | 27 +++++-------- arch/powerpc/mm/numa.c | 2 - arch/riscv/mm/hugetlbpage.c | 8 ++++ arch/riscv/mm/init.c | 10 +---- arch/s390/kernel/setup.c | 2 - arch/s390/mm/hugetlbpage.c | 8 ++++ arch/s390/mm/init.c | 13 +++---- arch/sh/mm/init.c | 12 +++--- arch/sparc/mm/init_64.c | 17 +++----- arch/sparc/mm/srmmu.c | 17 ++++---- arch/um/kernel/mem.c | 10 ++--- arch/x86/kernel/setup.c | 5 --- arch/x86/mm/hugetlbpage.c | 8 ++++ arch/x86/mm/init.c | 8 +--- arch/x86/mm/init_32.c | 2 - arch/x86/mm/init_64.c | 4 -- arch/x86/mm/mm_internal.h | 1 - arch/xtensa/mm/init.c | 14 +++---- include/linux/hugetlb.h | 12 ++---- include/linux/mm.h | 5 ++- include/linux/mmzone.h | 2 - init/main.c | 1 + mm/hugetlb.c | 13 ------- mm/hugetlb_cma.c | 33 ++++++++-------- mm/hugetlb_cma.h | 5 --- mm/hugetlb_vmemmap.c | 11 ------ mm/internal.h | 6 +++ mm/mm_init.c | 20 ++++++---- 64 files changed, 223 insertions(+), 414 deletions(-) base-commit: 8f0b4cce4481fb22653697cced8d0d04027cb1e8 -- 2.51.0
null
null
null
[PATCH v3 00/29] arch, mm: consolidate hugetlb early reservation
From: "Mike Rapoport (Microsoft)" <rppt@kernel.org> Commit 665eaf313314 ("x86/setup: call hugetlb_bootmem_alloc early") added an early call to hugetlb_bootmem_alloc() to setup_arch() to allow HVO style pre-initialization of vmemmap on x86. With the ordering of hugetlb reservation vs memory map initialization sorted out in core MM this no longer needs to be an architecture specific quirk. Drop the call to hugetlb_bootmem_alloc() from x86::setup_arch(). Signed-off-by: Mike Rapoport (Microsoft) <rppt@kernel.org> --- arch/x86/kernel/setup.c | 1 - 1 file changed, 1 deletion(-) diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c index 1b2edd07a3e1..e2318fa9b1bb 100644 --- a/arch/x86/kernel/setup.c +++ b/arch/x86/kernel/setup.c @@ -1191,7 +1191,6 @@ void __init setup_arch(char **cmdline_p) if (boot_cpu_has(X86_FEATURE_GBPAGES)) { hugetlb_cma_reserve(PUD_SHIFT - PAGE_SHIFT); - hugetlb_bootmem_alloc(); } /* -- 2.51.0
{ "author": "Mike Rapoport <rppt@kernel.org>", "date": "Sun, 11 Jan 2026 10:21:00 +0200", "is_openbsd": false, "thread_id": "b9527ed4-7a5c-42e9-8814-b276b3741f63@suse.cz.mbox.gz" }
lkml_critique
lkml
From: "Mike Rapoport (Microsoft)" <rppt@kernel.org> Hi, Order in which early memory reservation for hugetlb happens depends on architecture, on configuration options and on command line parameters. Some architectures rely on the core MM to call hugetlb_bootmem_alloc() while others call it very early to allow pre-allocation of HVO-style vmemmap. When hugetlb_cma is supported by an architecture it is initialized during setup_arch() and then later hugetlb_init code needs to understand did it happen or not. To make everything consistent and unified, both reservation of hugetlb memory from bootmem and creation of CMA areas for hugetlb must be called from core MM initialization and it would have been a simple change. However, HVO-style pre-initialization ordering requirements slightly complicate things and for HVO pre-init to work sparse and memory map should be initialized after hugetlb reservations. This required pulling out the call to free_area_init() out of setup_arch() path and moving it MM initialization and this is what the first 23 patches do. These changes are deliberately split into per-arch patches that change how the zone limits are calculated for each architecture and the patches 22 and 23 just remove the calls to free_area_init() and sprase_init() from arch/*. Patch 24 is a simple cleanup for MIPS. Patches 25 and 26 actually consolidate hugetlb reservations and patches 27 and 28 perform some aftermath cleanups. I tried to trim the distribution list and although it's still quite long if you feel that someone was wrongly excluded please add them back. The changes also available in git: https://git.kernel.org/pub/scm/linux/kernel/git/rppt/linux.git/log/?h=hugetlb-init/v3 v3 changes: * fix empty_zero_page initialization on arm * fix ZONE_DMA limit calculation on powerpc * add Acks v2: https://lore.kernel.org/all/20260102070005.65328-1-rppt@kernel.org * move the hugetlb and memory map initializaion to mm_core_init_early() * add Acks v1: https://lore.kernel.org/all/20251228124001.3624742-1-rppt@kernel.org Klara Modin (1): arm: make initialization of zero page independent of the memory map Mike Rapoport (Microsoft) (28): alpha: introduce arch_zone_limits_init() arc: introduce arch_zone_limits_init() arm: introduce arch_zone_limits_init() arm64: introduce arch_zone_limits_init() csky: introduce arch_zone_limits_init() hexagon: introduce arch_zone_limits_init() loongarch: introduce arch_zone_limits_init() m68k: introduce arch_zone_limits_init() microblaze: introduce arch_zone_limits_init() mips: introduce arch_zone_limits_init() nios2: introduce arch_zone_limits_init() openrisc: introduce arch_zone_limits_init() parisc: introduce arch_zone_limits_init() powerpc: introduce arch_zone_limits_init() riscv: introduce arch_zone_limits_init() s390: introduce arch_zone_limits_init() sh: introduce arch_zone_limits_init() sparc: introduce arch_zone_limits_init() um: introduce arch_zone_limits_init() x86: introduce arch_zone_limits_init() xtensa: introduce arch_zone_limits_init() arch, mm: consolidate initialization of nodes, zones and memory map arch, mm: consolidate initialization of SPARSE memory model mips: drop paging_init() x86: don't reserve hugetlb memory in setup_arch() mm, arch: consolidate hugetlb CMA reservation mm/hugetlb: drop hugetlb_cma_check() Revert "mm/hugetlb: deal with multiple calls to hugetlb_bootmem_alloc" .../driver-api/cxl/linux/early-boot.rst | 2 +- Documentation/mm/memory-model.rst | 3 -- .../translations/zh_CN/mm/memory-model.rst | 2 - arch/alpha/kernel/setup.c | 1 - arch/alpha/mm/init.c | 16 ++++---- arch/arc/mm/init.c | 37 +++++++++--------- arch/arm/include/asm/pgtable.h | 4 +- arch/arm/mm/init.c | 25 ++---------- arch/arm/mm/mmu.c | 10 +---- arch/arm/mm/nommu.c | 10 +---- arch/arm64/include/asm/hugetlb.h | 2 - arch/arm64/mm/hugetlbpage.c | 10 ++--- arch/arm64/mm/init.c | 39 ++++++++----------- arch/csky/kernel/setup.c | 16 ++++---- arch/hexagon/mm/init.c | 19 +++------ arch/loongarch/include/asm/pgtable.h | 2 - arch/loongarch/kernel/setup.c | 10 ----- arch/loongarch/mm/init.c | 6 +-- arch/m68k/mm/init.c | 8 ++-- arch/m68k/mm/mcfmmu.c | 3 -- arch/m68k/mm/motorola.c | 6 +-- arch/m68k/mm/sun3mmu.c | 9 ----- arch/microblaze/mm/init.c | 22 +++++------ arch/mips/include/asm/pgalloc.h | 2 - arch/mips/include/asm/pgtable.h | 2 +- arch/mips/kernel/setup.c | 15 +------ arch/mips/loongson64/numa.c | 10 ++--- arch/mips/mm/init.c | 8 +--- arch/mips/sgi-ip27/ip27-memory.c | 8 +--- arch/nios2/mm/init.c | 12 +++--- arch/openrisc/mm/init.c | 10 +---- arch/parisc/mm/init.c | 11 +----- arch/powerpc/include/asm/hugetlb.h | 5 --- arch/powerpc/include/asm/setup.h | 4 ++ arch/powerpc/kernel/setup-common.c | 1 - arch/powerpc/mm/hugetlbpage.c | 11 ++---- arch/powerpc/mm/mem.c | 27 +++++-------- arch/powerpc/mm/numa.c | 2 - arch/riscv/mm/hugetlbpage.c | 8 ++++ arch/riscv/mm/init.c | 10 +---- arch/s390/kernel/setup.c | 2 - arch/s390/mm/hugetlbpage.c | 8 ++++ arch/s390/mm/init.c | 13 +++---- arch/sh/mm/init.c | 12 +++--- arch/sparc/mm/init_64.c | 17 +++----- arch/sparc/mm/srmmu.c | 17 ++++---- arch/um/kernel/mem.c | 10 ++--- arch/x86/kernel/setup.c | 5 --- arch/x86/mm/hugetlbpage.c | 8 ++++ arch/x86/mm/init.c | 8 +--- arch/x86/mm/init_32.c | 2 - arch/x86/mm/init_64.c | 4 -- arch/x86/mm/mm_internal.h | 1 - arch/xtensa/mm/init.c | 14 +++---- include/linux/hugetlb.h | 12 ++---- include/linux/mm.h | 5 ++- include/linux/mmzone.h | 2 - init/main.c | 1 + mm/hugetlb.c | 13 ------- mm/hugetlb_cma.c | 33 ++++++++-------- mm/hugetlb_cma.h | 5 --- mm/hugetlb_vmemmap.c | 11 ------ mm/internal.h | 6 +++ mm/mm_init.c | 20 ++++++---- 64 files changed, 223 insertions(+), 414 deletions(-) base-commit: 8f0b4cce4481fb22653697cced8d0d04027cb1e8 -- 2.51.0
null
null
null
[PATCH v3 00/29] arch, mm: consolidate hugetlb early reservation
From: "Mike Rapoport (Microsoft)" <rppt@kernel.org> Every architecture that supports hugetlb_cma command line parameter reserves CMA areas for hugetlb during setup_arch(). This obfuscates the ordering of hugetlb CMA initialization with respect to the rest initialization of the core MM. Introduce arch_hugetlb_cma_order() callback to allow architectures report the desired order-per-bit of CMA areas and provide a week implementation of arch_hugetlb_cma_order() for architectures that don't support hugetlb with CMA. Use this callback in hugetlb_cma_reserve() instead if passing the order as parameter and call hugetlb_cma_reserve() from mm_core_init_early() rather than have it spread over architecture specific code. Signed-off-by: Mike Rapoport (Microsoft) <rppt@kernel.org> --- .../driver-api/cxl/linux/early-boot.rst | 2 +- arch/arm64/include/asm/hugetlb.h | 2 -- arch/arm64/mm/hugetlbpage.c | 10 +++------- arch/arm64/mm/init.c | 9 --------- arch/powerpc/include/asm/hugetlb.h | 5 ----- arch/powerpc/kernel/setup-common.c | 1 - arch/powerpc/mm/hugetlbpage.c | 11 ++++------- arch/riscv/mm/hugetlbpage.c | 8 ++++++++ arch/riscv/mm/init.c | 2 -- arch/s390/kernel/setup.c | 2 -- arch/s390/mm/hugetlbpage.c | 8 ++++++++ arch/x86/kernel/setup.c | 4 ---- arch/x86/mm/hugetlbpage.c | 8 ++++++++ include/linux/hugetlb.h | 6 ++++-- mm/hugetlb_cma.c | 19 ++++++++++++++----- mm/mm_init.c | 1 + 16 files changed, 51 insertions(+), 47 deletions(-) diff --git a/Documentation/driver-api/cxl/linux/early-boot.rst b/Documentation/driver-api/cxl/linux/early-boot.rst index a7fc6fc85fbe..414481f33819 100644 --- a/Documentation/driver-api/cxl/linux/early-boot.rst +++ b/Documentation/driver-api/cxl/linux/early-boot.rst @@ -125,7 +125,7 @@ The contiguous memory allocator (CMA) enables reservation of contiguous memory regions on NUMA nodes during early boot. However, CMA cannot reserve memory on NUMA nodes that are not online during early boot. :: - void __init hugetlb_cma_reserve(int order) { + void __init hugetlb_cma_reserve(void) { if (!node_online(nid)) /* do not allow reservations */ } diff --git a/arch/arm64/include/asm/hugetlb.h b/arch/arm64/include/asm/hugetlb.h index 44c1f757bfcf..e6f8ff3cc630 100644 --- a/arch/arm64/include/asm/hugetlb.h +++ b/arch/arm64/include/asm/hugetlb.h @@ -56,8 +56,6 @@ extern void huge_pte_clear(struct mm_struct *mm, unsigned long addr, #define __HAVE_ARCH_HUGE_PTEP_GET extern pte_t huge_ptep_get(struct mm_struct *mm, unsigned long addr, pte_t *ptep); -void __init arm64_hugetlb_cma_reserve(void); - #define huge_ptep_modify_prot_start huge_ptep_modify_prot_start extern pte_t huge_ptep_modify_prot_start(struct vm_area_struct *vma, unsigned long addr, pte_t *ptep); diff --git a/arch/arm64/mm/hugetlbpage.c b/arch/arm64/mm/hugetlbpage.c index 1d90a7e75333..f8dd58ab67a8 100644 --- a/arch/arm64/mm/hugetlbpage.c +++ b/arch/arm64/mm/hugetlbpage.c @@ -36,16 +36,12 @@ * huge pages could still be served from those areas. */ #ifdef CONFIG_CMA -void __init arm64_hugetlb_cma_reserve(void) +unsigned int arch_hugetlb_cma_order(void) { - int order; - if (pud_sect_supported()) - order = PUD_SHIFT - PAGE_SHIFT; - else - order = CONT_PMD_SHIFT - PAGE_SHIFT; + return PUD_SHIFT - PAGE_SHIFT; - hugetlb_cma_reserve(order); + return CONT_PMD_SHIFT - PAGE_SHIFT; } #endif /* CONFIG_CMA */ diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c index 9d271aff7652..96711b8578fd 100644 --- a/arch/arm64/mm/init.c +++ b/arch/arm64/mm/init.c @@ -311,15 +311,6 @@ void __init bootmem_init(void) arch_numa_init(); - /* - * must be done after arch_numa_init() which calls numa_init() to - * initialize node_online_map that gets used in hugetlb_cma_reserve() - * while allocating required CMA size across online nodes. - */ -#if defined(CONFIG_HUGETLB_PAGE) && defined(CONFIG_CMA) - arm64_hugetlb_cma_reserve(); -#endif - kvm_hyp_reserve(); dma_limits_init(); diff --git a/arch/powerpc/include/asm/hugetlb.h b/arch/powerpc/include/asm/hugetlb.h index 86326587e58d..6d32a4299445 100644 --- a/arch/powerpc/include/asm/hugetlb.h +++ b/arch/powerpc/include/asm/hugetlb.h @@ -68,7 +68,6 @@ int huge_ptep_set_access_flags(struct vm_area_struct *vma, unsigned long addr, pte_t *ptep, pte_t pte, int dirty); -void gigantic_hugetlb_cma_reserve(void) __init; #include <asm-generic/hugetlb.h> #else /* ! CONFIG_HUGETLB_PAGE */ @@ -77,10 +76,6 @@ static inline void flush_hugetlb_page(struct vm_area_struct *vma, { } -static inline void __init gigantic_hugetlb_cma_reserve(void) -{ -} - static inline void __init hugetlbpage_init_defaultsize(void) { } diff --git a/arch/powerpc/kernel/setup-common.c b/arch/powerpc/kernel/setup-common.c index c8c42b419742..cb5b73adc250 100644 --- a/arch/powerpc/kernel/setup-common.c +++ b/arch/powerpc/kernel/setup-common.c @@ -1003,7 +1003,6 @@ void __init setup_arch(char **cmdline_p) fadump_cma_init(); kdump_cma_reserve(); kvm_cma_reserve(); - gigantic_hugetlb_cma_reserve(); early_memtest(min_low_pfn << PAGE_SHIFT, max_low_pfn << PAGE_SHIFT); diff --git a/arch/powerpc/mm/hugetlbpage.c b/arch/powerpc/mm/hugetlbpage.c index d3c1b749dcfc..558fafb82b8a 100644 --- a/arch/powerpc/mm/hugetlbpage.c +++ b/arch/powerpc/mm/hugetlbpage.c @@ -200,18 +200,15 @@ static int __init hugetlbpage_init(void) arch_initcall(hugetlbpage_init); -void __init gigantic_hugetlb_cma_reserve(void) +unsigned int __init arch_hugetlb_cma_order(void) { - unsigned long order = 0; - if (radix_enabled()) - order = PUD_SHIFT - PAGE_SHIFT; + return PUD_SHIFT - PAGE_SHIFT; else if (!firmware_has_feature(FW_FEATURE_LPAR) && mmu_psize_defs[MMU_PAGE_16G].shift) /* * For pseries we do use ibm,expected#pages for reserving 16G pages. */ - order = mmu_psize_to_shift(MMU_PAGE_16G) - PAGE_SHIFT; + return mmu_psize_to_shift(MMU_PAGE_16G) - PAGE_SHIFT; - if (order) - hugetlb_cma_reserve(order); + return 0; } diff --git a/arch/riscv/mm/hugetlbpage.c b/arch/riscv/mm/hugetlbpage.c index 375dd96bb4a0..a6d217112cf4 100644 --- a/arch/riscv/mm/hugetlbpage.c +++ b/arch/riscv/mm/hugetlbpage.c @@ -447,3 +447,11 @@ static __init int gigantic_pages_init(void) } arch_initcall(gigantic_pages_init); #endif + +unsigned int __init arch_hugetlb_cma_order(void) +{ + if (IS_ENABLED(CONFIG_64BIT)) + return PUD_SHIFT - PAGE_SHIFT; + + return 0; +} diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c index 11ac4041afc0..848efeb9e163 100644 --- a/arch/riscv/mm/init.c +++ b/arch/riscv/mm/init.c @@ -311,8 +311,6 @@ static void __init setup_bootmem(void) memblock_reserve(dtb_early_pa, fdt_totalsize(dtb_early_va)); dma_contiguous_reserve(dma32_phys_limit); - if (IS_ENABLED(CONFIG_64BIT)) - hugetlb_cma_reserve(PUD_SHIFT - PAGE_SHIFT); } #ifdef CONFIG_RELOCATABLE diff --git a/arch/s390/kernel/setup.c b/arch/s390/kernel/setup.c index c1fe0b53c5ac..b60284328fe3 100644 --- a/arch/s390/kernel/setup.c +++ b/arch/s390/kernel/setup.c @@ -963,8 +963,6 @@ void __init setup_arch(char **cmdline_p) setup_uv(); dma_contiguous_reserve(ident_map_size); vmcp_cma_reserve(); - if (cpu_has_edat2()) - hugetlb_cma_reserve(PUD_SHIFT - PAGE_SHIFT); reserve_crashkernel(); #ifdef CONFIG_CRASH_DUMP diff --git a/arch/s390/mm/hugetlbpage.c b/arch/s390/mm/hugetlbpage.c index d42e61c7594e..d93417d1e53c 100644 --- a/arch/s390/mm/hugetlbpage.c +++ b/arch/s390/mm/hugetlbpage.c @@ -255,3 +255,11 @@ bool __init arch_hugetlb_valid_size(unsigned long size) else return false; } + +unsigned int __init arch_hugetlb_cma_order(void) +{ + if (cpu_has_edat2()) + return PUD_SHIFT - PAGE_SHIFT; + + return 0; +} diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c index e2318fa9b1bb..e1efe3975aa0 100644 --- a/arch/x86/kernel/setup.c +++ b/arch/x86/kernel/setup.c @@ -1189,10 +1189,6 @@ void __init setup_arch(char **cmdline_p) initmem_init(); dma_contiguous_reserve(max_pfn_mapped << PAGE_SHIFT); - if (boot_cpu_has(X86_FEATURE_GBPAGES)) { - hugetlb_cma_reserve(PUD_SHIFT - PAGE_SHIFT); - } - /* * Reserve memory for crash kernel after SRAT is parsed so that it * won't consume hotpluggable memory. diff --git a/arch/x86/mm/hugetlbpage.c b/arch/x86/mm/hugetlbpage.c index 58f7f2bd535d..3b26621c9128 100644 --- a/arch/x86/mm/hugetlbpage.c +++ b/arch/x86/mm/hugetlbpage.c @@ -42,3 +42,11 @@ static __init int gigantic_pages_init(void) arch_initcall(gigantic_pages_init); #endif #endif + +unsigned int __init arch_hugetlb_cma_order(void) +{ + if (boot_cpu_has(X86_FEATURE_GBPAGES)) + return PUD_SHIFT - PAGE_SHIFT; + + return 0; +} diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h index 019a1c5281e4..08fc332e88a7 100644 --- a/include/linux/hugetlb.h +++ b/include/linux/hugetlb.h @@ -279,6 +279,8 @@ void fixup_hugetlb_reservations(struct vm_area_struct *vma); void hugetlb_split(struct vm_area_struct *vma, unsigned long addr); int hugetlb_vma_lock_alloc(struct vm_area_struct *vma); +unsigned int arch_hugetlb_cma_order(void); + #else /* !CONFIG_HUGETLB_PAGE */ static inline void hugetlb_dup_vma_private(struct vm_area_struct *vma) @@ -1316,9 +1318,9 @@ static inline spinlock_t *huge_pte_lock(struct hstate *h, } #if defined(CONFIG_HUGETLB_PAGE) && defined(CONFIG_CMA) -extern void __init hugetlb_cma_reserve(int order); +extern void __init hugetlb_cma_reserve(void); #else -static inline __init void hugetlb_cma_reserve(int order) +static inline __init void hugetlb_cma_reserve(void) { } #endif diff --git a/mm/hugetlb_cma.c b/mm/hugetlb_cma.c index e8e4dc7182d5..b1eb5998282c 100644 --- a/mm/hugetlb_cma.c +++ b/mm/hugetlb_cma.c @@ -134,12 +134,24 @@ static int __init cmdline_parse_hugetlb_cma_only(char *p) early_param("hugetlb_cma_only", cmdline_parse_hugetlb_cma_only); -void __init hugetlb_cma_reserve(int order) +unsigned int __weak arch_hugetlb_cma_order(void) { - unsigned long size, reserved, per_node; + return 0; +} + +void __init hugetlb_cma_reserve(void) +{ + unsigned long size, reserved, per_node, order; bool node_specific_cma_alloc = false; int nid; + if (!hugetlb_cma_size) + return; + + order = arch_hugetlb_cma_order(); + if (!order) + return; + /* * HugeTLB CMA reservation is required for gigantic * huge pages which could not be allocated via the @@ -149,9 +161,6 @@ void __init hugetlb_cma_reserve(int order) VM_WARN_ON(order <= MAX_PAGE_ORDER); cma_reserve_called = true; - if (!hugetlb_cma_size) - return; - hugetlb_bootmem_set_nodes(); for (nid = 0; nid < MAX_NUMNODES; nid++) { diff --git a/mm/mm_init.c b/mm/mm_init.c index 4cfe722da062..5099a973be5b 100644 --- a/mm/mm_init.c +++ b/mm/mm_init.c @@ -2680,6 +2680,7 @@ void __init __weak mem_init(void) void __init mm_core_init_early(void) { + hugetlb_cma_reserve(); hugetlb_bootmem_alloc(); free_area_init(); -- 2.51.0
{ "author": "Mike Rapoport <rppt@kernel.org>", "date": "Sun, 11 Jan 2026 10:21:01 +0200", "is_openbsd": false, "thread_id": "b9527ed4-7a5c-42e9-8814-b276b3741f63@suse.cz.mbox.gz" }
lkml_critique
lkml
From: "Mike Rapoport (Microsoft)" <rppt@kernel.org> Hi, Order in which early memory reservation for hugetlb happens depends on architecture, on configuration options and on command line parameters. Some architectures rely on the core MM to call hugetlb_bootmem_alloc() while others call it very early to allow pre-allocation of HVO-style vmemmap. When hugetlb_cma is supported by an architecture it is initialized during setup_arch() and then later hugetlb_init code needs to understand did it happen or not. To make everything consistent and unified, both reservation of hugetlb memory from bootmem and creation of CMA areas for hugetlb must be called from core MM initialization and it would have been a simple change. However, HVO-style pre-initialization ordering requirements slightly complicate things and for HVO pre-init to work sparse and memory map should be initialized after hugetlb reservations. This required pulling out the call to free_area_init() out of setup_arch() path and moving it MM initialization and this is what the first 23 patches do. These changes are deliberately split into per-arch patches that change how the zone limits are calculated for each architecture and the patches 22 and 23 just remove the calls to free_area_init() and sprase_init() from arch/*. Patch 24 is a simple cleanup for MIPS. Patches 25 and 26 actually consolidate hugetlb reservations and patches 27 and 28 perform some aftermath cleanups. I tried to trim the distribution list and although it's still quite long if you feel that someone was wrongly excluded please add them back. The changes also available in git: https://git.kernel.org/pub/scm/linux/kernel/git/rppt/linux.git/log/?h=hugetlb-init/v3 v3 changes: * fix empty_zero_page initialization on arm * fix ZONE_DMA limit calculation on powerpc * add Acks v2: https://lore.kernel.org/all/20260102070005.65328-1-rppt@kernel.org * move the hugetlb and memory map initializaion to mm_core_init_early() * add Acks v1: https://lore.kernel.org/all/20251228124001.3624742-1-rppt@kernel.org Klara Modin (1): arm: make initialization of zero page independent of the memory map Mike Rapoport (Microsoft) (28): alpha: introduce arch_zone_limits_init() arc: introduce arch_zone_limits_init() arm: introduce arch_zone_limits_init() arm64: introduce arch_zone_limits_init() csky: introduce arch_zone_limits_init() hexagon: introduce arch_zone_limits_init() loongarch: introduce arch_zone_limits_init() m68k: introduce arch_zone_limits_init() microblaze: introduce arch_zone_limits_init() mips: introduce arch_zone_limits_init() nios2: introduce arch_zone_limits_init() openrisc: introduce arch_zone_limits_init() parisc: introduce arch_zone_limits_init() powerpc: introduce arch_zone_limits_init() riscv: introduce arch_zone_limits_init() s390: introduce arch_zone_limits_init() sh: introduce arch_zone_limits_init() sparc: introduce arch_zone_limits_init() um: introduce arch_zone_limits_init() x86: introduce arch_zone_limits_init() xtensa: introduce arch_zone_limits_init() arch, mm: consolidate initialization of nodes, zones and memory map arch, mm: consolidate initialization of SPARSE memory model mips: drop paging_init() x86: don't reserve hugetlb memory in setup_arch() mm, arch: consolidate hugetlb CMA reservation mm/hugetlb: drop hugetlb_cma_check() Revert "mm/hugetlb: deal with multiple calls to hugetlb_bootmem_alloc" .../driver-api/cxl/linux/early-boot.rst | 2 +- Documentation/mm/memory-model.rst | 3 -- .../translations/zh_CN/mm/memory-model.rst | 2 - arch/alpha/kernel/setup.c | 1 - arch/alpha/mm/init.c | 16 ++++---- arch/arc/mm/init.c | 37 +++++++++--------- arch/arm/include/asm/pgtable.h | 4 +- arch/arm/mm/init.c | 25 ++---------- arch/arm/mm/mmu.c | 10 +---- arch/arm/mm/nommu.c | 10 +---- arch/arm64/include/asm/hugetlb.h | 2 - arch/arm64/mm/hugetlbpage.c | 10 ++--- arch/arm64/mm/init.c | 39 ++++++++----------- arch/csky/kernel/setup.c | 16 ++++---- arch/hexagon/mm/init.c | 19 +++------ arch/loongarch/include/asm/pgtable.h | 2 - arch/loongarch/kernel/setup.c | 10 ----- arch/loongarch/mm/init.c | 6 +-- arch/m68k/mm/init.c | 8 ++-- arch/m68k/mm/mcfmmu.c | 3 -- arch/m68k/mm/motorola.c | 6 +-- arch/m68k/mm/sun3mmu.c | 9 ----- arch/microblaze/mm/init.c | 22 +++++------ arch/mips/include/asm/pgalloc.h | 2 - arch/mips/include/asm/pgtable.h | 2 +- arch/mips/kernel/setup.c | 15 +------ arch/mips/loongson64/numa.c | 10 ++--- arch/mips/mm/init.c | 8 +--- arch/mips/sgi-ip27/ip27-memory.c | 8 +--- arch/nios2/mm/init.c | 12 +++--- arch/openrisc/mm/init.c | 10 +---- arch/parisc/mm/init.c | 11 +----- arch/powerpc/include/asm/hugetlb.h | 5 --- arch/powerpc/include/asm/setup.h | 4 ++ arch/powerpc/kernel/setup-common.c | 1 - arch/powerpc/mm/hugetlbpage.c | 11 ++---- arch/powerpc/mm/mem.c | 27 +++++-------- arch/powerpc/mm/numa.c | 2 - arch/riscv/mm/hugetlbpage.c | 8 ++++ arch/riscv/mm/init.c | 10 +---- arch/s390/kernel/setup.c | 2 - arch/s390/mm/hugetlbpage.c | 8 ++++ arch/s390/mm/init.c | 13 +++---- arch/sh/mm/init.c | 12 +++--- arch/sparc/mm/init_64.c | 17 +++----- arch/sparc/mm/srmmu.c | 17 ++++---- arch/um/kernel/mem.c | 10 ++--- arch/x86/kernel/setup.c | 5 --- arch/x86/mm/hugetlbpage.c | 8 ++++ arch/x86/mm/init.c | 8 +--- arch/x86/mm/init_32.c | 2 - arch/x86/mm/init_64.c | 4 -- arch/x86/mm/mm_internal.h | 1 - arch/xtensa/mm/init.c | 14 +++---- include/linux/hugetlb.h | 12 ++---- include/linux/mm.h | 5 ++- include/linux/mmzone.h | 2 - init/main.c | 1 + mm/hugetlb.c | 13 ------- mm/hugetlb_cma.c | 33 ++++++++-------- mm/hugetlb_cma.h | 5 --- mm/hugetlb_vmemmap.c | 11 ------ mm/internal.h | 6 +++ mm/mm_init.c | 20 ++++++---- 64 files changed, 223 insertions(+), 414 deletions(-) base-commit: 8f0b4cce4481fb22653697cced8d0d04027cb1e8 -- 2.51.0
null
null
null
[PATCH v3 00/29] arch, mm: consolidate hugetlb early reservation
From: "Mike Rapoport (Microsoft)" <rppt@kernel.org> hugetlb_cma_check() was required when the ordering of hugetlb_cma_reserve() and hugetlb_bootmem_alloc() was architecture depended. Since hugetlb_cma_reserve() is always called before hugetlb_bootmem_alloc() there is no need to check whether hugetlb_cma_reserve() was already called. Drop unneeded hugetlb_cma_check() function. Signed-off-by: Mike Rapoport (Microsoft) <rppt@kernel.org> Acked-by: Muchun Song <muchun.song@linux.dev> --- mm/hugetlb.c | 1 - mm/hugetlb_cma.c | 16 +++------------- mm/hugetlb_cma.h | 5 ----- 3 files changed, 3 insertions(+), 19 deletions(-) diff --git a/mm/hugetlb.c b/mm/hugetlb.c index 51273baec9e5..82b322ae3fdc 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -4159,7 +4159,6 @@ static int __init hugetlb_init(void) } } - hugetlb_cma_check(); hugetlb_init_hstates(); gather_bootmem_prealloc(); report_hugepages(); diff --git a/mm/hugetlb_cma.c b/mm/hugetlb_cma.c index b1eb5998282c..f5e79103e110 100644 --- a/mm/hugetlb_cma.c +++ b/mm/hugetlb_cma.c @@ -85,9 +85,6 @@ hugetlb_cma_alloc_bootmem(struct hstate *h, int *nid, bool node_exact) return m; } - -static bool cma_reserve_called __initdata; - static int __init cmdline_parse_hugetlb_cma(char *p) { int nid, count = 0; @@ -149,8 +146,10 @@ void __init hugetlb_cma_reserve(void) return; order = arch_hugetlb_cma_order(); - if (!order) + if (!order) { + pr_warn("hugetlb_cma: the option isn't supported by current arch\n"); return; + } /* * HugeTLB CMA reservation is required for gigantic @@ -159,7 +158,6 @@ void __init hugetlb_cma_reserve(void) * breaking this assumption. */ VM_WARN_ON(order <= MAX_PAGE_ORDER); - cma_reserve_called = true; hugetlb_bootmem_set_nodes(); @@ -253,14 +251,6 @@ void __init hugetlb_cma_reserve(void) hugetlb_cma_size = 0; } -void __init hugetlb_cma_check(void) -{ - if (!hugetlb_cma_size || cma_reserve_called) - return; - - pr_warn("hugetlb_cma: the option isn't supported by current arch\n"); -} - bool hugetlb_cma_exclusive_alloc(void) { return hugetlb_cma_only; diff --git a/mm/hugetlb_cma.h b/mm/hugetlb_cma.h index 2c2ec8a7e134..78186839df3a 100644 --- a/mm/hugetlb_cma.h +++ b/mm/hugetlb_cma.h @@ -8,7 +8,6 @@ struct folio *hugetlb_cma_alloc_folio(int order, gfp_t gfp_mask, int nid, nodemask_t *nodemask); struct huge_bootmem_page *hugetlb_cma_alloc_bootmem(struct hstate *h, int *nid, bool node_exact); -void hugetlb_cma_check(void); bool hugetlb_cma_exclusive_alloc(void); unsigned long hugetlb_cma_total_size(void); void hugetlb_cma_validate_params(void); @@ -31,10 +30,6 @@ struct huge_bootmem_page *hugetlb_cma_alloc_bootmem(struct hstate *h, int *nid, return NULL; } -static inline void hugetlb_cma_check(void) -{ -} - static inline bool hugetlb_cma_exclusive_alloc(void) { return false; -- 2.51.0
{ "author": "Mike Rapoport <rppt@kernel.org>", "date": "Sun, 11 Jan 2026 10:21:02 +0200", "is_openbsd": false, "thread_id": "b9527ed4-7a5c-42e9-8814-b276b3741f63@suse.cz.mbox.gz" }
lkml_critique
lkml
From: "Mike Rapoport (Microsoft)" <rppt@kernel.org> Hi, Order in which early memory reservation for hugetlb happens depends on architecture, on configuration options and on command line parameters. Some architectures rely on the core MM to call hugetlb_bootmem_alloc() while others call it very early to allow pre-allocation of HVO-style vmemmap. When hugetlb_cma is supported by an architecture it is initialized during setup_arch() and then later hugetlb_init code needs to understand did it happen or not. To make everything consistent and unified, both reservation of hugetlb memory from bootmem and creation of CMA areas for hugetlb must be called from core MM initialization and it would have been a simple change. However, HVO-style pre-initialization ordering requirements slightly complicate things and for HVO pre-init to work sparse and memory map should be initialized after hugetlb reservations. This required pulling out the call to free_area_init() out of setup_arch() path and moving it MM initialization and this is what the first 23 patches do. These changes are deliberately split into per-arch patches that change how the zone limits are calculated for each architecture and the patches 22 and 23 just remove the calls to free_area_init() and sprase_init() from arch/*. Patch 24 is a simple cleanup for MIPS. Patches 25 and 26 actually consolidate hugetlb reservations and patches 27 and 28 perform some aftermath cleanups. I tried to trim the distribution list and although it's still quite long if you feel that someone was wrongly excluded please add them back. The changes also available in git: https://git.kernel.org/pub/scm/linux/kernel/git/rppt/linux.git/log/?h=hugetlb-init/v3 v3 changes: * fix empty_zero_page initialization on arm * fix ZONE_DMA limit calculation on powerpc * add Acks v2: https://lore.kernel.org/all/20260102070005.65328-1-rppt@kernel.org * move the hugetlb and memory map initializaion to mm_core_init_early() * add Acks v1: https://lore.kernel.org/all/20251228124001.3624742-1-rppt@kernel.org Klara Modin (1): arm: make initialization of zero page independent of the memory map Mike Rapoport (Microsoft) (28): alpha: introduce arch_zone_limits_init() arc: introduce arch_zone_limits_init() arm: introduce arch_zone_limits_init() arm64: introduce arch_zone_limits_init() csky: introduce arch_zone_limits_init() hexagon: introduce arch_zone_limits_init() loongarch: introduce arch_zone_limits_init() m68k: introduce arch_zone_limits_init() microblaze: introduce arch_zone_limits_init() mips: introduce arch_zone_limits_init() nios2: introduce arch_zone_limits_init() openrisc: introduce arch_zone_limits_init() parisc: introduce arch_zone_limits_init() powerpc: introduce arch_zone_limits_init() riscv: introduce arch_zone_limits_init() s390: introduce arch_zone_limits_init() sh: introduce arch_zone_limits_init() sparc: introduce arch_zone_limits_init() um: introduce arch_zone_limits_init() x86: introduce arch_zone_limits_init() xtensa: introduce arch_zone_limits_init() arch, mm: consolidate initialization of nodes, zones and memory map arch, mm: consolidate initialization of SPARSE memory model mips: drop paging_init() x86: don't reserve hugetlb memory in setup_arch() mm, arch: consolidate hugetlb CMA reservation mm/hugetlb: drop hugetlb_cma_check() Revert "mm/hugetlb: deal with multiple calls to hugetlb_bootmem_alloc" .../driver-api/cxl/linux/early-boot.rst | 2 +- Documentation/mm/memory-model.rst | 3 -- .../translations/zh_CN/mm/memory-model.rst | 2 - arch/alpha/kernel/setup.c | 1 - arch/alpha/mm/init.c | 16 ++++---- arch/arc/mm/init.c | 37 +++++++++--------- arch/arm/include/asm/pgtable.h | 4 +- arch/arm/mm/init.c | 25 ++---------- arch/arm/mm/mmu.c | 10 +---- arch/arm/mm/nommu.c | 10 +---- arch/arm64/include/asm/hugetlb.h | 2 - arch/arm64/mm/hugetlbpage.c | 10 ++--- arch/arm64/mm/init.c | 39 ++++++++----------- arch/csky/kernel/setup.c | 16 ++++---- arch/hexagon/mm/init.c | 19 +++------ arch/loongarch/include/asm/pgtable.h | 2 - arch/loongarch/kernel/setup.c | 10 ----- arch/loongarch/mm/init.c | 6 +-- arch/m68k/mm/init.c | 8 ++-- arch/m68k/mm/mcfmmu.c | 3 -- arch/m68k/mm/motorola.c | 6 +-- arch/m68k/mm/sun3mmu.c | 9 ----- arch/microblaze/mm/init.c | 22 +++++------ arch/mips/include/asm/pgalloc.h | 2 - arch/mips/include/asm/pgtable.h | 2 +- arch/mips/kernel/setup.c | 15 +------ arch/mips/loongson64/numa.c | 10 ++--- arch/mips/mm/init.c | 8 +--- arch/mips/sgi-ip27/ip27-memory.c | 8 +--- arch/nios2/mm/init.c | 12 +++--- arch/openrisc/mm/init.c | 10 +---- arch/parisc/mm/init.c | 11 +----- arch/powerpc/include/asm/hugetlb.h | 5 --- arch/powerpc/include/asm/setup.h | 4 ++ arch/powerpc/kernel/setup-common.c | 1 - arch/powerpc/mm/hugetlbpage.c | 11 ++---- arch/powerpc/mm/mem.c | 27 +++++-------- arch/powerpc/mm/numa.c | 2 - arch/riscv/mm/hugetlbpage.c | 8 ++++ arch/riscv/mm/init.c | 10 +---- arch/s390/kernel/setup.c | 2 - arch/s390/mm/hugetlbpage.c | 8 ++++ arch/s390/mm/init.c | 13 +++---- arch/sh/mm/init.c | 12 +++--- arch/sparc/mm/init_64.c | 17 +++----- arch/sparc/mm/srmmu.c | 17 ++++---- arch/um/kernel/mem.c | 10 ++--- arch/x86/kernel/setup.c | 5 --- arch/x86/mm/hugetlbpage.c | 8 ++++ arch/x86/mm/init.c | 8 +--- arch/x86/mm/init_32.c | 2 - arch/x86/mm/init_64.c | 4 -- arch/x86/mm/mm_internal.h | 1 - arch/xtensa/mm/init.c | 14 +++---- include/linux/hugetlb.h | 12 ++---- include/linux/mm.h | 5 ++- include/linux/mmzone.h | 2 - init/main.c | 1 + mm/hugetlb.c | 13 ------- mm/hugetlb_cma.c | 33 ++++++++-------- mm/hugetlb_cma.h | 5 --- mm/hugetlb_vmemmap.c | 11 ------ mm/internal.h | 6 +++ mm/mm_init.c | 20 ++++++---- 64 files changed, 223 insertions(+), 414 deletions(-) base-commit: 8f0b4cce4481fb22653697cced8d0d04027cb1e8 -- 2.51.0
null
null
null
[PATCH v3 00/29] arch, mm: consolidate hugetlb early reservation
From: "Mike Rapoport (Microsoft)" <rppt@kernel.org> This reverts commit d58b2498200724e4f8c12d71a5953da03c8c8bdf. hugetlb_bootmem_alloc() is called only once, no need to check if it was called already at its entry. Other checks performed during HVO initialization are also no longer necessary because sparse_init() that calls hugetlb_vmemmap_init_early() and hugetlb_vmemmap_init_late() is always called after hugetlb_bootmem_alloc(). Signed-off-by: Mike Rapoport (Microsoft) <rppt@kernel.org> Acked-by: Muchun Song <muchun.song@linux.dev> --- include/linux/hugetlb.h | 6 ------ mm/hugetlb.c | 12 ------------ mm/hugetlb_vmemmap.c | 11 ----------- 3 files changed, 29 deletions(-) diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h index 08fc332e88a7..c8b1a6dd2d46 100644 --- a/include/linux/hugetlb.h +++ b/include/linux/hugetlb.h @@ -175,7 +175,6 @@ extern int sysctl_hugetlb_shm_group __read_mostly; extern struct list_head huge_boot_pages[MAX_NUMNODES]; void hugetlb_bootmem_alloc(void); -bool hugetlb_bootmem_allocated(void); extern nodemask_t hugetlb_bootmem_nodes; void hugetlb_bootmem_set_nodes(void); @@ -1300,11 +1299,6 @@ static inline bool hugetlbfs_pagecache_present( static inline void hugetlb_bootmem_alloc(void) { } - -static inline bool hugetlb_bootmem_allocated(void) -{ - return false; -} #endif /* CONFIG_HUGETLB_PAGE */ static inline spinlock_t *huge_pte_lock(struct hstate *h, diff --git a/mm/hugetlb.c b/mm/hugetlb.c index 82b322ae3fdc..e5a350c83d75 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -4470,21 +4470,11 @@ void __init hugetlb_bootmem_set_nodes(void) } } -static bool __hugetlb_bootmem_allocated __initdata; - -bool __init hugetlb_bootmem_allocated(void) -{ - return __hugetlb_bootmem_allocated; -} - void __init hugetlb_bootmem_alloc(void) { struct hstate *h; int i; - if (__hugetlb_bootmem_allocated) - return; - hugetlb_bootmem_set_nodes(); for (i = 0; i < MAX_NUMNODES; i++) @@ -4498,8 +4488,6 @@ void __init hugetlb_bootmem_alloc(void) if (hstate_is_gigantic(h)) hugetlb_hstate_alloc_pages(h); } - - __hugetlb_bootmem_allocated = true; } /* diff --git a/mm/hugetlb_vmemmap.c b/mm/hugetlb_vmemmap.c index 9d01f883fd71..a9280259e12a 100644 --- a/mm/hugetlb_vmemmap.c +++ b/mm/hugetlb_vmemmap.c @@ -794,14 +794,6 @@ void __init hugetlb_vmemmap_init_early(int nid) struct huge_bootmem_page *m = NULL; void *map; - /* - * Noting to do if bootmem pages were not allocated - * early in boot, or if HVO wasn't enabled in the - * first place. - */ - if (!hugetlb_bootmem_allocated()) - return; - if (!READ_ONCE(vmemmap_optimize_enabled)) return; @@ -847,9 +839,6 @@ void __init hugetlb_vmemmap_init_late(int nid) struct hstate *h; void *map; - if (!hugetlb_bootmem_allocated()) - return; - if (!READ_ONCE(vmemmap_optimize_enabled)) return; -- 2.51.0
{ "author": "Mike Rapoport <rppt@kernel.org>", "date": "Sun, 11 Jan 2026 10:21:03 +0200", "is_openbsd": false, "thread_id": "b9527ed4-7a5c-42e9-8814-b276b3741f63@suse.cz.mbox.gz" }
lkml_critique
lkml
From: "Mike Rapoport (Microsoft)" <rppt@kernel.org> Hi, Order in which early memory reservation for hugetlb happens depends on architecture, on configuration options and on command line parameters. Some architectures rely on the core MM to call hugetlb_bootmem_alloc() while others call it very early to allow pre-allocation of HVO-style vmemmap. When hugetlb_cma is supported by an architecture it is initialized during setup_arch() and then later hugetlb_init code needs to understand did it happen or not. To make everything consistent and unified, both reservation of hugetlb memory from bootmem and creation of CMA areas for hugetlb must be called from core MM initialization and it would have been a simple change. However, HVO-style pre-initialization ordering requirements slightly complicate things and for HVO pre-init to work sparse and memory map should be initialized after hugetlb reservations. This required pulling out the call to free_area_init() out of setup_arch() path and moving it MM initialization and this is what the first 23 patches do. These changes are deliberately split into per-arch patches that change how the zone limits are calculated for each architecture and the patches 22 and 23 just remove the calls to free_area_init() and sprase_init() from arch/*. Patch 24 is a simple cleanup for MIPS. Patches 25 and 26 actually consolidate hugetlb reservations and patches 27 and 28 perform some aftermath cleanups. I tried to trim the distribution list and although it's still quite long if you feel that someone was wrongly excluded please add them back. The changes also available in git: https://git.kernel.org/pub/scm/linux/kernel/git/rppt/linux.git/log/?h=hugetlb-init/v3 v3 changes: * fix empty_zero_page initialization on arm * fix ZONE_DMA limit calculation on powerpc * add Acks v2: https://lore.kernel.org/all/20260102070005.65328-1-rppt@kernel.org * move the hugetlb and memory map initializaion to mm_core_init_early() * add Acks v1: https://lore.kernel.org/all/20251228124001.3624742-1-rppt@kernel.org Klara Modin (1): arm: make initialization of zero page independent of the memory map Mike Rapoport (Microsoft) (28): alpha: introduce arch_zone_limits_init() arc: introduce arch_zone_limits_init() arm: introduce arch_zone_limits_init() arm64: introduce arch_zone_limits_init() csky: introduce arch_zone_limits_init() hexagon: introduce arch_zone_limits_init() loongarch: introduce arch_zone_limits_init() m68k: introduce arch_zone_limits_init() microblaze: introduce arch_zone_limits_init() mips: introduce arch_zone_limits_init() nios2: introduce arch_zone_limits_init() openrisc: introduce arch_zone_limits_init() parisc: introduce arch_zone_limits_init() powerpc: introduce arch_zone_limits_init() riscv: introduce arch_zone_limits_init() s390: introduce arch_zone_limits_init() sh: introduce arch_zone_limits_init() sparc: introduce arch_zone_limits_init() um: introduce arch_zone_limits_init() x86: introduce arch_zone_limits_init() xtensa: introduce arch_zone_limits_init() arch, mm: consolidate initialization of nodes, zones and memory map arch, mm: consolidate initialization of SPARSE memory model mips: drop paging_init() x86: don't reserve hugetlb memory in setup_arch() mm, arch: consolidate hugetlb CMA reservation mm/hugetlb: drop hugetlb_cma_check() Revert "mm/hugetlb: deal with multiple calls to hugetlb_bootmem_alloc" .../driver-api/cxl/linux/early-boot.rst | 2 +- Documentation/mm/memory-model.rst | 3 -- .../translations/zh_CN/mm/memory-model.rst | 2 - arch/alpha/kernel/setup.c | 1 - arch/alpha/mm/init.c | 16 ++++---- arch/arc/mm/init.c | 37 +++++++++--------- arch/arm/include/asm/pgtable.h | 4 +- arch/arm/mm/init.c | 25 ++---------- arch/arm/mm/mmu.c | 10 +---- arch/arm/mm/nommu.c | 10 +---- arch/arm64/include/asm/hugetlb.h | 2 - arch/arm64/mm/hugetlbpage.c | 10 ++--- arch/arm64/mm/init.c | 39 ++++++++----------- arch/csky/kernel/setup.c | 16 ++++---- arch/hexagon/mm/init.c | 19 +++------ arch/loongarch/include/asm/pgtable.h | 2 - arch/loongarch/kernel/setup.c | 10 ----- arch/loongarch/mm/init.c | 6 +-- arch/m68k/mm/init.c | 8 ++-- arch/m68k/mm/mcfmmu.c | 3 -- arch/m68k/mm/motorola.c | 6 +-- arch/m68k/mm/sun3mmu.c | 9 ----- arch/microblaze/mm/init.c | 22 +++++------ arch/mips/include/asm/pgalloc.h | 2 - arch/mips/include/asm/pgtable.h | 2 +- arch/mips/kernel/setup.c | 15 +------ arch/mips/loongson64/numa.c | 10 ++--- arch/mips/mm/init.c | 8 +--- arch/mips/sgi-ip27/ip27-memory.c | 8 +--- arch/nios2/mm/init.c | 12 +++--- arch/openrisc/mm/init.c | 10 +---- arch/parisc/mm/init.c | 11 +----- arch/powerpc/include/asm/hugetlb.h | 5 --- arch/powerpc/include/asm/setup.h | 4 ++ arch/powerpc/kernel/setup-common.c | 1 - arch/powerpc/mm/hugetlbpage.c | 11 ++---- arch/powerpc/mm/mem.c | 27 +++++-------- arch/powerpc/mm/numa.c | 2 - arch/riscv/mm/hugetlbpage.c | 8 ++++ arch/riscv/mm/init.c | 10 +---- arch/s390/kernel/setup.c | 2 - arch/s390/mm/hugetlbpage.c | 8 ++++ arch/s390/mm/init.c | 13 +++---- arch/sh/mm/init.c | 12 +++--- arch/sparc/mm/init_64.c | 17 +++----- arch/sparc/mm/srmmu.c | 17 ++++---- arch/um/kernel/mem.c | 10 ++--- arch/x86/kernel/setup.c | 5 --- arch/x86/mm/hugetlbpage.c | 8 ++++ arch/x86/mm/init.c | 8 +--- arch/x86/mm/init_32.c | 2 - arch/x86/mm/init_64.c | 4 -- arch/x86/mm/mm_internal.h | 1 - arch/xtensa/mm/init.c | 14 +++---- include/linux/hugetlb.h | 12 ++---- include/linux/mm.h | 5 ++- include/linux/mmzone.h | 2 - init/main.c | 1 + mm/hugetlb.c | 13 ------- mm/hugetlb_cma.c | 33 ++++++++-------- mm/hugetlb_cma.h | 5 --- mm/hugetlb_vmemmap.c | 11 ------ mm/internal.h | 6 +++ mm/mm_init.c | 20 ++++++---- 64 files changed, 223 insertions(+), 414 deletions(-) base-commit: 8f0b4cce4481fb22653697cced8d0d04027cb1e8 -- 2.51.0
null
null
null
[PATCH v3 00/29] arch, mm: consolidate hugetlb early reservation
On Sun, Jan 11, 2026 at 10:20:51AM +0200, Mike Rapoport wrote: Hi Mike, ... You move initialization of max_zone_pfns[] to a function, name the function arch_zone_limits_init(), but leave the initializatio of max_zone_pfns[] to zeroes outside. Should not it be brought along? Thanks!
{ "author": "Alexander Gordeev <agordeev@linux.ibm.com>", "date": "Mon, 12 Jan 2026 08:02:48 +0100", "is_openbsd": false, "thread_id": "b9527ed4-7a5c-42e9-8814-b276b3741f63@suse.cz.mbox.gz" }
lkml_critique
lkml
From: "Mike Rapoport (Microsoft)" <rppt@kernel.org> Hi, Order in which early memory reservation for hugetlb happens depends on architecture, on configuration options and on command line parameters. Some architectures rely on the core MM to call hugetlb_bootmem_alloc() while others call it very early to allow pre-allocation of HVO-style vmemmap. When hugetlb_cma is supported by an architecture it is initialized during setup_arch() and then later hugetlb_init code needs to understand did it happen or not. To make everything consistent and unified, both reservation of hugetlb memory from bootmem and creation of CMA areas for hugetlb must be called from core MM initialization and it would have been a simple change. However, HVO-style pre-initialization ordering requirements slightly complicate things and for HVO pre-init to work sparse and memory map should be initialized after hugetlb reservations. This required pulling out the call to free_area_init() out of setup_arch() path and moving it MM initialization and this is what the first 23 patches do. These changes are deliberately split into per-arch patches that change how the zone limits are calculated for each architecture and the patches 22 and 23 just remove the calls to free_area_init() and sprase_init() from arch/*. Patch 24 is a simple cleanup for MIPS. Patches 25 and 26 actually consolidate hugetlb reservations and patches 27 and 28 perform some aftermath cleanups. I tried to trim the distribution list and although it's still quite long if you feel that someone was wrongly excluded please add them back. The changes also available in git: https://git.kernel.org/pub/scm/linux/kernel/git/rppt/linux.git/log/?h=hugetlb-init/v3 v3 changes: * fix empty_zero_page initialization on arm * fix ZONE_DMA limit calculation on powerpc * add Acks v2: https://lore.kernel.org/all/20260102070005.65328-1-rppt@kernel.org * move the hugetlb and memory map initializaion to mm_core_init_early() * add Acks v1: https://lore.kernel.org/all/20251228124001.3624742-1-rppt@kernel.org Klara Modin (1): arm: make initialization of zero page independent of the memory map Mike Rapoport (Microsoft) (28): alpha: introduce arch_zone_limits_init() arc: introduce arch_zone_limits_init() arm: introduce arch_zone_limits_init() arm64: introduce arch_zone_limits_init() csky: introduce arch_zone_limits_init() hexagon: introduce arch_zone_limits_init() loongarch: introduce arch_zone_limits_init() m68k: introduce arch_zone_limits_init() microblaze: introduce arch_zone_limits_init() mips: introduce arch_zone_limits_init() nios2: introduce arch_zone_limits_init() openrisc: introduce arch_zone_limits_init() parisc: introduce arch_zone_limits_init() powerpc: introduce arch_zone_limits_init() riscv: introduce arch_zone_limits_init() s390: introduce arch_zone_limits_init() sh: introduce arch_zone_limits_init() sparc: introduce arch_zone_limits_init() um: introduce arch_zone_limits_init() x86: introduce arch_zone_limits_init() xtensa: introduce arch_zone_limits_init() arch, mm: consolidate initialization of nodes, zones and memory map arch, mm: consolidate initialization of SPARSE memory model mips: drop paging_init() x86: don't reserve hugetlb memory in setup_arch() mm, arch: consolidate hugetlb CMA reservation mm/hugetlb: drop hugetlb_cma_check() Revert "mm/hugetlb: deal with multiple calls to hugetlb_bootmem_alloc" .../driver-api/cxl/linux/early-boot.rst | 2 +- Documentation/mm/memory-model.rst | 3 -- .../translations/zh_CN/mm/memory-model.rst | 2 - arch/alpha/kernel/setup.c | 1 - arch/alpha/mm/init.c | 16 ++++---- arch/arc/mm/init.c | 37 +++++++++--------- arch/arm/include/asm/pgtable.h | 4 +- arch/arm/mm/init.c | 25 ++---------- arch/arm/mm/mmu.c | 10 +---- arch/arm/mm/nommu.c | 10 +---- arch/arm64/include/asm/hugetlb.h | 2 - arch/arm64/mm/hugetlbpage.c | 10 ++--- arch/arm64/mm/init.c | 39 ++++++++----------- arch/csky/kernel/setup.c | 16 ++++---- arch/hexagon/mm/init.c | 19 +++------ arch/loongarch/include/asm/pgtable.h | 2 - arch/loongarch/kernel/setup.c | 10 ----- arch/loongarch/mm/init.c | 6 +-- arch/m68k/mm/init.c | 8 ++-- arch/m68k/mm/mcfmmu.c | 3 -- arch/m68k/mm/motorola.c | 6 +-- arch/m68k/mm/sun3mmu.c | 9 ----- arch/microblaze/mm/init.c | 22 +++++------ arch/mips/include/asm/pgalloc.h | 2 - arch/mips/include/asm/pgtable.h | 2 +- arch/mips/kernel/setup.c | 15 +------ arch/mips/loongson64/numa.c | 10 ++--- arch/mips/mm/init.c | 8 +--- arch/mips/sgi-ip27/ip27-memory.c | 8 +--- arch/nios2/mm/init.c | 12 +++--- arch/openrisc/mm/init.c | 10 +---- arch/parisc/mm/init.c | 11 +----- arch/powerpc/include/asm/hugetlb.h | 5 --- arch/powerpc/include/asm/setup.h | 4 ++ arch/powerpc/kernel/setup-common.c | 1 - arch/powerpc/mm/hugetlbpage.c | 11 ++---- arch/powerpc/mm/mem.c | 27 +++++-------- arch/powerpc/mm/numa.c | 2 - arch/riscv/mm/hugetlbpage.c | 8 ++++ arch/riscv/mm/init.c | 10 +---- arch/s390/kernel/setup.c | 2 - arch/s390/mm/hugetlbpage.c | 8 ++++ arch/s390/mm/init.c | 13 +++---- arch/sh/mm/init.c | 12 +++--- arch/sparc/mm/init_64.c | 17 +++----- arch/sparc/mm/srmmu.c | 17 ++++---- arch/um/kernel/mem.c | 10 ++--- arch/x86/kernel/setup.c | 5 --- arch/x86/mm/hugetlbpage.c | 8 ++++ arch/x86/mm/init.c | 8 +--- arch/x86/mm/init_32.c | 2 - arch/x86/mm/init_64.c | 4 -- arch/x86/mm/mm_internal.h | 1 - arch/xtensa/mm/init.c | 14 +++---- include/linux/hugetlb.h | 12 ++---- include/linux/mm.h | 5 ++- include/linux/mmzone.h | 2 - init/main.c | 1 + mm/hugetlb.c | 13 ------- mm/hugetlb_cma.c | 33 ++++++++-------- mm/hugetlb_cma.h | 5 --- mm/hugetlb_vmemmap.c | 11 ------ mm/internal.h | 6 +++ mm/mm_init.c | 20 ++++++---- 64 files changed, 223 insertions(+), 414 deletions(-) base-commit: 8f0b4cce4481fb22653697cced8d0d04027cb1e8 -- 2.51.0
null
null
null
[PATCH v3 00/29] arch, mm: consolidate hugetlb early reservation
Hi, On Mon, Jan 12, 2026 at 08:02:48AM +0100, Alexander Gordeev wrote: The idea is that is the caller responsibility to initialize max_zone_pfns to zero. After patch 24: "arch, mm: consolidate initialization of SPARSE memory model" there is a single caller of arch_zone_limits_init() and having initialization of max_zone_pfns() there is more optimal than having 20-something of those. -- Sincerely yours, Mike.
{ "author": "Mike Rapoport <rppt@kernel.org>", "date": "Mon, 12 Jan 2026 09:34:40 +0200", "is_openbsd": false, "thread_id": "b9527ed4-7a5c-42e9-8814-b276b3741f63@suse.cz.mbox.gz" }
lkml_critique
lkml
From: "Mike Rapoport (Microsoft)" <rppt@kernel.org> Hi, Order in which early memory reservation for hugetlb happens depends on architecture, on configuration options and on command line parameters. Some architectures rely on the core MM to call hugetlb_bootmem_alloc() while others call it very early to allow pre-allocation of HVO-style vmemmap. When hugetlb_cma is supported by an architecture it is initialized during setup_arch() and then later hugetlb_init code needs to understand did it happen or not. To make everything consistent and unified, both reservation of hugetlb memory from bootmem and creation of CMA areas for hugetlb must be called from core MM initialization and it would have been a simple change. However, HVO-style pre-initialization ordering requirements slightly complicate things and for HVO pre-init to work sparse and memory map should be initialized after hugetlb reservations. This required pulling out the call to free_area_init() out of setup_arch() path and moving it MM initialization and this is what the first 23 patches do. These changes are deliberately split into per-arch patches that change how the zone limits are calculated for each architecture and the patches 22 and 23 just remove the calls to free_area_init() and sprase_init() from arch/*. Patch 24 is a simple cleanup for MIPS. Patches 25 and 26 actually consolidate hugetlb reservations and patches 27 and 28 perform some aftermath cleanups. I tried to trim the distribution list and although it's still quite long if you feel that someone was wrongly excluded please add them back. The changes also available in git: https://git.kernel.org/pub/scm/linux/kernel/git/rppt/linux.git/log/?h=hugetlb-init/v3 v3 changes: * fix empty_zero_page initialization on arm * fix ZONE_DMA limit calculation on powerpc * add Acks v2: https://lore.kernel.org/all/20260102070005.65328-1-rppt@kernel.org * move the hugetlb and memory map initializaion to mm_core_init_early() * add Acks v1: https://lore.kernel.org/all/20251228124001.3624742-1-rppt@kernel.org Klara Modin (1): arm: make initialization of zero page independent of the memory map Mike Rapoport (Microsoft) (28): alpha: introduce arch_zone_limits_init() arc: introduce arch_zone_limits_init() arm: introduce arch_zone_limits_init() arm64: introduce arch_zone_limits_init() csky: introduce arch_zone_limits_init() hexagon: introduce arch_zone_limits_init() loongarch: introduce arch_zone_limits_init() m68k: introduce arch_zone_limits_init() microblaze: introduce arch_zone_limits_init() mips: introduce arch_zone_limits_init() nios2: introduce arch_zone_limits_init() openrisc: introduce arch_zone_limits_init() parisc: introduce arch_zone_limits_init() powerpc: introduce arch_zone_limits_init() riscv: introduce arch_zone_limits_init() s390: introduce arch_zone_limits_init() sh: introduce arch_zone_limits_init() sparc: introduce arch_zone_limits_init() um: introduce arch_zone_limits_init() x86: introduce arch_zone_limits_init() xtensa: introduce arch_zone_limits_init() arch, mm: consolidate initialization of nodes, zones and memory map arch, mm: consolidate initialization of SPARSE memory model mips: drop paging_init() x86: don't reserve hugetlb memory in setup_arch() mm, arch: consolidate hugetlb CMA reservation mm/hugetlb: drop hugetlb_cma_check() Revert "mm/hugetlb: deal with multiple calls to hugetlb_bootmem_alloc" .../driver-api/cxl/linux/early-boot.rst | 2 +- Documentation/mm/memory-model.rst | 3 -- .../translations/zh_CN/mm/memory-model.rst | 2 - arch/alpha/kernel/setup.c | 1 - arch/alpha/mm/init.c | 16 ++++---- arch/arc/mm/init.c | 37 +++++++++--------- arch/arm/include/asm/pgtable.h | 4 +- arch/arm/mm/init.c | 25 ++---------- arch/arm/mm/mmu.c | 10 +---- arch/arm/mm/nommu.c | 10 +---- arch/arm64/include/asm/hugetlb.h | 2 - arch/arm64/mm/hugetlbpage.c | 10 ++--- arch/arm64/mm/init.c | 39 ++++++++----------- arch/csky/kernel/setup.c | 16 ++++---- arch/hexagon/mm/init.c | 19 +++------ arch/loongarch/include/asm/pgtable.h | 2 - arch/loongarch/kernel/setup.c | 10 ----- arch/loongarch/mm/init.c | 6 +-- arch/m68k/mm/init.c | 8 ++-- arch/m68k/mm/mcfmmu.c | 3 -- arch/m68k/mm/motorola.c | 6 +-- arch/m68k/mm/sun3mmu.c | 9 ----- arch/microblaze/mm/init.c | 22 +++++------ arch/mips/include/asm/pgalloc.h | 2 - arch/mips/include/asm/pgtable.h | 2 +- arch/mips/kernel/setup.c | 15 +------ arch/mips/loongson64/numa.c | 10 ++--- arch/mips/mm/init.c | 8 +--- arch/mips/sgi-ip27/ip27-memory.c | 8 +--- arch/nios2/mm/init.c | 12 +++--- arch/openrisc/mm/init.c | 10 +---- arch/parisc/mm/init.c | 11 +----- arch/powerpc/include/asm/hugetlb.h | 5 --- arch/powerpc/include/asm/setup.h | 4 ++ arch/powerpc/kernel/setup-common.c | 1 - arch/powerpc/mm/hugetlbpage.c | 11 ++---- arch/powerpc/mm/mem.c | 27 +++++-------- arch/powerpc/mm/numa.c | 2 - arch/riscv/mm/hugetlbpage.c | 8 ++++ arch/riscv/mm/init.c | 10 +---- arch/s390/kernel/setup.c | 2 - arch/s390/mm/hugetlbpage.c | 8 ++++ arch/s390/mm/init.c | 13 +++---- arch/sh/mm/init.c | 12 +++--- arch/sparc/mm/init_64.c | 17 +++----- arch/sparc/mm/srmmu.c | 17 ++++---- arch/um/kernel/mem.c | 10 ++--- arch/x86/kernel/setup.c | 5 --- arch/x86/mm/hugetlbpage.c | 8 ++++ arch/x86/mm/init.c | 8 +--- arch/x86/mm/init_32.c | 2 - arch/x86/mm/init_64.c | 4 -- arch/x86/mm/mm_internal.h | 1 - arch/xtensa/mm/init.c | 14 +++---- include/linux/hugetlb.h | 12 ++---- include/linux/mm.h | 5 ++- include/linux/mmzone.h | 2 - init/main.c | 1 + mm/hugetlb.c | 13 ------- mm/hugetlb_cma.c | 33 ++++++++-------- mm/hugetlb_cma.h | 5 --- mm/hugetlb_vmemmap.c | 11 ------ mm/internal.h | 6 +++ mm/mm_init.c | 20 ++++++---- 64 files changed, 223 insertions(+), 414 deletions(-) base-commit: 8f0b4cce4481fb22653697cced8d0d04027cb1e8 -- 2.51.0
null
null
null
[PATCH v3 00/29] arch, mm: consolidate hugetlb early reservation
On Sun, 11 Jan 2026 10:20:34 +0200 Mike Rapoport <rppt@kernel.org> wrote: updated, thanks. I'll suppress the ensuing email flood. Kalle, can you please retest sometime, see if the BeagleBone Black boot failure was fixed? Seems we haven't heard back from rmk regarding https://lkml.kernel.org/r/aVrUDeSkqqY9ZCtS@shell.armlinux.org.uk.
{ "author": "Andrew Morton <akpm@linux-foundation.org>", "date": "Mon, 12 Jan 2026 14:23:23 -0800", "is_openbsd": false, "thread_id": "b9527ed4-7a5c-42e9-8814-b276b3741f63@suse.cz.mbox.gz" }
lkml_critique
lkml
From: "Mike Rapoport (Microsoft)" <rppt@kernel.org> Hi, Order in which early memory reservation for hugetlb happens depends on architecture, on configuration options and on command line parameters. Some architectures rely on the core MM to call hugetlb_bootmem_alloc() while others call it very early to allow pre-allocation of HVO-style vmemmap. When hugetlb_cma is supported by an architecture it is initialized during setup_arch() and then later hugetlb_init code needs to understand did it happen or not. To make everything consistent and unified, both reservation of hugetlb memory from bootmem and creation of CMA areas for hugetlb must be called from core MM initialization and it would have been a simple change. However, HVO-style pre-initialization ordering requirements slightly complicate things and for HVO pre-init to work sparse and memory map should be initialized after hugetlb reservations. This required pulling out the call to free_area_init() out of setup_arch() path and moving it MM initialization and this is what the first 23 patches do. These changes are deliberately split into per-arch patches that change how the zone limits are calculated for each architecture and the patches 22 and 23 just remove the calls to free_area_init() and sprase_init() from arch/*. Patch 24 is a simple cleanup for MIPS. Patches 25 and 26 actually consolidate hugetlb reservations and patches 27 and 28 perform some aftermath cleanups. I tried to trim the distribution list and although it's still quite long if you feel that someone was wrongly excluded please add them back. The changes also available in git: https://git.kernel.org/pub/scm/linux/kernel/git/rppt/linux.git/log/?h=hugetlb-init/v3 v3 changes: * fix empty_zero_page initialization on arm * fix ZONE_DMA limit calculation on powerpc * add Acks v2: https://lore.kernel.org/all/20260102070005.65328-1-rppt@kernel.org * move the hugetlb and memory map initializaion to mm_core_init_early() * add Acks v1: https://lore.kernel.org/all/20251228124001.3624742-1-rppt@kernel.org Klara Modin (1): arm: make initialization of zero page independent of the memory map Mike Rapoport (Microsoft) (28): alpha: introduce arch_zone_limits_init() arc: introduce arch_zone_limits_init() arm: introduce arch_zone_limits_init() arm64: introduce arch_zone_limits_init() csky: introduce arch_zone_limits_init() hexagon: introduce arch_zone_limits_init() loongarch: introduce arch_zone_limits_init() m68k: introduce arch_zone_limits_init() microblaze: introduce arch_zone_limits_init() mips: introduce arch_zone_limits_init() nios2: introduce arch_zone_limits_init() openrisc: introduce arch_zone_limits_init() parisc: introduce arch_zone_limits_init() powerpc: introduce arch_zone_limits_init() riscv: introduce arch_zone_limits_init() s390: introduce arch_zone_limits_init() sh: introduce arch_zone_limits_init() sparc: introduce arch_zone_limits_init() um: introduce arch_zone_limits_init() x86: introduce arch_zone_limits_init() xtensa: introduce arch_zone_limits_init() arch, mm: consolidate initialization of nodes, zones and memory map arch, mm: consolidate initialization of SPARSE memory model mips: drop paging_init() x86: don't reserve hugetlb memory in setup_arch() mm, arch: consolidate hugetlb CMA reservation mm/hugetlb: drop hugetlb_cma_check() Revert "mm/hugetlb: deal with multiple calls to hugetlb_bootmem_alloc" .../driver-api/cxl/linux/early-boot.rst | 2 +- Documentation/mm/memory-model.rst | 3 -- .../translations/zh_CN/mm/memory-model.rst | 2 - arch/alpha/kernel/setup.c | 1 - arch/alpha/mm/init.c | 16 ++++---- arch/arc/mm/init.c | 37 +++++++++--------- arch/arm/include/asm/pgtable.h | 4 +- arch/arm/mm/init.c | 25 ++---------- arch/arm/mm/mmu.c | 10 +---- arch/arm/mm/nommu.c | 10 +---- arch/arm64/include/asm/hugetlb.h | 2 - arch/arm64/mm/hugetlbpage.c | 10 ++--- arch/arm64/mm/init.c | 39 ++++++++----------- arch/csky/kernel/setup.c | 16 ++++---- arch/hexagon/mm/init.c | 19 +++------ arch/loongarch/include/asm/pgtable.h | 2 - arch/loongarch/kernel/setup.c | 10 ----- arch/loongarch/mm/init.c | 6 +-- arch/m68k/mm/init.c | 8 ++-- arch/m68k/mm/mcfmmu.c | 3 -- arch/m68k/mm/motorola.c | 6 +-- arch/m68k/mm/sun3mmu.c | 9 ----- arch/microblaze/mm/init.c | 22 +++++------ arch/mips/include/asm/pgalloc.h | 2 - arch/mips/include/asm/pgtable.h | 2 +- arch/mips/kernel/setup.c | 15 +------ arch/mips/loongson64/numa.c | 10 ++--- arch/mips/mm/init.c | 8 +--- arch/mips/sgi-ip27/ip27-memory.c | 8 +--- arch/nios2/mm/init.c | 12 +++--- arch/openrisc/mm/init.c | 10 +---- arch/parisc/mm/init.c | 11 +----- arch/powerpc/include/asm/hugetlb.h | 5 --- arch/powerpc/include/asm/setup.h | 4 ++ arch/powerpc/kernel/setup-common.c | 1 - arch/powerpc/mm/hugetlbpage.c | 11 ++---- arch/powerpc/mm/mem.c | 27 +++++-------- arch/powerpc/mm/numa.c | 2 - arch/riscv/mm/hugetlbpage.c | 8 ++++ arch/riscv/mm/init.c | 10 +---- arch/s390/kernel/setup.c | 2 - arch/s390/mm/hugetlbpage.c | 8 ++++ arch/s390/mm/init.c | 13 +++---- arch/sh/mm/init.c | 12 +++--- arch/sparc/mm/init_64.c | 17 +++----- arch/sparc/mm/srmmu.c | 17 ++++---- arch/um/kernel/mem.c | 10 ++--- arch/x86/kernel/setup.c | 5 --- arch/x86/mm/hugetlbpage.c | 8 ++++ arch/x86/mm/init.c | 8 +--- arch/x86/mm/init_32.c | 2 - arch/x86/mm/init_64.c | 4 -- arch/x86/mm/mm_internal.h | 1 - arch/xtensa/mm/init.c | 14 +++---- include/linux/hugetlb.h | 12 ++---- include/linux/mm.h | 5 ++- include/linux/mmzone.h | 2 - init/main.c | 1 + mm/hugetlb.c | 13 ------- mm/hugetlb_cma.c | 33 ++++++++-------- mm/hugetlb_cma.h | 5 --- mm/hugetlb_vmemmap.c | 11 ------ mm/internal.h | 6 +++ mm/mm_init.c | 20 ++++++---- 64 files changed, 223 insertions(+), 414 deletions(-) base-commit: 8f0b4cce4481fb22653697cced8d0d04027cb1e8 -- 2.51.0
null
null
null
[PATCH v3 00/29] arch, mm: consolidate hugetlb early reservation
On 1/13/26 00:23, Andrew Morton wrote: Hello! I will test this v3 patch ASAP and reply results here. Collective sorry for the delay; I have been busy! BR Kalle
{ "author": "Kalle Niemi <kaleposti@gmail.com>", "date": "Tue, 13 Jan 2026 08:50:33 +0200", "is_openbsd": false, "thread_id": "b9527ed4-7a5c-42e9-8814-b276b3741f63@suse.cz.mbox.gz" }
lkml_critique
lkml
From: "Mike Rapoport (Microsoft)" <rppt@kernel.org> Hi, Order in which early memory reservation for hugetlb happens depends on architecture, on configuration options and on command line parameters. Some architectures rely on the core MM to call hugetlb_bootmem_alloc() while others call it very early to allow pre-allocation of HVO-style vmemmap. When hugetlb_cma is supported by an architecture it is initialized during setup_arch() and then later hugetlb_init code needs to understand did it happen or not. To make everything consistent and unified, both reservation of hugetlb memory from bootmem and creation of CMA areas for hugetlb must be called from core MM initialization and it would have been a simple change. However, HVO-style pre-initialization ordering requirements slightly complicate things and for HVO pre-init to work sparse and memory map should be initialized after hugetlb reservations. This required pulling out the call to free_area_init() out of setup_arch() path and moving it MM initialization and this is what the first 23 patches do. These changes are deliberately split into per-arch patches that change how the zone limits are calculated for each architecture and the patches 22 and 23 just remove the calls to free_area_init() and sprase_init() from arch/*. Patch 24 is a simple cleanup for MIPS. Patches 25 and 26 actually consolidate hugetlb reservations and patches 27 and 28 perform some aftermath cleanups. I tried to trim the distribution list and although it's still quite long if you feel that someone was wrongly excluded please add them back. The changes also available in git: https://git.kernel.org/pub/scm/linux/kernel/git/rppt/linux.git/log/?h=hugetlb-init/v3 v3 changes: * fix empty_zero_page initialization on arm * fix ZONE_DMA limit calculation on powerpc * add Acks v2: https://lore.kernel.org/all/20260102070005.65328-1-rppt@kernel.org * move the hugetlb and memory map initializaion to mm_core_init_early() * add Acks v1: https://lore.kernel.org/all/20251228124001.3624742-1-rppt@kernel.org Klara Modin (1): arm: make initialization of zero page independent of the memory map Mike Rapoport (Microsoft) (28): alpha: introduce arch_zone_limits_init() arc: introduce arch_zone_limits_init() arm: introduce arch_zone_limits_init() arm64: introduce arch_zone_limits_init() csky: introduce arch_zone_limits_init() hexagon: introduce arch_zone_limits_init() loongarch: introduce arch_zone_limits_init() m68k: introduce arch_zone_limits_init() microblaze: introduce arch_zone_limits_init() mips: introduce arch_zone_limits_init() nios2: introduce arch_zone_limits_init() openrisc: introduce arch_zone_limits_init() parisc: introduce arch_zone_limits_init() powerpc: introduce arch_zone_limits_init() riscv: introduce arch_zone_limits_init() s390: introduce arch_zone_limits_init() sh: introduce arch_zone_limits_init() sparc: introduce arch_zone_limits_init() um: introduce arch_zone_limits_init() x86: introduce arch_zone_limits_init() xtensa: introduce arch_zone_limits_init() arch, mm: consolidate initialization of nodes, zones and memory map arch, mm: consolidate initialization of SPARSE memory model mips: drop paging_init() x86: don't reserve hugetlb memory in setup_arch() mm, arch: consolidate hugetlb CMA reservation mm/hugetlb: drop hugetlb_cma_check() Revert "mm/hugetlb: deal with multiple calls to hugetlb_bootmem_alloc" .../driver-api/cxl/linux/early-boot.rst | 2 +- Documentation/mm/memory-model.rst | 3 -- .../translations/zh_CN/mm/memory-model.rst | 2 - arch/alpha/kernel/setup.c | 1 - arch/alpha/mm/init.c | 16 ++++---- arch/arc/mm/init.c | 37 +++++++++--------- arch/arm/include/asm/pgtable.h | 4 +- arch/arm/mm/init.c | 25 ++---------- arch/arm/mm/mmu.c | 10 +---- arch/arm/mm/nommu.c | 10 +---- arch/arm64/include/asm/hugetlb.h | 2 - arch/arm64/mm/hugetlbpage.c | 10 ++--- arch/arm64/mm/init.c | 39 ++++++++----------- arch/csky/kernel/setup.c | 16 ++++---- arch/hexagon/mm/init.c | 19 +++------ arch/loongarch/include/asm/pgtable.h | 2 - arch/loongarch/kernel/setup.c | 10 ----- arch/loongarch/mm/init.c | 6 +-- arch/m68k/mm/init.c | 8 ++-- arch/m68k/mm/mcfmmu.c | 3 -- arch/m68k/mm/motorola.c | 6 +-- arch/m68k/mm/sun3mmu.c | 9 ----- arch/microblaze/mm/init.c | 22 +++++------ arch/mips/include/asm/pgalloc.h | 2 - arch/mips/include/asm/pgtable.h | 2 +- arch/mips/kernel/setup.c | 15 +------ arch/mips/loongson64/numa.c | 10 ++--- arch/mips/mm/init.c | 8 +--- arch/mips/sgi-ip27/ip27-memory.c | 8 +--- arch/nios2/mm/init.c | 12 +++--- arch/openrisc/mm/init.c | 10 +---- arch/parisc/mm/init.c | 11 +----- arch/powerpc/include/asm/hugetlb.h | 5 --- arch/powerpc/include/asm/setup.h | 4 ++ arch/powerpc/kernel/setup-common.c | 1 - arch/powerpc/mm/hugetlbpage.c | 11 ++---- arch/powerpc/mm/mem.c | 27 +++++-------- arch/powerpc/mm/numa.c | 2 - arch/riscv/mm/hugetlbpage.c | 8 ++++ arch/riscv/mm/init.c | 10 +---- arch/s390/kernel/setup.c | 2 - arch/s390/mm/hugetlbpage.c | 8 ++++ arch/s390/mm/init.c | 13 +++---- arch/sh/mm/init.c | 12 +++--- arch/sparc/mm/init_64.c | 17 +++----- arch/sparc/mm/srmmu.c | 17 ++++---- arch/um/kernel/mem.c | 10 ++--- arch/x86/kernel/setup.c | 5 --- arch/x86/mm/hugetlbpage.c | 8 ++++ arch/x86/mm/init.c | 8 +--- arch/x86/mm/init_32.c | 2 - arch/x86/mm/init_64.c | 4 -- arch/x86/mm/mm_internal.h | 1 - arch/xtensa/mm/init.c | 14 +++---- include/linux/hugetlb.h | 12 ++---- include/linux/mm.h | 5 ++- include/linux/mmzone.h | 2 - init/main.c | 1 + mm/hugetlb.c | 13 ------- mm/hugetlb_cma.c | 33 ++++++++-------- mm/hugetlb_cma.h | 5 --- mm/hugetlb_vmemmap.c | 11 ------ mm/internal.h | 6 +++ mm/mm_init.c | 20 ++++++---- 64 files changed, 223 insertions(+), 414 deletions(-) base-commit: 8f0b4cce4481fb22653697cced8d0d04027cb1e8 -- 2.51.0
null
null
null
[PATCH v3 00/29] arch, mm: consolidate hugetlb early reservation
On 1/13/26 08:50, Kalle Niemi wrote: Hello! I tried this patch by cloning https://git.kernel.org/pub/scm/linux/kernel/git/rppt/linux.git/log/?h=hugetlb-init/v3 Boots succesfully on BeagleBone Black! BR Kalle
{ "author": "Kalle Niemi <kaleposti@gmail.com>", "date": "Tue, 13 Jan 2026 10:40:22 +0200", "is_openbsd": false, "thread_id": "b9527ed4-7a5c-42e9-8814-b276b3741f63@suse.cz.mbox.gz" }
lkml_critique
lkml
From: "Mike Rapoport (Microsoft)" <rppt@kernel.org> Hi, Order in which early memory reservation for hugetlb happens depends on architecture, on configuration options and on command line parameters. Some architectures rely on the core MM to call hugetlb_bootmem_alloc() while others call it very early to allow pre-allocation of HVO-style vmemmap. When hugetlb_cma is supported by an architecture it is initialized during setup_arch() and then later hugetlb_init code needs to understand did it happen or not. To make everything consistent and unified, both reservation of hugetlb memory from bootmem and creation of CMA areas for hugetlb must be called from core MM initialization and it would have been a simple change. However, HVO-style pre-initialization ordering requirements slightly complicate things and for HVO pre-init to work sparse and memory map should be initialized after hugetlb reservations. This required pulling out the call to free_area_init() out of setup_arch() path and moving it MM initialization and this is what the first 23 patches do. These changes are deliberately split into per-arch patches that change how the zone limits are calculated for each architecture and the patches 22 and 23 just remove the calls to free_area_init() and sprase_init() from arch/*. Patch 24 is a simple cleanup for MIPS. Patches 25 and 26 actually consolidate hugetlb reservations and patches 27 and 28 perform some aftermath cleanups. I tried to trim the distribution list and although it's still quite long if you feel that someone was wrongly excluded please add them back. The changes also available in git: https://git.kernel.org/pub/scm/linux/kernel/git/rppt/linux.git/log/?h=hugetlb-init/v3 v3 changes: * fix empty_zero_page initialization on arm * fix ZONE_DMA limit calculation on powerpc * add Acks v2: https://lore.kernel.org/all/20260102070005.65328-1-rppt@kernel.org * move the hugetlb and memory map initializaion to mm_core_init_early() * add Acks v1: https://lore.kernel.org/all/20251228124001.3624742-1-rppt@kernel.org Klara Modin (1): arm: make initialization of zero page independent of the memory map Mike Rapoport (Microsoft) (28): alpha: introduce arch_zone_limits_init() arc: introduce arch_zone_limits_init() arm: introduce arch_zone_limits_init() arm64: introduce arch_zone_limits_init() csky: introduce arch_zone_limits_init() hexagon: introduce arch_zone_limits_init() loongarch: introduce arch_zone_limits_init() m68k: introduce arch_zone_limits_init() microblaze: introduce arch_zone_limits_init() mips: introduce arch_zone_limits_init() nios2: introduce arch_zone_limits_init() openrisc: introduce arch_zone_limits_init() parisc: introduce arch_zone_limits_init() powerpc: introduce arch_zone_limits_init() riscv: introduce arch_zone_limits_init() s390: introduce arch_zone_limits_init() sh: introduce arch_zone_limits_init() sparc: introduce arch_zone_limits_init() um: introduce arch_zone_limits_init() x86: introduce arch_zone_limits_init() xtensa: introduce arch_zone_limits_init() arch, mm: consolidate initialization of nodes, zones and memory map arch, mm: consolidate initialization of SPARSE memory model mips: drop paging_init() x86: don't reserve hugetlb memory in setup_arch() mm, arch: consolidate hugetlb CMA reservation mm/hugetlb: drop hugetlb_cma_check() Revert "mm/hugetlb: deal with multiple calls to hugetlb_bootmem_alloc" .../driver-api/cxl/linux/early-boot.rst | 2 +- Documentation/mm/memory-model.rst | 3 -- .../translations/zh_CN/mm/memory-model.rst | 2 - arch/alpha/kernel/setup.c | 1 - arch/alpha/mm/init.c | 16 ++++---- arch/arc/mm/init.c | 37 +++++++++--------- arch/arm/include/asm/pgtable.h | 4 +- arch/arm/mm/init.c | 25 ++---------- arch/arm/mm/mmu.c | 10 +---- arch/arm/mm/nommu.c | 10 +---- arch/arm64/include/asm/hugetlb.h | 2 - arch/arm64/mm/hugetlbpage.c | 10 ++--- arch/arm64/mm/init.c | 39 ++++++++----------- arch/csky/kernel/setup.c | 16 ++++---- arch/hexagon/mm/init.c | 19 +++------ arch/loongarch/include/asm/pgtable.h | 2 - arch/loongarch/kernel/setup.c | 10 ----- arch/loongarch/mm/init.c | 6 +-- arch/m68k/mm/init.c | 8 ++-- arch/m68k/mm/mcfmmu.c | 3 -- arch/m68k/mm/motorola.c | 6 +-- arch/m68k/mm/sun3mmu.c | 9 ----- arch/microblaze/mm/init.c | 22 +++++------ arch/mips/include/asm/pgalloc.h | 2 - arch/mips/include/asm/pgtable.h | 2 +- arch/mips/kernel/setup.c | 15 +------ arch/mips/loongson64/numa.c | 10 ++--- arch/mips/mm/init.c | 8 +--- arch/mips/sgi-ip27/ip27-memory.c | 8 +--- arch/nios2/mm/init.c | 12 +++--- arch/openrisc/mm/init.c | 10 +---- arch/parisc/mm/init.c | 11 +----- arch/powerpc/include/asm/hugetlb.h | 5 --- arch/powerpc/include/asm/setup.h | 4 ++ arch/powerpc/kernel/setup-common.c | 1 - arch/powerpc/mm/hugetlbpage.c | 11 ++---- arch/powerpc/mm/mem.c | 27 +++++-------- arch/powerpc/mm/numa.c | 2 - arch/riscv/mm/hugetlbpage.c | 8 ++++ arch/riscv/mm/init.c | 10 +---- arch/s390/kernel/setup.c | 2 - arch/s390/mm/hugetlbpage.c | 8 ++++ arch/s390/mm/init.c | 13 +++---- arch/sh/mm/init.c | 12 +++--- arch/sparc/mm/init_64.c | 17 +++----- arch/sparc/mm/srmmu.c | 17 ++++---- arch/um/kernel/mem.c | 10 ++--- arch/x86/kernel/setup.c | 5 --- arch/x86/mm/hugetlbpage.c | 8 ++++ arch/x86/mm/init.c | 8 +--- arch/x86/mm/init_32.c | 2 - arch/x86/mm/init_64.c | 4 -- arch/x86/mm/mm_internal.h | 1 - arch/xtensa/mm/init.c | 14 +++---- include/linux/hugetlb.h | 12 ++---- include/linux/mm.h | 5 ++- include/linux/mmzone.h | 2 - init/main.c | 1 + mm/hugetlb.c | 13 ------- mm/hugetlb_cma.c | 33 ++++++++-------- mm/hugetlb_cma.h | 5 --- mm/hugetlb_vmemmap.c | 11 ------ mm/internal.h | 6 +++ mm/mm_init.c | 20 ++++++---- 64 files changed, 223 insertions(+), 414 deletions(-) base-commit: 8f0b4cce4481fb22653697cced8d0d04027cb1e8 -- 2.51.0
null
null
null
[PATCH v3 00/29] arch, mm: consolidate hugetlb early reservation
On 2026-01-11 09:20, Mike Rapoport wrote: Hi Mike, Thanks for this nice cleanup series. This old initialization of max_zone_pfns[ZONE_NORMAL] should also be removed, right? With that removed it makes the local end_pfn variable set but unused, so could you please also remove that one? I know that this whole code block gets removed later, but the cleanup max_zone_pfns[ZONE_NORMAL] and the removal of end_pfn (that is not done later in this version of the series) fits logically in this patch. With the feedback for arch/sparc/mm/init_64.c addressed: Acked-by: Andreas Larsson <andreas@gaisler.com> Cheers, Andreas
{ "author": "Andreas Larsson <andreas@gaisler.com>", "date": "Tue, 13 Jan 2026 13:28:09 +0100", "is_openbsd": false, "thread_id": "b9527ed4-7a5c-42e9-8814-b276b3741f63@suse.cz.mbox.gz" }
lkml_critique
lkml
From: "Mike Rapoport (Microsoft)" <rppt@kernel.org> Hi, Order in which early memory reservation for hugetlb happens depends on architecture, on configuration options and on command line parameters. Some architectures rely on the core MM to call hugetlb_bootmem_alloc() while others call it very early to allow pre-allocation of HVO-style vmemmap. When hugetlb_cma is supported by an architecture it is initialized during setup_arch() and then later hugetlb_init code needs to understand did it happen or not. To make everything consistent and unified, both reservation of hugetlb memory from bootmem and creation of CMA areas for hugetlb must be called from core MM initialization and it would have been a simple change. However, HVO-style pre-initialization ordering requirements slightly complicate things and for HVO pre-init to work sparse and memory map should be initialized after hugetlb reservations. This required pulling out the call to free_area_init() out of setup_arch() path and moving it MM initialization and this is what the first 23 patches do. These changes are deliberately split into per-arch patches that change how the zone limits are calculated for each architecture and the patches 22 and 23 just remove the calls to free_area_init() and sprase_init() from arch/*. Patch 24 is a simple cleanup for MIPS. Patches 25 and 26 actually consolidate hugetlb reservations and patches 27 and 28 perform some aftermath cleanups. I tried to trim the distribution list and although it's still quite long if you feel that someone was wrongly excluded please add them back. The changes also available in git: https://git.kernel.org/pub/scm/linux/kernel/git/rppt/linux.git/log/?h=hugetlb-init/v3 v3 changes: * fix empty_zero_page initialization on arm * fix ZONE_DMA limit calculation on powerpc * add Acks v2: https://lore.kernel.org/all/20260102070005.65328-1-rppt@kernel.org * move the hugetlb and memory map initializaion to mm_core_init_early() * add Acks v1: https://lore.kernel.org/all/20251228124001.3624742-1-rppt@kernel.org Klara Modin (1): arm: make initialization of zero page independent of the memory map Mike Rapoport (Microsoft) (28): alpha: introduce arch_zone_limits_init() arc: introduce arch_zone_limits_init() arm: introduce arch_zone_limits_init() arm64: introduce arch_zone_limits_init() csky: introduce arch_zone_limits_init() hexagon: introduce arch_zone_limits_init() loongarch: introduce arch_zone_limits_init() m68k: introduce arch_zone_limits_init() microblaze: introduce arch_zone_limits_init() mips: introduce arch_zone_limits_init() nios2: introduce arch_zone_limits_init() openrisc: introduce arch_zone_limits_init() parisc: introduce arch_zone_limits_init() powerpc: introduce arch_zone_limits_init() riscv: introduce arch_zone_limits_init() s390: introduce arch_zone_limits_init() sh: introduce arch_zone_limits_init() sparc: introduce arch_zone_limits_init() um: introduce arch_zone_limits_init() x86: introduce arch_zone_limits_init() xtensa: introduce arch_zone_limits_init() arch, mm: consolidate initialization of nodes, zones and memory map arch, mm: consolidate initialization of SPARSE memory model mips: drop paging_init() x86: don't reserve hugetlb memory in setup_arch() mm, arch: consolidate hugetlb CMA reservation mm/hugetlb: drop hugetlb_cma_check() Revert "mm/hugetlb: deal with multiple calls to hugetlb_bootmem_alloc" .../driver-api/cxl/linux/early-boot.rst | 2 +- Documentation/mm/memory-model.rst | 3 -- .../translations/zh_CN/mm/memory-model.rst | 2 - arch/alpha/kernel/setup.c | 1 - arch/alpha/mm/init.c | 16 ++++---- arch/arc/mm/init.c | 37 +++++++++--------- arch/arm/include/asm/pgtable.h | 4 +- arch/arm/mm/init.c | 25 ++---------- arch/arm/mm/mmu.c | 10 +---- arch/arm/mm/nommu.c | 10 +---- arch/arm64/include/asm/hugetlb.h | 2 - arch/arm64/mm/hugetlbpage.c | 10 ++--- arch/arm64/mm/init.c | 39 ++++++++----------- arch/csky/kernel/setup.c | 16 ++++---- arch/hexagon/mm/init.c | 19 +++------ arch/loongarch/include/asm/pgtable.h | 2 - arch/loongarch/kernel/setup.c | 10 ----- arch/loongarch/mm/init.c | 6 +-- arch/m68k/mm/init.c | 8 ++-- arch/m68k/mm/mcfmmu.c | 3 -- arch/m68k/mm/motorola.c | 6 +-- arch/m68k/mm/sun3mmu.c | 9 ----- arch/microblaze/mm/init.c | 22 +++++------ arch/mips/include/asm/pgalloc.h | 2 - arch/mips/include/asm/pgtable.h | 2 +- arch/mips/kernel/setup.c | 15 +------ arch/mips/loongson64/numa.c | 10 ++--- arch/mips/mm/init.c | 8 +--- arch/mips/sgi-ip27/ip27-memory.c | 8 +--- arch/nios2/mm/init.c | 12 +++--- arch/openrisc/mm/init.c | 10 +---- arch/parisc/mm/init.c | 11 +----- arch/powerpc/include/asm/hugetlb.h | 5 --- arch/powerpc/include/asm/setup.h | 4 ++ arch/powerpc/kernel/setup-common.c | 1 - arch/powerpc/mm/hugetlbpage.c | 11 ++---- arch/powerpc/mm/mem.c | 27 +++++-------- arch/powerpc/mm/numa.c | 2 - arch/riscv/mm/hugetlbpage.c | 8 ++++ arch/riscv/mm/init.c | 10 +---- arch/s390/kernel/setup.c | 2 - arch/s390/mm/hugetlbpage.c | 8 ++++ arch/s390/mm/init.c | 13 +++---- arch/sh/mm/init.c | 12 +++--- arch/sparc/mm/init_64.c | 17 +++----- arch/sparc/mm/srmmu.c | 17 ++++---- arch/um/kernel/mem.c | 10 ++--- arch/x86/kernel/setup.c | 5 --- arch/x86/mm/hugetlbpage.c | 8 ++++ arch/x86/mm/init.c | 8 +--- arch/x86/mm/init_32.c | 2 - arch/x86/mm/init_64.c | 4 -- arch/x86/mm/mm_internal.h | 1 - arch/xtensa/mm/init.c | 14 +++---- include/linux/hugetlb.h | 12 ++---- include/linux/mm.h | 5 ++- include/linux/mmzone.h | 2 - init/main.c | 1 + mm/hugetlb.c | 13 ------- mm/hugetlb_cma.c | 33 ++++++++-------- mm/hugetlb_cma.h | 5 --- mm/hugetlb_vmemmap.c | 11 ------ mm/internal.h | 6 +++ mm/mm_init.c | 20 ++++++---- 64 files changed, 223 insertions(+), 414 deletions(-) base-commit: 8f0b4cce4481fb22653697cced8d0d04027cb1e8 -- 2.51.0
null
null
null
[PATCH v3 00/29] arch, mm: consolidate hugetlb early reservation
Mike Rapoport <rppt@kernel.org> writes: This v2 looks good to me. I have also done a basic bootup testing using Linux PPC CI. Please feel free to add: Reviewed-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com>
{ "author": "Ritesh Harjani (IBM) <ritesh.list@gmail.com>", "date": "Tue, 13 Jan 2026 17:59:49 +0530", "is_openbsd": false, "thread_id": "b9527ed4-7a5c-42e9-8814-b276b3741f63@suse.cz.mbox.gz" }
lkml_critique
lkml
From: "Mike Rapoport (Microsoft)" <rppt@kernel.org> Hi, Order in which early memory reservation for hugetlb happens depends on architecture, on configuration options and on command line parameters. Some architectures rely on the core MM to call hugetlb_bootmem_alloc() while others call it very early to allow pre-allocation of HVO-style vmemmap. When hugetlb_cma is supported by an architecture it is initialized during setup_arch() and then later hugetlb_init code needs to understand did it happen or not. To make everything consistent and unified, both reservation of hugetlb memory from bootmem and creation of CMA areas for hugetlb must be called from core MM initialization and it would have been a simple change. However, HVO-style pre-initialization ordering requirements slightly complicate things and for HVO pre-init to work sparse and memory map should be initialized after hugetlb reservations. This required pulling out the call to free_area_init() out of setup_arch() path and moving it MM initialization and this is what the first 23 patches do. These changes are deliberately split into per-arch patches that change how the zone limits are calculated for each architecture and the patches 22 and 23 just remove the calls to free_area_init() and sprase_init() from arch/*. Patch 24 is a simple cleanup for MIPS. Patches 25 and 26 actually consolidate hugetlb reservations and patches 27 and 28 perform some aftermath cleanups. I tried to trim the distribution list and although it's still quite long if you feel that someone was wrongly excluded please add them back. The changes also available in git: https://git.kernel.org/pub/scm/linux/kernel/git/rppt/linux.git/log/?h=hugetlb-init/v3 v3 changes: * fix empty_zero_page initialization on arm * fix ZONE_DMA limit calculation on powerpc * add Acks v2: https://lore.kernel.org/all/20260102070005.65328-1-rppt@kernel.org * move the hugetlb and memory map initializaion to mm_core_init_early() * add Acks v1: https://lore.kernel.org/all/20251228124001.3624742-1-rppt@kernel.org Klara Modin (1): arm: make initialization of zero page independent of the memory map Mike Rapoport (Microsoft) (28): alpha: introduce arch_zone_limits_init() arc: introduce arch_zone_limits_init() arm: introduce arch_zone_limits_init() arm64: introduce arch_zone_limits_init() csky: introduce arch_zone_limits_init() hexagon: introduce arch_zone_limits_init() loongarch: introduce arch_zone_limits_init() m68k: introduce arch_zone_limits_init() microblaze: introduce arch_zone_limits_init() mips: introduce arch_zone_limits_init() nios2: introduce arch_zone_limits_init() openrisc: introduce arch_zone_limits_init() parisc: introduce arch_zone_limits_init() powerpc: introduce arch_zone_limits_init() riscv: introduce arch_zone_limits_init() s390: introduce arch_zone_limits_init() sh: introduce arch_zone_limits_init() sparc: introduce arch_zone_limits_init() um: introduce arch_zone_limits_init() x86: introduce arch_zone_limits_init() xtensa: introduce arch_zone_limits_init() arch, mm: consolidate initialization of nodes, zones and memory map arch, mm: consolidate initialization of SPARSE memory model mips: drop paging_init() x86: don't reserve hugetlb memory in setup_arch() mm, arch: consolidate hugetlb CMA reservation mm/hugetlb: drop hugetlb_cma_check() Revert "mm/hugetlb: deal with multiple calls to hugetlb_bootmem_alloc" .../driver-api/cxl/linux/early-boot.rst | 2 +- Documentation/mm/memory-model.rst | 3 -- .../translations/zh_CN/mm/memory-model.rst | 2 - arch/alpha/kernel/setup.c | 1 - arch/alpha/mm/init.c | 16 ++++---- arch/arc/mm/init.c | 37 +++++++++--------- arch/arm/include/asm/pgtable.h | 4 +- arch/arm/mm/init.c | 25 ++---------- arch/arm/mm/mmu.c | 10 +---- arch/arm/mm/nommu.c | 10 +---- arch/arm64/include/asm/hugetlb.h | 2 - arch/arm64/mm/hugetlbpage.c | 10 ++--- arch/arm64/mm/init.c | 39 ++++++++----------- arch/csky/kernel/setup.c | 16 ++++---- arch/hexagon/mm/init.c | 19 +++------ arch/loongarch/include/asm/pgtable.h | 2 - arch/loongarch/kernel/setup.c | 10 ----- arch/loongarch/mm/init.c | 6 +-- arch/m68k/mm/init.c | 8 ++-- arch/m68k/mm/mcfmmu.c | 3 -- arch/m68k/mm/motorola.c | 6 +-- arch/m68k/mm/sun3mmu.c | 9 ----- arch/microblaze/mm/init.c | 22 +++++------ arch/mips/include/asm/pgalloc.h | 2 - arch/mips/include/asm/pgtable.h | 2 +- arch/mips/kernel/setup.c | 15 +------ arch/mips/loongson64/numa.c | 10 ++--- arch/mips/mm/init.c | 8 +--- arch/mips/sgi-ip27/ip27-memory.c | 8 +--- arch/nios2/mm/init.c | 12 +++--- arch/openrisc/mm/init.c | 10 +---- arch/parisc/mm/init.c | 11 +----- arch/powerpc/include/asm/hugetlb.h | 5 --- arch/powerpc/include/asm/setup.h | 4 ++ arch/powerpc/kernel/setup-common.c | 1 - arch/powerpc/mm/hugetlbpage.c | 11 ++---- arch/powerpc/mm/mem.c | 27 +++++-------- arch/powerpc/mm/numa.c | 2 - arch/riscv/mm/hugetlbpage.c | 8 ++++ arch/riscv/mm/init.c | 10 +---- arch/s390/kernel/setup.c | 2 - arch/s390/mm/hugetlbpage.c | 8 ++++ arch/s390/mm/init.c | 13 +++---- arch/sh/mm/init.c | 12 +++--- arch/sparc/mm/init_64.c | 17 +++----- arch/sparc/mm/srmmu.c | 17 ++++---- arch/um/kernel/mem.c | 10 ++--- arch/x86/kernel/setup.c | 5 --- arch/x86/mm/hugetlbpage.c | 8 ++++ arch/x86/mm/init.c | 8 +--- arch/x86/mm/init_32.c | 2 - arch/x86/mm/init_64.c | 4 -- arch/x86/mm/mm_internal.h | 1 - arch/xtensa/mm/init.c | 14 +++---- include/linux/hugetlb.h | 12 ++---- include/linux/mm.h | 5 ++- include/linux/mmzone.h | 2 - init/main.c | 1 + mm/hugetlb.c | 13 ------- mm/hugetlb_cma.c | 33 ++++++++-------- mm/hugetlb_cma.h | 5 --- mm/hugetlb_vmemmap.c | 11 ------ mm/internal.h | 6 +++ mm/mm_init.c | 20 ++++++---- 64 files changed, 223 insertions(+), 414 deletions(-) base-commit: 8f0b4cce4481fb22653697cced8d0d04027cb1e8 -- 2.51.0
null
null
null
[PATCH v3 00/29] arch, mm: consolidate hugetlb early reservation
Hello: This series was applied to riscv/linux.git (fixes) by Andrew Morton <akpm@linux-foundation.org>: On Sun, 11 Jan 2026 10:20:34 +0200 you wrote: Here is the summary with links: - [v3,01/29] alpha: introduce arch_zone_limits_init() https://git.kernel.org/riscv/c/ba1c86874e25 - [v3,02/29] arc: introduce arch_zone_limits_init() https://git.kernel.org/riscv/c/7988e8518904 - [v3,03/29] arm: introduce arch_zone_limits_init() https://git.kernel.org/riscv/c/30a66f8a8cd3 - [v3,04/29] arm: make initialization of zero page independent of the memory map https://git.kernel.org/riscv/c/18b7cc70dea8 - [v3,05/29] arm64: introduce arch_zone_limits_init() https://git.kernel.org/riscv/c/60b35af0a6aa - [v3,06/29] csky: introduce arch_zone_limits_init() https://git.kernel.org/riscv/c/37318eb97f23 - [v3,07/29] hexagon: introduce arch_zone_limits_init() https://git.kernel.org/riscv/c/934afdf7f4cc - [v3,08/29] loongarch: introduce arch_zone_limits_init() https://git.kernel.org/riscv/c/63cadcb731c9 - [v3,09/29] m68k: introduce arch_zone_limits_init() https://git.kernel.org/riscv/c/41b08a7abf89 - [v3,10/29] microblaze: introduce arch_zone_limits_init() https://git.kernel.org/riscv/c/2ce38c9ae840 - [v3,11/29] mips: introduce arch_zone_limits_init() https://git.kernel.org/riscv/c/f61385e29444 - [v3,12/29] nios2: introduce arch_zone_limits_init() https://git.kernel.org/riscv/c/3b1b0e5797bd - [v3,13/29] openrisc: introduce arch_zone_limits_init() https://git.kernel.org/riscv/c/1d28b1142383 - [v3,14/29] parisc: introduce arch_zone_limits_init() https://git.kernel.org/riscv/c/950696afe400 - [v3,15/29] powerpc: introduce arch_zone_limits_init() https://git.kernel.org/riscv/c/27bebe446f8d - [v3,16/29] riscv: introduce arch_zone_limits_init() https://git.kernel.org/riscv/c/db8cdb0ad603 - [v3,17/29] s390: introduce arch_zone_limits_init() https://git.kernel.org/riscv/c/76c4c463bbc0 - [v3,18/29] sh: introduce arch_zone_limits_init() https://git.kernel.org/riscv/c/8bfa6c2259f4 - [v3,19/29] sparc: introduce arch_zone_limits_init() https://git.kernel.org/riscv/c/6ad7ea22cf6f - [v3,20/29] um: introduce arch_zone_limits_init() https://git.kernel.org/riscv/c/531de7f02d51 - [v3,21/29] x86: introduce arch_zone_limits_init() https://git.kernel.org/riscv/c/34f6b9c6e417 - [v3,22/29] xtensa: introduce arch_zone_limits_init() https://git.kernel.org/riscv/c/2d3c8c5f33e0 - [v3,23/29] arch, mm: consolidate initialization of nodes, zones and memory map https://git.kernel.org/riscv/c/d49004c5f0c1 - [v3,24/29] arch, mm: consolidate initialization of SPARSE memory model https://git.kernel.org/riscv/c/4267739cabb8 - [v3,25/29] mips: drop paging_init() https://git.kernel.org/riscv/c/5dea39496c68 - [v3,26/29] x86: don't reserve hugetlb memory in setup_arch() https://git.kernel.org/riscv/c/6632314fddc4 - [v3,27/29] mm, arch: consolidate hugetlb CMA reservation https://git.kernel.org/riscv/c/9fac145b6d3f - [v3,28/29] mm/hugetlb: drop hugetlb_cma_check() https://git.kernel.org/riscv/c/7a9c0bf0aec6 - [v3,29/29] Revert "mm/hugetlb: deal with multiple calls to hugetlb_bootmem_alloc" https://git.kernel.org/riscv/c/743758ccf8be You are awesome, thank you! -- Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html
{ "author": "patchwork-bot+linux-riscv@kernel.org", "date": "Fri, 20 Feb 2026 04:10:42 +0000", "is_openbsd": false, "thread_id": "b9527ed4-7a5c-42e9-8814-b276b3741f63@suse.cz.mbox.gz" }
lkml_critique
lkml
From: "Mike Rapoport (Microsoft)" <rppt@kernel.org> Hi, Order in which early memory reservation for hugetlb happens depends on architecture, on configuration options and on command line parameters. Some architectures rely on the core MM to call hugetlb_bootmem_alloc() while others call it very early to allow pre-allocation of HVO-style vmemmap. When hugetlb_cma is supported by an architecture it is initialized during setup_arch() and then later hugetlb_init code needs to understand did it happen or not. To make everything consistent and unified, both reservation of hugetlb memory from bootmem and creation of CMA areas for hugetlb must be called from core MM initialization and it would have been a simple change. However, HVO-style pre-initialization ordering requirements slightly complicate things and for HVO pre-init to work sparse and memory map should be initialized after hugetlb reservations. This required pulling out the call to free_area_init() out of setup_arch() path and moving it MM initialization and this is what the first 23 patches do. These changes are deliberately split into per-arch patches that change how the zone limits are calculated for each architecture and the patches 22 and 23 just remove the calls to free_area_init() and sprase_init() from arch/*. Patch 24 is a simple cleanup for MIPS. Patches 25 and 26 actually consolidate hugetlb reservations and patches 27 and 28 perform some aftermath cleanups. I tried to trim the distribution list and although it's still quite long if you feel that someone was wrongly excluded please add them back. The changes also available in git: https://git.kernel.org/pub/scm/linux/kernel/git/rppt/linux.git/log/?h=hugetlb-init/v3 v3 changes: * fix empty_zero_page initialization on arm * fix ZONE_DMA limit calculation on powerpc * add Acks v2: https://lore.kernel.org/all/20260102070005.65328-1-rppt@kernel.org * move the hugetlb and memory map initializaion to mm_core_init_early() * add Acks v1: https://lore.kernel.org/all/20251228124001.3624742-1-rppt@kernel.org Klara Modin (1): arm: make initialization of zero page independent of the memory map Mike Rapoport (Microsoft) (28): alpha: introduce arch_zone_limits_init() arc: introduce arch_zone_limits_init() arm: introduce arch_zone_limits_init() arm64: introduce arch_zone_limits_init() csky: introduce arch_zone_limits_init() hexagon: introduce arch_zone_limits_init() loongarch: introduce arch_zone_limits_init() m68k: introduce arch_zone_limits_init() microblaze: introduce arch_zone_limits_init() mips: introduce arch_zone_limits_init() nios2: introduce arch_zone_limits_init() openrisc: introduce arch_zone_limits_init() parisc: introduce arch_zone_limits_init() powerpc: introduce arch_zone_limits_init() riscv: introduce arch_zone_limits_init() s390: introduce arch_zone_limits_init() sh: introduce arch_zone_limits_init() sparc: introduce arch_zone_limits_init() um: introduce arch_zone_limits_init() x86: introduce arch_zone_limits_init() xtensa: introduce arch_zone_limits_init() arch, mm: consolidate initialization of nodes, zones and memory map arch, mm: consolidate initialization of SPARSE memory model mips: drop paging_init() x86: don't reserve hugetlb memory in setup_arch() mm, arch: consolidate hugetlb CMA reservation mm/hugetlb: drop hugetlb_cma_check() Revert "mm/hugetlb: deal with multiple calls to hugetlb_bootmem_alloc" .../driver-api/cxl/linux/early-boot.rst | 2 +- Documentation/mm/memory-model.rst | 3 -- .../translations/zh_CN/mm/memory-model.rst | 2 - arch/alpha/kernel/setup.c | 1 - arch/alpha/mm/init.c | 16 ++++---- arch/arc/mm/init.c | 37 +++++++++--------- arch/arm/include/asm/pgtable.h | 4 +- arch/arm/mm/init.c | 25 ++---------- arch/arm/mm/mmu.c | 10 +---- arch/arm/mm/nommu.c | 10 +---- arch/arm64/include/asm/hugetlb.h | 2 - arch/arm64/mm/hugetlbpage.c | 10 ++--- arch/arm64/mm/init.c | 39 ++++++++----------- arch/csky/kernel/setup.c | 16 ++++---- arch/hexagon/mm/init.c | 19 +++------ arch/loongarch/include/asm/pgtable.h | 2 - arch/loongarch/kernel/setup.c | 10 ----- arch/loongarch/mm/init.c | 6 +-- arch/m68k/mm/init.c | 8 ++-- arch/m68k/mm/mcfmmu.c | 3 -- arch/m68k/mm/motorola.c | 6 +-- arch/m68k/mm/sun3mmu.c | 9 ----- arch/microblaze/mm/init.c | 22 +++++------ arch/mips/include/asm/pgalloc.h | 2 - arch/mips/include/asm/pgtable.h | 2 +- arch/mips/kernel/setup.c | 15 +------ arch/mips/loongson64/numa.c | 10 ++--- arch/mips/mm/init.c | 8 +--- arch/mips/sgi-ip27/ip27-memory.c | 8 +--- arch/nios2/mm/init.c | 12 +++--- arch/openrisc/mm/init.c | 10 +---- arch/parisc/mm/init.c | 11 +----- arch/powerpc/include/asm/hugetlb.h | 5 --- arch/powerpc/include/asm/setup.h | 4 ++ arch/powerpc/kernel/setup-common.c | 1 - arch/powerpc/mm/hugetlbpage.c | 11 ++---- arch/powerpc/mm/mem.c | 27 +++++-------- arch/powerpc/mm/numa.c | 2 - arch/riscv/mm/hugetlbpage.c | 8 ++++ arch/riscv/mm/init.c | 10 +---- arch/s390/kernel/setup.c | 2 - arch/s390/mm/hugetlbpage.c | 8 ++++ arch/s390/mm/init.c | 13 +++---- arch/sh/mm/init.c | 12 +++--- arch/sparc/mm/init_64.c | 17 +++----- arch/sparc/mm/srmmu.c | 17 ++++---- arch/um/kernel/mem.c | 10 ++--- arch/x86/kernel/setup.c | 5 --- arch/x86/mm/hugetlbpage.c | 8 ++++ arch/x86/mm/init.c | 8 +--- arch/x86/mm/init_32.c | 2 - arch/x86/mm/init_64.c | 4 -- arch/x86/mm/mm_internal.h | 1 - arch/xtensa/mm/init.c | 14 +++---- include/linux/hugetlb.h | 12 ++---- include/linux/mm.h | 5 ++- include/linux/mmzone.h | 2 - init/main.c | 1 + mm/hugetlb.c | 13 ------- mm/hugetlb_cma.c | 33 ++++++++-------- mm/hugetlb_cma.h | 5 --- mm/hugetlb_vmemmap.c | 11 ------ mm/internal.h | 6 +++ mm/mm_init.c | 20 ++++++---- 64 files changed, 223 insertions(+), 414 deletions(-) base-commit: 8f0b4cce4481fb22653697cced8d0d04027cb1e8 -- 2.51.0
null
null
null
[PATCH v3 00/29] arch, mm: consolidate hugetlb early reservation
Hi everyone, On Sun, Jan 11, 2026 at 10:20:58AM +0200, Mike Rapoport wrote: This broke the boot on RISC-V 32-bit (rv32_defconfig) for me. Specifically if sparse_init() is *not* called before the following callchain, the kernel dies at that point. start_kernel() setup_arch() apply_boot_alternatives() _apply_alternatives() riscv_cpufeature_patch_func() patch_text_nosync() riscv_alternative_fix_offsets() Simple reproducer, using kunit: ./tools/testing/kunit/kunit.py run --raw_output=all --make_options LLVM=1 --arch riscv32 --kconfig_add CONFIG_SPARSEMEM_MANUAL=y --kconfig_add CONFIG_SPARSEMEM=y (...)
{ "author": "Thomas =?utf-8?Q?Wei=C3=9Fschuh?= <thomas.weissschuh@linutronix.de>", "date": "Mon, 23 Feb 2026 14:52:45 +0100", "is_openbsd": false, "thread_id": "b9527ed4-7a5c-42e9-8814-b276b3741f63@suse.cz.mbox.gz" }