Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp1218695pxb; Tue, 1 Feb 2022 22:53:33 -0800 (PST) X-Google-Smtp-Source: ABdhPJxGX80l3tXGnya9t1ehOl2iDFC8l7QqVystq3zWezTjsJ5IXm8BW3FXAi6QJZ5hx+2y2we/ X-Received: by 2002:a17:90a:b003:: with SMTP id x3mr6539248pjq.31.1643784813329; Tue, 01 Feb 2022 22:53:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643784813; cv=none; d=google.com; s=arc-20160816; b=M+NWeIngDf68ul5/yNCVOKIJKC0Tqxv88VuyIVg6ee7laOTA0E7ZDpTRUCAXGQ08dZ uXYRTbYdrR/CiD9UNT7uBkD4jMZF/jxy07eF+RAajz6iOFId003sx/on07O1aTQ+vFAK 2dBPWHAhdJXec3DDGNo8HDz8N73bE5dzfzzyCnTM5gddY0Kzu1BR6br/G3ZHJfZ3qH5a t4PSRlnwn+NfYpzHsUPzKqCwa9HnwLGCHHXtQT6nT64xRwYWojaR1jKMFAVpaJE8kZgR Zhee+ExSeEISRlHZShs5VKGaIjp2cz3FOFuW4MZJP/LPMGSisIOKR0juNqyOm5uzd90p 2bQg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:sender:dkim-signature; bh=rruHlI71IVnsctxkm2K7muRq26h/I63Aku9v7y+wB9g=; b=h+zKUcXfsmRcFLf48lOitLZBVAx15tMWcbY1+FUYBQFHU9z4oZonnm69As5u31yGHi vFmSXOW+YOgL6NJ14iplc2oXonQrf+Qzlf3UvZH7rr2yrV2m76YnpbNq1dg5reqtTkJ8 O9Ro9om/7fQiE3foY6QWelgboY2qn3+nFurtRxgl23p/IJOwq/uhnM6yCeIAuKDj8Fir dnHopu7fgBiljbBcYj3OZ7qoNc/cN4xqZIg5Zjthm1bdVUFeL0/Zx2B7p0wl1SJ+0Oqe WLXbUg8wvvQtgVzUbkFfxLc95YfqvsyjKo6ftWyPRNvsxUnXyJRHiYP6zMOsB56qn8bL m+Cw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=exG7uRmu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x16si16953485plr.564.2022.02.01.22.53.21; Tue, 01 Feb 2022 22:53:33 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=exG7uRmu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241580AbiBAWgl (ORCPT + 99 others); Tue, 1 Feb 2022 17:36:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54348 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235380AbiBAWgg (ORCPT ); Tue, 1 Feb 2022 17:36:36 -0500 Received: from mail-ot1-x336.google.com (mail-ot1-x336.google.com [IPv6:2607:f8b0:4864:20::336]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0F1A8C061714; Tue, 1 Feb 2022 14:36:36 -0800 (PST) Received: by mail-ot1-x336.google.com with SMTP id p3-20020a0568301d4300b005a7a702f921so860918oth.9; Tue, 01 Feb 2022 14:36:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=rruHlI71IVnsctxkm2K7muRq26h/I63Aku9v7y+wB9g=; b=exG7uRmuhfLG+HfBxgkjQKxj9Whwoo0jGYSJNOPlwLoqW06rlw+/AIJ/BignzAgisD w0QG/zfPWPtstuTN+VeYjIgYmdIHl2F3Bh5k85g2HwYgV/Fe6RJfJWxUIEsIOlsk9vOv LjO+BnsZmxg3njmD9POrPK/CUxJ0Rir9cUIRnQD22thBvxXkd5t2oBHJGlQ3Gp86wjZa 88ipWvSsKo3Hwbvye33ziSvcMP/XMQ5dUiCgfvthFigsSHH7uG3Zxood5cik5roZrvoS rmE5P/T+ZActsSto06DebnTEz/73CejMeeZPiPiyqS9B88akQRpUXf6IgRoYWofBZ4yh kMUw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:message-id:date:mime-version:user-agent :subject:content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=rruHlI71IVnsctxkm2K7muRq26h/I63Aku9v7y+wB9g=; b=JyXGcXunuhcwcVmXx34E23xtkPMoAYL7Byb6+n1B7k+78LuL2PElSeHxIQywONGwsx wO4VevlX2w0ER1UtS7kKm8L/bEfQKTKbtkXPoR6iraKPuiMHLlfmlcIZJ1PXv3JqKzwB n0evWue0zXsSyio0ONBGupfrz7eZMynFUxOKJlJ3OdRGiNPWcqW8AiPOYSjhZTJa3hiu Xr0Oyw8jvuSGw1kMWCG8ks25wRvqgT5G6+asi+lnbNqkY5ffYMZlaz7nHy1j+qqMA2ZD 9qsIKwwlFxKAnkCoHukSsCxQZWIysyuVaRjLwojOUHKFBQijYRdc2GhVxmKPVSwi3hMf pYgg== X-Gm-Message-State: AOAM531ZtY4ZDzNyZ38mEM21a4h/CItIhq4xwp6ir3m+Mq7hZE8Frpr0 aeBRncbfrY4B+tHMk6dx7Y4= X-Received: by 2002:a9d:62da:: with SMTP id z26mr14687051otk.26.1643754995390; Tue, 01 Feb 2022 14:36:35 -0800 (PST) Received: from ?IPV6:2600:1700:e321:62f0:329c:23ff:fee3:9d7c? ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id k3sm17406361otl.41.2022.02.01.14.36.32 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 01 Feb 2022 14:36:34 -0800 (PST) Sender: Guenter Roeck Message-ID: <9e330860-e225-6e69-f2ed-0bf11372c3ce@roeck-us.net> Date: Tue, 1 Feb 2022 14:36:31 -0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.5.0 Subject: Re: [PATCH v4 2/4] Watchdog: sp5100_tco: Refactor MMIO base address initialization Content-Language: en-US To: Terry Bowman , linux-watchdog@vger.kernel.org, jdelvare@suse.com, linux-i2c@vger.kernel.org, wsa@kernel.org, andy.shevchenko@gmail.com, rafael.j.wysocki@intel.com Cc: linux-kernel@vger.kernel.org, wim@linux-watchdog.org, rrichter@amd.com, thomas.lendacky@amd.com, sudheesh.mavila@amd.com, Nehal-bakulchandra.Shah@amd.com, Basavaraj.Natikar@amd.com, Shyam-sundar.S-k@amd.com, Mario.Limonciello@amd.com References: <20220130191225.303115-1-terry.bowman@amd.com> <20220130191225.303115-3-terry.bowman@amd.com> From: Guenter Roeck In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2/1/22 12:32, Terry Bowman wrote: > > > On 2/1/22 10:46, Terry Bowman wrote: >> >> >> On 2/1/22 09:31, Guenter Roeck wrote: >>> On 1/30/22 11:12, Terry Bowman wrote: >>>> Combine MMIO base address and alternate base address detection. Combine >>>> based on layout type. This will simplify the function by eliminating >>>> a switch case. >>>> >>>> Move existing request/release code into functions. This currently only >>>> supports port I/O request/release. The move into a separate function >>>> will make it ready for adding MMIO region support. >>>> >>>> Co-developed-by: Robert Richter >>>> Signed-off-by: Robert Richter >>>> Signed-off-by: Terry Bowman >>>> Tested-by: Jean Delvare >>>> Reviewed-by: Jean Delvare >>>> --- >>>>   drivers/watchdog/sp5100_tco.c | 155 ++++++++++++++++++---------------- >>>>   drivers/watchdog/sp5100_tco.h |   1 + >>>>   2 files changed, 82 insertions(+), 74 deletions(-) >>>> >>>> diff --git a/drivers/watchdog/sp5100_tco.c b/drivers/watchdog/sp5100_tco.c >>>> index b365bbc9ac36..16e122d5045e 100644 >>>> --- a/drivers/watchdog/sp5100_tco.c >>>> +++ b/drivers/watchdog/sp5100_tco.c >>>> @@ -223,6 +223,55 @@ static u32 sp5100_tco_read_pm_reg32(u8 index) >>>>       return val; >>>>   } >>>>   +static u32 sp5100_tco_request_region(struct device *dev, >>>> +                     u32 mmio_addr, >>>> +                     const char *dev_name) >>>> +{ >>>> +    if (!devm_request_mem_region(dev, mmio_addr, SP5100_WDT_MEM_MAP_SIZE, >>>> +                     dev_name)) { >>>> +        dev_dbg(dev, "MMIO address 0x%08x already in use\n", mmio_addr); >>>> +        return 0; >>>> +    } >>>> + >>>> +    return mmio_addr; >>>> +} >>>> + >>>> +static u32 sp5100_tco_prepare_base(struct sp5100_tco *tco, >>>> +                   u32 mmio_addr, >>>> +                   u32 alt_mmio_addr, >>>> +                   const char *dev_name) >>>> +{ >>>> +    struct device *dev = tco->wdd.parent; >>>> + >>>> +    dev_dbg(dev, "Got 0x%08x from SBResource_MMIO register\n", mmio_addr); >>>> + >>>> +    if (!mmio_addr && !alt_mmio_addr) >>>> +        return -ENODEV; >>>> + >>>> +    /* Check for MMIO address and alternate MMIO address conflicts */ >>>> +    if (mmio_addr) >>>> +        mmio_addr = sp5100_tco_request_region(dev, mmio_addr, dev_name); >>>> + >>>> +    if (!mmio_addr && alt_mmio_addr) >>>> +        mmio_addr = sp5100_tco_request_region(dev, alt_mmio_addr, dev_name); >>>> + >>>> +    if (!mmio_addr) { >>>> +        dev_err(dev, "Failed to reserve MMIO or alternate MMIO region\n"); >>>> +        return -EBUSY; >>>> +    } >>>> + >>>> +    tco->tcobase = devm_ioremap(dev, mmio_addr, SP5100_WDT_MEM_MAP_SIZE); >>>> +    if (!tco->tcobase) { >>>> +        dev_err(dev, "MMIO address 0x%08x failed mapping\n", mmio_addr); >>>> +        devm_release_mem_region(dev, mmio_addr, SP5100_WDT_MEM_MAP_SIZE); >>>> +        return -ENOMEM; >>>> +    } >>>> + >>>> +    dev_info(dev, "Using 0x%08x for watchdog MMIO address\n", tco->tcobase); >>>> + >>> >>> I know this is the same as the old code, but I think it would make sense to change >>> this as suggested by 0-day and use %px instead. >>> >>> Thanks, >>> Guenter >> >> > Hi Guenter, > > This line was changed in v4 and should be reverted. It should be using the mmio_addr > physical address with '0x%08x' formatting instead of tco->tcobase. This would be: > > dev_info(dev, "Using 0x%08x for watchdog MMIO address\n", mmio_addr); > > The dmesg then provides: > > [ 5.972921] sp5100_tco: SP5100/SB800 TCO WatchDog Timer Driver > [ 5.978238] sp5100-tco sp5100-tco: Using 0xfeb00000 for watchdog MMIO address > [ 5.978252] sp5100-tco sp5100-tco: Watchdog hardware is disabled > > Do your agree? > Yes. Displaying the mapped address has zero if any value. Guenter