From patchwork Sat Oct 12 18:56:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Umang Jain X-Patchwork-Id: 13833992 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C8FD3CF2567 for ; Sat, 12 Oct 2024 18:58:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=E2g6hR14DXkhUG0xgUvtbVOi6JTLRfBDXS/x/Sm4F/M=; b=SLpSRrD3/BiGcALiSZWH3+82pV aeA851IYTYwsFyBvAsEeYMsjp/HdCALznJ761dYMdvFIkS2rlwE3+NYagOpMHA2SWZOMNtJr1mxgc ZSbnEA0AcSSL47E83eVmQ/MaPBmXGTM4yFRglcHuumJAGq2t4+9ow5r05ksqZB28RtkqHPR2mS2FZ H4F7PyPdzq/WcjPBORnWfwADD+UJACkdTOC/3z8zQ+Ynlr3mwuF3xO94CMqQWSvI7qo5/j3rSUOHA dUAwBDU1nnw8b5Ya0ib5rwROSy/WJ99ZADZUpZGdU3fP15NRa0tqarlQ+W19DBslQMsThGUKKYyyP gLv+s46w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1szhK2-00000001gfG-0m38; Sat, 12 Oct 2024 18:58:38 +0000 Received: from perceval.ideasonboard.com ([213.167.242.64]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1szhIc-00000001gJk-2eYF; Sat, 12 Oct 2024 18:57:11 +0000 Received: from umang.jain (unknown [IPv6:2405:201:2015:f873:55d7:c02e:b2eb:ee3f]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 07C118BF; Sat, 12 Oct 2024 20:55:24 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1728759326; bh=HPzlE9sh1djReKfpWW1YtSaIElNq0n+B+WspYQFZr6Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mCsXDAGFGtc4HtyEZ4CoWFS85kG8lU/zUPaUdAD5YH4/7AgHbF7uzs3wUA+CS1vK7 oBf1/gbI4XS+YaXeGUmLSgw6hRYmMtUGI/mA29xJ47n08W/z5G7qBmFw+8iSTYbr45 EX8XP2Qlff81SbQ8mkK/veQ/An3YrjxxxijQYQw0= From: Umang Jain To: Greg Kroah-Hartman , Broadcom internal kernel review list Cc: linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org, Kieran Bingham , Dan Carpenter , Laurent Pinchart , kernel-list@raspberrypi.com, Stefan Wahren , Umang Jain Subject: [PATCH v3 1/6] staging: vchiq_core: Locally cache cache_line_size information Date: Sun, 13 Oct 2024 00:26:47 +0530 Message-ID: <20241012185652.316172-2-umang.jain@ideasonboard.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241012185652.316172-1-umang.jain@ideasonboard.com> References: <20241012185652.316172-1-umang.jain@ideasonboard.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241012_115710_816465_067E575D X-CRM114-Status: UNSURE ( 9.67 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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 Reviewed-by: Stefan Wahren --- .../interface/vchiq_arm/vchiq_core.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) 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 1e4b2978c186..e9b60dd8d419 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c @@ -1490,6 +1490,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) @@ -1638,10 +1639,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)) { @@ -1671,6 +1672,7 @@ free_pagelist(struct vchiq_instance *instance, struct vchiq_pagelist_info *pagel 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); @@ -1685,16 +1687,17 @@ free_pagelist(struct vchiq_instance *instance, struct vchiq_pagelist_info *pagel 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 + (pagelist->type - PAGELIST_READ_WITH_FRAGMENTS) * 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) @@ -1707,8 +1710,8 @@ free_pagelist(struct vchiq_instance *instance, struct vchiq_pagelist_info *pagel (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);