This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

AM6548: Build Floating point driver - Linux Kernel v4.19

Part Number: AM6548


Hello Ti,
We are working on a custom platform based on the TI's AM6548 reference platform TMDX654GP EVM. The software is based upon the release from Texas instruments PROCESSOR-SDK-LINUX-AM65X  06_00_00_07(Linux kernel v4.19).
I have a driver code which consists of floating-point calculations. I looking for a method to build it in the kernel.
Is it possible to compile the code in the kernel?
If possible could you please suggest a method to do it?
Regards,
Johni
  • Hi Johni,

    When you mention driver is it a device driver or a user space driver? What is it getting used for?
    I want to understand the details before i can comment.

    Thanks,
    Keerthy

  • Hello Keerthy,
      We are attempting to control a BLDC motor from Linux. We have a device driver that performs open-loop control of the motor.
    Now, we are trying to implement field-oriented control to the motor. The FOC algorithm consists of floating-point calculations.
    As the algorithm expects real-time data(current and position values), we are planning to integrate it as part of the device driver so that we could avoid the delay.
    Please let me know your thoughts on this.
    Regards,
    Johni.
  • Hi Keerthy,
    Please let me know if you have any updates on this.
    Regards,
    Johni
  • Hi Johni,

    I do not see a good example of linux driver using float/double. I am checking with Linux experts
    and will get their feedback on that. So i will come back after couple of days.

    - Keerthy

  • Hi Johni,

    Here's the response from our expert. In summary it's easy and not right to enable floating operations in Linux kernel.

    For the current 64-bit kernel we don't know if there is a 'good' way to do this.

    The basic issue is kernel space typically doesn't maintain a floating point context. Often its only added to a user process in a lazy way so as to keep context switch costs down.  Only user processes who use floats pay the cost.  The mechanism to do the lazy usage typically has the float feature disabled until first use.  At first float use an exception happens where the kernel then allocates and assigns resources.

    For something in the kernel to use floats, it needs to save and restore any floating point context it touches.  It may have to enable and disable the unit. Further, some worry needs to be given to preemption of system code (kernel entities and interrupt handlers).  Even if a context were created for the kernel how would multiple interrupt handlers leveraged by different processes share this."

    As told earlier we do not recommend float usage in Linux kernel drivers. Hope you can close the issue

    Best regards,

    Keerthy