Received: by 2002:ab2:3350:0:b0:1f4:6588:b3a7 with SMTP id o16csp2159948lqe; Tue, 9 Apr 2024 11:07:59 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWCiHiZIBEEiFjhPxWqweOoXXLtJ/5DKRsxfKonneLza8+kEdhUbhVZ5CuPQWEvBCacQ+WbSQmuQyFb7vVxviIgMejNTpZqEMY3jOLwfA== X-Google-Smtp-Source: AGHT+IF2Jdqo4TBacZWDVNBhrPsqK8JvBwPdsa3ztavo56QVSsmTlDL+NY9pWXpIeRCAOiUH/63K X-Received: by 2002:a9d:67c5:0:b0:6ea:86c:fe12 with SMTP id c5-20020a9d67c5000000b006ea086cfe12mr552644otn.15.1712686079199; Tue, 09 Apr 2024 11:07:59 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712686079; cv=pass; d=google.com; s=arc-20160816; b=kNPxAk36CxIwonNu5Dmgr7A39YeULZjyaTQ6mtRYeVaMfYgYqOCtHvMN1ab4SlFaUs p2ODXhIVkrvsQdA9v2OIi8kjVkpiNDo694CWAPEsWFIKuujVpGkg6h6FHHfTG15PijnK GS9zDhJHrfldEayHCpvueAA/eBpscDH0bzUU87u45A9fLa9UbfEY11So5RgJ1/m/U7HB LaWpn9Y2Ojkqzqgttx1CfYS1629qoqkmZs3a30szvZShq45Y3LXUrzeBD1FiCtIh6h7m M2RPNR4nTQeXWu5HfE4bbl1QPyxECYUJyi8mXyPw/pIYolaga8M2BXyKTQk1rq2ZC31W 2+AQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=LUnxFMCJbP/TXFkTWkhYoNXpbsm6oQaeQbjA1rI+i1E=; fh=k/6iF/FVpQwbXL/FmEXvHb1VTlcX0UURzggYTUBmovI=; b=tAfDo9KTsssTQjeEVDUOEvAY3Ijy38lR8VFzpCDK0Jf9+qEMFEgtzVQ5cG5XqM7pXK VPvRJScs5mi2PJ6V394yzeTXAycCCXSYHHrNgurqBM0oeV6lFAK6RUdN3VGl7RWFt/7Z MlrAhlRX+zsLUrHIjlCr0jJk+LieQPyc7Kqv+XMwN6QwhiPO6Vx9IxkAdZuKH6+s+KCi cdhlBlDSVt/86yYyUA2fqSJ2EASJB+GKI2e5fhPzV8m+kUmTnQy7/WxQVSuj/d/UwmaD PZI5PWzMn6tNBe2eH91qoYkzQWNUG2pq9ekKDEZey4E/OHJLDrwMh3oAupiRG7T9zzQU FBRA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amazon.co.uk header.s=amazon201209 header.b=vIvdrfsn; arc=pass (i=1 spf=pass spfdomain=amazon.co.uk dkim=pass dkdomain=amazon.co.uk dmarc=pass fromdomain=amazon.co.uk); spf=pass (google.com: domain of linux-kernel+bounces-137437-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-137437-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amazon.co.uk Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id l12-20020a05620a28cc00b0078d6c319f00si2745747qkp.202.2024.04.09.11.07.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Apr 2024 11:07:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-137437-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 header.i=@amazon.co.uk header.s=amazon201209 header.b=vIvdrfsn; arc=pass (i=1 spf=pass spfdomain=amazon.co.uk dkim=pass dkdomain=amazon.co.uk dmarc=pass fromdomain=amazon.co.uk); spf=pass (google.com: domain of linux-kernel+bounces-137437-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-137437-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amazon.co.uk 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 B72F61C2163A for ; Tue, 9 Apr 2024 18:07:48 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4BEAE156976; Tue, 9 Apr 2024 18:07:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amazon.co.uk header.i=@amazon.co.uk header.b="vIvdrfsn" Received: from smtp-fw-52003.amazon.com (smtp-fw-52003.amazon.com [52.119.213.152]) (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 5998B156883; Tue, 9 Apr 2024 18:07:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=52.119.213.152 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712686057; cv=none; b=s19h2XwKNTjyq2UTBYaCGV7L5ztRpSp8dCytiIKsIDbgZ9osBOdoS70CqGpRIWqPstsAGXschaOHYcemsP+LWrJEsaSHtkiuJc9nId/ZQW5EuDTAKpDu6AaLupj9DnfTK5lnhj9Id+LhGVqhS44bZ4NFJ/64QBIxB0Q1VdknQnE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712686057; c=relaxed/simple; bh=wDHMOgkIcX9zNBekPyozvORWu7pLCVlon2Jq1iysZkM=; h=Message-ID:Date:MIME-Version:Subject:To:CC:References:From: In-Reply-To:Content-Type; b=hVEkvrwNCHM2hNnd2/TzXsqMDglkTXW1Ubem8aS2zjd2PVocwnrkap1MPoGe+FR0LK+4StBYXNaVHQxoLxa0pqm4OSF9bT1S9GDpfdzTfRfDClWzOyjq4OiKHMgXcu2JNLTcA7oEgIPc/Z9kE9Y4GDQBT2eprmRC0voJK5HcWAU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amazon.co.uk; spf=pass smtp.mailfrom=amazon.co.uk; dkim=pass (1024-bit key) header.d=amazon.co.uk header.i=@amazon.co.uk header.b=vIvdrfsn; arc=none smtp.client-ip=52.119.213.152 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amazon.co.uk Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=amazon.co.uk DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.co.uk; i=@amazon.co.uk; q=dns/txt; s=amazon201209; t=1712686056; x=1744222056; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=LUnxFMCJbP/TXFkTWkhYoNXpbsm6oQaeQbjA1rI+i1E=; b=vIvdrfsnSroOU3ZodmZB+hR2FYNr+pfm0C2/faWruG0HNxyDJgjR6eyu YxRngf3g48/RDHWg7yfKRhESbZ9A7Xxj30tFkWGtS+irY/r8sLVPv6w+g ocwxHIlwO4Bqwaybo4fCq+sieMzxBz5ZpnpMTFGYvllhI4bOHkyuJ747x I=; X-IronPort-AV: E=Sophos;i="6.07,190,1708387200"; d="scan'208";a="650816447" Received: from iad12-co-svc-p1-lb1-vlan3.amazon.com (HELO smtpout.prod.us-east-1.prod.farcaster.email.amazon.dev) ([10.43.8.6]) by smtp-border-fw-52003.iad7.amazon.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Apr 2024 18:07:32 +0000 Received: from EX19MTAEUC001.ant.amazon.com [10.0.17.79:41501] by smtpin.naws.eu-west-1.prod.farcaster.email.amazon.dev [10.0.25.48:2525] with esmtp (Farcaster) id 04d050b4-5579-4172-8b50-2a9616ef79f9; Tue, 9 Apr 2024 18:07:30 +0000 (UTC) X-Farcaster-Flow-ID: 04d050b4-5579-4172-8b50-2a9616ef79f9 Received: from EX19D036EUC002.ant.amazon.com (10.252.61.191) by EX19MTAEUC001.ant.amazon.com (10.252.51.155) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1258.28; Tue, 9 Apr 2024 18:07:30 +0000 Received: from [10.95.97.144] (10.95.97.144) by EX19D036EUC002.ant.amazon.com (10.252.61.191) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1258.28; Tue, 9 Apr 2024 18:07:25 +0000 Message-ID: <8eb80918-f3e8-4c02-837d-8950ac14b654@amazon.co.uk> Date: Tue, 9 Apr 2024 19:07:21 +0100 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v4 5/5] virt: vmgenid: add support for devicetree bindings Content-Language: en-US To: Sudan Landge , , , , , , , , , , CC: , , , References: <20240409170722.81738-1-sudanl@amazon.com> From: "Landge, Sudan" In-Reply-To: <20240409170722.81738-1-sudanl@amazon.com> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-ClientProxiedBy: EX19D032UWB001.ant.amazon.com (10.13.139.152) To EX19D036EUC002.ant.amazon.com (10.252.61.191) On 09/04/2024 18:07, Sudan Landge wrote: > Extend the vmgenid platform driver to support devicetree bindings. > With this support, hypervisors can send vmgenid notifications to > the virtual machine without the need to enable ACPI. > The bindings are located at: > Documentation/devicetree/bindings/rng/microsoft,vmgenid.yaml > > Signed-off-by: Sudan Landge > --- > drivers/virt/vmgenid.c | 53 ++++++++++++++++++++++++++++++++++++++++-- > 1 file changed, 51 insertions(+), 2 deletions(-) > > diff --git a/drivers/virt/vmgenid.c b/drivers/virt/vmgenid.c > index 3d93e3fb94c4..e1ad74116c0c 100644 > --- a/drivers/virt/vmgenid.c > +++ b/drivers/virt/vmgenid.c > @@ -2,12 +2,13 @@ > /* > * Copyright (C) 2022 Jason A. Donenfeld . All Rights Reserved. > * > - * The "Virtual Machine Generation ID" is exposed via ACPI and changes when a > + * The "Virtual Machine Generation ID" is exposed via ACPI or DT and changes when a > * virtual machine forks or is cloned. This driver exists for shepherding that > * information to random.c. > */ > > #include > +#include > #include > #include > #include > @@ -20,6 +21,7 @@ enum { VMGENID_SIZE = 16 }; > struct vmgenid_state { > u8 *next_id; > u8 this_id[VMGENID_SIZE]; > + int irq; > }; > > static void vmgenid_notify(struct device *device) > @@ -43,6 +45,14 @@ vmgenid_acpi_handler(acpi_handle __always_unused handle, > vmgenid_notify(dev); > } > > +static __maybe_unused irqreturn_t > +vmgenid_of_irq_handler(int __always_unused irq, void *dev) > +{ > + vmgenid_notify(dev); > + > + return IRQ_HANDLED; > +} > + > static int __maybe_unused > setup_vmgenid_state(struct vmgenid_state *state, u8 *next_id) > { > @@ -106,6 +116,35 @@ static int vmgenid_add_acpi(struct device __maybe_unused *dev, > #endif > } > > +static int vmgenid_add_of(struct platform_device *pdev, > + struct vmgenid_state *state) > +{ > + u8 *virt_addr; > + int ret = 0; > + > + virt_addr = (u8 *)devm_platform_get_and_ioremap_resource(pdev, 0, NULL); > + if (IS_ERR(virt_addr)) > + return PTR_ERR(virt_addr); > + > + ret = setup_vmgenid_state(state, virt_addr); > + if (ret) > + return ret; > + > + ret = platform_get_irq(pdev, 0); > + if (ret < 0) > + return ret; > + > + state->irq = ret; > + pdev->dev.driver_data = state; > + > + ret = devm_request_irq(&pdev->dev, state->irq, vmgenid_of_irq_handler, > + IRQF_SHARED, "vmgenid", &pdev->dev); > + if (ret) > + pdev->dev.driver_data = NULL; > + > + return ret; > +} > + > static int vmgenid_add(struct platform_device *pdev) > { > struct vmgenid_state *state; > @@ -116,7 +155,10 @@ static int vmgenid_add(struct platform_device *pdev) > if (!state) > return -ENOMEM; > > - ret = vmgenid_add_acpi(dev, state); > + if (dev->of_node) > + ret = vmgenid_add_of(pdev, state); > + else > + ret = vmgenid_add_acpi(dev, state); > > if (ret) > devm_kfree(dev, state); > @@ -124,6 +166,12 @@ static int vmgenid_add(struct platform_device *pdev) > return ret; > } > > +static const struct of_device_id vmgenid_of_ids[] = { > + { .compatible = "microsoft,vmgenid", }, > + { }, > +}; > +MODULE_DEVICE_TABLE(of, vmgenid_of_ids); > + > static const struct acpi_device_id vmgenid_acpi_ids[] = { > { "VMGENCTR", 0 }, > { "VM_GEN_COUNTER", 0 }, > @@ -136,6 +184,7 @@ static struct platform_driver vmgenid_plaform_driver = { > .driver = { > .name = "vmgenid", > .acpi_match_table = vmgenid_acpi_ids, > + .of_match_table = vmgenid_of_ids, > }, > }; > Due to a mail server error this last patch of the vmgenid series, "[PATCH v4 0/5] virt: vmgenid: Add devicetree bindings support", got sent separately. Apologies for this. I will resend the patches to correct this issue so, I request reviewers to please ignore this patch.