History log of /openbsd-current/sys/dev/pci/drm/drm_memory.c
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# 1.31 14-Jan-2022 jsg

update drm to linux 5.15.14

new hardware support includes

Intel
ehl/Elkhart Lake (embedded)
jsl/Jasper Lake (atom)
rkl/Rocket Lake (desktop)

AMD
van gogh APU (gfx1033)
yellow carp / rembrandt APU (gfx1035?)
Ryzen 6000 APU
navy flounder / navi 22 (gfx1031)
RX 6700, RX 6700 XT, RX 6700M, RX 6800M, RX 6850M XT
dimgrey cavefish / navi 23 (gfx1032)
Pro W6600, Pro W6600M, RX 6600, RX 6600 XT, RX 6600M,
RX 6600S, RX 6650M, RX 6650M XT, RX 6700S, RX 6800S
beige goby / navi 24 (gfx1034)
RX 6500 XT, RX 6400, RX 6500M, RX 6300M

Thanks to the OpenBSD Foundation for sponsoring this work
niklas@ for helping with ttm and amdgpu and patrick@ for adapting
rockchip drm.


Revision tags: OPENBSD_6_8_BASE OPENBSD_6_9_BASE OPENBSD_7_0_BASE
# 1.30 12-Jun-2020 kettenis

Since we don't support CONFIG_SWIOTLB, make drm_need_swiotlb() just return
false. In theory somebody could plug an old radeon card into a machine
with a ridiculous amount of memory (or a really old PCI/AGP card in a
machine with >4GB of memory) but supporting that scenario just isn't
worth it.

ok jsg@


# 1.29 08-Jun-2020 jsg

update drm to linux 5.7

adds kernel support for
amdgpu: vega20, raven2, renoir, navi10, navi14
inteldrm: icelake, tigerlake

Thanks to the OpenBSD Foundation for sponsoring this work, kettenis@ for
helping, patrick@ for helping adapt rockchip drm and many developers for
testing.


Revision tags: OPENBSD_6_6_BASE OPENBSD_6_7_BASE
# 1.28 14-Apr-2019 jsg

Update shared drm code, inteldrm(4) and radeondrm(4) from linux 4.4 to
linux 4.19.34.

Adds support for more Intel hardware:
Broxton/Apollo Lake (was is_preliminary in 4.4)
Amber Lake (another Kaby Lake refresh)
Gemini Lake
Coffee Lake
Whiskey Lake
Cannon Lake (though no hardware with Intel graphics ever shipped)
Ice Lake (alpha support, hardware not released)

This does not add support for new radeon hardware on the AMD side as
newer radeons have a different kernel driver (amdgpu).

Thanks to the OpenBSD Foundation for sponsoring this work, kettenis@ for
helping and a bunch of other developers for testing.


Revision tags: OPENBSD_5_8_BASE OPENBSD_5_9_BASE OPENBSD_6_0_BASE OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE
# 1.27 04-Jun-2015 jsg

use mallocarray instead of malloc in drm_calloc


Revision tags: OPENBSD_5_6_BASE OPENBSD_5_7_BASE
# 1.26 12-Jul-2014 tedu

add a size argument to free. will be used soon, but for now default to 0.
after discussions with beck deraadt kettenis.


# 1.25 09-Mar-2014 jsg

remove dri1 interfaces
discussed with kettenis some time last year


Revision tags: OPENBSD_5_3_BASE OPENBSD_5_4_BASE OPENBSD_5_5_BASE
# 1.24 06-Dec-2012 mpi

Rework how AGP memory regions are mapped and add support for AGP bridges
that do not support remapping for processor accesses.

Add new functions to map/unmap/mmap agp memory and let the agp layer
decides how these memory regions should be accessed. It's assumed here
that the bridge does not support remapping if its aperture address is 0.

This is the last diff required for having drm(4) on macppc using agp(4).

Joint work with and ok kettenis@


# 1.23 08-Sep-2012 mpi

Don't use mtrr if we are not on i386/amd64.

ok kettenis@


Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE
# 1.22 02-Jun-2011 weerd

Add $OpenBSD$ after oga said 'go ahead and fix that'

'go for it' oga@


Revision tags: OPENBSD_4_8_BASE OPENBSD_4_9_BASE
# 1.21 29-Apr-2010 oga

use BUS_SPACE_MAP_PREFETCHABLE on maps that should be WC (soon this will
actually do so).


Revision tags: OPENBSD_4_6_BASE OPENBSD_4_7_BASE
# 1.20 04-Apr-2009 oga

Remove the three inline functions from drmP.h.

deiline drm_core_findmap(), and merge drm_core_ioremap{,free}() into
drm_ioremap{,free}() instead of having an inline that just calls another
function.


# 1.19 03-Apr-2009 oga

detypedef drm_local_map.


# 1.18 31-Mar-2009 oga

remove the drm_read and drm_write functions. instead just do the
conditional on whether we treat the data like memspace or system memory
into the one driver that needs this.

Something similar was done upstream a while back.


# 1.17 27-Mar-2009 oga

Remove a bunch of compat macros, just expand them to the openbsd
equivalent.


# 1.16 26-Mar-2009 oga

The drm_* allocation functions have been #defined to not use most of
their arguments for a while. Actually go through the code and remove the
extraneous arguments. Makes things easier to read.


Revision tags: OPENBSD_4_5_BASE
# 1.15 24-Nov-2008 oga

change drm_attach_mi to drm_attach_pci. we take the pci_attach_args, and
setup the drm_attach_args with the needed information.

