Skip to content

Commit bd2ac32

Browse files
committed
linux/ena: Fix compilation of UEK3/4
Background ---------- Commit [1] replaced the older representation of dma attributes from struct dma_attr to an unsigned long of flags. Commit [2] added dma_unmap_page_attr(), which receives dma attributes. Both of these commits are needed for the code to compile without any changes. Issue 1 ------- Compilation failure in UEK4 due to redefinition of page_ref_count(). Searched the uek git ([3]) and found that page_ref_count() was added in kernel version 4.1.12-124.43.1. Added the necessary ifdef conditions to kcompat to define page_ref_count() in UEK only for older kernels. Issue 2 ------- Compilation failure due to undefined dma_unmap_page_attrs() According to uek git [3]: 1. dma_unmap_page_attrs() was first introduced to UEK4 in kernel 4.1.12-105.0.0, with struct dma_attrs as type of attributes. 2. Commit [1] was never backported to UEK4. 3. UEK5 has kernel 4.14 [4] , which includes commits [1] and [2] and therefore doesn't need any kcpompat fixes for this issue. From the above 3 it follows that: 1. For kernels < 4.1.12-105.0.0 dma_unmap_page_attrs() needs to be defined in kcompat. 2. For 4.1.12-105.0.0 =< kernels in UEK4, kcompat needs to translate unsigned long attributes to struct dma_attrs to be used by dma_unmap_page_attrs(). For the upper kernel we use 4.1.13, since it is larger than all UEK4 kernels that are of the form 4.1.12-X.Y.Z 3. All other kernels need no fixes for dma_unmap_page_attrs() This commit implements the above conclusions. These kcompat fixes also fix the compilation of UEK3. [1]: torvalds/linux@00085f1 [2]: torvalds/linux@0495c3d [3]: https://github.com/oracle/linux-uek [4]: https://docs.oracle.com/en/operating-systems/uek/ Signed-off-by: Arthur Kiyanovski <[email protected]> Change-Id: I58427404f18b746f4ab56989ad25fdcff62a7d64
1 parent d95afdf commit bd2ac32

File tree

1 file changed

+27
-9
lines changed

1 file changed

+27
-9
lines changed

kernel/linux/ena/kcompat.h

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -848,17 +848,32 @@ static inline void netdev_rss_key_fill(void *buffer, size_t len)
848848

849849
#if ((LINUX_VERSION_CODE < KERNEL_VERSION(4, 6 ,0)) && \
850850
!(RHEL_RELEASE_CODE && RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(7,3)))
851-
/* Linux versions 4.4.216 - 4.5 (non inclusive) back propagated page_ref_count
852-
* function from kernel 4.6. To make things more difficult, Ubuntu didn't add
853-
* these changes to its 4.4.* kernels
851+
/* Linux versions 4.4.216 - 4.5 (non inclusive) back propagated
852+
* page_ref_count() from kernel 4.6.
853+
* Ubuntu didn't add these changes to its 4.4.* kernels.
854+
* UEK added this function in kernel 4.1.12-124.43.1
855+
* Here is a figure that shows all of the cases:
856+
* Legend:
857+
* -------- page_ref_count() is present in the kernel
858+
* ******** page_ref_count() is missing in the kernel
859+
*
860+
* Distro\Kernel 4.1.12-124.43.1 4.4.216 4.5 4.6
861+
* | | | |
862+
* Upstrem kernel ***********|**************|--------|******|
863+
* | | | |
864+
* Ubuntu ***********|**************|********|******|
865+
* | | | |
866+
* UEK ***********|--------------|--------|------|
854867
*/
855-
#if !(KERNEL_VERSION(4, 4 ,216) <= LINUX_VERSION_CODE && LINUX_VERSION_CODE < KERNEL_VERSION(4, 5 ,0)) ||\
856-
defined(UBUNTU_VERSION_CODE)
868+
#if (defined(IS_UEK) && !ENA_KERNEL_VERSION_GTE(4, 1, 12, 124, 43, 1)) || \
869+
(defined(ubuntu)) || \
870+
(!defined(IS_UEK) && !defined(ubuntu) && \
871+
!(KERNEL_VERSION(4, 4, 216) <= LINUX_VERSION_CODE && LINUX_VERSION_CODE < KERNEL_VERSION(4, 5, 0)))
857872
static inline int page_ref_count(struct page *page)
858873
{
859874
return atomic_read(&page->_count);
860875
}
861-
#endif /* !(KERNEL_VERSION(4, 4 ,216) <= LINUX_VERSION_CODE && LINUX_VERSION_CODE < KERNEL_VERSION(4, 5 ,0)) */
876+
#endif /* (defined(IS_UEK) && !ENA_KERNEL_VERSION_GTE(4, 1, 12, 124, 43, 1)) ... */
862877

