Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp487406ybn; Thu, 3 Oct 2019 07:56:48 -0700 (PDT) X-Google-Smtp-Source: APXvYqwAB35J7P6piV05qJ0fe0cxFqCbnnjeKkS5pK/Frtl7gLLEU192Hwlm+RK/Lfe/8t3wDXez X-Received: by 2002:a50:9512:: with SMTP id u18mr9840734eda.182.1570114607960; Thu, 03 Oct 2019 07:56:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570114607; cv=none; d=google.com; s=arc-20160816; b=TEpbTdj1CW3LobgsxwKHwoC6NoN1NOBHPAI3Fa0Ord6Ko7uOk+fPV8WNL8O+iW3HyX SfbSJy3QRyenIbZ8j4z97o1NcF+xDJ2mZdswoJqyLdKwOqW8RjDcj3GQsCv2xUcr6GMi 7TuY/EDQ5FCHqvioVMopeOXx9XJLqBG/r5y7adev3pnA9pRnLMUbf2qt934t6rrHL8yc yWK6r4G3loelBCkgclmg0qMxVYgOytqEeNREaTtixQK/aa/BXtAhlSXeJwQ4JlLw4q2T Uh+P8GYDMuJhQl6Y5JX19a8cwRQw9HjYX6q4cujBHmMeDSQnb8yqflih5s1ad/v9eUYe n2fA== 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 :organization:references:in-reply-to:message-id:subject:cc:to:from :date; bh=bCHSyWVfcy0EllrPpSqzXrs6P8JkgAs7tOssbmoH+V0=; b=e44mjTsLKnM2DJi3KTIZcMdM7Q3U13dOvjVuarUMv/K+nREH4wM6g8bffjHnGy7wOC 9oBUGqUjmfPdmi+ZQe5UjMr/410QrXyxXjJtY4cOmkGPjoT5XwKO7YBDA/0kRUds0uta YcP8monKGHAEjD7SPpC/kOQkW4/XtKqi/EChumGNyz9OmMaGplK+XCr7aYQCKwRsw+Wf 9d+7jxeJ4g/5kyc76t2bBK4sb08X0KXq6fWNrvCip/V5gxBScHlC8b3+nik7A5wUhshJ kiy0V5mxDua3OBGtGWmhtqe+coYXHBg0yKrLUrPCx4F7FidjhzBbNcOEDq6zE7zQ5I7I jCHw== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p14si1430655ejn.192.2019.10.03.07.56.23; Thu, 03 Oct 2019 07:56:47 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730651AbfJCO3x (ORCPT + 99 others); Thu, 3 Oct 2019 10:29:53 -0400 Received: from bhuna.collabora.co.uk ([46.235.227.227]:42112 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726393AbfJCO3x (ORCPT ); Thu, 3 Oct 2019 10:29:53 -0400 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: bbrezillon) with ESMTPSA id 33AF328E8BE Date: Thu, 3 Oct 2019 16:29:43 +0200 From: Boris Brezillon To: Vitor Soares Cc: linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-i3c@lists.infradead.org, bbrezillon@kernel.org, robh+dt@kernel.org, mark.rutland@arm.com, pgaj@cadence.com, Joao.Pinto@synopsys.com, stable@vger.kernel.org Subject: Re: [PATCH v3 2/5] i3c: master: make sure ->boardinfo is initialized in add_i3c_dev_locked() Message-ID: <20191003162943.4a0d0274@collabora.com> In-Reply-To: References: Organization: Collabora X-Mailer: Claws Mail 3.17.3 (GTK+ 2.24.32; x86_64-redhat-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, 5 Sep 2019 12:00:35 +0200 Vitor Soares wrote: > The newdev->boardinfo assignment was missing in > i3c_master_add_i3c_dev_locked() and hence the ->of_node info isn't > propagated to i3c_dev_desc. > > Fix this by trying to initialize device i3c_dev_boardinfo if available. > > Cc: > Fixes: 3a379bbcea0a ("i3c: Add core I3C infrastructure") > Signed-off-by: Vitor Soares > --- > Change in v3: > - None > > Changes in v2: > - Change commit message > - Change i3c_master_search_i3c_boardinfo(newdev) to > i3c_master_init_i3c_dev_boardinfo(newdev) > - Add fixes, stable tags > > drivers/i3c/master.c | 27 +++++++++++++++++++++++++-- > 1 file changed, 25 insertions(+), 2 deletions(-) > > diff --git a/drivers/i3c/master.c b/drivers/i3c/master.c > index 586e34f..9fb99bc 100644 > --- a/drivers/i3c/master.c > +++ b/drivers/i3c/master.c > @@ -1798,6 +1798,22 @@ i3c_master_search_i3c_dev_duplicate(struct i3c_dev_desc *refdev) > return NULL; > } > > +static void i3c_master_init_i3c_dev_boardinfo(struct i3c_dev_desc *dev) > +{ > + struct i3c_master_controller *master = i3c_dev_get_master(dev); > + struct i3c_dev_boardinfo *boardinfo; > + > + if (dev->boardinfo) > + return; > + > + list_for_each_entry(boardinfo, &master->boardinfo.i3c, node) { > + if (dev->info.pid == boardinfo->pid) { > + dev->boardinfo = boardinfo; > + return; > + } > + } > +} > + > /** > * i3c_master_add_i3c_dev_locked() - add an I3C slave to the bus > * @master: master used to send frames on the bus > @@ -1818,8 +1834,9 @@ int i3c_master_add_i3c_dev_locked(struct i3c_master_controller *master, > u8 addr) > { > struct i3c_device_info info = { .dyn_addr = addr }; > - struct i3c_dev_desc *newdev, *olddev; > u8 old_dyn_addr = addr, expected_dyn_addr; > + enum i3c_addr_slot_status addrstatus; > + struct i3c_dev_desc *newdev, *olddev; > struct i3c_ibi_setup ibireq = { }; > bool enable_ibi = false; > int ret; > @@ -1878,6 +1895,8 @@ int i3c_master_add_i3c_dev_locked(struct i3c_master_controller *master, > if (ret) > goto err_detach_dev; > > + i3c_master_init_i3c_dev_boardinfo(newdev); > + > /* > * Depending on our previous state, the expected dynamic address might > * differ: > @@ -1895,7 +1914,11 @@ int i3c_master_add_i3c_dev_locked(struct i3c_master_controller *master, > else > expected_dyn_addr = newdev->info.dyn_addr; > > - if (newdev->info.dyn_addr != expected_dyn_addr) { > + addrstatus = i3c_bus_get_addr_slot_status(&master->bus, > + expected_dyn_addr); > + > + if (newdev->info.dyn_addr != expected_dyn_addr && > + addrstatus == I3C_ADDR_SLOT_FREE) { First, this change shouldn't be part of this patch, since the commit message only mentions the boardinfo init stuff, not the extra 'is slot free check'. Plus, I want the fix to be backported so we should avoid any unneeded deps. But even with those 2 things addressed, I'm still convinced the 'free desc when device is not reachable' change you do in patch 1 is not that great, and the fact that you can't pre-reserve the address to make sure no one uses it until the device had a chance to show up tends to prove me right. Can we please do what I suggest and solve the "not enough dev slots" problem later on (if we really have to). > /* > * Try to apply the expected dynamic address. If it fails, keep > * the address assigned by the master.