require interface version 1.1 libdrm has been requesting it for ages),
which means that we can set the busid string at attach time. (generated in
drm_attach_pci), also pass in the interrupt line and bst.

Now we don't need dev->pa at all, so remove it, finally.


# 1.14 23-Nov-2008 oga

#define away unused arguments for the drm_alloc functions. to save some
size.

kill (empty) drm_mem_{un,}init() while here.


# 1.13 22-Nov-2008 oga

Make all drm drivers map their mmio register space on attach instead of
using the drm_maps interface (this was done for inteldrm a few days
ago). All drivers now ignore the mmio_offset argument that the init
ioctl takes.

This clears up the code and makes sure that drm_ioremap_core() doesn't
need the vga_pci_map inteface anymore, so we don't have to pass in the
vga softc anymore. We also get to kill the drm_resource_{start,length}
linux-alike functions since we just calculate all the requisite offsets
at startup and cache those we need. This now means that technically the
only driver that needs the vga_pci_map api is inteldrm (due to sharing
with intagp issues), though this diff doesn't convert them over.


# 1.12 01-Sep-2008 chl

fix null dereference.

initial patch from me, reworked by oga@.

found by LLVM/Clang Static Analyzer.

ok oga@


# 1.11 29-Aug-2008 oga

Don't memcpy too far whem drm_realloc() is called with a smaller size.
This was never noticed since it's always used with a larger size.

Noticed by Stephane Marchesin.


# 1.10 16-Aug-2008 oga

Apply a light paddling with the knf stick. No binary change.


# 1.9 13-Aug-2008 oga

Check for zero in drm_calloc() to prevent divide-by-zero. Also rearrange
the two calls to drm_calloc() that had nmemb and size the wrong way
around.


Revision tags: OPENBSD_4_4_BASE
# 1.8 29-Jul-2008 oga

Switch all instances of malloc/free in the DRM to drm_alloc, drm_free
and drm_calloc.

With the recent change to check overflow in drm_calloc, this means that
all allocations that require multiplication are now checked. Also use
drm_calloc() when zeroing is needed and drop the bzero/memset
afterwards. Finally, make drm_free() check for NULL, so we don't need
to do so every time.

ok miod@, deraadt@


# 1.7 29-Jul-2008 miod

Check for multiplication overflow in drm_calloc(). ok oga@


# 1.6 10-Jul-2008 oga

the DRM_{READ,WRITE}$NUMBER() macros currently use
bus_space_{read,write}(). A bug in the code this was based on means that
this is also used for scatter gather maps, which are bus_dma memory, not
pci memory. This obviously fails. Pull them out into a function and
Special case scatter gather to use the mapped virtual address to write
instead. Makes writeback test pass on pci and pci express radeon cards.

Tested by, among others ckuethe@ and sthen@.


# 1.5 26-Jun-2008 oga

Kill the silly ``drm_device_t'' and ``drm_file_t'' typedefs. just use
``struct drm_device'' and ``struct drm_file'' respectively. Since i'm
changing a lot of prototypes anyway, remove all parameter names from
prototypes, in accordance with style(9) (and sanity).


# 1.4 26-Jun-2008 oga

Kill the rest of the ifdef maze in drm_*.c

I was going to do this per file, but decided all it would achieve was
artificially increasing my commit count.

>Kill the ifdef maze. I've been considering doing this for months, it
>doesn't make getting changes to and from upstream much easier, and just
>makes the code hard to read.


# 1.3 06-May-2008 oga

currently agp_i810 needs to map the same BAR as inteldrm, this obviously
fails.

In order to allow this, implement an API so that drm and agp can share
mappings for the BARs. Now it works as it should.

tested by many.
ok kettenis, miod said he'd look at it when it's in tree.


Revision tags: OPENBSD_4_3_BASE
# 1.2 16-Dec-2007 oga

destatic the static functions, they only make debugging harder.
While i'm here:
remove a couple of debug printfs that shouldn't have gone in anyway.
trowel on some KNF (I really need to get around to sending some of this upstream).
remove some netbsd specific code that netbsd doesn't have anymore.

ok tedu.


# 1.1 28-Nov-2007 oga

Initial import of the DRM (direct rendering manager).

This is the kernel part necessary for DRI support in X. Disabled for now
because it still has a few bugs, but now I can work on it in tree. Also
requires the requisite bits in X, which are currently under discussion
on how to deal with them with privsep. ported from a combination of the
free and netbsd implementations.

Known bugs:
1) only the first occurence of X in any session will have dri, after
that something prevents it working.
2) if the machine does not have a dri capable card, the kernel panics.
Something's up in one of the probe functions. I haven't been able to
find it though.
3) radeon cards need to be forced to use PCI mode otherwise they get
into an infinite loop.

This is known to at least kinda work with SiS, radeons in pci mode and
intel cards.

ok deraadt, kinda ok art, a few other people had a quick look.


# 1.30 12-Jun-2020 kettenis

Since we don't support CONFIG_SWIOTLB, make drm_need_swiotlb() just return
false. In theory somebody could plug an old radeon card into a machine
with a ridiculous amount of memory (or a really old PCI/AGP card in a
machine with >4GB of memory) but supporting that scenario just isn't
worth it.

ok jsg@


# 1.29 08-Jun-2020 jsg

update drm to linux 5.7

adds kernel support for
amdgpu: vega20, raven2, renoir, navi10, navi14
inteldrm: icelake, tigerlake

Thanks to the OpenBSD Foundation for sponsoring this work, kettenis@ for
helping, patrick@ for helping adapt rockchip drm and many developers for
testing.


