Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp3947316ybz; Mon, 20 Apr 2020 12:26:07 -0700 (PDT) X-Google-Smtp-Source: APiQypLEwDwNvpkrQOEKGcLFmPK9z0mlUtTAvVwV/YyTk02qWb0nzy//yCaemIahQM9Xw9xy/w5E X-Received: by 2002:a17:906:c7c5:: with SMTP id dc5mr17956568ejb.50.1587410767040; Mon, 20 Apr 2020 12:26:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587410767; cv=none; d=google.com; s=arc-20160816; b=zmpQS4me21l7r3dI9G+T4ASKksOLfQdAPGnufvI0VlltM8+KwPE1TTbt65yd6rRIwu Pht6sKh0ZaDq38B/33R5IsNjuaMbKuSBxClSVOA4OON+/Cudd3tOt3082UvqanGeRdmY Me38Jzh/dnuXHyaCQA069SLoliktzrhUm+as8YRPg1MjaAzE57SQFlhmPyvt5VzpjRkp 34KQ2hZ6zO37IBn+QWrQKz4k/W58IwjOuSITBxe03/ZgsJGUcMQGFF4suQCGgniaizUl 3yimgh6z6FlvTtFUP2GX4RI+a3z4jK+Q2ZuIJYsdVLxCnQQOS9LxubPF7mLzyRedsvTR EiFg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=ouDplEWW6fUbkXauA/dfejTAIJtQtE2FMr6yjX1ql2k=; b=w4LmJod9ecTb+bO4wAH4AAtuBAqZUDOr0UDWdhcbcU3c5EDMuj9GSCn6GfExhYhM0L 2xtMckEesJH+9su00LDX72RCsOpl0X+gB6k54lT41Dg9nlXH+sBXvDSkcRhTih2DLhk+ XRiuLyg2qPmmccYCVUsZb74mgFR4FDIyGgDf7dOzwrtImWpCwRKg5ObVPx/5xI1NUBx7 W+NcWBN9g6LCv8LZ2LAIspNyuCdwA5LEqf62+tQhTj7taTb3OP4LLyIMwrku4TKQUU9a jB6mEkkbPrirPhqkHceeclnQdYN46vFQqScNPZx02mYKiWK5ntjceBxHJCwiUuiVRvyJ N1pQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g3si243682edj.328.2020.04.20.12.25.44; Mon, 20 Apr 2020 12:26:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726816AbgDTTYd (ORCPT + 99 others); Mon, 20 Apr 2020 15:24:33 -0400 Received: from hostingweb31-40.netsons.net ([89.40.174.40]:45059 "EHLO hostingweb31-40.netsons.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725896AbgDTTYd (ORCPT ); Mon, 20 Apr 2020 15:24:33 -0400 Received: from [5.157.121.18] (port=47580 helo=[192.168.77.62]) by hostingweb31.netsons.net with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1jQc1o-003t9B-Rv; Mon, 20 Apr 2020 21:24:24 +0200 Subject: Re: [PATCH v11 2/2] media: v4l: xilinx: Add Xilinx MIPI CSI-2 Rx Subsystem driver To: Laurent Pinchart , Vishal Sagar Cc: Hyun Kwon , mchehab@kernel.org, robh+dt@kernel.org, mark.rutland@arm.com, Michal Simek , linux-media@vger.kernel.org, devicetree@vger.kernel.org, hans.verkuil@cisco.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Dinesh Kumar , Sandip Kothari , Jacopo Mondi , Hyun Kwon References: <20200409194424.45555-1-vishal.sagar@xilinx.com> <20200409194424.45555-3-vishal.sagar@xilinx.com> <20200419180222.GB8117@pendragon.ideasonboard.com> From: Luca Ceresoli Message-ID: <860c27da-eba0-ddcb-719b-52b2725bd9bf@lucaceresoli.net> Date: Mon, 20 Apr 2020 21:24:25 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 MIME-Version: 1.0 In-Reply-To: <20200419180222.GB8117@pendragon.ideasonboard.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - hostingweb31.netsons.net X-AntiAbuse: Original Domain - vger.kernel.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - lucaceresoli.net X-Get-Message-Sender-Via: hostingweb31.netsons.net: authenticated_id: luca@lucaceresoli.net X-Authenticated-Sender: hostingweb31.netsons.net: luca@lucaceresoli.net X-Source: X-Source-Args: X-Source-Dir: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Laurent, Vishal, On 19/04/20 20:02, Laurent Pinchart wrote: [...] >> +static irqreturn_t xcsi2rxss_irq_handler(int irq, void *dev_id) >> +{ >> + struct xcsi2rxss_state *state = (struct xcsi2rxss_state *)dev_id; >> + struct xcsi2rxss_core *core = &state->core; >> + u32 status; >> + >> + status = xcsi2rxss_read(core, XCSI_ISR_OFFSET) & XCSI_ISR_ALLINTR_MASK; >> + dev_dbg_ratelimited(core->dev, "interrupt status = 0x%08x\n", status); > > As this is expected to occur for every frame, I would drop the message, > even if rate-limited. > >> + >> + if (!status) >> + return IRQ_NONE; >> + >> + /* Received a short packet */ >> + if (status & XCSI_ISR_SPFIFONE) { >> + dev_dbg_ratelimited(core->dev, "Short packet = 0x%08x\n", >> + xcsi2rxss_read(core, XCSI_SPKTR_OFFSET)); >> + } > > Same here, this will occur all the time, I'd remove this message. You > need to read XCSI_SPKTR_OFFSET though, and you should do so in a loop > until the XCSI_CSR_SPFIFONE in XCSI_CSR_OFFSET is cleared in case > multiple short packets are received before the interrupt handler > executes. > > I also wonder if it would make sense to extract the frame number from > the FS short packet, and make it available through the subdev API. I > think it should be reported through a V4L2_EVENT_FRAME_SYNC event. This > can be implemented later. > >> + >> + /* Short packet FIFO overflow */ >> + if (status & XCSI_ISR_SPFIFOF) >> + dev_dbg_ratelimited(core->dev, "Short packet FIFO overflowed\n"); >> + >> + /* >> + * Stream line buffer full >> + * This means there is a backpressure from downstream IP >> + */ >> + if (status & XCSI_ISR_SLBF) { >> + dev_alert_ratelimited(core->dev, "Stream Line Buffer Full!\n"); >> + xcsi2rxss_stop_stream(state); >> + if (core->rst_gpio) { >> + gpiod_set_value(core->rst_gpio, 1); >> + /* minimum 40 dphy_clk_200M cycles */ >> + ndelay(250); >> + gpiod_set_value(core->rst_gpio, 0); >> + } > > I don't think you should stop the core here. xcsi2rxss_stop_stream() > calls the source .s_stream(0) operation, which usually involves I2C > writes that will sleep. > > You should instead report an event to userspace (it looks like we have > no error event defined in V4L2, one should be added), and rely on the > normal stop procedure. FWIW, since a long time I've been using a modified version of this routine, where after a Stream Line Buffer Full condition I just stop and restart the csi2rx core and the stream continues after a minimal glitch. Other subdev are unaware that anything has happened and keep on streaming. Not sure this is the correct thing to do, but it's working for me. Also I proposed this topic in one of the previous iterations of this patch, but the situation was different because the stream on/off was not propagated back at that time. -- Luca