Commit Graph

4584 Commits

Author SHA1 Message Date
Jean-Sébastien Pédron
a04aa80e77
lindebugfs: Add debugfs_create_file_size()
This is the same as `debugfs_create_file()` but takes the initial size
of the file. In FreeBSD, the given size is ignored and
`debugfs_create_file()` is called.

Reviewed by:	emaste, manu
Approved by:	manu
Differential Revision:	https://reviews.freebsd.org/D37914
2023-01-25 23:23:16 +01:00
Jean-Sébastien Pédron
66cc55a041
linuxkpi: Define PCI_STD_NUM_BARS in <linux/pci.h>
Reviewed by:	emaste, manu
Approved by:	emaste, manu
Differential Revision:	https://reviews.freebsd.org/D38162
2023-01-25 22:57:32 +01:00
Jean-Sébastien Pédron
ccd31b4645
linuxkpi: Define pm_suspend_target_state in <linux/suspend.h>
It is set to `PM_SUSPEND_ON`.

Reviewed by:	manu
Approved by:	manu
Differential Revision:	https://reviews.freebsd.org/D38161
2023-01-25 22:57:21 +01:00
Jean-Sébastien Pédron
4152ce2139
linuxkpi: Add msix_cap to struct pci_dev
At the same time, define `PCI_MSIX_FLAGS`and `PCI_MSIX_FLAGS_ENABLE`.

Reviewed by:	manu
Approved by:	manu
Differential Revision:	https://reviews.freebsd.org/D38160
2023-01-25 22:57:08 +01:00
Jean-Sébastien Pédron
e64afbc215
linuxkpi: Add sysfs_emit_at() in <linux/sysfs.h>
Reviewed by:	manu
Approved by:	manu
Differential Revision:	https://reviews.freebsd.org/D38159
2023-01-25 22:56:56 +01:00
Jean-Sébastien Pédron
47877d61af
linuxkpi: Define is_cow_mapping(flags) as false
Reviewed by:	manu
Approved by:	manu
Differential Revision:	https://reviews.freebsd.org/D38158
2023-01-25 22:56:40 +01:00
Jean-Sébastien Pédron
3d47e3bf7b
linuxkpi: Include <linux/vmalloc.h> from <linux/pagemap.h>
I'm not sure this is correct, but it gives access to the definition of
`PAGE_KERNEL` in `ttm_tt.c` in the DRM drivers.

Reviewed by:	manu
Approved by:	manu
Differential Revision:	https://reviews.freebsd.org/D38154
2023-01-25 22:50:52 +01:00
Jean-Sébastien Pédron
b34cd67243
linuxkpi: Add seqcount_ww_mutex_t in <linux/seqlock.h>
It is defined as a synonymous to `seqcount_mutex_t`.

Reviewed by:	manu
Approved by:	manu
Differential Revision:	https://reviews.freebsd.org/D38152
2023-01-25 22:50:38 +01:00
Jean-Sébastien Pédron
d9f1cb6774
linuxkpi: Define DEFINE_WD_CLASS(name) in <linux/ww_mutex.h>
It is defined as a synonymous to `DEFINE_WW_CLASS(name)`.

Reviewed by:	manu
Approved by:	manu
Differential Revision:	https://reviews.freebsd.org/D38151
2023-01-25 22:50:27 +01:00
Jean-Sébastien Pédron
04cbeeb597
linuxkpi: Adds more SZ_* macros
`SZ_2K` and `SZ_1G` were defined in irdma. They are removed from this
driver.

Reviewed by:	manu
Approved by:	manu
Differential Revision:	https://reviews.freebsd.org/D38150
2023-01-25 22:50:07 +01:00
Jean-Sébastien Pédron
f27b1399d6
linuxkpi: Define ENOKEY to 126.
This is the same error code as Linux. This value is unused on FreeBSD.

Reviewed by:	manu
Approved by:	manu
Differential Revision:	https://reviews.freebsd.org/D38149
2023-01-25 22:49:53 +01:00
Jean-Sébastien Pédron
49b6d5ed14
linuxkpi: Add pci_device_is_present()
This calls bus_child_present(9) internally.