Revision tags: OPENBSD_6_6_BASE OPENBSD_6_7_BASE
# 1.28 14-Apr-2019 jsg

Update shared drm code, inteldrm(4) and radeondrm(4) from linux 4.4 to
linux 4.19.34.

Adds support for more Intel hardware:
Broxton/Apollo Lake (was is_preliminary in 4.4)
Amber Lake (another Kaby Lake refresh)
Gemini Lake
Coffee Lake
Whiskey Lake
Cannon Lake (though no hardware with Intel graphics ever shipped)
Ice Lake (alpha support, hardware not released)

This does not add support for new radeon hardware on the AMD side as
newer radeons have a different kernel driver (amdgpu).

Thanks to the OpenBSD Foundation for sponsoring this work, kettenis@ for
helping and a bunch of other developers for testing.


Revision tags: OPENBSD_5_8_BASE OPENBSD_5_9_BASE OPENBSD_6_0_BASE OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE
# 1.27 04-Jun-2015 jsg

use mallocarray instead of malloc in drm_calloc


Revision tags: OPENBSD_5_6_BASE OPENBSD_5_7_BASE
# 1.26 12-Jul-2014 tedu

add a size argument to free. will be used soon, but for now default to 0.
after discussions with beck deraadt kettenis.


# 1.25 09-Mar-2014 jsg

remove dri1 interfaces
discussed with kettenis some time last year


Revision tags: OPENBSD_5_3_BASE OPENBSD_5_4_BASE OPENBSD_5_5_BASE
# 1.24 06-Dec-2012 mpi

Rework how AGP memory regions are mapped and add support for AGP bridges
that do not support remapping for processor accesses.

Add new functions to map/unmap/mmap agp memory and let the agp layer
decides how these memory regions should be accessed. It's assumed here
that the bridge does not support remapping if its aperture address is 0.

This is the last diff required for having drm(4) on macppc using agp(4).

Joint work with and ok kettenis@


# 1.23 08-Sep-2012 mpi

Don't use mtrr if we are not on i386/amd64.

ok kettenis@


Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE
# 1.22 02-Jun-2011 weerd

Add $OpenBSD$ after oga said 'go ahead and fix that'

'go for it' oga@


Revision tags: OPENBSD_4_8_BASE OPENBSD_4_9_BASE
# 1.21 29-Apr-2010 oga

use BUS_SPACE_MAP_PREFETCHABLE on maps that should be WC (soon this will
actually do so).


Revision tags: OPENBSD_4_6_BASE OPENBSD_4_7_BASE
# 1.20 04-Apr-2009 oga

Remove the three inline functions from drmP.h.

deiline drm_core_findmap(), and merge drm_core_ioremap{,free}() into
drm_ioremap{,free}() instead of having an inline that just calls another
function.


# 1.19 03-Apr-2009 oga

detypedef drm_local_map.


# 1.18 31-Mar-2009 oga

remove the drm_read and drm_write functions. instead just do the
conditional on whether we treat the data like memspace or system memory
into the one driver that needs this.

Something similar was done upstream a while back.


# 1.17 27-Mar-2009 oga

Remove a bunch of compat macros, just expand them to the openbsd
equivalent.


# 1.16 26-Mar-2009 oga

The drm_* allocation functions have been #defined to not use most of
their arguments for a while. Actually go through the code and remove the
extraneous arguments. Makes things easier to read.


Revision tags: OPENBSD_4_5_BASE
# 1.15 24-Nov-2008 oga

change drm_attach_mi to drm_attach_pci. we take the pci_attach_args, and
setup the drm_attach_args with the needed information.

require interface version 1.1 libdrm has been requesting it for ages),
which means that we can set the busid string at attach time. (generated in
drm_attach_pci), also pass in the interrupt line and bst.

Now we don't need dev->pa at all, so remove it, finally.


# 1.14 23-Nov-2008 oga

#define away unused arguments for the drm_alloc functions. to save some
size.

kill (empty) drm_mem_{un,}init() while here.


# 1.13 22-Nov-2008 oga

Make all drm drivers map their mmio register space on attach instead of
using the drm_maps interface (this was done for inteldrm a few days
ago). All drivers now ignore the mmio_offset argument that the init
ioctl takes.

This clears up the code and makes sure that drm_ioremap_core() doesn't
need the vga_pci_map inteface anymore, so we don't have to pass in the
vga softc anymore. We also get to kill the drm_resource_{start,length}
linux-alike functions since we just calculate all the requisite offsets
at startup and cache those we need. This now means that technically the
only driver that needs the vga_pci_map api is inteldrm (due to sharing
with intagp issues), though this diff doesn't convert them over.


# 1.12 01-Sep-2008 chl

fix null dereference.

initial patch from me, reworked by oga@.

found by LLVM/Clang Static Analyzer.

ok oga@


# 1.11 29-Aug-2008 oga

Don't memcpy too far whem drm_realloc() is called with a smaller size.
This was never noticed since it's always used with a larger size.

Noticed by Stephane Marchesin.


# 1.10 16-Aug-2008 oga

Apply a light paddling with the knf stick. No binary change.


# 1.9 13-Aug-2008 oga

Check for zero in drm_calloc() to prevent divide-by-zero. Also rearrange
the two calls to drm_calloc() that had nmemb and size the wrong way
around.


Revision tags: OPENBSD_4_4_BASE
# 1.8 29-Jul-2008 oga

Switch all instances of malloc/free in the DRM to drm_alloc, drm_free
and drm_calloc.

