From patchwork Thu Oct 12 02:38:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "David E. Box" X-Patchwork-Id: 151648 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp942639vqb; Wed, 11 Oct 2023 19:39:18 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGue07tOed23wT0vIZdJh3ZzkQ7GtmBUsy6El1Kyy0IAAIhK01nyv75KsUTcD9U3p1uNpFE X-Received: by 2002:a05:6870:1d0e:b0:1e9:9e04:1d24 with SMTP id pa14-20020a0568701d0e00b001e99e041d24mr2947530oab.5.1697078358663; Wed, 11 Oct 2023 19:39:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697078358; cv=none; d=google.com; s=arc-20160816; b=aeEebhTUrTKUHZgsfSWvUtzBYrzGUw3Aw69qiZ224kdVMJAGGvd2plCC0BSSUcunAy sb0OyxGrrJnkF4NMxC5WA5ASDwGBL6xMZI92FI6gJTlS8f4tLSt6zTWauqfX5bXPSp4P ZGtA4mZXxWME7bllN6DTUHHrNW67Zzsp0UdLhovwPDbp/heW2cOUonADvyg9BElozjsO UAtRbiQajxJEXWgUcYUBiWDbBAk3Fe+cEQcNX3eLgq8EcnZP3co3Y0BoCwAideanvcUq vOcx1yb0g/0vJoJ63D5WEBUN2bAtwRRRG6CVRJffAVxz0LvA17v6Ap8ctDXy4O4wi08h 5tAg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=Pnon3v3HEid4PIvbI8C5TxluM2pja92nS7cQTVYE9Qg=; fh=d9G4dsZtlI8UONIvGKwhW94hCYEPGxy6CqYeKEG646A=; b=zXxuMg/kcG6rOf8POTVdiK++WvG0ZZbw6BG/XWeutIovBW8J09/tMFd1isisi9E3Qs YnJs7vlvjPLdWbvTalYkUA1zd3WZ4ijmzXMP+mMUi/beZOX0SidqffchDaIoNTSefYM6 T7fpTDydv/uQiIxq6VrgzoAKRHRMBPBuE3O+ZPRBWTVnw18YJu094tlHKSLS0ohb/gy0 lkOF0nypJ1OAZyEhEljfJzeugXnZeOqONc3ktgck9+AEir8Py/ylR5wTbhjpKdqZo8oN kvSTGiuaBcKkGL2primpUAeruWuQbRYsSMqk9WmAidafyFhoFXO4bEpvvsCu+PoEy9cA webw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=n++Rde7P; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id g6-20020a636b06000000b0058a4883e6casi1057364pgc.225.2023.10.11.19.39.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Oct 2023 19:39:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=n++Rde7P; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 78B6C81E64A4; Wed, 11 Oct 2023 19:39:17 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376909AbjJLCjL (ORCPT + 18 others); Wed, 11 Oct 2023 22:39:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59240 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1376688AbjJLCiq (ORCPT ); Wed, 11 Oct 2023 22:38:46 -0400 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.9]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B8B47BA; Wed, 11 Oct 2023 19:38:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1697078324; x=1728614324; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=pO1E3835P+LdNYS0j3twJPg5eBQFsYzBKgSmmSamrCI=; b=n++Rde7Plr6z3JZ+gROR5DBpiNiaGnqM2ndGDhifvBfyk90AhxIYQ2Z5 FIN1t17zz4ifmWS82fYkIZhelP1mn8F9CIzwB2r1brvctsr5ZxSqPwWQL 7IgVCdmeZCFLUjyd2XPFCZ9X8sHvfq31cFfUV7RaPMAud7jgk0PjxVixk PD+SeFQ0oK1bbbSEN55pRdNZY00bkYdUp1VLSwiNbQNno98bkGCfsl3bA o+HwThNRCFWW7d6bHv3wccaoLqr15wJSOp/5qeA3AHA/APAcVMEnNbhiN AlevIna7+5YfUMvLPD8v+eCwUwxakBY8u+ILwbs5+Qo9M+VJSyuxlWCUX g==; X-IronPort-AV: E=McAfee;i="6600,9927,10860"; a="3402625" X-IronPort-AV: E=Sophos;i="6.03,217,1694761200"; d="scan'208";a="3402625" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orvoesa101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Oct 2023 19:38:42 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10860"; a="783507861" X-IronPort-AV: E=Sophos;i="6.03,217,1694761200"; d="scan'208";a="783507861" Received: from linux.intel.com ([10.54.29.200]) by orsmga008.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Oct 2023 19:38:41 -0700 Received: from debox1-desk4.intel.com (unknown [10.209.105.238]) by linux.intel.com (Postfix) with ESMTP id 6321D580D95; Wed, 11 Oct 2023 19:38:41 -0700 (PDT) From: "David E. Box" To: linux-kernel@vger.kernel.org, platform-driver-x86@vger.kernel.org, ilpo.jarvinen@linux.intel.com, rajvi.jingar@linux.intel.com Subject: [PATCH V3 05/16] platform/x86/intel/vsec: Add base address field Date: Wed, 11 Oct 2023 19:38:29 -0700 Message-Id: <20231012023840.3845703-6-david.e.box@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231012023840.3845703-1-david.e.box@linux.intel.com> References: <20231012023840.3845703-1-david.e.box@linux.intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, 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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Wed, 11 Oct 2023 19:39:17 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779515636915420849 X-GMAIL-MSGID: 1779515636915420849 Some devices may emulate PCI VSEC capabilities in MMIO. In such cases the BAR is not readable from a config space. Provide a field for drivers to indicate the base address to be used. Signed-off-by: David E. Box Reviewed-by: Ilpo Järvinen --- V3 - No change V2 - No change drivers/platform/x86/intel/pmt/class.c | 14 +++++++++++--- drivers/platform/x86/intel/vsec.c | 10 ++++++++-- drivers/platform/x86/intel/vsec.h | 2 ++ 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/drivers/platform/x86/intel/pmt/class.c b/drivers/platform/x86/intel/pmt/class.c index 2ad91d2fd954..32608baaa56c 100644 --- a/drivers/platform/x86/intel/pmt/class.c +++ b/drivers/platform/x86/intel/pmt/class.c @@ -160,10 +160,11 @@ static struct class intel_pmt_class = { static int intel_pmt_populate_entry(struct intel_pmt_entry *entry, struct intel_pmt_header *header, - struct device *dev, + struct intel_vsec_device *ivdev, struct resource *disc_res) { - struct pci_dev *pci_dev = to_pci_dev(dev->parent); + struct pci_dev *pci_dev = ivdev->pcidev; + struct device *dev = &ivdev->auxdev.dev; u8 bir; /* @@ -215,6 +216,13 @@ static int intel_pmt_populate_entry(struct intel_pmt_entry *entry, break; case ACCESS_BARID: + /* Use the provided base address if it exists */ + if (ivdev->base_addr) { + entry->base_addr = ivdev->base_addr + + GET_ADDRESS(header->base_offset); + break; + } + /* * If another BAR was specified then the base offset * represents the offset within that BAR. SO retrieve the @@ -319,7 +327,7 @@ int intel_pmt_dev_create(struct intel_pmt_entry *entry, struct intel_pmt_namespa if (ret) return ret; - ret = intel_pmt_populate_entry(entry, &header, dev, disc_res); + ret = intel_pmt_populate_entry(entry, &header, intel_vsec_dev, disc_res); if (ret) return ret; diff --git a/drivers/platform/x86/intel/vsec.c b/drivers/platform/x86/intel/vsec.c index 1d005077024a..5e18a06395e0 100644 --- a/drivers/platform/x86/intel/vsec.c +++ b/drivers/platform/x86/intel/vsec.c @@ -160,6 +160,7 @@ static int intel_vsec_add_dev(struct pci_dev *pdev, struct intel_vsec_header *he struct resource __free(kfree) *res = NULL; struct resource *tmp; unsigned long quirks = info->quirks; + u64 base_addr; int ret, i; if (!intel_vsec_supported(header->id, info->caps)) @@ -186,14 +187,18 @@ static int intel_vsec_add_dev(struct pci_dev *pdev, struct intel_vsec_header *he if (quirks & VSEC_QUIRK_TABLE_SHIFT) header->offset >>= TABLE_OFFSET_SHIFT; + if (info->base_addr) + base_addr = info->base_addr; + else + base_addr = pdev->resource[header->tbir].start; + /* * The DVSEC/VSEC contains the starting offset and count for a block of * discovery tables. Create a resource array of these tables to the * auxiliary device driver. */ for (i = 0, tmp = res; i < header->num_entries; i++, tmp++) { - tmp->start = pdev->resource[header->tbir].start + - header->offset + i * (header->entry_size * sizeof(u32)); + tmp->start = base_addr + header->offset + i * (header->entry_size * sizeof(u32)); tmp->end = tmp->start + (header->entry_size * sizeof(u32)) - 1; tmp->flags = IORESOURCE_MEM; @@ -208,6 +213,7 @@ static int intel_vsec_add_dev(struct pci_dev *pdev, struct intel_vsec_header *he intel_vsec_dev->resource = res; intel_vsec_dev->num_resources = header->num_entries; intel_vsec_dev->quirks = info->quirks; + intel_vsec_dev->base_addr = info->base_addr; if (header->id == VSEC_ID_SDSI) intel_vsec_dev->ida = &intel_vsec_sdsi_ida; diff --git a/drivers/platform/x86/intel/vsec.h b/drivers/platform/x86/intel/vsec.h index bb8b6452df70..e23e76129691 100644 --- a/drivers/platform/x86/intel/vsec.h +++ b/drivers/platform/x86/intel/vsec.h @@ -73,6 +73,7 @@ struct intel_vsec_platform_info { struct intel_vsec_header **headers; unsigned long caps; unsigned long quirks; + u64 base_addr; }; struct intel_vsec_device { @@ -85,6 +86,7 @@ struct intel_vsec_device { void *priv_data; size_t priv_data_size; unsigned long quirks; + u64 base_addr; }; int intel_vsec_add_aux(struct pci_dev *pdev, struct device *parent,