Commit Graph

3991 Commits

Author SHA1 Message Date
dyoung 7c4812b990 Add a device tree for the Red Pitaya SDRlab 122-16.
To boot NetBSD on the 122-16, copy the .dtb built from
zynq-red-pitays-122-16.dts, the first-stage bootloader (called
boot.bin) and U-Boot that came with the 122-16 and a kernel image,
netbsd.ub, built for earmv7hf to an MS-DOS partition on an
MBR-partitioned SD card.  At the U-Boot prompt, "Zynq> ", type these
commands:

i2c dev 0
eeprom read 0 0x50 0 0x1804 0x400
env import -b 0 0x400 hw_rev serial ethaddr
setenv bootargs "root=ld0a"
fatload mmc 0 0x01f00000 device~1.dtb
fatload mmc 0 0x02000000 netbsd.ub
fdt addr 0x01f00000
fdt set /axi/ethernet@e000b000 local-mac-address $ethaddr
bootm 0x02000000 - 0x01f00000

Note that the ethernet PHY will not attach unless you have applied
the patches from Lloyd Parkes in kern/58083.
2024-05-04 02:21:48 +00:00
riastradh 606bfddf18 linux_sync_file: Fix missing init/fini steps.
Noted by rjs@.

PR kern/58210
2024-04-28 15:35:39 +00:00
riastradh 003bb55d1d drm: Allow DRM_IOCTL_GET_UNIQUE on render nodes.
On NetBSD, libdrm uses this to discover what kind of bus the device
is on, without which it refuses to expose the render node at all,
rendering it useless.  With this change, libdrm is able to use render
nodes on NetBSD.

Since this is just reading out information about the bus type and
bus/dev/func numbers, I don't think it's problematic to expose to
render nodes.

This requires tweaking the access path to the master.

PR kern/58180
2024-04-21 03:02:51 +00:00
riastradh 759aa94308 drm(4): Fix st_rdev in stat.
dminor->index already has the 64*type adjustment, as allocated in
drm_minor_alloc.

PR kern/58180
2024-04-21 03:02:39 +00:00
riastradh a346ed41ae radeon_acpi.c: ifdef out unused function on NetBSD.
Should fix syzkaller build.
2024-04-18 23:33:15 +00:00
riastradh 770c9d5352 drm: Set CONFIG_ACPI in linux/acpi.h and make it build.
Leave a little ACPI-related functionality disabled for now, like
getting EDID out of ACPI -- needs a bit more work to make this work,
and I don't have hardware to work on that.

Should help with failures of the forms:

- unable to locate a BIOS ROM
- bios: unable to locate usable image

on various machines.
2024-04-16 14:34:01 +00:00
riastradh cb8d2cb71d nouveau: Rework nouveau2netbsd hack to get ACPI stuff. 2024-04-16 14:26:53 +00:00
riastradh 2722c57029 usb *hci: Always set ux_status before usbd_xfer_schedule_timeout.
Add an assert to usbd_xfer_schedule_timeout to enforce this.

Since access to ux_status is serialized by the bus lock, and nothing
releases the bus lock in the interim, this doesn't make a functional
change.  But it does reduce confusion by readers, who no longer have
to worry if some callers got the order wrong.  It could also now
potentially be factored out in a subsequent commit.
2024-04-05 18:57:10 +00:00
riastradh d0ccdab6f4 sljit: Pacify -Wsign-compare.
If these sizes are negative, we're probably in trouble anyway, so
assert nonnegative here.

Needed to resolve PR 58103.
2024-04-02 22:29:57 +00:00
mrg 4072902f97 drm(4): make pr_debug equivalent to aprint_debug
significantly reduces the default spam from amdgpu(4).
2024-03-09 09:55:52 +00:00
riastradh aef93b36e3 i915_gem_stolen: Fill sg_pgs, with size/PAGE_SIZE entries.
Use sg_alloc_table_from_bus_dmamem to do this.

i915_gem_mman.c vm_fault_cpu and i915_gem_object_release_mmap_offset
both rely on sg_pgs to be a page array, so providing a table with
only one entry doesn't work (except by accident, if the object is
page-sized anyway).  And they rely on the sg_pgs entries to be
initialized, which we weren't doing before, and which
sg_alloc_table_from_bus_dmamem does for us.