With the recent change to check overflow in drm_calloc, this means that
all allocations that require multiplication are now checked. Also use
drm_calloc() when zeroing is needed and drop the bzero/memset
afterwards. Finally, make drm_free() check for NULL, so we don't need
to do so every time.

ok miod@, deraadt@


# 1.7 29-Jul-2008 miod

Check for multiplication overflow in drm_calloc(). ok oga@


# 1.6 10-Jul-2008 oga

the DRM_{READ,WRITE}$NUMBER() macros currently use
bus_space_{read,write}(). A bug in the code this was based on means that
this is also used for scatter gather maps, which are bus_dma memory, not
pci memory. This obviously fails. Pull them out into a function and
Special case scatter gather to use the mapped virtual address to write
instead. Makes writeback test pass on pci and pci express radeon cards.

Tested by, among others ckuethe@ and sthen@.


# 1.5 26-Jun-2008 oga

Kill the silly ``drm_device_t'' and ``drm_file_t'' typedefs. just use
``struct drm_device'' and ``struct drm_file'' respectively. Since i'm
changing a lot of prototypes anyway, remove all parameter names from
prototypes, in accordance with style(9) (and sanity).


# 1.4 26-Jun-2008 oga

Kill the rest of the ifdef maze in drm_*.c

I was going to do this per file, but decided all it would achieve was
artificially increasing my commit count.

>Kill the ifdef maze. I've been considering doing this for months, it
>doesn't make getting changes to and from upstream much easier, and just
>makes the code hard to read.


# 1.3 06-May-2008 oga

currently agp_i810 needs to map the same BAR as inteldrm, this obviously
fails.

In order to allow this, implement an API so that drm and agp can share
mappings for the BARs. Now it works as it should.

tested by many.
ok kettenis, miod said he'd look at it when it's in tree.


Revision tags: OPENBSD_4_3_BASE
# 1.2 16-Dec-2007 oga

destatic the static functions, they only make debugging harder.
While i'm here:
remove a couple of debug printfs that shouldn't have gone in anyway.
trowel on some KNF (I really need to get around to sending some of this upstream).
remove some netbsd specific code that netbsd doesn't have anymore.

ok tedu.


# 1.1 28-Nov-2007 oga

Initial import of the DRM (direct rendering manager).

This is the kernel part necessary for DRI support in X. Disabled for now
because it still has a few bugs, but now I can work on it in tree. Also
requires the requisite bits in X, which are currently under discussion
on how to deal with them with privsep. ported from a combination of the
free and netbsd implementations.

Known bugs:
1) only the first occurence of X in any session will have dri, after
that something prevents it working.
2) if the machine does not have a dri capable card, the kernel panics.
Something's up in one of the probe functions. I haven't been able to
find it though.
3) radeon cards need to be forced to use PCI mode otherwise they get
into an infinite loop.

This is known to at least kinda work with SiS, radeons in pci mode and
intel cards.

ok deraadt, kinda ok art, a few other people had a quick look.


# 1.29 08-Jun-2020 jsg

update drm to linux 5.7

adds kernel support for
amdgpu: vega20, raven2, renoir, navi10, navi14
inteldrm: icelake, tigerlake

Thanks to the OpenBSD Foundation for sponsoring this work, kettenis@ for
helping, patrick@ for helping adapt rockchip drm and many developers for
testing.


Revision tags: OPENBSD_6_6_BASE OPENBSD_6_7_BASE
# 1.28 14-Apr-2019 jsg

Update shared drm code, inteldrm(4) and radeondrm(4) from linux 4.4 to
linux 4.19.34.

Adds support for more Intel hardware:
Broxton/Apollo Lake (was is_preliminary in 4.4)
Amber Lake (another Kaby Lake refresh)
Gemini Lake
Coffee Lake
Whiskey Lake
Cannon Lake (though no hardware with Intel graphics ever shipped)
Ice Lake (alpha support, hardware not released)

This does not add support for new radeon hardware on the AMD side as
newer radeons have a different kernel driver (amdgpu).

Thanks to the OpenBSD Foundation for sponsoring this work, kettenis@ for
helping and a bunch of other developers for testing.


Revision tags: OPENBSD_5_8_BASE OPENBSD_5_9_BASE OPENBSD_6_0_BASE OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE
# 1.27 04-Jun-2015 jsg

use mallocarray instead of malloc in drm_calloc


Revision tags: OPENBSD_5_6_BASE OPENBSD_5_7_BASE
# 1.26 12-Jul-2014 tedu

add a size argument to free. will be used soon, but for now default to 0.
after discussions with beck deraadt kettenis.


# 1.25 09-Mar-2014 jsg

remove dri1 interfaces
discussed with kettenis some time last year


Revision tags: OPENBSD_5_3_BASE OPENBSD_5_4_BASE OPENBSD_5_5_BASE
# 1.24 06-Dec-2012 mpi

Rework how AGP memory regions are mapped and add support for AGP bridges
that do not support remapping for processor accesses.

Add new functions to map/unmap/mmap agp memory and let the agp layer
decides how these memory regions should be accessed. It's assumed here
that the bridge does not support remapping if its aperture address is 0.

This is the last diff required for having drm(4) on macppc using agp(4).

Joint work with and ok kettenis@


# 1.23 08-Sep-2012 mpi

Don't use mtrr if we are not on i386/amd64.

ok kettenis@


Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE
# 1.22 02-Jun-2011 weerd

Add $OpenBSD$ after oga said 'go ahead and fix that'

'go for it' oga@


Revision tags: OPENBSD_4_8_BASE OPENBSD_4_9_BASE
# 1.21 29-Apr-2010 oga

