Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp573219imm; Thu, 6 Sep 2018 07:03:22 -0700 (PDT) X-Google-Smtp-Source: ANB0Vda7UUqdoRHAEI6MjnoFbEOHRAwA1GsTwumvXSVD8X0l+fXl/6i/8BRjZu0PNqCVSrNXeqqj X-Received: by 2002:a81:b716:: with SMTP id v22-v6mr1529972ywh.9.1536242602296; Thu, 06 Sep 2018 07:03:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536242602; cv=none; d=google.com; s=arc-20160816; b=mv6Xfa21usacJpE/WA24N3C8D2Reqz3i5D71LaGtQ/A+zbe+Es/yYVt8aipLhkMWaJ /WuR4yjCgwcPruDJchEW5t+rXhJAFKj1CtaokDCzcN2kDEvJa41r7uyaaLJufOMjX7kM oNZ1jqUg3uAoGFN6Ak1JBzhCVoO1vL3KM6tfAfv4kDnUO3J7d/2OFj+6eZAivX9uY9Z0 X0reALDJURiNrmNUaG9TStGBEQPJjb00Rn1T83jV+6SSX7pKSJQDb5eA1mRiHj+H7qUh 49nCrNY4fjpLuaq0z21lABsiAGCD8LfOg3W2Zbmb4Xd1/mCTekCIh+SCmY6gSGoXindm y39g== 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; bh=ICcUcSY8idJWWrGl9E/tfrhpNVpA+mqvxC/m2QZDKDo=; b=v3lgoOE9g3HnVuGfMXGiK/EO6gCtYzq0UUDTh7J+WpJ4ODUbwb8ZUrD4ZznUCBKKpE 5djcjGyqcd0rsjsa+Vrk1kbalQ+aqdxfDiJ30isQFYPtEgHxUhKHZQt5diSJEaCAoyJb 7WFzp+bIxjmMCQkCSEn0/+n0Rd+TgyBQqyjReeeWFD65uUUrabyZYm4E/Mr5dKN6fpzO 2ecbTd6X+oedBaMOiQWBHSLmdw3GhUYnTQTT/pc1GvtNFg1IdCSwsDA5KqKUiuuZNBiq phO+2mYMS0sTzUyZRWjXEYFdz7i4Qp3DKLbs4YDnoFDN1w5kPx5jP/Wu9tzKDehUajEY g8nQ== 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 l23-v6si5178637pgo.230.2018.09.06.07.03.01; Thu, 06 Sep 2018 07:03:22 -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 S1730076AbeIFSgp (ORCPT + 99 others); Thu, 6 Sep 2018 14:36:45 -0400 Received: from mail.bootlin.com ([62.4.15.54]:58570 "EHLO mail.bootlin.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729534AbeIFSgp (ORCPT ); Thu, 6 Sep 2018 14:36:45 -0400 Received: by mail.bootlin.com (Postfix, from userid 110) id 5C5112072B; Thu, 6 Sep 2018 16:01:02 +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-30-219.w90-88.abo.wanadoo.fr [90.88.15.219]) by mail.bootlin.com (Postfix) with ESMTPSA id 95C9320701; Thu, 6 Sep 2018 16:00:51 +0200 (CEST) Date: Thu, 6 Sep 2018 16:00:48 +0200 From: Boris Brezillon To: Arnd Bergmann Cc: Wolfram Sang , Linux I2C , gregkh , Jonathan Corbet , "open list:DOCUMENTATION" , 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 , "open list:GPIO SUBSYSTEM" , Sekhar Nori , Przemyslaw Gaj , Peter Rosin , mshettel@codeaurora.org, swboyd@chromium.org Subject: Re: [PATCH v7 01/10] i3c: Add core I3C infrastructure Message-ID: <20180906160048.2f585e2b@bbrezillon> In-Reply-To: References: <20180905154108.20770-1-boris.brezillon@bootlin.com> <20180905154108.20770-2-boris.brezillon@bootlin.com> 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=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 6 Sep 2018 15:38:49 +0200 Arnd Bergmann wrote: > On Wed, Sep 5, 2018 at 5:41 PM Boris Brezillon > wrote: > > > --- > > Changes in v7: > > - Stop representing the I3C master as a device under the I3C bus > > - Enforce a 1:1 relationship between i3c_bus and i3c_master_controller > > objects > > Thanks for implementing those changes. What is your feeling so far > about the difference? Has it gotten much simpler as I was hoping? Hm, to be honest I don't see a big difference in term of simplicity, but that's probably because I kept the bus/master concepts separated (even if the 1:1 relationship is enforced). > > I definitely like this version much better. I have found a couple of > things that I point out below that could be improved (or me being > proven wrong on them), but overall I think it looks great and I don't > see major issues. > > Great work! Thanks, I'm glad you think these changes go in the right direction. Will try to address your new comments. > > > +struct i3c_bus *i3c_bus_create(struct i3c_master_controller *master) > > +{ > > + struct i3c_bus *i3cbus; > > + int ret; > > + > > + i3cbus = kzalloc(sizeof(*i3cbus), GFP_KERNEL); > > + if (!i3cbus) > > + return ERR_PTR(-ENOMEM); > > I find it a bit confusing to have separate i3c_master_controller > and i3c_bus structures with this version. Why not merge the > two structures into one now and move the bus management > into master.c? Yes, I considered this approach. Not sure it would make the whole code a lot simpler though, and it was definitely more work on my side, so I decided to delay that and wait for someone to explicitly request this change ;-). I also like the bus/master separation in that it allows one to clearly identify the properties that are bus (speed, mode, ...) related and those that are master controller oriented (PID, DCR, ...). > > > +static int i3c_master_attach_i3c_dev(struct i3c_master_controller *master, > > + struct i3c_dev_desc *dev) > > +{ > > + int ret; > > + > > + /* > > + * We don't attach devices to the controller until they are > > + * addressable on the bus. > > + > > Apparently the new gmail version decided to cut off the second half of your > email after this line when I hit reply, which makes it much harder for me > to continue a proper review. I fear I'll have to get a real email client > again :( > > > + * The I3C bus is represented with its own object and not implicitly described > > + * by the I3C master to cope with the multi-master functionality, where one bus > > + * can be shared amongst several masters, each of them requesting bus ownership > > + * when they need to. > > This comment is now stale, even without merging the structures, right? Yep, it is. I'll drop it. > > > +struct i3c_master_controller { > > + struct device *parent; > > + struct i3c_dev_desc *this; > > + struct i2c_adapter i2c; > > I think the 'parent' pointer is better omitted, it should always be > the same as master->dev->parent, right? Absolutely. > > Since it contains an i2c_adapter, maybe a good name for the > combined i3c_master_controller+i3c_bus structure would > be 'i3c_adapter'? Hm, I'd really like to keep the name master and not adapter, just because that's how it's named in the spec. > > +#define i3c_bus_for_each_i2cdev(bus, dev) \ > + list_for_each_entry(dev, &(bus)->devs.i2c, common.node) > + > +#define i3c_bus_for_each_i3cdev(bus, dev) \ > + list_for_each_entry(dev, &(bus)->devs.i3c, common.node) > > I wonder if it would simplify things to drop the i2c and i3c > device lists and instead implement these for_each loops > based on device_for_each_child() with a check of the > bus_type==&i2c_bus/&i3c_bus. We don't store i3c/i3c_device objects in those lists, but i3c/i2c_dev_desc objects, so device_for_each_child() won't work. Remember that i3c devs can be present but not registered yet, and we need to have those representations somehow attached to the master/bus. Regarding the possibility of merging those 2 lists together, we could do it, but I find it simpler to have them separated. > That might help with locking > and keeping the two lists synchronized, which may or > may not be a problem here. Regarding the locking aspects. Anything touching those lists is either init code (which should be serialized) or DAA related, which requires the bus lock to be held in write mode (exclusive access mode). Do you see any other possible race? Thanks, Boris