Reviewed by:	manu
Approved by:	manu
Differential Revision:	https://reviews.freebsd.org/D38148
2023-01-25 22:49:38 +01:00
Jean-Sébastien Pédron
bbff0400c1
linuxkpi: Define dev_dbg_ratelimited()
Reviewed by:	manu
Approved by:	manu
Differential Revision:	https://reviews.freebsd.org/D38145
2023-01-25 22:48:32 +01:00
Jean-Sébastien Pédron
9491ea7c68
linuxkpi: Fix atomic_long_sub() overflow
By (ab)using `atomic_long_add_return()`, `atomic_long_sub()` was making
the atomic long overflow. Indeed the underlying FreeBSD atomic is based
on an unsigned long.

Reviewed by:	manu
Approved by:	manu
Differential Revision:	https://reviews.freebsd.org/D38090
2023-01-25 22:26:54 +01:00
Jean-Sébastien Pédron
b99bc86232
linuxkpi: Add io_mapping_map_user() and remap_pfn_range()
The code comes from the i915 DRM driver.

In Linux commits b739f125e4ebd73d10ed30a856574e13649119ed and
b12d691ea5e01db42ccf3b4207e57cb3ce7cfe91 (Linux 5.13), the i915 DRM
driver dropped specific implementations to use Linux generic functions.
Therefore I moved the FreeBSD code from that i915 driver to linuxkpi.

However, these commits were later reverted (also in Linux 5.13) so the
i915 driver doesn't use these functions. But perhaps it will help in the
future.

To sum up, the code comes from the i915 DRM driver but it doesn't use it
(i.e. it continues to use its internal implementation).

Reviewed by:	manu
Approved by:	manu
Differential Revision:	https://reviews.freebsd.org/D38088
2023-01-25 22:26:54 +01:00
Jean-Sébastien Pédron
4fee6659c4
linuxkpi: Add sysfs_emit()
Reviewed by:	manu
Approved by:	manu
Differential Revision:	https://reviews.freebsd.org/D38086
2023-01-25 22:26:54 +01:00
Jean-Sébastien Pédron
0d4d9ee6f0
linuxkpi: Add complete field to struct dev_pm_ops
This change breaks the KBI.

Reviewed by:	manu
Approved by:	manu
Differential Revision:	https://reviews.freebsd.org/D38085
2023-01-25 22:26:54 +01:00
Jean-Sébastien Pédron
270a133480
linuxkpi: Add pm_suspend_via_firmware()
Reviewed by:	manu
Approved by:	manu
Differential Revision:	https://reviews.freebsd.org/D38084
2023-01-25 22:26:53 +01:00
Jean-Sébastien Pédron
710c6084d1
linuxkpi: Add pm_runtime_suspended()
Reviewed by:	manu
Approved by:	manu
Differential Revision:	https://reviews.freebsd.org/D38083
2023-01-25 22:26:53 +01:00
Jean-Sébastien Pédron
2272ccaa68
linuxkpi: Define tasklet_unlock_spin_wait() as tasklet_unlock_wait()
Reviewed by:	manu
Approved by:	manu
Differential Revision:	https://reviews.freebsd.org/D38080
2023-01-25 22:26:53 +01:00
Jean-Sébastien Pédron
a609ed7959
linuxkpi: Define synchronize_hardirq()
It currently does the same as `synchronize_irq()`.

Reviewed by:	manu
Approved by:	manu
Differential Revision:	https://reviews.freebsd.org/D38079
2023-01-25 22:26:53 +01:00
Jean-Sébastien Pédron
976aa07a88
lindebugfs: Add missing debugfs_create_u*() and debugfs_create_x*()
The `debugfs_create_x*()` variants are the same as their
`debugfs_create_u*()` equivalent, but they work with lowercase
hexadecimal.

While here, fix a few style(9) issues.

Reviewed by:	manu
Approved by:	manu
Differential Revision:	https://reviews.freebsd.org/D38087
2023-01-25 22:26:52 +01:00
Jean-Sébastien Pédron
f2044a3030
lindebugfs: Add debugfs_create_atomic_t()
Reviewed by:	jfree
Approved by:	jfree
Differential Revision:	https://reviews.freebsd.org/D37915
2023-01-25 22:26:32 +01:00
Jean-Sébastien Pédron
bb651c77f5
linuxkpi: Define hrtimer_try_to_cancel()
It is the same as callout_stop(9) but the return values are different.

