Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp4300390rdb; Thu, 14 Sep 2023 19:38:13 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHbS22QjC08odCDv5nLn0IqRLKQ9Vs5JfJ5RsxeYjmlXU7GZWgX5vZnpndENR/yrcbZxBpc X-Received: by 2002:a05:6a00:1a86:b0:68f:bbc3:df44 with SMTP id e6-20020a056a001a8600b0068fbbc3df44mr556797pfv.0.1694745493183; Thu, 14 Sep 2023 19:38:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694745493; cv=none; d=google.com; s=arc-20160816; b=0x6eS99YbRd64cz/Ds23Gf6NyIW1+AgfrqaMSq7mp1Gkf5QvYgMKs4vXOk9r6/1VqC hWWb/F4NmJUUYTc4GNLdDbLGuHUN/gWR8+WGzAZJ4ih+nVUGVhN9r3oAEvdI/H118U4X T7myYmQZRFR5URNsKxI15eiU2Ow6AKML55l/G7QYu74ZcgtCj0qHg+39DU+fPU30Q154 I95bhFVvq2Bv7rkJ3Hpz/0XRK3NbyTrOsJbZPF96EggSJZ+kAIcS8ASa8Xen/Ncymp25 tp+kpMpwJp8cMSPHoUyy31QcwpddYtgQs/4B0kBlkGT/b8urs/+gCRY8aEl94/sO2FLf Vg+g== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=RzuuSbvQBu+IbXhqgSc/Jh1UYlftCrb0q8uG/spw850=; fh=pQcR6wP3nWQ9dpk9SPUjbUfMn/B6NE6eLFBvyslW3BE=; b=cvTMRkgy7I9fLAoWyntJJ97GzUlO4SkXQ7fKsR8XGaQrjX949Z2W7l8ecry1jFrTz5 ltjWX4y3Z/LjUS3UBSpQX13c9i10ls54rNJH6KnNtvCnMM3fLvvs6At5zkY7G2A2Sn1m psg3YAx2xgPFK+65LpHsSQZgpHZC0V4mvTQAmAGSPiGacjSVKz5SnWFt78r7JBXEx/ff TuXeiP8YehI9CE2VaYjreO9I5Jli5hnwE1ys0Y4Xzh6mHQyoWYRKn8Zodu7F7hOej/6Q sdfjaS50X9HDSR4LmUHBq6V1hn4XCflyNwhJUbVVVfNMoYvBnslf8OgDTc4z3qV64iBu oQEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=JHd7C4CH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Return-Path: Received: from morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id z2-20020a056a001d8200b0068e3f55075esi2463754pfw.134.2023.09.14.19.38.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 19:38:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=JHd7C4CH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 07D64836E266; Thu, 14 Sep 2023 14:32:25 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229472AbjINVcW (ORCPT + 99 others); Thu, 14 Sep 2023 17:32:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37358 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229561AbjINVcV (ORCPT ); Thu, 14 Sep 2023 17:32:21 -0400 Received: from mail-pf1-x429.google.com (mail-pf1-x429.google.com [IPv6:2607:f8b0:4864:20::429]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B9B682703 for ; Thu, 14 Sep 2023 14:31:57 -0700 (PDT) Received: by mail-pf1-x429.google.com with SMTP id d2e1a72fcca58-68fe2470d81so1277139b3a.1 for ; Thu, 14 Sep 2023 14:31:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1694727117; x=1695331917; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=RzuuSbvQBu+IbXhqgSc/Jh1UYlftCrb0q8uG/spw850=; b=JHd7C4CHjojVY6NuvrQbpLPpDuNxTaKWajQQni7xtxPZM7i575U+m6QfjtKI5OtUDu U7S1iYQmUyWz6ZtWHJhIv2FFEXoPPkNXjKgSzv34/LULtMR8vxKjHm0R0PtqvF5+t/9y yfQIqY227ERqh9fVqSLOzcId4pA211TyySUn2zCEi5omiwFwwiqkI6AXFFJVrJyQYpdS F+u3uiGR8qr3hrs11LUsmMantcGyg7Vdxzj9WaDrtHFoUpNUrB+xSJ5CGofjib5bs1iA gujpisWDZ1V8nyu+sMdEzoV829Fw0qwNON+KDr9w5mWhfyJO+6R0EYT2E7svEfnv13EF eI5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694727117; x=1695331917; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=RzuuSbvQBu+IbXhqgSc/Jh1UYlftCrb0q8uG/spw850=; b=VyEHgiE91lzY3bJYx1w7fr+dVTMdywKOeHdMptBjDQ2nq0bTskRpFie7q0dXJCwPUG Ypg84JFKdz+LAah4aPZBFT/ttGVwcq1J0XBeakHxZWE0D7GJAWZQniBTmGTk3OLuu/ur gR2JynkSR9yccwsEEOrixX5sdVCip9ZWXEMUkbhMzS/jj+ELEXhRZVoy7ZosXW/SWrDy 5Avg6RnqkL7YIIFCZ8wlPLJdTUCXXWlowYzSvvSuPDSoeKP2NrpgpYchP3oyHHetm/L6 LNLGwBbzwhbjy9NwbTIkKcNsvVIeh5z2m9uL2B0RoB0tnSzmkffaK/zg/Co5jNammDfg 6nrg== X-Gm-Message-State: AOJu0YzKWwMSPRNIJe48gwJWf3m8jwLHri/pP6908F5Wu0C02+kQPYZn A/CQDyjA3zI5myUAsuQ/NtaoNytlN33b6DPE9To= X-Received: by 2002:a05:6300:808d:b0:153:591b:4101 with SMTP id ap13-20020a056300808d00b00153591b4101mr5564711pzc.49.1694727117223; Thu, 14 Sep 2023 14:31:57 -0700 (PDT) Received: from PF2LML5M-SMJ.lan ([49.7.199.134]) by smtp.gmail.com with ESMTPSA id em19-20020a17090b015300b00273fc850342sm3590801pjb.20.2023.09.14.14.31.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 14:31:56 -0700 (PDT) From: Jinhui Guo To: rafael@kernel.org, lenb@kernel.org, gregkh@linuxfoundation.org Cc: lizefan.x@bytedance.com, linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, Jinhui Guo , stable@vger.kernel.org, kernel test robot Subject: [PATCH v5] driver core: platform: set numa_node before platform_add_device() Date: Fri, 15 Sep 2023 05:31:48 +0800 Message-Id: <20230914213148.3560-1-guojinhui.liam@bytedance.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 (morse.vger.email [0.0.0.0]); Thu, 14 Sep 2023 14:32:25 -0700 (PDT) X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email platform_add_device() creates the numa_node attribute of sysfs according to whether dev_to_node(dev) is equal to NUMA_NO_NODE. So set the numa node of device before creating numa_node attribute of sysfs. Fixes: 4a60406d3592 ("driver core: platform: expose numa_node to users in sysfs") Cc: stable@vger.kernel.org Reported-by: kernel test robot Closes: https://lore.kernel.org/oe-kbuild-all/202309122309.mbxAnAIe-lkp@intel.com/ Signed-off-by: Jinhui Guo --- V4 -> V5: Add Cc: stable line and changes from the previous submited patches V3 -> V4: Refactor code to be an ACPI function call V2 -> V3: Fix Signed-off name V1 -> V2: Fix compile error without enabling CONFIG_ACPI drivers/acpi/acpi_platform.c | 4 +--- drivers/base/platform.c | 1 + include/linux/acpi.h | 5 +++++ 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/drivers/acpi/acpi_platform.c b/drivers/acpi/acpi_platform.c index 48d15dd785f6..adcbfbdc343f 100644 --- a/drivers/acpi/acpi_platform.c +++ b/drivers/acpi/acpi_platform.c @@ -178,11 +178,9 @@ struct platform_device *acpi_create_platform_device(struct acpi_device *adev, if (IS_ERR(pdev)) dev_err(&adev->dev, "platform device creation failed: %ld\n", PTR_ERR(pdev)); - else { - set_dev_node(&pdev->dev, acpi_get_node(adev->handle)); + else dev_dbg(&adev->dev, "created platform device %s\n", dev_name(&pdev->dev)); - } kfree(resources); diff --git a/drivers/base/platform.c b/drivers/base/platform.c index 76bfcba25003..35c891075d95 100644 --- a/drivers/base/platform.c +++ b/drivers/base/platform.c @@ -841,6 +841,7 @@ struct platform_device *platform_device_register_full( goto err; } + set_dev_node(&pdev->dev, ACPI_NODE_GET(ACPI_COMPANION(&pdev->dev))); ret = platform_device_add(pdev); if (ret) { err: diff --git a/include/linux/acpi.h b/include/linux/acpi.h index a73246c3c35e..6a349d53f19e 100644 --- a/include/linux/acpi.h +++ b/include/linux/acpi.h @@ -477,6 +477,10 @@ static inline int acpi_get_node(acpi_handle handle) return 0; } #endif + +#define ACPI_NODE_GET(adev) ((adev) && (adev)->handle ? \ + acpi_get_node((adev)->handle) : NUMA_NO_NODE) + extern int pnpacpi_disabled; #define PXM_INVAL (-1) @@ -770,6 +774,7 @@ const char *acpi_get_subsystem_id(acpi_handle handle); #define ACPI_COMPANION_SET(dev, adev) do { } while (0) #define ACPI_HANDLE(dev) (NULL) #define ACPI_HANDLE_FWNODE(fwnode) (NULL) +#define ACPI_NODE_GET(adev) NUMA_NO_NODE #include -- 2.20.1