Related to PR kern/57833.

XXX pullup-10
2024-01-19 22:24:38 +00:00
riastradh 0b4ab1ab69 i915_gem_stolen: Fix memory leak.
Found while trying to address the PR 57833 class of problems.

XXX pullup-10
2024-01-19 22:24:27 +00:00
riastradh f37345eeac i915_gem_region: Fill sg_pgs, with size/PAGE_SIZE entries.
Use sg_alloc_table_from_bus_dmamem to do this.

i915_gem_mman.c vm_fault_cpu and i915_gem_object_release_mmap_offset
both rely on sg_pgs to be a page array, so using something else like
size >> ilog2(mem->mm.chunk_size) entries doesn't work.  And they
rely on the sg_pgs entries to be initialized, which we weren't doing
before, and which sg_alloc_table_from_bus_dmamem does for us.

Related to PR kern/57833.

XXX pullup-10
2024-01-19 22:23:19 +00:00
riastradh b7bb76c941 i915_gem_phys: Fill sg_pgs.
This is needed by i915 gem fault, which maps user virtual addresses
to those pages, and by i915 gem object destruction, which does
pmap_page_protect on the pages to remove any of those user virtual
mappings.

This needs pmap_kenter_pa rather than pmap_enter(pmap_kernel(), ...)
in order to preserve the _kernel's_ mapping of the pages after
pmap_page_protect.

But bus_dmamem_map currently uses pmap_enter(pmap_kernel(), ...)
instead which creates a mapping that is removed by pmap_page_protect.

So we use a variant of bus_dmamem_map that uses pmap_kenter_pa
instead.  Perhaps bus_dmamem_map should do this itself, but this
change is less risky to pull up than a change to bus_dmamem_map
itself.

PR kern/57833: kernel panic on xorg exit

XXX pullup-10
2024-01-19 22:23:04 +00:00
riastradh 92049612ad i915_gem: Assert page array size.
Let's detect the bug of sg_npgs failing to match
obj->base.size/PAGE_SIZE earlier.

Related to PR kern/57833.

XXX pullup-10
2024-01-19 22:22:54 +00:00
riastradh 1c9915e913 i915_gem: Avoid walking off end of sg_pgs.
sg_npgs currently fails to match obj->base.size/PAGE_SIZE only due to
bugs in the construction of sg_pgs in various i915 gem object types,
which we should also fix, but let's avoid compounding it here.

Related to PR kern/57833.

XXX pullup-10
2024-01-19 22:22:40 +00:00
riastradh 85d93b427b i915_gem_region: Reduce diff from upstream a little.
No functional change intended.

Prompted by upcoming nearby changes related to PR kern/57833.

XXX pullup-10 (to make subsequent pullups easier)
2024-01-19 22:22:27 +00:00
riastradh c7be4527bc i915: Backport change to downgrade gen7/vlv to aliasing-ppggtt.
PR kern/57268

XXX pullup-10

commit 4fbe112a569526e46fa2accb5763c069f78cb431
Author: Chris Wilson <chris@chris-wilson.co.uk>
Date:   Mon Feb 24 10:11:20 2020 +0000

    drm/i915/gtt: Downgrade gen7 (ivb, byt, hsw) back to aliasing-ppgtt

    Full-ppgtt on gen7 is proving to be highly unstable and not robust.

    Closes: https://gitlab.freedesktop.org/drm/intel/issues/694
    Fixes: 3cd6e8860ecd ("drm/i915/gen7: Re-enable full-ppgtt for ivb & hsw")
    Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
    Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
    Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
    Cc: Jani Nikula <jani.nikula@intel.com>
    Cc: Dave Airlie <airlied@redhat.com>
    Acked-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
    Link: https://patchwork.freedesktop.org/patch/msgid/20200224101120.4024481-1-chris@chris-wilson.co.uk
2024-01-14 22:15:15 +00:00
skrll b76ad2e5c8 The dr_node should be a property of usb_cdns3 and not usb3 for jh7100. 2024-01-14 07:55:48 +00:00
skrll 45e41911cd Import RISC-V starfive DTS from https://github.com/starfive-tech/linux.git"
The files are taken from the visionfive branch with latest DTS related commit

    commit 9b5f280fa413ee76fac20cd575075fc53468d527
    Author: Emil Renner Berthing <kernel@esmil.dk>
    Date:   Sun Oct 31 17:15:58 2021 +0100

        riscv: dts: Add full JH7100, Starlight and VisionFive support