Reviewed by:	hselasky
Approved by:	hselasky
Differential Revision:	https://reviews.freebsd.org/D38081
2023-01-18 23:02:24 +01:00
Jean-Sébastien Pédron
e8ce32bea3
linuxkpi: Define EBADSLT to 57
This is the same error code as Linux.

As emaste@ noted in the review, FreeBSD defines the following errno
values in `sys/errno.h`:
* 56 is `EISCONN`
* 57 is `ENOTCONN`

Reviewed by:	manu
Approved by:	manu
Differential Revision:	https://reviews.freebsd.org/D37935
2023-01-16 19:27:21 +01:00
Jean-Sébastien Pédron
cf8f392260
linuxkpi: Add memalloc_noreclaim_save() and memalloc_noreclaim_restore()
They are no-ops.

Reviewed by:	emaste, manu
Approved by:	emaste, manu
Differential Revision:	https://reviews.freebsd.org/D37933
2023-01-16 19:27:16 +01:00
Jean-Sébastien Pédron
ed53e350d7
linuxkpi: Define ioremap_cache()
It uses the `VM_MEMATTR_WRITE_BACK` flag on FreeBSD.

It replaces `ioremap_wb()` which doesn't exist in Linux. Perhaps it
existed in the past and was removed.

Reviewed by:	emaste, manu
Approved by:	emaste, manu
Differential Revision:	https://reviews.freebsd.org/D37916
2023-01-16 19:11:58 +01:00
Jean-Sébastien Pédron
3aa335d00a
linuxkpi: Add gfp_mask field to struct shrink_control
bz@ asked if the KBI breakage is a concern here. My answer was that this
is the first time in the DRM drivers in Linux 5.13 (the version I'm
working on) that this structure is initialized (as a variable local to
the function in this case), so it shouldn't be a problem for the DRM
drivers.

However, I can't speak for other drivers maintained outside of the src
tree.

Reviewed by:	emaste, manu
Approved by:	emaste, manu
Differential Revision:	https://reviews.freebsd.org/D37913
2023-01-16 19:11:58 +01:00
Jean-Sébastien Pédron
c0c1c599c0
linuxkpi: Define GFP_NOFS in linux/gfp.h
Reviewed by:	emaste, manu
Approved by:	emaste, manu
Differential Revision:	https://reviews.freebsd.org/D37910
2023-01-16 19:11:52 +01:00
Bjoern A. Zeeb
4b56afaf7b LinuxKPI: implement irq_get_msi_desc()
Add irq_get_msi_desc() as a wrapper around a PCI function which will
allocate a single cached value (see comment on struct) for the
msi_desc requested if it doesn't exist yet and handle freeing it
when the PCI device goes away.  We take the values from the ivars of
the native (FreeBSD) device.

While changing struct pci_dev also add the msi_cap field requested by
a wireless driver.

Bump __FreeBSD_version so these changes can be detected.

MFC after:	3 days
X-MFC: move fields to end of struct (alloc happens in linux_pci.c)
Reviewed by:	hselasky (earlier version)
Differential Revision: https://reviews.freebsd.org/D37523
2023-01-13 00:43:23 +00:00
Bjoern A. Zeeb
8f61992d7c LinuxKPI: pci: add [linuxkpi_]pci_get_device()
Add a version of pci_get_device() as linuxkpi_pci_get_device()
not (yet) supporting the last argument.
Due to conflicts we cannot redefine it as we would normally do
in LinuxKPI so drivers have to be adjusted.

MFC after:	3 days
Differential Revision: https://reviews.freebsd.org/D37593
2023-01-13 00:40:57 +00:00
Bjoern A. Zeeb
e9715b1c44 LinuxKPI: fix pci_alloc_irq_vectors() for MSI
pci_alloc_irq_vectors() is given a min and max vector value.
pci_enable_msi() will always succeed independent of these arguments as
it does not know about them.  Further it will only ever allocate
1 "vector" not supporting any other amount.
So upfront check that (a) the available pci_msi_count() can satisfy the
requested minv and (b) given the pci_enable_msi() hard coded limit check
that minv is not larger than 1.
If we cannot satisfy either requirement return an error.

