From patchwork Thu Feb 2 01:07:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: srinivas pandruvada X-Patchwork-Id: 51619 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp606698wrn; Wed, 1 Feb 2023 17:10:37 -0800 (PST) X-Google-Smtp-Source: AK7set9EYB1W0nIiI9Y4N2/i3fJwcL0/QStpXZ36kqAaoigWMZ6Iq8H1J4qbHOe4MCjrkv2g0ZSv X-Received: by 2002:a17:906:fb19:b0:86b:9216:2ddb with SMTP id lz25-20020a170906fb1900b0086b92162ddbmr4787484ejb.52.1675300237748; Wed, 01 Feb 2023 17:10:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675300237; cv=none; d=google.com; s=arc-20160816; b=ZaFnHwnwiryOY1otAnrPWzcYuDzmah/SLsTB/M6aCBLGvy+F6CJOtWQWzoNQHOiwm7 gtFcOCCES4SxONS2NdwlbXfkbDeJx2n7bvYzaSI6x/RKpZe8x80gmiBMVJxf0oXstVK5 /SZfdIZZ5xqocyO+9qO6XGGfx0KdQYhkc9lrT56sO95XpViKHAeei5gdrxuomgfu2z4A 7eFaFdSkiIbrjGUGZFtHt7sY7J/WfG1q5zbdAfoxkuD453yNAaYPblvckv6Lo0qjPgEd tcwxdOkMgbzzATWsb+uQ0TcXMru9+4M9CORxiQOvjK8+nCZHu21K+OixfZ4ZN4/yyor/ i9XA== 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:cc:to:from :dkim-signature; bh=uEOBi+OneXLPh+C2otbc5+cdHJ4DR2bQqClFkLUNHUg=; b=nVZKjOZZamsbabfMySo5mEOrtoLu5JN0pRIy1ZPMtFNnz2A6oJn/Xze+xMMZc/P1P3 bu+6vOPdDCt0gvsmFHwQsKxRvY7Tviq6+CrlsmB1xtFQ6EsCna3iT/Y9qwfiy4eU27QH AXE7hfMcRW0bozdlBSHe68yjaGUyHV204uyh/yqkzLB3o1bDsy7B0V4v8FQMAaMBn/P3 RH8qtSfDgKFIZVIZHLtjNgosSfU+vdkpXaCLOPmnAc9Qt/rX/oxUD217nDIsrrGfvMUX FO1qaKu8nA6ffVet/AmkuQ7m5uH0Jki2PASkzRpQx1HsGnMezzRVQ5YxKiml5rdLc4Qq gPAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="HqUE/Ji8"; 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=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z4-20020a056402274400b004a23fed6eddsi15979780edd.449.2023.02.01.17.10.14; Wed, 01 Feb 2023 17:10:37 -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=@intel.com header.s=Intel header.b="HqUE/Ji8"; 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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230462AbjBBBJQ (ORCPT + 99 others); Wed, 1 Feb 2023 20:09:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55128 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229551AbjBBBJD (ORCPT ); Wed, 1 Feb 2023 20:09:03 -0500 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A1F0A4ED26; Wed, 1 Feb 2023 17:09:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1675300141; x=1706836141; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=l3Pi5pRFRYGc5u8IPh/RxqSovVxp2fgjAvKiIcXzht4=; b=HqUE/Ji8t4NpBP4KdByyyG6SiFnxtagafbT2GkZuoXCeNtpwSFCWxMgG Psyf452JjuaCw6WORY/6kOYsigAiEEnfsKA6MiRdn6LBccCivqy9NKhDW DYt8A0ryQNAaWtbP8RY7dEnrv6aWwzwYGFfTsd1zhFRZ1wHkDNmk/Kyb4 2nvbYdK3Ji1cIjtg0RlCt/vZbBPd5WU8bSaPmOFKMV7Ym4Su4ehlNWO7n k7DV4YW9Fgi4EfcvRKeWUw6ryWZAZz4ATkoJSjQ9da1BAyv0U7UbUhWnt kN4yvv4K75ltez7KLWPNSGJmXTmZ2Mg7d5a8OTUaCL3Lu2p1WSE3rsWS3 g==; X-IronPort-AV: E=McAfee;i="6500,9779,10608"; a="355654307" X-IronPort-AV: E=Sophos;i="5.97,266,1669104000"; d="scan'208";a="355654307" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Feb 2023 17:08:16 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10608"; a="665087925" X-IronPort-AV: E=Sophos;i="5.97,266,1669104000"; d="scan'208";a="665087925" Received: from spandruv-desk.jf.intel.com ([10.54.75.8]) by orsmga002.jf.intel.com with ESMTP; 01 Feb 2023 17:08:15 -0800 From: Srinivas Pandruvada To: hdegoede@redhat.com, markgross@kernel.org Cc: platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org, Srinivas Pandruvada , "David E . Box" Subject: [PATCH 2/7] platform/x86/intel/vsec: Enhance and Export intel_vsec_add_aux() Date: Wed, 1 Feb 2023 17:07:33 -0800 Message-Id: <20230202010738.2186174-3-srinivas.pandruvada@linux.intel.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230202010738.2186174-1-srinivas.pandruvada@linux.intel.com> References: <20230202010738.2186174-1-srinivas.pandruvada@linux.intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,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-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756679622161801987?= X-GMAIL-MSGID: =?utf-8?q?1756679622161801987?= Remove static for intel_vsec_add_aux() and export this interface so that it can be used by other vsec related modules. This driver creates aux devices by parsing PCI-VSEC, which allows individual drivers to load on those devices. Those driver may further create more devices on aux bus by parsing the PCI MMIO region. For example, TPMI (Topology Aware Register and PM Capsule Interface) creates device nodes for power management features by parsing MMIO region. When TPMI driver creates devices, it can reuse existing function intel_vsec_add_aux() to create aux devices with TPMI device as the parent. Signed-off-by: Srinivas Pandruvada Acked-by: David E. Box --- drivers/platform/x86/intel/vsec.c | 16 +++++++++++----- drivers/platform/x86/intel/vsec.h | 4 ++++ 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/drivers/platform/x86/intel/vsec.c b/drivers/platform/x86/intel/vsec.c index a82b2a5ed99d..b936fc5776d7 100644 --- a/drivers/platform/x86/intel/vsec.c +++ b/drivers/platform/x86/intel/vsec.c @@ -138,8 +138,9 @@ static void intel_vsec_dev_release(struct device *dev) kfree(intel_vsec_dev); } -static int intel_vsec_add_aux(struct pci_dev *pdev, struct intel_vsec_device *intel_vsec_dev, - const char *name) +int intel_vsec_add_aux(struct pci_dev *pdev, struct device *parent, + struct intel_vsec_device *intel_vsec_dev, + const char *name) { struct auxiliary_device *auxdev = &intel_vsec_dev->auxdev; int ret, id; @@ -150,9 +151,12 @@ static int intel_vsec_add_aux(struct pci_dev *pdev, struct intel_vsec_device *in return ret; } + if (!parent) + parent = &pdev->dev; + auxdev->id = ret; auxdev->name = name; - auxdev->dev.parent = &pdev->dev; + auxdev->dev.parent = parent; auxdev->dev.release = intel_vsec_dev_release; ret = auxiliary_device_init(auxdev); @@ -169,7 +173,7 @@ static int intel_vsec_add_aux(struct pci_dev *pdev, struct intel_vsec_device *in return ret; } - ret = devm_add_action_or_reset(&pdev->dev, intel_vsec_remove_aux, + ret = devm_add_action_or_reset(parent, intel_vsec_remove_aux, auxdev); if (ret < 0) return ret; @@ -182,6 +186,7 @@ static int intel_vsec_add_aux(struct pci_dev *pdev, struct intel_vsec_device *in return 0; } +EXPORT_SYMBOL_NS_GPL(intel_vsec_add_aux, INTEL_VSEC); static int intel_vsec_add_dev(struct pci_dev *pdev, struct intel_vsec_header *header, struct intel_vsec_platform_info *info) @@ -239,7 +244,8 @@ static int intel_vsec_add_dev(struct pci_dev *pdev, struct intel_vsec_header *he else intel_vsec_dev->ida = &intel_vsec_ida; - return intel_vsec_add_aux(pdev, intel_vsec_dev, intel_vsec_name(header->id)); + return intel_vsec_add_aux(pdev, NULL, intel_vsec_dev, + intel_vsec_name(header->id)); } static bool intel_vsec_walk_header(struct pci_dev *pdev, diff --git a/drivers/platform/x86/intel/vsec.h b/drivers/platform/x86/intel/vsec.h index 3deeb05cf394..d02c340fd458 100644 --- a/drivers/platform/x86/intel/vsec.h +++ b/drivers/platform/x86/intel/vsec.h @@ -40,6 +40,10 @@ struct intel_vsec_device { int num_resources; }; +int intel_vsec_add_aux(struct pci_dev *pdev, struct device *parent, + struct intel_vsec_device *intel_vsec_dev, + const char *name); + static inline struct intel_vsec_device *dev_to_ivdev(struct device *dev) { return container_of(dev, struct intel_vsec_device, auxdev.dev);