From patchwork Wed May 18 19:11:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adrien Thierry X-Patchwork-Id: 12854006 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 B7539C433EF for ; Wed, 18 May 2022 19:13:44 +0000 (UTC) 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=h1FkZi4JMDUNbKtSU26Yr/Fn44+HiUANpAFzOFc6/aw=; b=zegGdZku9LXBKX 2LULDM9yeiHCBnlpkI7rhhcQIT76iF/HXtd0reQT2fRnXAulWmQcvg9qWp5psZR2tt8Z0XZtj2z6A w8Bfuwif1eNuECKzko2bmEO2XBxFEt+BhznValIDUOgZHR1Ju1rlNw7lfBorpWwGqbuTIawquZm5u 9NGhXiqfr4B8Z3hWil3Y+5JPZXIzF2eRJdHbTD8YdeRSc3HchGP3RyNVW+77gR4fHDJNAmTj9L7Nz 3HEv6u7vhIaAy1GBdUf+2OQNT2FQ8yzDuzElB5HoGKxgzRk6OkD88ssf6TNYv3rS4TGF4akl2zp27 +Sm0BXAzaj9HAdsbCEKg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nrP5x-003YBG-Ae; Wed, 18 May 2022 19:12:29 +0000 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nrP5X-003Xyy-FP for linux-arm-kernel@lists.infradead.org; Wed, 18 May 2022 19:12:05 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652901122; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=QfFtPnSA8RSHzQX8N1YJfWufC1bmREpixAf/dL1eNUI=; b=MpiUgvcrLG7qUfhO29p76xzVVJNJzEmAq7/4BPUzF/Xp3bvYViZp0mIiTnAi2CC1HBZZoe 1XPcFEcszSc7fQckk2t8WYurKxLoNsPVdlHBUMEzbfwgLurp8qph6fLHy13KmRN7jk1hZs 5Ujqg5SIpbvikCVof6XgUdiR889BKP0= Received: from mail-qk1-f200.google.com (mail-qk1-f200.google.com [209.85.222.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-606-sDUzZVYnNvyAjHmHcJG7lg-1; Wed, 18 May 2022 15:12:01 -0400 X-MC-Unique: sDUzZVYnNvyAjHmHcJG7lg-1 Received: by mail-qk1-f200.google.com with SMTP id z12-20020ae9e60c000000b006a0e769f9caso2267112qkf.5 for ; Wed, 18 May 2022 12:12:01 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=QfFtPnSA8RSHzQX8N1YJfWufC1bmREpixAf/dL1eNUI=; b=P4ZQdC34U95AAuKIsGDW0y3Qe4pIve0T+ylx31RZriJU1C+jtAq0S94UmwzEVPXRhU UqsKroHii7dIrZBQUabW75tapbFzUJvlKbf/QVzpnkMtFdG6SsEcZDYf19u+AJH0Q/FH bQzWIcqTmcmXKsjVF8WZcgNlhrTxZZ8/vxrWzci+EjNpXdKiH3f245Rp6L1QHbS4EJiH kbvwCTuj8k9dg4ffpzKxK+jGCWl2w53SoJHrM7b5vusayHdSEIHRFh+dgHT9dfPV6v5j p49oeOLDdO1tZwwhj4ssWiJXEJiPyJRAxvcQNaKTAIRbu+ToDRbn7YWpFJmcst9vBX74 DUmg== X-Gm-Message-State: AOAM530cEWfHIio51Y71xRCQrpuUZh/XDpueI6f6TzFq1tghbI8J8RGX q4fUWcovPsCZvOqeh/RiAJ4QQPgxGoaDUfhgcWIH6kGzEWGsVg/OMayTnEyGVNfo59TXbb1D+Gx 4zT2M/IuwCn9yS8Vrfl2DZba1ofMOX/AG0B4= X-Received: by 2002:a05:622a:15c8:b0:2f3:d7ae:bae6 with SMTP id d8-20020a05622a15c800b002f3d7aebae6mr1189557qty.106.1652901121080; Wed, 18 May 2022 12:12:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzXyKMtgTFHL5xH8+/fZjJ2Fl06xmfeWdnm+lzI/sOV5djl1NQa//Jh1s7JgWDcYA2MYMPczw== X-Received: by 2002:a05:622a:15c8:b0:2f3:d7ae:bae6 with SMTP id d8-20020a05622a15c800b002f3d7aebae6mr1189539qty.106.1652901120849; Wed, 18 May 2022 12:12:00 -0700 (PDT) Received: from fedora.hitronhub.home (modemcable200.11-22-96.mc.videotron.ca. [96.22.11.200]) by smtp.gmail.com with ESMTPSA id z190-20020a37b0c7000000b006a32d491f92sm39183qke.39.2022.05.18.12.11.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 May 2022 12:12:00 -0700 (PDT) From: Adrien Thierry To: Greg Kroah-Hartman , Nicolas Saenz Julienne , Florian Fainelli , Ray Jui , Scott Branden , bcm-kernel-feedback-list@broadcom.com Cc: Stefan Wahren , Adrien Thierry , linux-staging@lists.linux.dev, linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v2 3/9] staging: vchiq_arm: pass vchiq instance to service callbacks Date: Wed, 18 May 2022 15:11:14 -0400 Message-Id: <20220518191126.60396-4-athierry@redhat.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220518191126.60396-1-athierry@redhat.com> References: <20220518191126.60396-1-athierry@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=athierry@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220518_121203_657503_D363DFA2 X-CRM114-Status: GOOD ( 16.40 ) 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 In order to remove the 'vchiq_states' global array, we need to pass the vchiq_instance reference to the 'handle_to_service' function, as well as to all functions that call 'handle_to_service'. This will allow accessing the vchiq state through the vchiq instance instead of through the global array. 'handle_to_service' is called by 'service_callback'. Therefore, pass the vchiq instance reference to 'service_callback'. This also requires adding the vchiq instance reference to the service callbacks prototype, and update all other callbacks accordingly. Signed-off-by: Adrien Thierry --- .../staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c | 3 ++- .../vc04_services/include/linux/raspberrypi/vchiq.h | 8 ++++++-- .../vc04_services/interface/vchiq_arm/vchiq_arm.c | 9 ++++----- .../vc04_services/interface/vchiq_arm/vchiq_arm.h | 4 ++-- .../vc04_services/interface/vchiq_arm/vchiq_core.c | 3 ++- drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c | 3 ++- 6 files changed, 18 insertions(+), 12 deletions(-) diff --git a/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c b/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c index 701abe430877..c32c8c93a615 100644 --- a/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c +++ b/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c @@ -89,7 +89,8 @@ static int bcm2835_audio_send_simple(struct bcm2835_audio_instance *instance, return bcm2835_audio_send_msg(instance, &m, wait); } -static enum vchiq_status audio_vchi_callback(enum vchiq_reason reason, +static enum vchiq_status audio_vchi_callback(struct vchiq_instance *vchiq_instance, + enum vchiq_reason reason, struct vchiq_header *header, unsigned int handle, void *userdata) { diff --git a/drivers/staging/vc04_services/include/linux/raspberrypi/vchiq.h b/drivers/staging/vc04_services/include/linux/raspberrypi/vchiq.h index 715f02e7f1e1..97537d3b1d28 100644 --- a/drivers/staging/vc04_services/include/linux/raspberrypi/vchiq.h +++ b/drivers/staging/vc04_services/include/linux/raspberrypi/vchiq.h @@ -53,9 +53,12 @@ struct vchiq_element { unsigned int size; }; +struct vchiq_instance; + struct vchiq_service_base { int fourcc; - enum vchiq_status (*callback)(enum vchiq_reason reason, + enum vchiq_status (*callback)(struct vchiq_instance *instance, + enum vchiq_reason reason, struct vchiq_header *header, unsigned int handle, void *bulk_userdata); @@ -71,7 +74,8 @@ struct vchiq_completion_data_kernel { struct vchiq_service_params_kernel { int fourcc; - enum vchiq_status (*callback)(enum vchiq_reason reason, + enum vchiq_status (*callback)(struct vchiq_instance *instance, + enum vchiq_reason reason, struct vchiq_header *header, unsigned int handle, void *bulk_userdata); 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 3b447c635c3f..ffb24298e26b 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c @@ -1041,8 +1041,8 @@ add_completion(struct vchiq_instance *instance, enum vchiq_reason reason, } enum vchiq_status -service_callback(enum vchiq_reason reason, struct vchiq_header *header, - unsigned int handle, void *bulk_userdata) +service_callback(struct vchiq_instance *instance, enum vchiq_reason reason, + struct vchiq_header *header, unsigned int handle, void *bulk_userdata) { /* * How do we ensure the callback goes to the right client? @@ -1052,7 +1052,6 @@ service_callback(enum vchiq_reason reason, struct vchiq_header *header, */ struct user_service *user_service; struct vchiq_service *service; - struct vchiq_instance *instance; bool skip_completion = false; DEBUG_INITIALISE(g_state.local); @@ -1067,7 +1066,6 @@ service_callback(enum vchiq_reason reason, struct vchiq_header *header, } user_service = (struct user_service *)service->base.userdata; - instance = user_service->instance; if (!instance || instance->closing) { rcu_read_unlock(); @@ -1313,7 +1311,8 @@ vchiq_get_state(void) */ static enum vchiq_status -vchiq_keepalive_vchiq_callback(enum vchiq_reason reason, +vchiq_keepalive_vchiq_callback(struct vchiq_instance *instance, + enum vchiq_reason reason, struct vchiq_header *header, unsigned int service_user, void *bulk_user) { 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 2aa46b119a46..f671c3976ab7 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.h +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.h @@ -138,8 +138,8 @@ static inline int vchiq_register_chrdev(struct device *parent) { return 0; } #endif /* IS_ENABLED(CONFIG_VCHIQ_CDEV) */ extern enum vchiq_status -service_callback(enum vchiq_reason reason, struct vchiq_header *header, - unsigned int handle, void *bulk_userdata); +service_callback(struct vchiq_instance *vchiq_instance, enum vchiq_reason reason, + struct vchiq_header *header, unsigned int handle, void *bulk_userdata); extern void free_bulk_waiter(struct vchiq_instance *instance); 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 04eec18835da..547af55d3859 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c @@ -466,7 +466,8 @@ make_service_callback(struct vchiq_service *service, enum vchiq_reason reason, vchiq_log_trace(vchiq_core_log_level, "%d: callback:%d (%s, %pK, %pK)", service->state->id, service->localport, reason_names[reason], header, bulk_userdata); - status = service->base.callback(reason, header, service->handle, bulk_userdata); + status = service->base.callback(service->instance, reason, header, service->handle, + bulk_userdata); if (status == VCHIQ_ERROR) { vchiq_log_warning(vchiq_core_log_level, "%d: ignoring ERROR from callback to service %x", diff --git a/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c b/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c index 145021af93b2..55f290b64d6a 100644 --- a/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c +++ b/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c @@ -548,7 +548,8 @@ static void bulk_abort_cb(struct vchiq_mmal_instance *instance, } /* incoming event service callback */ -static enum vchiq_status service_callback(enum vchiq_reason reason, +static enum vchiq_status service_callback(struct vchiq_instance *vchiq_instance, + enum vchiq_reason reason, struct vchiq_header *header, unsigned int handle, void *bulk_ctx) {