use BUS_SPACE_MAP_PREFETCHABLE on maps that should be WC (soon this will
actually do so).


Revision tags: OPENBSD_4_6_BASE OPENBSD_4_7_BASE
# 1.20 04-Apr-2009 oga

Remove the three inline functions from drmP.h.

deiline drm_core_findmap(), and merge drm_core_ioremap{,free}() into
drm_ioremap{,free}() instead of having an inline that just calls another
function.


# 1.19 03-Apr-2009 oga

detypedef drm_local_map.


# 1.18 31-Mar-2009 oga

remove the drm_read and drm_write functions. instead just do the
conditional on whether we treat the data like memspace or system memory
into the one driver that needs this.

Something similar was done upstream a while back.


# 1.17 27-Mar-2009 oga

Remove a bunch of compat macros, just expand them to the openbsd
equivalent.


# 1.16 26-Mar-2009 oga

The drm_* allocation functions have been #defined to not use most of
their arguments for a while. Actually go through the code and remove the
extraneous arguments. Makes things easier to read.


Revision tags: OPENBSD_4_5_BASE
# 1.15 24-Nov-2008 oga

change drm_attach_mi to drm_attach_pci. we take the pci_attach_args, and
setup the drm_attach_args with the needed information.

require interface version 1.1 libdrm has been requesting it for ages),
which means that we can set the busid string at attach time. (generated in
drm_attach_pci), also pass in the interrupt line and bst.

Now we don't need dev->pa at all, so remove it, finally.


# 1.14 23-Nov-2008 oga

#define away unused arguments for the drm_alloc functions. to save some
size.

kill (empty) drm_mem_{un,}init() while here.


# 1.13 22-Nov-2008 oga

Make all drm drivers map their mmio register space on attach instead of
using the drm_maps interface (this was done for inteldrm a few days
ago). All drivers now ignore the mmio_offset argument that the init
ioctl takes.

This clears up the code and makes sure that drm_ioremap_core() doesn't
need the vga_pci_map inteface anymore, so we don't have to pass in the
vga softc anymore. We also get to kill the drm_resource_{start,length}
linux-alike functions since we just calculate all the requisite offsets
at startup and cache those we need. This now means that technically the
only driver that needs the vga_pci_map api is inteldrm (due to sharing
with intagp issues), though this diff doesn't convert them over.


# 1.12 01-Sep-2008 chl

fix null dereference.

initial patch from me, reworked by oga@.

found by LLVM/Clang Static Analyzer.

ok oga@


# 1.11 29-Aug-2008 oga

Don't memcpy too far whem drm_realloc() is called with a smaller size.
This was never noticed since it's always used with a larger size.

Noticed by Stephane Marchesin.


# 1.10 16-Aug-2008 oga

Apply a light paddling with the knf stick. No binary change.


# 1.9 13-Aug-2008 oga

Check for zero in drm_calloc() to prevent divide-by-zero. Also rearrange
the two calls to drm_calloc() that had nmemb and size the wrong way
around.


Revision tags: OPENBSD_4_4_BASE
# 1.8 29-Jul-2008 oga

Switch all instances of malloc/free in the DRM to drm_alloc, drm_free
and drm_calloc.

With the recent change to check overflow in drm_calloc, this means that
all allocations that require multiplication are now checked. Also use
drm_calloc() when zeroing is needed and drop the bzero/memset
afterwards. Finally, make drm_free() check for NULL, so we don't need
to do so every time.

ok miod@, deraadt@


# 1.7 29-Jul-2008 miod

Check for multiplication overflow in drm_calloc(). ok oga@


# 1.6 10-Jul-2008 oga

the DRM_{READ,WRITE}$NUMBER() macros currently use
bus_space_{read,write}(). A bug in the code this was based on means that
this is also used for scatter gather maps, which are bus_dma memory, not
pci memory. This obviously fails. Pull them out into a function and
Special case scatter gather to use the mapped virtual address to write
instead. Makes writeback test pass on pci and pci express radeon cards.

Tested by, among others ckuethe@ and sthen@.


# 1.5 26-Jun-2008 oga

Kill the silly ``drm_device_t'' and ``drm_file_t'' typedefs. just use
``struct drm_device'' and ``struct drm_file'' respectively. Since i'm
changing a lot of prototypes anyway, remove all parameter names from
prototypes, in accordance with style(9) (and sanity).


# 1.4 26-Jun-2008 oga

Kill the rest of the ifdef maze in drm_*.c

I was going to do this per file, but decided all it would achieve was
artificially increasing my commit count.

>Kill the ifdef maze. I've been considering doing this for months, it
>doesn't make getting changes to and from upstream much easier, and just
>makes the code hard to read.


# 1.3 06-May-2008 oga

currently agp_i810 needs to map the same BAR as inteldrm, this obviously
fails.

In order to allow this, implement an API so that drm and agp can share
mappings for the BARs. Now it works as it should.

tested by many.
ok kettenis, miod said he'd look at it when it's in tree.


Revision tags: OPENBSD_4_3_BASE
# 1.2 16-Dec-2007 oga

destatic the static functions, they only make debugging harder.
While i'm here:
remove a couple of debug printfs that shouldn't have gone in anyway.
trowel on some KNF (I really need to get around to sending some of this upstream).
remove some netbsd specific code that netbsd doesn't have anymore.

ok tedu.


# 1.1 28-Nov-2007 oga

Initial import of the DRM (direct rendering manager).

