Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp1373375img; Tue, 19 Mar 2019 06:24:09 -0700 (PDT) X-Google-Smtp-Source: APXvYqzgMLRGsJ2nOdluZZiJr3X6kwZ5UOF5W5O1tmsf/kWrWjAcCRflICfe3zAfS2fWNrYLToKA X-Received: by 2002:aa7:9289:: with SMTP id j9mr1957863pfa.130.1553001849058; Tue, 19 Mar 2019 06:24:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553001849; cv=none; d=google.com; s=arc-20160816; b=1BoXxXBLz6qzJojBXIrgDN0+SAOoYG3VCtEST/j0czRSCCDtmc+i1gigoID0yaKCoD wUMJLxUuEi/K+A+e7z6LT5jJE3pg0y0fRH5qrAykIdjFuRv+MyYSQlwlkO8h0Fc0xttx I8qdogXMNRgJLesm+5xEWfMCr1M9qXbgJ+CeZKyIiKuVKp0hRXdQUwKxCTxU/LVF5AfQ bIqgxeDOVg078smmH88vXVBLXonm5NGlPvDuBGEzgObyXszW5gdNLAFufrk/BFDd6SjN /hkYCLvL/CS0TrovUsdmF1vwS+JRkcc4LMl+wLR9h8ptE5YggOcgrIp2q7T+50e9grPn 4+9A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:references:message-id :content-transfer-encoding:cc:date:in-reply-to:from:subject :mime-version:dkim-signature; bh=6xQLzLjON/fGXa/2mLahHLOGkWeJ4HAYM2bQPijfEBY=; b=OQGnuD/IxbHG4UuZQIFO+NULm2v4SS45ogKvxQJym8Ks6ujN/t2VFDPDlb2auBdOdR pdaeY+Q5J7vb9fVewBJmnA3YcOqJXGyDj0nQmHlo695wmAXzjRf2Jhdd8FyuLKTgX6i5 0fH70AEceTHiBgmgdWVjmVz/0ioea2JR1kNLP30ICv8MzjpG1omPMv4hH0Io32BQdgkS R2IRqjxDJWk4xglGom9t08BG19rZBGLWf5JHh91zIfyChGRKziisNp6CqEgJK4e5ac/A kR9yXpjPg1kzH60urC0zE+cNRM3AmBUZSxui8Bh0AVdOrz7NivD/XVina+HAPtn8y0De xPyg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="WW/bNg9h"; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x7si11897063plr.73.2019.03.19.06.23.53; Tue, 19 Mar 2019 06:24:09 -0700 (PDT) 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; dkim=pass header.i=@gmail.com header.s=20161025 header.b="WW/bNg9h"; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727466AbfCSNVT (ORCPT + 99 others); Tue, 19 Mar 2019 09:21:19 -0400 Received: from mail-qt1-f194.google.com ([209.85.160.194]:35791 "EHLO mail-qt1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725951AbfCSNVT (ORCPT ); Tue, 19 Mar 2019 09:21:19 -0400 Received: by mail-qt1-f194.google.com with SMTP id h39so22036092qte.2 for ; Tue, 19 Mar 2019 06:21:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=6xQLzLjON/fGXa/2mLahHLOGkWeJ4HAYM2bQPijfEBY=; b=WW/bNg9hBvoXolIUz9XFO8KngjkJnWleG4JDrZbVWLfzXcdLMKY37DPQDXiqGt1psp ATv/b/Jac+KiyQ1DAnZ3f6x7MVIaV7WX/b4sB1eBLyY9d0Jyz1XoULyoEe92bHQ4WSQh MW2EpB7HImwT4lKiV37QvgOf6zPisbaN7B3yv5vKwS/jv6/suxVkPO57bMC+x6EmSAEg IeJASMQ7ZSqDxXY9+TbsXJGqFH98KLRR78MbO4ZJIRd0q8svhgNPUhu8FgHrDN11Xz/B A7v/mHMJWl5mw4xKQZcz+mZAUqa2sT2ZmQpd9qBzG+S4VsIlF4YJn2t1F7aKuG2HXFrd a47g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=6xQLzLjON/fGXa/2mLahHLOGkWeJ4HAYM2bQPijfEBY=; b=R3R70Hcug4tb4tlzlKTPJA2zR0mRbB9N7+nwHeq+FCMCk64HoJnXuzAdCTwldkNiPi LZA1wK8jnFiBUSn68JsFfiqi5+xvJBbeNwaT26QINMHEJbgVISCjuvPe2XPppvoCnfUB qCGXZU/jwstEjK3PxA3DjrbR9s6LBBul1CEeULKTC6Zs4s9RAD09i90VUptwFiTcI3tn Thl1OId8LLE6pXyVUU/pQ0O0d8p4/j/urJHvXS0L2d02pt10wvlYA6dqwuwjqAE4r8jX ZBJjDpVBV0ttbW6gjVqQ3ZPxTwgn9flaXFVHktPh/tP3NEZLvgCksxaJtfldKk2RDh/n BEow== X-Gm-Message-State: APjAAAWaV9XheRPCbZPm5uAnXv9yv+9kqgt3q3xv8wJYHmOcmzLOvA6C uX3nW5fPRUqHHiObpfKx7EsxftJe X-Received: by 2002:a0c:9e65:: with SMTP id z37mr1763034qve.152.1553001678525; Tue, 19 Mar 2019 06:21:18 -0700 (PDT) Received: from jfdmac.sonatest.net (ipagstaticip-d73c7528-4de5-0861-800b-03d8b15e3869.sdsl.bell.ca. [174.94.156.236]) by smtp.gmail.com with ESMTPSA id j9sm7200684qtb.30.2019.03.19.06.21.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 19 Mar 2019 06:21:17 -0700 (PDT) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 12.2 \(3445.102.3\)) Subject: Re: [PATCH 2/2] w1: fix the resume command API From: Jean-Francois Dagenais In-Reply-To: <20190318092737.8170-3-manio@skyboo.net> Date: Tue, 19 Mar 2019 09:21:16 -0400 Cc: linux-kernel@vger.kernel.org, Evgeniy Polyakov , Greg Kroah-Hartman Content-Transfer-Encoding: quoted-printable Message-Id: <6836A9A3-AF86-4E2F-9215-647CB36E22DA@gmail.com> References: <20190318092737.8170-1-manio@skyboo.net> <20190318092737.8170-3-manio@skyboo.net> To: Mariusz Bialonczyk X-Mailer: Apple Mail (2.3445.102.3) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Mariusz, I appreciate your work on this. > On Mar 18, 2019, at 05:27, Mariusz Bialonczyk = wrote: >=20 > =46rom the DS2408 datasheet [1]: > "Resume Command function checks the status of the RC flag and, if it = is set, > directly transfers control to the control functions, similar to a Skip = ROM > command. The only way to set the RC flag is through successfully = executing > the Match ROM, Search ROM, Conditional Search ROM, or Overdrive-Match = ROM > command" Indeed, figure 12-2 flow chart shows that SKIP_ROM resets RC to 0, then = RESUME looks for RC=3D=3D1 to enter the control function "mode". Nice find! I don't know however if other slaves are like that. Since the true = impact of your suggested change is indeed null on the bus (bit count wise). I = guess even this specific slave case is enough to warrant the change in the subsys. >=20 > The function currently works perfectly fine in a multidrop bus, but = when we > have only a single slave connected, then only a Skip ROM is used and = Match > ROM is not called at all. This is leading to problems e.g. with single = one > DS2408 connected, as the Resume Command is not working properly and = the > device is responding with failing results after the Resume Command. >=20 > This commit is fixing this by using a Skip ROM instead in those cases. > The bandwidth / performance advantage is exactly the same. >=20 > Refs: > [1] https://datasheets.maximintegrated.com/en/ds/DS2408.pdf >=20 > Signed-off-by: Mariusz Bialonczyk > Cc: Jean-Francois Dagenais Reviewed-by: Jean-Francois Dagenais > --- > drivers/w1/w1_io.c | 11 +++++++++-- > 1 file changed, 9 insertions(+), 2 deletions(-) >=20 > diff --git a/drivers/w1/w1_io.c b/drivers/w1/w1_io.c > index 0364d3329c52..4697136b9027 100644 > --- a/drivers/w1/w1_io.c > +++ b/drivers/w1/w1_io.c > @@ -432,8 +432,15 @@ int w1_reset_resume_command(struct w1_master = *dev) > if (w1_reset_bus(dev)) > return -1; >=20 > - /* This will make only the last matched slave perform a skip = ROM. */ > - w1_write_8(dev, W1_RESUME_CMD); > + if (dev->slave_count =3D=3D 1) { > + /* Resume Command has to be preceeded with e.g. Match = ROM which is > + * not happening on single-slave buses, just do a Skip = ROM instead > + */ > + w1_write_8(dev, W1_SKIP_ROM); > + } else { > + /* This will make only the last matched slave perform a = skip ROM. */ > + w1_write_8(dev, W1_RESUME_CMD); > + } This may be a subsys maintainer's style preference, but perhaps the = verbose comments might be better suited for the git commit message. Could this then be = shorted to if (dev->slave_count =3D=3D 1) w1_write_8(dev, W1_SKIP_ROM); else w1_write_8(dev, W1_RESUME_CMD); Or maybe: w1_write_8(dev, dev->slave_count > 1 ? W1_RESUME_CMD : = W1_SKIP_ROM); I am also ok with this proposed version, hence the "reviewed-by". > return 0; > } > EXPORT_SYMBOL_GPL(w1_reset_resume_command); > --=20 > 2.19.0.rc1 >=20