Received: by 10.223.176.5 with SMTP id f5csp114273wra; Mon, 5 Feb 2018 17:55:03 -0800 (PST) X-Google-Smtp-Source: AH8x2271kTs8vQ6jaJ2xOT/7dwR93wUNnOAGaoPqNyg0lw3mwWXYjhmPdmEZQSLJI5STYeRDUcmg X-Received: by 2002:a17:902:8bc5:: with SMTP id r5-v6mr745621plo.213.1517882103612; Mon, 05 Feb 2018 17:55:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517882103; cv=none; d=google.com; s=arc-20160816; b=RBRm+aID0svRDff7WpPbQ1UEdO5CpaYKjDPSFU0dVpvcSA7b2yWzFhYrkPvHRY45H2 bF9tr9XAuKPVhIbAeEVkg9/C1JlTG9J47XcPX8ARdj5HnXr4dCXcVhSuBxxVQMPOitsD zKq56RegC+gH3N3XmSeoN7uXXMYZhj2rF6pxybGpW3vx/iYAQGabRHNv6ElimsCwjGep O8dXXRWUP1EQWZYsedRHHabqD4WbQFAG+nRCP7fWLYOyTxiGoEimMk9B5t5aruN3QXXf iZjKgT0Ncm52rxd0tZX2tRyZ/iHYg5mgvvm8nAuanXJPHYxZYMza+qfWz9hR7K1TQsL1 9kmg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=UgQdA3NgYbGXwnt+r7kjde8Nd6xArHghhB/EuBmK9D8=; b=dS3VmuTFuhGihbOS4lOK5YrLNI7LSHzhiDJV4XxGkGYq6BcnbJcTqLwaoQasV77Dcv 4LmTLTRnSw+h3vZJ5icAKPM28Ye7lJWb7yl9wqIbi/PQ2A5LsjZNurlsrE3A0VooONs3 +RF9sAUUQHOXQkaNSqnaBouXgduEACLhKuzX7WbraLu4x/LFGuYUvr7gZAcB1D5gBFEq 5c33MM+0u4vW1IUhLfFVcxApdnVB7i7D7yfRosyrpTLgpjLFtkVksgMHnIvEGW6/+6xp fc6Y/eKKhRPbkK15cKhmx+uKA4shmW7gQpu0eqyCChuN/4g4bS3vYyW0VRIqJ6R8rQWm dL5w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=cK8/X521; 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=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b91-v6si3699343plb.819.2018.02.05.17.54.47; Mon, 05 Feb 2018 17:55:03 -0800 (PST) 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=@chromium.org header.s=google header.b=cK8/X521; 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=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752361AbeBFBxQ (ORCPT + 99 others); Mon, 5 Feb 2018 20:53:16 -0500 Received: from mail-pg0-f67.google.com ([74.125.83.67]:33904 "EHLO mail-pg0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752069AbeBFBxK (ORCPT ); Mon, 5 Feb 2018 20:53:10 -0500 Received: by mail-pg0-f67.google.com with SMTP id s73so370330pgc.1 for ; Mon, 05 Feb 2018 17:53:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=UgQdA3NgYbGXwnt+r7kjde8Nd6xArHghhB/EuBmK9D8=; b=cK8/X5214GE/GW4hJYfYopj9yE9O8iQCQoAAoFP6yTF6/J6zG0J4JveLo9WvtmHlgA CRr28IlDEJFrIkLv4ACaARPsia8WyfIjEara+a0pZw9WPUPvY3lp2SeOp1FKTL5wMgd9 kSJIe1JOZZcjql+qCsChjjQUffGbQS8fTE2X0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=UgQdA3NgYbGXwnt+r7kjde8Nd6xArHghhB/EuBmK9D8=; b=WIvcqdEK43wiUI8WzLxEjcaDnxB8fCDKzlL/lIh0g2kgLBpBtP2TaC06UvsPdkPjb1 dkV2053UVvm4wysyxWc+fnlPwWtEYp9jrtRHooQY5qaZ0CVNoUXXJlOGFLDAMEcbkqZz zLtdf+H8tF+iFsFt23OqcJEbe9DMdOeUuMNyv4wS4NwMpQueeHCYbgD7HqZAZSt4XV6U wnl5T278wrzl8Gvw4sOx8UgmgUWlxAXZr0DPawrF2uq5ftSmg/3Ze+WWhHJVDKloLvaK UaYoNgyHaL6fmrSXFpeNUlV94QJCQ93emIcZdjrP0Fpp15l2kEpR82TuSfjk9pm2pIMT jQNQ== X-Gm-Message-State: APf1xPD5remt0EoFX5sKy2kgB/H1E2Daav8AcjnUgeXFjE8l0+0sv2pc fRSJaHH0IPlMIcADM4s8k/fpEg== X-Received: by 10.99.126.73 with SMTP id o9mr608526pgn.429.1517881989221; Mon, 05 Feb 2018 17:53:09 -0800 (PST) Received: from ban.mtv.corp.google.com ([172.22.113.17]) by smtp.gmail.com with ESMTPSA id d205sm18745887pfd.165.2018.02.05.17.53.08 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 05 Feb 2018 17:53:08 -0800 (PST) Date: Mon, 5 Feb 2018 17:53:06 -0800 From: Brian Norris To: Philippe Cornu Cc: Archit Taneja , Andrzej Hajda , Laurent Pinchart , David Airlie , Benjamin Gaignard , Bhumika Goyal , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Sandy Huang , Heiko Stubner , linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org, Yannick Fertre , Vincent Abriou , Alexandre Torgue , Lin Huang , mka@chromium.org Subject: Re: [PATCH] drm/bridge/synopsys: dsi: Add read feature Message-ID: <20180206015306.GA112054@ban.mtv.corp.google.com> References: <20180204213104.17834-1-philippe.cornu@st.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180204213104.17834-1-philippe.cornu@st.com> User-Agent: Mutt/1.9.2 (2017-12-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On Sun, Feb 04, 2018 at 10:31:04PM +0100, Philippe Cornu wrote: > This patch adds the DCS/GENERIC DSI read feature. > > Signed-off-by: Philippe Cornu > --- > Extra notes: > DSI read tests have been performed with DCS & GENERIC, short & long > commands, on two different panels. > The maximum fifo size (32*32-bit = 128 bytes on stm32) has been > verified too. Seems OK to me, just comparing with work we've been borrowing from Rockchip: https://chromium-review.googlesource.com/c/chromiumos/third_party/kernel/+/863347 (And in fact, it looks much better than that.) So FWIW: Reviewed-by: Brian Norris and thanks a bunch! Brian > drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c | 58 +++++++++++++++++++++------ > 1 file changed, 45 insertions(+), 13 deletions(-) > > diff --git a/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c b/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c > index e9422d05e897..65aeb3f78b48 100644 > --- a/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c > +++ b/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c > @@ -397,18 +397,46 @@ static int dw_mipi_dsi_write(struct dw_mipi_dsi *dsi, > return dw_mipi_dsi_gen_pkt_hdr_write(dsi, le32_to_cpu(word)); > } > > +static int dw_mipi_dsi_read(struct dw_mipi_dsi *dsi, > + const struct mipi_dsi_msg *msg) > +{ > + int i, j, ret, len = msg->rx_len; > + u8 *buf = msg->rx_buf; > + u32 val; > + > + /* Wait end of the read operation */ > + ret = readl_poll_timeout(dsi->base + DSI_CMD_PKT_STATUS, > + val, !(val & GEN_RD_CMD_BUSY), > + 1000, CMD_PKT_STATUS_TIMEOUT_US); > + if (ret) { > + dev_err(dsi->dev, "Timeout during read operation\n"); > + return ret; > + } > + > + for (i = 0; i < len; i += 4) { > + /* Read fifo must not be empty before all bytes are read */ > + ret = readl_poll_timeout(dsi->base + DSI_CMD_PKT_STATUS, > + val, !(val & GEN_PLD_R_EMPTY), > + 1000, CMD_PKT_STATUS_TIMEOUT_US); > + if (ret) { > + dev_err(dsi->dev, "Read payload FIFO is empty\n"); > + return ret; > + } > + > + val = dsi_read(dsi, DSI_GEN_PLD_DATA); > + for (j = 0; j < 4 && j + i < len; j++) > + buf[i + j] = val >> (8 * j); > + } > + > + return ret; > +} > + > static ssize_t dw_mipi_dsi_host_transfer(struct mipi_dsi_host *host, > const struct mipi_dsi_msg *msg) > { > struct dw_mipi_dsi *dsi = host_to_dsi(host); > struct mipi_dsi_packet packet; > - int ret; > - > - if (msg->rx_buf || msg->rx_len) { > - /* TODO dw drv improvements: implement read feature */ > - dev_warn(dsi->dev, "read operations not yet implemented\n"); > - return -EINVAL; > - } > + int ret, nb_bytes; > > ret = mipi_dsi_create_packet(&packet, msg); > if (ret) { > @@ -422,12 +450,16 @@ static ssize_t dw_mipi_dsi_host_transfer(struct mipi_dsi_host *host, > if (ret) > return ret; > > - /* > - * TODO Only transmitted size is returned as actual driver does > - * not support dcs/generic reads. Please update return value when > - * delivering the read feature. > - */ > - return packet.size; > + if (msg->rx_buf && msg->rx_len) { > + ret = dw_mipi_dsi_read(dsi, msg); > + if (ret) > + return ret; > + nb_bytes = msg->rx_len; > + } else { > + nb_bytes = packet.size; > + } > + > + return nb_bytes; > } > > static const struct mipi_dsi_host_ops dw_mipi_dsi_host_ops = { > -- > 2.15.1 >