From patchwork Thu Oct 10 10:22:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Umang Jain X-Patchwork-Id: 13829931 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 79617CF11C6 for ; Thu, 10 Oct 2024 10:38:06 +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=W7My7ZvT/BeW7Atm53LhACgql0PTtXIvtgs69HQv3HU=; b=QZYmodoIbK3Ukhc2GS7/CYzjYI EwE/qAIRtve9K0EYqV97EpyFSd8syvx+4jiHKm6pcDAgJ2gox4rMvZuRsKGgq2oC+mJgbqsARc75w Y3l8GpEcg+XG8jepi5s+hEmXDf+0ZW4NsbbCGF2hf9SNC3HeYqVUhoZQHLGp17DWZgJ1TYbf9RBP0 n+3Kh5uqdnxVssDCtwsehsE4HGEGCcVjQ/C/GghqRs3N0rIdG7QMcJZ8SddWIn0Si3v+BBOYb/ZV5 wkPWcAA2jw3p0SSVNdpk/fA9eh17CCHmX9mj5qeCbzVjCqbq7EU3vE0QZ+zJBRNKIPPugdYpPtpGR CCCVds2g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1syqYN-0000000CQ7T-1vSn; Thu, 10 Oct 2024 10:37:55 +0000 Received: from perceval.ideasonboard.com ([213.167.242.64]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1syqKO-0000000CNN4-01Ka; Thu, 10 Oct 2024 10:23:29 +0000 Received: from umang.jain (unknown [IPv6:2405:201:2015:f873:55d7:c02e:b2eb:ee3f]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 5F06F1648; Thu, 10 Oct 2024 12:21:47 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1728555709; bh=s/1gGhbnt50tcEUMLNEZ7eg+4hprLgeErANYEfXxqho=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FhXyedf7uq/9gqlzV1eYj7ouAG0A7n/jKnsL2qcZJ0hTaRf7ld7GFB3P/+YjJfZYL KuN1W7kiWh5MU/eRpio4YTouFUY7nEK4I/EpAYTqoUS0NqSO0RYjyl0Cg8T/FkPc3U LJtWLgo2P4yoilFtgF1lJcF2eN0MNgxln15CPapg= 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 , Stefan Wahren , Laurent Pinchart , Umang Jain Subject: [PATCH 5/5] staging: vchiq_core: Locally cache cache_line_size information Date: Thu, 10 Oct 2024 15:52:49 +0530 Message-ID: <20241010102250.236545-6-umang.jain@ideasonboard.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241010102250.236545-1-umang.jain@ideasonboard.com> References: <20241010102250.236545-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-20241010_032328_236945_D6E7B7F6 X-CRM114-Status: UNSURE ( 9.64 ) 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 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);