Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp844952pxk; Wed, 9 Sep 2020 23:10:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxCesX2MTM+h5dZqI6OseiO8SNJnEM3vJVyYxRzikni5nyZJg29jwBXiAw4ZHxCj9MFmRU4 X-Received: by 2002:aa7:dcd9:: with SMTP id w25mr7254437edu.280.1599718258095; Wed, 09 Sep 2020 23:10:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599718258; cv=none; d=google.com; s=arc-20160816; b=gg+7+B3ftW+q+7wNqgaD0NL0Wi1820cxeKpjbfD5xWTax590IFDGv9PfB4ok0woUsi H2coInHNFChzgwefEmE4Lri33BqE7hI/0kag0ob5kb0RA0OCQz1gWZiI+c4fRiqz1J+c kfiF34gw1Am5mSGWHncjWFGek7EkAZpoxIqbKrnGgQONA+g7CpINnNeSjO+9Cs5DL7dU NxpWkzTULvhClq7KlCpYoG19kVxw5SvK2ox0J8tO39tMLod6iqQ3mQqkOvsEFjGW24dO vU1IZUdFEabd1nX1zV98JaWfR0Ya2tg0PtV7h6X+Gt/Inbw5B9y7nXXAC2q7KKH8YO6/ bOrA== 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:from:references:cc:to:subject; bh=e956mU3aMxXnIEY0VUkldW0dLYMCG11eWB75kLTsjMc=; b=kLbZzqkynf5EbD6YyDjSURSGjz+hOpog207w+9vc7LYNUv7QOjVQK4OtPQ99ThLyNx suRR5/Z/3KdW5HT+LPJWE53EVAT3eiZ4bnz9yJ5bg0NgLgcW/bTpmUFbocJ2lksQQ6x4 cT+NCg+PPcpOK3XnlBsop5EPx8W/zdNJiY0jGlHD6Z/KQXCEBC7wvwlwrfI0+3hJoNGJ mGsSKdGyX2zWL4geCBcVIW9urM5InI45Ewb5zpNQKl1vz/PvY+XqoM5cklBlp5PfiIWq jNRRIYLtC7BRj7i8UvBJCEXIj+Wkk0AYtI41zYR76dyB1fkD+bWnDrPjn79X7JrLdMmF EDHw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=siemens.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w20si3060434ejb.217.2020.09.09.23.10.35; Wed, 09 Sep 2020 23:10:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=siemens.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726647AbgIJGJc (ORCPT + 99 others); Thu, 10 Sep 2020 02:09:32 -0400 Received: from thoth.sbs.de ([192.35.17.2]:47371 "EHLO thoth.sbs.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725885AbgIJGJa (ORCPT ); Thu, 10 Sep 2020 02:09:30 -0400 Received: from mail2.sbs.de (mail2.sbs.de [192.129.41.66]) by thoth.sbs.de (8.15.2/8.15.2) with ESMTPS id 08A698gW015304 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 10 Sep 2020 08:09:08 +0200 Received: from [167.87.23.29] ([167.87.23.29]) by mail2.sbs.de (8.15.2/8.15.2) with ESMTP id 08A6978D012373; Thu, 10 Sep 2020 08:09:07 +0200 Subject: Re: watchdog: sp5100_tco support for AMD V/R/E series To: Guenter Roeck , linux-watchdog@vger.kernel.org Cc: Wim Van Sebroeck , linux-kernel@vger.kernel.org, "Awan, Arsalan" , "Hombourger, Cedric" , "Farnsworth, Wade" References: <15c8913e-9026-2649-9911-71d6f1c79519@siemens.com> <9e270546-7962-932b-2e4c-3c833b7d4b30@siemens.com> <39327ba6-0eff-3555-124c-64f3f105c9fe@roeck-us.net> From: Jan Kiszka Message-ID: Date: Thu, 10 Sep 2020 08:09:07 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.11.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 09.09.20 18:04, Guenter Roeck wrote: > On 9/7/20 1:45 PM, Guenter Roeck wrote: >> On 9/7/20 12:18 PM, Guenter Roeck wrote: >>> On 9/7/20 8:46 AM, Jan Kiszka wrote: >>>> On 07.09.20 17:31, Guenter Roeck wrote: >>>>> On 9/7/20 4:20 AM, Jan Kiszka wrote: >>>>>> Hi all, >>>>>> >>>>>> Arsalan reported that the upstream driver for sp5100_tco does not work >>>>>> for embedded Ryzen. Meanwhile, I was able to confirm that on an R1505G: >>>>>> >>>>>> [ 11.607251] sp5100_tco: SP5100/SB800 TCO WatchDog Timer Driver >>>>>> [ 11.607337] sp5100-tco sp5100-tco: Using 0xfed80b00 for watchdog MMIO address >>>>>> [ 11.607344] sp5100-tco sp5100-tco: Watchdog hardware is disabled >>>>>> >>>>>> ..and fix it: >>>>>> >>>>>> diff --git a/drivers/watchdog/sp5100_tco.c b/drivers/watchdog/sp5100_tco.c >>>>>> index 85e9664318c9..5482154fde42 100644 >>>>>> --- a/drivers/watchdog/sp5100_tco.c >>>>>> +++ b/drivers/watchdog/sp5100_tco.c >>>>>> @@ -193,7 +193,8 @@ static void tco_timer_enable(struct sp5100_tco *tco) >>>>>> /* Set the Watchdog timer resolution to 1 sec and enable */ >>>>>> sp5100_tco_update_pm_reg8(EFCH_PM_DECODEEN3, >>>>>> ~EFCH_PM_WATCHDOG_DISABLE, >>>>>> - EFCH_PM_DECODEEN_SECOND_RES); >>>>>> + EFCH_PM_DECODEEN_SECOND_RES | >>>>>> + EFCH_PM_DECODEEN_WDT_TMREN); >>>>> >>>>> Confusing. The register in question is a 32-bit register, but only a byte >>>>> is written into it. Bit 24-25 are supposed to be the resolution, bit 25-26 >>>>> set to 0 enable the watchdog. Bit 7 is supposed to enable MMIO decoding. >>>>> This is from AMD Publication 52740. So something in the existing code >>>>> is (or seems to be) wrong, but either case I don't see how setting bit 7 >>>>> (or 31 ?) would enable the watchdog hardware. >>>>> >>>>> Hmm, I wrote that code. Guess I'll need to to spend some time figuring out >>>>> what is going on. >>>> >>>> The logic came from [1] which inspired [2] - that's where I pointed out >>>> the large overlap with the existing upstream driver. I would love to see >>>> all that consolidated. >>>> >>>> BTW, the R1505G is family 0x17. Maybe something changed there, and that >>>> bit 7 was just reserved/ignored so far. ENOSPECS >>>> >>> >>> Thanks for the pointers. >>> >>> I think you are talking about bit 31. Bit 7 is and was WatchdogTmrEn, but that >>> supposedly only enables watchdog timer memory access at 0xfeb00000. From what >>> I glance from the other drivers, the existing code is wrong. It should set >>> the disable and resolution bits in register offset 3 (bit 24..27), not 0. >>> In other words, EFCH_PM_DECODEEN3 should be defined as 0x03, not as 0x00. >>> Which actually makes sense from the name. >>> >>> Playing with my hardware, turns out that setting bit 7 in EFCH_PM_DECODEEN >>> (register offset 0) does indeed enable the watchdog. I'll need to check >>> if it actually works. Either case, -ENOSPECS is really a problem here. >>> >> >> ... and it does work. After playing with it, it seems that on Family 17h >> CPUs EFCH_PM_DECODEEN_WDT_TMREN not only enables watchdog timer memory >> access at 0xfeb0000, but also enables the watchdog itself. >> >> Also, turns out the documentation is now public, at least for some of the >> Family 17h CPUs (though oddly enough not for all of them). See processor >> reference manuals at https://www.amd.com/en/support/tech-docs. The documents >> for model 18h and model 20h include a note stating that bit 7 of >> EFCH_PM_DECODEEN enables both memory access and the watchdog hardware. >> >> So we'll need two patches - one to fix the value of EFCH_PM_DECODEEN3, >> and one to enable the watchdog bit setting bit 7 of EFCH_PM_DECODEEN >> for Family 17h CPUs. >> > Jan - any chance you can submit those patches ? Or do you want me to do it ? Oh, I was reading your reply as if you were writing the patches. The first one is definitely your finding, and while I can also see now what is wrong and needed on 17h, I'm unsure about the rest. If you have a better picture, please go ahead. Jan -- Siemens AG, Corporate Technology, CT RDA IOT SES-DE Corporate Competence Center Embedded Linux