Received: by 2002:a89:413:0:b0:1fd:dba5:e537 with SMTP id m19csp740797lqs; Fri, 14 Jun 2024 04:36:22 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWwhJ7NC9RgGG8zh1taToMGda7leyLn7SkUHBO7/k4iYxUzbtDTIV52iJzJl3PL3KdsF2e0KqdAoeL/iaA5pnan5yvjNiPubbtCZZneug== X-Google-Smtp-Source: AGHT+IHfAxXLuP9aHz5dAGRKoedtbDxkMaPw8zmyV7uwARSlusbtIR07iWB7wZpfgFEKqf5LtNRA X-Received: by 2002:a05:622a:283:b0:43f:fd01:bb89 with SMTP id d75a77b69052e-4417ac5d25cmr88478971cf.34.1718364982118; Fri, 14 Jun 2024 04:36:22 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718364982; cv=pass; d=google.com; s=arc-20160816; b=RA0Emk3RBQvua4fJX+b357jDffXhyfActnRR2dr69YB8ViuwaHEGswCN5BWrD0Zspo vk6+oUqPXG0LbEzqzWw/azB32e1X1icBeg0UzbfoXt7iktqKlNov07YKYvlB4upGncIi TbPNJs5cEWdyaz4EtxGZE+YoZbpl6TkeKwl4LPuHJ5jKuYGO+9LzBm0uAtsnyvnPL+xa HNQhQJ2rMMKO8wj1BTsUDJDwFJEy729pBPKWIld5aGPD9McJchhOto++phatnKdBo9Mo xMCAa/HAK60weKgAQCKu4Gv57YO/3DpsTjb/B3JGuQQ1relQfeHx9JmtzTB0enTJqdOj cu4w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=user-agent:message-id:date:to:cc:from:subject:references :in-reply-to:content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:dkim-signature; bh=x4b1V8DQJcEC/RWJfUoocrG2I9SUYDrS2ndi2f276EY=; fh=YFYOnEEV+Mfn2Mbo1RBkKptU9ykARJKf499+LxNThsk=; b=O+5mttBH6CRnxwZhAJ1BsHeCquWbVy2fPPAWBLApUIOXxpxbE/lSe+DaZ+5sf7o6ed XBMhereyVOzcihb3pFdKyPZpgtDEMG7BkbfGOllJZ3voTG+uJf2kC7u47LU5LQz2w6fQ Wew/m1TeTbU8jxYpyghROy6bP38fjgooQc6iwZ5pKJVFOqP9NfjsDfShq0uKcQeDYmFt olzoYX+zOWHkWpPeY1xKY9rK4CqTAL26WfBqlESN6tqeSV4kCVE5al5OUkCTcSwrG8+y LmOejWFh5uEE/ax97en9eUUl66AqxTCDQEd99AfpLe5tsPDXTkp6wIQk0ZNG1zN+Mm+W g5pw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=R28OVEM3; arc=pass (i=1 spf=pass spfdomain=ideasonboard.com dkim=pass dkdomain=ideasonboard.com); spf=pass (google.com: domain of linux-kernel+bounces-214839-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-214839-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id d75a77b69052e-441f2ea88c0si31590571cf.243.2024.06.14.04.36.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Jun 2024 04:36:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-214839-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=R28OVEM3; arc=pass (i=1 spf=pass spfdomain=ideasonboard.com dkim=pass dkdomain=ideasonboard.com); spf=pass (google.com: domain of linux-kernel+bounces-214839-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-214839-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id C48391C21EA7 for ; Fri, 14 Jun 2024 11:36:21 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 536B5195B03; Fri, 14 Jun 2024 11:36:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="R28OVEM3" 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 F3BBB14D29B for ; Fri, 14 Jun 2024 11:36:10 +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=1718364972; cv=none; b=XIFg4VYntQ2uBSMtZztHP063e5CowmRumoK8cc9R1k7QQnK7qSk/u1XsqIPXb5uh9UWYfBkv7yEH23RDTp/Oq9NDmGn/CIjqM7uiSB6dqX1V09KuXZys8d8chHaaC2AYPI5XDDeDRg/inVZGke0y2xgxrfzjnc3OUu+6AbYZE7E= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718364972; c=relaxed/simple; bh=D57VW2tUjXTLhv/XmrfsMmV1i/cLw0/QIlJ1ekguQ3s=; h=Content-Type:MIME-Version:In-Reply-To:References:Subject:From:Cc: To:Date:Message-ID; b=QEh8J7HRoVlyDfmmfV39ZuPG0Mh0NlqycLfAdM0Z0EMbLV/VipKwon9Sk4C2WWsfd/bNswY6/81rzwObhFqlEnnD7jrivjgjMK6aQvgiOKzyEZlUjlR/Pdjn5SY2wlu94A6lHql6yRjiHQ+L3WXuf59yQd/IdXtC5MZyVzJCuXI= 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=R28OVEM3; 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 Received: from pendragon.ideasonboard.com (cpc89244-aztw30-2-0-cust6594.18-1.cable.virginm.net [86.31.185.195]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 6CCFB397; Fri, 14 Jun 2024 13:35:53 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1718364953; bh=D57VW2tUjXTLhv/XmrfsMmV1i/cLw0/QIlJ1ekguQ3s=; h=In-Reply-To:References:Subject:From:Cc:To:Date:From; b=R28OVEM3qBRkruo0lA6efSJ2h9zoPF5nl4sscfD4VdZW2fa+hs0GuZapUSTLcRXkF /xXdu9zC89vz1FYULTc2RdsSuBLryN6j9EjvVdpwuTLQpAS5p6fgs2HA2WnROTV/LW RZxsfr/a0L3oHAIPMQOv2lQrHjRdeK27wKQ2V5YQ= Content-Type: text/plain; charset="utf-8" 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 In-Reply-To: <082d9df0-0947-4452-a3fc-87eab2019e01@gmx.net> References: <20240613194150.2915202-1-kieran.bingham@ideasonboard.com> <20240613194150.2915202-2-kieran.bingham@ideasonboard.com> <082d9df0-0947-4452-a3fc-87eab2019e01@gmx.net> Subject: Re: [PATCH] staging: vc04_services: vchiq_arm: Fix initialisation check From: Kieran Bingham Cc: Broadcom internal kernel review list , Greg Kroah-Hartman , Laurent Pinchart , Dave Stevenson , detule , Dan Carpenter , moderated list:BROADCOM BCM2711/BCM2835 ARM ARCHITECTURE , open list:STAGING SUBSYSTEM , open list ; To: Florian Fainelli , Stefan Wahren , Umang Jain , linux-rpi-kernel@lists.infradead.org Date: Fri, 14 Jun 2024 12:36:05 +0100 Message-ID: <171836496531.2248009.11650291484570726735@ping.linuxembedded.co.uk> User-Agent: alot/0.10 Hi Stefan, Sorry, indeed I completely missed this mail. Quoting Stefan Wahren (2024-06-13 21:01:42) > Hi Kieran, >=20 > Am 13.06.24 um 21:41 schrieb Kieran Bingham: > > The vchiq_state used to be obtained through an accessor > > which would validate that the VCHIQ had been initialised > > correctly with the remote. > > > > In commit 42a2f6664e18 ("staging: vc04_services: Move global g_state to > > vchiq_state") the global state was moved to the vchiq_mgnt structures > > stored as a vchiq instance specific context. This conversion removed the > > helpers and instead replaced users of this helper with the assumption > > that the state is always available and the remote connected. > > > > Fix this broken assumption by re-introducing the logic that was lost > > during the conversion. >=20 > thank you for sending this patch. Maybe it's worth to mention that this > patch also drop some unnecessary NULL checks of state. I don't understand this comment. Nothing is dropped is it? The newly added vchiq_remote_initialised() is itself a null-check too! > > Fixes: 42a2f6664e18 ("staging: vc04_services: Move global g_state to vc= hiq_state") > > Signed-off-by: Kieran Bingham > > --- > > .../staging/vc04_services/interface/vchiq_arm/vchiq_arm.c | 4 ++-- > > .../staging/vc04_services/interface/vchiq_arm/vchiq_core.h | 5 +++++ > > .../staging/vc04_services/interface/vchiq_arm/vchiq_dev.c | 7 ++++++- > > 3 files changed, 13 insertions(+), 3 deletions(-) > > > > diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_ar= m.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c > > index 54467be8c371..67d853f5f2a0 100644 > > --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c > > +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c > > @@ -804,7 +804,7 @@ int vchiq_initialise(struct vchiq_state *state, str= uct vchiq_instance **instance > > * block forever. > > */ > > for (i =3D 0; i < VCHIQ_INIT_RETRIES; i++) { > > - if (state) > > + if (vchiq_remote_initialised(state)) > > break; > > usleep_range(500, 600); > > } > > @@ -1299,7 +1299,7 @@ void vchiq_dump_platform_instances(struct vchiq_s= tate *state, struct seq_file *f > > { > > int i; > > > > - if (!state) > > + if (!vchiq_remote_initialised(state)) > > return; > > > > /* > > diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_co= re.h b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h > > index 8af209e34fb2..382ec08f6a14 100644 > > --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h > > +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h > > @@ -413,6 +413,11 @@ struct vchiq_state { > > struct opaque_platform_state *platform_state; > > }; > > > > +static inline bool vchiq_remote_initialised(const struct vchiq_state *= state) > > +{ > > + return state->remote && state->remote->initialised; > > +} > > + > > struct bulk_waiter { > > struct vchiq_bulk *bulk; > > struct completion event; > > diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_de= v.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_dev.c > > index 3c63347d2d08..8c4830df1070 100644 > > --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_dev.c > > +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_dev.c > > @@ -1170,6 +1170,11 @@ static int vchiq_open(struct inode *inode, struc= t file *file) > > > > dev_dbg(state->dev, "arm: vchiq open\n"); > > > > + if (!vchiq_remote_initialised(state)) { > > + dev_err(state->dev, "arm: vchiq has no connection to Vide= oCore\n"); > Can you please downgrade the log level to dev_dbg, because vchiq_open is > called from userspace, so we can prevent log spamming? Sure. > > + return -ENOTCONN; > > + } > > + > > instance =3D kzalloc(sizeof(*instance), GFP_KERNEL); > > if (!instance) > > return -ENOMEM; > > @@ -1200,7 +1205,7 @@ static int vchiq_release(struct inode *inode, str= uct file *file) > > > > dev_dbg(state->dev, "arm: instance=3D%p\n", instance); > > > > - if (!state) { > > + if (!vchiq_remote_initialised(state)) { > > ret =3D -EPERM; > > goto out; > > } >