CVS commit: src/sys/external/bsd/drm2/linux
Module Name:src Committed By: riastradh Date: Mon Jun 24 21:23:53 UTC 2024 Modified Files: src/sys/external/bsd/drm2/linux: linux_pci.c Log Message: linux_pci: Fix shifto in pci_get_class. It looks like Linux's pci_get_class also matches the interface part of the PCI class register (but not the revision part), and I hadn't noticed that in the previous shim structured differently. To generate a diff of this commit: cvs rdiff -u -r1.29 -r1.30 src/sys/external/bsd/drm2/linux/linux_pci.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/external/bsd/drm2/linux/linux_pci.c diff -u src/sys/external/bsd/drm2/linux/linux_pci.c:1.29 src/sys/external/bsd/drm2/linux/linux_pci.c:1.30 --- src/sys/external/bsd/drm2/linux/linux_pci.c:1.29 Sun Jun 23 00:53:48 2024 +++ src/sys/external/bsd/drm2/linux/linux_pci.c Mon Jun 24 21:23:53 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_pci.c,v 1.29 2024/06/23 00:53:48 riastradh Exp $ */ +/* $NetBSD: linux_pci.c,v 1.30 2024/06/24 21:23:53 riastradh Exp $ */ /*- * Copyright (c) 2013 The NetBSD Foundation, Inc. @@ -35,7 +35,7 @@ #endif #include -__KERNEL_RCSID(0, "$NetBSD: linux_pci.c,v 1.29 2024/06/23 00:53:48 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux_pci.c,v 1.30 2024/06/24 21:23:53 riastradh Exp $"); #if NACPICA > 0 #include @@ -621,7 +621,7 @@ pci_dev_put(struct pci_dev *pdev) } struct pci_get_class_state { - uint32_t class_subclass_shifted; + uint32_t class_subclass_interface; const struct pci_dev *from; }; @@ -639,17 +639,19 @@ pci_get_class_match(void *cookie, const C->from = NULL; return 0; } - if (C->class_subclass_shifted != - (PCI_CLASS(pa->pa_class) << 8 | PCI_SUBCLASS(pa->pa_class))) + if (C->class_subclass_interface != + (PCI_CLASS(pa->pa_class) << 16 | + PCI_SUBCLASS(pa->pa_class) << 8 | + PCI_INTERFACE(pa->pa_class))) return 0; return 1; } struct pci_dev * -pci_get_class(uint32_t class_subclass_shifted, struct pci_dev *from) +pci_get_class(uint32_t class_subclass_interface, struct pci_dev *from) { - struct pci_get_class_state context = {class_subclass_shifted, from}, + struct pci_get_class_state context = {class_subclass_interface, from}, *C = struct pci_attach_args pa; struct pci_dev *pdev = NULL;
CVS commit: src/sys/external/bsd/drm2/linux
Module Name:src Committed By: riastradh Date: Mon Jun 24 21:23:53 UTC 2024 Modified Files: src/sys/external/bsd/drm2/linux: linux_pci.c Log Message: linux_pci: Fix shifto in pci_get_class. It looks like Linux's pci_get_class also matches the interface part of the PCI class register (but not the revision part), and I hadn't noticed that in the previous shim structured differently. To generate a diff of this commit: cvs rdiff -u -r1.29 -r1.30 src/sys/external/bsd/drm2/linux/linux_pci.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/external/bsd/drm2/linux
Module Name:src Committed By: riastradh Date: Sun Jun 23 00:53:48 UTC 2024 Modified Files: src/sys/external/bsd/drm2/linux: linux_pci.c Log Message: linux_pci: Nix pci enumeration kludges. Now that we can pass a cookie through, this stuff will be a little less fragile. To generate a diff of this commit: cvs rdiff -u -r1.28 -r1.29 src/sys/external/bsd/drm2/linux/linux_pci.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/external/bsd/drm2/linux/linux_pci.c diff -u src/sys/external/bsd/drm2/linux/linux_pci.c:1.28 src/sys/external/bsd/drm2/linux/linux_pci.c:1.29 --- src/sys/external/bsd/drm2/linux/linux_pci.c:1.28 Sun May 19 17:36:08 2024 +++ src/sys/external/bsd/drm2/linux/linux_pci.c Sun Jun 23 00:53:48 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_pci.c,v 1.28 2024/05/19 17:36:08 riastradh Exp $ */ +/* $NetBSD: linux_pci.c,v 1.29 2024/06/23 00:53:48 riastradh Exp $ */ /*- * Copyright (c) 2013 The NetBSD Foundation, Inc. @@ -35,7 +35,7 @@ #endif #include -__KERNEL_RCSID(0, "$NetBSD: linux_pci.c,v 1.28 2024/05/19 17:36:08 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux_pci.c,v 1.29 2024/06/23 00:53:48 riastradh Exp $"); #if NACPICA > 0 #include @@ -573,24 +573,20 @@ pci_bus_alloc_resource(struct pci_bus *b return 0; } -/* - * XXX Mega-kludgerific! pci_get_bus_and_slot and pci_get_class are - * defined only for their single purposes in i915drm, in - * i915_get_bridge_dev and intel_detect_pch. We can't define them more - * generally without adapting pci_find_device (and pci_enumerate_bus - * internally) to pass a cookie through. - */ +struct pci_domain_bus_and_slot { + int domain, bus, slot; +}; static int -pci_kludgey_match_bus0_dev0_func0(const struct pci_attach_args *pa) +pci_match_domain_bus_and_slot(void *cookie, const struct pci_attach_args *pa) { + const struct pci_domain_bus_and_slot *C = cookie; - /* XXX domain */ - if (pa->pa_bus != 0) + if (pci_get_segment(pa->pa_pc) != C->domain) return 0; - if (pa->pa_device != 0) + if (pa->pa_bus != C->bus) return 0; - if (pa->pa_function != 0) + if (PCI_DEVFN(pa->pa_device, pa->pa_function) != C->slot) return 0; return 1; @@ -600,12 +596,10 @@ struct pci_dev * pci_get_domain_bus_and_slot(int domain, int bus, int slot) { struct pci_attach_args pa; + struct pci_domain_bus_and_slot context = {domain, bus, slot}, + *C = - KASSERT(domain == 0); - KASSERT(bus == 0); - KASSERT(slot == PCI_DEVFN(0, 0)); - - if (!pci_find_device(, _kludgey_match_bus0_dev0_func0)) + if (!pci_find_device1(, _match_domain_bus_and_slot, C)) return NULL; struct pci_dev *const pdev = kmem_zalloc(sizeof(*pdev), KM_SLEEP); @@ -614,101 +608,59 @@ pci_get_domain_bus_and_slot(int domain, return pdev; } -static int -pci_kludgey_match_isa_bridge(const struct pci_attach_args *pa) -{ - - if (PCI_CLASS(pa->pa_class) != PCI_CLASS_BRIDGE) - return 0; - if (PCI_SUBCLASS(pa->pa_class) != PCI_SUBCLASS_BRIDGE_ISA) - return 0; - - return 1; -} - -static int -pci_kludgey_match_other_display(const struct pci_attach_args *pa) +void +pci_dev_put(struct pci_dev *pdev) { - if (PCI_CLASS(pa->pa_class) != PCI_CLASS_DISPLAY) - return 0; - if (PCI_SUBCLASS(pa->pa_class) != PCI_SUBCLASS_DISPLAY_MISC) - return 0; + if (pdev == NULL) + return; - return 1; + KASSERT(ISSET(pdev->pd_kludges, NBPCI_KLUDGE_GET_MUMBLE)); + kmem_free(pdev->bus, sizeof(*pdev->bus)); + kmem_free(pdev, sizeof(*pdev)); } -static int -pci_kludgey_match_vga_display(const struct pci_attach_args *pa) -{ - - if (PCI_CLASS(pa->pa_class) != PCI_CLASS_DISPLAY) - return 0; - if (PCI_SUBCLASS(pa->pa_class) != PCI_SUBCLASS_DISPLAY_VGA) - return 0; - - return 1; -} +struct pci_get_class_state { + uint32_t class_subclass_shifted; + const struct pci_dev *from; +}; static int -pci_kludgey_match_3d_display(const struct pci_attach_args *pa) +pci_get_class_match(void *cookie, const struct pci_attach_args *pa) { + struct pci_get_class_state *C = cookie; - if (PCI_CLASS(pa->pa_class) != PCI_CLASS_DISPLAY) + if (C->from) { + if ((pci_get_segment(C->from->pd_pa.pa_pc) == + pci_get_segment(pa->pa_pc)) && + C->from->pd_pa.pa_bus == pa->pa_bus && + C->from->pd_pa.pa_device == pa->pa_device && + C->from->pd_pa.pa_function == pa->pa_function) + C->from = NULL; return 0; - if (PCI_SUBCLASS(pa->pa_class) != PCI_SUBCLASS_DISPLAY_3D) + } + if (C->class_subclass_shifted != + (PCI_CLASS(pa->pa_class) << 8 | PCI_SUBCLASS(pa->pa_class))) return 0; return 1; } -void -pci_dev_put(struct pci_dev *pdev) -{ - - if (pdev == NULL) - return; - - KASSERT(ISSET(pdev->pd_kludges, NBPCI_KLUDGE_GET_MUMBLE)); - kmem_free(pdev->bus, sizeof(*pdev->bus)); - kmem_free(pdev, sizeof(*pdev)); -} - -struct pci_dev * /* XXX i915/amdgpu kludge */ +struct pci_dev * pci_get_class(uint32_t class_subclass_shifted, struct pci_dev *from) { + struct
CVS commit: src/sys/external/bsd/drm2/linux
Module Name:src Committed By: riastradh Date: Sun Jun 23 00:53:48 UTC 2024 Modified Files: src/sys/external/bsd/drm2/linux: linux_pci.c Log Message: linux_pci: Nix pci enumeration kludges. Now that we can pass a cookie through, this stuff will be a little less fragile. To generate a diff of this commit: cvs rdiff -u -r1.28 -r1.29 src/sys/external/bsd/drm2/linux/linux_pci.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/external/bsd/drm2/linux
Module Name:src Committed By: riastradh Date: Wed May 22 15:59:25 UTC 2024 Modified Files: src/sys/external/bsd/drm2/linux: linux_xa.c Log Message: linux_xa: Delete and replace collision in xa_store as intended. Don't free the colliding node that's still in the tree. Noted by rjs@. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/sys/external/bsd/drm2/linux/linux_xa.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/external/bsd/drm2/linux/linux_xa.c diff -u src/sys/external/bsd/drm2/linux/linux_xa.c:1.3 src/sys/external/bsd/drm2/linux/linux_xa.c:1.4 --- src/sys/external/bsd/drm2/linux/linux_xa.c:1.3 Sun Dec 19 12:05:25 2021 +++ src/sys/external/bsd/drm2/linux/linux_xa.c Wed May 22 15:59:25 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_xa.c,v 1.3 2021/12/19 12:05:25 riastradh Exp $ */ +/* $NetBSD: linux_xa.c,v 1.4 2024/05/22 15:59:25 riastradh Exp $ */ /*- * Copyright (c) 2021 The NetBSD Foundation, Inc. @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: linux_xa.c,v 1.3 2021/12/19 12:05:25 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux_xa.c,v 1.4 2024/05/22 15:59:25 riastradh Exp $"); /* * This is a lame-o implementation of the Linux xarray data type, which @@ -124,7 +124,7 @@ xa_load(struct xarray *xa, unsigned long void * xa_store(struct xarray *xa, unsigned long key, void *datum, gfp_t gfp) { - struct node *n, *collision; + struct node *n, *collision, *recollision; KASSERT(datum != NULL); KASSERT(((uintptr_t)datum & 0x3) == 0); @@ -137,6 +137,11 @@ xa_store(struct xarray *xa, unsigned lon mutex_enter(>xa_lock); collision = rb_tree_insert_node(>xa_tree, n); + if (collision != n) { + rb_tree_remove_node(>xa_tree, n); + recollision = rb_tree_insert_node(>xa_tree, n); + KASSERT(recollision == n); + } mutex_exit(>xa_lock); if (collision != n) {
CVS commit: src/sys/external/bsd/drm2/linux
Module Name:src Committed By: riastradh Date: Wed May 22 15:59:25 UTC 2024 Modified Files: src/sys/external/bsd/drm2/linux: linux_xa.c Log Message: linux_xa: Delete and replace collision in xa_store as intended. Don't free the colliding node that's still in the tree. Noted by rjs@. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/sys/external/bsd/drm2/linux/linux_xa.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/external/bsd/drm2/linux
Module Name:src Committed By: riastradh Date: Mon May 20 11:35:11 UTC 2024 Modified Files: src/sys/external/bsd/drm2/linux: linux_dma_buf.c Log Message: drm: Fix missing bounds checks in dma buf mmap. To generate a diff of this commit: cvs rdiff -u -r1.16 -r1.17 src/sys/external/bsd/drm2/linux/linux_dma_buf.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/external/bsd/drm2/linux/linux_dma_buf.c diff -u src/sys/external/bsd/drm2/linux/linux_dma_buf.c:1.16 src/sys/external/bsd/drm2/linux/linux_dma_buf.c:1.17 --- src/sys/external/bsd/drm2/linux/linux_dma_buf.c:1.16 Tue Feb 21 11:40:13 2023 +++ src/sys/external/bsd/drm2/linux/linux_dma_buf.c Mon May 20 11:35:10 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_dma_buf.c,v 1.16 2023/02/21 11:40:13 riastradh Exp $ */ +/* $NetBSD: linux_dma_buf.c,v 1.17 2024/05/20 11:35:10 riastradh Exp $ */ /*- * Copyright (c) 2018 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: linux_dma_buf.c,v 1.16 2023/02/21 11:40:13 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux_dma_buf.c,v 1.17 2024/05/20 11:35:10 riastradh Exp $"); #include #include @@ -285,7 +285,7 @@ dmabuf_fop_mmap(struct file *file, off_t { struct dma_buf *dmabuf = file->f_data; - if (size > dmabuf->size) + if (size > dmabuf->size || *offp < 0 || *offp > dmabuf->size - size) return EINVAL; return dmabuf->ops->mmap(dmabuf, offp, size, prot, flagsp, advicep,
CVS commit: src/sys/external/bsd/drm2/linux
Module Name:src Committed By: riastradh Date: Mon May 20 11:35:11 UTC 2024 Modified Files: src/sys/external/bsd/drm2/linux: linux_dma_buf.c Log Message: drm: Fix missing bounds checks in dma buf mmap. To generate a diff of this commit: cvs rdiff -u -r1.16 -r1.17 src/sys/external/bsd/drm2/linux/linux_dma_buf.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/external/bsd/drm2/linux
Module Name:src Committed By: riastradh Date: Sun Apr 28 15:35:39 UTC 2024 Modified Files: src/sys/external/bsd/drm2/linux: linux_sync_file.c Log Message: linux_sync_file: Fix missing init/fini steps. Noted by rjs@. PR kern/58210 To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/sys/external/bsd/drm2/linux/linux_sync_file.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/external/bsd/drm2/linux
Module Name:src Committed By: riastradh Date: Sun Apr 28 15:35:39 UTC 2024 Modified Files: src/sys/external/bsd/drm2/linux: linux_sync_file.c Log Message: linux_sync_file: Fix missing init/fini steps. Noted by rjs@. PR kern/58210 To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/sys/external/bsd/drm2/linux/linux_sync_file.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/external/bsd/drm2/linux/linux_sync_file.c diff -u src/sys/external/bsd/drm2/linux/linux_sync_file.c:1.2 src/sys/external/bsd/drm2/linux/linux_sync_file.c:1.3 --- src/sys/external/bsd/drm2/linux/linux_sync_file.c:1.2 Sat Feb 12 15:51:29 2022 +++ src/sys/external/bsd/drm2/linux/linux_sync_file.c Sun Apr 28 15:35:39 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_sync_file.c,v 1.2 2022/02/12 15:51:29 thorpej Exp $ */ +/* $NetBSD: linux_sync_file.c,v 1.3 2024/04/28 15:35:39 riastradh Exp $ */ /*- * Copyright (c) 2020 The NetBSD Foundation, Inc. @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: linux_sync_file.c,v 1.2 2022/02/12 15:51:29 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux_sync_file.c,v 1.3 2024/04/28 15:35:39 riastradh Exp $"); #include #include @@ -51,15 +51,17 @@ sync_file_create(struct dma_fence *fence sf = kmem_zalloc(sizeof(*sf), KM_SLEEP); sf->file = fp; - sf->sf_fence = dma_fence_get(fence); + mutex_init(>sf_lock, MUTEX_DEFAULT, IPL_VM); selinit(>sf_selq); sf->sf_polling = false; sf->sf_signalled = false; + sf->sf_fence = dma_fence_get(fence); fp->f_type = DTYPE_MISC; fp->f_flag = FREAD | FWRITE; fp->f_ops = _file_ops; + fp->f_data = sf; return sf; } @@ -73,6 +75,8 @@ sync_file_close(struct file *fp) dma_fence_remove_callback(sf->sf_fence, >sf_fcb); dma_fence_put(sf->sf_fence); sf->sf_fence = NULL; + seldestroy(>sf_selq); + mutex_destroy(>sf_lock); kmem_free(sf, sizeof(*sf));
CVS commit: src/sys/external/bsd/drm2/linux
Module Name:src Committed By: mrg Date: Mon Sep 4 21:31:58 UTC 2023 Modified Files: src/sys/external/bsd/drm2/linux: linux_pci.c Log Message: convert a KASSERT() into an if () panic() sequence to appease GCC 12. OK riastradh@. To generate a diff of this commit: cvs rdiff -u -r1.25 -r1.26 src/sys/external/bsd/drm2/linux/linux_pci.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/external/bsd/drm2/linux
Module Name:src Committed By: mrg Date: Mon Sep 4 21:31:58 UTC 2023 Modified Files: src/sys/external/bsd/drm2/linux: linux_pci.c Log Message: convert a KASSERT() into an if () panic() sequence to appease GCC 12. OK riastradh@. To generate a diff of this commit: cvs rdiff -u -r1.25 -r1.26 src/sys/external/bsd/drm2/linux/linux_pci.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/external/bsd/drm2/linux/linux_pci.c diff -u src/sys/external/bsd/drm2/linux/linux_pci.c:1.25 src/sys/external/bsd/drm2/linux/linux_pci.c:1.26 --- src/sys/external/bsd/drm2/linux/linux_pci.c:1.25 Mon Oct 17 03:05:32 2022 +++ src/sys/external/bsd/drm2/linux/linux_pci.c Mon Sep 4 21:31:58 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_pci.c,v 1.25 2022/10/17 03:05:32 mrg Exp $ */ +/* $NetBSD: linux_pci.c,v 1.26 2023/09/04 21:31:58 mrg Exp $ */ /*- * Copyright (c) 2013 The NetBSD Foundation, Inc. @@ -35,7 +35,7 @@ #endif #include -__KERNEL_RCSID(0, "$NetBSD: linux_pci.c,v 1.25 2022/10/17 03:05:32 mrg Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux_pci.c,v 1.26 2023/09/04 21:31:58 mrg Exp $"); #if NACPICA > 0 #include @@ -790,7 +790,8 @@ bus_addr_t pci_resource_start(struct pci_dev *pdev, unsigned i) { - KASSERT(i < PCI_NUM_RESOURCES); + if (i >= PCI_NUM_RESOURCES) + panic("resource %d >= max %d", i, PCI_NUM_RESOURCES); return pdev->pd_resources[i].addr; } @@ -798,7 +799,8 @@ bus_size_t pci_resource_len(struct pci_dev *pdev, unsigned i) { - KASSERT(i < PCI_NUM_RESOURCES); + if (i >= PCI_NUM_RESOURCES) + panic("resource %d >= max %d", i, PCI_NUM_RESOURCES); return pdev->pd_resources[i].size; } @@ -813,7 +815,8 @@ int pci_resource_flags(struct pci_dev *pdev, unsigned i) { - KASSERT(i < PCI_NUM_RESOURCES); + if (i >= PCI_NUM_RESOURCES) + panic("resource %d >= max %d", i, PCI_NUM_RESOURCES); return pdev->pd_resources[i].flags; }
CVS commit: src/sys/external/bsd/drm2/linux
Module Name:src Committed By: riastradh Date: Sat Jul 29 23:50:03 UTC 2023 Modified Files: src/sys/external/bsd/drm2/linux: linux_ww_mutex.c Log Message: drm/linux_ww_mutex: Fix ww acquire context ordering. XXX pullup-8 XXX pullup-9 XXX pullup-10 To generate a diff of this commit: cvs rdiff -u -r1.15 -r1.16 src/sys/external/bsd/drm2/linux/linux_ww_mutex.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/external/bsd/drm2/linux/linux_ww_mutex.c diff -u src/sys/external/bsd/drm2/linux/linux_ww_mutex.c:1.15 src/sys/external/bsd/drm2/linux/linux_ww_mutex.c:1.16 --- src/sys/external/bsd/drm2/linux/linux_ww_mutex.c:1.15 Sat Jul 29 22:43:56 2023 +++ src/sys/external/bsd/drm2/linux/linux_ww_mutex.c Sat Jul 29 23:50:03 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_ww_mutex.c,v 1.15 2023/07/29 22:43:56 riastradh Exp $ */ +/* $NetBSD: linux_ww_mutex.c,v 1.16 2023/07/29 23:50:03 riastradh Exp $ */ /*- * Copyright (c) 2014 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: linux_ww_mutex.c,v 1.15 2023/07/29 22:43:56 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux_ww_mutex.c,v 1.16 2023/07/29 23:50:03 riastradh Exp $"); #include #include @@ -62,7 +62,7 @@ ww_acquire_ctx_compare(void *cookie __un if (ctx_a->wwx_ticket < ctx_b->wwx_ticket) return -1; if (ctx_a->wwx_ticket > ctx_b->wwx_ticket) - return -1; + return +1; return 0; } @@ -76,7 +76,7 @@ ww_acquire_ctx_compare_key(void *cookie if (ctx->wwx_ticket < ticket) return -1; if (ctx->wwx_ticket > ticket) - return -1; + return +1; return 0; }
CVS commit: src/sys/external/bsd/drm2/linux
Module Name:src Committed By: riastradh Date: Sat Jul 29 23:50:03 UTC 2023 Modified Files: src/sys/external/bsd/drm2/linux: linux_ww_mutex.c Log Message: drm/linux_ww_mutex: Fix ww acquire context ordering. XXX pullup-8 XXX pullup-9 XXX pullup-10 To generate a diff of this commit: cvs rdiff -u -r1.15 -r1.16 src/sys/external/bsd/drm2/linux/linux_ww_mutex.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/external/bsd/drm2/linux
Module Name:src Committed By: riastradh Date: Sat Jul 29 22:43:56 UTC 2023 Modified Files: src/sys/external/bsd/drm2/linux: linux_ww_mutex.c Log Message: drm/linux_ww_mutex: Fix wait loops. If cv_wait_sig returns because a signal is delivered, we may nonetheless have been granted the lock. It is harmless for us to ignore this fact in three of the four paths, but in ww_mutex_state_wait_sig, we may now have ownership of the lock and MUST NOT return failure because the caller MUST release the lock before destroying the ww_acquire_ctx. While here, restructure the other three loops for clarity, so they match the structure of the fourth and so they have a little less impenetrable negation. PR kern/57537 XXX pullup-8 XXX pullup-9 XXX pullup-10 To generate a diff of this commit: cvs rdiff -u -r1.14 -r1.15 src/sys/external/bsd/drm2/linux/linux_ww_mutex.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/external/bsd/drm2/linux/linux_ww_mutex.c diff -u src/sys/external/bsd/drm2/linux/linux_ww_mutex.c:1.14 src/sys/external/bsd/drm2/linux/linux_ww_mutex.c:1.15 --- src/sys/external/bsd/drm2/linux/linux_ww_mutex.c:1.14 Fri Mar 18 23:33:41 2022 +++ src/sys/external/bsd/drm2/linux/linux_ww_mutex.c Sat Jul 29 22:43:56 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_ww_mutex.c,v 1.14 2022/03/18 23:33:41 riastradh Exp $ */ +/* $NetBSD: linux_ww_mutex.c,v 1.15 2023/07/29 22:43:56 riastradh Exp $ */ /*- * Copyright (c) 2014 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: linux_ww_mutex.c,v 1.14 2022/03/18 23:33:41 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux_ww_mutex.c,v 1.15 2023/07/29 22:43:56 riastradh Exp $"); #include #include @@ -286,8 +286,14 @@ ww_mutex_state_wait(struct ww_mutex *mut KASSERT(mutex_owned(>wwm_lock)); KASSERT(mutex->wwm_state == state); - do cv_wait(>wwm_cv, >wwm_lock); - while (mutex->wwm_state == state); + + for (;;) { + cv_wait(>wwm_cv, >wwm_lock); + if (mutex->wwm_state != state) + break; + } + + KASSERT(mutex->wwm_state != state); } /* @@ -310,18 +316,26 @@ ww_mutex_state_wait_sig(struct ww_mutex KASSERT(mutex_owned(>wwm_lock)); KASSERT(mutex->wwm_state == state); - do { + + for (;;) { /* XXX errno NetBSD->Linux */ ret = -cv_wait_sig(>wwm_cv, >wwm_lock); + if (mutex->wwm_state != state) { + ret = 0; + break; + } if (ret) { KASSERTMSG((ret == -EINTR || ret == -ERESTART), "ret=%d", ret); ret = -EINTR; break; } - } while (mutex->wwm_state == state); + } KASSERTMSG((ret == 0 || ret == -EINTR), "ret=%d", ret); + KASSERTMSG(ret != 0 || mutex->wwm_state != state, + "ret=%d mutex=%p mutex->wwm_state=%d state=%d", + ret, mutex, mutex->wwm_state, state); return ret; } @@ -363,12 +377,18 @@ ww_mutex_lock_wait(struct ww_mutex *mute "ticket number reused: %"PRId64" (%p) %"PRId64" (%p)", ctx->wwx_ticket, ctx, collision->wwx_ticket, collision); - do cv_wait(>wwm_cv, >wwm_lock); - while (!(((mutex->wwm_state == WW_CTX) || - (mutex->wwm_state == WW_WANTOWN)) && - (mutex->wwm_u.ctx == ctx))); + for (;;) { + cv_wait(>wwm_cv, >wwm_lock); + if ((mutex->wwm_state == WW_CTX || + mutex->wwm_state == WW_WANTOWN) && + mutex->wwm_u.ctx == ctx) + break; + } rb_tree_remove_node(>wwm_waiters, ctx); + + KASSERT(mutex->wwm_state == WW_CTX || mutex->wwm_state == WW_WANTOWN); + KASSERT(mutex->wwm_u.ctx == ctx); } /* @@ -411,21 +431,29 @@ ww_mutex_lock_wait_sig(struct ww_mutex * "ticket number reused: %"PRId64" (%p) %"PRId64" (%p)", ctx->wwx_ticket, ctx, collision->wwx_ticket, collision); - do { + for (;;) { /* XXX errno NetBSD->Linux */ ret = -cv_wait_sig(>wwm_cv, >wwm_lock); + if ((mutex->wwm_state == WW_CTX || + mutex->wwm_state == WW_WANTOWN) && + mutex->wwm_u.ctx == ctx) { + ret = 0; + break; + } if (ret) { KASSERTMSG((ret == -EINTR || ret == -ERESTART), "ret=%d", ret); ret = -EINTR; - goto out; + break; } - } while (!(((mutex->wwm_state == WW_CTX) || - (mutex->wwm_state == WW_WANTOWN)) && - (mutex->wwm_u.ctx == ctx))); + } + + rb_tree_remove_node(>wwm_waiters, ctx); -out: rb_tree_remove_node(>wwm_waiters, ctx); KASSERTMSG((ret == 0 || ret == -EINTR), "ret=%d", ret); + KASSERT(ret != 0 || + mutex->wwm_state == WW_CTX || mutex->wwm_state == WW_WANTOWN); + KASSERT(ret != 0 || mutex->wwm_u.ctx == ctx); return ret; }
CVS commit: src/sys/external/bsd/drm2/linux
Module Name:src Committed By: riastradh Date: Sat Jul 29 22:43:56 UTC 2023 Modified Files: src/sys/external/bsd/drm2/linux: linux_ww_mutex.c Log Message: drm/linux_ww_mutex: Fix wait loops. If cv_wait_sig returns because a signal is delivered, we may nonetheless have been granted the lock. It is harmless for us to ignore this fact in three of the four paths, but in ww_mutex_state_wait_sig, we may now have ownership of the lock and MUST NOT return failure because the caller MUST release the lock before destroying the ww_acquire_ctx. While here, restructure the other three loops for clarity, so they match the structure of the fourth and so they have a little less impenetrable negation. PR kern/57537 XXX pullup-8 XXX pullup-9 XXX pullup-10 To generate a diff of this commit: cvs rdiff -u -r1.14 -r1.15 src/sys/external/bsd/drm2/linux/linux_ww_mutex.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/external/bsd/drm2/linux
Module Name:src Committed By: riastradh Date: Tue Feb 21 11:40:13 UTC 2023 Modified Files: src/sys/external/bsd/drm2/linux: linux_dma_buf.c Log Message: drm: Teach dmabuf to handle lseek. Needed by libdrm_amdgpu. Based on patch from Jeff Frasca -- thanks! XXX pullup-10 To generate a diff of this commit: cvs rdiff -u -r1.15 -r1.16 src/sys/external/bsd/drm2/linux/linux_dma_buf.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/external/bsd/drm2/linux/linux_dma_buf.c diff -u src/sys/external/bsd/drm2/linux/linux_dma_buf.c:1.15 src/sys/external/bsd/drm2/linux/linux_dma_buf.c:1.16 --- src/sys/external/bsd/drm2/linux/linux_dma_buf.c:1.15 Sat Apr 9 23:44:44 2022 +++ src/sys/external/bsd/drm2/linux/linux_dma_buf.c Tue Feb 21 11:40:13 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_dma_buf.c,v 1.15 2022/04/09 23:44:44 riastradh Exp $ */ +/* $NetBSD: linux_dma_buf.c,v 1.16 2023/02/21 11:40:13 riastradh Exp $ */ /*- * Copyright (c) 2018 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: linux_dma_buf.c,v 1.15 2022/04/09 23:44:44 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux_dma_buf.c,v 1.16 2023/02/21 11:40:13 riastradh Exp $"); #include #include @@ -48,6 +48,8 @@ static int dmabuf_fop_close(struct file static int dmabuf_fop_kqfilter(struct file *, struct knote *); static int dmabuf_fop_mmap(struct file *, off_t *, size_t, int, int *, int *, struct uvm_object **, int *); +static int dmabuf_fop_seek(struct file *fp, off_t delta, int whence, + off_t *newoffp, int flags); static const struct fileops dmabuf_fileops = { .fo_name = "dmabuf", @@ -61,6 +63,7 @@ static const struct fileops dmabuf_fileo .fo_kqfilter = dmabuf_fop_kqfilter, .fo_restart = fnullop_restart, .fo_mmap = dmabuf_fop_mmap, + .fo_seek = dmabuf_fop_seek, }; struct dma_buf * @@ -288,3 +291,54 @@ dmabuf_fop_mmap(struct file *file, off_t return dmabuf->ops->mmap(dmabuf, offp, size, prot, flagsp, advicep, uobjp, maxprotp); } + +/* + * We don't actually do anything with the file offset; this is just how + * libdrm_amdgpu expects to find the size of the DMA buf. (Why it + * doesn't use fstat is unclear, but it doesn't really matter.) + */ +static int +dmabuf_fop_seek(struct file *fp, off_t delta, int whence, off_t *newoffp, +int flags) +{ + const off_t OFF_MAX = __type_max(off_t); + struct dma_buf *dmabuf = fp->f_data; + off_t base, newoff; + int error; + + mutex_enter(>f_lock); + + switch (whence) { + case SEEK_CUR: + base = fp->f_offset; + break; + case SEEK_END: + base = dmabuf->size; + break; + case SEEK_SET: + base = 0; + break; + default: + error = EINVAL; + goto out; + } + + /* Check for arithmetic overflow and reject negative offsets. */ + if (base < 0 || delta > OFF_MAX - base || base + delta < 0) { + error = EINVAL; + goto out; + } + + /* Compute the new offset. */ + newoff = base + delta; + + /* Success! */ + if (newoffp) + *newoffp = newoff; + if (flags & FOF_UPDATE_OFFSET) + fp->f_offset = newoff; + error = 0; + +out: mutex_exit(>f_lock); + return error; +}
CVS commit: src/sys/external/bsd/drm2/linux
Module Name:src Committed By: riastradh Date: Tue Feb 21 11:40:13 UTC 2023 Modified Files: src/sys/external/bsd/drm2/linux: linux_dma_buf.c Log Message: drm: Teach dmabuf to handle lseek. Needed by libdrm_amdgpu. Based on patch from Jeff Frasca -- thanks! XXX pullup-10 To generate a diff of this commit: cvs rdiff -u -r1.15 -r1.16 src/sys/external/bsd/drm2/linux/linux_dma_buf.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/external/bsd/drm2/linux
Module Name:src Committed By: riastradh Date: Thu Sep 1 09:37:06 UTC 2022 Modified Files: src/sys/external/bsd/drm2/linux: linux_dma_fence.c Log Message: drm: Fix dma fence stub fix so the lock is actually initialized. Tested but forgot to amend change before exporting to CVS again. To generate a diff of this commit: cvs rdiff -u -r1.41 -r1.42 src/sys/external/bsd/drm2/linux/linux_dma_fence.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/external/bsd/drm2/linux/linux_dma_fence.c diff -u src/sys/external/bsd/drm2/linux/linux_dma_fence.c:1.41 src/sys/external/bsd/drm2/linux/linux_dma_fence.c:1.42 --- src/sys/external/bsd/drm2/linux/linux_dma_fence.c:1.41 Thu Sep 1 01:54:38 2022 +++ src/sys/external/bsd/drm2/linux/linux_dma_fence.c Thu Sep 1 09:37:06 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_dma_fence.c,v 1.41 2022/09/01 01:54:38 riastradh Exp $ */ +/* $NetBSD: linux_dma_fence.c,v 1.42 2022/09/01 09:37:06 riastradh Exp $ */ /*- * Copyright (c) 2018 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: linux_dma_fence.c,v 1.41 2022/09/01 01:54:38 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux_dma_fence.c,v 1.42 2022/09/01 09:37:06 riastradh Exp $"); #include #include @@ -95,13 +95,15 @@ SDT_PROBE_DEFINE2(sdt, drm, fence, wait_ */ int linux_dma_fence_trace = 0; -static spinlock_t dma_fence_stub_lock; -static struct dma_fence dma_fence_stub; +static struct { + spinlock_t lock; + struct dma_fence fence; +} dma_fence_stub __cacheline_aligned; static const char *dma_fence_stub_name(struct dma_fence *f) { - KASSERT(f == _fence_stub); + KASSERT(f == _fence_stub.fence); return "stub"; } @@ -109,7 +111,7 @@ static void dma_fence_stub_release(struct dma_fence *f) { - KASSERT(f == _fence_stub); + KASSERT(f == _fence_stub.fence); dma_fence_destroy(f); } @@ -129,9 +131,10 @@ linux_dma_fences_init(void) { int error __diagused; - dma_fence_init(_fence_stub, _fence_stub_ops, - _fence_stub_lock, /*context*/0, /*seqno*/0); - error = dma_fence_signal(_fence_stub); + spin_lock_init(_fence_stub.lock); + dma_fence_init(_fence_stub.fence, _fence_stub_ops, + _fence_stub.lock, /*context*/0, /*seqno*/0); + error = dma_fence_signal(_fence_stub.fence); KASSERTMSG(error == 0, "error=%d", error); } @@ -139,7 +142,8 @@ void linux_dma_fences_fini(void) { - dma_fence_put(_fence_stub); + dma_fence_put(_fence_stub.fence); + spin_lock_destroy(_fence_stub.lock); } /* @@ -361,7 +365,7 @@ struct dma_fence * dma_fence_get_stub(void) { - return dma_fence_get(_fence_stub); + return dma_fence_get(_fence_stub.fence); } /*
CVS commit: src/sys/external/bsd/drm2/linux
Module Name:src Committed By: riastradh Date: Thu Sep 1 09:37:06 UTC 2022 Modified Files: src/sys/external/bsd/drm2/linux: linux_dma_fence.c Log Message: drm: Fix dma fence stub fix so the lock is actually initialized. Tested but forgot to amend change before exporting to CVS again. To generate a diff of this commit: cvs rdiff -u -r1.41 -r1.42 src/sys/external/bsd/drm2/linux/linux_dma_fence.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/external/bsd/drm2/linux
Module Name:src Committed By: riastradh Date: Sun Jul 10 13:56:44 UTC 2022 Modified Files: src/sys/external/bsd/drm2/linux: linux_hdmi.c Log Message: linux/hdmi: Fix size of product id. To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/sys/external/bsd/drm2/linux/linux_hdmi.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/external/bsd/drm2/linux/linux_hdmi.c diff -u src/sys/external/bsd/drm2/linux/linux_hdmi.c:1.9 src/sys/external/bsd/drm2/linux/linux_hdmi.c:1.10 --- src/sys/external/bsd/drm2/linux/linux_hdmi.c:1.9 Sun Jul 10 12:32:31 2022 +++ src/sys/external/bsd/drm2/linux/linux_hdmi.c Sun Jul 10 13:56:44 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_hdmi.c,v 1.9 2022/07/10 12:32:31 riastradh Exp $ */ +/* $NetBSD: linux_hdmi.c,v 1.10 2022/07/10 13:56:44 riastradh Exp $ */ /*- * Copyright (c) 2014 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: linux_hdmi.c,v 1.9 2022/07/10 12:32:31 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux_hdmi.c,v 1.10 2022/07/10 13:56:44 riastradh Exp $"); #include @@ -515,7 +515,7 @@ hdmi_spd_infoframe_unpack(struct hdmi_sp size -= HDMI_INFOFRAME_HEADER_SIZE; memcpy(frame->vendor, [0], 8); - memcpy(frame->product, [8], 8); + memcpy(frame->product, [8], 16); frame->sdi = p[24]; return 0;
CVS commit: src/sys/external/bsd/drm2/linux
Module Name:src Committed By: riastradh Date: Sun Jul 10 13:56:44 UTC 2022 Modified Files: src/sys/external/bsd/drm2/linux: linux_hdmi.c Log Message: linux/hdmi: Fix size of product id. To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/sys/external/bsd/drm2/linux/linux_hdmi.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/external/bsd/drm2/linux
Module Name:src Committed By: riastradh Date: Sun Jul 10 12:32:31 UTC 2022 Modified Files: src/sys/external/bsd/drm2/linux: linux_hdmi.c Log Message: linux/hdmi: Fix return value in unpack. To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/sys/external/bsd/drm2/linux/linux_hdmi.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/external/bsd/drm2/linux/linux_hdmi.c diff -u src/sys/external/bsd/drm2/linux/linux_hdmi.c:1.8 src/sys/external/bsd/drm2/linux/linux_hdmi.c:1.9 --- src/sys/external/bsd/drm2/linux/linux_hdmi.c:1.8 Sat Jul 9 19:53:00 2022 +++ src/sys/external/bsd/drm2/linux/linux_hdmi.c Sun Jul 10 12:32:31 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_hdmi.c,v 1.8 2022/07/09 19:53:00 riastradh Exp $ */ +/* $NetBSD: linux_hdmi.c,v 1.9 2022/07/10 12:32:31 riastradh Exp $ */ /*- * Copyright (c) 2014 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: linux_hdmi.c,v 1.8 2022/07/09 19:53:00 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux_hdmi.c,v 1.9 2022/07/10 12:32:31 riastradh Exp $"); #include @@ -111,7 +111,7 @@ hdmi_infoframe_header_unpack(struct hdmi return -EINVAL; hdmi_infoframe_header_init(header, p[0], p[1], p[2]); - return HDMI_INFOFRAME_HEADER_SIZE; + return 0; } static void
CVS commit: src/sys/external/bsd/drm2/linux
Module Name:src Committed By: riastradh Date: Sun Jul 10 12:32:31 UTC 2022 Modified Files: src/sys/external/bsd/drm2/linux: linux_hdmi.c Log Message: linux/hdmi: Fix return value in unpack. To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/sys/external/bsd/drm2/linux/linux_hdmi.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/external/bsd/drm2/linux
Module Name:src Committed By: riastradh Date: Sat Jul 9 19:53:00 UTC 2022 Modified Files: src/sys/external/bsd/drm2/linux: linux_hdmi.c Log Message: linux/hdmi: Fix hdmi_infoframe_unpack to record the unpacked header. To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/sys/external/bsd/drm2/linux/linux_hdmi.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/external/bsd/drm2/linux/linux_hdmi.c diff -u src/sys/external/bsd/drm2/linux/linux_hdmi.c:1.7 src/sys/external/bsd/drm2/linux/linux_hdmi.c:1.8 --- src/sys/external/bsd/drm2/linux/linux_hdmi.c:1.7 Sat Jul 9 18:41:23 2022 +++ src/sys/external/bsd/drm2/linux/linux_hdmi.c Sat Jul 9 19:53:00 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_hdmi.c,v 1.7 2022/07/09 18:41:23 riastradh Exp $ */ +/* $NetBSD: linux_hdmi.c,v 1.8 2022/07/09 19:53:00 riastradh Exp $ */ /*- * Copyright (c) 2014 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: linux_hdmi.c,v 1.7 2022/07/09 18:41:23 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux_hdmi.c,v 1.8 2022/07/09 19:53:00 riastradh Exp $"); #include @@ -691,15 +691,14 @@ int hdmi_infoframe_unpack(union hdmi_infoframe *frame, const void *buf, size_t size) { - struct hdmi_infoframe_header header; int ret; memset(frame, 0, sizeof(*frame)); - ret = hdmi_infoframe_header_unpack(, buf, size); + ret = hdmi_infoframe_header_unpack(>any, buf, size); if (ret) return ret; - switch (header.type) { + switch (frame->any.type) { case HDMI_INFOFRAME_TYPE_VENDOR: return hdmi_vendor_infoframe_unpack(>vendor.hdmi, buf, size);
CVS commit: src/sys/external/bsd/drm2/linux
Module Name:src Committed By: riastradh Date: Sat Jul 9 19:53:00 UTC 2022 Modified Files: src/sys/external/bsd/drm2/linux: linux_hdmi.c Log Message: linux/hdmi: Fix hdmi_infoframe_unpack to record the unpacked header. To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/sys/external/bsd/drm2/linux/linux_hdmi.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/external/bsd/drm2/linux
Module Name:src Committed By: riastradh Date: Sat Jul 9 18:41:23 UTC 2022 Modified Files: src/sys/external/bsd/drm2/linux: linux_hdmi.c Log Message: linux/hdmi: Handle audio infoframes in hdmi_infoframe_pack. Sort cases by type number. To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/sys/external/bsd/drm2/linux/linux_hdmi.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/external/bsd/drm2/linux/linux_hdmi.c diff -u src/sys/external/bsd/drm2/linux/linux_hdmi.c:1.6 src/sys/external/bsd/drm2/linux/linux_hdmi.c:1.7 --- src/sys/external/bsd/drm2/linux/linux_hdmi.c:1.6 Sat Jul 9 18:21:23 2022 +++ src/sys/external/bsd/drm2/linux/linux_hdmi.c Sat Jul 9 18:41:23 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_hdmi.c,v 1.6 2022/07/09 18:21:23 riastradh Exp $ */ +/* $NetBSD: linux_hdmi.c,v 1.7 2022/07/09 18:41:23 riastradh Exp $ */ /*- * Copyright (c) 2014 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: linux_hdmi.c,v 1.6 2022/07/09 18:21:23 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux_hdmi.c,v 1.7 2022/07/09 18:41:23 riastradh Exp $"); #include @@ -671,15 +671,17 @@ hdmi_infoframe_pack(const union hdmi_inf { switch (frame->any.type) { + case HDMI_INFOFRAME_TYPE_VENDOR: + return hdmi_vendor_infoframe_pack(>vendor.hdmi, buf, + size); case HDMI_INFOFRAME_TYPE_AVI: return hdmi_avi_infoframe_pack(>avi, buf, size); - case HDMI_INFOFRAME_TYPE_DRM: - return hdmi_drm_infoframe_pack(>drm, buf, size); case HDMI_INFOFRAME_TYPE_SPD: return hdmi_spd_infoframe_pack(>spd, buf, size); - case HDMI_INFOFRAME_TYPE_VENDOR: - return hdmi_vendor_infoframe_pack(>vendor.hdmi, buf, - size); + case HDMI_INFOFRAME_TYPE_AUDIO: + return hdmi_audio_infoframe_pack(>audio, buf, size); + case HDMI_INFOFRAME_TYPE_DRM: + return hdmi_drm_infoframe_pack(>drm, buf, size); default: return -EINVAL; }
CVS commit: src/sys/external/bsd/drm2/linux
Module Name:src Committed By: riastradh Date: Sat Jul 9 18:41:23 UTC 2022 Modified Files: src/sys/external/bsd/drm2/linux: linux_hdmi.c Log Message: linux/hdmi: Handle audio infoframes in hdmi_infoframe_pack. Sort cases by type number. To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/sys/external/bsd/drm2/linux/linux_hdmi.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/external/bsd/drm2/linux
Module Name:src Committed By: riastradh Date: Sat Jul 9 18:21:23 UTC 2022 Modified Files: src/sys/external/bsd/drm2/linux: linux_hdmi.c Log Message: linux/hdmi: Convert failure branch to kassert for internal invariant. To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/sys/external/bsd/drm2/linux/linux_hdmi.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/external/bsd/drm2/linux/linux_hdmi.c diff -u src/sys/external/bsd/drm2/linux/linux_hdmi.c:1.5 src/sys/external/bsd/drm2/linux/linux_hdmi.c:1.6 --- src/sys/external/bsd/drm2/linux/linux_hdmi.c:1.5 Sat Jul 9 18:18:36 2022 +++ src/sys/external/bsd/drm2/linux/linux_hdmi.c Sat Jul 9 18:21:23 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_hdmi.c,v 1.5 2022/07/09 18:18:36 riastradh Exp $ */ +/* $NetBSD: linux_hdmi.c,v 1.6 2022/07/09 18:21:23 riastradh Exp $ */ /*- * Copyright (c) 2014 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: linux_hdmi.c,v 1.5 2022/07/09 18:18:36 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux_hdmi.c,v 1.6 2022/07/09 18:21:23 riastradh Exp $"); #include @@ -72,8 +72,8 @@ hdmi_infoframe_header_pack(const struct { uint8_t *const p = buf; - if (length < HDMI_INFOFRAME_HEADER_SIZE) - return -ENOSPC; + KASSERT(length >= HDMI_INFOFRAME_HEADER_SIZE); + if (size < length) return -ENOSPC;
CVS commit: src/sys/external/bsd/drm2/linux
Module Name:src Committed By: riastradh Date: Sat Jul 9 18:21:23 UTC 2022 Modified Files: src/sys/external/bsd/drm2/linux: linux_hdmi.c Log Message: linux/hdmi: Convert failure branch to kassert for internal invariant. To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/sys/external/bsd/drm2/linux/linux_hdmi.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/external/bsd/drm2/linux
Module Name:src Committed By: riastradh Date: Sat Jul 9 18:11:47 UTC 2022 Modified Files: src/sys/external/bsd/drm2/linux: linux_hdmi.c Log Message: linux/hdmi: Zero entire union hdmi_infoframe on unpack. Don't just zero the part that we're about to initialize -- i915 does memcmp on the whole structure. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/sys/external/bsd/drm2/linux/linux_hdmi.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/external/bsd/drm2/linux
Module Name:src Committed By: riastradh Date: Sat Jul 9 18:11:47 UTC 2022 Modified Files: src/sys/external/bsd/drm2/linux: linux_hdmi.c Log Message: linux/hdmi: Zero entire union hdmi_infoframe on unpack. Don't just zero the part that we're about to initialize -- i915 does memcmp on the whole structure. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/sys/external/bsd/drm2/linux/linux_hdmi.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/external/bsd/drm2/linux/linux_hdmi.c diff -u src/sys/external/bsd/drm2/linux/linux_hdmi.c:1.3 src/sys/external/bsd/drm2/linux/linux_hdmi.c:1.4 --- src/sys/external/bsd/drm2/linux/linux_hdmi.c:1.3 Sat Jul 9 18:11:36 2022 +++ src/sys/external/bsd/drm2/linux/linux_hdmi.c Sat Jul 9 18:11:47 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_hdmi.c,v 1.3 2022/07/09 18:11:36 riastradh Exp $ */ +/* $NetBSD: linux_hdmi.c,v 1.4 2022/07/09 18:11:47 riastradh Exp $ */ /*- * Copyright (c) 2014 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: linux_hdmi.c,v 1.3 2022/07/09 18:11:36 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux_hdmi.c,v 1.4 2022/07/09 18:11:47 riastradh Exp $"); #include @@ -192,8 +192,6 @@ hdmi_audio_infoframe_unpack(struct hdmi_ const uint8_t *p = buf; int ret; - memset(frame, 0, sizeof(*frame)); - ret = hdmi_infoframe_header_unpack(>header, p, size); if (ret) return ret; @@ -302,8 +300,6 @@ hdmi_avi_infoframe_unpack(struct hdmi_av const uint8_t *p = buf; int ret; - memset(frame, 0, sizeof(*frame)); - ret = hdmi_infoframe_header_unpack(>header, p, size); if (ret) return ret; @@ -419,8 +415,6 @@ hdmi_drm_infoframe_unpack(struct hdmi_dr unsigned i; int ret; - memset(frame, 0, sizeof(*frame)); - ret = hdmi_infoframe_header_unpack(>header, p, size); if (ret) return ret; @@ -512,8 +506,6 @@ hdmi_spd_infoframe_unpack(struct hdmi_sp const uint8_t *p = buf; int ret; - memset(frame, 0, sizeof(*frame)); - ret = hdmi_infoframe_header_unpack(>header, p, size); if (ret) return ret; @@ -629,8 +621,6 @@ hdmi_vendor_infoframe_unpack(struct hdmi const uint8_t *p = buf; int ret; - memset(frame, 0, sizeof(*frame)); - ret = hdmi_infoframe_header_unpack(>header, p, size); if (ret) return ret; @@ -702,6 +692,8 @@ hdmi_infoframe_unpack(union hdmi_infofra struct hdmi_infoframe_header header; int ret; + memset(frame, 0, sizeof(*frame)); + ret = hdmi_infoframe_header_unpack(, buf, size); if (ret) return ret;
CVS commit: src/sys/external/bsd/drm2/linux
Module Name:src Committed By: riastradh Date: Sun May 22 18:41:14 UTC 2022 Modified Files: src/sys/external/bsd/drm2/linux: linux_i2c.c Log Message: linux: Repeat i2c transfer if driver fails with EAGAIN. The Intel GMBUS (graphics management bus, i2c controller) relies on this now to fall back from interrupt-driven xfers to bit-banging. To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/sys/external/bsd/drm2/linux/linux_i2c.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/external/bsd/drm2/linux
Module Name:src Committed By: riastradh Date: Sun May 22 18:41:14 UTC 2022 Modified Files: src/sys/external/bsd/drm2/linux: linux_i2c.c Log Message: linux: Repeat i2c transfer if driver fails with EAGAIN. The Intel GMBUS (graphics management bus, i2c controller) relies on this now to fall back from interrupt-driven xfers to bit-banging. To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/sys/external/bsd/drm2/linux/linux_i2c.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/external/bsd/drm2/linux/linux_i2c.c diff -u src/sys/external/bsd/drm2/linux/linux_i2c.c:1.6 src/sys/external/bsd/drm2/linux/linux_i2c.c:1.7 --- src/sys/external/bsd/drm2/linux/linux_i2c.c:1.6 Sun Dec 19 11:49:12 2021 +++ src/sys/external/bsd/drm2/linux/linux_i2c.c Sun May 22 18:41:14 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_i2c.c,v 1.6 2021/12/19 11:49:12 riastradh Exp $ */ +/* $NetBSD: linux_i2c.c,v 1.7 2022/05/22 18:41:14 riastradh Exp $ */ /*- * Copyright (c) 2015 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: linux_i2c.c,v 1.6 2021/12/19 11:49:12 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux_i2c.c,v 1.7 2022/05/22 18:41:14 riastradh Exp $"); #include #include @@ -127,8 +127,18 @@ i2c_master_recv(const struct i2c_client int __i2c_transfer(struct i2c_adapter *adapter, struct i2c_msg *msgs, int n) { + unsigned timeout = hz; /* XXX adapter->timeout */ + unsigned start = getticks(); + int ret, nretries = 0; + + do { + ret = (*adapter->algo->master_xfer)(adapter, msgs, n); + if (ret != -EAGAIN) + break; + } while (nretries++ < adapter->retries && + getticks() - start < timeout); - return (*adapter->algo->master_xfer)(adapter, msgs, n); + return ret; } int
CVS commit: src/sys/external/bsd/drm2/linux
Module Name:src Committed By: riastradh Date: Sat Apr 9 23:44:45 UTC 2022 Modified Files: src/sys/external/bsd/drm2/linux: linux_dma_buf.c linux_dma_fence.c linux_dma_fence_chain.c Log Message: drm: Convert membar_enter/exit stragglers to membar_acquire/release. To generate a diff of this commit: cvs rdiff -u -r1.14 -r1.15 src/sys/external/bsd/drm2/linux/linux_dma_buf.c cvs rdiff -u -r1.39 -r1.40 src/sys/external/bsd/drm2/linux/linux_dma_fence.c cvs rdiff -u -r1.3 -r1.4 \ src/sys/external/bsd/drm2/linux/linux_dma_fence_chain.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/external/bsd/drm2/linux
Module Name:src Committed By: riastradh Date: Sat Apr 9 23:44:45 UTC 2022 Modified Files: src/sys/external/bsd/drm2/linux: linux_dma_buf.c linux_dma_fence.c linux_dma_fence_chain.c Log Message: drm: Convert membar_enter/exit stragglers to membar_acquire/release. To generate a diff of this commit: cvs rdiff -u -r1.14 -r1.15 src/sys/external/bsd/drm2/linux/linux_dma_buf.c cvs rdiff -u -r1.39 -r1.40 src/sys/external/bsd/drm2/linux/linux_dma_fence.c cvs rdiff -u -r1.3 -r1.4 \ src/sys/external/bsd/drm2/linux/linux_dma_fence_chain.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/external/bsd/drm2/linux/linux_dma_buf.c diff -u src/sys/external/bsd/drm2/linux/linux_dma_buf.c:1.14 src/sys/external/bsd/drm2/linux/linux_dma_buf.c:1.15 --- src/sys/external/bsd/drm2/linux/linux_dma_buf.c:1.14 Thu Feb 17 01:38:38 2022 +++ src/sys/external/bsd/drm2/linux/linux_dma_buf.c Sat Apr 9 23:44:44 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_dma_buf.c,v 1.14 2022/02/17 01:38:38 riastradh Exp $ */ +/* $NetBSD: linux_dma_buf.c,v 1.15 2022/04/09 23:44:44 riastradh Exp $ */ /*- * Copyright (c) 2018 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: linux_dma_buf.c,v 1.14 2022/02/17 01:38:38 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux_dma_buf.c,v 1.15 2022/04/09 23:44:44 riastradh Exp $"); #include #include @@ -160,10 +160,10 @@ void dma_buf_put(struct dma_buf *dmabuf) { - membar_exit(); + membar_release(); if (atomic_dec_uint_nv(>db_refcnt) != 0) return; - membar_enter(); + membar_acquire(); dma_resv_poll_fini(>db_resv_poll); mutex_destroy(>db_lock); Index: src/sys/external/bsd/drm2/linux/linux_dma_fence.c diff -u src/sys/external/bsd/drm2/linux/linux_dma_fence.c:1.39 src/sys/external/bsd/drm2/linux/linux_dma_fence.c:1.40 --- src/sys/external/bsd/drm2/linux/linux_dma_fence.c:1.39 Sun Dec 19 12:39:40 2021 +++ src/sys/external/bsd/drm2/linux/linux_dma_fence.c Sat Apr 9 23:44:44 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_dma_fence.c,v 1.39 2021/12/19 12:39:40 riastradh Exp $ */ +/* $NetBSD: linux_dma_fence.c,v 1.40 2022/04/09 23:44:44 riastradh Exp $ */ /*- * Copyright (c) 2018 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: linux_dma_fence.c,v 1.39 2021/12/19 12:39:40 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux_dma_fence.c,v 1.40 2022/04/09 23:44:44 riastradh Exp $"); #include #include @@ -245,9 +245,9 @@ dma_fence_context_alloc(unsigned n) } S; uint64_t c; - while (__predict_false(atomic_cas_uint(, 0, 1) != 0)) + while (__predict_false(atomic_swap_uint(, 1))) SPINLOCK_BACKOFF_HOOK; - membar_enter(); + membar_acquire(); c = S.context; S.context += n; atomic_store_release(, 0); Index: src/sys/external/bsd/drm2/linux/linux_dma_fence_chain.c diff -u src/sys/external/bsd/drm2/linux/linux_dma_fence_chain.c:1.3 src/sys/external/bsd/drm2/linux/linux_dma_fence_chain.c:1.4 --- src/sys/external/bsd/drm2/linux/linux_dma_fence_chain.c:1.3 Sun Dec 19 12:39:32 2021 +++ src/sys/external/bsd/drm2/linux/linux_dma_fence_chain.c Sat Apr 9 23:44:44 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_dma_fence_chain.c,v 1.3 2021/12/19 12:39:32 riastradh Exp $ */ +/* $NetBSD: linux_dma_fence_chain.c,v 1.4 2022/04/09 23:44:44 riastradh Exp $ */ /*- * Copyright (c) 2021 The NetBSD Foundation, Inc. @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: linux_dma_fence_chain.c,v 1.3 2021/12/19 12:39:32 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux_dma_fence_chain.c,v 1.4 2022/04/09 23:44:44 riastradh Exp $"); #include @@ -262,7 +262,7 @@ dma_fence_chain_walk(struct dma_fence *f break; splice = NULL; } - membar_exit(); /* pairs with dma_fence_get_rcu_safe */ + membar_release(); /* pairs with dma_fence_get_rcu_safe */ if (atomic_cas_ptr(>dfc_prev, prev, splice) == prev) dma_fence_put(prev); /* transferred to splice */ else
CVS commit: src/sys/external/bsd/drm2/linux
Module Name:src Committed By: riastradh Date: Fri Mar 18 23:33:41 UTC 2022 Modified Files: src/sys/external/bsd/drm2/linux: linux_ww_mutex.c Log Message: drm: In ww_mutex_unlock, do lockdebug check first. This way we get a full lockdebug dump when LOCKDEBUG is enabled, instead of just the panic message (which includes the lock address you could pass to `show lock' in ddb, but let's get the dump by default even if you don't enter ddb). Also in the KASSERT print the mutex. To generate a diff of this commit: cvs rdiff -u -r1.13 -r1.14 src/sys/external/bsd/drm2/linux/linux_ww_mutex.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/external/bsd/drm2/linux/linux_ww_mutex.c diff -u src/sys/external/bsd/drm2/linux/linux_ww_mutex.c:1.13 src/sys/external/bsd/drm2/linux/linux_ww_mutex.c:1.14 --- src/sys/external/bsd/drm2/linux/linux_ww_mutex.c:1.13 Sun Dec 26 16:14:34 2021 +++ src/sys/external/bsd/drm2/linux/linux_ww_mutex.c Fri Mar 18 23:33:41 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_ww_mutex.c,v 1.13 2021/12/26 16:14:34 riastradh Exp $ */ +/* $NetBSD: linux_ww_mutex.c,v 1.14 2022/03/18 23:33:41 riastradh Exp $ */ /*- * Copyright (c) 2014 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: linux_ww_mutex.c,v 1.13 2021/12/26 16:14:34 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux_ww_mutex.c,v 1.14 2022/03/18 23:33:41 riastradh Exp $"); #include #include @@ -1041,7 +1041,8 @@ ww_mutex_unlock(struct ww_mutex *mutex) struct ww_acquire_ctx *ctx; mutex_enter(>wwm_lock); - KASSERT(mutex->wwm_state != WW_UNLOCKED); + WW_UNLOCKED(mutex); + KASSERTMSG(mutex->wwm_state != WW_UNLOCKED, "mutex %p", mutex); switch (mutex->wwm_state) { case WW_UNLOCKED: panic("unlocking unlocked wait/wound mutex: %p", mutex); @@ -1070,7 +1071,6 @@ ww_mutex_unlock(struct ww_mutex *mutex) mutex->wwm_state = WW_UNLOCKED; break; } - WW_UNLOCKED(mutex); cv_broadcast(>wwm_cv); mutex_exit(>wwm_lock); }
CVS commit: src/sys/external/bsd/drm2/linux
Module Name:src Committed By: riastradh Date: Fri Mar 18 23:33:41 UTC 2022 Modified Files: src/sys/external/bsd/drm2/linux: linux_ww_mutex.c Log Message: drm: In ww_mutex_unlock, do lockdebug check first. This way we get a full lockdebug dump when LOCKDEBUG is enabled, instead of just the panic message (which includes the lock address you could pass to `show lock' in ddb, but let's get the dump by default even if you don't enter ddb). Also in the KASSERT print the mutex. To generate a diff of this commit: cvs rdiff -u -r1.13 -r1.14 src/sys/external/bsd/drm2/linux/linux_ww_mutex.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/external/bsd/drm2/linux
Module Name:src Committed By: jakllsch Date: Sun Feb 27 15:02:58 UTC 2022 Modified Files: src/sys/external/bsd/drm2/linux: files.drmkms_linux Log Message: only build linux_acpi.c if we have acpi(4) in the kernel To generate a diff of this commit: cvs rdiff -u -r1.41 -r1.42 src/sys/external/bsd/drm2/linux/files.drmkms_linux Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/external/bsd/drm2/linux/files.drmkms_linux diff -u src/sys/external/bsd/drm2/linux/files.drmkms_linux:1.41 src/sys/external/bsd/drm2/linux/files.drmkms_linux:1.42 --- src/sys/external/bsd/drm2/linux/files.drmkms_linux:1.41 Sun Feb 27 14:22:21 2022 +++ src/sys/external/bsd/drm2/linux/files.drmkms_linux Sun Feb 27 15:02:58 2022 @@ -1,11 +1,11 @@ -# $NetBSD: files.drmkms_linux,v 1.41 2022/02/27 14:22:21 riastradh Exp $ +# $NetBSD: files.drmkms_linux,v 1.42 2022/02/27 15:02:58 jakllsch Exp $ define drmkms_linux: i2cexec, i2c_bitbang makeoptions drmkms_linux "CPPFLAGS.drmkms_linux"+="-I$S/external/bsd/common/include" makeoptions drmkms_linux "CPPFLAGS.drmkms_linux"+="-I$S/external/bsd/drm2/include" -file external/bsd/drm2/linux/linux_acpi.c drmkms_linux +file external/bsd/drm2/linux/linux_acpi.c drmkms_linux & acpi file external/bsd/drm2/linux/linux_atomic64.c drmkms_linux file external/bsd/drm2/linux/linux_backlight.c drmkms_linux file external/bsd/drm2/linux/linux_dma_buf.c drmkms_linux
CVS commit: src/sys/external/bsd/drm2/linux
Module Name:src Committed By: jakllsch Date: Sun Feb 27 15:02:58 UTC 2022 Modified Files: src/sys/external/bsd/drm2/linux: files.drmkms_linux Log Message: only build linux_acpi.c if we have acpi(4) in the kernel To generate a diff of this commit: cvs rdiff -u -r1.41 -r1.42 src/sys/external/bsd/drm2/linux/files.drmkms_linux Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/external/bsd/drm2/linux
Module Name:src Committed By: riastradh Date: Sun Feb 27 14:19:20 UTC 2022 Modified Files: src/sys/external/bsd/drm2/linux: linux_pci.c Log Message: drm: Deconditionalize pci_get_segment. To generate a diff of this commit: cvs rdiff -u -r1.20 -r1.21 src/sys/external/bsd/drm2/linux/linux_pci.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/external/bsd/drm2/linux/linux_pci.c diff -u src/sys/external/bsd/drm2/linux/linux_pci.c:1.20 src/sys/external/bsd/drm2/linux/linux_pci.c:1.21 --- src/sys/external/bsd/drm2/linux/linux_pci.c:1.20 Sun Dec 19 12:00:16 2021 +++ src/sys/external/bsd/drm2/linux/linux_pci.c Sun Feb 27 14:19:20 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_pci.c,v 1.20 2021/12/19 12:00:16 riastradh Exp $ */ +/* $NetBSD: linux_pci.c,v 1.21 2022/02/27 14:19:20 riastradh Exp $ */ /*- * Copyright (c) 2013 The NetBSD Foundation, Inc. @@ -35,7 +35,7 @@ #endif #include -__KERNEL_RCSID(0, "$NetBSD: linux_pci.c,v 1.20 2021/12/19 12:00:16 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux_pci.c,v 1.21 2022/02/27 14:19:20 riastradh Exp $"); #if NACPICA > 0 #include @@ -88,11 +88,7 @@ linux_pci_dev_init(struct pci_dev *pdev, pdev->pd_rom_vaddr = NULL; pdev->pd_dev = dev; #if (NACPICA > 0) -#ifdef __HAVE_PCI_GET_SEGMENT const int seg = pci_get_segment(pa->pa_pc); -#else - const int seg = 0; -#endif pdev->pd_ad = acpi_pcidev_find(seg, pa->pa_bus, pa->pa_device, pa->pa_function); #else
CVS commit: src/sys/external/bsd/drm2/linux
Module Name:src Committed By: riastradh Date: Sun Feb 27 14:19:20 UTC 2022 Modified Files: src/sys/external/bsd/drm2/linux: linux_pci.c Log Message: drm: Deconditionalize pci_get_segment. To generate a diff of this commit: cvs rdiff -u -r1.20 -r1.21 src/sys/external/bsd/drm2/linux/linux_pci.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/external/bsd/drm2/linux
Module Name:src Committed By: riastradh Date: Thu Feb 17 01:38:38 UTC 2022 Modified Files: src/sys/external/bsd/drm2/linux: linux_dma_buf.c Log Message: drm: Fix membars around dma_buf_put reference count release. To generate a diff of this commit: cvs rdiff -u -r1.13 -r1.14 src/sys/external/bsd/drm2/linux/linux_dma_buf.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/external/bsd/drm2/linux/linux_dma_buf.c diff -u src/sys/external/bsd/drm2/linux/linux_dma_buf.c:1.13 src/sys/external/bsd/drm2/linux/linux_dma_buf.c:1.14 --- src/sys/external/bsd/drm2/linux/linux_dma_buf.c:1.13 Sun Dec 19 12:01:40 2021 +++ src/sys/external/bsd/drm2/linux/linux_dma_buf.c Thu Feb 17 01:38:38 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_dma_buf.c,v 1.13 2021/12/19 12:01:40 riastradh Exp $ */ +/* $NetBSD: linux_dma_buf.c,v 1.14 2022/02/17 01:38:38 riastradh Exp $ */ /*- * Copyright (c) 2018 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: linux_dma_buf.c,v 1.13 2021/12/19 12:01:40 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux_dma_buf.c,v 1.14 2022/02/17 01:38:38 riastradh Exp $"); #include #include @@ -160,8 +160,10 @@ void dma_buf_put(struct dma_buf *dmabuf) { + membar_exit(); if (atomic_dec_uint_nv(>db_refcnt) != 0) return; + membar_enter(); dma_resv_poll_fini(>db_resv_poll); mutex_destroy(>db_lock);
CVS commit: src/sys/external/bsd/drm2/linux
Module Name:src Committed By: riastradh Date: Thu Feb 17 01:38:38 UTC 2022 Modified Files: src/sys/external/bsd/drm2/linux: linux_dma_buf.c Log Message: drm: Fix membars around dma_buf_put reference count release. To generate a diff of this commit: cvs rdiff -u -r1.13 -r1.14 src/sys/external/bsd/drm2/linux/linux_dma_buf.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/external/bsd/drm2/linux
Module Name:src Committed By: riastradh Date: Tue Feb 15 22:51:03 UTC 2022 Modified Files: src/sys/external/bsd/drm2/linux: linux_dma_resv.c Log Message: drm: Use KM_SLEEP to allocate reservation fence arrays. Except as a fast path in an RCU reader. The array sizes appear to be reasonably small and not trivially controlled by userland, from what I can tell, so if my impression is accurate, it is reasonable to sleep for allocation here. To generate a diff of this commit: cvs rdiff -u -r1.21 -r1.22 src/sys/external/bsd/drm2/linux/linux_dma_resv.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/external/bsd/drm2/linux/linux_dma_resv.c diff -u src/sys/external/bsd/drm2/linux/linux_dma_resv.c:1.21 src/sys/external/bsd/drm2/linux/linux_dma_resv.c:1.22 --- src/sys/external/bsd/drm2/linux/linux_dma_resv.c:1.21 Sun Dec 19 12:36:02 2021 +++ src/sys/external/bsd/drm2/linux/linux_dma_resv.c Tue Feb 15 22:51:03 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_dma_resv.c,v 1.21 2021/12/19 12:36:02 riastradh Exp $ */ +/* $NetBSD: linux_dma_resv.c,v 1.22 2022/02/15 22:51:03 riastradh Exp $ */ /*- * Copyright (c) 2018 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: linux_dma_resv.c,v 1.21 2021/12/19 12:36:02 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux_dma_resv.c,v 1.22 2022/02/15 22:51:03 riastradh Exp $"); #include #include @@ -56,6 +56,17 @@ objlist_tryalloc(uint32_t n) return list; } +static struct dma_resv_list * +objlist_alloc(uint32_t n) +{ + struct dma_resv_list *list; + + list = kmem_alloc(offsetof(typeof(*list), shared[n]), KM_SLEEP); + list->shared_max = n; + + return list; +} + static void objlist_free(struct dma_resv_list *list) { @@ -346,9 +357,7 @@ dma_resv_reserve_shared(struct dma_resv /* Try to double its capacity. */ nalloc = n > UINT32_MAX/2 ? UINT32_MAX : 2*n; - prealloc = objlist_tryalloc(nalloc); - if (prealloc == NULL) - return -ENOMEM; + prealloc = objlist_alloc(nalloc); /* Swap the new preallocated list and free the old one. */ objlist_free(robj->robj_prealloc); @@ -356,9 +365,8 @@ dma_resv_reserve_shared(struct dma_resv } else { /* Start with some spare. */ nalloc = n > UINT32_MAX/2 ? UINT32_MAX : MAX(2*n, 4); - prealloc = objlist_tryalloc(nalloc); - if (prealloc == NULL) - return -ENOMEM; + prealloc = objlist_alloc(nalloc); + /* Save the new preallocated list. */ robj->robj_prealloc = prealloc; } @@ -689,8 +697,10 @@ dma_resv_add_shared_fence(struct dma_res prealloc->shared_count = shared_count; /* If we didn't find one, add it at the end. */ - if (replace == NULL) + if (replace == NULL) { + KASSERT(prealloc->shared_count < prealloc->shared_max); prealloc->shared[prealloc->shared_count++] = fence; + } /* * Now ready to replace the list. Begin an update. @@ -919,11 +929,20 @@ top: KASSERT(fence == NULL); if (!dma_resv_get_shared_reader(src_robj, _list, _count, _ticket)) goto restart; - if (src_list != NULL) { - /* Allocate a new list. */ - dst_list = objlist_tryalloc(shared_count); + if (src_list) { + /* Allocate a new list, if necessary. */ if (dst_list == NULL) - return -ENOMEM; + dst_list = objlist_tryalloc(shared_count); + if (dst_list == NULL || dst_list->shared_max < shared_count) { + rcu_read_unlock(); + if (dst_list) { +objlist_free(dst_list); +dst_list = NULL; + } + dst_list = objlist_alloc(shared_count); + dst_list->shared_count = 0; /* paranoia */ + goto top; + } /* Copy over all fences that are not yet signalled. */ dst_list->shared_count = 0; @@ -1005,8 +1024,7 @@ restart: dma_fence_put(dst_list->shared[i]); dst_list->shared[i] = NULL; /* paranoia */ } - objlist_free(dst_list); - dst_list = NULL; + /* reuse dst_list allocation for the next attempt */ } goto top; }
CVS commit: src/sys/external/bsd/drm2/linux
Module Name:src Committed By: riastradh Date: Tue Feb 15 22:51:03 UTC 2022 Modified Files: src/sys/external/bsd/drm2/linux: linux_dma_resv.c Log Message: drm: Use KM_SLEEP to allocate reservation fence arrays. Except as a fast path in an RCU reader. The array sizes appear to be reasonably small and not trivially controlled by userland, from what I can tell, so if my impression is accurate, it is reasonable to sleep for allocation here. To generate a diff of this commit: cvs rdiff -u -r1.21 -r1.22 src/sys/external/bsd/drm2/linux/linux_dma_resv.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/external/bsd/drm2/linux
Module Name:src Committed By: riastradh Date: Sun Dec 26 16:14:34 UTC 2021 Modified Files: src/sys/external/bsd/drm2/linux: linux_ww_mutex.c Log Message: drm: Allow ww_mutex_lock after ww_acquire_done if we already hold it. In other words, if ww_mutex_lock would return -EALREADY, that's OK and does not warrant an assertion. PR kern/56557 To generate a diff of this commit: cvs rdiff -u -r1.12 -r1.13 src/sys/external/bsd/drm2/linux/linux_ww_mutex.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/external/bsd/drm2/linux
Module Name:src Committed By: riastradh Date: Fri Dec 24 15:08:31 UTC 2021 Modified Files: src/sys/external/bsd/drm2/linux: linux_sgt.c Log Message: drm: Sprinkle some assertions into sg dma logic. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/sys/external/bsd/drm2/linux/linux_sgt.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/external/bsd/drm2/linux/linux_sgt.c diff -u src/sys/external/bsd/drm2/linux/linux_sgt.c:1.3 src/sys/external/bsd/drm2/linux/linux_sgt.c:1.4 --- src/sys/external/bsd/drm2/linux/linux_sgt.c:1.3 Sun Dec 19 12:10:42 2021 +++ src/sys/external/bsd/drm2/linux/linux_sgt.c Fri Dec 24 15:08:31 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_sgt.c,v 1.3 2021/12/19 12:10:42 riastradh Exp $ */ +/* $NetBSD: linux_sgt.c,v 1.4 2021/12/24 15:08:31 riastradh Exp $ */ /*- * Copyright (c) 2021 The NetBSD Foundation, Inc. @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: linux_sgt.c,v 1.3 2021/12/19 12:10:42 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux_sgt.c,v 1.4 2021/12/24 15:08:31 riastradh Exp $"); #include #include @@ -153,6 +153,7 @@ dma_map_sg_attrs(bus_dma_tag_t dmat, str int ret, error = 0; KASSERT(sg->sg_dmamap == NULL); + KASSERT(sg->sg_npgs); KASSERT(nents >= 1); switch (dir) { @@ -213,6 +214,8 @@ dma_unmap_sg_attrs(bus_dma_tag_t dmat, s int dir, int attrs) { + KASSERT(sg->sg_dmat == dmat); + bus_dmamap_unload(dmat, sg->sg_dmamap); bus_dmamap_destroy(dmat, sg->sg_dmamap); sg->sg_dmamap = NULL;
CVS commit: src/sys/external/bsd/drm2/linux
Module Name:src Committed By: riastradh Date: Fri Dec 24 15:08:31 UTC 2021 Modified Files: src/sys/external/bsd/drm2/linux: linux_sgt.c Log Message: drm: Sprinkle some assertions into sg dma logic. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/sys/external/bsd/drm2/linux/linux_sgt.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/external/bsd/drm2/linux
Module Name:src Committed By: riastradh Date: Sun Dec 19 12:43:06 UTC 2021 Modified Files: src/sys/external/bsd/drm2/linux: linux_kthread.c Log Message: drm: Work around busted kthread_join. To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/sys/external/bsd/drm2/linux/linux_kthread.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/external/bsd/drm2/linux/linux_kthread.c diff -u src/sys/external/bsd/drm2/linux/linux_kthread.c:1.8 src/sys/external/bsd/drm2/linux/linux_kthread.c:1.9 --- src/sys/external/bsd/drm2/linux/linux_kthread.c:1.8 Sun Dec 19 12:42:48 2021 +++ src/sys/external/bsd/drm2/linux/linux_kthread.c Sun Dec 19 12:43:05 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_kthread.c,v 1.8 2021/12/19 12:42:48 riastradh Exp $ */ +/* $NetBSD: linux_kthread.c,v 1.9 2021/12/19 12:43:05 riastradh Exp $ */ /*- * Copyright (c) 2021 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: linux_kthread.c,v 1.8 2021/12/19 12:42:48 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux_kthread.c,v 1.9 2021/12/19 12:43:05 riastradh Exp $"); #include @@ -53,6 +53,8 @@ struct task_struct { bool kt_shouldstop:1; bool kt_shouldpark:1; bool kt_parked:1; + bool kt_exited:1; + int kt_ret; int (*kt_func)(void *); void *kt_cookie; @@ -111,7 +113,19 @@ linux_kthread_start(void *cookie) lwp_setspecific(linux_kthread_key, T); ret = (*T->kt_func)(T->kt_cookie); - kthread_exit(ret); + + /* + * Mark the thread exited, set the return value, and wake any + * waiting kthread_stop. + */ + mutex_enter(>kt_lock); + T->kt_exited = true; + T->kt_ret = ret; + cv_broadcast(>kt_cv); + mutex_exit(>kt_lock); + + /* Exit the (NetBSD) kthread. */ + kthread_exit(0); } static struct task_struct * @@ -125,6 +139,12 @@ kthread_alloc(int (*func)(void *), void mutex_init(>kt_lock, MUTEX_DEFAULT, IPL_VM); cv_init(>kt_cv, "lnxkthrd"); + T->kt_shouldstop = false; + T->kt_shouldpark = false; + T->kt_parked = false; + T->kt_exited = false; + T->kt_ret = 0; + T->kt_func = func; T->kt_cookie = cookie; T->kt_interlock = interlock; @@ -137,6 +157,8 @@ static void kthread_free(struct task_struct *T) { + KASSERT(T->kt_exited); + cv_destroy(>kt_cv); mutex_destroy(>kt_lock); kmem_free(T, sizeof(*T)); @@ -150,7 +172,7 @@ kthread_run(int (*func)(void *), void *c int error; T = kthread_alloc(func, cookie, interlock, wq); - error = kthread_create(PRI_NONE, KTHREAD_MPSAFE|KTHREAD_MUSTJOIN, NULL, + error = kthread_create(PRI_NONE, KTHREAD_MPSAFE, NULL, linux_kthread_start, T, >kt_lwp, "%s", name); if (error) { kthread_free(T); @@ -178,12 +200,16 @@ kthread_stop(struct task_struct *T) cv_broadcast(>kt_cv); DRM_SPIN_WAKEUP_ALL(T->kt_wq, T->kt_interlock); - /* Release the locks. */ - mutex_exit(>kt_lock); + /* Release the interlock while we wait for thread to finish. */ spin_unlock(T->kt_interlock); - /* Wait for the (NetBSD) kthread to exit. */ - ret = kthread_join(T->kt_lwp); + /* Wait for the thread to finish. */ + while (!T->kt_exited) + cv_wait(>kt_cv, >kt_lock); + + /* Grab the return code and release the lock -- we're done. */ + ret = T->kt_ret; + mutex_exit(>kt_lock); /* Free the (Linux) kthread. */ kthread_free(T);
CVS commit: src/sys/external/bsd/drm2/linux
Module Name:src Committed By: riastradh Date: Sun Dec 19 12:43:06 UTC 2021 Modified Files: src/sys/external/bsd/drm2/linux: linux_kthread.c Log Message: drm: Work around busted kthread_join. To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/sys/external/bsd/drm2/linux/linux_kthread.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/external/bsd/drm2/linux
Module Name:src Committed By: riastradh Date: Sun Dec 19 12:42:48 UTC 2021 Modified Files: src/sys/external/bsd/drm2/linux: linux_kthread.c Log Message: drm: Fix error return for kthread_run: error pointer, not null. To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/sys/external/bsd/drm2/linux/linux_kthread.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/external/bsd/drm2/linux/linux_kthread.c diff -u src/sys/external/bsd/drm2/linux/linux_kthread.c:1.7 src/sys/external/bsd/drm2/linux/linux_kthread.c:1.8 --- src/sys/external/bsd/drm2/linux/linux_kthread.c:1.7 Sun Dec 19 12:42:32 2021 +++ src/sys/external/bsd/drm2/linux/linux_kthread.c Sun Dec 19 12:42:48 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_kthread.c,v 1.7 2021/12/19 12:42:32 riastradh Exp $ */ +/* $NetBSD: linux_kthread.c,v 1.8 2021/12/19 12:42:48 riastradh Exp $ */ /*- * Copyright (c) 2021 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: linux_kthread.c,v 1.7 2021/12/19 12:42:32 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux_kthread.c,v 1.8 2021/12/19 12:42:48 riastradh Exp $"); #include @@ -41,6 +41,7 @@ __KERNEL_RCSID(0, "$NetBSD: linux_kthrea #include #include +#include #include #include @@ -153,7 +154,7 @@ kthread_run(int (*func)(void *), void *c linux_kthread_start, T, >kt_lwp, "%s", name); if (error) { kthread_free(T); - T = NULL; + return ERR_PTR(-error); /* XXX errno NetBSD->Linux */ } return T;
CVS commit: src/sys/external/bsd/drm2/linux
Module Name:src Committed By: riastradh Date: Sun Dec 19 12:42:48 UTC 2021 Modified Files: src/sys/external/bsd/drm2/linux: linux_kthread.c Log Message: drm: Fix error return for kthread_run: error pointer, not null. To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/sys/external/bsd/drm2/linux/linux_kthread.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/external/bsd/drm2/linux
Module Name:src Committed By: riastradh Date: Sun Dec 19 12:42:15 UTC 2021 Modified Files: src/sys/external/bsd/drm2/linux: linux_kthread.c Log Message: drm: Trigger `spurious' wakeup for kthread_stop too. To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/sys/external/bsd/drm2/linux/linux_kthread.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/external/bsd/drm2/linux/linux_kthread.c diff -u src/sys/external/bsd/drm2/linux/linux_kthread.c:1.4 src/sys/external/bsd/drm2/linux/linux_kthread.c:1.5 --- src/sys/external/bsd/drm2/linux/linux_kthread.c:1.4 Sun Dec 19 12:38:56 2021 +++ src/sys/external/bsd/drm2/linux/linux_kthread.c Sun Dec 19 12:42:14 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_kthread.c,v 1.4 2021/12/19 12:38:56 riastradh Exp $ */ +/* $NetBSD: linux_kthread.c,v 1.5 2021/12/19 12:42:14 riastradh Exp $ */ /*- * Copyright (c) 2021 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: linux_kthread.c,v 1.4 2021/12/19 12:38:56 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux_kthread.c,v 1.5 2021/12/19 12:42:14 riastradh Exp $"); #include @@ -150,18 +150,56 @@ kthread_run(int (*func)(void *), void *c return T; } +/* + * lwp_kick(l) + * + * Cause l to wake up if it is asleep, no matter what condvar or + * other wchan it's asleep on. This logic is like sleepq_timeout, + * but without setting LW_STIMO. This is not a general-purpose + * mechanism -- don't go around using this instead of condvars. + */ +static void +lwp_kick(struct lwp *l) +{ + + lwp_lock(l); + if (l->l_wchan == NULL) { + /* Not sleeping, so no need to wake up. */ + lwp_unlock(l); + } else { + /* + * Sleeping, so wake it up. lwp_unsleep has the side + * effect of unlocking l when we pass unlock=true. + */ + lwp_unsleep(l, /*unlock*/true); + } +} + int kthread_stop(struct task_struct *T) { + struct lwp *l; int ret; + /* + * Notify the thread that it's stopping, and wake it if it's + * parked. + */ mutex_enter(>kt_lock); T->kt_shouldpark = false; T->kt_shouldstop = true; cv_broadcast(>kt_cv); mutex_exit(>kt_lock); - ret = kthread_join(T->kt_lwp); + /* + * Kick the lwp in case it's waiting on anything else, and then + * wait for it to complete. It is the thread's obligation to + * check kthread_shouldstop before sleeping again. + */ + l = T->kt_lwp; + KASSERT(l != curlwp); + lwp_kick(l); + ret = kthread_join(l); kthread_free(T); @@ -201,23 +239,9 @@ kthread_park(struct task_struct *T) /* * If the thread is asleep for any reason, give it a spurious * wakeup. The thread is responsible for checking - * kthread_shouldpark before sleeping. This logic is like - * sleepq_timeout, but without setting LW_STIMO. + * kthread_shouldpark before sleeping. */ - lwp_lock(l); - if (l->l_wchan == NULL) { - /* - * Not sleeping, so no need to wake up -- the thread - * will eventually check kthread_shouldpark. - */ - lwp_unlock(l); - } else { - /* - * Sleeping, so wake it up. lwp_unsleep has the side - * effect of unlocking l when we pass unlock=true. - */ - lwp_unsleep(l, /*unlock*/true); - } + lwp_kick(l); /* Wait until the thread has issued kthread_parkme. */ while (!T->kt_parked)
CVS commit: src/sys/external/bsd/drm2/linux
Module Name:src Committed By: riastradh Date: Sun Dec 19 12:42:15 UTC 2021 Modified Files: src/sys/external/bsd/drm2/linux: linux_kthread.c Log Message: drm: Trigger `spurious' wakeup for kthread_stop too. To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/sys/external/bsd/drm2/linux/linux_kthread.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/external/bsd/drm2/linux
Module Name:src Committed By: riastradh Date: Sun Dec 19 12:39:56 UTC 2021 Modified Files: src/sys/external/bsd/drm2/linux: linux_dma_fence_array.c Log Message: drm: Make dma fence array name strings match Linux. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 \ src/sys/external/bsd/drm2/linux/linux_dma_fence_array.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/external/bsd/drm2/linux/linux_dma_fence_array.c diff -u src/sys/external/bsd/drm2/linux/linux_dma_fence_array.c:1.3 src/sys/external/bsd/drm2/linux/linux_dma_fence_array.c:1.4 --- src/sys/external/bsd/drm2/linux/linux_dma_fence_array.c:1.3 Sun Dec 19 12:33:26 2021 +++ src/sys/external/bsd/drm2/linux/linux_dma_fence_array.c Sun Dec 19 12:39:56 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_dma_fence_array.c,v 1.3 2021/12/19 12:33:26 riastradh Exp $ */ +/* $NetBSD: linux_dma_fence_array.c,v 1.4 2021/12/19 12:39:56 riastradh Exp $ */ /*- * Copyright (c) 2021 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: linux_dma_fence_array.c,v 1.3 2021/12/19 12:33:26 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux_dma_fence_array.c,v 1.4 2021/12/19 12:39:56 riastradh Exp $"); #include @@ -39,13 +39,13 @@ __KERNEL_RCSID(0, "$NetBSD: linux_dma_fe static const char * dma_fence_array_driver_name(struct dma_fence *fence) { - return "dma-fence-array"; + return "dma_fence_array"; } static const char * dma_fence_array_timeline_name(struct dma_fence *fence) { - return "dma-fence-array-timeline"; + return "unbound"; } static void
CVS commit: src/sys/external/bsd/drm2/linux
Module Name:src Committed By: riastradh Date: Sun Dec 19 12:39:56 UTC 2021 Modified Files: src/sys/external/bsd/drm2/linux: linux_dma_fence_array.c Log Message: drm: Make dma fence array name strings match Linux. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 \ src/sys/external/bsd/drm2/linux/linux_dma_fence_array.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/external/bsd/drm2/linux
Module Name:src Committed By: riastradh Date: Sun Dec 19 12:39:41 UTC 2021 Modified Files: src/sys/external/bsd/drm2/linux: linux_dma_fence.c Log Message: drm: Use atomic_load_consume/relaxed to simplify code. To generate a diff of this commit: cvs rdiff -u -r1.38 -r1.39 src/sys/external/bsd/drm2/linux/linux_dma_fence.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/external/bsd/drm2/linux/linux_dma_fence.c diff -u src/sys/external/bsd/drm2/linux/linux_dma_fence.c:1.38 src/sys/external/bsd/drm2/linux/linux_dma_fence.c:1.39 --- src/sys/external/bsd/drm2/linux/linux_dma_fence.c:1.38 Sun Dec 19 12:39:25 2021 +++ src/sys/external/bsd/drm2/linux/linux_dma_fence.c Sun Dec 19 12:39:40 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_dma_fence.c,v 1.38 2021/12/19 12:39:25 riastradh Exp $ */ +/* $NetBSD: linux_dma_fence.c,v 1.39 2021/12/19 12:39:40 riastradh Exp $ */ /*- * Copyright (c) 2018 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: linux_dma_fence.c,v 1.38 2021/12/19 12:39:25 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux_dma_fence.c,v 1.39 2021/12/19 12:39:40 riastradh Exp $"); #include #include @@ -394,21 +394,16 @@ dma_fence_get_rcu(struct dma_fence *fenc struct dma_fence * dma_fence_get_rcu_safe(struct dma_fence *volatile const *fencep) { - struct dma_fence *fence, *fence0; + struct dma_fence *fence; retry: - fence = *fencep; - - /* Load fence only once. */ - __insn_barrier(); - - /* If there's nothing there, give up. */ - if (fence == NULL) + /* + * Load the fence, ensuring we observe the fully initialized + * content. + */ + if ((fence = atomic_load_consume(fencep)) == NULL) return NULL; - /* Make sure we don't load stale fence guts. */ - membar_datadep_consumer(); - /* Try to acquire a reference. If we can't, try again. */ if (!dma_fence_get_rcu(fence)) goto retry; @@ -417,9 +412,7 @@ retry: * Confirm that it's still the same fence. If not, release it * and retry. */ - fence0 = *fencep; - __insn_barrier(); - if (fence != fence0) { + if (fence != atomic_load_relaxed(fencep)) { dma_fence_put(fence); goto retry; }
CVS commit: src/sys/external/bsd/drm2/linux
Module Name:src Committed By: riastradh Date: Sun Dec 19 12:39:41 UTC 2021 Modified Files: src/sys/external/bsd/drm2/linux: linux_dma_fence.c Log Message: drm: Use atomic_load_consume/relaxed to simplify code. To generate a diff of this commit: cvs rdiff -u -r1.38 -r1.39 src/sys/external/bsd/drm2/linux/linux_dma_fence.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/external/bsd/drm2/linux
Module Name:src Committed By: riastradh Date: Sun Dec 19 12:39:16 UTC 2021 Modified Files: src/sys/external/bsd/drm2/linux: linux_dma_fence_chain.c Log Message: drm: Release fence in dma_fence_chain_walk. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 \ src/sys/external/bsd/drm2/linux/linux_dma_fence_chain.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/external/bsd/drm2/linux/linux_dma_fence_chain.c diff -u src/sys/external/bsd/drm2/linux/linux_dma_fence_chain.c:1.1 src/sys/external/bsd/drm2/linux/linux_dma_fence_chain.c:1.2 --- src/sys/external/bsd/drm2/linux/linux_dma_fence_chain.c:1.1 Sun Dec 19 10:47:06 2021 +++ src/sys/external/bsd/drm2/linux/linux_dma_fence_chain.c Sun Dec 19 12:39:16 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_dma_fence_chain.c,v 1.1 2021/12/19 10:47:06 riastradh Exp $ */ +/* $NetBSD: linux_dma_fence_chain.c,v 1.2 2021/12/19 12:39:16 riastradh Exp $ */ /*- * Copyright (c) 2020 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: linux_dma_fence_chain.c,v 1.1 2021/12/19 10:47:06 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux_dma_fence_chain.c,v 1.2 2021/12/19 12:39:16 riastradh Exp $"); #include @@ -103,6 +103,7 @@ dma_fence_chain_walk(struct dma_fence *f { /* XXX */ + dma_fence_put(fence); return NULL; }
CVS commit: src/sys/external/bsd/drm2/linux
Module Name:src Committed By: riastradh Date: Sun Dec 19 12:39:16 UTC 2021 Modified Files: src/sys/external/bsd/drm2/linux: linux_dma_fence_chain.c Log Message: drm: Release fence in dma_fence_chain_walk. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 \ src/sys/external/bsd/drm2/linux/linux_dma_fence_chain.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/external/bsd/drm2/linux
Module Name:src Committed By: riastradh Date: Sun Dec 19 12:38:56 UTC 2021 Modified Files: src/sys/external/bsd/drm2/linux: linux_kthread.c Log Message: linux: In kthread_park, wake thread to re-check kthread_shouldpark. Otherwise, the thread to pakr may be sleeping on some condvar not noticing it has to notify kthread_park --> deadlock. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/sys/external/bsd/drm2/linux/linux_kthread.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/external/bsd/drm2/linux/linux_kthread.c diff -u src/sys/external/bsd/drm2/linux/linux_kthread.c:1.3 src/sys/external/bsd/drm2/linux/linux_kthread.c:1.4 --- src/sys/external/bsd/drm2/linux/linux_kthread.c:1.3 Sun Dec 19 12:29:39 2021 +++ src/sys/external/bsd/drm2/linux/linux_kthread.c Sun Dec 19 12:38:56 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_kthread.c,v 1.3 2021/12/19 12:29:39 riastradh Exp $ */ +/* $NetBSD: linux_kthread.c,v 1.4 2021/12/19 12:38:56 riastradh Exp $ */ /*- * Copyright (c) 2021 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: linux_kthread.c,v 1.3 2021/12/19 12:29:39 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux_kthread.c,v 1.4 2021/12/19 12:38:56 riastradh Exp $"); #include @@ -184,13 +184,46 @@ kthread_should_stop(void) void kthread_park(struct task_struct *T) { + struct lwp *l; mutex_enter(>kt_lock); + + /* Caller must not ask to park if they've already asked to stop. */ KASSERT(!T->kt_shouldstop); + + /* Ask the thread to park. */ T->kt_shouldpark = true; + + /* Don't wait for ourselves -- Linux allows this semantics. */ + if ((l = T->kt_lwp) == curlwp) + goto out; + + /* + * If the thread is asleep for any reason, give it a spurious + * wakeup. The thread is responsible for checking + * kthread_shouldpark before sleeping. This logic is like + * sleepq_timeout, but without setting LW_STIMO. + */ + lwp_lock(l); + if (l->l_wchan == NULL) { + /* + * Not sleeping, so no need to wake up -- the thread + * will eventually check kthread_shouldpark. + */ + lwp_unlock(l); + } else { + /* + * Sleeping, so wake it up. lwp_unsleep has the side + * effect of unlocking l when we pass unlock=true. + */ + lwp_unsleep(l, /*unlock*/true); + } + + /* Wait until the thread has issued kthread_parkme. */ while (!T->kt_parked) cv_wait(>kt_cv, >kt_lock); - mutex_exit(>kt_lock); + +out: mutex_exit(>kt_lock); } void
CVS commit: src/sys/external/bsd/drm2/linux
Module Name:src Committed By: riastradh Date: Sun Dec 19 12:38:56 UTC 2021 Modified Files: src/sys/external/bsd/drm2/linux: linux_kthread.c Log Message: linux: In kthread_park, wake thread to re-check kthread_shouldpark. Otherwise, the thread to pakr may be sleeping on some condvar not noticing it has to notify kthread_park --> deadlock. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/sys/external/bsd/drm2/linux/linux_kthread.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/external/bsd/drm2/linux
Module Name:src Committed By: riastradh Date: Sun Dec 19 12:38:34 UTC 2021 Modified Files: src/sys/external/bsd/drm2/linux: linux_dma_fence.c Log Message: drm: Make sure dma_fence_wait gets traced too. Deduplicate. To generate a diff of this commit: cvs rdiff -u -r1.36 -r1.37 src/sys/external/bsd/drm2/linux/linux_dma_fence.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/external/bsd/drm2/linux/linux_dma_fence.c diff -u src/sys/external/bsd/drm2/linux/linux_dma_fence.c:1.36 src/sys/external/bsd/drm2/linux/linux_dma_fence.c:1.37 --- src/sys/external/bsd/drm2/linux/linux_dma_fence.c:1.36 Sun Dec 19 12:38:15 2021 +++ src/sys/external/bsd/drm2/linux/linux_dma_fence.c Sun Dec 19 12:38:33 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_dma_fence.c,v 1.36 2021/12/19 12:38:15 riastradh Exp $ */ +/* $NetBSD: linux_dma_fence.c,v 1.37 2021/12/19 12:38:33 riastradh Exp $ */ /*- * Copyright (c) 2018 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: linux_dma_fence.c,v 1.36 2021/12/19 12:38:15 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux_dma_fence.c,v 1.37 2021/12/19 12:38:33 riastradh Exp $"); #include #include @@ -965,11 +965,7 @@ dma_fence_wait(struct dma_fence *fence, KASSERT(dma_fence_referenced_p(fence)); - if (fence->ops->wait) - ret = (*fence->ops->wait)(fence, intr, MAX_SCHEDULE_TIMEOUT); - else - ret = dma_fence_default_wait(fence, intr, - MAX_SCHEDULE_TIMEOUT); + ret = dma_fence_wait_timeout(fence, intr, MAX_SCHEDULE_TIMEOUT); KASSERT(ret != 0); KASSERTMSG(ret == -ERESTARTSYS || ret == MAX_SCHEDULE_TIMEOUT, "ret=%ld", ret);
CVS commit: src/sys/external/bsd/drm2/linux
Module Name:src Committed By: riastradh Date: Sun Dec 19 12:38:34 UTC 2021 Modified Files: src/sys/external/bsd/drm2/linux: linux_dma_fence.c Log Message: drm: Make sure dma_fence_wait gets traced too. Deduplicate. To generate a diff of this commit: cvs rdiff -u -r1.36 -r1.37 src/sys/external/bsd/drm2/linux/linux_dma_fence.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/external/bsd/drm2/linux
Module Name:src Committed By: riastradh Date: Sun Dec 19 12:38:15 UTC 2021 Modified Files: src/sys/external/bsd/drm2/linux: linux_dma_fence.c Log Message: drm: Add dtrace probes to fences. To generate a diff of this commit: cvs rdiff -u -r1.35 -r1.36 src/sys/external/bsd/drm2/linux/linux_dma_fence.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/external/bsd/drm2/linux/linux_dma_fence.c diff -u src/sys/external/bsd/drm2/linux/linux_dma_fence.c:1.35 src/sys/external/bsd/drm2/linux/linux_dma_fence.c:1.36 --- src/sys/external/bsd/drm2/linux/linux_dma_fence.c:1.35 Sun Dec 19 12:38:06 2021 +++ src/sys/external/bsd/drm2/linux/linux_dma_fence.c Sun Dec 19 12:38:15 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_dma_fence.c,v 1.35 2021/12/19 12:38:06 riastradh Exp $ */ +/* $NetBSD: linux_dma_fence.c,v 1.36 2021/12/19 12:38:15 riastradh Exp $ */ /*- * Copyright (c) 2018 The NetBSD Foundation, Inc. @@ -30,11 +30,12 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: linux_dma_fence.c,v 1.35 2021/12/19 12:38:06 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux_dma_fence.c,v 1.36 2021/12/19 12:38:15 riastradh Exp $"); #include #include #include +#include #include #include @@ -46,6 +47,44 @@ __KERNEL_RCSID(0, "$NetBSD: linux_dma_fe #define FENCE_MAGIC_GOOD 0x607ba424048c37e5ULL #define FENCE_MAGIC_BAD 0x7641ca721344505fULL +SDT_PROBE_DEFINE1(sdt, drm, fence, init, +"struct dma_fence *"/*fence*/); +SDT_PROBE_DEFINE1(sdt, drm, fence, reset, +"struct dma_fence *"/*fence*/); +SDT_PROBE_DEFINE1(sdt, drm, fence, release, +"struct dma_fence *"/*fence*/); +SDT_PROBE_DEFINE1(sdt, drm, fence, free, +"struct dma_fence *"/*fence*/); +SDT_PROBE_DEFINE1(sdt, drm, fence, destroy, +"struct dma_fence *"/*fence*/); + +SDT_PROBE_DEFINE1(sdt, drm, fence, enable_signaling, +"struct dma_fence *"/*fence*/); +SDT_PROBE_DEFINE2(sdt, drm, fence, add_callback, +"struct dma_fence *"/*fence*/, +"struct dma_fence_callback *"/*callback*/); +SDT_PROBE_DEFINE2(sdt, drm, fence, remove_callback, +"struct dma_fence *"/*fence*/, +"struct dma_fence_callback *"/*callback*/); +SDT_PROBE_DEFINE2(sdt, drm, fence, callback, +"struct dma_fence *"/*fence*/, +"struct dma_fence_callback *"/*callback*/); +SDT_PROBE_DEFINE1(sdt, drm, fence, test, +"struct dma_fence *"/*fence*/); +SDT_PROBE_DEFINE2(sdt, drm, fence, set_error, +"struct dma_fence *"/*fence*/, +"int"/*error*/); +SDT_PROBE_DEFINE1(sdt, drm, fence, signal, +"struct dma_fence *"/*fence*/); + +SDT_PROBE_DEFINE3(sdt, drm, fence, wait_start, +"struct dma_fence *"/*fence*/, +"bool"/*intr*/, +"long"/*timeout*/); +SDT_PROBE_DEFINE2(sdt, drm, fence, wait_done, +"struct dma_fence *"/*fence*/, +"long"/*ret*/); + /* * linux_dma_fence_trace * @@ -97,6 +136,8 @@ dma_fence_init(struct dma_fence *fence, #ifdef DIAGNOSTIC fence->f_magic = FENCE_MAGIC_GOOD; #endif + + SDT_PROBE1(sdt, drm, fence, init, fence); } /* @@ -126,6 +167,8 @@ dma_fence_reset(struct dma_fence *fence, fence->context = context; fence->seqno = seqno; fence->error = 0; + + SDT_PROBE1(sdt, drm, fence, reset, fence); } /* @@ -142,6 +185,8 @@ dma_fence_destroy(struct dma_fence *fenc KASSERT(!dma_fence_referenced_p(fence)); + SDT_PROBE1(sdt, drm, fence, destroy, fence); + #ifdef DIAGNOSTIC fence->f_magic = FENCE_MAGIC_BAD; #endif @@ -179,6 +224,8 @@ dma_fence_free(struct dma_fence *fence) KASSERT(!dma_fence_referenced_p(fence)); + SDT_PROBE1(sdt, drm, fence, free, fence); + call_rcu(>rcu, _fence_free_cb); } @@ -355,6 +402,8 @@ dma_fence_release(struct kref *refcount) "fence %p has pending callbacks", fence); KASSERT(!dma_fence_referenced_p(fence)); + SDT_PROBE1(sdt, drm, fence, release, fence); + if (fence->ops->release) (*fence->ops->release)(fence); else @@ -408,12 +457,13 @@ dma_fence_ensure_signal_enabled(struct d * Otherwise, if it wasn't enabled yet, try to enable * signalling. */ - if (!already_enabled && - fence->ops->enable_signaling && - !(*fence->ops->enable_signaling)(fence)) { - /* If it failed, signal and return -ENOENT. */ - dma_fence_signal_locked(fence); - return -ENOENT; + if (!already_enabled && fence->ops->enable_signaling) { + SDT_PROBE1(sdt, drm, fence, enable_signaling, fence); + if (!(*fence->ops->enable_signaling)(fence)) { + /* If it failed, signal and return -ENOENT. */ + dma_fence_signal_locked(fence); + return -ENOENT; + } } /* Success! */ @@ -456,6 +506,7 @@ dma_fence_add_callback(struct dma_fence goto out1; /* Insert the callback. */ + SDT_PROBE2(sdt, drm, fence, add_callback, fence, fcb); fcb->func = fn; TAILQ_INSERT_TAIL(>f_callbacks, fcb, fcb_entry); fcb->fcb_onqueue = true; @@ -488,6 +539,7 @@ dma_fence_remove_callback(struct dma_fen spin_lock(fence->lock); onqueue =
CVS commit: src/sys/external/bsd/drm2/linux
Module Name:src Committed By: riastradh Date: Sun Dec 19 12:38:15 UTC 2021 Modified Files: src/sys/external/bsd/drm2/linux: linux_dma_fence.c Log Message: drm: Add dtrace probes to fences. To generate a diff of this commit: cvs rdiff -u -r1.35 -r1.36 src/sys/external/bsd/drm2/linux/linux_dma_fence.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/external/bsd/drm2/linux
Module Name:src Committed By: riastradh Date: Sun Dec 19 12:38:06 UTC 2021 Modified Files: src/sys/external/bsd/drm2/linux: linux_dma_fence.c Log Message: drm: Fix signalling return value if no enable_signaling op. To generate a diff of this commit: cvs rdiff -u -r1.34 -r1.35 src/sys/external/bsd/drm2/linux/linux_dma_fence.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/external/bsd/drm2/linux/linux_dma_fence.c diff -u src/sys/external/bsd/drm2/linux/linux_dma_fence.c:1.34 src/sys/external/bsd/drm2/linux/linux_dma_fence.c:1.35 --- src/sys/external/bsd/drm2/linux/linux_dma_fence.c:1.34 Sun Dec 19 12:35:21 2021 +++ src/sys/external/bsd/drm2/linux/linux_dma_fence.c Sun Dec 19 12:38:06 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_dma_fence.c,v 1.34 2021/12/19 12:35:21 riastradh Exp $ */ +/* $NetBSD: linux_dma_fence.c,v 1.35 2021/12/19 12:38:06 riastradh Exp $ */ /*- * Copyright (c) 2018 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: linux_dma_fence.c,v 1.34 2021/12/19 12:35:21 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux_dma_fence.c,v 1.35 2021/12/19 12:38:06 riastradh Exp $"); #include #include @@ -406,16 +406,14 @@ dma_fence_ensure_signal_enabled(struct d /* * Otherwise, if it wasn't enabled yet, try to enable - * signalling, or fail if the fence doesn't support that. + * signalling. */ - if (!already_enabled) { - if (fence->ops->enable_signaling == NULL) - return -ENOENT; - if (!(*fence->ops->enable_signaling)(fence)) { - /* If it failed, signal and return -ENOENT. */ - dma_fence_signal_locked(fence); - return -ENOENT; - } + if (!already_enabled && + fence->ops->enable_signaling && + !(*fence->ops->enable_signaling)(fence)) { + /* If it failed, signal and return -ENOENT. */ + dma_fence_signal_locked(fence); + return -ENOENT; } /* Success! */
CVS commit: src/sys/external/bsd/drm2/linux
Module Name:src Committed By: riastradh Date: Sun Dec 19 12:38:06 UTC 2021 Modified Files: src/sys/external/bsd/drm2/linux: linux_dma_fence.c Log Message: drm: Fix signalling return value if no enable_signaling op. To generate a diff of this commit: cvs rdiff -u -r1.34 -r1.35 src/sys/external/bsd/drm2/linux/linux_dma_fence.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/external/bsd/drm2/linux
Module Name:src Committed By: riastradh Date: Sun Dec 19 12:36:24 UTC 2021 Modified Files: src/sys/external/bsd/drm2/linux: linux_ww_mutex.c Log Message: drm: Spruce up ww_mutex comments. Audit return values. To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/sys/external/bsd/drm2/linux/linux_ww_mutex.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/external/bsd/drm2/linux/linux_ww_mutex.c diff -u src/sys/external/bsd/drm2/linux/linux_ww_mutex.c:1.9 src/sys/external/bsd/drm2/linux/linux_ww_mutex.c:1.10 --- src/sys/external/bsd/drm2/linux/linux_ww_mutex.c:1.9 Sun Dec 19 11:21:20 2021 +++ src/sys/external/bsd/drm2/linux/linux_ww_mutex.c Sun Dec 19 12:36:24 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_ww_mutex.c,v 1.9 2021/12/19 11:21:20 riastradh Exp $ */ +/* $NetBSD: linux_ww_mutex.c,v 1.10 2021/12/19 12:36:24 riastradh Exp $ */ /*- * Copyright (c) 2014 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: linux_ww_mutex.c,v 1.9 2021/12/19 11:21:20 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux_ww_mutex.c,v 1.10 2021/12/19 12:36:24 riastradh Exp $"); #include #include @@ -168,6 +168,13 @@ static lockops_t ww_lockops = { }; #endif +/* + * ww_mutex_init(mutex, class) + * + * Initialize mutex in the given class. Must precede any other + * ww_mutex_* operations. After done, mutex must be destroyed + * with ww_mutex_destroy. + */ void ww_mutex_init(struct ww_mutex *mutex, struct ww_class *class) { @@ -187,6 +194,13 @@ ww_mutex_init(struct ww_mutex *mutex, st #endif } +/* + * ww_mutex_destroy(mutex) + * + * Destroy mutex initialized by ww_mutex_init. Caller must not be + * with any other ww_mutex_* operations except after + * reinitializing with ww_mutex_init. + */ void ww_mutex_destroy(struct ww_mutex *mutex) { @@ -205,9 +219,15 @@ ww_mutex_destroy(struct ww_mutex *mutex) } /* - * XXX WARNING: This returns true if it is locked by ANYONE. Does not - * mean `Do I hold this lock?' (answering which really requires an - * acquire context). + * ww_mutex_is_locked(mutex) + * + * True if anyone holds mutex locked at the moment, false if not. + * Answer is stale as soon returned unless mutex is held by + * caller. + * + * XXX WARNING: This returns true if it is locked by ANYONE. Does + * not mean `Do I hold this lock?' (answering which really + * requires an acquire context). */ bool ww_mutex_is_locked(struct ww_mutex *mutex) @@ -233,33 +253,78 @@ ww_mutex_is_locked(struct ww_mutex *mute return locked; } +/* + * ww_mutex_state_wait(mutex, state) + * + * Wait for mutex, which must be in the given state, to transition + * to another state. Uninterruptible; never fails. + * + * Caller must hold mutex's internal lock. + * + * May sleep. + * + * Internal subroutine. + */ static void ww_mutex_state_wait(struct ww_mutex *mutex, enum ww_mutex_state state) { + KASSERT(mutex_owned(>wwm_lock)); KASSERT(mutex->wwm_state == state); do cv_wait(>wwm_cv, >wwm_lock); while (mutex->wwm_state == state); } +/* + * ww_mutex_state_wait_sig(mutex, state) + * + * Wait for mutex, which must be in the given state, to transition + * to another state, or fail if interrupted by a signal. Return 0 + * on success, -EINTR if interrupted by a signal. + * + * Caller must hold mutex's internal lock. + * + * May sleep. + * + * Internal subroutine. + */ static int ww_mutex_state_wait_sig(struct ww_mutex *mutex, enum ww_mutex_state state) { int ret; + KASSERT(mutex_owned(>wwm_lock)); KASSERT(mutex->wwm_state == state); do { /* XXX errno NetBSD->Linux */ ret = -cv_wait_sig(>wwm_cv, >wwm_lock); - if (ret == -ERESTART) - ret = -ERESTARTSYS; - if (ret) + if (ret) { + KASSERTMSG((ret == -EINTR || ret == -ERESTART), + "ret=%d", ret); + ret = -EINTR; break; + } } while (mutex->wwm_state == state); + KASSERTMSG((ret == 0 || ret == -EINTR), "ret=%d", ret); return ret; } +/* + * ww_mutex_lock_wait(mutex, ctx) + * + * With mutex locked and in the WW_CTX or WW_WANTOWN state, owned + * by another thread with an acquire context, wait to acquire + * mutex. While waiting, record ctx in the tree of waiters. Does + * not update the mutex state otherwise. + * + * Caller must not already hold mutex. Caller must hold mutex's + * internal lock. Uninterruptible; never fails. + * + * May sleep. + * + * Internal subroutine. + */ static void ww_mutex_lock_wait(struct ww_mutex *mutex, struct ww_acquire_ctx *ctx) { @@ -291,6 +356,22 @@ ww_mutex_lock_wait(struct ww_mutex *mute rb_tree_remove_node(>wwm_waiters, ctx); } +/* + * ww_mutex_lock_wait_sig(mutex, ctx) + * + * With mutex locked and in the WW_CTX or WW_WANTOWN state, owned + * by another thread with an acquire context, wait to acquire + * mutex and return 0, or return -EINTR if interrupted by a + * signal. While waiting, record ctx in
CVS commit: src/sys/external/bsd/drm2/linux
Module Name:src Committed By: riastradh Date: Sun Dec 19 12:36:24 UTC 2021 Modified Files: src/sys/external/bsd/drm2/linux: linux_ww_mutex.c Log Message: drm: Spruce up ww_mutex comments. Audit return values. To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/sys/external/bsd/drm2/linux/linux_ww_mutex.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/external/bsd/drm2/linux
Module Name:src Committed By: riastradh Date: Sun Dec 19 12:36:02 UTC 2021 Modified Files: src/sys/external/bsd/drm2/linux: linux_dma_resv.c Log Message: drm: Fix comment about dma_resv_lock_* return values. To generate a diff of this commit: cvs rdiff -u -r1.20 -r1.21 src/sys/external/bsd/drm2/linux/linux_dma_resv.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/external/bsd/drm2/linux/linux_dma_resv.c diff -u src/sys/external/bsd/drm2/linux/linux_dma_resv.c:1.20 src/sys/external/bsd/drm2/linux/linux_dma_resv.c:1.21 --- src/sys/external/bsd/drm2/linux/linux_dma_resv.c:1.20 Sun Dec 19 12:33:42 2021 +++ src/sys/external/bsd/drm2/linux/linux_dma_resv.c Sun Dec 19 12:36:02 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_dma_resv.c,v 1.20 2021/12/19 12:33:42 riastradh Exp $ */ +/* $NetBSD: linux_dma_resv.c,v 1.21 2021/12/19 12:36:02 riastradh Exp $ */ /*- * Copyright (c) 2018 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: linux_dma_resv.c,v 1.20 2021/12/19 12:33:42 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux_dma_resv.c,v 1.21 2021/12/19 12:36:02 riastradh Exp $"); #include #include @@ -165,7 +165,7 @@ dma_resv_lock_slow(struct dma_resv *robj * Acquire a reservation object's lock. Return 0 on success, * -EALREADY if caller already holds it, -EDEADLK if a * higher-priority owner holds it and the caller must back out and - * retry, -ERESTART/-EINTR if interrupted. + * retry, -EINTR if interrupted. */ int dma_resv_lock_interruptible(struct dma_resv *robj, @@ -182,7 +182,7 @@ dma_resv_lock_interruptible(struct dma_r * this lock or any others -- this is to be used in slow paths * after dma_resv_lock or dma_resv_lock_interruptible has failed * and the caller has backed out all other locks. Return 0 on - * success, -ERESTART/-EINTR if interrupted. + * success, -EINTR if interrupted. */ int dma_resv_lock_slow_interruptible(struct dma_resv *robj,
CVS commit: src/sys/external/bsd/drm2/linux
Module Name:src Committed By: riastradh Date: Sun Dec 19 12:36:02 UTC 2021 Modified Files: src/sys/external/bsd/drm2/linux: linux_dma_resv.c Log Message: drm: Fix comment about dma_resv_lock_* return values. To generate a diff of this commit: cvs rdiff -u -r1.20 -r1.21 src/sys/external/bsd/drm2/linux/linux_dma_resv.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/external/bsd/drm2/linux
Module Name:src Committed By: riastradh Date: Sun Dec 19 12:35:21 UTC 2021 Modified Files: src/sys/external/bsd/drm2/linux: linux_dma_fence.c Log Message: drm: Use atomic_load_relaxed for fence->flags when not locked. Shouldn't make a semantic difference on any machines we run on, but will make sanitizers happier and emphasize to readers that the result may not be reliable at these points. To generate a diff of this commit: cvs rdiff -u -r1.33 -r1.34 src/sys/external/bsd/drm2/linux/linux_dma_fence.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/external/bsd/drm2/linux/linux_dma_fence.c diff -u src/sys/external/bsd/drm2/linux/linux_dma_fence.c:1.33 src/sys/external/bsd/drm2/linux/linux_dma_fence.c:1.34 --- src/sys/external/bsd/drm2/linux/linux_dma_fence.c:1.33 Sun Dec 19 12:34:58 2021 +++ src/sys/external/bsd/drm2/linux/linux_dma_fence.c Sun Dec 19 12:35:21 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_dma_fence.c,v 1.33 2021/12/19 12:34:58 riastradh Exp $ */ +/* $NetBSD: linux_dma_fence.c,v 1.34 2021/12/19 12:35:21 riastradh Exp $ */ /*- * Copyright (c) 2018 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: linux_dma_fence.c,v 1.33 2021/12/19 12:34:58 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux_dma_fence.c,v 1.34 2021/12/19 12:35:21 riastradh Exp $"); #include #include @@ -443,7 +443,8 @@ dma_fence_add_callback(struct dma_fence KASSERT(dma_fence_referenced_p(fence)); /* Optimistically try to skip the lock if it's already signalled. */ - if (fence->flags & (1u << DMA_FENCE_FLAG_SIGNALED_BIT)) { + if (atomic_load_relaxed(>flags) & + (1u << DMA_FENCE_FLAG_SIGNALED_BIT)) { ret = -ENOENT; goto out0; } @@ -585,7 +586,8 @@ dma_fence_set_error(struct dma_fence *fe KASSERTMSG(fence->f_magic != FENCE_MAGIC_BAD, "fence %p", fence); KASSERTMSG(fence->f_magic == FENCE_MAGIC_GOOD, "fence %p", fence); - KASSERT(!(fence->flags & (1u << DMA_FENCE_FLAG_SIGNALED_BIT))); + KASSERT((atomic_load_relaxed(>flags) & + (1u << DMA_FENCE_FLAG_SIGNALED_BIT)) == 0); KASSERTMSG(error >= -ELAST, "%d", error); KASSERTMSG(error < 0, "%d", error); @@ -938,7 +940,8 @@ dma_fence_default_wait(struct dma_fence KASSERTMSG(timeout <= MAX_SCHEDULE_TIMEOUT, "timeout %ld", timeout); /* Optimistically try to skip the lock if it's already signalled. */ - if (fence->flags & (1u << DMA_FENCE_FLAG_SIGNALED_BIT)) + if (atomic_load_relaxed(>flags) & + (1u << DMA_FENCE_FLAG_SIGNALED_BIT)) return MAX(1, timeout); /* Acquire the lock. */
CVS commit: src/sys/external/bsd/drm2/linux
Module Name:src Committed By: riastradh Date: Sun Dec 19 12:35:21 UTC 2021 Modified Files: src/sys/external/bsd/drm2/linux: linux_dma_fence.c Log Message: drm: Use atomic_load_relaxed for fence->flags when not locked. Shouldn't make a semantic difference on any machines we run on, but will make sanitizers happier and emphasize to readers that the result may not be reliable at these points. To generate a diff of this commit: cvs rdiff -u -r1.33 -r1.34 src/sys/external/bsd/drm2/linux/linux_dma_fence.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/external/bsd/drm2/linux
Module Name:src Committed By: riastradh Date: Sun Dec 19 12:34:58 UTC 2021 Modified Files: src/sys/external/bsd/drm2/linux: linux_dma_fence.c Log Message: drm: Assert dma_fence_wait internal return value. To generate a diff of this commit: cvs rdiff -u -r1.32 -r1.33 src/sys/external/bsd/drm2/linux/linux_dma_fence.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/external/bsd/drm2/linux/linux_dma_fence.c diff -u src/sys/external/bsd/drm2/linux/linux_dma_fence.c:1.32 src/sys/external/bsd/drm2/linux/linux_dma_fence.c:1.33 --- src/sys/external/bsd/drm2/linux/linux_dma_fence.c:1.32 Sun Dec 19 12:34:16 2021 +++ src/sys/external/bsd/drm2/linux/linux_dma_fence.c Sun Dec 19 12:34:58 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_dma_fence.c,v 1.32 2021/12/19 12:34:16 riastradh Exp $ */ +/* $NetBSD: linux_dma_fence.c,v 1.33 2021/12/19 12:34:58 riastradh Exp $ */ /*- * Copyright (c) 2018 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: linux_dma_fence.c,v 1.32 2021/12/19 12:34:16 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux_dma_fence.c,v 1.33 2021/12/19 12:34:58 riastradh Exp $"); #include #include @@ -909,6 +909,8 @@ dma_fence_wait(struct dma_fence *fence, ret = dma_fence_default_wait(fence, intr, MAX_SCHEDULE_TIMEOUT); KASSERT(ret != 0); + KASSERTMSG(ret == -ERESTARTSYS || ret == MAX_SCHEDULE_TIMEOUT, + "ret=%ld", ret); return (ret < 0 ? ret : 0); }
CVS commit: src/sys/external/bsd/drm2/linux
Module Name:src Committed By: riastradh Date: Sun Dec 19 12:34:58 UTC 2021 Modified Files: src/sys/external/bsd/drm2/linux: linux_dma_fence.c Log Message: drm: Assert dma_fence_wait internal return value. To generate a diff of this commit: cvs rdiff -u -r1.32 -r1.33 src/sys/external/bsd/drm2/linux/linux_dma_fence.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/external/bsd/drm2/linux
Module Name:src Committed By: riastradh Date: Sun Dec 19 12:34:16 UTC 2021 Modified Files: src/sys/external/bsd/drm2/linux: linux_dma_fence.c Log Message: drm: Rework timeout return code logic. To generate a diff of this commit: cvs rdiff -u -r1.31 -r1.32 src/sys/external/bsd/drm2/linux/linux_dma_fence.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/external/bsd/drm2/linux/linux_dma_fence.c diff -u src/sys/external/bsd/drm2/linux/linux_dma_fence.c:1.31 src/sys/external/bsd/drm2/linux/linux_dma_fence.c:1.32 --- src/sys/external/bsd/drm2/linux/linux_dma_fence.c:1.31 Sun Dec 19 12:34:05 2021 +++ src/sys/external/bsd/drm2/linux/linux_dma_fence.c Sun Dec 19 12:34:16 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_dma_fence.c,v 1.31 2021/12/19 12:34:05 riastradh Exp $ */ +/* $NetBSD: linux_dma_fence.c,v 1.32 2021/12/19 12:34:16 riastradh Exp $ */ /*- * Copyright (c) 2018 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: linux_dma_fence.c,v 1.31 2021/12/19 12:34:05 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux_dma_fence.c,v 1.32 2021/12/19 12:34:16 riastradh Exp $"); #include #include @@ -723,8 +723,12 @@ dma_fence_wait_any_timeout(struct dma_fe int start, end; long ret = 0; + KASSERTMSG(timeout >= 0, "timeout %ld", timeout); + KASSERTMSG(timeout <= MAX_SCHEDULE_TIMEOUT, "timeout %ld", timeout); + /* Optimistically check whether any are signalled. */ for (i = 0; i < nfences; i++) { + KASSERT(dma_fence_referenced_p(fences[i])); if (dma_fence_is_signaled(fences[i])) { if (ip) *ip = i; @@ -741,10 +745,8 @@ dma_fence_wait_any_timeout(struct dma_fe /* Allocate an array of callback records. */ cb = kcalloc(nfences, sizeof(cb[0]), GFP_KERNEL); - if (cb == NULL) { - ret = -ENOMEM; - goto out0; - } + if (cb == NULL) + return -ENOMEM; /* Initialize a mutex and condvar for the common wait. */ mutex_init(, MUTEX_DEFAULT, IPL_VM); @@ -766,7 +768,7 @@ dma_fence_wait_any_timeout(struct dma_fe if (ip) *ip = i; ret = MAX(1, timeout); - goto out1; + goto out; } } @@ -775,7 +777,8 @@ dma_fence_wait_any_timeout(struct dma_fe * callbacks to notify us when it is done. */ mutex_enter(); - while (timeout > 0 && !common.done) { + while (!common.done) { + /* Wait for the time remaining. */ start = getticks(); if (intr) { if (timeout != MAX_SCHEDULE_TIMEOUT) { @@ -796,13 +799,42 @@ dma_fence_wait_any_timeout(struct dma_fe } } end = getticks(); + + /* Deduct from time remaining. If none left, time out. */ + if (timeout != MAX_SCHEDULE_TIMEOUT) { + timeout -= MIN(timeout, + (unsigned)end - (unsigned)start); + if (timeout == 0) +ret = -EWOULDBLOCK; + } + + /* If the wait failed, give up. */ if (ret) break; - timeout -= MIN(timeout, (unsigned)end - (unsigned)start); } mutex_exit(); /* + * Massage the return code if nonzero: + * - if we were interrupted, return -ERESTARTSYS; + * - if we timed out, return 0. + * No other failure is possible. On success, ret=0 but we + * check again below to verify anyway. + */ + if (ret) { + KASSERTMSG((ret == -EINTR || ret == -ERESTART || + ret == -EWOULDBLOCK), "ret=%ld", ret); + if (ret == -EINTR || ret == -ERESTART) { + ret = -ERESTARTSYS; + } else if (ret == -EWOULDBLOCK) { + KASSERT(timeout != MAX_SCHEDULE_TIMEOUT); + ret = 0; /* timed out */ + } + } + + KASSERT(ret != -ERESTART); /* would be confused with time left */ + + /* * Test whether any of the fences has been signalled. If they * have, return success. */ @@ -811,28 +843,22 @@ dma_fence_wait_any_timeout(struct dma_fe if (ip) *ip = j; ret = MAX(1, timeout); - goto out1; + goto out; } } /* - * Massage the return code: if we were interrupted, return - * ERESTARTSYS; if cv_timedwait timed out, return 0; otherwise - * return the remaining time. + * If user passed MAX_SCHEDULE_TIMEOUT, we can't return 0 + * meaning timed out because we're supposed to wait forever. */ - if (ret == -EINTR || ret == -ERESTART) { - ret = -ERESTARTSYS; - } else if (ret == -EWOULDBLOCK) { - ret = 0; /* timed out */ - } - KASSERTMSG(ret == -ERESTARTSYS || ret >= 0, "ret=%ld", ret); + KASSERT(timeout == MAX_SCHEDULE_TIMEOUT ? ret != 0 : 1); -out1: while (i --> 0) +out: while (i --> 0) (void)dma_fence_remove_callback(fences[i], [i].fcb); cv_destroy(); mutex_destroy(); kfree(cb); -out0: return ret; + return ret; } /* @@ -911,27 +937,26 @@ dma_fence_default_wait(struct dma_fence /* Optimistically try to skip the lock if it's already signalled. */ if (fence->flags & (1u << DMA_FENCE_FLAG_SIGNALED_BIT)) - return (timeout ? timeout : 1); + return MAX(1, timeout); /* Acquire the lock. */ spin_lock(fence->lock); /* Ensure signalling is enabled, or stop if already completed. */
CVS commit: src/sys/external/bsd/drm2/linux
Module Name:src Committed By: riastradh Date: Sun Dec 19 12:34:16 UTC 2021 Modified Files: src/sys/external/bsd/drm2/linux: linux_dma_fence.c Log Message: drm: Rework timeout return code logic. To generate a diff of this commit: cvs rdiff -u -r1.31 -r1.32 src/sys/external/bsd/drm2/linux/linux_dma_fence.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/external/bsd/drm2/linux
Module Name:src Committed By: riastradh Date: Sun Dec 19 12:34:05 UTC 2021 Modified Files: src/sys/external/bsd/drm2/linux: linux_dma_fence.c Log Message: drm: Rework dma_fence_wait_any_timeout. - Yield the first index, not the most recently signalled one. - Check again after last wakeup. - Make sure to return positive for nontimeout. - Handle ip=null. To generate a diff of this commit: cvs rdiff -u -r1.30 -r1.31 src/sys/external/bsd/drm2/linux/linux_dma_fence.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/external/bsd/drm2/linux/linux_dma_fence.c diff -u src/sys/external/bsd/drm2/linux/linux_dma_fence.c:1.30 src/sys/external/bsd/drm2/linux/linux_dma_fence.c:1.31 --- src/sys/external/bsd/drm2/linux/linux_dma_fence.c:1.30 Sun Dec 19 12:31:11 2021 +++ src/sys/external/bsd/drm2/linux/linux_dma_fence.c Sun Dec 19 12:34:05 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_dma_fence.c,v 1.30 2021/12/19 12:31:11 riastradh Exp $ */ +/* $NetBSD: linux_dma_fence.c,v 1.31 2021/12/19 12:34:05 riastradh Exp $ */ /*- * Copyright (c) 2018 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: linux_dma_fence.c,v 1.30 2021/12/19 12:31:11 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux_dma_fence.c,v 1.31 2021/12/19 12:34:05 riastradh Exp $"); #include #include @@ -685,9 +685,8 @@ struct wait_any { struct wait_any1 { kmutex_t lock; kcondvar_t cv; - bool done; - uint32_t *ip; struct wait_any *cb; + bool done; } *common; }; @@ -700,8 +699,6 @@ wait_any_cb(struct dma_fence *fence, str mutex_enter(>common->lock); cb->common->done = true; - if (cb->common->ip) - *cb->common->ip = cb - cb->common->cb; cv_broadcast(>common->cv); mutex_exit(>common->lock); } @@ -712,6 +709,9 @@ wait_any_cb(struct dma_fence *fence, str * Wait for any of fences[0], fences[1], fences[2], ..., * fences[nfences-1] to be signalled. If ip is nonnull, set *ip * to the index of the first one. + * + * Return -ERESTARTSYS if interrupted, 0 on timeout, or time + * remaining (at least 1) on success. */ long dma_fence_wait_any_timeout(struct dma_fence **fences, uint32_t nfences, @@ -723,6 +723,22 @@ dma_fence_wait_any_timeout(struct dma_fe int start, end; long ret = 0; + /* Optimistically check whether any are signalled. */ + for (i = 0; i < nfences; i++) { + if (dma_fence_is_signaled(fences[i])) { + if (ip) +*ip = i; + return MAX(1, timeout); + } + } + + /* + * If timeout is zero, we're just polling, so stop here as if + * we timed out instantly. + */ + if (timeout == 0) + return 0; + /* Allocate an array of callback records. */ cb = kcalloc(nfences, sizeof(cb[0]), GFP_KERNEL); if (cb == NULL) { @@ -733,30 +749,23 @@ dma_fence_wait_any_timeout(struct dma_fe /* Initialize a mutex and condvar for the common wait. */ mutex_init(, MUTEX_DEFAULT, IPL_VM); cv_init(, "fence"); - common.done = false; - common.ip = ip; common.cb = cb; + common.done = false; - /* Add a callback to each of the fences, or stop here if we can't. */ + /* + * Add a callback to each of the fences, or stop if already + * signalled. + */ for (i = 0; i < nfences; i++) { cb[i].common = KASSERT(dma_fence_referenced_p(fences[i])); ret = dma_fence_add_callback(fences[i], [i].fcb, _any_cb); - if (ret) - goto out1; - } - - /* - * Test whether any of the fences has been signalled. If they - * have, stop here. If the haven't, we are guaranteed to be - * notified by one of the callbacks when they have. - */ - for (j = 0; j < nfences; j++) { - if (test_bit(DMA_FENCE_FLAG_SIGNALED_BIT, [j]->flags)) { + if (ret) { + KASSERT(ret == -ENOENT); if (ip) -*ip = j; - ret = 0; +*ip = i; + ret = MAX(1, timeout); goto out1; } } @@ -768,7 +777,6 @@ dma_fence_wait_any_timeout(struct dma_fe mutex_enter(); while (timeout > 0 && !common.done) { start = getticks(); - __insn_barrier(); if (intr) { if (timeout != MAX_SCHEDULE_TIMEOUT) { ret = -cv_timedwait_sig(, @@ -788,30 +796,36 @@ dma_fence_wait_any_timeout(struct dma_fe } } end = getticks(); - __insn_barrier(); - if (ret) { - if (ret == -ERESTART) -ret = -ERESTARTSYS; + if (ret) break; - } timeout -= MIN(timeout, (unsigned)end - (unsigned)start); } mutex_exit(); /* + * Test whether any of the fences has been signalled. If they + * have, return success. + */ + for (j = 0; j < nfences; j++) { + if (dma_fence_is_signaled(fences[i])) { + if (ip) +*ip = j; + ret = MAX(1, timeout); + goto out1; + } + } + + /* * Massage the return code: if we were interrupted, return * ERESTARTSYS; if cv_timedwait timed out, return 0; otherwise * return the remaining time. */ - if (ret < 0) { - if (ret == -EINTR || ret == -ERESTART) - ret = -ERESTARTSYS; - if (ret == -EWOULDBLOCK) - ret = 0; -
CVS commit: src/sys/external/bsd/drm2/linux
Module Name:src Committed By: riastradh Date: Sun Dec 19 12:34:05 UTC 2021 Modified Files: src/sys/external/bsd/drm2/linux: linux_dma_fence.c Log Message: drm: Rework dma_fence_wait_any_timeout. - Yield the first index, not the most recently signalled one. - Check again after last wakeup. - Make sure to return positive for nontimeout. - Handle ip=null. To generate a diff of this commit: cvs rdiff -u -r1.30 -r1.31 src/sys/external/bsd/drm2/linux/linux_dma_fence.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/external/bsd/drm2/linux
Module Name:src Committed By: riastradh Date: Sun Dec 19 12:33:42 UTC 2021 Modified Files: src/sys/external/bsd/drm2/linux: linux_dma_resv.c Log Message: drm: Paranoia: handle fencep=null, fence!=null, and 0 shared. Not sure this is possible but I don't know the API well enough to prove it can't happen. To generate a diff of this commit: cvs rdiff -u -r1.19 -r1.20 src/sys/external/bsd/drm2/linux/linux_dma_resv.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/external/bsd/drm2/linux/linux_dma_resv.c diff -u src/sys/external/bsd/drm2/linux/linux_dma_resv.c:1.19 src/sys/external/bsd/drm2/linux/linux_dma_resv.c:1.20 --- src/sys/external/bsd/drm2/linux/linux_dma_resv.c:1.19 Sun Dec 19 12:33:34 2021 +++ src/sys/external/bsd/drm2/linux/linux_dma_resv.c Sun Dec 19 12:33:42 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_dma_resv.c,v 1.19 2021/12/19 12:33:34 riastradh Exp $ */ +/* $NetBSD: linux_dma_resv.c,v 1.20 2021/12/19 12:33:42 riastradh Exp $ */ /*- * Copyright (c) 2018 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: linux_dma_resv.c,v 1.19 2021/12/19 12:33:34 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux_dma_resv.c,v 1.20 2021/12/19 12:33:42 riastradh Exp $"); #include #include @@ -758,7 +758,7 @@ dma_resv_get_fences_rcu(const struct dma const struct dma_resv_list *list = NULL; struct dma_fence *fence = NULL; struct dma_fence **shared = NULL; - unsigned shared_alloc, shared_count, i; + unsigned shared_alloc = 0, shared_count, i; struct dma_resv_read_ticket ticket; top: KASSERT(fence == NULL); @@ -851,11 +851,19 @@ top: KASSERT(fence == NULL); /* Success! */ rcu_read_unlock(); + KASSERT(shared_count <= shared_alloc); + KASSERT(shared_alloc == 0 || shared_count < shared_alloc); + KASSERT(shared_alloc <= UINT_MAX); if (fencep) { *fencep = fence; } else if (fence) { - KASSERT(shared_count < UINT_MAX); - shared[shared_count++] = fence; + if (shared_count) { + shared[shared_count++] = fence; + } else { + shared = kmalloc(sizeof(shared[0]), GFP_KERNEL); + shared[0] = fence; + shared_count = 1; + } } *nsharedp = shared_count; *sharedp = shared;
CVS commit: src/sys/external/bsd/drm2/linux
Module Name:src Committed By: riastradh Date: Sun Dec 19 12:33:42 UTC 2021 Modified Files: src/sys/external/bsd/drm2/linux: linux_dma_resv.c Log Message: drm: Paranoia: handle fencep=null, fence!=null, and 0 shared. Not sure this is possible but I don't know the API well enough to prove it can't happen. To generate a diff of this commit: cvs rdiff -u -r1.19 -r1.20 src/sys/external/bsd/drm2/linux/linux_dma_resv.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/external/bsd/drm2/linux
Module Name:src Committed By: riastradh Date: Sun Dec 19 12:33:34 UTC 2021 Modified Files: src/sys/external/bsd/drm2/linux: linux_dma_resv.c Log Message: drm: Fix missing restart on race in dma_resv_get_fences_rcu. To generate a diff of this commit: cvs rdiff -u -r1.18 -r1.19 src/sys/external/bsd/drm2/linux/linux_dma_resv.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/external/bsd/drm2/linux/linux_dma_resv.c diff -u src/sys/external/bsd/drm2/linux/linux_dma_resv.c:1.18 src/sys/external/bsd/drm2/linux/linux_dma_resv.c:1.19 --- src/sys/external/bsd/drm2/linux/linux_dma_resv.c:1.18 Sun Dec 19 12:32:53 2021 +++ src/sys/external/bsd/drm2/linux/linux_dma_resv.c Sun Dec 19 12:33:34 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_dma_resv.c,v 1.18 2021/12/19 12:32:53 riastradh Exp $ */ +/* $NetBSD: linux_dma_resv.c,v 1.19 2021/12/19 12:33:34 riastradh Exp $ */ /*- * Copyright (c) 2018 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: linux_dma_resv.c,v 1.18 2021/12/19 12:32:53 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux_dma_resv.c,v 1.19 2021/12/19 12:33:34 riastradh Exp $"); #include #include @@ -818,6 +818,7 @@ top: KASSERT(fence == NULL); GFP_KERNEL); if (shared == NULL) return -ENOMEM; + goto top; } /*
CVS commit: src/sys/external/bsd/drm2/linux
Module Name:src Committed By: riastradh Date: Sun Dec 19 12:33:34 UTC 2021 Modified Files: src/sys/external/bsd/drm2/linux: linux_dma_resv.c Log Message: drm: Fix missing restart on race in dma_resv_get_fences_rcu. To generate a diff of this commit: cvs rdiff -u -r1.18 -r1.19 src/sys/external/bsd/drm2/linux/linux_dma_resv.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/external/bsd/drm2/linux
Module Name:src Committed By: riastradh Date: Sun Dec 19 12:33:26 UTC 2021 Modified Files: src/sys/external/bsd/drm2/linux: linux_dma_fence_array.c Log Message: drm: Another missing spin_lock_destroy. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 \ src/sys/external/bsd/drm2/linux/linux_dma_fence_array.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/external/bsd/drm2/linux/linux_dma_fence_array.c diff -u src/sys/external/bsd/drm2/linux/linux_dma_fence_array.c:1.2 src/sys/external/bsd/drm2/linux/linux_dma_fence_array.c:1.3 --- src/sys/external/bsd/drm2/linux/linux_dma_fence_array.c:1.2 Sun Dec 19 12:23:50 2021 +++ src/sys/external/bsd/drm2/linux/linux_dma_fence_array.c Sun Dec 19 12:33:26 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_dma_fence_array.c,v 1.2 2021/12/19 12:23:50 riastradh Exp $ */ +/* $NetBSD: linux_dma_fence_array.c,v 1.3 2021/12/19 12:33:26 riastradh Exp $ */ /*- * Copyright (c) 2021 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: linux_dma_fence_array.c,v 1.2 2021/12/19 12:23:50 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux_dma_fence_array.c,v 1.3 2021/12/19 12:33:26 riastradh Exp $"); #include @@ -139,6 +139,7 @@ dma_fence_array_release(struct dma_fence dma_fence_put(A->fences[i]); kfree(A->fences); + spin_lock_destroy(>dfa_lock); dma_fence_free(fence); }
CVS commit: src/sys/external/bsd/drm2/linux
Module Name:src Committed By: riastradh Date: Sun Dec 19 12:33:26 UTC 2021 Modified Files: src/sys/external/bsd/drm2/linux: linux_dma_fence_array.c Log Message: drm: Another missing spin_lock_destroy. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 \ src/sys/external/bsd/drm2/linux/linux_dma_fence_array.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/external/bsd/drm2/linux
Module Name:src Committed By: riastradh Date: Sun Dec 19 12:32:53 UTC 2021 Modified Files: src/sys/external/bsd/drm2/linux: linux_dma_resv.c Log Message: drm: Support dma_resv_reserve_shared(..., num_fences>1). To generate a diff of this commit: cvs rdiff -u -r1.17 -r1.18 src/sys/external/bsd/drm2/linux/linux_dma_resv.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/external/bsd/drm2/linux/linux_dma_resv.c diff -u src/sys/external/bsd/drm2/linux/linux_dma_resv.c:1.17 src/sys/external/bsd/drm2/linux/linux_dma_resv.c:1.18 --- src/sys/external/bsd/drm2/linux/linux_dma_resv.c:1.17 Sun Dec 19 12:31:34 2021 +++ src/sys/external/bsd/drm2/linux/linux_dma_resv.c Sun Dec 19 12:32:53 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_dma_resv.c,v 1.17 2021/12/19 12:31:34 riastradh Exp $ */ +/* $NetBSD: linux_dma_resv.c,v 1.18 2021/12/19 12:32:53 riastradh Exp $ */ /*- * Copyright (c) 2018 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: linux_dma_resv.c,v 1.17 2021/12/19 12:31:34 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux_dma_resv.c,v 1.18 2021/12/19 12:32:53 riastradh Exp $"); #include #include @@ -300,10 +300,10 @@ dma_resv_get_list(struct dma_resv *robj) } /* - * dma_resv_reserve_shared(robj) + * dma_resv_reserve_shared(robj, num_fences) * - * Reserve space in robj to add a shared fence. To be used only - * once before calling dma_resv_add_shared_fence. + * Reserve space in robj to add num_fences shared fences. To be + * used only once before calling dma_resv_add_shared_fence. * * Caller must have robj locked. * @@ -317,7 +317,6 @@ dma_resv_reserve_shared(struct dma_resv uint32_t n, nalloc; KASSERT(dma_resv_held(robj)); - KASSERT(num_fences == 1); list = robj->fence; prealloc = robj->robj_prealloc; @@ -325,18 +324,18 @@ dma_resv_reserve_shared(struct dma_resv /* If there's an existing list, check it for space. */ if (list) { /* If there's too many already, give up. */ - if (list->shared_count == UINT32_MAX) + if (list->shared_count > UINT32_MAX - num_fences) return -ENOMEM; - /* Add one more. */ - n = list->shared_count + 1; + /* Add some more. */ + n = list->shared_count + num_fences; /* If there's enough for one more, we're done. */ if (n <= list->shared_max) return 0; } else { - /* No list already. We need space for 1. */ - n = 1; + /* No list already. We need space for num_fences. */ + n = num_fences; } /* If not, maybe there's a preallocated list ready. */
CVS commit: src/sys/external/bsd/drm2/linux
Module Name:src Committed By: riastradh Date: Sun Dec 19 12:32:53 UTC 2021 Modified Files: src/sys/external/bsd/drm2/linux: linux_dma_resv.c Log Message: drm: Support dma_resv_reserve_shared(..., num_fences>1). To generate a diff of this commit: cvs rdiff -u -r1.17 -r1.18 src/sys/external/bsd/drm2/linux/linux_dma_resv.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/external/bsd/drm2/linux
Module Name:src Committed By: riastradh Date: Sun Dec 19 12:31:34 UTC 2021 Modified Files: src/sys/external/bsd/drm2/linux: linux_dma_resv.c Log Message: drm: Implement drm_resv_get_fences_rcu with null fencep. To generate a diff of this commit: cvs rdiff -u -r1.16 -r1.17 src/sys/external/bsd/drm2/linux/linux_dma_resv.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/external/bsd/drm2/linux/linux_dma_resv.c diff -u src/sys/external/bsd/drm2/linux/linux_dma_resv.c:1.16 src/sys/external/bsd/drm2/linux/linux_dma_resv.c:1.17 --- src/sys/external/bsd/drm2/linux/linux_dma_resv.c:1.16 Sun Dec 19 12:26:39 2021 +++ src/sys/external/bsd/drm2/linux/linux_dma_resv.c Sun Dec 19 12:31:34 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_dma_resv.c,v 1.16 2021/12/19 12:26:39 riastradh Exp $ */ +/* $NetBSD: linux_dma_resv.c,v 1.17 2021/12/19 12:31:34 riastradh Exp $ */ /*- * Copyright (c) 2018 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: linux_dma_resv.c,v 1.16 2021/12/19 12:26:39 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux_dma_resv.c,v 1.17 2021/12/19 12:31:34 riastradh Exp $"); #include #include @@ -745,6 +745,8 @@ dma_resv_get_excl_rcu(const struct dma_r * Get a snapshot of the exclusive and shared fences of robj. The * shared fences are returned as a pointer *sharedp to an array, * to be freed by the caller with kfree, of *nsharedp elements. + * If fencep is null, then add the exclusive fence, if any, at the + * end of the array instead. * * Returns zero on success, negative (Linux-style) error code on * failure. On failure, *fencep, *nsharedp, and *sharedp are @@ -771,13 +773,24 @@ top: KASSERT(fence == NULL); goto restart; if (list != NULL) { + /* + * Avoid arithmetic overflow with `+ 1' below. + * Strictly speaking we don't need this if the caller + * specified fencep or if there is no exclusive fence, + * but it is simpler to not have to consider those + * cases. + */ + KASSERT(shared_count <= list->shared_max); + if (list->shared_max == UINT_MAX) + return -ENOMEM; + /* Check whether we have a buffer. */ if (shared == NULL) { /* * We don't have a buffer yet. Try to allocate * one without waiting. */ - shared_alloc = list->shared_max; + shared_alloc = list->shared_max + 1; shared = kcalloc(shared_alloc, sizeof(shared[0]), GFP_NOWAIT); if (shared == NULL) { @@ -793,13 +806,13 @@ top: KASSERT(fence == NULL); return -ENOMEM; goto top; } - } else if (shared_alloc < list->shared_max) { + } else if (shared_alloc < list->shared_max + 1) { /* * We have a buffer but it's too small. We're * already racing in this case, so just back * out and wait to allocate a bigger one. */ - shared_alloc = list->shared_max; + shared_alloc = list->shared_max + 1; rcu_read_unlock(); kfree(shared); shared = kcalloc(shared_alloc, sizeof(shared[0]), @@ -838,7 +851,12 @@ top: KASSERT(fence == NULL); /* Success! */ rcu_read_unlock(); - *fencep = fence; + if (fencep) { + *fencep = fence; + } else if (fence) { + KASSERT(shared_count < UINT_MAX); + shared[shared_count++] = fence; + } *nsharedp = shared_count; *sharedp = shared; return 0;
CVS commit: src/sys/external/bsd/drm2/linux
Module Name:src Committed By: riastradh Date: Sun Dec 19 12:31:34 UTC 2021 Modified Files: src/sys/external/bsd/drm2/linux: linux_dma_resv.c Log Message: drm: Implement drm_resv_get_fences_rcu with null fencep. To generate a diff of this commit: cvs rdiff -u -r1.16 -r1.17 src/sys/external/bsd/drm2/linux/linux_dma_resv.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/external/bsd/drm2/linux
Module Name:src Committed By: riastradh Date: Sun Dec 19 12:31:12 UTC 2021 Modified Files: src/sys/external/bsd/drm2/linux: linux_dma_fence.c Log Message: drm: Set fence->ops for stub fences too. To generate a diff of this commit: cvs rdiff -u -r1.29 -r1.30 src/sys/external/bsd/drm2/linux/linux_dma_fence.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/external/bsd/drm2/linux/linux_dma_fence.c diff -u src/sys/external/bsd/drm2/linux/linux_dma_fence.c:1.29 src/sys/external/bsd/drm2/linux/linux_dma_fence.c:1.30 --- src/sys/external/bsd/drm2/linux/linux_dma_fence.c:1.29 Sun Dec 19 12:30:56 2021 +++ src/sys/external/bsd/drm2/linux/linux_dma_fence.c Sun Dec 19 12:31:11 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_dma_fence.c,v 1.29 2021/12/19 12:30:56 riastradh Exp $ */ +/* $NetBSD: linux_dma_fence.c,v 1.30 2021/12/19 12:31:11 riastradh Exp $ */ /*- * Copyright (c) 2018 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: linux_dma_fence.c,v 1.29 2021/12/19 12:30:56 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux_dma_fence.c,v 1.30 2021/12/19 12:31:11 riastradh Exp $"); #include #include @@ -221,6 +221,17 @@ dma_fence_is_later(struct dma_fence *a, return a->seqno - b->seqno < INT_MAX; } +static const char *dma_fence_stub_name(struct dma_fence *f) +{ + + return "stub"; +} + +static const struct dma_fence_ops dma_fence_stub_ops = { + .get_driver_name = dma_fence_stub_name, + .get_timeline_name = dma_fence_stub_name, +}; + /* * dma_fence_get_stub() * @@ -238,6 +249,7 @@ dma_fence_get_stub(void) static struct dma_fence fence = { .refcount = {1}, /* always referenced */ .flags = 1u << DMA_FENCE_FLAG_SIGNALED_BIT, + .ops = _fence_stub_ops, #ifdef DIAGNOSTIC .f_magic = FENCE_MAGIC_GOOD, #endif
CVS commit: src/sys/external/bsd/drm2/linux
Module Name:src Committed By: riastradh Date: Sun Dec 19 12:31:12 UTC 2021 Modified Files: src/sys/external/bsd/drm2/linux: linux_dma_fence.c Log Message: drm: Set fence->ops for stub fences too. To generate a diff of this commit: cvs rdiff -u -r1.29 -r1.30 src/sys/external/bsd/drm2/linux/linux_dma_fence.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/external/bsd/drm2/linux
Module Name:src Committed By: riastradh Date: Sun Dec 19 12:30:56 UTC 2021 Modified Files: src/sys/external/bsd/drm2/linux: linux_dma_fence.c Log Message: drm: set f_magic in the stub fence. Author: phone Committer: Taylor R Campbell To generate a diff of this commit: cvs rdiff -u -r1.28 -r1.29 src/sys/external/bsd/drm2/linux/linux_dma_fence.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/external/bsd/drm2/linux/linux_dma_fence.c diff -u src/sys/external/bsd/drm2/linux/linux_dma_fence.c:1.28 src/sys/external/bsd/drm2/linux/linux_dma_fence.c:1.29 --- src/sys/external/bsd/drm2/linux/linux_dma_fence.c:1.28 Sun Dec 19 12:23:34 2021 +++ src/sys/external/bsd/drm2/linux/linux_dma_fence.c Sun Dec 19 12:30:56 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_dma_fence.c,v 1.28 2021/12/19 12:23:34 riastradh Exp $ */ +/* $NetBSD: linux_dma_fence.c,v 1.29 2021/12/19 12:30:56 riastradh Exp $ */ /*- * Copyright (c) 2018 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: linux_dma_fence.c,v 1.28 2021/12/19 12:23:34 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux_dma_fence.c,v 1.29 2021/12/19 12:30:56 riastradh Exp $"); #include #include @@ -238,6 +238,9 @@ dma_fence_get_stub(void) static struct dma_fence fence = { .refcount = {1}, /* always referenced */ .flags = 1u << DMA_FENCE_FLAG_SIGNALED_BIT, +#ifdef DIAGNOSTIC + .f_magic = FENCE_MAGIC_GOOD, +#endif }; return dma_fence_get();
CVS commit: src/sys/external/bsd/drm2/linux
Module Name:src Committed By: riastradh Date: Sun Dec 19 12:30:56 UTC 2021 Modified Files: src/sys/external/bsd/drm2/linux: linux_dma_fence.c Log Message: drm: set f_magic in the stub fence. Author: phone Committer: Taylor R Campbell To generate a diff of this commit: cvs rdiff -u -r1.28 -r1.29 src/sys/external/bsd/drm2/linux/linux_dma_fence.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/external/bsd/drm2/linux
Module Name:src Committed By: riastradh Date: Sun Dec 19 12:29:39 UTC 2021 Modified Files: src/sys/external/bsd/drm2/linux: linux_kthread.c Log Message: linux: Make kthread_park/stop work at IPL_VM. Needed in order to hold spin locks around it. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/sys/external/bsd/drm2/linux/linux_kthread.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/external/bsd/drm2/linux/linux_kthread.c diff -u src/sys/external/bsd/drm2/linux/linux_kthread.c:1.2 src/sys/external/bsd/drm2/linux/linux_kthread.c:1.3 --- src/sys/external/bsd/drm2/linux/linux_kthread.c:1.2 Sun Dec 19 12:24:19 2021 +++ src/sys/external/bsd/drm2/linux/linux_kthread.c Sun Dec 19 12:29:39 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_kthread.c,v 1.2 2021/12/19 12:24:19 riastradh Exp $ */ +/* $NetBSD: linux_kthread.c,v 1.3 2021/12/19 12:29:39 riastradh Exp $ */ /*- * Copyright (c) 2021 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: linux_kthread.c,v 1.2 2021/12/19 12:24:19 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux_kthread.c,v 1.3 2021/12/19 12:29:39 riastradh Exp $"); #include @@ -115,7 +115,7 @@ kthread_alloc(int (*func)(void *), void T = kmem_zalloc(sizeof(*T), KM_SLEEP); - mutex_init(>kt_lock, MUTEX_DEFAULT, IPL_NONE); + mutex_init(>kt_lock, MUTEX_DEFAULT, IPL_VM); cv_init(>kt_cv, "lnxkthrd"); T->kt_func = func;
CVS commit: src/sys/external/bsd/drm2/linux
Module Name:src Committed By: riastradh Date: Sun Dec 19 12:29:39 UTC 2021 Modified Files: src/sys/external/bsd/drm2/linux: linux_kthread.c Log Message: linux: Make kthread_park/stop work at IPL_VM. Needed in order to hold spin locks around it. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/sys/external/bsd/drm2/linux/linux_kthread.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/external/bsd/drm2/linux
Module Name:src Committed By: riastradh Date: Sun Dec 19 12:26:39 UTC 2021 Modified Files: src/sys/external/bsd/drm2/linux: linux_dma_resv.c Log Message: drm: Factor dma_fence_put out of multiple dma_resv_do_poll branches. To generate a diff of this commit: cvs rdiff -u -r1.15 -r1.16 src/sys/external/bsd/drm2/linux/linux_dma_resv.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/external/bsd/drm2/linux/linux_dma_resv.c diff -u src/sys/external/bsd/drm2/linux/linux_dma_resv.c:1.15 src/sys/external/bsd/drm2/linux/linux_dma_resv.c:1.16 --- src/sys/external/bsd/drm2/linux/linux_dma_resv.c:1.15 Sun Dec 19 12:26:30 2021 +++ src/sys/external/bsd/drm2/linux/linux_dma_resv.c Sun Dec 19 12:26:39 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_dma_resv.c,v 1.15 2021/12/19 12:26:30 riastradh Exp $ */ +/* $NetBSD: linux_dma_resv.c,v 1.16 2021/12/19 12:26:39 riastradh Exp $ */ /*- * Copyright (c) 2018 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: linux_dma_resv.c,v 1.15 2021/12/19 12:26:30 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux_dma_resv.c,v 1.16 2021/12/19 12:26:39 riastradh Exp $"); #include #include @@ -1350,11 +1350,8 @@ top: KASSERT(fence == NULL); * Test whether it is signalled. If not, stop and * request a callback. */ - if (dma_fence_is_signaled(fence)) { - dma_fence_put(fence); - fence = NULL; + if (dma_fence_is_signaled(fence)) break; - } /* Put ourselves on the selq if we haven't already. */ if (!recorded) { @@ -1369,8 +1366,6 @@ top: KASSERT(fence == NULL); * assume the event is not ready. */ if (!claimed || callback) { - dma_fence_put(fence); - fence = NULL; revents = 0; break; } @@ -1383,16 +1378,15 @@ top: KASSERT(fence == NULL); */ if (!dma_fence_add_callback(fence, >rp_fcb, dma_resv_poll_cb)) { - dma_fence_put(fence); - fence = NULL; revents = 0; callback = true; break; } + } while (0); + if (fence != NULL) { dma_fence_put(fence); fence = NULL; - } while (0); - KASSERT(fence == NULL); + } /* All done reading the fences. */ rcu_read_unlock();
CVS commit: src/sys/external/bsd/drm2/linux
Module Name:src Committed By: riastradh Date: Sun Dec 19 12:26:39 UTC 2021 Modified Files: src/sys/external/bsd/drm2/linux: linux_dma_resv.c Log Message: drm: Factor dma_fence_put out of multiple dma_resv_do_poll branches. To generate a diff of this commit: cvs rdiff -u -r1.15 -r1.16 src/sys/external/bsd/drm2/linux/linux_dma_resv.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/external/bsd/drm2/linux
Module Name:src Committed By: riastradh Date: Sun Dec 19 12:26:30 UTC 2021 Modified Files: src/sys/external/bsd/drm2/linux: linux_dma_resv.c Log Message: drm: Fix dma_resv_test_signaled_rcu and dma_resv_wait_timeout_rcu. Make them implemented the semantics as documented like Linux does: only test the exclusive fence if there's no shared fences. To generate a diff of this commit: cvs rdiff -u -r1.14 -r1.15 src/sys/external/bsd/drm2/linux/linux_dma_resv.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/external/bsd/drm2/linux/linux_dma_resv.c diff -u src/sys/external/bsd/drm2/linux/linux_dma_resv.c:1.14 src/sys/external/bsd/drm2/linux/linux_dma_resv.c:1.15 --- src/sys/external/bsd/drm2/linux/linux_dma_resv.c:1.14 Sun Dec 19 12:26:22 2021 +++ src/sys/external/bsd/drm2/linux/linux_dma_resv.c Sun Dec 19 12:26:30 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_dma_resv.c,v 1.14 2021/12/19 12:26:22 riastradh Exp $ */ +/* $NetBSD: linux_dma_resv.c,v 1.15 2021/12/19 12:26:30 riastradh Exp $ */ /*- * Copyright (c) 2018 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: linux_dma_resv.c,v 1.14 2021/12/19 12:26:22 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux_dma_resv.c,v 1.15 2021/12/19 12:26:30 riastradh Exp $"); #include #include @@ -1044,6 +1044,8 @@ top: KASSERT(fence == NULL); if (!dma_resv_read_valid(robj, )) goto restart; } + if (shared_count) + goto out; /* If there is an exclusive fence, test it. */ KASSERT(fence == NULL); @@ -1131,6 +1133,8 @@ top: KASSERT(fence == NULL); if (!dma_resv_read_valid(robj, )) goto restart; } + if (shared_count) + goto out; /* If there is an exclusive fence, test it. */ KASSERT(fence == NULL); @@ -1144,7 +1148,7 @@ top: KASSERT(fence == NULL); fence = NULL; } - /* Success! Return the number of ticks left. */ +out: /* Success! Return the number of ticks left. */ rcu_read_unlock(); KASSERT(fence == NULL); return timeout;