Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug fixes and updates to common/driver #123

Merged
merged 9 commits into from
Mar 1, 2024
Merged

bug fixes and updates to common/driver #123

merged 9 commits into from
Mar 1, 2024

Conversation

ruck314
Copy link
Contributor

@ruck314 ruck314 commented Feb 24, 2024

Description

  • use readl() and writel() instead of ioread32() and iowrite32()
    • These changes replace the direct I/O access functions with the recommended memory-mapped I/O functions, improving portability and security within the kernel module.
  • Switching to kzalloc to automatically zero out the allocated memory can be beneficial for several reasons:
    • Security: Automatically zeroing memory can help prevent the unintentional leak of sensitive information from previously used memory blocks.
    • Stability: Initializing memory to zero can prevent bugs related to uninitialized memory usage.
    • Simplicity: Using kzalloc simplifies the code by combining allocation and initialization into a single operation, reducing the risk of forgetting to explicitly zero the memory.
  • changing GFP_DMA32 to GFP_DMA
    • Using GFP_DMA for DMA allocations in a kernel code that runs on a 32-bit system should not inherently cause an error just because of the flag's usage. The GFP_DMA flag is used to indicate that the allocated memory is DMA-able, and it's generally used for devices that require direct access to physical memory without going through the CPU's caching mechanisms. This flag is not specifically tied to 32-bit or 64-bit addressing; it's more about the requirements of the device and the DMA (Direct Memory Access) system.
  • remap_pfn_range() is deprecated in favor of functions like ioremap_pfn_range()
  • dma_map_single() being depreciated in future and switching to dma_alloc_coherent()
    • offers simplified management, potentially better performance, reduced fragmentation, and safer memory access for your DMA operations
  • replacing IOREMAP_NO_CACHE with ioremap_wc
    • This change adapts the code to be compliant with the new kernel requirements by using ioremap_wc for write-combining mappings, which is recommended for device memory mappings that do not require caching. This adjustment ensures that the driver remains functional and efficient under the updated kernel API.
    • The ioremap_wc() function was first introduced in the Linux kernel version 2.6.15, released on January 21, 2006.

These changes replace the direct I/O access functions with the recommended memory-mapped I/O functions, improving portability and security within the kernel module.
Using GFP_DMA for DMA allocations in a kernel code that runs on a 32-bit system should not inherently cause an error just because of the flag's usage. The GFP_DMA flag is used to indicate that the allocated memory is DMA-able, and it's generally used for devices that require direct access to physical memory without going through the CPU's caching mechanisms. This flag is not specifically tied to 32-bit or 64-bit addressing; it's more about the requirements of the device and the DMA (Direct Memory Access) system.
Base automatically changed from misc-code-clean-up to pre-release February 25, 2024 16:54
…oc_coherent()

offers simplified management, potentially better performance, reduced fragmentation, and safer memory access for your DMA operations
This change adapts the code to be compliant with the new kernel requirements by using ioremap_wc for write-combining mappings, which is recommended for device memory mappings that do not require caching. This adjustment ensures that the driver remains functional and efficient under the updated kernel API
@ruck314 ruck314 marked this pull request as ready for review February 28, 2024 02:59
@ruck314
Copy link
Contributor Author

ruck314 commented Feb 28, 2024

Confirmed this worked using DMA loopback firmware on the following Linux kernels:

  • 5.15.0-94-generic
  • 6.5.0-18-generic
  • 6.1.30-xilinx-v2023.2

@ruck314 ruck314 merged commit 678f21d into pre-release Mar 1, 2024
2 checks passed
@ruck314 ruck314 deleted the ESROGUE-661 branch March 1, 2024 02:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants