From patchwork Thu Mar 16 15:38:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zhang, Rui" X-Patchwork-Id: 70876 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:604a:0:0:0:0:0 with SMTP id j10csp561833wrt; Thu, 16 Mar 2023 08:58:30 -0700 (PDT) X-Google-Smtp-Source: AK7set/mp+IYffxWnvgr1zVJlIfedcJjyxnvxqm6LgbL8fAfBXTdjCAMGzQmhfaIpXABl8+QLTu0 X-Received: by 2002:a05:6a20:bab0:b0:d0:4361:9723 with SMTP id fb48-20020a056a20bab000b000d043619723mr3971205pzb.22.1678982309716; Thu, 16 Mar 2023 08:58:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1678982309; cv=none; d=google.com; s=arc-20160816; b=rStukN+4BSEjMQlU52hH6cphKwvCVWipfbg8yD0BvN3ZzwEGY0rUNM+J88/6AUCm1g Y7ilMJoy84zdJ2COcxjIeUy/8O2q49DVfHxFzEeO1Te8tT0eulv5QLofZ0ixj7hraoHH EDbD+q7lnhwNkSmksR8LlkJGbaVVnLx6LXhqheY4KzAVbaHQ0rovv8UplxHtXNVJIh+9 y/Q4ZRxri7MJBySXYGyOaPmttjhvzMnqkqgJtLYtSS5aWeoV7eAmO5zBCRg4KcPrffex 6huYlkCajR+2dTrsODvVUTEC6p9h/7fvRSmXKSxdnOHEQ201BD68RovJpwnMH1DexLu+ XbIw== 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=PrM/jRF8/EAJj1by4nBB98DfRrly8W0X47hDn9H6duU=; b=BnPUBCeZShcZRhu8yTfFfh/oGnT/4YQEh4OlN1W2uiywevfqc5sLZ86BiOZVrScf5H sLEYlP509eyySq8yxKqFPZM7sGUY4BQ18FtiFTe+giDA+82cXLqE54JqUAN9qFNUOUZO qM6ClQF3hlC/w6W0NXh18sb82MzElaJCWxgWqUlCQpJ0VmFXH1V5AdskXfZaG+HJR4F4 S0QUvjRD8dPCojZBNsy1tz9ZETFNX39YQCAnPePu3lv5VXkscxf0R7yZpB31PaQL6tOI f0Ze2nftqM69gfPET+hE0q6XzcDqLGJ9N25QEMPIv2LDhj6BLqA3m4R+YACEIGu3Ka3F kBIQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=CbzBLRk8; 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 v28-20020aa799dc000000b00625683e6d41si6000004pfi.343.2023.03.16.08.58.15; Thu, 16 Mar 2023 08:58:29 -0700 (PDT) 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=CbzBLRk8; 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 S229890AbjCPPli (ORCPT + 99 others); Thu, 16 Mar 2023 11:41:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53976 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231523AbjCPPlM (ORCPT ); Thu, 16 Mar 2023 11:41:12 -0400 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 53CABE1924; Thu, 16 Mar 2023 08:40:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1678981232; x=1710517232; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=a5MNbpYbKfb3nVRQzqabf7Y+DsBQlBga7mJL/qjGgpg=; b=CbzBLRk84kM6nTeUFanvGHU7pI9Fw7/ULYjsBf2aSPA+yorIAKh0jd3x aly//T0BQErvMyggk9NJWQMNLSqbcWdhYdrAVQMHJhwfrCtHSk16b6mCJ Vhb7r27yv3niStH9daExTFqZx1vZ5Q2yC1Cc9g8cbevgYE9ZRWvJ9qfxl dpagcfcCXilAVwTLlttTCZjtV2B0evcQRHztjQY47f1QkpIaNaj1IDSbN +6q44qCGPh4syEkPEYUvICaYNTMFsXjOVZIERKfG9w63NFuYT8e5zWiJo gyw7ykdtSRSuKhFESHp2E7R8Kkia009CQNYcRJJiGP6hgjbDe6haYNZqC Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10651"; a="339570953" X-IronPort-AV: E=Sophos;i="5.98,265,1673942400"; d="scan'208";a="339570953" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Mar 2023 08:38:53 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10651"; a="1009266968" X-IronPort-AV: E=Sophos;i="5.98,265,1673942400"; d="scan'208";a="1009266968" Received: from feiwang3-mobl2.ccr.corp.intel.com (HELO rzhang1-DESK.intel.com) ([10.249.170.93]) by fmsmga005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Mar 2023 08:38:52 -0700 From: Zhang Rui To: linux-pm@vger.kernel.org, rafael.j.wysocki@intel.com, daniel.lezcano@linaro.org Cc: linux-kernel@vger.kernel.org, srinivas.pandruvada@intel.com Subject: [PATCH 02/15] powercap/intel_rapl: Allow probing without CPUID match Date: Thu, 16 Mar 2023 23:38:28 +0800 Message-Id: <20230316153841.3666-3-rui.zhang@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230316153841.3666-1-rui.zhang@intel.com> References: <20230316153841.3666-1-rui.zhang@intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,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?1760540554392032281?= X-GMAIL-MSGID: =?utf-8?q?1760540554392032281?= Currently, CPU model checks is used to 1. get proper rapl_defaults callbacks for RAPL MSR/MMIO Interface. 2. create a platform device node for the intel_rapl_msr driver to probe. Both of these are only mandatory for the RAPL MSR/MMIO Interface. Make the CPUID match optional. Signed-off-by: Zhang Rui --- drivers/powercap/intel_rapl_common.c | 35 +++++++++++----------------- 1 file changed, 14 insertions(+), 21 deletions(-) diff --git a/drivers/powercap/intel_rapl_common.c b/drivers/powercap/intel_rapl_common.c index 8970c7b80884..2d2c15eea8eb 100644 --- a/drivers/powercap/intel_rapl_common.c +++ b/drivers/powercap/intel_rapl_common.c @@ -1528,32 +1528,25 @@ static int __init rapl_init(void) int ret; id = x86_match_cpu(rapl_ids); - if (!id) { - pr_err("driver does not support CPU family %d model %d\n", - boot_cpu_data.x86, boot_cpu_data.x86_model); + if (id) { + rapl_defaults = (struct rapl_defaults *)id->driver_data; - return -ENODEV; - } - - rapl_defaults = (struct rapl_defaults *)id->driver_data; - - ret = register_pm_notifier(&rapl_pm_notifier); - if (ret) - return ret; + rapl_msr_platdev = platform_device_alloc("intel_rapl_msr", 0); + if (!rapl_msr_platdev) + return -ENOMEM; - rapl_msr_platdev = platform_device_alloc("intel_rapl_msr", 0); - if (!rapl_msr_platdev) { - ret = -ENOMEM; - goto end; + ret = platform_device_add(rapl_msr_platdev); + if (ret) { + platform_device_put(rapl_msr_platdev); + return ret; + } } - ret = platform_device_add(rapl_msr_platdev); - if (ret) + ret = register_pm_notifier(&rapl_pm_notifier); + if (ret && rapl_msr_platdev) { + platform_device_del(rapl_msr_platdev); platform_device_put(rapl_msr_platdev); - -end: - if (ret) - unregister_pm_notifier(&rapl_pm_notifier); + } return ret; }