Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp1568785pxa; Thu, 6 Aug 2020 10:28:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxoFSQwkRImpc+6Z6bSyoKYdRIzN8DBEL+0pMhQqsv0M8F82ovJIOI67ki5n4hBX20eqrjY X-Received: by 2002:a17:907:100f:: with SMTP id ox15mr5293000ejb.323.1596734908844; Thu, 06 Aug 2020 10:28:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596734908; cv=none; d=google.com; s=arc-20160816; b=aX6p0xvdmMct8dHsKkGxcO2nV/q3uOAUgCiHR52G/oSqmHv5wDpMBtvEvBpsANMBPC aU3KSOMxzss7o/cdUAND/3vFqmyBfoTCPQGrIdfNVNfk9Y7M6ba8I5tKj5MTd9BfbNvE P9MrKZqL0qScrRwG86fFaV3u/FANJ1LfzUUup1Jja1DnXYyjcJYxdqSCOweiUebYTT3T 0dzm81FtWQYJYfShEt4K5ZJIjazF0Sx1c+xCZKtdBW6asabFWYVtVhB8V+4h+i15JQCk qhCnayADIKzno3lsNduq4CcH2l2sBY7sqWrDSXmrZaH7vuNJUcvlN3ULC7LflXEDsnRL r04w== 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:dkim-signature; bh=aV1obyLP1kSAuWoOSd1TJKMwTZ27aQ8wVfEpw+0wGBU=; b=tJ/V49kkil8Ydh0nlIZ4Snz6kt7HJBk0gEl1cfora+QWyZZTacD16JvtbN+b4woYcr PfFUJHxEoe8o4HCLvkUB9ac0dCN8CY5boFqSC+JATEWdLNqTt2okJENQ2eQq5A/v1bBR D/BTo4b4vy/hq+ZcgZmTUKdCi9TyeM55MpRvD6Vp5WakfwA6iCIb6krDskml3fSXNf4G kwbZ7sCQb8a8FYuNFW6aeUXbsu///Lu1tA+NSJ/KWSB2agTIH+uWYuK1BCXXvPXfARrX BivgnxTTKqYBqGodRcv5yNpL4dl/8kXCkBCX9vSBUNt2Bxj75/JzS33pfXJ3ZyJ6PQwl VKSA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=a9WJfCrp; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i24si3764638eja.529.2020.08.06.10.28.05; Thu, 06 Aug 2020 10:28:28 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=a9WJfCrp; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730049AbgHFR1W (ORCPT + 99 others); Thu, 6 Aug 2020 13:27:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49156 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727057AbgHFR1U (ORCPT ); Thu, 6 Aug 2020 13:27:20 -0400 Received: from mail-lj1-x241.google.com (mail-lj1-x241.google.com [IPv6:2a00:1450:4864:20::241]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D470CC061574; Thu, 6 Aug 2020 10:27:18 -0700 (PDT) Received: by mail-lj1-x241.google.com with SMTP id i10so17919639ljn.2; Thu, 06 Aug 2020 10:27:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=aV1obyLP1kSAuWoOSd1TJKMwTZ27aQ8wVfEpw+0wGBU=; b=a9WJfCrpB0mlGFNpjp3IMfO8eESkaYVXerUr07b3nryvHt7lbOBlM6Ty3pQW2Q544O uUTqXruVltYm4Xm/9+qUMi8tpCWA/dePs4LvfKbLdpYyscOAy70TzTqm+ezEu8bsb/BF c5I3sLn+QKgstFfFONCvce0M4QYvl8bofh0CsIl7Io8GCP0KMzaUk/uRXs6+tDT9ufm1 7EviczQgNP7fD0T30hHs6/6YLgLWnhHPk9J+xAK4GJbNxyCeRHPgo9B7ln9sJlL/6r88 F/Gf0r+jAUN9aunIRSR+SVbJQlWyHBbNynqgnOM3DI2RNT2KWf75FuJSEVdSoWs4MoAJ 3H4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=aV1obyLP1kSAuWoOSd1TJKMwTZ27aQ8wVfEpw+0wGBU=; b=jWfmdvpRKtHfvME27eeiVVdgejwUCu1576N44sd6lUKCFGik305IGfzQOmiEWeNoYL fMI7Z65ftnBiu/VjLioupFI6eCakvQLKq/95hXTEhbfVlcmLQte3vq6Jn2D462w7JU7X KSH6NFFw83afqfgJ4rSifIIHMRFQTP1ngGJs2ACszrx5Q8A1/IB/mtiNT9bUsoHzOwXn qN2ImEY52KcpnY2qjSXzSLFclAk0WoanbPVCsTjyXc9awx4B9VKJwS7kB246dx20pTwn lvJOlRcq7IuuFdWlola2SH6I2NjKyb5s5bmV2oKTsCivKTr9tTcMkWLf07i4GtI4QC6V T97A== X-Gm-Message-State: AOAM533QiENBK8PcbuB4vm2+zHRpuPSHkguBq7SmwZjRP8Zr7/cYwU1K jkol+OkNROXLyDRuBNCdCAGIQeN2 X-Received: by 2002:a2e:b0d2:: with SMTP id g18mr4011627ljl.136.1596734836681; Thu, 06 Aug 2020 10:27:16 -0700 (PDT) Received: from [192.168.2.145] (94-29-41-50.dynamic.spd-mgts.ru. [94.29.41.50]) by smtp.googlemail.com with ESMTPSA id g4sm2974058lfh.13.2020.08.06.10.27.15 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 06 Aug 2020 10:27:15 -0700 (PDT) Subject: Re: [PATCH v8 08/10] gpu: host1x: mipi: Keep MIPI clock enabled till calibration is done To: Sowjanya Komatineni , Thierry Reding Cc: jonathanh@nvidia.com, frankc@nvidia.com, hverkuil@xs4all.nl, sakari.ailus@iki.fi, robh+dt@kernel.org, helen.koike@collabora.com, gregkh@linuxfoundation.org, linux-media@vger.kernel.org, devicetree@vger.kernel.org, linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org References: <1596469346-937-1-git-send-email-skomatineni@nvidia.com> <20200805134600.GA3351349@ulmo> <103efe31-1abc-54f2-6004-490d7bb1b61a@gmail.com> <6eede805-80fd-016f-22f8-b6d25f6587af@nvidia.com> <1c12e40e-de7f-0599-a941-82760b4c7668@gmail.com> <9ef0b875-e826-43e2-207e-168d2081ff6a@nvidia.com> <4689cfe9-e7c4-48bf-217f-3a31b59b8bda@nvidia.com> <0e78c5ca-c529-1e98-891d-30351c9aae81@gmail.com> <309e3b66-9288-91ef-71b4-be73eacbbd62@nvidia.com> <4025a458-fa78-924d-c84f-166f82df0f8e@gmail.com> <4f15d655-3d62-cf9f-82da-eae379d60fa6@nvidia.com> <412f8c53-1aca-db31-99a1-a0ecb2081ca5@nvidia.com> <61275bd6-58e7-887f-aa7d-8e60895e7b2b@nvidia.com> From: Dmitry Osipenko Message-ID: <6ff57c38-9847-42b0-643b-0d167c13779f@gmail.com> Date: Thu, 6 Aug 2020 20:27:15 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <61275bd6-58e7-887f-aa7d-8e60895e7b2b@nvidia.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 06.08.2020 20:12, Sowjanya Komatineni пишет: > > On 8/6/20 9:41 AM, Sowjanya Komatineni wrote: >> >> On 8/6/20 9:10 AM, Dmitry Osipenko wrote: >>> 06.08.2020 18:59, Sowjanya Komatineni пишет: >>> ... >>>>>> Confirmed from HW designer, calibration FSM to finish takes worst >>>>>> case >>>>>> 72uS so by the time it gets to sensor stream it will be done its >>>>>> sequence and will be waiting for DONE bit. >>>>>> >>>>>> So disabling MIPI CAL clock on sensor stream fails is safe. >>>>> 72us is quite a lot of time, what will happen if LP-11 happens before >>>>> FSM finished calibration? >>>>> >>>>> Maybe the finish_calibration() needs to split into two parts: >>>>> >>>>>    1. wait for CAL_STATUS_ACTIVE before enabling sensor >>>>>    2. wait for CAL_STATUS_DONE after enabling sensor >>>> I don't think we need to split for active and done. Active will be 1 as >>>> long as other pads are in calibration as well. >>>> >>>> We cant use active status check for specific pads under calibration. >>>> This is common bit for all pads. >>> Does hardware have a single FSM block shared by all pads or there is FSM >>> per group of pads? >> >> MIPI CAL status register has DONE bits for individual pads status and >> single ACTIVE bit. >> >> ACTIVE bit set to 1 indicates auto calibration is active which is the >> case even when other pads (other CSI pads from other ports streaming >> in case of parallel stream) are under calibration. Also DSI is shared >> as well. >> >> We do calibration for individual pads. So, we should not rely on >> ACTIVE bit. >> >> >> MIPI driver checks for condition ACTIVE == 1 && DONE == 1 from the >> beginning. >> >> But I think this also should be fixed as in case of parallel streams >> calibration can happen in parallel waiting for ACTIVE to be cleared >> makes all calibration callers to wait for longer than needed as ACTIVE >> is common for all pads. >> >>> >>>> Unfortunately HW don't have separate status indicating when sequence is >>>> done to indicate its waiting for LP11. >>>> >>>> >>>> To avoid all this, will remove cancel_calibration() totally and use >>>> same >>>> finish calibration even in case of stream failure then. >>>> >>> What about to add 72us delay to the end of start_calibration() in order >>> to ensure that FSM is finished before LP-11? >> >> Why we should add 72uS in start_calibration() when can use same >> finish_calibration() for both pass/fail cases? >> >> Only timing loose we see is in case of failure we still wait for 250ms >> and as this is failing case I hope should be ok. >> > Also as we don't need cancel_calibration(), keeping tegra_mipi_wait() > like earlier makes sense I believe as we are letting it finish going > thru sequence. > > So I think below are fixes, > > 1. Existing MIPI driver, tegra_mipi_wait() to not use status ACTIVE bit > to be 0 and use only DONE bit to be 1 for wait condition  as we are > calibrating separately for individual pads and this ACTIVE bit is common > for all pads where it will not be 0 in case of other parallel streams > which may also be under calibration. Yes, looks like it's a mistake of the current MIPI driver that it polls the ACTIVE bit. > 2. No need for separate cancel_calibration. So, probably earlier names > tegra_mipi_calibrate() and tegra_mipi_wait() hols good as we are waiting > for calibration sequence to finish irrespective of fail/pass. The new names reflect better what those functions actually do, IMO. What about to make finish_calibration() to take an additional argument which corresponds to the awaited HW bits? For example if it's CSIA, then it could be: tegra_mipi_finish_calibration(csi_chan->mipi, MIPI_CAL_CSIA); Also, is it okay that DSI and CSI could change MIPI_CAL_CTRL after DSI or CSI already started calibration? Looking at the current start_calibration(), I think the mutex should be kept locked and then finish_calibration() should unlock it.