Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp5448670imu; Wed, 19 Dec 2018 11:20:02 -0800 (PST) X-Google-Smtp-Source: AFSGD/VfZKhnYcIamQctUhoRyG7XQMGmJAZlFCdLUd88N9cKF1NwbOYnMRzP8yUh3zYXT8Lk7kKj X-Received: by 2002:a62:c21c:: with SMTP id l28mr21367413pfg.74.1545247202106; Wed, 19 Dec 2018 11:20:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545247202; cv=none; d=google.com; s=arc-20160816; b=d9PVSeq6uPYXLFjGKmZMZMHwBvtFtWUTQUk9kyTrV7d1+Q8u2BjsekFmaEfkg19Hbl S+rp+vzTQFstwZedgMWXCTiZxx9d/3sdyDQVUtnqWiRSrbn2Q76RPU0mUtJLAqQtvEx/ aj/LqBr+bZdAnta4mSgPS+4oMktVMqN+CsJazgN+m1WyL4rAopjJE6DRdD851vXR6+xs luo0xxXN57SPukl5hlSiy8u1yMyEJqgl0osN6nO7ZeV62umTwL2Qw/UbJY2Ju4C5pNJh 9frBOZYqCiE6XQXMTAOI7PmSedyHLXhybof4Kg0ls6dF+eazNaNahruK6rv/akQ1EU+E rxbQ== 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=SeMoYYRoyywUMQiBfYtyiBEqpBgxDAi4Kzp38E75PII=; b=pvmbzU0H+WW2yCXb/IMS4rCXL/oDcAnZle1h3OUZwm2fmjx4ghNIqZIiK/CzJfuu/I KglhwllF4x66yHDNHGBV3cz1zCra2nIdHPopNy/6BRqXHz8ioeZcVkqC+XbyA+dd3j5m yWEqLmEK2vyn1ASHFUDdWP+FeXDccfdVS3RBLwQYSXWTktiobgyESwN5oOZMs0kSLeE0 4oP9VnyAr9fzjCOABnIYLkF+u2J6DqlhB4eI2mOKHgK9f7pcUjgjTNw2iTS6AXL0WWVa 21GKklcjUcLL0l6f6BztEALY5oYRPFpHaXHEkyDIF+2ne3Rnf41sk9LLPzuSqyFylrhs IzmA== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q7si17075895pfa.99.2018.12.19.11.19.46; Wed, 19 Dec 2018 11:20:02 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729546AbeLSSg6 (ORCPT + 99 others); Wed, 19 Dec 2018 13:36:58 -0500 Received: from mail-wm1-f65.google.com ([209.85.128.65]:50261 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729161AbeLSSg6 (ORCPT ); Wed, 19 Dec 2018 13:36:58 -0500 Received: by mail-wm1-f65.google.com with SMTP id n190so7093975wmd.0 for ; Wed, 19 Dec 2018 10:36:56 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=SeMoYYRoyywUMQiBfYtyiBEqpBgxDAi4Kzp38E75PII=; b=B/ivXX9fJcAyQ9wTWE+AHKue+kznun72Rcli9fOe1EYG06m6NI/PFzZE/NDrEazJv0 5bP2H6ajjYLgyGkLIpJZG737fYaZjJrE+d0h0wfT04BkgIgwzU+wVMz0IsWOmDN+kVqg D4vCtdSITaB1IryfTdCEixEIE5RnlXD1w8cFFaVReCoMzo3ENqzXLluiStFqGjeumHPf JUjJ3mrXRxC2hRsAIy9EQJbCXeVNs28RBa5xTUE9JRwRSto0ODUhMj19ySnOpazc/u4d 9FP42WsthSBs6b7ydVPBKqXHYYLKp9qMA0SEWIJo84z+lFlLNWhBrscw8idlZgFYB0mB YTqQ== X-Gm-Message-State: AA+aEWaJp9wkDTqT2epkKofZtHULLe0wdIEtY9dDjqRRpFP0eiHz/Qk1 A+fmz+Xn8dETTTqQ/Km5XTSq3aLdsgk= X-Received: by 2002:a1c:d912:: with SMTP id q18mr8153087wmg.122.1545244615827; Wed, 19 Dec 2018 10:36:55 -0800 (PST) Received: from shalem.localdomain (546A5441.cm-12-3b.dynamic.ziggo.nl. [84.106.84.65]) by smtp.gmail.com with ESMTPSA id x20sm8926562wme.6.2018.12.19.10.36.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 19 Dec 2018 10:36:55 -0800 (PST) Subject: Re: [PATCH 01/10] i2c: add suspended flag and accessors for i2c adapters To: Lukas Wunner , Wolfram Sang Cc: linux-i2c@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Wolfram Sang , linux-kernel@vger.kernel.org References: <20181219164827.20985-1-wsa+renesas@sang-engineering.com> <20181219164827.20985-2-wsa+renesas@sang-engineering.com> <20181219172250.ytronxeq2yc4vp4r@wunner.de> From: Hans de Goede Message-ID: <83b17734-2437-5a04-8843-e18ccf7ad398@redhat.com> Date: Wed, 19 Dec 2018 19:36:54 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.3.1 MIME-Version: 1.0 In-Reply-To: <20181219172250.ytronxeq2yc4vp4r@wunner.de> Content-Type: text/plain; charset=utf-8; format=flowed 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 Hi, On 19-12-18 18:22, Lukas Wunner wrote: > On Wed, Dec 19, 2018 at 05:48:17PM +0100, Wolfram Sang wrote: >> +static inline void i2c_mark_adapter_suspended(struct i2c_adapter *adap) >> +{ >> + i2c_lock_bus(adap, I2C_LOCK_ROOT_ADAPTER); >> + set_bit(I2C_ALF_IS_SUSPENDED, &adap->locked_flags); >> + i2c_unlock_bus(adap, I2C_LOCK_ROOT_ADAPTER); >> +} > > This looks like a duplication of the is_suspended flag in struct dev_pm_info. > Any reason why you can't use that? If so, it would be good to document the > reason in the commit message. Oh, that is a very good point and that one only gets set on system suspend and not on resume suspend, working around the problems with the i2c-designware driver. I think this might be as simple as adding: if (WARN_ON(adap->dev.parent->power.is_suspended)) return -ESHUTDOWN; To __i2c_transfer (and document the -ESHUTDOWN) combined with removing all the now no longer DIY code from various bus drivers. Regards, Hans > > If the point is to constrain refusal of transfers in suspended state to > certain drivers, those drivers could opt in to that functionality by > setting a flag, and the i2c core could then gate refusal based on > that flag and the is_suspended flag in struct dev_pm_info. > > Also, why is it necessary to take a lock to perform an atomic bitop? > (Sorry if that's a dumb question, seems non-obvious to me.) > > Thanks, > > Lukas >