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

Feat/intel dfl #5

Merged
merged 2 commits into from
Mar 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions prepare_source
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,5 @@ cp -r config "$dir/src/debian/"

rm "$dir/src/debian/patches/debian/Revert-docs-kernel_feat.py-fix-potential-command-inj.patch"
sed -i '/debian\/Revert-docs-kernel_feat\.py-fix-potential-command-inj\.patch/d' "$dir/src/debian/patches/series"

import_upstream_patches
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
From 15acf7e9d055c32ec1f87643340febb9ea2fa7e6 Mon Sep 17 00:00:00 2001
From: Peter Colberg <[email protected]>
Date: Mon, 19 Jun 2023 15:56:34 -0400
Subject: [PATCH] fpga: dfl: afu: use PFN_DOWN() and PFN_PHYS() helper macros

Replace all shifts by PAGE_SHIFT with PFN_DOWN() and PFN_PHYS() helper
macros to convert between physical addresses and page frame numbers.

These changes are cosmetic only; no functional changes.

Suggested-by: Andy Shevchenko <[email protected]>
Signed-off-by: Peter Colberg <[email protected]>
Reviewed-by: Andy Shevchenko <[email protected]>
---
drivers/fpga/dfl-afu-dma-region.c | 7 ++++---
drivers/fpga/dfl-afu-main.c | 5 +++--
2 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/drivers/fpga/dfl-afu-dma-region.c b/drivers/fpga/dfl-afu-dma-region.c
index 02b60fde0430..e8d54cfbb301 100644
--- a/drivers/fpga/dfl-afu-dma-region.c
+++ b/drivers/fpga/dfl-afu-dma-region.c
@@ -10,6 +10,7 @@
*/

#include <linux/dma-mapping.h>
+#include <linux/pfn.h>
#include <linux/sched/signal.h>
#include <linux/uaccess.h>
#include <linux/mm.h>
@@ -34,7 +35,7 @@ void afu_dma_region_init(struct dfl_feature_platform_data *pdata)
static int afu_dma_pin_pages(struct dfl_feature_platform_data *pdata,
struct dfl_afu_dma_region *region)
{
- int npages = region->length >> PAGE_SHIFT;
+ int npages = PFN_DOWN(region->length);
struct device *dev = &pdata->dev->dev;
int ret, pinned;

@@ -82,7 +83,7 @@ static int afu_dma_pin_pages(struct dfl_feature_platform_data *pdata,
static void afu_dma_unpin_pages(struct dfl_feature_platform_data *pdata,
struct dfl_afu_dma_region *region)
{
- long npages = region->length >> PAGE_SHIFT;
+ long npages = PFN_DOWN(region->length);
struct device *dev = &pdata->dev->dev;

unpin_user_pages(region->pages, npages);
@@ -101,7 +102,7 @@ static void afu_dma_unpin_pages(struct dfl_feature_platform_data *pdata,
*/
static bool afu_dma_check_continuous_pages(struct dfl_afu_dma_region *region)
{
- int npages = region->length >> PAGE_SHIFT;
+ int npages = PFN_DOWN(region->length);
int i;

for (i = 0; i < npages - 1; i++)
diff --git a/drivers/fpga/dfl-afu-main.c b/drivers/fpga/dfl-afu-main.c
index 7f621e96d3b8..048c9b418c8b 100644
--- a/drivers/fpga/dfl-afu-main.c
+++ b/drivers/fpga/dfl-afu-main.c
@@ -16,6 +16,7 @@

#include <linux/kernel.h>
#include <linux/module.h>
+#include <linux/pfn.h>
#include <linux/uaccess.h>
#include <linux/fpga-dfl.h>

@@ -816,7 +817,7 @@ static int afu_mmap(struct file *filp, struct vm_area_struct *vma)

pdata = dev_get_platdata(&pdev->dev);

- offset = vma->vm_pgoff << PAGE_SHIFT;
+ offset = PFN_PHYS(vma->vm_pgoff);
ret = afu_mmio_region_get_by_offset(pdata, offset, size, &region);
if (ret)
return ret;
@@ -837,7 +838,7 @@ static int afu_mmap(struct file *filp, struct vm_area_struct *vma)
vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);

return remap_pfn_range(vma, vma->vm_start,
- (region.phys + (offset - region.offset)) >> PAGE_SHIFT,
+ PFN_DOWN(region.phys + (offset - region.offset)),
size, vma->vm_page_prot);
}

Loading