This is the kernel part necessary for DRI support in X. Disabled for now
because it still has a few bugs, but now I can work on it in tree. Also
requires the requisite bits in X, which are currently under discussion
on how to deal with them with privsep. ported from a combination of the
free and netbsd implementations.

Known bugs:
1) only the first occurence of X in any session will have dri, after
that something prevents it working.
2) if the machine does not have a dri capable card, the kernel panics.
Something's up in one of the probe functions. I haven't been able to
find it though.
3) radeon cards need to be forced to use PCI mode otherwise they get
into an infinite loop.

This is known to at least kinda work with SiS, radeons in pci mode and
intel cards.

ok deraadt, kinda ok art, a few other people had a quick look.


# 1.28 14-Apr-2019 jsg

Update shared drm code, inteldrm(4) and radeondrm(4) from linux 4.4 to
linux 4.19.34.

Adds support for more Intel hardware:
Broxton/Apollo Lake (was is_preliminary in 4.4)
Amber Lake (another Kaby Lake refresh)
Gemini Lake
Coffee Lake
Whiskey Lake
Cannon Lake (though no hardware with Intel graphics ever shipped)
Ice Lake (alpha support, hardware not released)

This does not add support for new radeon hardware on the AMD side as
newer radeons have a different kernel driver (amdgpu).

Thanks to the OpenBSD Foundation for sponsoring this work, kettenis@ for
helping and a bunch of other developers for testing.


Revision tags: OPENBSD_5_8_BASE OPENBSD_5_9_BASE OPENBSD_6_0_BASE OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE
# 1.27 04-Jun-2015 jsg

use mallocarray instead of malloc in drm_calloc


Revision tags: OPENBSD_5_6_BASE OPENBSD_5_7_BASE
# 1.26 12-Jul-2014 tedu

add a size argument to free. will be used soon, but for now default to 0.
after discussions with beck deraadt kettenis.


# 1.25 09-Mar-2014 jsg

remove dri1 interfaces
discussed with kettenis some time last year


Revision tags: OPENBSD_5_3_BASE OPENBSD_5_4_BASE OPENBSD_5_5_BASE
# 1.24 06-Dec-2012 mpi

Rework how AGP memory regions are mapped and add support for AGP bridges
that do not support remapping for processor accesses.

Add new functions to map/unmap/mmap agp memory and let the agp layer
decides how these memory regions should be accessed. It's assumed here
that the bridge does not support remapping if its aperture address is 0.

This is the last diff required for having drm(4) on macppc using agp(4).

Joint work with and ok kettenis@


# 1.23 08-Sep-2012 mpi

Don't use mtrr if we are not on i386/amd64.

ok kettenis@


Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE
# 1.22 02-Jun-2011 weerd

Add $OpenBSD$ after oga said 'go ahead and fix that'

'go for it' oga@


Revision tags: OPENBSD_4_8_BASE OPENBSD_4_9_BASE
# 1.21 29-Apr-2010 oga

use BUS_SPACE_MAP_PREFETCHABLE on maps that should be WC (soon this will
actually do so).


Revision tags: OPENBSD_4_6_BASE OPENBSD_4_7_BASE
# 1.20 04-Apr-2009 oga

Remove the three inline functions from drmP.h.

deiline drm_core_findmap(), and merge drm_core_ioremap{,free}() into
drm_ioremap{,free}() instead of having an inline that just calls another
function.


# 1.19 03-Apr-2009 oga

detypedef drm_local_map.


# 1.18 31-Mar-2009 oga

remove the drm_read and drm_write functions. instead just do the
conditional on whether we treat the data like memspace or system memory
into the one driver that needs this.

Something similar was done upstream a while back.


# 1.17 27-Mar-2009 oga

Remove a bunch of compat macros, just expand them to the openbsd
equivalent.


# 1.16 26-Mar-2009 oga

The drm_* allocation functions have been #defined to not use most of
their arguments for a while. Actually go through the code and remove the
extraneous arguments. Makes things easier to read.


Revision tags: OPENBSD_4_5_BASE
# 1.15 24-Nov-2008 oga

change drm_attach_mi to drm_attach_pci. we take the pci_attach_args, and
setup the drm_attach_args with the needed information.

require interface version 1.1 libdrm has been requesting it for ages),
which means that we can set the busid string at attach time. (generated in
drm_attach_pci), also pass in the interrupt line and bst.

Now we don't need dev->pa at all, so remove it, finally.


# 1.14 23-Nov-2008 oga

#define away unused arguments for the drm_alloc functions. to save some
size.

kill (empty) drm_mem_{un,}init() while here.


# 1.13 22-Nov-2008 oga

Make all drm drivers map their mmio register space on attach instead of
using the drm_maps interface (this was done for inteldrm a few days
ago). All drivers now ignore the mmio_offset argument that the init
ioctl takes.

This clears up the code and makes sure that drm_ioremap_core() doesn't
need the vga_pci_map inteface anymore, so we don't have to pass in the
vga softc anymore. We also get to kill the drm_resource_{start,length}
linux-alike functions since we just calculate all the requisite offsets
at startup and cache those we need. This now means that technically the
only driver that needs the vga_pci_map api is inteldrm (due to sharing
with intagp issues), though this diff doesn't convert them over.


# 1.12 01-Sep-2008 chl

fix null dereference.

initial patch from me, reworked by oga@.

found by LLVM/Clang Static Analyzer.

ok oga@


# 1.11 29-Aug-2008 oga

Don't memcpy too far whem drm_realloc() is called with a smaller size.
This was never noticed since it's always used with a larger size.

Noticed by Stephane Marchesin.


# 1.10 16-Aug-2008 oga

