0

I am working with an embedded device which communicates with my PowerPC CPU via PCIe. Due to the SDK constraints i have to use linux kernel version 4.1.8. This version doesn't have functions related to cache operations in $KERNEL_SOURCE/arch/powerpc/include/asm/, such as:

  • "invalidate_dcache_range()"
  • "flush_dcache_range()"
  • "clean_dcache_range()"

(in this directory "cacheflush.h" header just contains declaration of mentioned functions.)
Also, my embedded device's SDK needs to call these functions to prepare DMA access.
Note that Kernel versions higher than 4.5 provide declaration of these functions.

Now i have some questions:

  1. I can use and copy functions which are implemented in newer kernels, in my old kernel and rebuild it, but modifying the kernel source doesn't make sense, right?
  2. Can you suggest some workaround to resolve it?
  3. How can i test that cache invalidated or flushed correctly? is there any way to read cache blocks in userspace?

Thanks,

1 Answer 1

0

This version doesn't have functions related to cache operations in $KERNEL_SOURCE/arch/powerpc/include/asm/, such as:

  • "invalidate_dcache_range()"
  • "flush_dcache_range()"
  • "clean_dcache_range()"

(in this directory "cacheflush.h" header just contains declaration of mentioned functions.)

Kernel version 4.1.8 has these functions - they are defined in arch/powerpc/kernel/misc_32.S, which is used only if CONFIG_WORD_SIZE is 32 (i.e. only on 32-bit platforms).

You will have to give more details about your platform.

  1. I can use and copy functions which are implemented in newer kernels, in my old kernel and rebuild it, but modifying the kernel source doesn't make sense, right?

It makes perfect sense to modify the kernel source, if you need to. Back porting some code seems like it might be a good reason ... but my feeling is that maybe you are missing something (in your platform's configuration perhaps?).

  1. Can you suggest some workaround to resolve it?

If your driver really does need these, and they aren't provided by the kernel for some reason, I would suggest you (re)implement the ones you need inside your driver code, rather than trying to patch the files in arch/powerpc/kernel/.

  1. How can i test that cache invalidated or flushed correctly? is there any way to read cache blocks in userspace?

Sorry, can't help you with this one - maybe you could use a JTAG debugger? Cheers!

Murray...

8
  • My processor is a PowerPC, 64-bit made by NXP model number T1022, but when i compiled the kernel, i didn't enable 64-bit in Kernel Configuration. and thanks for your suggestion. i think, i have to use misc_32.S. Commented Oct 23, 2019 at 6:30
  • You can't use misc_32.S - you have a 64 bit processor. When you configure your processor correctly in the config, it will set CONFIG_WORD_SIZE to 64 automatically. For some reason the set of cache management routines are different between 32 and 64 bit powerpc processors (see line 46 of this) - there must be a good reason so you should try to understand why and modify your driver accordingly, using the functions available to you - my guess is the driver was written for a 32 bit platform originally. Commented Oct 23, 2019 at 14:01
  • Yes, driver is written for 32-bit likewise embedded device processor. But in kernel configuration the CONFIG_WORD_SIZE is set 32. you mean that the misc_32.s functions cannot work correctly for 64 bit processor? Commented Oct 24, 2019 at 6:34
  • After a bit of digging, it turns out the NXP T1022 is a dual 64 bit e5500 and can run in either 64-bit mode or 32-bit mode. It can mix the modes as long as the kernel is running in 64-bit mode. From what you've said, you appear to be trying to run the kernel in 32-bit mode - but if this is the case, why can your driver not see the cache management functions in misc_32.S? In any case, it looks to me like you can't select the correct cpu type (Freescale e5500) without selecting CONFIG_PPC64, which sort of implies that CONFIG_WORD_SIZE should be 64. You need to get your config right! Commented Oct 24, 2019 at 15:02
  • The problem is that my driver cannot find the misc_32 functions when compiled using cmake. the misc_32.o object file exists in kernel build directory (arch/powerpc/kernel/), but when i compile the SDK, compiler says that Implicit declaration of functions. I tried out direct compiler using -I flag but it could not find the functions. Commented Oct 30, 2019 at 8:00

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.