diff mbox series

[5/5] staging: vchiq_core: Locally cache cache_line_size information

Message ID 20241010102250.236545-6-umang.jain@ideasonboard.com (mailing list archive)
State New, archived
Headers show
Series staging: vchiq_core: Improve indentation | expand

Commit Message

Umang Jain Oct. 10, 2024, 10:22 a.m. UTC
Locally cache 'cache_line_size' information in a variable instead of
repeatedly accessing it from drv_mgmt->info. This helps to reflow lines
under 80 columns.

No functional change intended in this patch.

Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
---
 .../interface/vchiq_arm/vchiq_core.c          | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)

Comments

Stefan Wahren Oct. 10, 2024, 4:52 p.m. UTC | #1
Am 10.10.24 um 12:22 schrieb Umang Jain:
> Locally cache 'cache_line_size' information in a variable instead of
> repeatedly accessing it from drv_mgmt->info. This helps to reflow lines
> under 80 columns.
>
> No functional change intended in this patch.
>
> Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
> ---
Reviewed-by: Stefan Wahren <wahrenst@gmx.net>
Greg Kroah-Hartman Oct. 11, 2024, 4:39 a.m. UTC | #2
On Thu, Oct 10, 2024 at 03:52:49PM +0530, Umang Jain wrote:
> Locally cache 'cache_line_size' information in a variable instead of
> repeatedly accessing it from drv_mgmt->info. This helps to reflow lines
> under 80 columns.
> 
> No functional change intended in this patch.
> 
> Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>

As I didn't take all of the other patches in this series, this one
failed to apply :(

Please rebase and resend it, thanks.

greg k-h
diff mbox series

Patch

diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c
index d03b67f9cdb7..19c24dd9d1b3 100644
--- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c
+++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c
@@ -1516,6 +1516,7 @@  create_pagelist(struct vchiq_instance *instance, char *buf, char __user *ubuf,
 	size_t pagelist_size;
 	struct scatterlist *scatterlist, *sg;
 	int dma_buffers;
+	unsigned int cache_line_size;
 	dma_addr_t dma_addr;
 
 	if (count >= INT_MAX - PAGE_SIZE)
@@ -1666,10 +1667,10 @@  create_pagelist(struct vchiq_instance *instance, char *buf, char __user *ubuf,
 	}
 
 	/* Partial cache lines (fragments) require special measures */
+	cache_line_size = drv_mgmt->info->cache_line_size;
 	if ((type == PAGELIST_READ) &&
-	    ((pagelist->offset & (drv_mgmt->info->cache_line_size - 1)) ||
-	    ((pagelist->offset + pagelist->length) &
-	    (drv_mgmt->info->cache_line_size - 1)))) {
+	    ((pagelist->offset & (cache_line_size - 1)) ||
+	    ((pagelist->offset + pagelist->length) & (cache_line_size - 1)))) {
 		char *fragments;
 
 		if (down_interruptible(&drv_mgmt->free_fragments_sema)) {
@@ -1699,6 +1700,7 @@  free_pagelist(struct vchiq_instance *instance,
 	struct pagelist *pagelist = pagelistinfo->pagelist;
 	struct page **pages = pagelistinfo->pages;
 	unsigned int num_pages = pagelistinfo->num_pages;
+	unsigned int cache_line_size;
 
 	dev_dbg(instance->state->dev, "arm: %pK, %d\n",
 		pagelistinfo->pagelist, actual);
@@ -1714,6 +1716,7 @@  free_pagelist(struct vchiq_instance *instance,
 	pagelistinfo->scatterlist_mapped = 0;
 
 	/* Deal with any partial cache lines (fragments) */
+	cache_line_size = drv_mgmt->info->cache_line_size;
 	if (pagelist->type >= PAGELIST_READ_WITH_FRAGMENTS &&
 	    drv_mgmt->fragments_base) {
 		char *fragments = drv_mgmt->fragments_base +
@@ -1721,10 +1724,10 @@  free_pagelist(struct vchiq_instance *instance,
 			drv_mgmt->fragments_size;
 		int head_bytes, tail_bytes;
 
-		head_bytes = (drv_mgmt->info->cache_line_size - pagelist->offset) &
-			     (drv_mgmt->info->cache_line_size - 1);
+		head_bytes = (cache_line_size - pagelist->offset) &
+			     (cache_line_size - 1);
 		tail_bytes = (pagelist->offset + actual) &
-			     (drv_mgmt->info->cache_line_size - 1);
+			     (cache_line_size - 1);
 
 		if ((actual >= 0) && (head_bytes != 0)) {
 			if (head_bytes > actual)
@@ -1737,8 +1740,8 @@  free_pagelist(struct vchiq_instance *instance,
 		    (tail_bytes != 0))
 			memcpy_to_page(pages[num_pages - 1],
 				       (pagelist->offset + actual) &
-				       (PAGE_SIZE - 1) & ~(drv_mgmt->info->cache_line_size - 1),
-				       fragments + drv_mgmt->info->cache_line_size,
+				       (PAGE_SIZE - 1) & ~(cache_line_size - 1),
+				       fragments + cache_line_size,
 				       tail_bytes);
 
 		down(&drv_mgmt->free_fragments_mutex);