Page MenuHomeFreeBSD

Update linuxkpi to Linux 4.11
AbandonedPublic

Authored by johalun0_gmail.com on Jan 22 2018, 4:28 PM.

Details

Summary

This patch updates sys/compat/linuxkpi/common to match Linux version 4.11.

Due to API changes in Linux 4.11 is not compatible with 4.9 so this can not be committed until drm-next-kmod also has been updated to 4.11. There is some memory bug that needs fixing for i915 and AMD/Radeon need more testing before drm-next-kmod 4.11 is ready for release.

This work was started before linuxkpi development moved from drm-next repo to HEAD so there might be something in this patch that re-introduce that has already been removed or changed. Reviewers that have been working on linuxkpi in HEAD lately should keep an extra eye open for that.

FreeBSD update is here (head branched around 2018-02-14):
https://github.com/FreeBSDDesktop/freebsd-base-graphics/tree/linuxkpi411

drm-next-kmod update is here:
https://github.com/FreeBSDDesktop/kms-drm/tree/linuxkpi411

gpu firmware update is here:
https://github.com/FreeBSDDesktop/kms-firmware/tree/linuxkpi411

No known bugs in linuxkpi common.

Known bugs in drm-next-kmod / linuxkpi gplv2:

  • [FIXED] Leaking drm_i915_gem_objects (try switching glxgears or something between window and fullscreen rapidly, check with vmstat -z)

WIPs

  • sync_file and anon_inode in linuxkpi_gplv2 is WIP and won't be used until 4.12 so no rush to perfect them yet.

Diff Detail

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

Event Timeline

sys/compat/linuxkpi/common/include/asm/atomic.h
162

I can't immediately see the purpose of this change.

196

Why add a default case? We definitely don't want to silently proceed there.

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

Style is to have a tab after a #define.

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

This is missing a license, and a lot of these includes look bogus.

22

Is this used?

sys/compat/linuxkpi/common/include/linux/device.h
184

Not sure what this is accomplishing.

sys/compat/linuxkpi/common/include/linux/gfp.h
57

Tab after #define.

sys/compat/linuxkpi/common/include/linux/hardirq.h
41 ↗(On Diff #38310)

This isn't right.

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

Missing license header.

sys/compat/linuxkpi/common/include/linux/mutex.h
142

Style: parens around return value.

sys/compat/linuxkpi/common/include/linux/pid.h
62

Presumably this should be curthread->td_proc->p_pid?

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

This clearly can't go in under the current copyright.

sys/compat/linuxkpi/common/include/linux/wait.h
100

Style is broken here.

sys/compat/linuxkpi/common/src/linux_radix.c
224 ↗(On Diff #38310)

Again, we can't just drop this code in...

sys/compat/linuxkpi/common/include/asm/atomic.h
162

There was a build error with the previous cmpxchg which is why I included this in the merge. I don't know who wrote it but assumed it fixed something.

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

Some files might have extra includes to match what is expected by the linux file using the api. The option would be to add includes to the linux files which later causes merge conflicts when updating to newer versions. I can clean it up so that we don't include more than we need.

22

Good catch. qstr was a placeholder, not needed anymore.

sys/compat/linuxkpi/common/include/linux/device.h
184

Fix a compile error

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

Yes, I meant to discuss around this. I guess we have a few options:

  1. Move the whole radix thing to gplv2 (unless there's something in base that depends on it)
  2. Move only the iterator part to gplv2 if that is an acceptable and possible thing to do
  3. Re-implement it to get rid of gpl

Done

  • Moved radix_tree_iter parts to gplv2 module in kms-drm repo
  • Cleaned up style
  • Fixed issues pointed out in comments

Enable / disable irq
Not sure if this is the right way to do it. Couldn't find any hints about how to temporary disable and enable irqs.

Hi,

Probably this patch should go in multiple smaller chunks to the FreeBSD-head branch. I don't have many objections, please look at my comments.

--HPS

sys/compat/linuxkpi/common/include/linux/device.h
184

I'd prefer if you fix the code causing the compile error instead of this macro.

sys/compat/linuxkpi/common/include/linux/interrupt.h
128

BSD-style: wrapping long line, starts 4-spaces in.

sys/compat/linuxkpi/common/include/linux/irqreturn.h
2

Is this code Submitted by LLN ?

32

strange indentation here.

sys/compat/linuxkpi/common/include/linux/kernel.h
92

TAB after #define

sys/compat/linuxkpi/common/include/linux/list.h
126

If there is a check for list_del_entry_valid() in Linux and it is there always, we need the similar piece here.

235

(pos)->member.next

sys/compat/linuxkpi/common/include/linux/lockdep.h
51
NOTE: The meaning of lock_held() in Linux might be different from the one in FreeBSD! Please carefully verify if this means:
  1. lock held by calling thread or
  2. lock held by any thread
54

TAB after #define

sys/compat/linuxkpi/common/include/linux/mm.h
124

why is the vma part of the vm_fault when also passed to the fault function?

sys/compat/linuxkpi/common/include/linux/pid.h
55

whitespace change?

sys/compat/linuxkpi/common/include/linux/printk.h
111

Please update macro below to handle this!

#define printk_ratelimited(...) ({
    int __retval;
     .... code ....
    __retval;
})
sys/compat/linuxkpi/common/include/linux/slab.h
69

TAB after #define and strange indentation.

sys/compat/linuxkpi/common/include/linux/wait.h
144

Are you sure this is right?

sys/compat/linuxkpi/common/src/linux_compat.c
548

Is it needed to change type of vmf.address ?

sys/compat/linuxkpi/common/src/linux_tasklet.c
203

This function doesn't do anything.

@hselasky
Thanks for the feedback! I will look at the issues. Please look at my replies to your comments.
The work was started before the split of linuxkpi so merging it back into the two different parts is somewhat messy...

sys/compat/linuxkpi/common/include/linux/device.h
184

That means patching Linux code which will in the future cause merge conflicts and other pains when updating... But fortunately it's not in many places so I'll do that.

sys/compat/linuxkpi/common/include/linux/mm.h
124

It's not anymore. See change in fault callback function.

sys/compat/linuxkpi/common/include/linux/wait.h
144

No. There are two versions, one where __ret is not set.. I can't tell which is newer. Did you write this piece?

sys/compat/linuxkpi/common/src/linux_compat.c
548

To match changes in Linux 4.11. If not, we have to patch drm drivers all over the place.

sys/compat/linuxkpi/common/src/linux_tasklet.c
203

Good catch! That could explain some of the bugs I'm seeing.

Fixed some comments. Will update the diff when the last one is fixed.
@hselasky please check my comments in list.h and wait.h.

sys/compat/linuxkpi/common/include/linux/irqreturn.h
2

It's written by me as LLNW employee.

sys/compat/linuxkpi/common/include/linux/list.h
126

It actually only does something if CONFIG_DEBUG_LIST is defined, otherwise returns true. We still need it?

johalun0_gmail.com added inline comments.
sys/compat/linuxkpi/common/include/linux/lockdep.h
51

Not needed since we don't enable CONFIG_LOCKDEP.

johalun0_gmail.com marked an inline comment as done.

Fix comments and various style fixes.

Simplify tasklet_enable function.

sys/compat/linuxkpi/common/include/asm/atomic.h
196

The CTASSERT() will take that one.

This revision is now accepted and ready to land.Feb 20 2018, 4:32 PM