Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp1792494ybe; Tue, 3 Sep 2019 03:38:21 -0700 (PDT) X-Google-Smtp-Source: APXvYqyPV/Z0yHdGcatxAZWLc8Nk1BfMTVgZOogF5b8UV60n2LvY+i5fjlUuJEMlUDchweC3V5db X-Received: by 2002:a17:902:a714:: with SMTP id w20mr33991255plq.135.1567507101717; Tue, 03 Sep 2019 03:38:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567507101; cv=none; d=google.com; s=arc-20160816; b=FkBEYKPK/p02tEVLMFI/ID3zJC8jUc/4EH/rPm1LGAkrWWUOLhg8eEz/rLN+x86i9w oAgTkEK06qcoUAp6IpIMUEZvWJJ7MG1eHOLQKW8JI63/dYtMMP9ARr5J6+ry0MaBXQBv KcUyvh4aR2d6E3ii+lEPnVEuQWSiSJniyuvyZQ7HNJsk8kXML05nBPDewPa3bYc8ApOo kyL+qdvuIQcEbdHjcbBxwsMrawiddDfhvi+PpbdR5lbGp+8nGWx39vQWJwnGYFvAouKF NrZBF1AZpHp2A2sEJqY1jehMWhCfA/16sUxVImR63RA2yN+sNf4F1NeVv1Ggd94VUtAq Wyng== 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=pof8cl8oNB90dX/VnloAlnqyXrbuIWbVha2YKOi3l2o=; b=XKKZuUJiGJvRdWsj8WyP7Lm6cojTTq/e46YzrPHIDTR2vl1dMNj0QqrZaQPISUWiuG wESj5QrmaEZfDLIvRxb9pvY0ZbgTaVI8VBVGtPf6OyYqFCNdZMPuh5DHlxm6on7MO5kx NU5cnVxMSy/kiojQPrIXuBqQ3cZU2wyI99MFMEda1t4RPAf27JqYAzKrg10K7pjYfcZV 4QrezmI5zatwCiLP/SX+qq+XDlIsDeWI25s8rMsBUcy3P9XXNkBPdKWfYhmkwUievYDW YS+kc9k0dQDFCoD9CzUMF9VGHe+nXxnY0W6gXCpYtw8Sw8lgBNjSRTBs1ltkxP4wmQI9 sVHw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@synopsys.com header.s=mail header.b=GniHgZu+; 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 i5si14273526plt.283.2019.09.03.03.38.06; Tue, 03 Sep 2019 03:38:21 -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=GniHgZu+; 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 S1728874AbfICKgS (ORCPT + 99 others); Tue, 3 Sep 2019 06:36:18 -0400 Received: from smtprelay-out1.synopsys.com ([198.182.61.142]:35616 "EHLO smtprelay-out1.synopsys.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728747AbfICKgA (ORCPT ); Tue, 3 Sep 2019 06:36:00 -0400 Received: from mailhost.synopsys.com (mdc-mailhost1.synopsys.com [10.225.0.209]) (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 562C2C0416; Tue, 3 Sep 2019 10:35:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=synopsys.com; s=mail; t=1567506960; bh=wcWwratgm8ehYW75XaHQWAIMPGVfnICMKiObM27MCu0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:In-Reply-To: References:From; b=GniHgZu+adDcfTGlIjdjxgpPuaMK3KYAHngpYsl8jlO+u2gWCty2+hLXDbsv5j1fs qFZ5QPKuDJy5vGhQVlHqDcCmleIOkYf4zeEWtA0PWyutbUt0E4k/yOxa9Tu9itLS3n HMx40mPjd84uM+rHlgDeKoj+cJ6avEUoouCB0HafmRJyxobd8Mu1XSDMeP78Uxl49h SZvAZHsaDZ9OfMohgLXOW4pQWoFUpK7JJTmu9tzZWQjDg4o61ZHsMqw5x6571uBAGp MR/HJUoLNRTAltgR0/1WTYtp/KFEqg3UlxXGGsMrRqstY5GPhg7ivV8lfQKgefkvjA 3GoaWeBRxqorQ== Received: from de02.synopsys.com (germany.internal.synopsys.com [10.225.17.21]) by mailhost.synopsys.com (Postfix) with ESMTP id 212D3A006A; Tue, 3 Sep 2019 10:35:57 +0000 (UTC) Received: from de02dwia024.internal.synopsys.com (de02dwia024.internal.synopsys.com [10.225.19.81]) by de02.synopsys.com (Postfix) with ESMTP id E55A93C0E4; Tue, 3 Sep 2019 12:35:56 +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 v2 5/5] i3c: master: dw: reattach device on first available location of address table Date: Tue, 3 Sep 2019 12:35:54 +0200 Message-Id: <594bce70368177256376fc2f592736db78cf40db.1567437955.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 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