From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 10EF0C3DA59 for ; Tue, 16 Jul 2024 15:06:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=oIsP9WfA0TMZUezHpRe4LD3xeHG2Pnug2FDZg/pF9jA=; b=sTE2MdJ9Szr+/OZDDqv5sp6tcL efQWCqdefELynzJd+YTZrL5SM3636KlO2PTYIC4k3W5AqXQIfW/8g3ADo9+9i57RGY459VbeXXXyL DCqahlc5HKDJj7wE4lGs2/oQVMmS6d/mCke6yI9HJ7m9eRLK38cUeqlser/dUzNrfMfo3cqDkK3wv ZAKA+ag8wwFHyP0gnurTDDe/9jBOoa67dl3qEg/zd9RtKkz2ujCZitUfMnn5Be8cT2HjIZlkIbIv2 k0u6nzppS2DVBhyJ+yHINIISPPPEVD9ukiVnXq/CBql5qidyUTSrXRQhvonh9xiSbq9y5EYgZy1eM DmODxfmg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sTjkX-0000000Ar2S-2xgp; Tue, 16 Jul 2024 15:05:53 +0000 Received: from mail-ej1-x62e.google.com ([2a00:1450:4864:20::62e]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sTjkD-0000000AqyB-2F8C for linux-arm-kernel@lists.infradead.org; Tue, 16 Jul 2024 15:05:35 +0000 Received: by mail-ej1-x62e.google.com with SMTP id a640c23a62f3a-a77e6dd7f72so670472866b.3 for ; Tue, 16 Jul 2024 08:05:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1721142331; x=1721747131; darn=lists.infradead.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=oIsP9WfA0TMZUezHpRe4LD3xeHG2Pnug2FDZg/pF9jA=; b=Rgj6tduFgvoe8Nn0Av7r61QeMBjAXhZRj1TbTks5h0Dq6UuNce1PH17IZTLrUnp15d rj9i4A9EBQOaACcV/xMd/4HOKOtKxH0RF9NfpOqxvbp8tNhs9ODmaN6Oth+4CI3SOC3w yEa0eL8/jqfRq+JUz/piDaZOFkxnjRdQmf8TS462SHmrxViDGlHVQCk62bmpqDVjK0sL BuB1r4rLRvCv2Bs/ixck6wwfEfvaomNdubaYMnn8jFrvSFs6LTcbHMU75lHgs0+VbUwE EVTYbEBogNiKOfS2ZrwIK12cip0wMNVvQSx96RN6kz4bCHm7allYjG/3eN6ql1k4xFzY fajg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721142331; x=1721747131; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=oIsP9WfA0TMZUezHpRe4LD3xeHG2Pnug2FDZg/pF9jA=; b=rt3l3Yiu7iF9k8omrbdymJvJPePqTptsoKSw7ecShrO+vaw3ZSYOPfogSebWe6iVu+ 8uE4IcszVv+dbW+G8V250JL7UunohC7V86mnyqG0sljlKwZj5W6zi42TWxPhDH5lKZzT phCWc8ea4L2tywWjulN/QQfRNSkcKenjA7KeQJZ3n5zB+UdxESq5nhtPUSwg06cjjlMG ql1/DAwc2gQq5sY9udAx4QJdWpxA/dcHXD1zLi32qffFIm8DBODryDSnX/Td+OZiXXPE r2hVKjy68wGV8I0WjL7HVMUU4fWkjpCOAt9nN9VnDz5S3+Nd3+16WdfUSt/LDiSqlehA I/uA== X-Forwarded-Encrypted: i=1; AJvYcCXptFfJyjxyt8x37Z9IoZf2uOdMZsd73X7cXvSxMe7RIdYmMgC98TEYa4GUFc5rqmYoC3qdOMXxSj+fH1eQ5XM+AIM325/LQHiiQ1vhB7zbpWi4RJk= X-Gm-Message-State: AOJu0YyWJM+6YTUEhuygtVV6GgtCgiKznQ2Av85tY0KfGSkeHNId3v3+ qiSBJ5DtLnhhGTWc7Knir8VYJy3MRrXjHJdZw13HxsHtNY3+5pc4 X-Google-Smtp-Source: AGHT+IHu17WSkuVX0jxOAWCJadIe0O6dlHEv4dokYnccOiyPeH2LoXogdOhBgimTWYiWMAXlMX5fnw== X-Received: by 2002:a17:907:dac:b0:a77:e0ed:8b9 with SMTP id a640c23a62f3a-a79ea3dfc64mr274375466b.6.1721142330957; Tue, 16 Jul 2024 08:05:30 -0700 (PDT) Received: from eichest-laptop ([77.109.188.34]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a79bc7f1e04sm328378066b.127.2024.07.16.08.05.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Jul 2024 08:05:30 -0700 (PDT) Date: Tue, 16 Jul 2024 17:05:28 +0200 From: Stefan Eichenberger To: Frank Li Cc: o.rempel@pengutronix.de, kernel@pengutronix.de, andi.shyti@kernel.org, shawnguo@kernel.org, s.hauer@pengutronix.de, festevam@gmail.com, wsa+renesas@sang-engineering.com, francesco.dolcini@toradex.com, joao.goncalves@toradex.com, linux-i2c@vger.kernel.org, imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Stefan Eichenberger Subject: Re: [PATCH v1 3/3] i2c: imx: prevent rescheduling in non dma mode Message-ID: References: <20240715151824.90033-1-eichest@gmail.com> <20240715151824.90033-4-eichest@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240716_080533_595135_9778766A X-CRM114-Status: GOOD ( 24.04 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hi Frank, On Mon, Jul 15, 2024 at 01:03:26PM -0400, Frank Li wrote: > > +static inline void i2c_imx_isr_read_continue(struct imx_i2c_struct *i2c_imx) > > +{ > > + unsigned int temp; > > + > > + if ((i2c_imx->msg->len - 1) == i2c_imx->msg_buf_idx) { > > + if (i2c_imx->is_lastmsg) { > > + /* > > + * It must generate STOP before read I2DR to prevent > > + * controller from generating another clock cycle > > + */ > > + temp = imx_i2c_read_reg(i2c_imx, IMX_I2C_I2CR); > > + if (!(temp & I2CR_MSTA)) > > + i2c_imx->stopped = 1; > > + temp &= ~(I2CR_MSTA | I2CR_MTX); > > + imx_i2c_write_reg(temp, i2c_imx, IMX_I2C_I2CR); > > + } else { > > + /* > > + * For i2c master receiver repeat restart operation like: > > + * read -> repeat MSTA -> read/write > > + * The controller must set MTX before read the last byte in > > + * the first read operation, otherwise the first read cost > > + * one extra clock cycle. > > + */ > > + temp = imx_i2c_read_reg(i2c_imx, IMX_I2C_I2CR); > > + temp |= I2CR_MTX; > > + imx_i2c_write_reg(temp, i2c_imx, IMX_I2C_I2CR); > > + } > > + } else if (i2c_imx->msg_buf_idx == (i2c_imx->msg->len - 2)) { > > + temp = imx_i2c_read_reg(i2c_imx, IMX_I2C_I2CR); > > + temp |= I2CR_TXAK; > > + imx_i2c_write_reg(temp, i2c_imx, IMX_I2C_I2CR); > > + } > > + > > + i2c_imx->msg->buf[i2c_imx->msg_buf_idx++] = imx_i2c_read_reg(i2c_imx, IMX_I2C_I2DR); > > Why not use loop to read all data from FIFO? I think read_reg use readb(), > suggest change to readb_relaxed(). The similar case for writeb. dma_engine > will use writel() at least once when start DMA. it should be enough for > memory barrier. > > Because it move to irq handle, writex__relaxed() will help reduce some > register access time. > I think there is not FIFO on the i.MX I2C controller, or do I miss something? In the i.MX 8M Plus reference manual they write for example: > In Master Receive mode, reading the data register allows a read to occur > and initiates the next byte to be received. I will test the changes with readb_relaxed() and writeb_relaxed() and see what happens, thanks a lot for the hint. Regards, Stefan