Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp731397ybe; Thu, 5 Sep 2019 05:12:50 -0700 (PDT) X-Google-Smtp-Source: APXvYqzsrS18mXjpxWWT7s6688wTqVX+89WRv8NeFhLmmi45CLOL6hNd51FmHyf3o8dIa7h2bAbS X-Received: by 2002:a17:90a:ba06:: with SMTP id s6mr3365978pjr.69.1567685570414; Thu, 05 Sep 2019 05:12:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567685570; cv=none; d=google.com; s=arc-20160816; b=VNi1Q0Ap1VeKw5NSVeVuGnZJV+Ak3ODLCrWHRfuZnOc/WD2ELZCE3mS7SO+dYBhlgl Q/z9RZGCQUhfe+7iDgtL18IMpM/aztctoYl2MeZo18h2gup0/x/AfnEXOAMxudMuT6ZB 9/Ab7UYJIZDcQ+8vw52bfWVWUWKlDJAMFJrH+XsBFMtXuENz22/YhZSiCbScWrx1+9cR JAeAD1JtJZgywxjZTU7KxmevUp8rqFjdxNx7u8QLW+iNYSPSfcspK8Xe0H6t5GU7nZ8O 82ln/+Q24lKsu4e5QJ6rK46DsP+YXkKjVkp2A9rTAY+cUgS3sVyHagRyZwB8Zpcu97HJ aUoA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature; bh=RUwfM3TfCnNJVfwQO/rthjDKBVPmwPHd7hyGRzSlPsQ=; b=nklym3QtpKrC1ucZhGAUfYwGNopGwwI+ISz9S2fPuVHovncHf3ktEkpSQbfJ+G2zq+ lNbCQf6X3sBA91gG731G49KJyxV5DwrcLP76yI3IFzZLnndwgnOQyJMlwsS2az9+Vl7u fwH9qgtULVux0ev91GbfLo99RyUVwg1YwIxQKCoutQiOkVdFfoNRRczigUEWPgTH2eIv a14dI7/Uio7I39lPd1D6q7ff5I5Ymx+K9OWCGhCXjSC0V9EH38OqGCVpRLUBG8DwvLK/ FI8snY7Wpn0TVEU9uc21U5/BN4q15EfXUt72WdxNOF0bhkrDiTTxosABcxGoFGxs/CtO XBgw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@synopsys.com header.s=mail header.b=alkwKZZb; 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=pass (p=NONE sp=NONE dis=NONE) header.from=synopsys.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x7si1123035pff.140.2019.09.05.05.12.34; Thu, 05 Sep 2019 05:12:50 -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=pass header.i=@synopsys.com header.s=mail header.b=alkwKZZb; 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=pass (p=NONE sp=NONE dis=NONE) header.from=synopsys.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387795AbfIEKBM (ORCPT + 99 others); Thu, 5 Sep 2019 06:01:12 -0400 Received: from smtprelay-out1.synopsys.com ([198.182.61.142]:49716 "EHLO smtprelay-out1.synopsys.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S2387698AbfIEKAw (ORCPT ); Thu, 5 Sep 2019 06:00:52 -0400 Received: from mailhost.synopsys.com (mdc-mailhost2.synopsys.com [10.225.0.210]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by smtprelay-out1.synopsys.com (Postfix) with ESMTPS id 53ACFC29A4; Thu, 5 Sep 2019 10:00:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=synopsys.com; s=mail; t=1567677651; bh=jpITmRkSQ88mmTqXmv0bcx69vjIs1qPZ/IAyeZ+eQaE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:In-Reply-To: References:From; b=alkwKZZbijz8D15wvpQoRDEUHSvPmmf4FLJlRs5Ui0rBfAr1TTmU/P9T/Ji9qqv+m EusdrrFJtRD0CyyrcVlRpNYnsc7F1TudS2mU37F9pYirZcBoXBJoAOkXfmlZci7n0w YmldJqxB9bCUsG1zVOuHmpaKbHp4BB72PYT1KqnuEqNuHGGdOHphnoNamdiq7RGKZ8 yBD+mCvvGk0yxtNe8lXXsPZxzSfhN6MySVUdOzTZtvQS7uT5wXlyCYON60CjrJ+/GF UChPioNmcFtjHCf4QeeWZxFSSdQaqLurzB7XWhbVgtbyg361q2W7UcKDysOLg2ZS09 4hPOw9ftUsYuA== Received: from de02.synopsys.com (germany.internal.synopsys.com [10.225.17.21]) by mailhost.synopsys.com (Postfix) with ESMTP id B2110A0064; Thu, 5 Sep 2019 10:00:49 +0000 (UTC) Received: from de02dwia024.internal.synopsys.com (de02dwia024.internal.synopsys.com [10.225.19.81]) by de02.synopsys.com (Postfix) with ESMTP id 9374F3F3BF; Thu, 5 Sep 2019 12:00:49 +0200 (CEST) From: Vitor Soares To: linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-i3c@lists.infradead.org Cc: bbrezillon@kernel.org, robh+dt@kernel.org, mark.rutland@arm.com, pgaj@cadence.com, Joao.Pinto@synopsys.com, Vitor Soares Subject: [PATCH v3 5/5] i3c: master: dw: reattach device on first available location of address table Date: Thu, 5 Sep 2019 12:00:38 +0200 Message-Id: <245de28c177b3169ce5b8c26d807f5fd46c2921c.1567608245.git.vitor.soares@synopsys.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org For today the reattach function only update the device address on the controller. Update the location to the first available too, will optimize the enumeration process avoiding additional checks to keep the available positions on address table consecutive. Signed-off-by: Vitor Soares Reviewed-by: Boris Brezillon --- Change in v3: - None Change in v2: - Add Boris rb-tag drivers/i3c/master/dw-i3c-master.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/drivers/i3c/master/dw-i3c-master.c b/drivers/i3c/master/dw-i3c-master.c index 1d83c97..62261ac 100644 --- a/drivers/i3c/master/dw-i3c-master.c +++ b/drivers/i3c/master/dw-i3c-master.c @@ -898,6 +898,22 @@ static int dw_i3c_master_reattach_i3c_dev(struct i3c_dev_desc *dev, struct dw_i3c_i2c_dev_data *data = i3c_dev_get_master_data(dev); struct i3c_master_controller *m = i3c_dev_get_master(dev); struct dw_i3c_master *master = to_dw_i3c_master(m); + int pos; + + pos = dw_i3c_master_get_free_pos(master); + + if (data->index > pos && pos > 0) { + writel(0, + master->regs + + DEV_ADDR_TABLE_LOC(master->datstartaddr, data->index)); + + master->addrs[data->index] = 0; + master->free_pos |= BIT(data->index); + + data->index = pos; + master->addrs[pos] = dev->info.dyn_addr; + master->free_pos &= ~BIT(pos); + } writel(DEV_ADDR_TABLE_DYNAMIC_ADDR(dev->info.dyn_addr), master->regs + -- 2.7.4