2024-01-14 07:39:25 +00:00
chs 5b8c340b31 drm: put_cpu() should enable preemption, not disable it again 2023-12-29 22:58:23 +00:00
tnn 83f810f510 radeon: fix and enable ACPI methods for getting ROM BIOS
The hacky way of getting the BIOS mapped only works on x86. ACPI
should be preferred if available. Makes BIOS reading though VFCT
work on aarch64 with EDK2. (But only if EDK2 has POSTed the GPU.)

XXX amdgpu should get the same treatment.
2023-11-06 14:33:51 +00:00
jdolecek e5f5445a48 ena(4): destroy all wait_event
Code contributed by KUSABA Takeshi <t-kusaba@iij.ad.jp>
2023-11-05 18:24:31 +00:00
jdolecek bc911a556a ena(4): prevent AENQ handler from use-after-free
Code contributed by KUSABA Takeshi <t-kusaba@iij.ad.jp>
2023-11-05 18:21:54 +00:00
jdolecek a964a2995f ena(4): replace malloc(9) to kmem(9)
Code contributed by KUSABA Takeshi <t-kusaba@iij.ad.jp>
2023-11-05 18:15:02 +00:00
bouyer 3c08d38d32 Add XENPF_get_dom0_console, which gets a dom0_vga_console_info stucture
from the hypervisor. To be used by PVH dom0 kernels.
2023-10-17 16:02:55 +00:00
bouyer 03f1d351dc Add ext_lfb_base to dom0_vga_console_info, from recent Xen. We know if it's
present or not by checking dom0.info_size
2023-10-17 14:15:54 +00:00
mrg 00c5a72cc0 drm: enable almost all PCIe functionality
linux_pci.c revisions 1.24 and 1.25 implemented most of the remaining
missing PCIe backends, but only enabled them for some amdgpu portions.

this enables all code marked with "XXX amdgpu pcie", "XXX radeon pcie",
and "XXX pcie speed".  for most of it, simply removing #ifndefs __NetBSD__
to enable compliation was required, once the new "bus->max_bus_speed"
member was added to struct pci_bus.  add an "always fails" backend for
pci_enable_atomic_ops_to_root() which seems to only be necessary
for virtual GPU functionality (and could be implemented if needed.)

tested on radeon 5450, 7750, R7 240 [radeon], and RX 550 [amdgpu], and
nvidia 750 and 1030 [nouveau].


this still does not quite work on nvidia cards.  there are two problems
that remain:

- the call to set the link speed is skipped because the speed is set
  to the default value of "-1".  nvkm_pcie_set_link() will actually
  determine the right value for this and for some cards, calling this
  function if the current speed is -1 helps set the link speed.  it
  may be that on linux other paths we don't have enabled properly
  would set this (there's one via debugfs, and a jetson specific one,
  though perhaps setting either AC or DC speed values as boot options
  (after hooking up these for netbsd) would currently work.

- worse, cards newer than kepler - geforce 900, 1000, and newer, are
  all lacking the backing support to set pcie link speed.  the GT 1030
  card i have been testing with remains at pcie 1.0.
2023-09-30 10:46:45 +00:00
mrg 77e2579da2 avoid an unlikely array bounds issue picked up by GCC 12.
nvkm_pcie_speed() can return -1, which is then used as an array index,
so make this default return PCIe 1.0 speeds.
2023-09-30 10:38:31 +00:00
christos 821c512655 we don't have/need limits.h 2023-09-05 22:15:46 +00:00
riastradh ee3f67d30d drm: Fix conditionals around drmkms_pci and agp.
Kernel should build now with all pci drm drivers stripped out but
DRM_LEGACY still enabled.  (Might not be very useful, but it'll
build.  Maybe we should also have DRM_LEGACY_PCI so those drivers can
be modloaded later.)
2023-09-05 20:15:10 +00:00
mrg 0221302e0d match warnings with the module build, fixes i386 with GCC 12. 2023-09-05 06:08:02 +00:00
mrg 7cb953c82f convert a KASSERT() into an if () panic() sequence to appease GCC 12.
OK riastradh@.
2023-09-04 21:31:58 +00:00
christos 2c7d7e3ca2 merge conflicts between 20230628 and 20221020 2023-09-01 18:37:29 +00:00
christos 046a29855e Import acpica-20230628 (last was 20221020)
----------------------------------------
28 June 2023. Summary of changes for version 20230628:

0) Global changes:

