From nobody Fri Nov 29 12:47:08 2024 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D068D19E7E2 for ; Thu, 19 Sep 2024 14:21:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=213.167.242.64 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726755709; cv=none; b=A5abT3toQpgMG+fmY/BB0nXJ0T53ZUEGTSA1t+wqeBKdc6+zmB1JKQV9W3BQIuaT2DdDjGtkVALZZd/lHKw6uygSNVLFLHj33II5neggI+VblI1n/knMQlbb5lpsrdPI55k5SF+xlCKzvLqRG4F89yEZDCUd1hyX5Uwmo+k0pfE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726755709; c=relaxed/simple; bh=yalx1iY3oUr63A3ECojFRU4frdF6VGfKWcHOLLSVRb4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=gLR1E/MZsxGLLWB2AtvNbcGTXmSgVWiRT8j4TbyvtejZCCL6pMO38J1IRTNxqOaixIN0xY/FkSIb+LlW1DG/xwunqimXgcQfjkJietqn9O5w+JEhniPOpj6llh6SB6KlnJy29m7Q+4aEia0j1qP5KSsFU0O1e95iF4sSxUbPRdA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ideasonboard.com; spf=pass smtp.mailfrom=ideasonboard.com; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b=L9rbX6Hs; arc=none smtp.client-ip=213.167.242.64 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="L9rbX6Hs" Received: from umang.jain (unknown [IPv6:2405:201:2015:f873:55d7:c02e:b2eb:ee3f]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 9C80777F; Thu, 19 Sep 2024 16:20:20 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1726755622; bh=yalx1iY3oUr63A3ECojFRU4frdF6VGfKWcHOLLSVRb4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=L9rbX6HsQSCs5eTsBYl4j0x16yH8t/ltanwAqe673aZnUzC/KrhKefpr0gZivxdUB 6eIaYJYuAFJmNmmfx7ZuAv0cL2etOCnfXHB2chpi8UAK8XsbjSJqlSY+nqTfI47eyY P81RU6Ww4UaoCugAHu1cZTTwaNdZ3KfuLIwlS1Rs= 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 , Stefan Wahren , Umang Jain Subject: [PATCH 1/3] staging: vchiq_core: Move remote_event_signal() vchiq_core Date: Thu, 19 Sep 2024 19:51:28 +0530 Message-ID: <20240919142130.1331495-2-umang.jain@ideasonboard.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240919142130.1331495-1-umang.jain@ideasonboard.com> References: <20240919142130.1331495-1-umang.jain@ideasonboard.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The function remote_event_signal() is declared in vchiq_core.h while defined in vchiq_arm.c and used only in vchiq_core.c. Move the definition to vchiq_core.c as it is only used in this file. Also convert it to static and drop the function signature from vchiq_core.h header. BELL2 doorbell macro is also moved from vchiq_arm to vchiq_core as part of this change. No functional changes intended in this patch. Signed-off-by: Umang Jain Reviewed-by: Dan Carpenter --- .../interface/vchiq_arm/vchiq_arm.c | 19 ---------------- .../interface/vchiq_arm/vchiq_core.c | 22 +++++++++++++++++++ .../interface/vchiq_arm/vchiq_core.h | 2 -- 3 files changed, 22 insertions(+), 21 deletions(-) diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c = b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c index c44b4dc79c03..8e9a5c67a6de 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c @@ -48,7 +48,6 @@ #define VCHIQ_PLATFORM_FRAGMENTS_COUNT_IDX 1 =20 #define BELL0 0x00 -#define BELL2 0x08 =20 #define ARM_DS_ACTIVE BIT(2) =20 @@ -616,24 +615,6 @@ static struct vchiq_arm_state *vchiq_platform_get_arm_= state(struct vchiq_state * return (struct vchiq_arm_state *)state->platform_state; } =20 -void -remote_event_signal(struct vchiq_state *state, struct remote_event *event) -{ - struct vchiq_drv_mgmt *mgmt =3D dev_get_drvdata(state->dev); - - /* - * Ensure that all writes to shared data structures have completed - * before signalling the peer. - */ - wmb(); - - event->fired =3D 1; - - dsb(sy); /* data barrier operation */ - - if (event->armed) - writel(0, mgmt->regs + BELL2); /* trigger vc interrupt */ -} =20 int vchiq_prepare_bulk_data(struct vchiq_instance *instance, struct vchiq_bulk= *bulk, void *offset, 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 7ad43a3d1bab..88d510c6793a 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include @@ -61,6 +62,8 @@ #define MAKE_REMOTE_USE (VCHIQ_MSG_REMOTE_USE << TYPE_SHIFT) #define MAKE_REMOTE_USE_ACTIVE (VCHIQ_MSG_REMOTE_USE_ACTIVE << TYPE_SHIFT) =20 +#define BELL2 0x08 + /* Ensure the fields are wide enough */ static_assert(VCHIQ_MSG_SRCPORT(VCHIQ_MAKE_MSG(0, 0, VCHIQ_PORT_MAX)) =3D=3D 0); @@ -526,6 +529,25 @@ remote_event_wait(wait_queue_head_t *wq, struct remote= _event *event) return ret; } =20 +static void +remote_event_signal(struct vchiq_state *state, struct remote_event *event) +{ + struct vchiq_drv_mgmt *mgmt =3D dev_get_drvdata(state->dev); + + /* + * Ensure that all writes to shared data structures have completed + * before signalling the peer. + */ + wmb(); + + event->fired =3D 1; + + dsb(sy); /* data barrier operation */ + + if (event->armed) + writel(0, mgmt->regs + BELL2); /* trigger vc interrupt */ +} + /* * Acknowledge that the event has been signalled, and wake any waiters. Us= ually * called as a result of the doorbell being rung. diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h= b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h index 5bf543dfc9c7..32b0521aa036 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h @@ -534,8 +534,6 @@ int vchiq_prepare_bulk_data(struct vchiq_instance *inst= ance, struct vchiq_bulk * =20 void vchiq_complete_bulk(struct vchiq_instance *instance, struct vchiq_bul= k *bulk); =20 -void remote_event_signal(struct vchiq_state *state, struct remote_event *e= vent); - void vchiq_dump_platform_state(struct seq_file *f); =20 void vchiq_dump_platform_instances(struct vchiq_state *state, struct seq_f= ile *f); --=20 2.45.2 From nobody Fri Nov 29 12:47:08 2024 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0BCB019F49A for ; Thu, 19 Sep 2024 14:21:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=213.167.242.64 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726755712; cv=none; b=MbUawGZ7/VgR9ZbH7TlbrPocKShJJhXwZtArIEmAjnMCkCfpnHhWOSNQa7CzFNSh6vIi+G8T4zzZyAJIUbF2e6dBbNBNIMrgQyK0k4QRapLHMp45PifBJM3OsSfXMKF4ufPc76eP+ceguzBeKe4LIAYG0SFszYMjjSvdRclP1J0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726755712; c=relaxed/simple; bh=vXQfoi9V2PmzfXTkCro03EgekhTgkHwHVEyWHwje/qQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=StZSdIm99SB3q+5z0ySqaOE9T8YhBYnLc2HvvmZT4s9KJdiaDcamapg/wgq8PcP3RaqdLViqz4XVzbhpsspxUfx41Sm3YBucRR3eLoFr5RbMa2Xze4n0mLE9pGyYC9u1sp39gNgkcTF1O9/j1EHebQP+zADJ47ie2j5JtJxY7/Q= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ideasonboard.com; spf=pass smtp.mailfrom=ideasonboard.com; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b=t6gMqDiZ; arc=none smtp.client-ip=213.167.242.64 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="t6gMqDiZ" Received: from umang.jain (unknown [IPv6:2405:201:2015:f873:55d7:c02e:b2eb:ee3f]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 693AEC8E; Thu, 19 Sep 2024 16:20:22 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1726755624; bh=vXQfoi9V2PmzfXTkCro03EgekhTgkHwHVEyWHwje/qQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=t6gMqDiZl8XeyTYURO88bzPH9LwCOqqquVxg7gfZXXBh9PECL/KEgPLfbQLPfzM6a 7jyJKOnyFZ8xGdmbwPVkhBcQeChJI81Wm7m7ji9MGCbP+SwFx3uEWvTGx41DJTmhjA pRGumF8JHfxiRgfoamj1uAoBdC2HpOSKZMbuxS3o= 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 , Stefan Wahren , Umang Jain Subject: [PATCH 2/3] staging: vchiq_core: Move bulk data functions in vchiq_core Date: Thu, 19 Sep 2024 19:51:29 +0530 Message-ID: <20240919142130.1331495-3-umang.jain@ideasonboard.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240919142130.1331495-1-umang.jain@ideasonboard.com> References: <20240919142130.1331495-1-umang.jain@ideasonboard.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Bulk transfers core logic lives in vchiq_core.c, hence move all the preparatory bulk data allocation helpers to vchiq_core.c (from vchiq_arm). The discrepancy was noticed when vchiq_prepare_bulk_data() and vchiq_complete_bulk() are being used vchiq_core.c but are defined in vchiq_arm. Now that they are now confined to vchiq_core.c, they can be made static and their signatures from vchiq_core header can be dropped. vchiq_prepare_bulk_data() and vchiq_complete_bulk() depends on struct vchiq_pagelist_info, cleanup_pagelist(), free_pagelist() and create_pagelist() hence they are pulled in from vchiq_arm as well, as part of this commit. No functional changes intended in this patch. Signed-off-by: Umang Jain Reviewed-by: Dan Carpenter --- .../interface/vchiq_arm/vchiq_arm.c | 337 ------------------ .../interface/vchiq_arm/vchiq_core.c | 324 +++++++++++++++++ .../interface/vchiq_arm/vchiq_core.h | 19 +- 3 files changed, 338 insertions(+), 342 deletions(-) diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c = b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c index 8e9a5c67a6de..cc0b3f2506a4 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c @@ -14,7 +14,6 @@ #include #include #include -#include #include #include #include @@ -36,7 +35,6 @@ #include "vchiq_arm.h" #include "vchiq_bus.h" #include "vchiq_debugfs.h" -#include "vchiq_pagelist.h" =20 #define DEVICE_NAME "vchiq" =20 @@ -108,17 +106,6 @@ struct vchiq_arm_state { int first_connect; }; =20 -struct vchiq_pagelist_info { - struct pagelist *pagelist; - size_t pagelist_buffer_size; - dma_addr_t dma_addr; - enum dma_data_direction dma_dir; - unsigned int num_pages; - unsigned int pages_need_release; - struct page **pages; - struct scatterlist *scatterlist; - unsigned int scatterlist_mapped; -}; =20 static int vchiq_blocking_bulk_transfer(struct vchiq_instance *instance, unsigned int= handle, void *data, @@ -145,35 +132,6 @@ vchiq_doorbell_irq(int irq, void *dev_id) return ret; } =20 -static void -cleanup_pagelistinfo(struct vchiq_instance *instance, struct vchiq_pagelis= t_info *pagelistinfo) -{ - if (pagelistinfo->scatterlist_mapped) { - dma_unmap_sg(instance->state->dev, pagelistinfo->scatterlist, - pagelistinfo->num_pages, pagelistinfo->dma_dir); - } - - if (pagelistinfo->pages_need_release) - unpin_user_pages(pagelistinfo->pages, pagelistinfo->num_pages); - - dma_free_coherent(instance->state->dev, pagelistinfo->pagelist_buffer_siz= e, - pagelistinfo->pagelist, pagelistinfo->dma_addr); -} - -static inline bool -is_adjacent_block(u32 *addrs, dma_addr_t addr, unsigned int k) -{ - u32 tmp; - - if (!k) - return false; - - tmp =3D (addrs[k - 1] & PAGE_MASK) + - (((addrs[k - 1] & ~PAGE_MASK) + 1) << PAGE_SHIFT); - - return tmp =3D=3D (addr & PAGE_MASK); -} - /* * This function is called by the vchiq stack once it has been connected to * the videocore and clients can start to use the stack. @@ -224,270 +182,6 @@ void vchiq_add_connected_callback(struct vchiq_device= *device, void (*callback)( } EXPORT_SYMBOL(vchiq_add_connected_callback); =20 -/* There is a potential problem with partial cache lines (pages?) - * at the ends of the block when reading. If the CPU accessed anything in - * the same line (page?) then it may have pulled old data into the cache, - * obscuring the new data underneath. We can solve this by transferring the - * partial cache lines separately, and allowing the ARM to copy into the - * cached area. - */ - -static struct vchiq_pagelist_info * -create_pagelist(struct vchiq_instance *instance, char *buf, char __user *u= buf, - size_t count, unsigned short type) -{ - struct vchiq_drv_mgmt *drv_mgmt; - struct pagelist *pagelist; - struct vchiq_pagelist_info *pagelistinfo; - struct page **pages; - u32 *addrs; - unsigned int num_pages, offset, i, k; - int actual_pages; - size_t pagelist_size; - struct scatterlist *scatterlist, *sg; - int dma_buffers; - dma_addr_t dma_addr; - - if (count >=3D INT_MAX - PAGE_SIZE) - return NULL; - - drv_mgmt =3D dev_get_drvdata(instance->state->dev); - - if (buf) - offset =3D (uintptr_t)buf & (PAGE_SIZE - 1); - else - offset =3D (uintptr_t)ubuf & (PAGE_SIZE - 1); - num_pages =3D DIV_ROUND_UP(count + offset, PAGE_SIZE); - - if ((size_t)num_pages > (SIZE_MAX - sizeof(struct pagelist) - - sizeof(struct vchiq_pagelist_info)) / - (sizeof(u32) + sizeof(pages[0]) + - sizeof(struct scatterlist))) - return NULL; - - pagelist_size =3D sizeof(struct pagelist) + - (num_pages * sizeof(u32)) + - (num_pages * sizeof(pages[0]) + - (num_pages * sizeof(struct scatterlist))) + - sizeof(struct vchiq_pagelist_info); - - /* Allocate enough storage to hold the page pointers and the page - * list - */ - pagelist =3D dma_alloc_coherent(instance->state->dev, pagelist_size, &dma= _addr, - GFP_KERNEL); - - dev_dbg(instance->state->dev, "arm: %pK\n", pagelist); - - if (!pagelist) - return NULL; - - addrs =3D pagelist->addrs; - pages =3D (struct page **)(addrs + num_pages); - scatterlist =3D (struct scatterlist *)(pages + num_pages); - pagelistinfo =3D (struct vchiq_pagelist_info *) - (scatterlist + num_pages); - - pagelist->length =3D count; - pagelist->type =3D type; - pagelist->offset =3D offset; - - /* Populate the fields of the pagelistinfo structure */ - pagelistinfo->pagelist =3D pagelist; - pagelistinfo->pagelist_buffer_size =3D pagelist_size; - pagelistinfo->dma_addr =3D dma_addr; - pagelistinfo->dma_dir =3D (type =3D=3D PAGELIST_WRITE) ? - DMA_TO_DEVICE : DMA_FROM_DEVICE; - pagelistinfo->num_pages =3D num_pages; - pagelistinfo->pages_need_release =3D 0; - pagelistinfo->pages =3D pages; - pagelistinfo->scatterlist =3D scatterlist; - pagelistinfo->scatterlist_mapped =3D 0; - - if (buf) { - unsigned long length =3D count; - unsigned int off =3D offset; - - for (actual_pages =3D 0; actual_pages < num_pages; - actual_pages++) { - struct page *pg =3D - vmalloc_to_page((buf + - (actual_pages * PAGE_SIZE))); - size_t bytes =3D PAGE_SIZE - off; - - if (!pg) { - cleanup_pagelistinfo(instance, pagelistinfo); - return NULL; - } - - if (bytes > length) - bytes =3D length; - pages[actual_pages] =3D pg; - length -=3D bytes; - off =3D 0; - } - /* do not try and release vmalloc pages */ - } else { - actual_pages =3D pin_user_pages_fast((unsigned long)ubuf & PAGE_MASK, nu= m_pages, - type =3D=3D PAGELIST_READ, pages); - - if (actual_pages !=3D num_pages) { - dev_dbg(instance->state->dev, "arm: Only %d/%d pages locked\n", - actual_pages, num_pages); - - /* This is probably due to the process being killed */ - if (actual_pages > 0) - unpin_user_pages(pages, actual_pages); - cleanup_pagelistinfo(instance, pagelistinfo); - return NULL; - } - /* release user pages */ - pagelistinfo->pages_need_release =3D 1; - } - - /* - * Initialize the scatterlist so that the magic cookie - * is filled if debugging is enabled - */ - sg_init_table(scatterlist, num_pages); - /* Now set the pages for each scatterlist */ - for (i =3D 0; i < num_pages; i++) { - unsigned int len =3D PAGE_SIZE - offset; - - if (len > count) - len =3D count; - sg_set_page(scatterlist + i, pages[i], len, offset); - offset =3D 0; - count -=3D len; - } - - dma_buffers =3D dma_map_sg(instance->state->dev, - scatterlist, - num_pages, - pagelistinfo->dma_dir); - - if (dma_buffers =3D=3D 0) { - cleanup_pagelistinfo(instance, pagelistinfo); - return NULL; - } - - pagelistinfo->scatterlist_mapped =3D 1; - - /* Combine adjacent blocks for performance */ - k =3D 0; - for_each_sg(scatterlist, sg, dma_buffers, i) { - unsigned int len =3D sg_dma_len(sg); - dma_addr_t addr =3D sg_dma_address(sg); - - /* Note: addrs is the address + page_count - 1 - * The firmware expects blocks after the first to be page- - * aligned and a multiple of the page size - */ - WARN_ON(len =3D=3D 0); - WARN_ON(i && (i !=3D (dma_buffers - 1)) && (len & ~PAGE_MASK)); - WARN_ON(i && (addr & ~PAGE_MASK)); - if (is_adjacent_block(addrs, addr, k)) - addrs[k - 1] +=3D ((len + PAGE_SIZE - 1) >> PAGE_SHIFT); - else - addrs[k++] =3D (addr & PAGE_MASK) | - (((len + PAGE_SIZE - 1) >> PAGE_SHIFT) - 1); - } - - /* Partial cache lines (fragments) require special measures */ - if ((type =3D=3D PAGELIST_READ) && - ((pagelist->offset & (drv_mgmt->info->cache_line_size - 1)) || - ((pagelist->offset + pagelist->length) & - (drv_mgmt->info->cache_line_size - 1)))) { - char *fragments; - - if (down_interruptible(&drv_mgmt->free_fragments_sema)) { - cleanup_pagelistinfo(instance, pagelistinfo); - return NULL; - } - - WARN_ON(!drv_mgmt->free_fragments); - - down(&drv_mgmt->free_fragments_mutex); - fragments =3D drv_mgmt->free_fragments; - WARN_ON(!fragments); - drv_mgmt->free_fragments =3D *(char **)drv_mgmt->free_fragments; - up(&drv_mgmt->free_fragments_mutex); - pagelist->type =3D PAGELIST_READ_WITH_FRAGMENTS + - (fragments - drv_mgmt->fragments_base) / drv_mgmt->fragments_size; - } - - return pagelistinfo; -} - -static void -free_pagelist(struct vchiq_instance *instance, struct vchiq_pagelist_info = *pagelistinfo, - int actual) -{ - struct vchiq_drv_mgmt *drv_mgmt; - struct pagelist *pagelist =3D pagelistinfo->pagelist; - struct page **pages =3D pagelistinfo->pages; - unsigned int num_pages =3D pagelistinfo->num_pages; - - dev_dbg(instance->state->dev, "arm: %pK, %d\n", pagelistinfo->pagelist, a= ctual); - - drv_mgmt =3D dev_get_drvdata(instance->state->dev); - - /* - * NOTE: dma_unmap_sg must be called before the - * cpu can touch any of the data/pages. - */ - dma_unmap_sg(instance->state->dev, pagelistinfo->scatterlist, - pagelistinfo->num_pages, pagelistinfo->dma_dir); - pagelistinfo->scatterlist_mapped =3D 0; - - /* Deal with any partial cache lines (fragments) */ - if (pagelist->type >=3D PAGELIST_READ_WITH_FRAGMENTS && drv_mgmt->fragmen= ts_base) { - char *fragments =3D drv_mgmt->fragments_base + - (pagelist->type - PAGELIST_READ_WITH_FRAGMENTS) * - drv_mgmt->fragments_size; - int head_bytes, tail_bytes; - - head_bytes =3D (drv_mgmt->info->cache_line_size - pagelist->offset) & - (drv_mgmt->info->cache_line_size - 1); - tail_bytes =3D (pagelist->offset + actual) & - (drv_mgmt->info->cache_line_size - 1); - - if ((actual >=3D 0) && (head_bytes !=3D 0)) { - if (head_bytes > actual) - head_bytes =3D actual; - - memcpy_to_page(pages[0], - pagelist->offset, - fragments, - head_bytes); - } - if ((actual >=3D 0) && (head_bytes < actual) && - (tail_bytes !=3D 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, - tail_bytes); - - down(&drv_mgmt->free_fragments_mutex); - *(char **)fragments =3D drv_mgmt->free_fragments; - drv_mgmt->free_fragments =3D fragments; - up(&drv_mgmt->free_fragments_mutex); - up(&drv_mgmt->free_fragments_sema); - } - - /* Need to mark all the pages dirty. */ - if (pagelist->type !=3D PAGELIST_WRITE && - pagelistinfo->pages_need_release) { - unsigned int i; - - for (i =3D 0; i < num_pages; i++) - set_page_dirty(pages[i]); - } - - cleanup_pagelistinfo(instance, pagelistinfo); -} - static int vchiq_platform_init(struct platform_device *pdev, struct vchiq_= state *state) { struct device *dev =3D &pdev->dev; @@ -616,38 +310,7 @@ static struct vchiq_arm_state *vchiq_platform_get_arm_= state(struct vchiq_state * } =20 =20 -int -vchiq_prepare_bulk_data(struct vchiq_instance *instance, struct vchiq_bulk= *bulk, void *offset, - void __user *uoffset, int size, int dir) -{ - struct vchiq_pagelist_info *pagelistinfo; - - pagelistinfo =3D create_pagelist(instance, offset, uoffset, size, - (dir =3D=3D VCHIQ_BULK_RECEIVE) - ? PAGELIST_READ - : PAGELIST_WRITE); - - if (!pagelistinfo) - return -ENOMEM; - - bulk->data =3D pagelistinfo->dma_addr; - - /* - * Store the pagelistinfo address in remote_data, - * which isn't used by the slave. - */ - bulk->remote_data =3D pagelistinfo; =20 - return 0; -} - -void -vchiq_complete_bulk(struct vchiq_instance *instance, struct vchiq_bulk *bu= lk) -{ - if (bulk && bulk->remote_data && bulk->actual) - free_pagelist(instance, (struct vchiq_pagelist_info *)bulk->remote_data, - bulk->actual); -} =20 void vchiq_dump_platform_state(struct seq_file *f) { 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 88d510c6793a..586c41cd1ed5 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include @@ -1437,6 +1438,329 @@ poll_services(struct vchiq_state *state) poll_services_of_group(state, group); } =20 +static void +cleanup_pagelistinfo(struct vchiq_instance *instance, struct vchiq_pagelis= t_info *pagelistinfo) +{ + if (pagelistinfo->scatterlist_mapped) { + dma_unmap_sg(instance->state->dev, pagelistinfo->scatterlist, + pagelistinfo->num_pages, pagelistinfo->dma_dir); + } + + if (pagelistinfo->pages_need_release) + unpin_user_pages(pagelistinfo->pages, pagelistinfo->num_pages); + + dma_free_coherent(instance->state->dev, pagelistinfo->pagelist_buffer_siz= e, + pagelistinfo->pagelist, pagelistinfo->dma_addr); +} + +static inline bool +is_adjacent_block(u32 *addrs, dma_addr_t addr, unsigned int k) +{ + u32 tmp; + + if (!k) + return false; + + tmp =3D (addrs[k - 1] & PAGE_MASK) + + (((addrs[k - 1] & ~PAGE_MASK) + 1) << PAGE_SHIFT); + + return tmp =3D=3D (addr & PAGE_MASK); +} + +/* There is a potential problem with partial cache lines (pages?) + * at the ends of the block when reading. If the CPU accessed anything in + * the same line (page?) then it may have pulled old data into the cache, + * obscuring the new data underneath. We can solve this by transferring the + * partial cache lines separately, and allowing the ARM to copy into the + * cached area. + */ +static struct vchiq_pagelist_info * +create_pagelist(struct vchiq_instance *instance, char *buf, char __user *u= buf, + size_t count, unsigned short type) +{ + struct vchiq_drv_mgmt *drv_mgmt; + struct pagelist *pagelist; + struct vchiq_pagelist_info *pagelistinfo; + struct page **pages; + u32 *addrs; + unsigned int num_pages, offset, i, k; + int actual_pages; + size_t pagelist_size; + struct scatterlist *scatterlist, *sg; + int dma_buffers; + dma_addr_t dma_addr; + + if (count >=3D INT_MAX - PAGE_SIZE) + return NULL; + + drv_mgmt =3D dev_get_drvdata(instance->state->dev); + + if (buf) + offset =3D (uintptr_t)buf & (PAGE_SIZE - 1); + else + offset =3D (uintptr_t)ubuf & (PAGE_SIZE - 1); + num_pages =3D DIV_ROUND_UP(count + offset, PAGE_SIZE); + + if ((size_t)num_pages > (SIZE_MAX - sizeof(struct pagelist) - + sizeof(struct vchiq_pagelist_info)) / + (sizeof(u32) + sizeof(pages[0]) + + sizeof(struct scatterlist))) + return NULL; + + pagelist_size =3D sizeof(struct pagelist) + + (num_pages * sizeof(u32)) + + (num_pages * sizeof(pages[0]) + + (num_pages * sizeof(struct scatterlist))) + + sizeof(struct vchiq_pagelist_info); + + /* Allocate enough storage to hold the page pointers and the page + * list + */ + pagelist =3D dma_alloc_coherent(instance->state->dev, pagelist_size, &dma= _addr, + GFP_KERNEL); + + dev_dbg(instance->state->dev, "arm: %pK\n", pagelist); + + if (!pagelist) + return NULL; + + addrs =3D pagelist->addrs; + pages =3D (struct page **)(addrs + num_pages); + scatterlist =3D (struct scatterlist *)(pages + num_pages); + pagelistinfo =3D (struct vchiq_pagelist_info *) + (scatterlist + num_pages); + + pagelist->length =3D count; + pagelist->type =3D type; + pagelist->offset =3D offset; + + /* Populate the fields of the pagelistinfo structure */ + pagelistinfo->pagelist =3D pagelist; + pagelistinfo->pagelist_buffer_size =3D pagelist_size; + pagelistinfo->dma_addr =3D dma_addr; + pagelistinfo->dma_dir =3D (type =3D=3D PAGELIST_WRITE) ? + DMA_TO_DEVICE : DMA_FROM_DEVICE; + pagelistinfo->num_pages =3D num_pages; + pagelistinfo->pages_need_release =3D 0; + pagelistinfo->pages =3D pages; + pagelistinfo->scatterlist =3D scatterlist; + pagelistinfo->scatterlist_mapped =3D 0; + + if (buf) { + unsigned long length =3D count; + unsigned int off =3D offset; + + for (actual_pages =3D 0; actual_pages < num_pages; + actual_pages++) { + struct page *pg =3D + vmalloc_to_page((buf + + (actual_pages * PAGE_SIZE))); + size_t bytes =3D PAGE_SIZE - off; + + if (!pg) { + cleanup_pagelistinfo(instance, pagelistinfo); + return NULL; + } + + if (bytes > length) + bytes =3D length; + pages[actual_pages] =3D pg; + length -=3D bytes; + off =3D 0; + } + /* do not try and release vmalloc pages */ + } else { + actual_pages =3D pin_user_pages_fast((unsigned long)ubuf & PAGE_MASK, nu= m_pages, + type =3D=3D PAGELIST_READ, pages); + + if (actual_pages !=3D num_pages) { + dev_dbg(instance->state->dev, "arm: Only %d/%d pages locked\n", + actual_pages, num_pages); + + /* This is probably due to the process being killed */ + if (actual_pages > 0) + unpin_user_pages(pages, actual_pages); + cleanup_pagelistinfo(instance, pagelistinfo); + return NULL; + } + /* release user pages */ + pagelistinfo->pages_need_release =3D 1; + } + + /* + * Initialize the scatterlist so that the magic cookie + * is filled if debugging is enabled + */ + sg_init_table(scatterlist, num_pages); + /* Now set the pages for each scatterlist */ + for (i =3D 0; i < num_pages; i++) { + unsigned int len =3D PAGE_SIZE - offset; + + if (len > count) + len =3D count; + sg_set_page(scatterlist + i, pages[i], len, offset); + offset =3D 0; + count -=3D len; + } + + dma_buffers =3D dma_map_sg(instance->state->dev, + scatterlist, + num_pages, + pagelistinfo->dma_dir); + + if (dma_buffers =3D=3D 0) { + cleanup_pagelistinfo(instance, pagelistinfo); + return NULL; + } + + pagelistinfo->scatterlist_mapped =3D 1; + + /* Combine adjacent blocks for performance */ + k =3D 0; + for_each_sg(scatterlist, sg, dma_buffers, i) { + unsigned int len =3D sg_dma_len(sg); + dma_addr_t addr =3D sg_dma_address(sg); + + /* Note: addrs is the address + page_count - 1 + * The firmware expects blocks after the first to be page- + * aligned and a multiple of the page size + */ + WARN_ON(len =3D=3D 0); + WARN_ON(i && (i !=3D (dma_buffers - 1)) && (len & ~PAGE_MASK)); + WARN_ON(i && (addr & ~PAGE_MASK)); + if (is_adjacent_block(addrs, addr, k)) + addrs[k - 1] +=3D ((len + PAGE_SIZE - 1) >> PAGE_SHIFT); + else + addrs[k++] =3D (addr & PAGE_MASK) | + (((len + PAGE_SIZE - 1) >> PAGE_SHIFT) - 1); + } + + /* Partial cache lines (fragments) require special measures */ + if ((type =3D=3D PAGELIST_READ) && + ((pagelist->offset & (drv_mgmt->info->cache_line_size - 1)) || + ((pagelist->offset + pagelist->length) & + (drv_mgmt->info->cache_line_size - 1)))) { + char *fragments; + + if (down_interruptible(&drv_mgmt->free_fragments_sema)) { + cleanup_pagelistinfo(instance, pagelistinfo); + return NULL; + } + + WARN_ON(!drv_mgmt->free_fragments); + + down(&drv_mgmt->free_fragments_mutex); + fragments =3D drv_mgmt->free_fragments; + WARN_ON(!fragments); + drv_mgmt->free_fragments =3D *(char **)drv_mgmt->free_fragments; + up(&drv_mgmt->free_fragments_mutex); + pagelist->type =3D PAGELIST_READ_WITH_FRAGMENTS + + (fragments - drv_mgmt->fragments_base) / drv_mgmt->fragments_size; + } + + return pagelistinfo; +} + +static void +free_pagelist(struct vchiq_instance *instance, struct vchiq_pagelist_info = *pagelistinfo, + int actual) +{ + struct vchiq_drv_mgmt *drv_mgmt; + struct pagelist *pagelist =3D pagelistinfo->pagelist; + struct page **pages =3D pagelistinfo->pages; + unsigned int num_pages =3D pagelistinfo->num_pages; + + dev_dbg(instance->state->dev, "arm: %pK, %d\n", pagelistinfo->pagelist, a= ctual); + + drv_mgmt =3D dev_get_drvdata(instance->state->dev); + + /* + * NOTE: dma_unmap_sg must be called before the + * cpu can touch any of the data/pages. + */ + dma_unmap_sg(instance->state->dev, pagelistinfo->scatterlist, + pagelistinfo->num_pages, pagelistinfo->dma_dir); + pagelistinfo->scatterlist_mapped =3D 0; + + /* Deal with any partial cache lines (fragments) */ + if (pagelist->type >=3D PAGELIST_READ_WITH_FRAGMENTS && drv_mgmt->fragmen= ts_base) { + char *fragments =3D drv_mgmt->fragments_base + + (pagelist->type - PAGELIST_READ_WITH_FRAGMENTS) * + drv_mgmt->fragments_size; + int head_bytes, tail_bytes; + + head_bytes =3D (drv_mgmt->info->cache_line_size - pagelist->offset) & + (drv_mgmt->info->cache_line_size - 1); + tail_bytes =3D (pagelist->offset + actual) & + (drv_mgmt->info->cache_line_size - 1); + + if ((actual >=3D 0) && (head_bytes !=3D 0)) { + if (head_bytes > actual) + head_bytes =3D actual; + + memcpy_to_page(pages[0], pagelist->offset, + fragments, head_bytes); + } + if ((actual >=3D 0) && (head_bytes < actual) && + (tail_bytes !=3D 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, + tail_bytes); + + down(&drv_mgmt->free_fragments_mutex); + *(char **)fragments =3D drv_mgmt->free_fragments; + drv_mgmt->free_fragments =3D fragments; + up(&drv_mgmt->free_fragments_mutex); + up(&drv_mgmt->free_fragments_sema); + } + + /* Need to mark all the pages dirty. */ + if (pagelist->type !=3D PAGELIST_WRITE && + pagelistinfo->pages_need_release) { + unsigned int i; + + for (i =3D 0; i < num_pages; i++) + set_page_dirty(pages[i]); + } + + cleanup_pagelistinfo(instance, pagelistinfo); +} + +static int +vchiq_prepare_bulk_data(struct vchiq_instance *instance, struct vchiq_bulk= *bulk, void *offset, + void __user *uoffset, int size, int dir) +{ + struct vchiq_pagelist_info *pagelistinfo; + + pagelistinfo =3D create_pagelist(instance, offset, uoffset, size, + (dir =3D=3D VCHIQ_BULK_RECEIVE) + ? PAGELIST_READ + : PAGELIST_WRITE); + + if (!pagelistinfo) + return -ENOMEM; + + bulk->data =3D pagelistinfo->dma_addr; + + /* + * Store the pagelistinfo address in remote_data, + * which isn't used by the slave. + */ + bulk->remote_data =3D pagelistinfo; + + return 0; +} + +static void +vchiq_complete_bulk(struct vchiq_instance *instance, struct vchiq_bulk *bu= lk) +{ + if (bulk && bulk->remote_data && bulk->actual) + free_pagelist(instance, (struct vchiq_pagelist_info *)bulk->remote_data, + bulk->actual); +} + /* Called with the bulk_mutex held */ static void abort_outstanding_bulks(struct vchiq_service *service, diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h= b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h index 32b0521aa036..6662dd21e827 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h @@ -6,6 +6,7 @@ =20 #include #include +#include #include #include #include @@ -16,6 +17,7 @@ =20 #include "../../include/linux/raspberrypi/vchiq.h" #include "vchiq_cfg.h" +#include "vchiq_pagelist.h" =20 /* Do this so that we can test-build the code on non-rpi systems */ #if IS_ENABLED(CONFIG_RASPBERRYPI_FIRMWARE) @@ -409,6 +411,18 @@ struct vchiq_state { struct opaque_platform_state *platform_state; }; =20 +struct vchiq_pagelist_info { + struct pagelist *pagelist; + size_t pagelist_buffer_size; + dma_addr_t dma_addr; + enum dma_data_direction dma_dir; + unsigned int num_pages; + unsigned int pages_need_release; + struct page **pages; + struct scatterlist *scatterlist; + unsigned int scatterlist_mapped; +}; + static inline bool vchiq_remote_initialised(const struct vchiq_state *stat= e) { return state->remote && state->remote->initialised; @@ -529,11 +543,6 @@ vchiq_queue_message(struct vchiq_instance *instance, u= nsigned int handle, void *context, size_t size); =20 -int vchiq_prepare_bulk_data(struct vchiq_instance *instance, struct vchiq_= bulk *bulk, void *offset, - void __user *uoffset, int size, int dir); - -void vchiq_complete_bulk(struct vchiq_instance *instance, struct vchiq_bul= k *bulk); - void vchiq_dump_platform_state(struct seq_file *f); =20 void vchiq_dump_platform_instances(struct vchiq_state *state, struct seq_f= ile *f); --=20 2.45.2 From nobody Fri Nov 29 12:47:08 2024 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 486D21A00EE for ; Thu, 19 Sep 2024 14:21:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=213.167.242.64 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726755712; cv=none; b=glAZA7FspW1SaxLtnW6HtYPNk745ciZsiVegB5d/tpJOwOZTGue4RqSLtcW5LuGOxIM4PnfG4G/waa0tqxgyF+JV8oDrRKaeR61gIBf2WrZ8KNZBS9NXE2uzjNLlkv56JfImf+EaZnFOqsMd8pINOeFNaIaPSkXuxcLxBOy1zS4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726755712; c=relaxed/simple; bh=+G1ALUjL+2EMlZ/KTTRa4nLLszzAdAcmC+aiCIRahjg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=BbEg/fyYY797w+Lv5YAkytR+cPN+r5O6SfNXhKkRxeBekevYmV/D9ZpdryHzNKmPgZts6D3OOnKUALRE/P3HYQVb/bPfsx5lcaMGAcAB9DrQFzB+DPG1nlY2hU/kR8KMbjgwmKHnpmSG6wFRbi5kIl2Dd5RLal+E1xJKS3TKcGU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ideasonboard.com; spf=pass smtp.mailfrom=ideasonboard.com; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b=lCPwC6O7; arc=none smtp.client-ip=213.167.242.64 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="lCPwC6O7" Received: from umang.jain (unknown [IPv6:2405:201:2015:f873:55d7:c02e:b2eb:ee3f]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 57076FF6; Thu, 19 Sep 2024 16:20:24 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1726755625; bh=+G1ALUjL+2EMlZ/KTTRa4nLLszzAdAcmC+aiCIRahjg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lCPwC6O79Dn3Zym20FK7+k1qE0vlzxuiNYt8sjl/ePObMZCVGIzEdHpYghik0oV8W h/vRnBqrFFyZSmkvv1gWtFm6Mn1woScpk2P9UuNZxv1/UMbCW77qbBbqNQeAtv2M5W 5TWSgDBvLsjTCNWep/4i5KDKEHUj1igoGH1ESNro= 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 , Stefan Wahren , Umang Jain Subject: [PATCH 3/3] staging: vchiq_core: Drop vchiq_pagelist.h Date: Thu, 19 Sep 2024 19:51:30 +0530 Message-ID: <20240919142130.1331495-4-umang.jain@ideasonboard.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240919142130.1331495-1-umang.jain@ideasonboard.com> References: <20240919142130.1331495-1-umang.jain@ideasonboard.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" vchiq_pagelist.h only defines one struct and a couple of macros. It can be merged with vchiq_core since all the pagelist related function helpers are now in vchiq_core for bulk transfers. Move the struct and related macros to vchiq_core header and drop vchiq_pagelist.h. Signed-off-by: Umang Jain Reviewed-by: Dan Carpenter --- .../interface/vchiq_arm/vchiq_core.c | 4 ++++ .../interface/vchiq_arm/vchiq_core.h | 11 +++++++++- .../interface/vchiq_arm/vchiq_pagelist.h | 21 ------------------- 3 files changed, 14 insertions(+), 22 deletions(-) delete mode 100644 drivers/staging/vc04_services/interface/vchiq_arm/vchiq= _pagelist.h 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 586c41cd1ed5..1281f3bc5548 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c @@ -63,6 +63,10 @@ #define MAKE_REMOTE_USE (VCHIQ_MSG_REMOTE_USE << TYPE_SHIFT) #define MAKE_REMOTE_USE_ACTIVE (VCHIQ_MSG_REMOTE_USE_ACTIVE << TYPE_SHIFT) =20 +#define PAGELIST_WRITE 0 +#define PAGELIST_READ 1 +#define PAGELIST_READ_WITH_FRAGMENTS 2 + #define BELL2 0x08 =20 /* Ensure the fields are wide enough */ diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h= b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h index 6662dd21e827..400472f1aa06 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h @@ -17,7 +17,6 @@ =20 #include "../../include/linux/raspberrypi/vchiq.h" #include "vchiq_cfg.h" -#include "vchiq_pagelist.h" =20 /* Do this so that we can test-build the code on non-rpi systems */ #if IS_ENABLED(CONFIG_RASPBERRYPI_FIRMWARE) @@ -411,6 +410,16 @@ struct vchiq_state { struct opaque_platform_state *platform_state; }; =20 +struct pagelist { + u32 length; + u16 type; + u16 offset; + u32 addrs[1]; /* N.B. 12 LSBs hold the number + * of following pages at consecutive + * addresses. + */ +}; + struct vchiq_pagelist_info { struct pagelist *pagelist; size_t pagelist_buffer_size; diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_pageli= st.h b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_pagelist.h deleted file mode 100644 index ebd12bfabb63..000000000000 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_pagelist.h +++ /dev/null @@ -1,21 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ -/* Copyright (c) 2010-2012 Broadcom. All rights reserved. */ - -#ifndef VCHIQ_PAGELIST_H -#define VCHIQ_PAGELIST_H - -#define PAGELIST_WRITE 0 -#define PAGELIST_READ 1 -#define PAGELIST_READ_WITH_FRAGMENTS 2 - -struct pagelist { - u32 length; - u16 type; - u16 offset; - u32 addrs[1]; /* N.B. 12 LSBs hold the number - * of following pages at consecutive - * addresses. - */ -}; - -#endif /* VCHIQ_PAGELIST_H */ --=20 2.45.2