Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp28209imm; Thu, 28 Jun 2018 14:12:35 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfH823vSimmDIS4IPLbK0LoM9rqeAyEqCu7yV00sgDwKuqTTkrMxUBL/Ml0ghEU5KiHAp1j X-Received: by 2002:a62:8f8c:: with SMTP id n134-v6mr11709782pfd.66.1530220355642; Thu, 28 Jun 2018 14:12:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530220355; cv=none; d=google.com; s=arc-20160816; b=wdPI9WCS3CSRNYmDVPlPP5uNk+09NV8O2FiGwKYPZRl5TTkw5CSC0vR1JQFftg1p5E T0jlJbmxAwRp6JLtWdeMOwi0e3qQ/NDxH/07PrW6kVM61IEEiYrY33k3b0JxX0iXkejA iCt66KIjGmYhFV/FDXVs3J1bsxvyzX05i28pdifotUmKhftAFrLgdYPEwo8/oRtzUsm2 ca3r1J0ASXXZFZkJHxXESQvy8skGdA0IzNtxp07sFyHvRkJBtB3DKTMPyNM5E05K/dJS hB6VFuZzALm+JpGuRyX9+lkKeaK1rl68pnMRYSxhWd3WIl9veA0b+iF4tu7l8NBcEMJj BsUg== 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=q+ljms4Lts8mbV9C54MOWAsEvCXxwo9kGrmBhE/F0Vo=; b=wuC2WL63mebppETnASFh2pnhfPDBNVtFA+R/CMxHn+xxYgKBAEHLQk3lOrfRjwBFu6 6MUzCSgJo2565BxYrAmTEb98M+7GnrDxt02+D8sJ9nmk23RyKgmliaOkW51WeDK+28w/ o2UmlcypJ3/w6oMs0bBxJF/chsIqFkZdO5LBGC7RTd/Dj7ZhhKYMyp90/cCu5TtmdGGa ti6q30p3hAN8y0+wP/i9N9QdzujRcX0ahQY8Z3j2KiE50WPynGoYt0tV3YuzrDFaJPzw vUWjRNdl4ww61pDpFDH0QmX+HMtT6gc7r29gmBo01XMHWlVe/ZNbDie3zDPBsntcyG1C EEBQ== 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 91-v6si7274983ply.296.2018.06.28.14.12.20; Thu, 28 Jun 2018 14:12:35 -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 S933164AbeF1VC4 convert rfc822-to-8bit (ORCPT + 99 others); Thu, 28 Jun 2018 17:02:56 -0400 Received: from mail.bootlin.com ([62.4.15.54]:34086 "EHLO mail.bootlin.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753042AbeF1VCx (ORCPT ); Thu, 28 Jun 2018 17:02:53 -0400 Received: by mail.bootlin.com (Postfix, from userid 110) id 9517620733; Thu, 28 Jun 2018 23:02:50 +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 (unknown [91.160.177.164]) by mail.bootlin.com (Postfix) with ESMTPSA id A9CA9206A6; Thu, 28 Jun 2018 23:02:38 +0200 (CEST) Date: Thu, 28 Jun 2018 23:02:37 +0200 From: Boris Brezillon To: vitor Cc: Wolfram Sang , , Jonathan Corbet , , Greg Kroah-Hartman , Arnd Bergmann , 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" , , , Geert Uytterhoeven , Linus Walleij , Xiang Lin , , Sekhar Nori , Przemyslaw Gaj Subject: Re: [PATCH v5 01/10] i3c: Add core I3C infrastructure Message-ID: <20180628230237.7728a9bf@bbrezillon> In-Reply-To: <088dc947-da66-cec9-44a8-0f1097690bfd@synopsys.com> References: <20180622104930.32050-1-boris.brezillon@bootlin.com> <20180622104930.32050-2-boris.brezillon@bootlin.com> <088dc947-da66-cec9-44a8-0f1097690bfd@synopsys.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=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 Hi Vitor, On Thu, 28 Jun 2018 16:38:56 +0100 vitor wrote: > Hi Boris, > > > On 22-06-2018 11:49, Boris Brezillon wrote: > > +static int of_i3c_master_add_i3c_dev(struct i3c_master_controller *master, > > + struct device_node *node, u32 *reg) > > +{ > > + struct i3c_device_info info = { }; > > + enum i3c_addr_slot_status addrstatus; > > + struct i3c_device *i3cdev; > > + u32 init_dyn_addr = 0; > > + > > + if (reg[0]) { > > + if (reg[0] > I3C_MAX_ADDR) > > + return -EINVAL; > > + > > + addrstatus = i3c_bus_get_addr_slot_status(master->bus, reg[0]); > > + if (addrstatus != I3C_ADDR_SLOT_FREE) > > + return -EINVAL; > > + } > > + > > + info.static_addr = reg[0]; > > + > > + if (!of_property_read_u32(node, "assigned-address", &init_dyn_addr)) { > > + if (init_dyn_addr > I3C_MAX_ADDR) > > + return -EINVAL; > > + > > + addrstatus = i3c_bus_get_addr_slot_status(master->bus, > > + init_dyn_addr); > > + if (addrstatus != I3C_ADDR_SLOT_FREE) > > + return -EINVAL; > > + } > > + > > + info.pid = ((u64)reg[1] << 32) | reg[2]; > > + > > + if ((info.pid & GENMASK_ULL(63, 48)) || > > + I3C_PID_RND_LOWER_32BITS(info.pid)) > > + return -EINVAL; > > + > > + i3cdev = i3c_master_alloc_i3c_dev(master, &info, &i3c_device_type); > > + if (IS_ERR(i3cdev)) > > + return PTR_ERR(i3cdev); > > + > > + i3cdev->init_dyn_addr = init_dyn_addr; > > + i3cdev->dev.of_node = node; > > + list_add_tail(&i3cdev->common.node, &master->bus->devs.i3c); > > + > > + return 0; > > +} > > + > > I'm writing the driver for the Synopsys master and but now I getting an > issue. > > I use the "slot" of the device to do all transfers, something like you > use in DAA. I using the master_priv to save the "slot" per device but > the problem is when I call the i3c_master_add_i3c_dev_locked() to > retrieve the info I don't have it yet. Hm, I knew that might become a problem at some point. The Cadence IP does not need the slot index because it works with addresses and figure the device slot out of this address, but it looks like others don't go this road. > > From my analysis this can be solve with: >     - send PID, BCR and DCR when I call i3c_master_add_i3c_dev_locked() > or similar function. Except these are not the only thing we retrieve before attaching the device. Also, if we go this road, that means we don't have the same path for devices whose dynamic address is assigned through SETDASA, and those that are discovered using DAA. >     - Pre-allocate an i3c_device -> attach it (slot data goes to > master_priv) -> retrieve info -> if there is already an i3c_device with > same PID destroy the pre-allocated one. That's the very reason I didn't go this road. It gets messy if we already know this device. This being said, among all the options you list here, this is the one I prefer. Let's see if we can standardize the resource allocation/free process and let ->attach/detach() only take care of the device/bus configuration. >     - Replace the info.dyn_address with a structure with dyn_address > and slot and use it in CCC structure. I'd really like to keep the device-slot-id a priv information, because we don't know how other IPs will deal with I3C device resources. > > This is something that will need to be supported for I3C HCI spec too. I agree. > Do you have any suggestion? I'll try to come up with something. Need to think a bit more about it. Thanks, Boris