Apply a light paddling with the knf stick. No binary change.


# 1.9 13-Aug-2008 oga

Check for zero in drm_calloc() to prevent divide-by-zero. Also rearrange
the two calls to drm_calloc() that had nmemb and size the wrong way
around.


Revision tags: OPENBSD_4_4_BASE
# 1.8 29-Jul-2008 oga

Switch all instances of malloc/free in the DRM to drm_alloc, drm_free
and drm_calloc.

With the recent change to check overflow in drm_calloc, this means that
all allocations that require multiplication are now checked. Also use
drm_calloc() when zeroing is needed and drop the bzero/memset
afterwards. Finally, make drm_free() check for NULL, so we don't need
to do so every time.

ok miod@, deraadt@


# 1.7 29-Jul-2008 miod

Check for multiplication overflow in drm_calloc(). ok oga@


# 1.6 10-Jul-2008 oga

the DRM_{READ,WRITE}$NUMBER() macros currently use
bus_space_{read,write}(). A bug in the code this was based on means that
this is also used for scatter gather maps, which are bus_dma memory, not
pci memory. This obviously fails. Pull them out into a function and
Special case scatter gather to use the mapped virtual address to write
instead. Makes writeback test pass on pci and pci express radeon cards.

Tested by, among others ckuethe@ and sthen@.


# 1.5 26-Jun-2008 oga

Kill the silly ``drm_device_t'' and ``drm_file_t'' typedefs. just use
``struct drm_device'' and ``struct drm_file'' respectively. Since i'm
changing a lot of prototypes anyway, remove all parameter names from
prototypes, in accordance with style(9) (and sanity).


# 1.4 26-Jun-2008 oga

Kill the rest of the ifdef maze in drm_*.c

I was going to do this per file, but decided all it would achieve was
artificially increasing my commit count.

>Kill the ifdef maze. I've been considering doing this for months, it
>doesn't make getting changes to and from upstream much easier, and just
>makes the code hard to read.


# 1.3 06-May-2008 oga

currently agp_i810 needs to map the same BAR as inteldrm, this obviously
fails.

In order to allow this, implement an API so that drm and agp can share
mappings for the BARs. Now it works as it should.

tested by many.
ok kettenis, miod said he'd look at it when it's in tree.


Revision tags: OPENBSD_4_3_BASE
# 1.2 16-Dec-2007 oga

destatic the static functions, they only make debugging harder.
While i'm here:
remove a couple of debug printfs that shouldn't have gone in anyway.
trowel on some KNF (I really need to get around to sending some of this upstream).
remove some netbsd specific code that netbsd doesn't have anymore.

ok tedu.


# 1.1 28-Nov-2007 oga

Initial import of the DRM (direct rendering manager).

This is the kernel part necessary for DRI support in X. Disabled for now
because it still has a few bugs, but now I can work on it in tree. Also
requires the requisite bits in X, which are currently under discussion
on how to deal with them with privsep. ported from a combination of the
free and netbsd implementations.

Known bugs:
1) only the first occurence of X in any session will have dri, after
that something prevents it working.
2) if the machine does not have a dri capable card, the kernel panics.
Something's up in one of the probe functions. I haven't been able to
find it though.
3) radeon cards need to be forced to use PCI mode otherwise they get
into an infinite loop.

This is known to at least kinda work with SiS, radeons in pci mode and
intel cards.

ok deraadt, kinda ok art, a few other people had a quick look.


Revision tags: OPENBSD_5_8_BASE OPENBSD_5_9_BASE OPENBSD_6_0_BASE OPENBSD_6_1_BASE OPENBSD_6_2_BASE
# 1.27 04-Jun-2015 jsg

use mallocarray instead of malloc in drm_calloc


Revision tags: OPENBSD_5_6_BASE OPENBSD_5_7_BASE
# 1.26 12-Jul-2014 tedu

add a size argument to free. will be used soon, but for now default to 0.
after discussions with beck deraadt kettenis.


# 1.25 09-Mar-2014 jsg

remove dri1 interfaces
discussed with kettenis some time last year


Revision tags: OPENBSD_5_3_BASE OPENBSD_5_4_BASE OPENBSD_5_5_BASE
# 1.24 06-Dec-2012 mpi

Rework how AGP memory regions are mapped and add support for AGP bridges
that do not support remapping for processor accesses.

Add new functions to map/unmap/mmap agp memory and let the agp layer
decides how these memory regions should be accessed. It's assumed here
that the bridge does not support remapping if its aperture address is 0.

This is the last diff required for having drm(4) on macppc using agp(4).

Joint work with and ok kettenis@


# 1.23 08-Sep-2012 mpi

Don't use mtrr if we are not on i386/amd64.

ok kettenis@


Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE
# 1.22 02-Jun-2011 weerd

Add $OpenBSD$ after oga said 'go ahead and fix that'

'go for it' oga@


Revision tags: OPENBSD_4_8_BASE OPENBSD_4_9_BASE
# 1.21 29-Apr-2010 oga

use BUS_SPACE_MAP_PREFETCHABLE on maps that should be WC (soon this will
actually do so).


Revision tags: OPENBSD_4_6_BASE OPENBSD_4_7_BASE
# 1.20 04-Apr-2009 oga

Remove the three inline functions from drmP.h.

deiline drm_core_findmap(), and merge drm_core_ioremap{,free}() into
drm_ioremap{,free}() instead of having an inline that just calls another
function.


# 1.19 03-Apr-2009 oga

detypedef drm_local_map.


# 1.18 31-Mar-2009 oga

