Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp5121260ybl; Tue, 10 Dec 2019 00:28:08 -0800 (PST) X-Google-Smtp-Source: APXvYqzP9tc1b/Fl+9zK3ltplQ5rBbgNm881Irw57/5bvfx3rYeXL4AIHTzRse14tpc5D47g9K99 X-Received: by 2002:aca:5117:: with SMTP id f23mr2643298oib.50.1575966488520; Tue, 10 Dec 2019 00:28:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575966488; cv=none; d=google.com; s=arc-20160816; b=SnUUL66SIvVnke8a1SnDdLg9cCmCgS5VtfUD7Pi4U4gjS0O9MElt631OcGNX0mnpM1 6SHdc1QHzPf6706h863FQxwvbtHkUNLPN4Hew/g3/TVXY5A8b1xF+2ZXK69jXV1ePqDK XMJvYokANfG/srH1bKP3QWl7P6Ci12C6PipTzyFfhxnz5wBpMcGHwZxl1dUKA5CYJ6wr 9+Vtk2nmpZVaFYb7gDtCLUxZOqyckKrcc15wXwLbEeNVQN+zBSRqedw42uHZMQAHotXm GmoFwK8i3+SrMAdmda646FUr6lDBwxDidKvfSvV3s8VNaio6SLrZzhG2U6cNpCpKsDA8 gjRg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version; bh=BX8/IGebb3UQLoc8g0MqAatjMar/ymE4GzyE+cDdTqE=; b=Cu2yB/7f/FzzmwbJTu/eAQ0uHo2A00mabQ6Ix9UMsvdPZNp5wLt9Bk1liMlDBe6Zji +4Kbab3B/2uUQkK7APgxbsrBn+5sPDdN7I/PATjwdBb39HZcHWVo/uAHzTR/S28BoBWS bmKdhw4ZUodHHeE2T++9Bs5Uj9f7gDIU96is6ZLHKQNORik2Sh1tW8Xv7X5WTr9mqKCC xheR5uLObIupys0uYzG5a7r6Xb/cfjLOF4xjRlXIQo9/Kv+iQAoENPoNqnt+ZTciBpz+ OTZOv4c7pA5T7H8euTa2BqhH99ZYTJACoLzIInor8THJEN8vW7LAn5o+/YYTOHL+aP/j OFsw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v9si1493375oic.251.2019.12.10.00.27.55; Tue, 10 Dec 2019 00:28:08 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726884AbfLJI12 (ORCPT + 99 others); Tue, 10 Dec 2019 03:27:28 -0500 Received: from mail-oi1-f193.google.com ([209.85.167.193]:41087 "EHLO mail-oi1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726248AbfLJI12 (ORCPT ); Tue, 10 Dec 2019 03:27:28 -0500 Received: by mail-oi1-f193.google.com with SMTP id i1so9015244oie.8; Tue, 10 Dec 2019 00:27:28 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=BX8/IGebb3UQLoc8g0MqAatjMar/ymE4GzyE+cDdTqE=; b=V3yISq+chPoAk5G46RySgKigPauyG4Zz+V0byCVxo1RhU//1uJ2/JJu7CL/Baip4wU 5xyQa6vNU1S1wU5wEOclUxDJRiB851GAfTUbSKL0lECQpX1WXVMWpheLco6GXDGKt/cM cnconTPra/LmljSyup2Cork5J2xbMNdcd3HmfdBeQz+vBUEi3XDcm8PRO5kom5GGfjxP 0o1cPvnjhqwpqnIzhb1E0Fbcr9VFbtk9grOvUUOF/fgqJJcxsAgMCAaOSbOmSCaaEsmL BckGfKHxWM25qoSTVFpcJVo5XTjDDLWBgiLvxB8yAyBkF614+hAanTMYG5D0ZsXXW3FG bcgg== X-Gm-Message-State: APjAAAXIGn0On9hu1d2pymXxV7kc7ztoXCU1redqsLBIzkwjxzRrgbPA SdIAwuRVrbUOOQE3BwRwBFRBu5gZDkEW2sesk/Q= X-Received: by 2002:a05:6808:b38:: with SMTP id t24mr3038315oij.110.1575966447761; Tue, 10 Dec 2019 00:27:27 -0800 (PST) MIME-Version: 1.0 References: <20191202070348.32148-1-tao3.xu@intel.com> <6dbcdaff-feae-68b9-006d-dd8aec032553@intel.com> <0e4219c3-943a-e416-e5eb-723bed8c9383@intel.com> In-Reply-To: <0e4219c3-943a-e416-e5eb-723bed8c9383@intel.com> From: "Rafael J. Wysocki" Date: Tue, 10 Dec 2019 09:27:15 +0100 Message-ID: Subject: Re: [PATCH] ACPI/HMAT: Fix the parsing of Cache Associativity and Write Policy To: Tao Xu Cc: "Rafael J. Wysocki" , Rafael Wysocki , Len Brown , Greg Kroah-Hartman , Dan Williams , Dave Hansen , ACPI Devel Maling List , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Dec 10, 2019 at 9:19 AM Tao Xu wrote: > > On 12/10/2019 4:06 PM, Rafael J. Wysocki wrote: > > On Tue, Dec 10, 2019 at 2:04 AM Tao Xu wrote: > >> > >> On 12/9/2019 6:01 PM, Rafael J. Wysocki wrote: > >>> On Mon, Dec 2, 2019 at 8:03 AM Tao Xu wrote: > >>>> > >>>> In chapter 5.2.27.5, Table 5-147: Field "Cache Attributes" of > >>>> ACPI 6.3 spec: 0 is "None", 1 is "Direct Mapped", 2 is "Complex Cache > >>>> Indexing" for Cache Associativity; 0 is "None", 1 is "Write Back", > >>>> 2 is "Write Through" for Write Policy. > >>> > >>> Well, I'm not sure what the connection between the above statement, > >>> which is correct AFAICS, and the changes made by the patch is. > >>> > >>> Is that the *_OTHER symbol names are confusing or something deeper? > >>> > >> > >> Because in include/acpi/actbl1.h: > >> > >> #define ACPI_HMAT_CA_NONE (0) > >> > >> ACPI_HMAT_CA_NONE is 0, but in include/linux/node.h: > >> > >> enum cache_indexing { > >> NODE_CACHE_DIRECT_MAP, > >> NODE_CACHE_INDEXED, > >> NODE_CACHE_OTHER, > >> }; > >> NODE_CACHE_OTHER is 2, and for otner enum: > >> > >> case ACPI_HMAT_CA_DIRECT_MAPPED: > >> tcache->cache_attrs.indexing = NODE_CACHE_DIRECT_MAP; > >> break; > >> case ACPI_HMAT_CA_COMPLEX_CACHE_INDEXING: > >> tcache->cache_attrs.indexing = NODE_CACHE_INDEXED; > >> break; > >> in include/acpi/actbl1.h: > >> > >> #define ACPI_HMAT_CA_DIRECT_MAPPED (1) > >> #define ACPI_HMAT_CA_COMPLEX_CACHE_INDEXING (2) > >> > >> but in include/linux/node.h: > >> > >> NODE_CACHE_DIRECT_MAP is 0, NODE_CACHE_INDEXED is 1. This is incorrect. > > > > Why is it incorrect? > > Sorry I paste the wrong pre-define. > > This is the incorrect line: > > case ACPI_HMAT_CA_DIRECT_MAPPED: > tcache->cache_attrs.indexing = NODE_CACHE_DIRECT_MAP; > > ACPI_HMAT_CA_DIRECT_MAPPED is 1, NODE_CACHE_DIRECT_MAP is 0. That means > if HMAT table input 1 for cache_attrs.indexing, kernel store 0 in > cache_attrs.indexing. But in ACPI 6.3, 0 means "None". So for the whole > switch codes: This is a mapping between the ACPI-defined values and the generic ones defined in the kernel. There is not rule I know of by which they must be the same numbers. Or is there such a rule which I'm missing? As long as cache_attrs.indexing is used consistently going forward, the difference between the ACPI-defined numbers and its values shouldn't matter, should it? > > switch ((attrs & ACPI_HMAT_CACHE_ASSOCIATIVITY) >> 8) { > case ACPI_HMAT_CA_DIRECT_MAPPED(1): > tcache->cache_attrs.indexing = NODE_CACHE_DIRECT_MAP(0); > break; > case ACPI_HMAT_CA_COMPLEX_CACHE_INDEXING(2): > tcache->cache_attrs.indexing = NODE_CACHE_INDEXED(1); > break; > case ACPI_HMAT_CA_NONE(0): > default: > tcache->cache_attrs.indexing = NODE_CACHE_OTHER(2); > break; > }