Fixed a problem with the ASL/AML Timer() operator. Discovered by
UBSAN: ?array-index-out-of-bounds in acpica/dswexec.c:401:12 index
-1 is out of range for type 'acpi_operand_object?. Added
AML_NO_OPERAND_RESOLVE flag to Timer (since there are no runtime
arguments). Reported by: Abhishek Mainkar abmainkar@nvidia.com.

Added a define for size of acpi_srat_generic_affinity DeviceHandle.
Replaced a magic number with a define. The Linux kernel code will
utilize this. Reported by Dave Jiang dave.jiang@intel.com.

Added support for _DSC (Deepest State for Configuration) as per ACPI 6.5.

1) ACPICA kernel-resident subsystem:

Added port definitions for CDAT SSLBIS. Add upstream port and any
port definitions for SSLBIS. Reported by: Dave Jiang dave.jiang@intel.com.

Fixed misspelled CDAT DSMAS define: ACPI_CEDT_DSMAS_NON_VOLATILE
-> ACPI_CDAT_DSMAS_NON_VOLATILE. Reported by: Dave Jiang
dave.jiang@intel.com.

1) ACPICA kernel-resident subsystem:

Fix GCC 12 dangling-pointer warning.  We're storing a persistent
pointer to an ephemeral local variable which technically is a
dangling pointer and the compiler is correct. However, since we
never indirect the pointer, this is a safe operation and we can
suppress the warning.

Also, some C run-times (like MUSL) aren't including <stdint.h>
indirectly so we must include it explicitly or we won't have the
type definition for uintptr_t.

2) iASL Compiler/Disassembler and ACPICA tools:.

IASL/RHCT: Enable dumping and compiling newly added nodes. The RHCT
table is updated with new nodes. Add compile and dump functionality
for these new structures.

AcpiExec: Added a new command, ?interrupt?. The Interrupt command
simulates an interrupt with a IntID (GSIV) equal to the first
argument of the call/invocation. The acpiexec code simulates the
behavior by OSPM: execute the _EVT method of the GED device associated
with that IntID. Submitted by: Jose Marinho jose.marinho@arm.com.

AcpiExec: Detect GED device and keep track of _EVT. The GED device
is described by a _HID of ACPI0013. This code traverses the namespace
identifying all GED devices. For each GED device in the namespace
we record the Interrupt object and the _EVT method. This information
is used when an interrupt is simulated via the ?interrupt? command.
Submitted by: Jose Marinho jose.marinho@arm.com.
----------------------------------------
31 March 2023. Summary of changes for version 20230331:

This release is available at https://acpica.org/downloads

0) Global changes:


Update all copyright notices to the year 2023. This effects all source
modules, as well as utility signons.
Add OS-specific support for Zephyr RTOS.
Fix miscellaneous code that accesses various objects.
Remove some dead code.
Add C ?Flexible Array? support.
Add support for 64 bit LoongArch compilation.
Add first batch of RISC-V related definitions.
Performed a global automated update to remove tabs, fix indentation
issues, etc.

1) ACPICA kernel-resident subsystem:

hwvalid: Drop port I/O validation.

2) ACPICA tools and utilities:

iASL: Added full macro support in the preprocessor. Example:
#define ABCD(a,b,c,d) a+b+c-d

Known macro support limitations (at this time):
	No support for multi-line #define macros (backslash continuation
