Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp2032893rwb; Thu, 17 Nov 2022 05:47:31 -0800 (PST) X-Google-Smtp-Source: AA0mqf5uQKtYXE6fLOzdqMG+QA9Oer6K3SKH+LVtaGYYIgKPjQFg/nvFbCO3hIRGuBx/lYfXweuj X-Received: by 2002:a05:6402:1612:b0:462:2426:49d1 with SMTP id f18-20020a056402161200b00462242649d1mr2238828edv.195.1668692850833; Thu, 17 Nov 2022 05:47:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668692850; cv=none; d=google.com; s=arc-20160816; b=ChooQ4+QbuROIr8pUQdMiORkuwrgd8cZKBfbXkHjMVAjWA/cBonUwHy/B7rZvZBvh8 UyZlluLJN1OSuYo9cNzC2lu6hzDQPgb1aAVcJYRAK5B1m6IDB35RDN279QEJhfW+/wsD VCAXVa5qZPf1JG4+UYSST2xwvswsbdnm1QvPBuptiyuVhP+cWfKASUYvmDnL6fbQMDNc tjDD6UPEh3Bdn7fND16MfP7j3q0VnbQy6mxxQlEJmKFvguRqTaZ9GfuLm4A/EmnTDZes R5LyRMlNgjTbwI7Zxu8ZUx5WF+OA+Xsr+kdP8dpYdsZ/kNpJdWHeVE0uz7EvrQx/FB69 q5Ow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=kKR7OdPNU6xaK3dFkFAJM5RIPG7b+zn03F5YyC8LFZI=; b=Ie/nMemOVEiwz1RBjYMlQG8hMmBzKVk8oVzZdTAr99QSZ/bZWHhnxUBtLdypiZ3NZk D8HKSm/CF/v6Ez6r9sCTbEB6OeQj7Vra4mY5K8yABHmCuzY43FsDkCKRyBA2wubZdcA3 D2MaFCsaX3QFgs4Gdccir6NmdCVimylfv/oH9alTnleKAfArZ6ECage1Y8qU5akeDLA6 0sNtNKG6i+iTrljrEfLS3BaXwPuJxErct+d1hnDRTCgeYSkrOa7Z4EbqXy7WAjH/4KBP 7jcO8b+Jgy/9DbE9mhhUx32J9e+bCTdhHpcjOkG4zSmkVhwSvdxrqIQRWWA42YfIeUyF yXYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=OeGAfhNP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bc17-20020a056402205100b0046721c5b7e0si858113edb.511.2022.11.17.05.47.08; Thu, 17 Nov 2022 05:47:30 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=OeGAfhNP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239969AbiKQNbZ (ORCPT + 92 others); Thu, 17 Nov 2022 08:31:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45766 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240116AbiKQNbU (ORCPT ); Thu, 17 Nov 2022 08:31:20 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B91A773415 for ; Thu, 17 Nov 2022 05:30:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1668691815; 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=kKR7OdPNU6xaK3dFkFAJM5RIPG7b+zn03F5YyC8LFZI=; b=OeGAfhNPFC6iXIr9P3ZdCnC7BY/PKPs1lYlOxf0IqnSIPF1DE73CmUI9diuI2B3N/9INup OeUHy+zBvxP3BcZ/pjWHjR41jo/x77OAFoeBRleqIHoobRRMhXzQZ75kqSvpoZvuzixnX8 eLVkpbnGP1l1IiEPF+sdmNsw8DWkwLo= Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-91-G_gfcoyCPZqIbM9JWp-axA-1; Thu, 17 Nov 2022 08:30:14 -0500 X-MC-Unique: G_gfcoyCPZqIbM9JWp-axA-1 Received: by mail-ed1-f70.google.com with SMTP id f17-20020a056402355100b00466481256f6so1215248edd.19 for ; Thu, 17 Nov 2022 05:30:14 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=kKR7OdPNU6xaK3dFkFAJM5RIPG7b+zn03F5YyC8LFZI=; b=TaHanl6iynFYhNe63YuaamMB/BHjIFzB3mmE7+lbEjGhYzsdown1RiieaL0PpwdwqA O9K1dYwlAykA9ku3lLvjrYUn/DtFaIX4hFzKfy7AOFbYBK608y67tqN3idsyVnrzRi2U 3O9b2qTM8m5cYetF7+8F+hIIFZkn2FZg0MBriJAL76HFivHcxz48+nwJowbGqoiiawbm j69bCknxEpLe6ximbqg3J7l2gUQaQMwWJMZraQlruyIq+XZ+/eJfeIuD/0xuaydLxsTW vfSLC6uLj2WjeltyeREYpi/IFBv7JWF+cWXDzermlqN3ktI2jNilk8IGkYkZ3ZdItrA5 5DXQ== X-Gm-Message-State: ANoB5pmWM1+DltZ3nh10M5T2YCTRGRnuEvL0WPmE4+cn1n6CfXWMdh9o N9K3dsMh9fC0OtN0oGdb8RuO9Qu5APYQHKkdI/GDEMqaq9dIVRm3L+z30yHnHY6sdHdl8hf4yLF eVQ5I8DnhnF/MD2WgRInrqlhv X-Received: by 2002:a17:906:89a3:b0:78d:408a:4a18 with SMTP id gg35-20020a17090689a300b0078d408a4a18mr2151386ejc.261.1668691813312; Thu, 17 Nov 2022 05:30:13 -0800 (PST) X-Received: by 2002:a17:906:89a3:b0:78d:408a:4a18 with SMTP id gg35-20020a17090689a300b0078d408a4a18mr2151378ejc.261.1668691813156; Thu, 17 Nov 2022 05:30:13 -0800 (PST) Received: from ?IPV6:2001:1c00:c1e:bf00:d69d:5353:dba5:ee81? (2001-1c00-0c1e-bf00-d69d-5353-dba5-ee81.cable.dynamic.v6.ziggo.nl. [2001:1c00:c1e:bf00:d69d:5353:dba5:ee81]) by smtp.gmail.com with ESMTPSA id jp8-20020a170906f74800b007adaca75bd0sm370553ejb.179.2022.11.17.05.30.12 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 17 Nov 2022 05:30:12 -0800 (PST) Message-ID: <7412dae3-c8b7-c826-ab70-d3f63d788f0e@redhat.com> Date: Thu, 17 Nov 2022 14:30:11 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.1 Subject: Re: [PATCH 3/9] platform/x86/intel/sdsi: Support different GUIDs Content-Language: en-US, nl To: "David E. Box" , markgross@kernel.org, andriy.shevchenko@linux.intel.com, srinivas.pandruvada@intel.com Cc: platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org References: <20221101191023.4150315-1-david.e.box@linux.intel.com> <20221101191023.4150315-4-david.e.box@linux.intel.com> From: Hans de Goede In-Reply-To: <20221101191023.4150315-4-david.e.box@linux.intel.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On 11/1/22 20:10, David E. Box wrote: > Newer versions of Intel On Demand hardware may have an expanded list of > registers to support new features. The register layout is identified by a > unique GUID that's read during driver probe. Add support for handling > different GUIDs and add support for current GUIDs [1]. > > [1] https://github.com/intel/intel-sdsi/blob/master/os-interface.rst > > Signed-off-by: David E. Box With Andy's remarks fixed this looks good to me: Reviewed-by: Hans de Goede Regards, Hans > --- > drivers/platform/x86/intel/sdsi.c | 47 +++++++++++++++++++++++++++++-- > 1 file changed, 44 insertions(+), 3 deletions(-) > > diff --git a/drivers/platform/x86/intel/sdsi.c b/drivers/platform/x86/intel/sdsi.c > index bca05b4dd983..ab1f65919fc5 100644 > --- a/drivers/platform/x86/intel/sdsi.c > +++ b/drivers/platform/x86/intel/sdsi.c > @@ -27,10 +27,10 @@ > #define ACCESS_TYPE_LOCAL 3 > > #define SDSI_MIN_SIZE_DWORDS 276 > -#define SDSI_SIZE_CONTROL 8 > #define SDSI_SIZE_MAILBOX 1024 > -#define SDSI_SIZE_REGS 72 > +#define SDSI_SIZE_REGS 80 > #define SDSI_SIZE_CMD sizeof(u64) > +#define SDSI_SIZE_MAILBOX 1024 > > /* > * Write messages are currently up to the size of the mailbox > @@ -76,6 +76,9 @@ > #define DT_TBIR GENMASK(2, 0) > #define DT_OFFSET(v) ((v) & GENMASK(31, 3)) > > +#define SDSI_GUID_V1 0x006DD191 > +#define SDSI_GUID_V2 0xF210D9EF > + > enum sdsi_command { > SDSI_CMD_PROVISION_AKC = 0x04, > SDSI_CMD_PROVISION_CAP = 0x08, > @@ -100,6 +103,9 @@ struct sdsi_priv { > void __iomem *control_addr; > void __iomem *mbox_addr; > void __iomem *regs_addr; > + int control_size; > + int maibox_size; > + int registers_size; > u32 guid; > u32 features; > }; > @@ -444,6 +450,18 @@ static ssize_t registers_read(struct file *filp, struct kobject *kobj, > struct device *dev = kobj_to_dev(kobj); > struct sdsi_priv *priv = dev_get_drvdata(dev); > void __iomem *addr = priv->regs_addr; > + int size = priv->registers_size; > + > + /* > + * The check below is performed by the sysfs caller based on the static > + * file size. But this may be greater than the actual size which is based > + * on the GUID. So check here again based on actual size before reading. > + */ > + if (off >= size) > + return 0; > + > + if (off + count > size) > + count = size - off; > > memcpy_fromio(buf, addr + off, count); > > @@ -496,6 +514,24 @@ static const struct attribute_group sdsi_group = { > }; > __ATTRIBUTE_GROUPS(sdsi); > > +static int sdsi_get_layout(struct sdsi_priv *priv, struct disc_table *table) > +{ > + switch (table->guid) { > + case SDSI_GUID_V1: > + priv->control_size = 8; > + priv->registers_size = 72; > + break; > + case SDSI_GUID_V2: > + priv->control_size = 16; > + priv->registers_size = 80; > + break; > + default: > + dev_err(priv->dev, "Unrecognized GUID 0x%x\n", table->guid); > + return -EINVAL; > + } > + return 0; > +} > + > static int sdsi_map_mbox_registers(struct sdsi_priv *priv, struct pci_dev *parent, > struct disc_table *disc_table, struct resource *disc_res) > { > @@ -537,7 +573,7 @@ static int sdsi_map_mbox_registers(struct sdsi_priv *priv, struct pci_dev *paren > if (IS_ERR(priv->control_addr)) > return PTR_ERR(priv->control_addr); > > - priv->mbox_addr = priv->control_addr + SDSI_SIZE_CONTROL; > + priv->mbox_addr = priv->control_addr + priv->control_size; > priv->regs_addr = priv->mbox_addr + SDSI_SIZE_MAILBOX; > > priv->features = readq(priv->regs_addr + SDSI_ENABLED_FEATURES_OFFSET); > @@ -572,6 +608,11 @@ static int sdsi_probe(struct auxiliary_device *auxdev, const struct auxiliary_de > > priv->guid = disc_table.guid; > > + /* Get guid based layout info */ > + ret = sdsi_get_layout(priv, &disc_table); > + if (ret) > + return ret; > + > /* Map the SDSi mailbox registers */ > ret = sdsi_map_mbox_registers(priv, intel_cap_dev->pcidev, &disc_table, disc_res); > if (ret)