From patchwork Wed Jul 21 16:20:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ojaswin Mujoo X-Patchwork-Id: 12391587 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A109EC12002 for ; Wed, 21 Jul 2021 16:23:55 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 604D860FE9 for ; Wed, 21 Jul 2021 16:23:55 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 604D860FE9 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=RVUtonb2KaP+f+HRrEuLkTq5b0KQ8CcV6NijGEmeWaY=; b=t+tCT5y2+Ze/H6 ui0DLtIL7GCAwtrxK17olJfyOUWz+/ADcOx8g+Rig2FzodFLmvNhMH8ovHkeeSqur1/oztg0C1geY m13jMn7sfhPSOlKiSO3npnS8mx6JH46m+U27zOan8RmTtMtUxOq9tUJhh0O3KwGFD2BGrHnglIugl KgbTy6SUdadGF1Pqp9PsBK5DUdEEFC5vUhxtU7xf0XEwZuo0kw9muDMdL/1djJZ/WYRs/P4ihDs/A xGXrC7lcjcRsXQU0D7GuJiU+YNEdEywqnQjiDhoU99E0N1/MFvdXeRR1LNTb3m+rVjf5lPpGgAfcw PAgWSLTpg1PzqkXCmW0w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1m6Eyv-00GX7i-B2; Wed, 21 Jul 2021 16:22:01 +0000 Received: from mail-pl1-x636.google.com ([2607:f8b0:4864:20::636]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1m6Eyc-00GWyi-Lj for linux-arm-kernel@lists.infradead.org; Wed, 21 Jul 2021 16:21:44 +0000 Received: by mail-pl1-x636.google.com with SMTP id c15so1191811pls.13 for ; Wed, 21 Jul 2021 09:21:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=By1I86ZOhnAYxBe4OcTi1BPRS1LKy0lQmzeoiW7UDbQ=; b=T4kHSH3+jq39ObcjeNlWPzmVoGR+D+VTIIrXWHB7Sah12yGeVeXP1FM3oeZKiyfz03 vc6A3O1CYPQnqAj9XjmwvWwq0n2MLf9vi/diZG6Br8xlX6kfbR0QBgQvR3m+EJqN471P NxQgqes9ki8vdL/zFPLopCHwyN94kR01Az6WxCgPa/lU33qKBvjUcE6qkJCXlS36Q/nE XAJKrIfSFi5cWiLoJu74/uP0rUzJ6j54GrL/CG1f/OP0GG0ukBxvfVVewfLS1Adgvhzd sB+x+ovuoAPQppMI5XOhYhqFnWgboopcQVIiroMrml+Oju8r5hfZ3BpGvtCQwp5L0aOa synQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=By1I86ZOhnAYxBe4OcTi1BPRS1LKy0lQmzeoiW7UDbQ=; b=jT3cSvRE1yTghHF6uU9M0PHzEe6Y1TzxFxpwLNx2oB37s2OjcHUOU3+kuhZo6gPNCn 0OmOown9w+05J2xZ5310iDooCG4aikshnFhhtNL4E0osp9rnNWX9+szq59+JCSORZgNl P+Ii9IDJ2Ydr/TOFNNfZzFGJ3BWOem273dl095ZteuLuolwoYfIp8uXIQ7gtSsRXNsny 09Zt6uxUBF1Dy+NSRQosqqLQ+BxXODyvxIrbDIUr9cwy9eNJLcA9pHipq9q4uNWx7Oxv 67Z032PsylHMG9mAo0KUZzjLqSj2T++O2rGV1Dw5Z3CMrYzfYsqsGc943Y0NCxt7hjE2 nWSQ== X-Gm-Message-State: AOAM530KIrlNFurJRmWCkeOaUL9jfDTSgBMK7ESxRSlehQHD4Kr4iAb4 EuiGRojyc+qxIMSpj0Izz9s= X-Google-Smtp-Source: ABdhPJwipnZah8O9YpelmeBDYoqwrcdespn71Gdrhyo9/A6hlvHvBqzBBfLciEp4sxmp3b2nPaIo8w== X-Received: by 2002:a17:90b:128a:: with SMTP id fw10mr36011752pjb.116.1626884501565; Wed, 21 Jul 2021 09:21:41 -0700 (PDT) Received: from localhost.localdomain ([122.161.48.33]) by smtp.googlemail.com with ESMTPSA id s21sm3013459pfw.69.2021.07.21.09.21.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Jul 2021 09:21:41 -0700 (PDT) From: Ojaswin Mujoo To: nsaenz@kernel.org Cc: Ojaswin Mujoo , gregkh@linuxfoundation.org, stefan.wahren@i2se.com, dan.carpenter@oracle.com, phil@raspberrypi.com, linux-arm-kernel@lists.infradead.org, linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [PATCH v4 2/5] staging: vchiq: Move certain declarations to vchiq_arm.h Date: Wed, 21 Jul 2021 21:50:50 +0530 Message-Id: <8abcbd9fb3227e2a78ccc4a1186c8c0801061a68.1626882325.git.ojaswin98@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210721_092142_779775_FFFF6199 X-CRM114-Status: GOOD ( 18.21 ) 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 Move certain declarations from vchiq_arm.c to vchiq_arm.h to allow code sharing. This will be useful when we eventually separate the vchiq char driver code from platform code, into its own file. Signed-off-by: Ojaswin Mujoo --- .../interface/vchiq_arm/vchiq_arm.c | 68 ++--------------- .../interface/vchiq_arm/vchiq_arm.h | 73 +++++++++++++++++++ 2 files changed, 79 insertions(+), 62 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 3a0724fe25ea..3152466086f3 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c @@ -38,12 +38,6 @@ #undef MODULE_PARAM_PREFIX #define MODULE_PARAM_PREFIX DEVICE_NAME "." -/* Some per-instance constants */ -#define MAX_COMPLETIONS 128 -#define MAX_SERVICES 64 -#define MAX_ELEMENTS 8 -#define MSG_QUEUE_SIZE 128 - #define KEEPALIVE_VER 1 #define KEEPALIVE_VER_MIN KEEPALIVE_VER @@ -51,62 +45,12 @@ int vchiq_arm_log_level = VCHIQ_LOG_DEFAULT; int vchiq_susp_log_level = VCHIQ_LOG_ERROR; -struct user_service { - struct vchiq_service *service; - void __user *userdata; - struct vchiq_instance *instance; - char is_vchi; - char dequeue_pending; - char close_pending; - int message_available_pos; - int msg_insert; - int msg_remove; - struct completion insert_event; - struct completion remove_event; - struct completion close_event; - struct vchiq_header *msg_queue[MSG_QUEUE_SIZE]; -}; - -struct bulk_waiter_node { - struct bulk_waiter bulk_waiter; - int pid; - struct list_head list; -}; - -struct vchiq_instance { - struct vchiq_state *state; - struct vchiq_completion_data_kernel completions[MAX_COMPLETIONS]; - int completion_insert; - int completion_remove; - struct completion insert_event; - struct completion remove_event; - struct mutex completion_mutex; - - int connected; - int closing; - int pid; - int mark; - int use_close_delivered; - int trace; - - struct list_head bulk_waiter_list; - struct mutex bulk_waiter_list_mutex; - - struct vchiq_debugfs_node debugfs_node; -}; - -struct dump_context { - char __user *buf; - size_t actual; - size_t space; - loff_t offset; -}; +DEFINE_SPINLOCK(msg_queue_spinlock); +struct vchiq_state g_state; static struct cdev vchiq_cdev; static dev_t vchiq_devid; -static struct vchiq_state g_state; static struct class *vchiq_class; -static DEFINE_SPINLOCK(msg_queue_spinlock); static struct platform_device *bcm2835_camera; static struct platform_device *bcm2835_audio; @@ -199,7 +143,7 @@ int vchiq_initialise(struct vchiq_instance **instance_out) } EXPORT_SYMBOL(vchiq_initialise); -static void free_bulk_waiter(struct vchiq_instance *instance) +void free_bulk_waiter(struct vchiq_instance *instance) { struct bulk_waiter_node *waiter, *next; @@ -561,7 +505,7 @@ add_completion(struct vchiq_instance *instance, enum vchiq_reason reason, return VCHIQ_SUCCESS; } -static enum vchiq_status +enum vchiq_status service_callback(enum vchiq_reason reason, struct vchiq_header *header, unsigned int handle, void *bulk_userdata) { @@ -2142,7 +2086,7 @@ vchiq_fops = { * * Returns 0 on success else returns the error code. */ -static int vchiq_register_chrdev(struct device *parent) +int vchiq_register_chrdev(struct device *parent) { struct device *vchiq_dev; int ret; @@ -2201,7 +2145,7 @@ static int vchiq_register_chrdev(struct device *parent) * vchiq_deregister_chrdev - Deregister and cleanup the vchiq char * driver and device files */ -static void vchiq_deregister_chrdev(void) +void vchiq_deregister_chrdev(void) { device_destroy(vchiq_class, vchiq_devid); cdev_del(&vchiq_cdev); diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.h b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.h index c7d2cf1f2e68..2453971b6b78 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.h +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.h @@ -14,6 +14,12 @@ #include "vchiq_core.h" #include "vchiq_debugfs.h" +/* Some per-instance constants */ +#define MAX_COMPLETIONS 128 +#define MAX_SERVICES 64 +#define MAX_ELEMENTS 8 +#define MSG_QUEUE_SIZE 128 + enum USE_TYPE_E { USE_TYPE_SERVICE, USE_TYPE_VCHIQ @@ -58,9 +64,63 @@ struct vchiq_drvdata { struct rpi_firmware *fw; }; +struct user_service { + struct vchiq_service *service; + void __user *userdata; + struct vchiq_instance *instance; + char is_vchi; + char dequeue_pending; + char close_pending; + int message_available_pos; + int msg_insert; + int msg_remove; + struct completion insert_event; + struct completion remove_event; + struct completion close_event; + struct vchiq_header *msg_queue[MSG_QUEUE_SIZE]; +}; + +struct bulk_waiter_node { + struct bulk_waiter bulk_waiter; + int pid; + struct list_head list; +}; + +struct vchiq_instance { + struct vchiq_state *state; + struct vchiq_completion_data_kernel completions[MAX_COMPLETIONS]; + int completion_insert; + int completion_remove; + struct completion insert_event; + struct completion remove_event; + struct mutex completion_mutex; + + int connected; + int closing; + int pid; + int mark; + int use_close_delivered; + int trace; + + struct list_head bulk_waiter_list; + struct mutex bulk_waiter_list_mutex; + + struct vchiq_debugfs_node debugfs_node; +}; + +struct dump_context { + char __user *buf; + size_t actual; + size_t space; + loff_t offset; +}; + extern int vchiq_arm_log_level; extern int vchiq_susp_log_level; +extern spinlock_t msg_queue_spinlock; +extern struct vchiq_state g_state; + int vchiq_platform_init(struct platform_device *pdev, struct vchiq_state *state); @@ -114,4 +174,17 @@ vchiq_instance_get_trace(struct vchiq_instance *instance); extern void vchiq_instance_set_trace(struct vchiq_instance *instance, int trace); +extern void +vchiq_deregister_chrdev(void); + +extern int +vchiq_register_chrdev(struct device *parent); + +extern enum vchiq_status +service_callback(enum vchiq_reason reason, struct vchiq_header *header, + unsigned int handle, void *bulk_userdata); + +extern void +free_bulk_waiter(struct vchiq_instance *instance); + #endif /* VCHIQ_ARM_H */