From patchwork Sun Jul 4 15:57:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ojaswin Mujoo X-Patchwork-Id: 12357547 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=-10.7 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,URIBL_BLOCKED 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 A47FBC07E95 for ; Sun, 4 Jul 2021 15:59:37 +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 6CB63613B1 for ; Sun, 4 Jul 2021 15:59:37 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6CB63613B1 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:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date: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=ZYY+e+ev2f3meR KAFP/XgCaihmNSBek48hJHmEisoBRNEwz2hDeH9CrSu7xOjQI4EYF5LlEZCpCMeBdA8ZhJ2oLkw4h Bdj4yyk6DG6aTbCgOJ2APiiGWZyiTkNFCL7Qan/jFxXd/cWq/t2UHgnggH6nFXIcEKk6BPqdpKzUx ulz+GKIX5coKQ1ohkNqE2bfdFjSTKDalvlMCEt1OfK+3GSvdU8HcUcj3frEDLrPA3KLdhDay3zF8M FqOsZLPJkFzYhsAaGNYge8/KPvTX/XgvIt8Vf4O59cCtkXCwfvlpjDZCJvc9uz7Z0mW0ZPfk0o8G0 w6DH/XpFtOiuQoRuVWvw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1m04VY-006Ujy-06; Sun, 04 Jul 2021 15:58:12 +0000 Received: from mail-pj1-x1032.google.com ([2607:f8b0:4864:20::1032]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1m04VU-006Uj3-GO for linux-arm-kernel@lists.infradead.org; Sun, 04 Jul 2021 15:58:10 +0000 Received: by mail-pj1-x1032.google.com with SMTP id kt19so9892396pjb.2 for ; Sun, 04 Jul 2021 08:58:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=By1I86ZOhnAYxBe4OcTi1BPRS1LKy0lQmzeoiW7UDbQ=; b=cMPNXsgqYz53r3xjvLoBVNnfyCR1L6nWkQHOCebRjo2a4ijTm5aEbgfBFcRSewNTSr igbL2Gu1r/HKaYKD6RFnsdZKVkC9YfuV8LnPvqnVx3HuTKlemW7WT8aSTcTwRkKxp3jj ILE2vBK9i6YSE6p0AWJrdzZembra1mc0Di8lYfMSoApXtRn+MXoohNgwtxP6gYQ44PiB 7H1qK1HyD6Dzp3OrWr/elxg8yNiMWCiVS++k8Y4EntnHwN0NrNkL5DhDZ4Y5REx5utYg wbsGGISQ1mqBz45dA04Lw7poKF+07eQzQ3lSaChdUxzLaOFucbVjpRUcnAb7Idc3QSeD 3pGQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=By1I86ZOhnAYxBe4OcTi1BPRS1LKy0lQmzeoiW7UDbQ=; b=uV+gn295DR6UoJERFgWD3/RR9YuN4PoLaRzaZbmLypUy3fH11jnj18GGq7E83IcBQv gZ4JLgXReDE+c47dCTZIXaMqlyGh35HWIWx8j5gx1rlJe+AUuHV5p4wzfHqHiB1byI3m 3zbR0KXBzlHlw7pn68Z8FVPS1i0J4D0WY8C3fzq0DfVZSfmZEfU4Rg4ay4BLcGh5Rhlw nTZxQNURl7AVbDAGHhHq8cOYdUpdOIF9Xq2yf47UxK4g3VSFwn9+toCiB8D5XDQVNl2w WBjC5WbOLnSSOTxEcuwul6EH2ocIoE+VDdL+fZuVZN0BVdJ8HY36p+DDBStULDzpubRE AMkQ== X-Gm-Message-State: AOAM533IcmBfV1Yvl+1k3QJEtTU6u2P5SG9c4R8DLSJ/sF+T9iZAfaIJ NN1ZjJLU12QObrUxB0fwS9M= X-Google-Smtp-Source: ABdhPJx8ZXhW9Ec9WXeeWynvYQtC78Dt3iTCuTcbHTrkxXdJFdtbbe6mii6P4t6f8/Nuufd/7XSgcg== X-Received: by 2002:a17:90a:898b:: with SMTP id v11mr6974859pjn.192.1625414287826; Sun, 04 Jul 2021 08:58:07 -0700 (PDT) Received: from ojas ([182.69.223.21]) by smtp.gmail.com with ESMTPSA id 10sm9944717pfh.174.2021.07.04.08.58.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Jul 2021 08:58:07 -0700 (PDT) Date: Sun, 4 Jul 2021 21:27:57 +0530 From: Ojaswin Mujoo To: nsaenz@kernel.org Cc: gregkh@linuxfoundation.org, stefan.wahren@i2se.com, arnd@arndb.de, dan.carpenter@oracle.com, phil@raspberrypi.com, bcm-kernel-feedback-list@broadcom.com, linux-arm-kernel@lists.infradead.org, linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [PATCH v3 2/5] staging: vchiq: Move certain declarations to vchiq_arm.h Message-ID: <3ed6ab5cbcc5647c9837a2a20428e954b6fb4de1.1625401927.git.ojaswin98@gmail.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210704_085808_620673_16A662BB X-CRM114-Status: GOOD ( 17.67 ) 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 Reviewed-by: Stefan Wahren --- .../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 */