Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp3305529imm; Mon, 13 Aug 2018 09:19:32 -0700 (PDT) X-Google-Smtp-Source: AA+uWPzRH4FE0/ycsBTRiT9mOE4GsvSyMjCopfc3D94UpTEeD+p/o16iqeQx59nB93+1zWuwQaSy X-Received: by 2002:a63:fb07:: with SMTP id o7-v6mr18009603pgh.333.1534177172139; Mon, 13 Aug 2018 09:19:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534177172; cv=none; d=google.com; s=arc-20160816; b=G6LGYwuA2khF9AOV+CFEbD6k2siI72fbqE1hUTghf3v/gbxRmwDGIQ7a2XezkRsVf3 jjt0Uq0TSdBAnitKsbIN03E0SqDJraeAEylK4T1jRH2bIHmR0Ha72xgSR629MtHCaHrF UQVrHp+ag6TqdR+BU/eDHQxEkuG7Oco8N1OoaRU8C8emb9KfqA7rYZqagt2jIj6QN1Sw x9p2vOZi1X9AkMo0FIUE74EwwVpMC1tWC9FMPbqhTlBsMzlXfG1N79GHIgJzI5fOU0I2 bQFFerUJi7N8UxVohUHNiMimvB17HfHy2DCe71s9IVpYMVZHfhZTU4lxCWRUYwIQMg+N hwVg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:references:cc:to:subject:from:arc-authentication-results; bh=0UqUpVF54vhf32h0ny1SWZ6ck/bhB/14kfa2GfwEaxI=; b=umISdj64v0x2h7bC9wRLIO3LhlgkqYnMLACQeS8QW6qcG+0iFC8OcfV/BBCher1CI9 rj3rhQoOU7eEUnrhUDTRu2hIi1ea+XNpsArLC6BZLW5HyZIEyi6n64HmCUvF/iDAMkcf UZXZLqlppX6xEri4FJiBgUudxgslZHlwNj/i/EZfll+02C10TfG3AAeInn7LLtHcqRPg rWpTRGN60nwBw6y21/rvg5vISGuEpOrylpsAMyZGSGxr9oD9JGRPk4e1I/jAytlKl2lN 2bfuHjpGTMdMLoDfEWQ0jnx8O3AIH84hWZzDwr63Y7PKl7bgan0pb2xYd4hXkLmo0Hqc JL8g== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i8-v6si16539386pfo.128.2018.08.13.09.19.16; Mon, 13 Aug 2018 09:19:32 -0700 (PDT) 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729741AbeHMTBO (ORCPT + 99 others); Mon, 13 Aug 2018 15:01:14 -0400 Received: from smtp20.cstnet.cn ([159.226.251.20]:46324 "EHLO cstnet.cn" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728763AbeHMTBO (ORCPT ); Mon, 13 Aug 2018 15:01:14 -0400 Received: from [192.168.1.7] (unknown [110.184.152.220]) by APP-10 (Coremail) with SMTP id tACowACXYu0zr3FbNT4BAQ--.8204S2; Tue, 14 Aug 2018 00:17:56 +0800 (CST) From: Pu Wen Subject: Re: [PATCH v3 16/17] driver/edac: enable Hygon support to AMD64 EDAC driver To: Michael Jin Cc: tglx@linutronix.de, mingo@redhat.com, hpa@zytor.com, x86@kernel.org, thomas.lendacky@amd.com, bp@alien8.de, pbonzini@redhat.com, Mauro Carvalho Chehab , linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, linux-edac@vger.kernel.org References: Message-ID: <68538d23-8880-29a2-decd-f63b48667274@hygon.cn> Date: Tue, 14 Aug 2018 00:17:55 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-CM-TRANSID: tACowACXYu0zr3FbNT4BAQ--.8204S2 X-Coremail-Antispam: 1UD129KBjvJXoWxurW5Xw45tr13KFWUWF45ZFb_yoW5ZF43pr W5JF4j9rn7JasxJryvvr4UXFyrCw4kJFZrCrsxK3WFqFZ8ZFyrW345tF4fuFyUAF93J3y2 vayrWw47Ga1qyaDanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUvCb7Iv0xC_tr1lb4IE77IF4wAFF20E14v26r4j6ryUM7CY07I2 0VC2zVCF04k26cxKx2IYs7xG6rWj6s0DM7CIcVAFz4kK6r1j6r18M28lY4IEw2IIxxk0rw A2F7IY1VAKz4vEj48ve4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_Jr0_JF4l84ACjcxK6xII jxv20xvEc7CjxVAFwI0_Gr0_Cr1l84ACjcxK6I8E87Iv67AKxVWUJVW8JwA2z4x0Y4vEx4 A2jsIEc7CjxVAFwI0_Gr0_Gr1UM2AIxVAIcxkEcVAq07x20xvEncxIr21l5I8CrVACY4xI 64kE6c02F40Ex7xfMcIj6xIIjxv20xvE14v26r1j6r18McIj6I8E87Iv67AKxVWUJVW8Jw Am72CE4IkC6x0Yz7v_Jr0_Gr1lF7xvr2IY64vIr41lFIxGxcIEc7CjxVA2Y2ka0xkIwI1l c7I2V7IY0VAS07AlzVAYIcxG8wCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJV W8JwC20s026c02F40E14v26r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF 1VAFwI0_Jw0_GFylIxkGc2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVWUJVWUCwCI42IY6x IIjxv20xvEc7CjxVAFwI0_Gr0_Cr1lIxAIcVCF04k26cxKx2IYs7xG6rW3Jr0E3s1lIxAI cVC2z280aVAFwI0_Jr0_Gr1lIxAIcVC2z280aVCY1x0267AKxVW8JVW8JrUvcSsGvfC2Kf nxnUUI43ZEXa7IU8489tUUUUU== X-Originating-IP: [110.184.152.220] X-CM-SenderInfo: psxzv046klw03qof0z/ Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2018/8/12 3:56, Michael Jin wrote: > On Sat, Aug 11, 2018 at 9:30 AM, Pu Wen wrote: >> diff --git a/drivers/edac/amd64_edac.c b/drivers/edac/amd64_edac.c >> index 18aeabb..fb81354 100644 >> --- a/drivers/edac/amd64_edac.c >> +++ b/drivers/edac/amd64_edac.c >> @@ -211,7 +211,7 @@ static int __set_scrub_rate(struct amd64_pvt *pvt, u32 new_bw, u32 min_rate) >> >> scrubval = scrubrates[i].scrubval; >> >> - if (pvt->fam == 0x17) { >> + if (pvt->fam == 0x17 || pvt->vendor == X86_VENDOR_HYGON) { >> __f17h_set_scrubval(pvt, scrubval); > > Separating the vendor check as an "else if (pvt->vendor == > X86_VENDOR_HYGON)" block would make architectural changes (future > hygon models, i.e. 19h, 20h, etc) less confusing. Your suggestion is reasonable, but that might make the branch a little complicated.If we explicitly testing Hygon family in condition case, will that be ok? + if (pvt->fam == 0x17 || + (pvt->vendor == X86_VENDOR_HYGON && pvt->fam == 0x18)) > >> + amd64_read_pci_cfg(pvt->F6, >> + F17H_SCR_BASE_ADDR, &scrubval); >> + if (scrubval & BIT(0)) { >> + amd64_read_pci_cfg(pvt->F6, > > The new lines after "amd64_read_pci_cfg(pvt->F6," can be removed. To fix the warning "line over 80 characters" reported by running the checking script checkpatch.pl, I added the new line. But your sugesstion is reasonable, remove the new line will make the codes much easier to read. >> @@ -1051,6 +1065,16 @@ static void determine_memory_type(struct amd64_pvt *pvt) >> else >> pvt->dram_type = MEM_DDR4; >> return; >> + case 0x18: >> + if (pvt->vendor == X86_VENDOR_HYGON) { > > This vendor checking is not necessary as there are no other known > family 18h processors. > > >> switch (pvt->fam) { >> @@ -3192,6 +3227,13 @@ static struct amd64_family_type *per_family_init(struct amd64_pvt *pvt) >> pvt->ops = &family_types[F17_CPUS].ops; >> break; >> >> + case 0x18: >> + if (pvt->vendor == X86_VENDOR_HYGON) { >> + fam_type = &family_types[HYGON_F18_CPUS]; >> + pvt->ops = &family_types[HYGON_F18_CPUS].ops; >> + break; >> + } > > There is a missing second 'break' statement after the "if (pvt->vendor > == X86_VENDOR_HYGON)" block for case 0x18, see case 0x15 and case 0x16 > for comparison. The missed second 'break' is on purpose. Thinking that if BIOS report a vendor AMD and family 18h processor(which is not in case now), the code will fall through and print out "Unsupported family". > >> diff --git a/drivers/edac/mce_amd.c b/drivers/edac/mce_amd.c >> index 2ab4d61..f7adc47 100644 >> + case 0x18: >> + if (c->x86_vendor == X86_VENDOR_HYGON) { >> + xec_mask = 0x3f; >> + if (!boot_cpu_has(X86_FEATURE_SMCA)) { >> + pr_warn("Decoding supported only on Scalable MCA processors.\n"); >> + goto err_out; >> + } >> + break; >> + } > > The 'break' statement could be moved outside of the "if (c->x86_vendor > == X86_VENDOR_HYGON)" block, this is to allow case 0x18 to reach the > 'break' statement if the vendor is not X86_VENDOR_HYGON. For the same reason as previous, if the vendor is not X86_VENDOR_HYGON, it's not a valid vendor by now, and should fall through to the default case and print out error message. Thanks, Pu Wen