Received: by 2002:a89:d88:0:b0:1fa:5c73:8e2d with SMTP id eb8csp750921lqb; Fri, 24 May 2024 12:00:56 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWEuXWkzZAAW52LHdp/LOBjXP4j9AWvi34j75V+BjxGJYDuv9llA7k4b6G5249ucVDN2z+IPlpsmDS352lTsqGCBRpqyzlXhbrIe/XBCw== X-Google-Smtp-Source: AGHT+IHU7XGBBUM9Qakur7bvSxmUnhhA7lC/LL4qBUMv4yI9IFEupFDExScoIcapDaXi9BKrIL7P X-Received: by 2002:a17:906:69c9:b0:a5a:5f31:7663 with SMTP id a640c23a62f3a-a6265128c7bmr211611766b.56.1716577255987; Fri, 24 May 2024 12:00:55 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716577255; cv=pass; d=google.com; s=arc-20160816; b=ZUMagJ/BbZUU4NKryyICitmSRcTrs11t7oFbLUIqftRVEvktlGpDKwjqoSC/Pvdox5 G/yeqz5ubvgECS9kwygA2Wc6PGQcsO35VXZvZ628cW85HqAyJIm7qUwhfbwpy3rM6OJH GuAwR5MbO6yl5MgetGAwPw4++rB8f0JHUKJVANMEpCRnz0cTxJk7lRfW2i9/NJFij0ak W83AEHVXA22LgG6GKXvlaj+52225tyrJj1Hnbfp3DlB4PXjoMjD1M5wzqxEaXBAlu6H5 n9FrR+hcGYlA5CCa67+6avhX7jJpKlIsUHq+SGVYZI2R0HDJUFTc881w1P5Ex0LhSDCk w6Aw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=WEkkLdCGazwASjryegaKeQ77W4ScoMwRB0DTmQ79T2U=; fh=02EqNmcCFXgHTtRZidmCZ5UcsgLieJSFTxK0pXzMCBw=; b=KpZM6gJ7cpiPgriPrnlDKdFkciIUpixN/wgEr8TPW/lVqRSsOpNbrzlLsTgoNytNzV mniTtoCVXKmLCTV/EShLSRmZpn4WDXnnpo0rgkhLxbUWJ1ICUjt9x3JeYWwDpOsE73EM 4gBPpAXpjlOkGOkuAwS2VUqxXmAVOJlgMxYiQBRtMO1hr3HMuWAZG7Wg7LDp5d8coF0j 6KQUKk+/5MThtCr19ntY+qlvUQIBj5MqvQQH5tpVDuvJ2BH2v34colqKfr2r8dLxsfpg RJaTmqdy1EvNT+GxWIYOifYi5tv6dOWHx1GXdAEDRjQMqm8Jz1tp7KXYMlyMO7VuYxhW hLNw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=pH0rEgdg; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-189034-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-189034-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id a640c23a62f3a-a626c8019f2si108641466b.66.2024.05.24.12.00.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 May 2024 12:00:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-189034-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=pH0rEgdg; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-189034-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-189034-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=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 am.mirrors.kernel.org (Postfix) with ESMTPS id A2C061F213D8 for ; Fri, 24 May 2024 19:00:55 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2D2A642ABD; Fri, 24 May 2024 19:00:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="pH0rEgdg" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 396452C6B6; Fri, 24 May 2024 19:00:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716577247; cv=none; b=I7RhPR9e54veNiM6dEthHMH2/wOfcPLfqtLFB6qt1YJkG6CrEUIKlb/xmaEtfHRi0qgFqmQXG472Omhlyl+gVGcCGhiUMe2rR7b5MmKZowClJgljeKr3tCEu/esYSuRWME29iTpkshlGZxP1IJ236wdEBYcD6vDrOKde7z4V2tI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716577247; c=relaxed/simple; bh=VyzR2s6C8P2vLomjsBBd3QvXEWZ/mkRDvK+dqfX0+/8=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=XjTXmxdAep+nUHkU4GUdU7mXtVwq6oRkFQYBbzcM0x03Exk6tFq2VxQ/zYqooniUtRoatF8E5wR1veBvV35QCjDNjk8Clq0Qfz4KsLYD0P15FgCFTI5VhhpPz6BQ1BFGQ5PUQCRZXjSdED6w+LKLbX9mDcAcD5SYBDrP6AA2Z3I= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=pH0rEgdg; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7DCA1C2BBFC; Fri, 24 May 2024 19:00:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1716577246; bh=VyzR2s6C8P2vLomjsBBd3QvXEWZ/mkRDvK+dqfX0+/8=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=pH0rEgdgVzpDKKX9puQlG7rfJY33T+gFeYjZDHCfaNoWD4sD+BC8ntl0sDpXZoUCq 5ysmt3ex7iuR4uTZ58vuVgr3qPJiEs7afUAL1ScHfN759SIw2bmZHhXJkmFx8y2CT8 gKjfKBZemhwWvdthMfvjg4twakye93/yjSSBgA3Rt+Z4iW8M7k3zSJ7Fz50uK+bK1G ogkuHlJwuPrwmKTtCvsnc59C9kpZB6lASGWGZBkUlwsOqFD4sIrDCHanzBTwfmcYW3 iTWvInG+/Z60Mwdx/ex7qqCpas6WNjGgQ8H9YT1zjESTTocW2ls6qrf83m3gVNe6LA A1frRObBmUwRg== Date: Fri, 24 May 2024 20:00:42 +0100 From: Conor Dooley To: Sebastian Ene Cc: arnd@arndb.de, gregkh@linuxfoundation.org, will@kernel.org, maz@kernel.org, Rob Herring , Dragan Cvetic , Guenter Roeck , linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, kernel-team@android.com Subject: Re: [PATCH 2/2] misc: Register a PPI for the vcpu stall detection virtual device Message-ID: <20240524-joyous-fantastic-2747ab94e83d@spud> References: <20240523160413.868830-1-sebastianene@google.com> <20240523160413.868830-3-sebastianene@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="U4biA59HViDJpe97" Content-Disposition: inline In-Reply-To: <20240523160413.868830-3-sebastianene@google.com> --U4biA59HViDJpe97 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, May 23, 2024 at 04:04:13PM +0000, Sebastian Ene wrote: > Request a PPI for each vCPU during probe which will be used by the host > to communicate a stall detected event on the vCPU. When the host raises > this interrupt from the virtual machine monitor, the guest is expected to > handle the interrupt and panic. >=20 > Signed-off-by: Sebastian Ene > --- > drivers/misc/vcpu_stall_detector.c | 41 ++++++++++++++++++++++++++++-- > 1 file changed, 39 insertions(+), 2 deletions(-) >=20 > diff --git a/drivers/misc/vcpu_stall_detector.c b/drivers/misc/vcpu_stall= _detector.c > index e2015c87f03f..c580cd7fd225 100644 > --- a/drivers/misc/vcpu_stall_detector.c > +++ b/drivers/misc/vcpu_stall_detector.c > @@ -32,6 +32,7 @@ > struct vcpu_stall_detect_config { > u32 clock_freq_hz; > u32 stall_timeout_sec; > + int ppi_irq; > =20 > void __iomem *membase; > struct platform_device *dev; > @@ -77,6 +78,12 @@ vcpu_stall_detect_timer_fn(struct hrtimer *hrtimer) > return HRTIMER_RESTART; > } > =20 > +static irqreturn_t vcpu_stall_detector_irq(int irq, void *dev) > +{ > + panic("vCPU stall detector"); > + return IRQ_HANDLED; > +} > + > static int start_stall_detector_cpu(unsigned int cpu) > { > u32 ticks, ping_timeout_ms; > @@ -132,7 +139,7 @@ static int stop_stall_detector_cpu(unsigned int cpu) > =20 > static int vcpu_stall_detect_probe(struct platform_device *pdev) > { > - int ret; > + int ret, irq, num_irqs; > struct resource *r; > void __iomem *membase; > u32 clock_freq_hz =3D VCPU_STALL_DEFAULT_CLOCK_HZ; > @@ -169,9 +176,32 @@ static int vcpu_stall_detect_probe(struct platform_d= evice *pdev) > vcpu_stall_config =3D (struct vcpu_stall_detect_config) { > .membase =3D membase, > .clock_freq_hz =3D clock_freq_hz, > - .stall_timeout_sec =3D stall_timeout_sec > + .stall_timeout_sec =3D stall_timeout_sec, > + .ppi_irq =3D -1, > }; > =20 > + num_irqs =3D platform_irq_count(pdev); > + if (num_irqs < 0) { > + dev_err(&pdev->dev, "Failed to get irqs\n"); platform_irq_count() either returns a number or EPROBE_DEFER, I don't think emitting an error on deferred probe is the correct thing to do here? > + ret =3D num_irqs; > + goto err; > + } else if (num_irqs > 1) { > + dev_err(&pdev->dev, "Multipple irqs detected\n"); Typo. I don't really see why you're going to this level of complexity though, why aren't you just doing a single get_irq_optional()? > + ret =3D -EINVAL; > + goto err; > + } else if (num_irqs =3D=3D 1) { > + irq =3D platform_get_irq(pdev, 0); > + if ((irq > 0) && irq_is_percpu_devid(irq)) { > + ret =3D request_percpu_irq(irq, > + vcpu_stall_detector_irq, > + "vcpu_stall_detector", > + vcpu_stall_detectors); > + if (!ret) > + vcpu_stall_config.ppi_irq =3D irq; > + > + } > + } > + > ret =3D cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, > "virt/vcpu_stall_detector:online", > start_stall_detector_cpu, > @@ -184,6 +214,9 @@ static int vcpu_stall_detect_probe(struct platform_de= vice *pdev) > vcpu_stall_config.hp_online =3D ret; > return 0; > err: > + if (vcpu_stall_config.ppi_irq > 0) > + free_percpu_irq(vcpu_stall_config.ppi_irq, > + vcpu_stall_detectors); > return ret; > } > =20 > @@ -193,6 +226,10 @@ static void vcpu_stall_detect_remove(struct platform= _device *pdev) > =20 > cpuhp_remove_state(vcpu_stall_config.hp_online); > =20 > + if (vcpu_stall_config.ppi_irq > 0) > + free_percpu_irq(vcpu_stall_config.ppi_irq, > + vcpu_stall_detectors); > + > for_each_possible_cpu(cpu) > stop_stall_detector_cpu(cpu); > } > --=20 > 2.45.1.288.g0e0cd299f1-goog >=20 >=20 --U4biA59HViDJpe97 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iHUEABYIAB0WIQRh246EGq/8RLhDjO14tDGHoIJi0gUCZlDj2gAKCRB4tDGHoIJi 0pKCAQCh1w4ktNbvOBnvKlPyT8kVEaqv6qVAvawgu15jGC1guwEAoBW32iJ63XM/ ox+um5tZltvEvtfyuCM4wVclCNrmHwI= =dzas -----END PGP SIGNATURE----- --U4biA59HViDJpe97--