lines)
	No support for the C-style ternary operator
	No support for the stringizing operator (#)
	No support for the concatenation (token pasting) operator (##)
	No support for variable number of macro arguments

Add support for AMD Secure Processor Table (ASPT) version 1.
Add support for Arm's MPAM ACPI table version 2.
ACPI 6.5: MADT: add support for trace buffer extension in GICC.
Headers: Delete bogus NodeArray array of pointers from AEST table.
PHAT table support is still ongoing.
2023-09-01 17:48:12 +00:00
mrg a56a944e10 avoid a GCC 12 warning.
there's a 1-element long array and a loop conditional that tries to see
if indexes for it are not identical.  as these indexes will always both
be 0, the only valid index, the condition is always false.  GCC 12
triggers a strange warning on this code that can never run (see below),
so simply assert the array size is 1 and comment the rest.

amdgpu_dc_stream.c:470:55: error: array subscript [0, 0] is outside array bounds of 'struct dc_writeback_info[1]' [-Werror=array-bounds]
  470 |                                 stream->writeback_info[j] = stream->writeback_info[i];
2023-08-15 05:01:57 +00:00
mrg c7cd742397 avoid uninitialised variable usage in drm_gem_cma_create_internal().
in the case nothing has returned 'error', 'nsegs' and the dma info
are (potentially) uninitialised, so consider this an error.

found by GCC 12.
2023-08-15 04:57:36 +00:00
andvar 2c4d487849 viadrmums(4): build legacy VIA DRM UMS driver module for amd64.
This driver is not built-in by default, thus loadable module can help (un)lucky
owners of 64-bit capable VIA (Nano/Eden) systems or early AMD/Intel systems
with some VIA chipsets, which include VIA integrated graphics.
I also boldly added product IDs for few later models from VX8xx/VX9xx chipsets
without 3D support (DX9_0) to "expand" the driver support to more systems.
Tested successfully basic functionality on VX800, and partially successfully
on VX900 (on VX900 Xorg failed to initialize due to openchrome related issues,
viadrmums attaches and it is by used the driver).
Didn't test on VX855, I don't have one.

Pull up to netbsd-10 is needed.
2023-08-09 09:36:26 +00:00
mrg a636a908ed nix the NetBSD specific GEM_BUG_ON().
avoids GCC 12 warnings, and matches upstream closer.
2023-08-08 06:59:40 +00:00
mrg 681df724ca comment a function that has a clear overbounds read but it isn't used.
found by GCC 12.
2023-08-08 06:58:20 +00:00
riastradh 58192d9832 radeon: Suspend ioctls while device is suspended.
XXX pullup-10
2023-08-07 16:35:06 +00:00
riastradh cdd0d8dc1e nouveau: Suspend ioctls while device is suspended.
XXX pullup-10
2023-08-07 16:34:57 +00:00
riastradh 602d3f06a0 amdgpu: Suspend ioctls while device is suspended.
XXX pullup-10
2023-08-07 16:34:47 +00:00
christos 397eb5e938 Use the new struct and ioctl names for the compat functions (thanks Ryo) 2023-08-02 10:31:46 +00:00
mrg f8570f8a97 fix simple mis-matched function prototype and definitions.
most of these are like, eg

   void foo(int[2]);

with either of these

   void foo(int*) { ... }
   void foo(int[]) { ... }

in some cases (such as stat or utimes* calls found in our header files),
we now match standard definition from opengroup.

found by GCC 12.
2023-08-01 07:04:14 +00:00
riastradh 1bc3b8615e drm/linux_ww_mutex: Fix ww acquire context ordering.
XXX pullup-8
XXX pullup-9
XXX pullup-10
2023-07-29 23:50:03 +00:00
riastradh b9b36368ff 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
2023-07-29 22:43:56 +00:00
riastradh 97560bd7b0 amdgpu: Mark float-dependent variables volatile.
This way they are computed -- using FP instructions -- before
DC_FP_END, after which point FP instructions will trap or behave
unpredictably.

This is a workaround, not a proper solution -- really, the
DC_FP_START/END calls should happen in a separate compilation unit
built without -mhard-float or whatever, but that's a lot more work to
make happen for now.

PR kern/57059

XXX pullup-10
2023-07-20 21:48:49 +00:00
mrg b478b13b30 avoid calling drm_sched_fini() for AMDGPU_RING_TYPE_KIQ rings.
drm_sched_init() is not called for these rings, and we'd panic trying
to mutex_destroy() a mutex that wasn't initialised.

this seems like a general bug, not a bug in netbsd port.
2023-07-20 18:02:45 +00:00
riastradh 9860f317b8 amdgpu: Define CONFIG_DRM_AMD_DC to enable display core logic.
Probably resolves a host of issues with amdgpu not detecting
displays!

Noticed by rjs@.

PR kern/57059
PR kern/57325
PR kern/57452

XXX pullup-10
2023-07-14 13:05:59 +00:00