From patchwork Mon Apr 16 06:35:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pingfan Liu X-Patchwork-Id: 898481 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 40Pf1y6PVJz9s1l for ; Mon, 16 Apr 2018 16:42:14 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="FyHEU2Ex"; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 40Pf1y4xMVzDrq2 for ; Mon, 16 Apr 2018 16:42:14 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="FyHEU2Ex"; dkim-atps=neutral X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:400e:c01::242; helo=mail-pl0-x242.google.com; envelope-from=kernelfans@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="FyHEU2Ex"; dkim-atps=neutral Received: from mail-pl0-x242.google.com (mail-pl0-x242.google.com [IPv6:2607:f8b0:400e:c01::242]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 40Pdt51yVMzF1t4 for ; Mon, 16 Apr 2018 16:35:25 +1000 (AEST) Received: by mail-pl0-x242.google.com with SMTP id w12-v6so8545989plp.0 for ; Sun, 15 Apr 2018 23:35:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=hUFamUr718bZ8Yu4vbGwuwWXqCP57ToTluJIDV3Qxkk=; b=FyHEU2Ex+bGxIhcTjAfCqPRYq9XV0jbo9XZvWprN9IzJtNImbySyUDW63TCVbAJqeu 7r2HhjYBJmMQyA9+Pa9mkZyZ+TDMHG8eG0FTqbR/Xw4RuAoV1kE6veNBKkWQMkyyE1uO PWjk6h2vkKecmX5tB1BnHvESChS6Wl1uwxiu/gjTa8QOlYLtUhd8ev/NhQJKgYIN7Rkh ipz1brC0LPPznhTPXaC+W5qkaUTbquc0+37lzKqxuRayr6IqgHpwheoyVAxn3NOSKMoz FpV7JlbSBUJngYDHBoCZFLlt7dePs09C6hnAF+zR9XeQkHeQmfypNWDj+bwJsjuU0uhG TUmw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=hUFamUr718bZ8Yu4vbGwuwWXqCP57ToTluJIDV3Qxkk=; b=siehIUGMZcfz1tAQyOpXtqv0z99bZVM4ORR5mI6e+7ZdwtE5yCQ2EgfKmCsoWfqYLx j+ESsUh4zE/EjmF0NWd29iYtSirECG3tpR8ZuwHvtfWs4UvT76UPHnzqSEmbEpREos4C /d6/9LyAjI2eDxsBQu1naMVrB0w/9jTUN/Myy5GXg+a8Ra+snlWhXvydmVniHR95sWWu /WgOFh3+ubtG4EQTb33mD/GbRyMEbfHqjKHSTpRqlFwM28KdbMs/qaIF0IVx8y99v2Vg 9dufDaXgjn/bm4ZosyYJCEZcE+hTNvt3PznvTN6WhXuWisqd9LPxC3ka0hTC1L/nHEqy 9n8Q== X-Gm-Message-State: ALQs6tA1zpQKa2nTc7q+Ybdmv7Oyj/jqddmNTHo264HJD/0Kdhe0qwbI c5leRc6kyoL6Iq8OAD0YP6Ui X-Google-Smtp-Source: AIpwx49+XJGe2ODJ06kdpAdeu84809pxIsUAptqVDn+93hDpTqbJkjX9WxoAFx/klmd236jSBSULgg== X-Received: by 2002:a17:902:7d92:: with SMTP id a18-v6mr14343562plm.331.1523860523393; Sun, 15 Apr 2018 23:35:23 -0700 (PDT) Received: from mylaptop.nay.redhat.com ([209.132.188.80]) by smtp.gmail.com with ESMTPSA id u19sm10111187pfg.96.2018.04.15.23.35.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 15 Apr 2018 23:35:22 -0700 (PDT) From: Pingfan Liu To: linuxppc-dev@lists.ozlabs.org Subject: [PATCHv2 2/3] powerpc/cpu: dynmamically to create/destroy the file physical_id during hotplug Date: Mon, 16 Apr 2018 14:35:07 +0800 Message-Id: <1523860508-19364-3-git-send-email-kernelfans@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1523860508-19364-1-git-send-email-kernelfans@gmail.com> References: <1523860508-19364-1-git-send-email-kernelfans@gmail.com> X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Hari Bathini , Paul Mackerras Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" In order to cope with the incoming patch [3/3], which causes the dir /sys/../cpuX is created/destroyed during hotplug, we also need to create the file cpuX/physical_id dynamically. Signed-off-by: Pingfan Liu Reported-by: Hari Bathini Reviewed-by: Hari Bathini --- arch/powerpc/kernel/sysfs.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/arch/powerpc/kernel/sysfs.c b/arch/powerpc/kernel/sysfs.c index 04d0bbd..a05ab5e 100644 --- a/arch/powerpc/kernel/sysfs.c +++ b/arch/powerpc/kernel/sysfs.c @@ -716,6 +716,16 @@ static struct device_attribute pa6t_attrs[] = { #endif /* HAS_PPC_PMC_PA6T */ #endif /* HAS_PPC_PMC_CLASSIC */ +/* Only valid if CPU is present. */ +static ssize_t show_physical_id(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct cpu *cpu = container_of(dev, struct cpu, dev); + + return sprintf(buf, "%d\n", get_hard_smp_processor_id(cpu->dev.id)); +} +static DEVICE_ATTR(physical_id, 0444, show_physical_id, NULL); + static int register_cpu_online(unsigned int cpu) { struct cpu *c = &per_cpu(cpu_devices, cpu); @@ -723,6 +733,8 @@ static int register_cpu_online(unsigned int cpu) struct device_attribute *attrs, *pmc_attrs; int i, nattrs; + device_create_file(&c->dev, &dev_attr_physical_id); + /* For cpus present at boot a reference was already grabbed in register_cpu() */ if (!s->of_node) s->of_node = of_get_cpu_node(cpu, NULL); @@ -816,6 +828,7 @@ static int unregister_cpu_online(unsigned int cpu) BUG_ON(!c->hotpluggable); + device_remove_file(s, &dev_attr_physical_id); #ifdef CONFIG_PPC64 if (cpu_has_feature(CPU_FTR_SMT)) device_remove_file(s, &dev_attr_smt_snooze_delay); @@ -1017,16 +1030,6 @@ static void register_nodes(void) #endif -/* Only valid if CPU is present. */ -static ssize_t show_physical_id(struct device *dev, - struct device_attribute *attr, char *buf) -{ - struct cpu *cpu = container_of(dev, struct cpu, dev); - - return sprintf(buf, "%d\n", get_hard_smp_processor_id(cpu->dev.id)); -} -static DEVICE_ATTR(physical_id, 0444, show_physical_id, NULL); - static int __init topology_init(void) { int cpu, r; @@ -1049,7 +1052,6 @@ static int __init topology_init(void) if (cpu_online(cpu) || c->hotpluggable) { register_cpu(c, cpu); - device_create_file(&c->dev, &dev_attr_physical_id); } } r = cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, "powerpc/topology:online",