From patchwork Mon Jan 21 16:47:41 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Shearman X-Patchwork-Id: 1028761 X-Patchwork-Delegate: patchwork@peda.user.lysator.liu.se Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-i2c-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="N95WEkTC"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 43jyCj4Js3z9s7T for ; Tue, 22 Jan 2019 03:48:01 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730171AbfAUQsA (ORCPT ); Mon, 21 Jan 2019 11:48:00 -0500 Received: from mail-wr1-f68.google.com ([209.85.221.68]:36813 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729940AbfAUQr7 (ORCPT ); Mon, 21 Jan 2019 11:47:59 -0500 Received: by mail-wr1-f68.google.com with SMTP id u4so24197106wrp.3; Mon, 21 Jan 2019 08:47:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=sHbgmgpwNDM8hyU0ywe19gF8jTaoNhxjen0iEn2P3T0=; b=N95WEkTCjPk0VnsyEtFS1P74UoJFU90eGoRbipal8+Q2SucuWUH8YW8NvBKmH2Rb3/ 4wmGGTiRjznpJbulAUyBX+c/FotTsZ7nEOv8dGoX9z/R0t+HfBGbM81W1Se1LTKBInJQ vbNkkDsbDJ+Q3K91XhO8+TuA/8xUsugiHWlKx0abtX1e753HSkIbM9yZygdnWdlABZBL DAris+CqxCrXM1wS2ino9XEohpfMhYvTr9/RyA+FlnsBWWPLIXimJMRv+jtR8x23ZPg2 OBaA3es6xfEIZI36ephmFfKCDRguADraNQ8Hjp0DAsCMod4NTHRdO5aXvref0omIzCp8 M6Pw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=sHbgmgpwNDM8hyU0ywe19gF8jTaoNhxjen0iEn2P3T0=; b=RgWPBfgBbBztegh+nf6pwnIYxv6H1SY4sm7pO8TJxC0bEnNFQXkv8bFUmsg6woebOc 2aEt7CgGCHcrni8xQxgsi/wK2JUar3P4FV/V59cjwKI6HQ6dJJRj4WJliP5PzoVWngsA 0xPsj0Erb+9wHiLF1icW/RSVUjZIL5VO37DDEN7/z/WrzGiMA6rUqIL/pubUBFhp3zz+ Kw13caF+uCnJ4KykTFGvMhMCIuwRGUkRDJBfWfDYTPDedjw8ccBX+b37xoxkSsi9UQ5B OBa8qCi83pi6BL25+7cSuuGzVdDpVhP0MbwoHYiHXAm5dvV18uV2wjTXlS429+RxJxRJ 1p9g== X-Gm-Message-State: AJcUukcNC59WjohcQgfaJy1oCk5zeFP2ifeuXcq+OMWRVq27rihhSXG+ BAtxA5WJVgf36gYApK3TmnM= X-Google-Smtp-Source: ALg8bN6MAaBOi+B5D4Ii5SvqELRf9kPG6GS3coQ1HXXpEwUQ+GyecGUbYnT1bMmPQFSBLPN8pbTxWA== X-Received: by 2002:adf:e247:: with SMTP id n7mr27625828wri.205.1548089277892; Mon, 21 Jan 2019 08:47:57 -0800 (PST) Received: from uks1.vyatta.net ([137.221.143.78]) by smtp.gmail.com with ESMTPSA id b18sm81681003wrw.83.2019.01.21.08.47.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 21 Jan 2019 08:47:57 -0800 (PST) From: Robert Shearman To: Peter Rosin , Rob Herring , Mark Rutland Cc: linux-i2c@vger.kernel.org, devicetree@vger.kernel.org, Robert Shearman Subject: [PATCH 1/2] i2c: mux: pca954x: change the default to deselect after each transfer Date: Mon, 21 Jan 2019 16:47:41 +0000 Message-Id: <20190121164742.35718-1-robertshearman@gmail.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Sender: linux-i2c-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org From: Robert Shearman The behaviour, by default, to not deselect after each transfer is not safe/correct when there is a device with an address that conflicts with another device either on the parent bus, or on another pca954x mux on the same parent bus. Therefore, default to the least surprising mode, where the mux channels are deselected after each transaction, which is safe in the face of one or more devices hanging off the mux with addresses that conflict with other devices on different muxes, or on the parent bus. On systems where it is guaranteed that this is not the case, then the i2c-mux-no-idle-disconnect devicetree or no_deselect_on_exit platform data options can be used to improve the performance. Signed-off-by: Robert Shearman --- drivers/i2c/muxes/i2c-mux-pca954x.c | 16 +++++++++------- include/linux/platform_data/pca954x.h | 6 +++--- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/drivers/i2c/muxes/i2c-mux-pca954x.c b/drivers/i2c/muxes/i2c-mux-pca954x.c index bfabf985e830..c2b6cff4ba3c 100644 --- a/drivers/i2c/muxes/i2c-mux-pca954x.c +++ b/drivers/i2c/muxes/i2c-mux-pca954x.c @@ -351,7 +351,7 @@ static int pca954x_probe(struct i2c_client *client, struct pca954x_platform_data *pdata = dev_get_platdata(&client->dev); struct device *dev = &client->dev; struct device_node *np = dev->of_node; - bool idle_disconnect_dt; + bool no_idle_disconnect_dt; struct gpio_desc *gpio; int num, force, class; struct i2c_mux_core *muxc; @@ -412,9 +412,10 @@ static int pca954x_probe(struct i2c_client *client, } data->last_chan = 0; /* force the first selection */ + data->deselect = GENMASK(data->chip->nchans, 0); - idle_disconnect_dt = np && - of_property_read_bool(np, "i2c-mux-idle-disconnect"); + no_idle_disconnect_dt = np && + of_property_read_bool(np, "i2c-mux-no-idle-disconnect"); ret = pca954x_irq_setup(muxc); if (ret) @@ -422,7 +423,7 @@ static int pca954x_probe(struct i2c_client *client, /* Now create an adapter for each channel */ for (num = 0; num < data->chip->nchans; num++) { - bool idle_disconnect_pd = false; + bool no_idle_disconnect_pd = false; force = 0; /* dynamic adap number */ class = 0; /* no class by default */ @@ -434,10 +435,11 @@ static int pca954x_probe(struct i2c_client *client, } else /* discard unconfigured channels */ break; - idle_disconnect_pd = pdata->modes[num].deselect_on_exit; + no_idle_disconnect_pd = + pdata->modes[num].no_deselect_on_exit; } - data->deselect |= (idle_disconnect_pd || - idle_disconnect_dt) << num; + data->deselect &= ~((no_idle_disconnect_pd || + no_idle_disconnect_dt) << num); ret = i2c_mux_add_adapter(muxc, force, num, class); if (ret) diff --git a/include/linux/platform_data/pca954x.h b/include/linux/platform_data/pca954x.h index 1712677d5904..cb5359797867 100644 --- a/include/linux/platform_data/pca954x.h +++ b/include/linux/platform_data/pca954x.h @@ -29,13 +29,13 @@ /* Per channel initialisation data: * @adap_id: bus number for the adapter. 0 = don't care - * @deselect_on_exit: set this entry to 1, if your H/W needs deselection - * of this channel after transaction. + * @no_deselect_on_exit: set this entry to 1, if your H/W doesn't need + * deselection of this channel after transaction. * */ struct pca954x_platform_mode { int adap_id; - unsigned int deselect_on_exit:1; + unsigned int no_deselect_on_exit:1; unsigned int class; };