This fixes problems with drivers which check that the returned value
of allocated "vectors" will match their requests and only otherwise try
to fall back to ask for 1 or deal otherwise.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
Reviewed by:	hselasky (earlier version)
Differential Revision: https://reviews.freebsd.org/D37522
2023-01-13 00:39:24 +00:00
Bjoern A. Zeeb
75388b9ca5 LinuxKPI: add (skeleton) functions to make drivers compile
Add more functions to netdevice.h (netif_napi_add_tx() being the only
one implemented) and add platform_device.h and netlink.h in order to
make driver code compile.
The skeleton functions are used only in very limited scope and not at
all in our usage so far but add (invasive) #ifdef if removed.
Add pr_debug() calls to each of them in order to log a TODO (if DEBUG
compiled in) and someone should hit them in the future.

MFC after:	3 days
Commented on by: hselasky (earlier version)
Differential Revision: https://reviews.freebsd.org/D37599
2023-01-13 00:38:11 +00:00
Bjoern A. Zeeb
f82cf28b31 LinuxKPI: add kstrtou32_from_user() and mac_pton()
While here:
- fix an argument of kstrtouint_from_user() to correct signedness.
- make kstrtou32() call kstrtouint() to avoid duplication (keep inline
  function)

Add kstrtou32_from_user() based on other examples in the file
making it a copy of the now fixed kstrtouint_from_user().

Also add a rudimentarily hacked up version of mac_pton() which is
leanient accepting non-well-formed input but so far only with ':'
separators.  It does not seem to obviously belong to any networking
header file so add it here.

Both new functions are needed for debugfs support for iwlwifi hence
coming together in one commit.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
Commented on by:	emaste
Differential Revision: https://reviews.freebsd.org/D37088
2023-01-13 00:34:32 +00:00
Bjoern A. Zeeb
51e94a4658 LinuxKPI: fix possible NULL dereference in linuxkpi_page_frag_alloc()
Fix a possible NULL pointer deref in case alloc_pages() fails.
This is theoretical so far as up to now no code in the tree uses
linuxkpi_page_frag_alloc().

Reported by:	Coverity via emaste
Coverity ID:	1502345
Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
X-MFC-with:	55038a6306
2023-01-11 23:40:05 +00:00
Val Packett
0b4531511e copyright: chase my name and email change
Reviewed by:	imp, emaste
Differential Revision:	https://reviews.freebsd.org/D37945
2023-01-06 15:28:42 -05:00
Jean-Sébastien Pédron
17f2b12a38
linuxkpi: Define lockdep_assert_none_held_once()
This is defined as a no-op even when INVARIANTS is defined. I admit I
don't know how to implement that in FreeBSD and didn't search
thoroughly.

Reviewed by:	bz
Approved by:	bz
Differential Revision:	https://reviews.freebsd.org/D37911
2023-01-02 22:07:31 +01:00
Jean-Sébastien Pédron
8dfb5571c4
linuxkpi: Include errno.h from acpi/video.h
This defines `ENODEV` used in this header. This fixes a build failure in
the DRM drivers.

Reviewed by:	bz
Approved by:	bz
Differential Revision:	https://reviews.freebsd.org/D37909
2023-01-02 22:05:27 +01:00
Bjoern A. Zeeb
4052b0e4b2 LinuxKPI: pm.h add pm_sleep_ptr and DEFINE_SIMPLE_DEV_PM_OPS
Extend pm.h by pm_sleep_ptr and DEFINE_SIMPLE_DEV_PM_OPS().
For the moment this duplicates some parts (as can be seen in the earlier
review I tried to simplify bits but given our implementation this
was easier in the end).

While here and cleanup the SIMPLE_DEV_PM_OPS() bits (white-space only).

MFC after:	3 days
Reviewed by:	hselasky
Differential Revision: https://reviews.freebsd.org/D37527
2022-12-31 02:51:09 +00:00
Bjoern A. Zeeb
55038a6306 LinuxKPI: add simplified vesion of page_frag_cache
For the moment and the currently only consumer (mt76) add a simplified
version of the page_frag_cache.  We will only accept fragement sizes up
to 1 PAGE_SIZE (KASSERT) and we will always return a full page.
Should we add more consumers or small (or large) objects would become a
problem we can always add a more elaborate version.

