Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755020AbdDEMVg (ORCPT ); Wed, 5 Apr 2017 08:21:36 -0400 Received: from mail-dm3nam03on0076.outbound.protection.outlook.com ([104.47.41.76]:56576 "EHLO NAM03-DM3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753792AbdDEMU3 (ORCPT ); Wed, 5 Apr 2017 08:20:29 -0400 Authentication-Results: spf=pass (sender IP is 137.71.25.55) smtp.mailfrom=analog.com; kernel.org; dkim=none (message not signed) header.d=none;kernel.org; dmarc=bestguesspass action=none header.from=analog.com; Reply-To: Subject: Re: [PATCH v2] i2c/muxes/i2c-mux-ltc4306: LTC4306 and LTC4305 I2C multiplexer/switch References: <1490782541-7832-1-git-send-email-michael.hennerich@analog.com> <0d4c068f-d909-64be-421d-4500da7ebd4c@axentia.se> To: Peter Rosin , , , , CC: , , , From: Michael Hennerich Organization: Analog Devices Inc. Message-ID: <5d8dc69b-579d-09ee-2ad4-2d7336f9b4e3@analog.com> Date: Wed, 5 Apr 2017 14:21:17 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="windows-1252"; format=flowed Content-Transfer-Encoding: 8bit X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:137.71.25.55;IPV:NLI;CTRY:US;EFV:NLI;SFV:NSPM;SFS:(10009020)(6009001)(39410400002)(39860400002)(39840400002)(39450400003)(39850400002)(39400400002)(2980300002)(438002)(189002)(24454002)(199003)(189998001)(230783001)(31696002)(50466002)(54356999)(6666003)(33646002)(2950100002)(53546009)(64126003)(36756003)(4326008)(50986999)(76176999)(93886004)(229853002)(23746002)(43066003)(47776003)(2870700001)(4001350100001)(3450700001)(8676002)(65826007)(7636002)(356003)(65956001)(65806001)(8936002)(6246003)(86362001)(38730400002)(77096006)(305945005)(54906002);DIR:OUT;SFP:1101;SCL:1;SRVR:MWHPR03MB3150;H:nwd2mta1.analog.com;FPR:;SPF:Pass;MLV:sfv;MX:1;A:1;LANG:en; X-Microsoft-Exchange-Diagnostics: 1;BY2FFO11FD033;1:7zUK1PFFHPuLKQZn6QDvIn0/ZWKAUTTanZSZhAyDiu1LbNAYrS3DPgSDuTxn+E1NBr+/iv1OPqJU59kJTe/+IZCNxZXQkjjRWpFAIIHqm2AeSX8b8EUK2P9IRq41t+EpwJ+JSKKQXoiQm9MCZKSUNjCgZY0Dt8ubovrWpbo+AtAb3x1X8YvD1Gq2kphPKgCRLkhOIw5F2znAI9zhEzlRtVvFTMMehjZ3i/qddVnB8IS5xobciy4WRX7QOeI0govHPPtxqdj5I+xLAtd4ryF3M9OIcQTHF7kl0OkGER2YKa3FTBSXnRR0NWJ/7ROP83agnDKgrLWwfkYpJPlAOSL3wj8Je5ky6I68fi+IsC4KE9nd0VZeKVS7SbmvCguGwk0Z84WL3Ua2zg5nl/QOuaSzeiwwoWWrPk0s53mTPKs7NAaOo4GLYWJ4azczidPVY1t8+Uv4zaR/H17g8FocMf++j7u26Pv08eX8OSyl0NjV8jjGJse0e1Gq+6DE8/VUad1gT9bxru9Zo4RVcjuBoUKjX2xVxCcgS7AjJJAV4RQnNN2+WUU5vTE4GwjVlSginqv/EUH3CaAbeg8KnsiEZL3q8NR019oRRRd+MlKku2MooDWKuvoFItsiKioKmbgrKqgn X-MS-Office365-Filtering-Correlation-Id: 84e9eaf4-576a-40a8-bc50-08d47c1e11cb X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001)(8251501002)(2017030254075)(201703131423075)(201703031133081);SRVR:MWHPR03MB3150; X-Microsoft-Exchange-Diagnostics: 1;MWHPR03MB3150;3:SxpQWMrO1HTelAUgN71dChxY3JsrIwTTsmDP03C4ovr0iaAwPblQLokaNJKFol1vcQT9anIj9EipkC+SLRnA1cLlKhkESxKpB6adIaYV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M3RQkthJnItn46Va0qR+3MuNk+FOC9fjvKAC8YToxjUYjKyc8UUWor8tjgMfb2kPeLsQMM/aNu+94OKu8nEnGTz87c74Q== X-Microsoft-Exchange-Diagnostics: 1;MWHPR03MB3150;20:6A0TW1j+37RhuJZXbX7s+ihSFtiV+YRvNSrUpWTquslUG86MIQn7OnveWyRrXh2LZsFj1iMEzp9fZTBRewckKj90GEVncsLgRbwjfRUSzHdzysa5QQtK1FyGpFwt2QjJ3Edol8eLm6632muSySk+5fEpo8ApxvESjXOdYp6rK4xWe9LVpX6e6/EQzryKHZnkrBKU13h92TBTxMtlvifGtCSZqKJ0Sj0wPLV3XgH5bFnw0+tsBimYBWXw+fEmWSU3mvKDfw9PNPryZAx2QEB31tRwcU8ZzHC4rRrKmBnw74nr0G8ebuK4bpj8bN2c9Gtx2ZfxWfJ3gEehHmEd2ZJtONoKnL1Uel/ClzwvQRujh/R+2O5CpuWTNxMhtm9BAS12KALLUCQBga2r++mMcivMdvUOgbnoOL4p4EXru/68YPonZgBzZHtaruadnMdYNwPQPAAr0tucOYxllaRZL/n/qKCIZDlb/GBwudvbViEFWauPkWpgZBFt821dUqMq1VKt X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6040450)(601004)(2401047)(13024025)(13023025)(13018025)(13017025)(13015025)(8121501046)(5005006)(93006095)(93004095)(10201501046)(3002001)(6055026)(6041248)(20161123562025)(201703131423075)(201702281528075)(201703061421075)(20161123560025)(20161123555025)(20161123564025)(6072148);SRVR:MWHPR03MB3150;BCL:0;PCL:0;RULEID:;SRVR:MWHPR03MB3150; X-Microsoft-Exchange-Diagnostics: 1;MWHPR03MB3150;4:GYPM3kHzXJAX+JSPbJ1H5wj1mcxbpG2oN3uF2Q/BCPrhNuoUMMgTj7cTl9BgmX8LnmHksUFwjE7CMtw7aLACXysd6BTUqBFHQ7tMzHc5BOSyQEPANRc7FMoCmbyLjsG9Rd1uKS+oJuQ0wEol2OWNxX3admJCrD2PWwH3WA9h+B7QhuvukoZjeTM2OT8qYMJCnA7bgGZWAup1FKw0eNLK6F8vRZj1yfanLjxgLzG22h2dp0DrrPkU98OdHGkSjWebxyhLiPhy0qWHy1zXPpVvJk/Mqo5LHYagTH+7h/m0Le9O4n958oc+h0zBWwTf8Ici6KGPOKkzZ90Mg2HZP43PVXV1TNW8oaAqHsbLpisC3hE01ACa6vF6cUHqt6SpLehJcbLoCg4w/Fp4RZNjWW+VnFHJsUFbY/XZp+f+LeKcszUsMO+e3YMp8loMtCK0B10gQQeka0WdubQX79jw5bF5JFv3zbxxfqB7adQ9wtp1QtfW707c0gZhW731sJa2CblLEIEfN3rOkpotVnS3CNg6KnHfgzobx8PNi8jhFiRfChWCKk/VWRbDy83WL84/SDgVg9d+Gb52b5yocj7vnNZ5WmNcmFa8zX9QSWnTphNFhXOVbY3ULsddcdwz1XjdO692FusS/m/gvCUwyNrXVs3ve69+Yi5H387PrR9FFCLKHFY3YbxZpsjIwGgCLCgPiG/Zf33adFQ2wMeuuvCu+rVJY2LprXYPFcDIBdclJwHhpaTl4wuwM656ASMT+vTIIy2h5dPaTTvWfQj/grY5PudKZ0vcX2C6EtH6dK7oMIA8o1NI/BflQ+z34tkz3q06b09O685RbApg3PAqqPZgKYFmog== X-Forefront-PRVS: 0268246AE7 X-Microsoft-Exchange-Diagnostics: =?Windows-1252?Q?1;MWHPR03MB3150;23:phQA+6t3IBwcwEakr/RC64kFJCnQn4lcfV3yh?= =?Windows-1252?Q?ilagbNjHzbxFx+PKMKn5ihu6KUACVK/aNWLNjBVL3KrVq4SGGcY1giJS?= =?Windows-1252?Q?/2QKTXjic4ryoPVKONCs3sMatsW+72MrT9S0/5Sstx9ZVne/V7y5ZIrv?= =?Windows-1252?Q?uwESMtLtaiz+vdT11EZxMd4HlLP5RTjyK2j1dUI99aoolAH8Ww/UaPrS?= =?Windows-1252?Q?H2sdM+3JMwPPCqM1Ta9YcnTmPUPVW+y78fwq9qHbsGN+54XVhT78VE6J?= =?Windows-1252?Q?Z8UccOmeqth8IwYGZu+3OhsRb5fnUiDtln737epPKygdj9wBJuqka4iT?= =?Windows-1252?Q?e7mHP6luIFobCPeAB2Kk2iZTHY6oOW72VdjMc7cDwqROYomspcULb614?= =?Windows-1252?Q?CFC3u9tUaUvfG5vtm0CkjR1cfiLTkNmNkOBLx+YNRVESOVG6tK0ZxRbr?= =?Windows-1252?Q?6Jm+Iumx6vKe29DKaJszT0lXpeuKveJrsSJWjZyMne5Y6Bn76Bb1/gRp?= =?Windows-1252?Q?Xf/jhxwxfDGTGexI7D4Xwq8NiTtu3SuM33R2IFtaRwktpbGLNK6wZ26m?= =?Windows-1252?Q?Zw4ZlgkctB/nn8TYMjGQ618xbyNz1P/YangKipz84w8HXM/79JZWqPcC?= =?Windows-1252?Q?Fs+gBsQ41fMb9pGrkZ7aHBt0lD1tSxVDaXXh4xODuvJP55k7RqscWRdH?= =?Windows-1252?Q?xnnZVK1FrkeBaImkqx+dczLow4OST2lX7dqW1NhNt+79F1KncwI1Cj8e?= =?Windows-1252?Q?JowutlXLdVQW6e4lnn4Z91Lw+OkwHfBQvqavBDmpMHoB3lThOcZe8Z/X?= =?Windows-1252?Q?JmYvN5Y/Lg5XEqpnAkEF2cF6NUdJHokWDSouRvuyOibmVwo6Y9eFnECb?= =?Windows-1252?Q?9R2M1ewZmqSk3yEPDTIXDKQK/rKcYvd1O3zrdVLVN58pUBKgBZjl3ZNc?= =?Windows-1252?Q?9+8lAu3obK1mIhmZwZdMGx+hykDPvxtl6cAaVyIgzmGDoUD7w2bnQd/t?= =?Windows-1252?Q?u4b6GYvBi24XQ/mQ9DgoZEH0+SRkFvjgWgF3Z6ahCjSzUyGwqCd4wNYX?= =?Windows-1252?Q?G8YjnjGSf2lxZo4vugCjg0BmuhlASjuJsN088PXZXZVgNkcIRowtDgUj?= =?Windows-1252?Q?plhdc5jXEjUor1ucKvGTmYw3hrRJdNE35s3QbOgTVm+BE5kKngvNabgX?= =?Windows-1252?Q?+4tGiZuE0lpboLFEpRzGqKLjZqe9pyP6A6tpbi6Zyg5OVb+SnbFM/qcg?= =?Windows-1252?Q?KtZyhATjLXq1IUK7A=3D=3D?= X-Microsoft-Exchange-Diagnostics: 1;MWHPR03MB3150;6:3BAiifImDq1tetxxx68xyyB5YxjG/9VMAlnTHAy/JGxp9VOjs71cDsFw31aTETHamKkP/vr3tpL2n/yjLIJheiMbzscP6lUeXavg8RzxCUlrC2IQOs5mkBrKNo5hsWMvdzhTg+6Tn9IeKfVz2WS8mlAMp3OXeTKHFBJqyd4THyHIfpiMB4jDSGsOdh2LVTlNQeZcbaAfoArY54jYm+3WIMVP9kNLzMrkbMsagGsr6E6e3Yi1/gUQNRHeeGHbJtnNQncagsCzV3uEp9F5oQjtiaC91DTgU71fDd+rbLqQUVI2tUG9RZ7+O6gEd6MPkrtDUSOa+jc1meDzteTSpWxjBulZzZZdHC17BjgVblJPKJG6N8dusxmsSj5td8ER3xDjlbjCSUN4C31z+JoE8F7fIfGLXSri+fTbiEG8A+fmhc4=;5:VGPzu3l5kA6BCGcAaNPVHLdCRQeeKY6q8awgoaHkCHa1hVOUK36yq9cGEqZyGm+KwbA8t2gy+1Y7dSA/n5msvPsx9iXzb9u8rS8xF0pg6GxlLde2tuypUzav6VLkMrZQdjnYjKeBEyTNLiV0hTBiew==;24:snWj214ox1Z9s6McUM+Wv2WKqh4XVJXZqf6dThQJNd4IOL1Hn1q0wBYxycff25UfzRb3zvvhfmzAJhutipCug3PyavXqtB8J91M5iHo4Taw= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;MWHPR03MB3150;7:tuaDaK1kWIpkq9ZI5EtpKam4PJBQq0ArA7YXNONS6AUNHTbvhPBRJ19uFSeDKvz5WRczol3C5tlGSJ99C97rL+X5x3PIRMb0ieq6R9oe3FufegRvQiKiVEoWt8F7/ri/mOsa+6gUvWwSPJ1acZGIirFSTERTES3EAou8weB0eu+s+ZY7YW7b+nan+dt9jDRM6C9xROg/oOGtiSXg1s7SBOCOIptOGNTV2ETdlnuCJjCzVmucmIsBN60vgHbQnvNrtfL4hGUkbQkmbsvYd4K9m1o4WMnINyaj70WHgUgUg9XpdNjF5sennFvkpJh5/6XAx2s7WL+1TlHByZDauEjEig== X-OriginatorOrg: analog.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Apr 2017 12:19:55.2702 (UTC) X-MS-Exchange-CrossTenant-Id: eaa689b4-8f87-40e0-9c6f-7228de4d754a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=eaa689b4-8f87-40e0-9c6f-7228de4d754a;Ip=[137.71.25.55];Helo=[nwd2mta1.analog.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR03MB3150 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 4145 Lines: 103 On 04.04.2017 11:28, Peter Rosin wrote: > *snip* *snip* > >>>> +static int ltc4306_gpio_get(struct gpio_chip *chip, unsigned int offset) >>>> +{ >>>> + struct ltc4306 *data = gpiochip_get_data(chip); >>>> + int ret = 0; >>>> + >>>> + if (gpiochip_line_is_open_drain(chip, offset) || >>>> + (data->regs[LTC_REG_MODE] & BIT(7 - offset))) { >>> >>> I wonder about this open-coded register cache. So, gpio people, is there >>> a guarantee from gpiolib that only one gpio_chip operation is in flight >>> concurrently? Because I don't see any evidence of that. With that in >>> mind, I think some locking is needed? >> >> I thought there is a per chip mutex in the gpiolib. But I can't find >> anything like this either. Since these two gpios can be used from >> different internal or external users. The locking seem to be needed. >> >> This gets us back to the regmap option. I did a quick grep, and 9 out of >> 205 drivers using regmap i2c, also use i2c_smbus... concurrently. >> >> grep -Rl regmap_init_i2c ./drivers | xargs grep -l i2c_smbus_ | grep "\.c" >> >> Mostly to work around non uniform transfer layouts. > > I see three options. > > 1. Go with regmap and convert to mux-locked. Then the unlocked i2c-xfer > becomes an ordinary i2c-xfer (or smbus, whatever). This will result in > the cleanest code. ok - you convinced me. > > 2. Go with regmap and stay parent-locked. Then hook into the regmap > locking as is done in one of the drivers that have worked around similar > problems with regmap and parent-locked i2c-mux interactions: > > drivers/media/dvb-frontends/rtl2830.c > drivers/media/dvb-frontends/m88ds3103.c > > This will probably work, but you'd need to add a number of extra helper > functions. > > 3. Exclude register 3 from regmap and only use regmap for the other > registers. This will be a bit ugly and ad-hoc, will need clear comments > on what is going on and why it is safe etc. And I want to see it before > I accept it. And it might not be my call to begin with, because TBH, it > sounds a bit disgusting... > >> I'll check with Mark Brown on this topic. > > Ok, might be a good idea... > >>>> + >>>> +add_adapter_failed: >>>> + i2c_mux_del_adapters(muxc); >>>> +gpio_default: >>>> + gpiod_direction_input(data->en_gpio); >>> >>> This was actually not what I had in mind when I asked about it in v1, and >>> this looks a bit strange. You have no way of knowing if the pin was >>> configured as input when probe was called, and I don't see code like this >>> all over the place. Maybe it's is ok to not disable the chip over >>> suspend/resume, I was just asking because it looked a bit strange to grab >>> a pin and then forget about it. Now that I think about it some more, it's >>> probably ok to do just that since it is perhaps not possible to make the >>> chip draw less power by deasserting enable, but what do I know? >> >> GPIOs are assumed by default inputs. So if you want to undo the actions >> in probe. The logical consequence is to move them back to inputs, and >> let the external PULL-UP or PULL-DOWN on the ENABLE decide what happens. >> I would also prefer to leave it enabled, so that the GPIOs can retain > > My point is that I do not see any probe functions undoing gpio configs. > Why bother in this case? Or are other probe functions really doing this? > I actually didn't check, but I haven't stumbled over it previously and > at least think I would have noticed... > >> it's last state. Well I think the device draws a bit less power when >> disabled. But we don't support runtime PM anyways. > > It might not be safe to reset the gpio pins over a suspend/resume depending > on what they are used for, so it is probably a bad idea to go there. Sorry > for bringing the whole issue up and muddying the waters... I restore the original implementation and also pulse the ENABLE low so we're always doing a clean reset. I'll send a new patch shortly. Thanks! -- Greetings, Michael -- Analog Devices GmbH Otl-Aicher Strasse 60-64 80807 M?nchen Sitz der Gesellschaft M?nchen, Registergericht M?nchen HRB 40368, Gesch?ftsf?hrer: Peter Kolberg, Ali Raza Husain, Eileen Wynne