Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp2624652pxa; Fri, 7 Aug 2020 16:26:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzB/UMYGROojzc2xPs7JsZ7++94JPN+sgDHUJo/knDS3yEVm0H/NQw1SE2uYKZ3x/AbGI9O X-Received: by 2002:a17:906:6558:: with SMTP id u24mr11199073ejn.364.1596842807055; Fri, 07 Aug 2020 16:26:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596842807; cv=none; d=google.com; s=arc-20160816; b=Fz8OyIwCeZU7sd/cRfo7udx8i6xxSGeoduAJGzemgxdn/6F9hY3cZ8qA6SyAoHfPLt Psbl05fo9Jnyc42BVh9PSuh1lSxFM9mGVyFyTHYOmO0jXr84Q8VusdHITRuRo6QT0JWq icz9afGYBNof/aSV3OgoJusd3GpZ7fOQb6OHmYZFj/88XpgZbf3+tcL7cCI1MpdM/8aU jCs+dtr9STnxv+BpOHhdh0H4c8OIFiQwkIvH3Dfs70XLpxj+rHj9OKVJGRNqLy3Z1B7L sgw+eyuoLcnv45T2WT0NOLiPnIrECj0y4Z9bBSBMaIIgruJ9cCvsc+Sx3zLbfJ0y/ESN hZTg== 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:autocrypt:from:references:cc:to:subject:dkim-signature; bh=xeyRmBMtht9F/95S4PxaQKGge21ituHAnotfo3X2meM=; b=lIXuUSG1UcbCf9MTsUjkjrcCEKz7cIvbm0Cfc8XPfJiJvZYHZL+9dPxnc6FA8vWLzK G2snxdIskaqcNHUy+54A6PDs+t/BVDApu3AKyJkQXnyCb+KE/rtU/NoVxM/td1iupH3i PuTZZ2KX5LQ16+w2fmr4fngSiV4LyeyHsieWy52vjvBZiwCca2KLcRizi22i9ZBgl417 ET769Xhabib5OrQx82VfuNLGwu4NQFR6s2YPli+tz6QlmS704F7bvjD8BGpWeYgj2s2P MOjxkomwRatbF2f+W89lxmCDO5AwrFUCbR+T46NS2pCMgoFYUhZcGl0iL25w1oKeSa1y tiqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=tbgt4hQD; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y7si6011923ejr.228.2020.08.07.16.26.23; Fri, 07 Aug 2020 16:26:47 -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; dkim=fail header.i=@gmail.com header.s=20161025 header.b=tbgt4hQD; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726398AbgHGXX6 (ORCPT + 99 others); Fri, 7 Aug 2020 19:23:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42814 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726066AbgHGXX5 (ORCPT ); Fri, 7 Aug 2020 19:23:57 -0400 Received: from mail-pg1-x541.google.com (mail-pg1-x541.google.com [IPv6:2607:f8b0:4864:20::541]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4E24DC061756; Fri, 7 Aug 2020 16:23:57 -0700 (PDT) Received: by mail-pg1-x541.google.com with SMTP id s15so1760337pgc.8; Fri, 07 Aug 2020 16:23:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:to:cc:references:from:autocrypt:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=xeyRmBMtht9F/95S4PxaQKGge21ituHAnotfo3X2meM=; b=tbgt4hQD25W0pSZ4Yo1gL5rlx4vXvb5c8AoYeLxH7hDkreXBP6TPVD9o8Zsz6/ZnyK wyB0bx6N1agIUqBg8EgdLh/oVN2O9Q4tfcNsiHUHpJFzfHYWFOK6l7O3pGuheYPbSUaX 5iKHRtYQjY6+93o9FWMXXzPEfv96ArfmOam9O/8B4JuEn0lqDDK/48CtPbaEo2IV9Q2y FQwU7zqaqgT9nGYA6i2BeZeKRkG8ybDhL58HeEucPFOdijNw5TgJBqc8s/8NazrbkEj+ pAlJ0fCgLFlsm8GLjX5vx07s9r+GfHpI2LuwHlextoMmBhUruN0L2ng6+kVHNrfe7/hj NXNw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:to:cc:references:from:autocrypt :message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=xeyRmBMtht9F/95S4PxaQKGge21ituHAnotfo3X2meM=; b=jo8zuUEuPRVzDuCSnZ5l0m/eb+ApggHCdZ++f0MnK/bJG2dmoceinEs8ZllJbevp9F bVXQCEdExhonCyAcwNyqfMfjYKLfvMqhCkZ5ooW8CW4QnZMuQflBC2/6K4biYCnKVUVb jAucACc7fI/muzkqdgC5jBbcQMibQ1pqoYz39GE1wQuL4ImlwloYbouKi2H0pSg5SItQ 9IZ9gMymcoFmUKCkcFDg/Bzi+amO2C5jLn4zX77lmbo1WCrI5F9HuL8J4XUWZSbBp6Xq rgy9dDXjkonLIRCGe4qCSCrXdhIdILc09m/UCkRv1NybgFGotFE2qX1aePtM+Xmc4pSz 02QA== X-Gm-Message-State: AOAM530PVO3U1OEglilx/nHSAmxLFmM6SS6vO+W7schxFaNtHtbDpI7I ODiU060wBDnJ1Ar97EBvIZ4= X-Received: by 2002:a62:7dd5:: with SMTP id y204mr16088852pfc.318.1596842636725; Fri, 07 Aug 2020 16:23:56 -0700 (PDT) Received: from server.roeck-us.net ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id u21sm12165863pjn.27.2020.08.07.16.23.55 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 07 Aug 2020 16:23:55 -0700 (PDT) Subject: Re: [PATCH] drivers: watchdog: rdc321x_wdt: Fix race condition bugs To: Florian Fainelli , madhuparnabhowmik10@gmail.com Cc: wim@linux-watchdog.org, linux-watchdog@vger.kernel.org, linux-kernel@vger.kernel.org, andrianov@ispras.ru, ldv-project@linuxtesting.org References: <20200807112902.28764-1-madhuparnabhowmik10@gmail.com> <20200807162141.GA41980@roeck-us.net> <8dca64a1-8cd9-6a41-b61d-1c4c14e5cd5e@gmail.com> <1b9db5ad-0edf-091b-a04e-a8f3a6ac08e2@gmail.com> From: Guenter Roeck Autocrypt: addr=linux@roeck-us.net; keydata= xsFNBE6H1WcBEACu6jIcw5kZ5dGeJ7E7B2uweQR/4FGxH10/H1O1+ApmcQ9i87XdZQiB9cpN RYHA7RCEK2dh6dDccykQk3bC90xXMPg+O3R+C/SkwcnUak1UZaeK/SwQbq/t0tkMzYDRxfJ7 nyFiKxUehbNF3r9qlJgPqONwX5vJy4/GvDHdddSCxV41P/ejsZ8PykxyJs98UWhF54tGRWFl 7i1xvaDB9lN5WTLRKSO7wICuLiSz5WZHXMkyF4d+/O5ll7yz/o/JxK5vO/sduYDIlFTvBZDh gzaEtNf5tQjsjG4io8E0Yq0ViobLkS2RTNZT8ICq/Jmvl0SpbHRvYwa2DhNsK0YjHFQBB0FX IdhdUEzNefcNcYvqigJpdICoP2e4yJSyflHFO4dr0OrdnGLe1Zi/8Xo/2+M1dSSEt196rXaC kwu2KgIgmkRBb3cp2vIBBIIowU8W3qC1+w+RdMUrZxKGWJ3juwcgveJlzMpMZNyM1jobSXZ0 VHGMNJ3MwXlrEFPXaYJgibcg6brM6wGfX/LBvc/haWw4yO24lT5eitm4UB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djva++GT0VLXtHULdlzg8VjDnFZ3lfz5PWEOeIMk7Rj trjv82EZtrhLuLjHRCaG50OOm0hwPSk1J64R8O3HjSLdertmw7eyAYOo4RuWJguYMg5DRnBk WkRwrSuCn7UG+qVWZeKEsFKFOkynOs3pVbcbq1pxbhk3TRWCGRU5JolI4ohy/7JV1TVbjiDI HP/aVnm6NC8of26P40Pg8EdAhajZnHHjA7FrJXsy3cyIGqvg9os4rNkUWmrCfLLsZDHD8FnU mDW4+i+XlNFUPUYMrIKi9joBhu18ssf5i5Q= Message-ID: Date: Fri, 7 Aug 2020 16:23:54 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <1b9db5ad-0edf-091b-a04e-a8f3a6ac08e2@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Florian, On 8/7/20 1:09 PM, Florian Fainelli wrote: > > On 8/7/2020 12:08 PM, Guenter Roeck wrote: >> On 8/7/20 11:08 AM, Florian Fainelli wrote: >>> >>> >>> On 8/7/2020 9:21 AM, Guenter Roeck wrote: >>>> On Fri, Aug 07, 2020 at 04:59:02PM +0530, madhuparnabhowmik10@gmail.com wrote: >>>>> From: Madhuparna Bhowmik >>>>> >>>>> In rdc321x_wdt_probe(), rdc321x_wdt_device.queue is initialized >>>>> after misc_register(), hence if ioctl is called before its >>>>> initialization which can call rdc321x_wdt_start() function, >>>>> it will see an uninitialized value of rdc321x_wdt_device.queue, >>>>> hence initialize it before misc_register(). >>>>> Also, rdc321x_wdt_device.default_ticks is accessed in reset() >>>>> function called from write callback, thus initialize it before >>>>> misc_register(). >>>>> >>>>> Found by Linux Driver Verification project (linuxtesting.org). >>>>> >>>>> Signed-off-by: Madhuparna Bhowmik >>>> >>>> Reviewed-by: Guenter Roeck >>>> >>>> Having said that ... this is yet another potentially obsolete driver. >>>> You are really wasting your (and, fwiw, my) time. >>>> >>>> Florian, any thoughts if support for this chip can/should be deprecated >>>> or even removed ? >>> >>> I am still using my rdc321x-based SoC, so no, this is not obsolete as >>> far as I am concerned, time permitting, modernizing the driver is on my >>> TODO after checking/fixing the Ethernet driver first. >>> >> >> Do you have a manual ? I'd give it a try if you can test it - conversion >> should be simple enough (I have a coccinelle script which partially >> automates it), but this chip seems to have a fast timeout, and the >> comments in the code ("set the timeout to 81.92 us") seem to be quite >> obviously wrong. > > Yes, there is a public manual for that SoC, search for RDC R8610 and the > first link you find should be a 276 page long manual for the SoC. > I found two, one for R8610 and one for R8610-G. Unfortunately, none of those describes the use of bit(31) in the watchdog register, nor the meaning of bit(12) and bit(13). Bit(31) is described in the code as "Mask", and it is set by a couple of commands. I _suspect_ that bit(31) has to be set to change some of the register bits, for example the counter value. That is just a wild guess, but it would explain why the driver works in the first place. It is also not clear if the bits in the counter register are accumulative or if only the highest bit counts. The datasheets suggest that only the highest bit counts, but then the value of RDC_CLS_TMR doesn't make much sense since it sets two bits. Since you wrote the driver, I was hoping that you might have a datasheet which explains all this in more detail. Thanks, Guenter