863878
static inline void page_ref_inc(struct page *page)
864879
{
@@ -1089,7 +1104,8 @@ static inline void ena_netif_napi_add(struct net_device *dev,
10891104
}
10901105

10911106
#if (RHEL_RELEASE_CODE && (RHEL_RELEASE_CODE <= RHEL_RELEASE_VERSION(7, 4))) || \
1092-
(defined(UBUNTU_VERSION_CODE) && UBUNTU_VERSION_CODE < UBUNTU_VERSION(4, 5, 0, 0))
1107+
(defined(UBUNTU_VERSION_CODE) && UBUNTU_VERSION_CODE < UBUNTU_VERSION(4, 5, 0, 0)) || \
1108+
(defined(IS_UEK) && !ENA_KERNEL_VERSION_GTE(4, 1, 12, 105, 0, 0))
10931109
static inline void dma_unmap_page_attrs(struct device *dev,
10941110
dma_addr_t addr, size_t size,
10951111
enum dma_data_direction dir,
@@ -1107,7 +1123,8 @@ static inline void dma_unmap_page_attrs(struct device *dev,
11071123
#if (RHEL_RELEASE_CODE && (RHEL_RELEASE_CODE <= RHEL_RELEASE_VERSION(7, 9)) && \
11081124
(RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(7, 0)) && \
11091125
(LINUX_VERSION_CODE != KERNEL_VERSION(4, 14, 0))) || \
1110-
(defined(UBUNTU_VERSION_CODE) && UBUNTU_VERSION_CODE < UBUNTU_VERSION(4, 5, 0, 0))
1126+
(defined(UBUNTU_VERSION_CODE) && UBUNTU_VERSION_CODE < UBUNTU_VERSION(4, 5, 0, 0)) || \
1127+
(defined(IS_UEK) && LINUX_VERSION_CODE < KERNEL_VERSION(4, 1, 13))
11111128
#define ENA_DMA_ATTR_SKIP_CPU_SYNC (1 << DMA_ATTR_SKIP_CPU_SYNC)
11121129
#elif (RHEL_RELEASE_CODE && (RHEL_RELEASE_CODE <= RHEL_RELEASE_VERSION(6, 10)))
11131130
#define ENA_DMA_ATTR_SKIP_CPU_SYNC 0
@@ -1122,7 +1139,8 @@ static inline void ena_dma_unmap_page_attrs(struct device *dev,
11221139
{
11231140
#if (RHEL_RELEASE_CODE && (RHEL_RELEASE_CODE <= RHEL_RELEASE_VERSION(7, 9)) && \
11241141
(LINUX_VERSION_CODE != KERNEL_VERSION(4, 14, 0))) || \
1125-
(defined(UBUNTU_VERSION_CODE) && UBUNTU_VERSION_CODE < UBUNTU_VERSION(4, 5, 0, 0))
1142+
(defined(UBUNTU_VERSION_CODE) && UBUNTU_VERSION_CODE < UBUNTU_VERSION(4, 5, 0, 0)) || \
1143+
(defined(IS_UEK) && LINUX_VERSION_CODE < KERNEL_VERSION(4, 1, 13))
11261144
struct dma_attrs dma_attrs;
11271145

11281146
init_dma_attrs(&dma_attrs);

0 commit comments

Comments
 (0)