From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtpout-02.galae.net (smtpout-02.galae.net [185.246.84.56]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C8EC634C98E for ; Fri, 31 Oct 2025 14:35:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.246.84.56 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761921361; cv=none; b=LXUsy9n5P7VC0NsKzsFVBloZFwhjVWepBKY7xqD7490I5nz3tq5BQ/7Vvpz2WsWiTQpk2zcYFJnW4xnXBUYzaP6/6xihsgF32RHFCoMJSROii+ZW9m+Oa7SqVCxdWmZL6WKZfWmR311jcyt1rgX+K/U/eYavzBY0CjhoBRRFXiQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761921361; c=relaxed/simple; bh=QYdwTGffhiIsHPXcV+yojSMBuQCvwVv+QuSeD1Et69Q=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=rg91ZOGq02rGpyCi30wpednjWGmYKWg4Bf5qbmDC5K8r4JvfF2kkCwbyGKWw9wpalRx7lvu3xof5gT0IEOcVy0uf4Op6VICUwxJZ0UyhCXRLtH9KrL4uZehsVDRci5UGgpEAgmO08Nj1yfcd1TN82CYwOVYrDJIX+t7ex3xCp8Q= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=DiqSK31Z; arc=none smtp.client-ip=185.246.84.56 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="DiqSK31Z" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-02.galae.net (Postfix) with ESMTPS id 2E4671A17AF; Fri, 31 Oct 2025 14:35:58 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 0407E60704; Fri, 31 Oct 2025 14:35:58 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 695B811818039; Fri, 31 Oct 2025 15:35:55 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1761921357; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=/r+8Xznx3k7NPhBfqnm1ZY9xbZMhMWI68J+yr6/nu6k=; b=DiqSK31ZShcEOTH4IkEYxhu5kBnbxYiuKxzsSduaxsZVcjfeku3QlVJmxCkAXzBL5oV+f3 Al1oIDRhqRhJttItSLjTH0fXPBvkDFY2U82zK/DAmrkcFDfVHIPLQ4jSAIH3T8uuUJPYwj 5NSLjfrPdnsOK7LK6Ax5fN5YiaYjHfCqvZt+eWZzvNkESkNayCmqCV8Frbxg57qi8oG8E3 XiSBNf1uhzbFW43twbXpZDU1PdYXAQO7bRHYy4/gA6OHtlJQr1HOLaGQV0RFjz08h65J0G ZQ9QxEwEtm1xmNQjdgF9Escl93/Z0jPDI8VEayfu43SzBi9Fnk/JK30kYCIK/Q== From: =?utf-8?q?Beno=C3=AEt_Monin?= Date: Fri, 31 Oct 2025 15:35:40 +0100 Subject: [PATCH v2 2/5] i2c: designware: Optimize flag reading in i2c_dw_read() Precedence: bulk X-Mailing-List: linux-i2c@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Message-Id: <20251031-i2c-dw-v2-2-90416874fcc0@bootlin.com> References: <20251031-i2c-dw-v2-0-90416874fcc0@bootlin.com> In-Reply-To: <20251031-i2c-dw-v2-0-90416874fcc0@bootlin.com> To: Andi Shyti , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Jarkko Nikula , Mika Westerberg , Andy Shevchenko , Jan Dabros , Sebastian Andrzej Siewior , Clark Williams , Steven Rostedt Cc: Thomas Petazzoni , Gregory CLEMENT , =?utf-8?q?Th=C3=A9o_Lebrun?= , Tawfik Bayouk , Vladimir Kondratiev , Dmitry Guzman , linux-i2c@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-rt-devel@lists.linux.dev, =?utf-8?q?Beno=C3=AEt_Monin?= X-Mailer: b4 0.14.3 X-Last-TLS-Session-Version: TLSv1.3 Optimize the i2c_dw_read() function by reading the message flags only once per message, rather than for every byte. The message index is only modified by the outer loop, so reading the flags in the inner loop was always getting the same value. Signed-off-by: BenoƮt Monin --- drivers/i2c/busses/i2c-designware-master.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/i2c/busses/i2c-designware-master.c b/drivers/i2c/busses/i2c-designware-master.c index 41e9b5ecad20..ec4fc2708d03 100644 --- a/drivers/i2c/busses/i2c-designware-master.c +++ b/drivers/i2c/busses/i2c-designware-master.c @@ -586,11 +586,12 @@ i2c_dw_read(struct dw_i2c_dev *dev) unsigned int rx_valid; for (; dev->msg_read_idx < dev->msgs_num; dev->msg_read_idx++) { + u32 flags = msgs[dev->msg_read_idx].flags; unsigned int tmp; u32 len; u8 *buf; - if (!(msgs[dev->msg_read_idx].flags & I2C_M_RD)) + if (!(flags & I2C_M_RD)) continue; if (!(dev->status & STATUS_READ_IN_PROGRESS)) { @@ -604,8 +605,6 @@ i2c_dw_read(struct dw_i2c_dev *dev) regmap_read(dev->map, DW_IC_RXFLR, &rx_valid); for (; len > 0 && rx_valid > 0; len--, rx_valid--) { - u32 flags = msgs[dev->msg_read_idx].flags; - regmap_read(dev->map, DW_IC_DATA_CMD, &tmp); tmp &= DW_IC_DATA_CMD_DAT; /* Ensure length byte is a valid value */ -- 2.51.1