From patchwork Sun Dec 31 17:30:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 759242 Received: from mail-lf1-f51.google.com (mail-lf1-f51.google.com [209.85.167.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E9F738F57 for ; Sun, 31 Dec 2023 17:31:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="EZJCzGpq" Received: by mail-lf1-f51.google.com with SMTP id 2adb3069b0e04-50e78f1f41fso5225537e87.2 for ; Sun, 31 Dec 2023 09:31:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1704043859; x=1704648659; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=KpTNKk8wKE3bGmO15Z42fFt5aqX74H0FvDnsTf/kF6g=; b=EZJCzGpqQ1p8WedLDNoJEPxlq25P7e48YW8LxNKPtK9VAXMOTo0FCEGwDNAmNDI+k2 YOosY2z8Sbgz8CPioqkPI23zYJvOy7X+RQGMIUX4iFkdzLze+OjlQrLVm0Sx2esSHL9g LRy2QE40CFGLTrq+U2nuDHEqXRBPuEQpjQPW9blCRv5OkCkVm6pwU1OYMRDJ5CLuWua2 gL94joj4w2kMddSsV6IEph9KTqxQBBn9jOfWfZfkIoRvi2wirG5X22H0wssTQbMzjYeS C0i/7PGO9GRj+ROpwbLrDgFuW/KPgA/RPhUWmiJ1hYb1C5jieiLqVmhhh4oRwVI3LWcA xA0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704043859; x=1704648659; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=KpTNKk8wKE3bGmO15Z42fFt5aqX74H0FvDnsTf/kF6g=; b=EL25L53fFF7ae51nDM+7n+4MwOyId6c5me8zwf40aiYAeXtsbyIGZJgfpz1l4C/yO7 H9X5c6rxofD2KtbmhPXAvAj0ke2vRCqFW/fUi+6McQo9e5VcoFIcVYfuQ3/3LQNiVlAB 4ZlTv4+iKFC/hnyL67z8DEY9lQs4JSgU8iogMh2qLyw4Cr775sdSRGZcdz8pi/o9+yQt 4gbRs3ELgfAIfFtnQIsT8aQ2ghY8lGrAyFtXjkfruiCthxiEKM95FGpgXvEjaciZ/Oba pCQN3fFG2c/9oxoiAGZiEZ9v6qTYmgruGL6ofgAEcp1rL8fylgFge7lmoROEXePNb/5k 8HPQ== X-Gm-Message-State: AOJu0YxzyOnk9/sxALAj2s+Qnz3JuDnux77hKP/3/j6Uncn0Ey5lsA7h cSia8eNhyqUKZJVYGGp36pYxOgLRXjhJtVU39vKMYntcfZFDog== X-Google-Smtp-Source: AGHT+IENoo22xZd0OQJGp2+i4gXTX40/3BcU1jdwTsSIBXQX4/aJ+f8F1UkMoJhVSv8Gv6Gp1OQcPw== X-Received: by 2002:a05:6512:108d:b0:50e:86af:97e3 with SMTP id j13-20020a056512108d00b0050e86af97e3mr3424089lfg.76.1704043858623; Sun, 31 Dec 2023 09:30:58 -0800 (PST) Received: from umbar.lan ([192.130.178.91]) by smtp.gmail.com with ESMTPSA id k1-20020ac257c1000000b0050e6b5228d3sm2754645lfo.304.2023.12.31.09.30.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 31 Dec 2023 09:30:57 -0800 (PST) From: Dmitry Baryshkov Date: Sun, 31 Dec 2023 19:30:56 +0200 Subject: [PATCH 1/2] cpu: allow matching cpu_subsys devices against OF nodes Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20231231-cpu-cacheinfo-of-v1-1-cd3584d2c7b4@linaro.org> References: <20231231-cpu-cacheinfo-of-v1-0-cd3584d2c7b4@linaro.org> In-Reply-To: <20231231-cpu-cacheinfo-of-v1-0-cd3584d2c7b4@linaro.org> To: Greg Kroah-Hartman , "Rafael J. Wysocki" , Thomas Gleixner , Peter Zijlstra , Rob Herring Cc: linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, Dmitry Baryshkov X-Mailer: b4 0.12.4 X-Developer-Signature: v=1; a=openpgp-sha256; l=4075; i=dmitry.baryshkov@linaro.org; h=from:subject:message-id; bh=Ehv6GDEdCHawMog1wnKBhOB1sHxHki22fxkxD9ai0tc=; b=owEBbQGS/pANAwAKAYs8ij4CKSjVAcsmYgBlkaVQazLVjIx8wxs0/MWfqPVsLl+jgCPjd8r1A diEZ0OZSc+JATMEAAEKAB0WIQRMcISVXLJjVvC4lX+LPIo+Aiko1QUCZZGlUAAKCRCLPIo+Aiko 1SgzB/4scjIO/y2psHuNY5d/EHQIZnXizgNLH1YUBDwLJsUZqNP09yiAe6nfWqnkxLO066rEiLP WOYHikm5RqbTuJxSUFJBMojUt1JJ/1dnDyD96ukr2Si8KVY4qtcIRgi9whCuZ48Rx5ismof/MyS BmzzSyn6Xr6PJLzIvlACfswp9kuCW+m0PaHNxUk3eFrEK2TeIkw2IJ0kZ++mKS9uBIdLCIT5QmX XvwHwgeAEuOSOBbpWV2+zzitwPAa3Ymy98XT97KiC8mHxwynwemjQr+1urNC8XwUIJCVCZuUN5Q fdKktIyhdU40Fjo709jORg8B4frgnabVD76QjVdfq4W2cvJD X-Developer-Key: i=dmitry.baryshkov@linaro.org; a=openpgp; fpr=8F88381DD5C873E4AE487DA5199BF1243632046A Currently cpu_sybsys devices support only ACPI style matching. Pass DT node pointer to cpu_device_create to support OF style matching for cpu_subsys devices. Signed-off-by: Dmitry Baryshkov --- drivers/base/cacheinfo.c | 6 ++++-- drivers/base/cpu.c | 15 ++++++++++++--- include/linux/cpu.h | 3 ++- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/drivers/base/cacheinfo.c b/drivers/base/cacheinfo.c index f1e79263fe61..a72c69e70fa3 100644 --- a/drivers/base/cacheinfo.c +++ b/drivers/base/cacheinfo.c @@ -845,7 +845,7 @@ static int cpu_cache_sysfs_init(unsigned int cpu) if (per_cpu_cacheinfo(cpu) == NULL) return -ENOENT; - per_cpu_cache_dev(cpu) = cpu_device_create(dev, NULL, NULL, "cache"); + per_cpu_cache_dev(cpu) = cpu_device_create(dev, NULL, NULL, NULL, "cache"); if (IS_ERR(per_cpu_cache_dev(cpu))) return PTR_ERR(per_cpu_cache_dev(cpu)); @@ -882,7 +882,9 @@ static int cache_add_dev(unsigned int cpu) if (this_leaf->type == CACHE_TYPE_NOCACHE) break; cache_groups = cache_get_attribute_groups(this_leaf); - ci_dev = cpu_device_create(parent, this_leaf, cache_groups, + ci_dev = cpu_device_create(parent, this_leaf, + NULL, + cache_groups, "index%1u", i); if (IS_ERR(ci_dev)) { rc = PTR_ERR(ci_dev); diff --git a/drivers/base/cpu.c b/drivers/base/cpu.c index 47de0f140ba6..d7db38fbfc17 100644 --- a/drivers/base/cpu.c +++ b/drivers/base/cpu.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -28,7 +29,11 @@ static DEFINE_PER_CPU(struct device *, cpu_sys_devices); static int cpu_subsys_match(struct device *dev, struct device_driver *drv) { - /* ACPI style match is the only one that may succeed. */ + /* Attempt an OF style match first */ + if (of_driver_match_device(dev, drv)) + return 1; + + /* Then try ACPI style match */ if (acpi_driver_match_device(dev, drv)) return 1; @@ -428,12 +433,14 @@ EXPORT_SYMBOL_GPL(get_cpu_device); static void device_create_release(struct device *dev) { + of_node_put(dev->of_node); kfree(dev); } -__printf(4, 0) +__printf(5, 0) static struct device * __cpu_device_create(struct device *parent, void *drvdata, + struct device_node *np, const struct attribute_group **groups, const char *fmt, va_list args) { @@ -447,6 +454,7 @@ __cpu_device_create(struct device *parent, void *drvdata, device_initialize(dev); dev->parent = parent; dev->groups = groups; + dev->of_node = of_node_get(np); dev->release = device_create_release; device_set_pm_not_required(dev); dev_set_drvdata(dev, drvdata); @@ -467,6 +475,7 @@ __cpu_device_create(struct device *parent, void *drvdata, } struct device *cpu_device_create(struct device *parent, void *drvdata, + struct device_node *np, const struct attribute_group **groups, const char *fmt, ...) { @@ -474,7 +483,7 @@ struct device *cpu_device_create(struct device *parent, void *drvdata, struct device *dev; va_start(vargs, fmt); - dev = __cpu_device_create(parent, drvdata, groups, fmt, vargs); + dev = __cpu_device_create(parent, drvdata, np, groups, fmt, vargs); va_end(vargs); return dev; } diff --git a/include/linux/cpu.h b/include/linux/cpu.h index dcb89c987164..6ae291080e4a 100644 --- a/include/linux/cpu.h +++ b/include/linux/cpu.h @@ -76,8 +76,9 @@ extern ssize_t cpu_show_spec_rstack_overflow(struct device *dev, extern ssize_t cpu_show_gds(struct device *dev, struct device_attribute *attr, char *buf); -extern __printf(4, 5) +extern __printf(5, 6) struct device *cpu_device_create(struct device *parent, void *drvdata, + struct device_node *np, const struct attribute_group **groups, const char *fmt, ...); extern bool arch_cpu_is_hotpluggable(int cpu);