Discussed with:	markj
Reviewed by:	markj (,hselasky commented as well)
MFC after:	3 days
Differential Revision: https://reviews.freebsd.org/D37595
2022-12-31 02:45:44 +00:00
Bjoern A. Zeeb
4b0af11437 LinuxKPI: 802.11: move ieee80211_{unregister,restart}_hw out of header
Migrate the two functions from the header into the implementation file
in order to have access to more facilities and not to run into possible
allocation/locking/... problems in the future.

Sponsored by:	The FreeBSD Foundation
MFC after:	10 days
2022-12-31 02:24:23 +00:00
Bjoern A. Zeeb
c990500bf1 LinuxKPI; 802.11: update mac80211.h structures and fields
Cleanup some fields and structures and add new ones.

Sponsored by:	The FreeBSD Foundation
MFC after:	10 days
2022-12-31 02:15:28 +00:00
Bjoern A. Zeeb
3391199496 LinuxKPI: 802.11: implement ieee80211_get_hdrlen_from_skb()
Implement ieee80211_get_hdrlen_from_skb() doing basic sanity checks
on lengths (minimal length or skb data length vs. header length).

Sponsored by:	The FreeBSD Foundation
MFC after:	10 days
2022-12-31 02:02:01 +00:00
Bjoern A. Zeeb
13d87d92e4 LinuxKPI: 802.11: implement cfg80211_get_ies_channel_number()
Using the previous changes implement cfg80211_get_ies_channel_number()
either based on DSPARMS (or for the future HTINFO).

Sponsored by:	The FreeBSD Foundation
MFC after:	10 days
2022-12-31 01:59:20 +00:00
Bjoern A. Zeeb
5db817d864 LinuxKPI: 802.11: implement some *eleme/ie* lookup functions
Implement cfg80211_find_elem(), ieee80211_bss_get_elem(),
ieee80211_bss_get_ie(), and cfg80211_find_vendor_ie() with the last
one having a short cut always also checking oui_type in the pattern.

Sponsored by:	The FreeBSD Foundation
MFC after:	10 days
2022-12-31 01:33:28 +00:00
Bjoern A. Zeeb
5edde07c2a LinuxKPI: 802.11: implement cfg80211_{get,put}_bss
Implement cfg80211_{get,put}_bss currently doing malloc/free bits,
so hopefully the drivers get the calls right.

cfg80211_get_bss() sets up a lookup structure which may also take a
result (first hit wins) and calls ieee80211_scan_iterate() comparing
the various values in the iterator funcion.  Some of the checks are
partially pointless (as it seems the drivers are not interested in
these parts [ANY] but we keep them for documentation purposes should
futher values arise in the future).

We currently only iterate over the first VAP which will do for now.

Sponsored by:	The FreeBSD Foundation
MFC after:	10 days
2022-12-31 01:18:16 +00:00
Bjoern A. Zeeb
b6b352e4c7 LinuxKPI: 802.11: set sta supported legacy rates
When initializing the sta set the per-band supported legacy rates
as some drivers take the information from there.

Sponsored by:	The FreeBSD Foundation
MFC after:	10 days
2022-12-31 00:33:34 +00:00
Vladimir Kondratyev
68f08e26e2 LinuxKPI: linux/seqlock.h: Fix write_seqcount_(begin|end)
in seqcount_mutex_t case with removal of extraneous mutex lock/unlock
calls and addition of missing critical section.
While here strip one inline wrap layer to reduce code size.

Fixes startup lockup of i915kms after update to drm-kmod v5.12

Reviewed by:	hselasky, bz
MFC after:	1week
Differential Revision:	https://reviews.freebsd.org/D37699
2022-12-24 12:01:20 +03:00
Konstantin Belousov
140ceb5d95 ptrace(2): add PT_SC_REMOTE remote syscall request
Reviewed by:	markj
Discussed with:	jhb
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D37590
2022-12-22 23:11:35 +02:00
Konstantin Belousov
f081a291a1 compat32: move struct ptrace_sc_ret32 definition from .c to .h
Reviewed by:	markj
Sponsoreed by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D37590
2022-12-22 23:11:35 +02:00