Page MenuHomeFreeBSD

Update LinuxKPI to 4.15
AbandonedPublic

Authored by johalun0_gmail.com on May 16 2018, 3:16 PM.

Details

Reviewers
hselasky
Summary

Tested without issues on i915, amdgpu, radeonkms.

Issues/unknowns:

user_access_{begin|end} and copy_{to|from}_user
The previous implementation "default" is in linux/uaccess.h.
Machine dependent implementation is in include/asm/uaccess.h.

The machine version is missing __{get,put}_user_size() functions so disabled for now.

What the best solution for FreeBSD here? Do we need user_access_{begin|end} (stac() / clac())?
Is there any idea make implementation for __{get,put}_user_size() ?

{un}use_mm()
Located in linux/mmu_context.h.
I left this empty for now. Maybe someone with more insight can figure out what we need to do here?

TASK_KILLABLE and wait_event_killable()
COMMITTED!

Source tree here: https://github.com/FreeBSDDesktop/freebsd-base/tree/drm-v4.15

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Skipped
Unit
Unit Tests Skipped

Event Timeline

Added TASK_KILLABLE to TASK_NORMAL so that the assert don't cause panic in linux_add_to_sleepqueue().

Revert change to MPASS test in scheduler code.

sys/compat/linuxkpi/common/src/linux_idr.c
243

I think this "res = " should be after the "idx = " ?

johalun0_gmail.com added inline comments.
sys/compat/linuxkpi/common/src/linux_idr.c
243

Good catch! Fixed in my local branch.

sys/compat/linuxkpi/common/src/linux_idr.c
254

You might want to put after the if-checks, just before the NULL assignment.

sys/compat/linuxkpi/common/include/linux/radix-tree.h
58

Can you change the code not to add the "next_index" ?

Instead just increment the "iter->index" ?

sys/compat/linuxkpi/common/src/linux_idr.c
728

Is this one only used for debugging?

sys/compat/linuxkpi/common/src/linux_radix.c
114

this looks like a bug? ++index ?? See comments below.

170

iter->index++ ??

johalun0_gmail.com added inline comments.
sys/compat/linuxkpi/common/src/linux_idr.c
728

Is is only used directly by the function below, idr_is_empty.
idr_is_empty is used here
https://github.com/FreeBSDDesktop/kms-drm/blob/drm-v4.15/drivers/gpu/drm/drm_lease.c#L647
https://github.com/FreeBSDDesktop/kms-drm/blob/drm-v4.15/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c#L2911

drm_lease is actually not used currently because we lack something it needs but probably will be in the future

sys/compat/linuxkpi/common/src/linux_radix.c
114

Yes. I simplified the code as you suggested.

sys/compat/linuxkpi/common/include/linux/compiler.h
37

The commit comment says it is for 4.15, but this looks like 4.9.

johalun0_gmail.com added inline comments.
sys/compat/linuxkpi/common/include/linux/compiler.h
37

Yes but we need to keep 4.9 compatibility for things in the kernel still using the old KPI.
The external linuxkpi_gplv2 module will define this as 40015.

sys/compat/linuxkpi/common/include/linux/scatterlist.h
66

Can you use PAGE_SIZE here to derive the PAGE_MASK instead of PAGE_MASK? PAGE_MASK is redefined by the LinuxKPI and might make the code difficult to understand.

sys/compat/linuxkpi/common/include/linux/file.h
188

This function cannot be safely implemented under FreeBSD, because Linux use RCU to protect FD's while in FreeBSD we have a refcount. You need to use the existing fget() and don't forget to add a fput() call to release the refcount!
Please remove this #define

johalun0_gmail.com marked an inline comment as done.

Update since some parts have been committed to head.
Also,

  • Remove fcheck() macro, patch driver source code instead to use fget() and fput().
  • Derive PAGE_MASK from PAGE_SIZE since PAGE_MASK is different on FreeBSD and Linux
sys/compat/linuxkpi/common/src/linux_radix.c
170

This increment is done by the caller and should be removed!

Don't increment index in radix_tree_iter_delete

Some stuff has been committed so rebase against head.

Reminder to rebase this patch again.

sys/compat/linuxkpi/common/include/linux/export.h
1

This file lacks a Copright.

sys/compat/linuxkpi/common/include/linux/ww_mutex.h
49

Is this field used?

115

These chunks look just like re-ordered code? Can you remove them?

Add license and clean up some reorder diffs

johalun0_gmail.com added inline comments.
sys/compat/linuxkpi/common/include/linux/ww_mutex.h
49

Yes

sys/compat/linuxkpi/common/include/asm/uaccess.h
34

Is this code supposed to be used? Or just remove it?

sys/compat/linuxkpi/common/include/linux/mmu_context.h
1

This file also lacks a copyright.

I don't see why we need this in the LinuxKPI.

Can this file be part of the LGPLv2 LinuxKPI ?

9

This print should be under some debug check.

Please rebase patch and address comments.

sys/compat/linuxkpi/common/include/linux/ww_mutex.h
49

This field is only read. Who is setting it up? I think you should stub its usage in drm-next?

sys/compat/linuxkpi/common/include/linux/mmu_context.h
9

All these functions should do is:

MPASS(current->mm != NULL);

or

panic();

We don't support this functions.

johalun0_gmail.com added inline comments.
sys/compat/linuxkpi/common/include/asm/uaccess.h
34

I wanted to discuss about this.

user_access_{begin|end} are now empty implementation in linux/uaccess.h. is that ok or should we use stac()/clac()?

If the generic implementation in linux/uaccess.h is fine that we can delete this commented code.

sys/compat/linuxkpi/common/include/linux/mmu_context.h
9

This is one of the things I wanted to discuss about. Can we safely ignore these functions or we risk breaking something by doing nothing? They are used by i915 gvt and amdkfd code so currently not used but will be used when we port amdkfd. I can move to gplv2 for now.

sys/compat/linuxkpi/common/include/linux/ww_mutex.h
49

The usage is here: https://github.com/FreeBSDDesktop/kms-drm/blob/drm-v4.15/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c#L1587

However, I can not find where it's being set. Maybe that's a Linux internal thing? I can disable that check in the driver code.

sys/compat/linuxkpi/common/include/linux/mmu_context.h
9

current->mm is always set in FreeBSD. These functions can just do nothing for now.

sys/compat/linuxkpi/common/include/linux/ww_mutex.h
49

Yes, I believe that check should be disabled or replaced.

sys/compat/linuxkpi/common/include/asm/uaccess.h
34

From what I know there is no platform specific handling regarding user-memory access in the LinuxKPI.