Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp1422450imm; Thu, 12 Jul 2018 01:23:03 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdcPFIAqPBeMbOVqAXBUmZiyMmjez5iRn8bFpJryusIaukw9EDhDPFXt/HBu3TPveW93Oyo X-Received: by 2002:a63:3190:: with SMTP id x138-v6mr1211230pgx.60.1531383783192; Thu, 12 Jul 2018 01:23:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531383783; cv=none; d=google.com; s=arc-20160816; b=WD5PGXCZ7yv9pYQixKAW9avtmNeG7owWvARt/sPO1cAZx1q23g1EMGiratwP3Hxs/O 0QxfehE18trfW3KDxsA/1BKEd2BIkSA8NPIRpNDOheo2+8wB20hcitdTxVjC/kz6uNoO EJNQxnUvOrk9DR8QGYn2z/WkBImT4pzx5SdaJCc9/B4XuCSmohza34FJj04lmv8iYq22 fYVRT5sx2yOEOItTl19CMLZB2+G1fpym8MsHwuA8C7Cyf5UQgneHebl9C4RimPXm2QzN EVcEHtrNp0QW/05LS0GcMr1nxgWoCmYa4o0PBcVcWLTT8xsMj593pbRtnOVLxVPca3vo PDow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=j3GRVs5QdaCvzkNqHu3pRIHoQbXSF4DPa5zkup5RP0I=; b=fKf3gYZX/eEK8e7NaysPhRIAjwXIqyYVv5GYZ6mG4PTOV44PlMi9aKwbWsxA2RuGW8 LHvNfhsOafQeU0pBLiD8ktfIM2wOIcr3bM6irVMEqeBAxpfKc7V++PAhiPRrJ1NVOS1v XNmqJk8u2NJN4BECsLe24Pm3ZO+OTTHfl7oEawjO+W2dtxteVipGgHWdOEptbDoAkKmR IUU2+IQS4XEo3zbJySNkCUDdcq2TMpVMjywz5Ppv/kZjeCpP2TzGKupuDYwZLTBBCE4l kJe+VtcvWAGzWepX3QCvUNGJP+mrZNCWO1mk8NEL8QbTQF4uW9ejlRPKI5yWWcEsJKv0 hpdw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=RHRuN39I; 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 d64-v6si21780413pfc.31.2018.07.12.01.22.47; Thu, 12 Jul 2018 01:23:03 -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=fail header.i=@gmail.com header.s=20161025 header.b=RHRuN39I; 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 S1732512AbeGLIaQ (ORCPT + 99 others); Thu, 12 Jul 2018 04:30:16 -0400 Received: from mail-lj1-f194.google.com ([209.85.208.194]:41922 "EHLO mail-lj1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725874AbeGLIaP (ORCPT ); Thu, 12 Jul 2018 04:30:15 -0400 Received: by mail-lj1-f194.google.com with SMTP id y17-v6so16558543ljy.8; Thu, 12 Jul 2018 01:21:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=j3GRVs5QdaCvzkNqHu3pRIHoQbXSF4DPa5zkup5RP0I=; b=RHRuN39ItsDFxGc1cWjLEJZQmV29TcarcMt1X4T69oyd1773KoLJh4/259KVNI88jS 36ci2nOjnaPAsEYIZavrtMf0KVwUvJxNUCeRiYmURCKc9CEaYUTui5XNgthfq+0OCcNx ffDcH6to64fcl9+VnYmrWCrSq0TK7U5AWXXuWX1bQnGlpqxf84lt92Nf/z5g5CWHXYWZ Z3KfKN+U8/aCSwz+eTjJICFk8Ws734D8vkTRQdhb1ccmsbVqZ/HOyUPTfGWlOCotkn3b 3yj6l43xHd7jFpU3yAtjJzYR2c3sefKymWZ261UI3oe1B1bOGrU/suZ7OOpjfGkvYiCw 6+ug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=j3GRVs5QdaCvzkNqHu3pRIHoQbXSF4DPa5zkup5RP0I=; b=IT3sU8IwQDZzl57YHi5MW4iE4BQl7NATXQVcUlwzm/gmERWTH2I/eruz/SkYjDG7DV svLz0N46U3ZSDGY7bDxFnUZRAv02Ze3tbHcpwJqeaH5Ww3PihcvhjratUX1+Et4G/vc3 YCyiwXf4E5TulF4wjmCy1PngH69wB/TgBEZzSlsOrNBwCFEqC9eAPi7VeCgimf1Hl8wn 4mgEddab3wB2IWw4g4SljxIQxCu4zasTlQEEfC9m1mXU/JyHbB1tIXonYc3U3KCDOpND 7eN/Y8xGcLebtdMsLzKk77O8g/71asq2KBr4LRHTN++G+0V7WGdkvjQpT34Moesiqzje 2ObA== X-Gm-Message-State: APt69E1RD1dvpSm9CQB0UzsdN4NaQqg9+5lFnplhhbOm5RYSGBMlG5nI chuyXo7i63l2RAE9PkoDDWHLR3mAwcsQXTBJfXw= X-Received: by 2002:a2e:118f:: with SMTP id 15-v6mr19848413ljr.38.1531383701692; Thu, 12 Jul 2018 01:21:41 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a2e:41c1:0:0:0:0:0 with HTTP; Thu, 12 Jul 2018 01:21:40 -0700 (PDT) In-Reply-To: <20180712000932.3b04ee9d@bbrezillon> References: <20180330074751.25987-1-boris.brezillon@bootlin.com> <20180330074751.25987-2-boris.brezillon@bootlin.com> <20180711164120.3e32fb08@bbrezillon> <20180711191212.3855bb25@bbrezillon> <20180712000932.3b04ee9d@bbrezillon> From: Arnd Bergmann Date: Thu, 12 Jul 2018 10:21:40 +0200 X-Google-Sender-Auth: fqlxLLQ7N9vvq3ZEjGGtsR8bo5w Message-ID: Subject: Re: [PATCH v4 01/10] i3c: Add core I3C infrastructure To: Boris Brezillon 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 Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. 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 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? >> 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. Arnd