Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp3722696ybl; Mon, 13 Jan 2020 01:16:42 -0800 (PST) X-Google-Smtp-Source: APXvYqwgyWscygtxT9Z1dA9rmTdUzvGysMkRorh3haPRo8caXgXORqnRpMCWahkgiVX4VbWMTkEY X-Received: by 2002:a9d:6b12:: with SMTP id g18mr11803095otp.211.1578907002770; Mon, 13 Jan 2020 01:16:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578907002; cv=none; d=google.com; s=arc-20160816; b=ddI1hItsxyWTkb3bu1xe5ZELnHl0wk0QUZCmjpvJKAQRrZ5dqkA4MBZB2E3NpJluR9 6Fm+YaIDUPoqtj9iZFPyOALrKrvRoxFosLZqFp4eL51mo1ddtYvCxEk5tsqYEzfVAR0w HBFCcaPiVj/tvpJBGaxsuBLl+Vn7KCCfXlMh5W5oXnyd08/RjS/SfCADVay1VOMxslFI BORmpc/aqQ2BulTY69zfDLweg8NO16Nl0RGo52dVoXdQ4M9xljMh9pnpqVs0B0koToF9 McsnU26MbWk3wE4rgtjC/NIf3B9QcbMN1O/2keuQi8BZd+Rv4kIQmojhJ+HiAqvCy6oJ ZEIA== 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:mime-version :message-id:date:subject:cc:to:from; bh=jrX1fmwG0t/WZpNdmsT4/qHDWlh495GK8jrzaxSn5gw=; b=P2cxMCYnm98Cof+2MrBwhg4TIVCmrZpi1oXUqUDbiUtVUsvaKUKbPWrLDF+eUbKNFA +VQfMbv5zR4dITkEFWkgAolxvsZgKG5ls2RlyLnP34jB9mzSNoYEquxC9KpRWr3ADzvq UcLzN7OM6KBBI2Xa51x/j2aSOeu5LronSC8jOLPlO9UhbM0IU3PC9MHIvBoAOl0ADW8t 9IGdT5cSsBOQwv7bFJMBL6qgSIHgyrZCMEb/Lu2QHun/pEyYeq/598I1Btiwl/YZmp+m BicesVLc9FSTuxUdDv57VLRGFdmy2T0P9JeEYOTG0ijoAe41mE+dNiTd+lFgqZjFMvhr edRQ== 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 t14si6604304otp.210.2020.01.13.01.16.30; Mon, 13 Jan 2020 01:16:42 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726804AbgAMJPg (ORCPT + 99 others); Mon, 13 Jan 2020 04:15:36 -0500 Received: from metis.ext.pengutronix.de ([85.220.165.71]:51241 "EHLO metis.ext.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725878AbgAMJPg (ORCPT ); Mon, 13 Jan 2020 04:15:36 -0500 Received: from dude02.hi.pengutronix.de ([2001:67c:670:100:1d::28] helo=dude02.lab.pengutronix.de) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1iqvop-0000XT-6m; Mon, 13 Jan 2020 10:15:31 +0100 Received: from mfe by dude02.lab.pengutronix.de with local (Exim 4.92) (envelope-from ) id 1iqvoo-0001dm-4X; Mon, 13 Jan 2020 10:15:30 +0100 From: Marco Felsch To: support.opensource@diasemi.com, linux@roeck-us.net, contact@stefanchrist.eu, Adam.Thomson.Opensource@diasemi.com Cc: linux-watchdog@vger.kernel.org, linux-kernel@vger.kernel.org, kernel@pengutronix.de Subject: [PATCH] watchdog: da9062: make restart handler atomic safe Date: Mon, 13 Jan 2020 10:15:21 +0100 Message-Id: <20200113091521.5754-1-m.felsch@pengutronix.de> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::28 X-SA-Exim-Mail-From: mfe@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The restart handler is executed during the shutdown phase which is atomic/irq-less. The i2c framework supports atomic transfers since commit 63b96983a5dd ("i2c: core: introduce callbacks for atomic transfers") but unfortunately the regmap framework doesn't support it yet. Hard coding the i2c stuff can be done without worries since the DA9062 is an i2c-only device. Signed-off-by: Marco Felsch --- Hi, This patch is based on Stefan Lengfeld's RFC Patch [1]. [1] https://patchwork.ozlabs.org/patch/1085942/ --- drivers/watchdog/da9062_wdt.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/drivers/watchdog/da9062_wdt.c b/drivers/watchdog/da9062_wdt.c index c9b9d6394525..84c5a0a455b2 100644 --- a/drivers/watchdog/da9062_wdt.c +++ b/drivers/watchdog/da9062_wdt.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -149,12 +150,18 @@ static int da9062_wdt_restart(struct watchdog_device *wdd, unsigned long action, void *data) { struct da9062_watchdog *wdt = watchdog_get_drvdata(wdd); + struct i2c_client *client = to_i2c_client(wdt->hw->dev); + u8 buf[] = {DA9062AA_CONTROL_F, DA9062AA_SHUTDOWN_MASK}; + struct i2c_msg msg = { + .addr = client->addr, + .flags = 0, + .len = sizeof(buf), + .buf = buf, + }; int ret; - ret = regmap_write(wdt->hw->regmap, - DA9062AA_CONTROL_F, - DA9062AA_SHUTDOWN_MASK); - if (ret) + ret = i2c_transfer(client->adapter, &msg, 1); + if (ret < 0) dev_alert(wdt->hw->dev, "Failed to shutdown (err = %d)\n", ret); -- 2.20.1