remove the drm_read and drm_write functions. instead just do the
conditional on whether we treat the data like memspace or system memory
into the one driver that needs this.

Something similar was done upstream a while back.


# 1.17 27-Mar-2009 oga

Remove a bunch of compat macros, just expand them to the openbsd
equivalent.


# 1.16 26-Mar-2009 oga

The drm_* allocation functions have been #defined to not use most of
their arguments for a while. Actually go through the code and remove the
extraneous arguments. Makes things easier to read.


Revision tags: OPENBSD_4_5_BASE
# 1.15 24-Nov-2008 oga

change drm_attach_mi to drm_attach_pci. we take the pci_attach_args, and
setup the drm_attach_args with the needed information.

require interface version 1.1 libdrm has been requesting it for ages),
which means that we can set the busid string at attach time. (generated in
drm_attach_pci), also pass in the interrupt line and bst.

Now we don't need dev->pa at all, so remove it, finally.


# 1.14 23-Nov-2008 oga

#define away unused arguments for the drm_alloc functions. to save some
size.

kill (empty) drm_mem_{un,}init() while here.


# 1.13 22-Nov-2008 oga

Make all drm drivers map their mmio register space on attach instead of
using the drm_maps interface (this was done for inteldrm a few days
ago). All drivers now ignore the mmio_offset argument that the init
ioctl takes.

This clears up the code and makes sure that drm_ioremap_core() doesn't
need the vga_pci_map inteface anymore, so we don't have to pass in the
vga softc anymore. We also get to kill the drm_resource_{start,length}
linux-alike functions since we just calculate all the requisite offsets
at startup and cache those we need. This now means that technically the
only driver that needs the vga_pci_map api is inteldrm (due to sharing
with intagp issues), though this diff doesn't convert them over.


# 1.12 01-Sep-2008 chl

fix null dereference.

initial patch from me, reworked by oga@.

found by LLVM/Clang Static Analyzer.

ok oga@


# 1.11 29-Aug-2008 oga

Don't memcpy too far whem drm_realloc() is called with a smaller size.
This was never noticed since it's always used with a larger size.

Noticed by Stephane Marchesin.


# 1.10 16-Aug-2008 oga

Apply a light paddling with the knf stick. No binary change.


# 1.9 13-Aug-2008 oga

Check for zero in drm_calloc() to prevent divide-by-zero. Also rearrange
the two calls to drm_calloc() that had nmemb and size the wrong way
around.


Revision tags: OPENBSD_4_4_BASE
# 1.8 29-Jul-2008 oga

Switch all instances of malloc/free in the DRM to drm_alloc, drm_free
and drm_calloc.

With the recent change to check overflow in drm_calloc, this means that
all allocations that require multiplication are now checked. Also use
drm_calloc() when zeroing is needed and drop the bzero/memset
afterwards. Finally, make drm_free() check for NULL, so we don't need
to do so every time.

ok miod@, deraadt@


# 1.7 29-Jul-2008 miod

Check for multiplication overflow in drm_calloc(). ok oga@


# 1.6 10-Jul-2008 oga

the DRM_{READ,WRITE}$NUMBER() macros currently use
bus_space_{read,write}(). A bug in the code this was based on means that
this is also used for scatter gather maps, which are bus_dma memory, not
pci memory. This obviously fails. Pull them out into a function and
Special case scatter gather to use the mapped virtual address to write
instead. Makes writeback test pass on pci and pci express radeon cards.

Tested by, among others ckuethe@ and sthen@.


# 1.5 26-Jun-2008 oga

Kill the silly ``drm_device_t'' and ``drm_file_t'' typedefs. just use
``struct drm_device'' and ``struct drm_file'' respectively. Since i'm
changing a lot of prototypes anyway, remove all parameter names from
prototypes, in accordance with style(9) (and sanity).


# 1.4 26-Jun-2008 oga

Kill the rest of the ifdef maze in drm_*.c

I was going to do this per file, but decided all it would achieve was
artificially increasing my commit count.

>Kill the ifdef maze. I've been considering doing this for months, it
>doesn't make getting changes to and from upstream much easier, and just
>makes the code hard to read.


# 1.3 06-May-2008 oga

currently agp_i810 needs to map the same BAR as inteldrm, this obviously
fails.

In order to allow this, implement an API so that drm and agp can share
mappings for the BARs. Now it works as it should.

tested by many.
ok kettenis, miod said he'd look at it when it's in tree.


Revision tags: OPENBSD_4_3_BASE
# 1.2 16-Dec-2007 oga

destatic the static functions, they only make debugging harder.
While i'm here:
remove a couple of debug printfs that shouldn't have gone in anyway.
trowel on some KNF (I really need to get around to sending some of this upstream).
remove some netbsd specific code that netbsd doesn't have anymore.

ok tedu.


# 1.1 28-Nov-2007 oga

Initial import of the DRM (direct rendering manager).

This is the kernel part necessary for DRI support in X. Disabled for now
because it still has a few bugs, but now I can work on it in tree. Also
requires the requisite bits in X, which are currently under discussion
on how to deal with them with privsep. ported from a combination of the
free and netbsd implementations.

Known bugs:
1) only the first occurence of X in any session will have dri, after
that something prevents it working.
2) if the machine does not have a dri capable card, the kernel panics.
Something's up in one of the probe functions. I haven't been able to
find it though.
3) radeon cards need to be forced to use PCI mode otherwise they get
into an infinite loop.

This is known to at least kinda work with SiS, radeons in pci mode and
intel cards.

ok deraadt, kinda ok art, a few other people had a quick look.