From patchwork Tue Jun 23 16:42:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Saenz Julienne X-Patchwork-Id: 11621157 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 31CA160D for ; Tue, 23 Jun 2020 17:08:07 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 071A320706 for ; Tue, 23 Jun 2020 17:08:07 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="kDP0dfJs"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="KyAifUVQ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 071A320706 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=Sv4B0Z3jyvHzwud+1aN7LeQxS8QyGXYG+UYrK7EH+EY=; b=kDP0dfJs24fSH0WmmcivualXV d6wB2Gca9T/DbvHAkRMHd4n9wKAhlCSZn3XCv0dH7036MVeAa5e+wEBEPsCAZ+C84IBPDkiDZVbA7 TVlmVoHgqtOsrbTtdegfRHEqBednUHRrwNYS+7BYli+JUhMDg/PHDKgWI35k5dKl7vPxaItbPGYss Zm8hUFwF7x/8Lr/KtfyhTVWOa0k8BcPtI1958p/hki5a/p++BYXq4y6DL+WDQBG+0U78dZhkY2mdU +8q9+5Svv1vL2m4XhWSXoEmGUuxmhQvb/ro43StWrdBuh8OD6lIrm3Y9xyiFnu7DF7HHFuH0L4add 1NjzW0Dig==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jnmMh-0008IN-Tw; Tue, 23 Jun 2020 17:05:43 +0000 Received: from casper.infradead.org ([90.155.50.34]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jnm3J-0005YV-GY; Tue, 23 Jun 2020 16:45:41 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=Rd+6dW5HDDrUl1TiE4ebBdUbX9fm322L+unVUcaEcaI=; b=KyAifUVQeX7Uf5nHY9Dbr9ccDB Bh8eQsFdHFYfitTm/OotlMF68prCW8LFHp5HsolaZnk5q4FHB6o0wJeqHS4pduP+DEocmanrqTi6m jXOwCUcwEGcrL0E69NazcoiHTR8SRUZ3EYpxeKe2ghCRrU5hJU0oX25FEPXZXKPZvsPxDV1nWcx3t RDxJjZaQMoqEd1psniM8yQ8qjsdWHuSLsUo6VkkPskCf9wgD1SMC+7MjIAIM/Yhspv6H+oCr2B03J bLDxU8+1K1U6VjbXwL5coq7Ty0+vwSF+Xi0ahrApIEiUYHp0X6yMY7Y0onx0kP6/iFu04tou2qiFC ieW2jWxA==; Received: from mx2.suse.de ([195.135.220.15]) by casper.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jnm3C-0002u6-4n; Tue, 23 Jun 2020 16:45:40 +0000 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 1F319B066; Tue, 23 Jun 2020 16:45:33 +0000 (UTC) From: Nicolas Saenz Julienne To: gregkh@linuxfoundation.org Subject: [PATCH 45/50] staging: vchi: Move vchi_queue_kernel_message() into vchiq Date: Tue, 23 Jun 2020 18:42:31 +0200 Message-Id: <20200623164235.29566-46-nsaenzjulienne@suse.de> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200623164235.29566-1-nsaenzjulienne@suse.de> References: <20200623164235.29566-1-nsaenzjulienne@suse.de> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200623_174534_313864_9B154FE3 X-CRM114-Status: GOOD ( 15.33 ) X-Spam-Score: -4.2 (----) X-Spam-Report: SpamAssassin version 3.4.4 on casper.infradead.org summary: Content analysis details: (-4.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [195.135.220.15 listed in wl.mailspike.net] -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at https://www.dnswl.org/, medium trust [195.135.220.15 listed in list.dnswl.org] -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 RCVD_IN_MSPIKE_WL Mailspike good senders X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devel@driverdev.osuosl.org, kernel-list@raspberrypi.com, linux-kernel@vger.kernel.org, Nicolas Saenz Julienne , laurent.pinchart@ideasonboard.com, linux-arm-kernel@lists.infradead.org, linux-rpi-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org We can't really merge it with vchiq_queue_message() as it has internal users that will not benefit from the retry mechanism vchiq_queue_kernel_message() uses. So, for the sake of getting rid of vchi, move it into vchiq. Signed-off-by: Nicolas Saenz Julienne --- .../bcm2835-audio/bcm2835-vchiq.c | 8 +++---- .../vc04_services/interface/vchi/vchi.h | 4 ---- .../interface/vchiq_arm/vchiq_core.c | 23 ++++++++++++++++--- .../interface/vchiq_arm/vchiq_if.h | 4 ++-- .../interface/vchiq_arm/vchiq_shim.c | 22 ------------------ .../vc04_services/vchiq-mmal/mmal-vchiq.c | 14 +++++------ 6 files changed, 32 insertions(+), 43 deletions(-) diff --git a/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c b/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c index 28d64bc895cd..efaa2ae11f52 100644 --- a/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c +++ b/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c @@ -44,8 +44,8 @@ static int bcm2835_audio_send_msg_locked(struct bcm2835_audio_instance *instance init_completion(&instance->msg_avail_comp); } - status = vchi_queue_kernel_message(instance->service_handle, - m, sizeof(*m)); + status = vchiq_queue_kernel_message(instance->service_handle, + m, sizeof(*m)); if (status) { dev_err(instance->dev, "vchi message queue failed: %d, msg=%d\n", @@ -350,8 +350,8 @@ int bcm2835_audio_write(struct bcm2835_alsa_stream *alsa_stream, while (count > 0) { int bytes = min(instance->max_packet, count); - status = vchi_queue_kernel_message(instance->service_handle, - src, bytes); + status = vchiq_queue_kernel_message(instance->service_handle, + src, bytes); src += bytes; count -= bytes; } diff --git a/drivers/staging/vc04_services/interface/vchi/vchi.h b/drivers/staging/vc04_services/interface/vchi/vchi.h index c800796f9986..6de5df43cc29 100644 --- a/drivers/staging/vc04_services/interface/vchi/vchi.h +++ b/drivers/staging/vc04_services/interface/vchi/vchi.h @@ -37,10 +37,6 @@ extern int32_t vchi_service_use(unsigned handle); // Routine to decrement ref count on a named service extern int32_t vchi_service_release(unsigned handle); -/* Routine to send a message from kernel memory across a service */ -extern int vchi_queue_kernel_message(unsigned handle, void *data, - unsigned int size); - // Routine to look at a message in place. // The message is dequeued, so the caller is left holding it; the descriptor is // filled in and must be released when the user has finished with the message. 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 01a9331dbff4..ee11707b7476 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c @@ -3213,11 +3213,28 @@ vchiq_queue_message(unsigned int handle, return status; } -enum vchiq_status vchiq_queue_kernel_message(unsigned int handle, void *context, - size_t size) +int vchiq_queue_kernel_message(unsigned handle, void *data, unsigned size) { - return vchiq_queue_message(handle, memcpy_copy_callback, context, size); + enum vchiq_status status; + + while (1) { + status = vchiq_queue_message(handle, memcpy_copy_callback, + data, size); + + /* + * vchiq_queue_message() may return VCHIQ_RETRY, so we need to + * implement a retry mechanism since this function is supposed + * to block until queued + */ + if (status != VCHIQ_RETRY) + break; + + msleep(1); + } + + return status; } +EXPORT_SYMBOL(vchiq_queue_kernel_message); void vchiq_release_message(unsigned int handle, diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_if.h b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_if.h index 931debcd6492..6374eda4ea0c 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_if.h +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_if.h @@ -89,8 +89,8 @@ extern enum vchiq_status vchiq_open_service(struct vchiq_instance *instance, extern enum vchiq_status vchiq_close_service(unsigned int service); extern enum vchiq_status vchiq_use_service(unsigned int service); extern enum vchiq_status vchiq_release_service(unsigned int service); -extern enum vchiq_status vchiq_queue_kernel_message(unsigned int handle, - void *context, size_t size); +extern int vchiq_queue_kernel_message(unsigned handle, void *data, + unsigned size); extern void vchiq_msg_queue_push(unsigned handle, struct vchiq_header *header); extern void vchiq_release_message(unsigned int service, struct vchiq_header *header); diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c index 33493643b5f8..57ac6a289a08 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c @@ -9,28 +9,6 @@ #include "../vchi/vchi.h" #include "vchiq.h" -int vchi_queue_kernel_message(unsigned handle, void *data, unsigned int size) -{ - enum vchiq_status status; - - while (1) { - status = vchiq_queue_kernel_message(handle, data, size); - - /* - * vchiq_queue_message() may return VCHIQ_RETRY, so we need to - * implement a retry mechanism since this function is supposed - * to block until queued - */ - if (status != VCHIQ_RETRY) - break; - - msleep(1); - } - - return status; -} -EXPORT_SYMBOL(vchi_queue_kernel_message); - /*********************************************************** * Name: vchi_held_msg_release * diff --git a/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c b/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c index 34a1627754f3..4cb0fdcc6750 100644 --- a/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c +++ b/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c @@ -440,10 +440,9 @@ buffer_from_host(struct vchiq_mmal_instance *instance, vchi_service_use(instance->service_handle); - ret = vchi_queue_kernel_message(instance->service_handle, - &m, - sizeof(struct mmal_msg_header) + - sizeof(m.u.buffer_from_host)); + ret = vchiq_queue_kernel_message(instance->service_handle, &m, + sizeof(struct mmal_msg_header) + + sizeof(m.u.buffer_from_host)); vchi_service_release(instance->service_handle); @@ -681,10 +680,9 @@ static int send_synchronous_mmal_msg(struct vchiq_mmal_instance *instance, vchi_service_use(instance->service_handle); - ret = vchi_queue_kernel_message(instance->service_handle, - msg, - sizeof(struct mmal_msg_header) + - payload_len); + ret = vchiq_queue_kernel_message(instance->service_handle, msg, + sizeof(struct mmal_msg_header) + + payload_len); vchi_service_release(instance->service_handle);