Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp1441354imm; Thu, 12 Jul 2018 01:48:42 -0700 (PDT) X-Google-Smtp-Source: AAOMgpf6znTWM2bbOWSVPPcOyQaJanfBdSQAzZH7okRXld10+Zdg+U36br05ZhPQ5YrSl/hoogBO X-Received: by 2002:a62:43c8:: with SMTP id l69-v6mr1451991pfi.196.1531385322408; Thu, 12 Jul 2018 01:48:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531385322; cv=none; d=google.com; s=arc-20160816; b=TM7PCn5+Mk6IPHvVcMgiW7MCJ3Jo1JU1c3lfS2FkxPPzFmDA37Lp4dHf2kq+u2tT/F p2464owlnGpfPkXiAv0lpYK6ven+OLAuqnNyMVMmSuGyjO4EtN5s99SZfll6PwqXaGqy 1twMyiD8LEb/eMp6R9vWreT7XlV3+L/6UqtYnIK4cui5eKUIAwgK1mgSIbOR2cfu+Sih yeHt7DgbX202+qaggSZuaEdBDzlEst5F4H9FV7Rf/rwRx+tW4MP9KuC2iuWcS9z8YAKL Ht5iq+G4jhgKlWQo/xDH5L8ps+UkrU/N4NJbP/zeIfhiA8M8lfwv4CaEfP4cZRxcpsY4 qesQ== 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 :references:in-reply-to:message-id:subject:cc:to:from:date :arc-authentication-results; bh=vTKL7Or2yRNl6mogRnbwioKxditXvlnMi6v4l/csqW4=; b=sGGDosH4HgxJOxC5vn0oU04WnAeSBvZD7Z/mbK+h5CVZdiQQnP+xQcrkIj8xfJjwJv EYFPqdJYlUj3i5KUPMV26xZ8IGeVzxzrevJkT5tdNBR7X1U+6WCPpNej4W1nC3jBDftm zU0CuYrS32GcfpVOgSxfA4GDd82Xi3zzIr3gFQ91DFtdpm3+oKRYnAs+UfAU10PmEmZi PO2ewKArT7hUmrJzpJxerM4CGopOtNjIH7vYXTxaTcxxL8raIBpa2ltAF2amMw+GcJXk HVX8zzI26Mv31Q++f/pBl/1zhwk6/07DkFdGUkJIE3syiXTXGld1gT758M5MP81Tx2t3 qlkQ== 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 a16-v6si20807066pga.168.2018.07.12.01.48.26; Thu, 12 Jul 2018 01:48:42 -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; 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 S1732307AbeGLIzs convert rfc822-to-8bit (ORCPT + 99 others); Thu, 12 Jul 2018 04:55:48 -0400 Received: from mail.bootlin.com ([62.4.15.54]:54091 "EHLO mail.bootlin.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726393AbeGLIzs (ORCPT ); Thu, 12 Jul 2018 04:55:48 -0400 Received: by mail.bootlin.com (Postfix, from userid 110) id 4DC7E2072B; Thu, 12 Jul 2018 10:47:09 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mail.bootlin.com X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,SHORTCIRCUIT shortcircuit=ham autolearn=disabled version=3.4.0 Received: from bbrezillon (AAubervilliers-681-1-12-56.w90-88.abo.wanadoo.fr [90.88.133.56]) by mail.bootlin.com (Postfix) with ESMTPSA id ABD5720012; Thu, 12 Jul 2018 10:46:58 +0200 (CEST) Date: Thu, 12 Jul 2018 10:46:58 +0200 From: Boris Brezillon To: Arnd Bergmann Cc: Wolfram Sang , linux-i2c@vger.kernel.org, Jonathan Corbet , "open list:DOCUMENTATION" , Greg Kroah-Hartman , Przemyslaw Sroka , Arkadiusz Golec , Alan Douglas , Bartosz Folta , Damian Kos , Alicja Jurasik-Urbaniak , Cyprian Wronka , Suresh Punnoose , Rafal Ciepiela , Thomas Petazzoni , Nishanth Menon , Rob Herring , Pawel Moll , Mark Rutland , Ian Campbell , Kumar Gala , DTML , Linux Kernel Mailing List , Vitor Soares , Geert Uytterhoeven , Linus Walleij , Xiang Lin , linux-gpio@vger.kernel.org Subject: Re: [PATCH v4 01/10] i3c: Add core I3C infrastructure Message-ID: <20180712104658.220ef8f6@bbrezillon> In-Reply-To: References: <20180330074751.25987-1-boris.brezillon@bootlin.com> <20180330074751.25987-2-boris.brezillon@bootlin.com> <20180711164120.3e32fb08@bbrezillon> <20180711191212.3855bb25@bbrezillon> <20180712000932.3b04ee9d@bbrezillon> X-Mailer: Claws Mail 3.15.0-dirty (GTK+ 2.24.31; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 12 Jul 2018 10:21:40 +0200 Arnd Bergmann wrote: > On Thu, Jul 12, 2018 at 12:09 AM, Boris Brezillon > wrote: > > On Wed, 11 Jul 2018 22:10:26 +0200 Arnd Bergmann wrote: > >> On Wed, Jul 11, 2018 at 7:12 PM, Boris Brezillon wrote: > >> > On Wed, 11 Jul 2018 17:39:56 +0200 Arnd Bergmann wrote: > >> >> On Wed, Jul 11, 2018 at 4:41 PM, Boris Brezillon wrote: > > >> >> IOW, what feature would we lose if we were to declare that > >> >> setup above invalid (and ensure you cannot represent it in DT)? > >> > > >> > That's exactly the sort of discussion I wanted to trigger. Maybe we > >> > shouldn't care and expose this use case as if it was X different I3C > >> > buses (with all devices present on the bus being exposed X times > >> > to the system). > >> > >> That's probably fine for many slave devices (you could read a > >> single sensor multiple times if you iterate through all i2c sensors > >> on all buses) but might not work for others (a slave device sending > >> an interrupt to the current master for a request that was started > >> from the previous master). > >> My impression however is that this is actually a corner case that > >> we can leave to be undefined, and not prepare to handle well, > >> as long as we can deal with the interesting examples above. > > > > Mastership handover/takeover is something I already thought about. > > Actually, that's the reason for the i3c_bus->cur_master field (so that > > the master being asked to do a transfer on the bus can request bus > > ownership it bus->cur_master != master->this->info.pid). > > > > I guess this would be replaced by something simpler if we get rid of > > the i3c_bus object (just a bool i3c_master->owns_bus). > > If we can ignore the case of handing over between two masters that > we both own, we end up being in just one of two states: > > a) currently we are the master > b) we are not currently the master but have asked the current > master to transfer ownership back to us. For this, we have to > know who the current master is of course. > > I think that's the simplest case that would work with the specification, > but it relies on the assumption that the master controlled by Linux > is always more important than any other master, and that we just > hand over ownership for as long as the others want it. > > If that is not the case, we also need a third state > > c) we have handed ownership to another master that is equally > important, but no i2c device driver is currently trying to talk > to a device, so we don't need ownership back until a slave driver > changes state. That was the solution I was opting for. > > The main difference between b) and c) that I see would be what > happens with in-band interrupts. If I understand the specification > correctly, only the current master receives them, so if you have > any i2c device that uses interrupts to talk to a Linux driver, we ^ you mean i3c here, right? > want to be in b) rather than c). An example of this would be > an input device on a PC: If the user operateds the keyboard > or pointer and we have handed off ownership to a sensor hub, > we never get an input event, right? Correct. I guess we could try to regain bus ownership in case we have IBIs enabled. Or we let the secondary master give the bus back to us when it sees IBIs it can't handle, as described in section 5.1.7: " Once granted control of the Bus, the Secondary Master maintains control until another Master is granted Bus control. After the Secondary Master transitions to the Current Master role it could encounter Bus management activities besides the data transfers that it itself initiates. Some examples are the In-Band Interrupt, or the Hot-Join request. One optional possibility, shown at Section 5.1.7.2, is that the Secondary Master performs the Current Master’s actions with the full capabilities of the Main Master. Another optional possibility is that the Secondary Master, while serving in the Current Master role, could defer some actions to a more capable Master, as described in Section 5.1.7.3. " > > >> Ok, but maybe you could you put the information about those devices > >> on a local list on the stack rather than the controller? I suppose this > >> would not change the logic much, but it would slightly simplify the > >> data structures for the bus and stop others from wondering about > >> them. ;-) > > > > This has changed a bit in the v6 I'm about to send (probably next week). > > I now have 2 different objects which do not necessarily have the same > > lifetime: > > > > * i3c_dev_desc: an I3C device descriptor. This is the representation > > exposed to I3C master controller drivers which usually reserve one > > slot in the HW device table per-device on the bus. Since the same > > device can be re-discovered with a different address, we have a short > > period in time during which the controller will have 2 > > slots/descriptors used to control the same device, except one would > > be inactive (any transfer to the old dynamic address would fail) and > > the other one would be active. The core then takes care of releasing > > the old descriptor/slot and attaching the new one to the i3c_device > > object exposed to I3C device drivers > > > > * i3c_device: this is the object exposed to I3C device drivers. It's > > lifetime is usually the same as the i3c_dev_desc it's attached to, > > except when the device lose its dynamic address and get a new one > > assigned. In this case we keep the same i3c_device object, but > > dynamically re-attach it to a new i3c_dev_desc before releasing the > > old dev desc. This way the I3C does not even see that the device > > address has changed and can keep doing transfers to it. > > > > With these 2 distinct representations, the handling on the controller > > side is greatly simplified: the core takes care of the resource > > migration steps, while it was up to the controller to do that my > > previous versions (look at the ->reattach_i3c_dev() hook in the Cadence > > driver, and I think it's even more complicated with other controllers, > > like the HCI one). > > > >> This is a really minor point though, let's work out the problem of the > >> multiple masters first. > > > > I agree. This being said, moving to a representation where the bus is > > implicitly represented by the master_controller instance shouldn't be > > too difficult. So, if you think we should try this approach I can do > > the modifications in my v6. > > I'd say let's wait before you do that change, possibly add a comment > in there now to remind us of what an alternative would be. You mean I should keep the i3c_bus object?