Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp652647ybz; Wed, 15 Apr 2020 16:01:03 -0700 (PDT) X-Google-Smtp-Source: APiQypJPQQZwPHS0iarHkf87N+ITl38AOjq1HFlOlg8q2k0j9382pKwi97xKcHwSDRTYntuSagrJ X-Received: by 2002:a17:906:412:: with SMTP id d18mr6760564eja.54.1586991663144; Wed, 15 Apr 2020 16:01:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586991663; cv=none; d=google.com; s=arc-20160816; b=QT7q105Uan2pNVtfQx3oYNVgu/02WAMVOzdQNs0MeL6tr2fx4cpfqC5oW7X6KMMz4w ivlYGnMUJUAtk7DzvSed97xQSnr444GRzUs616M1g9/V/wN6tciWwcg5KG+/HmSZi2wV 4NU+Q+1oyiyEQzh0FwcOByezZSguwkdeZjwBiKJenrdOQa+f4tSHBcPD5yyH+pFOXfZU QizKfsT/XOQfP0d7WOfu/UatCC131bLEj1UPyOVPIi5E29Dv/q/TLYXTkT45fOFPYY7+ 8Bs6zMQrqcdfDDg7Dx0XqGm/ppHkctrK70/LiWeT0La+gLdZzIB6kQSSeJIP2vPgUUhm vjsA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=7VVkEWhFDrQp1FEX/xgl0zHsV0VTqPDsyKWDKAx8HhU=; b=BiQN3gDYTybfhRzBO9FcbQe8d0FkXLpjah2xkwHQ+lxfWAv6BtdBLLjfzH53jeYOss jnMkMaKYGHsyJGtwofkmZqSll0n0B9OefwjfAMSuvum884oEShSVk9Trt4EzYtbGcQef YJV7SveZWbS5dE6UN9P/qmAljpP3KXPI2XoheBJymaevkHK0pV7f/cT+zNkT7OVTgc4Y 5DzJh3E48kWSdiYjgUnja+CZUwER0pi6t0PW9pRznnRVJa13fI6DbKxNHaZXFfgdy+S8 NfX/7+/OEsZl68E1ib2M+XCcoYhI4TrPgBu+/J/Ph4gyivV1EEuy6UqEQPhl/1xOjnPY ZHcw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=qbZFV3Bl; 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=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id fx19si2906666ejb.39.2020.04.15.16.00.39; Wed, 15 Apr 2020 16:01:03 -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=@linaro.org header.s=google header.b=qbZFV3Bl; 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=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2896790AbgDOLMJ (ORCPT + 99 others); Wed, 15 Apr 2020 07:12:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36126 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2896758AbgDOLLA (ORCPT ); Wed, 15 Apr 2020 07:11:00 -0400 Received: from mail-ot1-x342.google.com (mail-ot1-x342.google.com [IPv6:2607:f8b0:4864:20::342]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9D01CC061A0C for ; Wed, 15 Apr 2020 04:10:25 -0700 (PDT) Received: by mail-ot1-x342.google.com with SMTP id x11so2965833otp.6 for ; Wed, 15 Apr 2020 04:10:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=7VVkEWhFDrQp1FEX/xgl0zHsV0VTqPDsyKWDKAx8HhU=; b=qbZFV3BlewRqWWzxURbMbQyWSKBolKHBMmxFyRO94vFBV6mxHqqIfEqv7TQ+iFMsv1 1nR6ZF1eviwKR/cFpxfubIZegHBYf5A9fKZpT/SD1eypiranG1RGxGa8bt/mztgvzH0O lRdJSE8wksvgW1oflK34Dfw86IJu+n2MDsOLG0TmbOw2qYhXqvI5YLUl90jjXi2+BoGD 5Ut/KoR5fHbvxYX9jIBvCVED3OAVRGVpkDIiMqTnmGTVfvt3RHx9SzNS965hXOLgSJ6w c0FdkNtJt+PbSfJK0R4rHF+gUW0tMZYaPGv8NNqx/nUOY1FtoYN0ozthEOySpYMU6rY9 K+6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=7VVkEWhFDrQp1FEX/xgl0zHsV0VTqPDsyKWDKAx8HhU=; b=D1plGz95ROW6Mp71aVfve2+nrx6NNo8xjiV0lykpuS1G115EjTX1uO+vbE89VPIi7R hvpZwa9PDlgqJN8LPR8oWek6QpCFpbg2HDmLgTiS2GeSYP7eVlTO8aM0z8nHnP5T5G/X 11zJcBaibUVOOklZj8hd6qpLg8WybBPRnsBy6RF/GSZdLEZ4Dd+IUSuAZBV4XJxm6t/j 5hhL1PQV0bjhnmzdieCbI9sMNNspPQNj1BtfTGt38SDEl7w8oSG7V9n3sVJh8H3zhqKq q/v+vQ19VaoyG9jyUeKzDtEx79HdKfZH+XaVFAVV/3GHEkp+wV1ePMZ6dQcmNCdUt9AZ N9nw== X-Gm-Message-State: AGi0Pubr6pE01y5IVV/uWufT6Fe1sto6pjjU7LB1Farni/6PtQKgqTSf 5BEqr7+37DYR6uO+9ykLPvqCM4PP3NrhInBcwl4CWg== X-Received: by 2002:a05:6830:1e4e:: with SMTP id e14mr3795854otj.91.1586949024721; Wed, 15 Apr 2020 04:10:24 -0700 (PDT) MIME-Version: 1.0 References: <20200407123232.ktvaifhqntgzvkap@gilmour.lan> <20200407163916.GL6127@valkosipuli.retiisi.org.uk> <20200407172035.GM6127@valkosipuli.retiisi.org.uk> <20200408122127.i27hrmjh3pbjeulk@gilmour.lan> <20200408134315.a7cemmto6bi26arg@gilmour.lan> <20200408152857.GO6127@valkosipuli.retiisi.org.uk> <20200408153051.GP6127@valkosipuli.retiisi.org.uk> <20200415101827.owf5babnigev2vit@gilmour.lan> In-Reply-To: <20200415101827.owf5babnigev2vit@gilmour.lan> From: Robert Foss Date: Wed, 15 Apr 2020 13:10:13 +0200 Message-ID: Subject: Re: [PATCH v6 1/3] media: dt-bindings: ov8856: Document YAML bindings To: Maxime Ripard Cc: Sakari Ailus , Tomasz Figa , Dongchun Zhu , Fabio Estevam , Andy Shevchenko , linux-media , "open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS" , linux-kernel , "moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE" , Laurent Pinchart Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 15 Apr 2020 at 12:18, Maxime Ripard wrote: > > On Wed, Apr 08, 2020 at 06:30:51PM +0300, Sakari Ailus wrote: > > Cc'ing Laurent as well. > > > > On Wed, Apr 08, 2020 at 06:28:57PM +0300, Sakari Ailus wrote: > > > Hi Maxime, > > > > > > On Wed, Apr 08, 2020 at 03:43:15PM +0200, Maxime Ripard wrote: > > > > On Wed, Apr 08, 2020 at 02:35:28PM +0200, Tomasz Figa wrote: > > > > > On Wed, Apr 8, 2020 at 2:21 PM Maxime Ripard wrote: > > > > > > On Tue, Apr 07, 2020 at 08:20:35PM +0300, Sakari Ailus wrote: > > > > > > > On Tue, Apr 07, 2020 at 06:46:06PM +0200, Tomasz Figa wrote: > > > > > > > > On Tue, Apr 7, 2020 at 6:40 PM Sakari Ailus wrote: > > > > > > > > > > > > > > > > > > On Tue, Apr 07, 2020 at 05:47:41PM +0200, Robert Foss wrote: > > > > > > > > > > On Tue, 7 Apr 2020 at 14:32, Maxime Ripard wrote: > > > > > > > > > > > > > > > > > > > > > > Hi Robert, > > > > > > > > > > > > > > > > > > > > > > On Tue, Apr 07, 2020 at 01:29:05PM +0200, Robert Foss wrote: > > > > > > > > > > > > On Tue, 7 Apr 2020 at 10:36, Maxime Ripard wrote: > > > > > > > > > > > > > On Mon, Apr 06, 2020 at 11:35:07AM +0300, Sakari Ailus wrote: > > > > > > > > > > > > > > > But that 19.2MHz is not a limitation of the device itself, it's a > > > > > > > > > > > > > > > limitation of our implementation, so we can instead implement > > > > > > > > > > > > > > > something equivalent in Linux using a clk_set_rate to 19.2MHz (to make > > > > > > > > > > > > > > > sure that our parent clock is configured at the right rate) and the > > > > > > > > > > > > > > > clk_get_rate and compare that to 19.2MHz (to make sure that it's not > > > > > > > > > > > > > > > been rounded too far apart from the frequency we expect). > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > This is doing exactly the same thing, except that we don't encode our > > > > > > > > > > > > > > > implementation limitations in the DT, but in the driver instead. > > > > > > > > > > > > > > > > > > > > > > > > > > > > What I really wanted to say that a driver that doesn't get the clock > > > > > > > > > > > > > > frequency from DT but still sets that frequency is broken. > > > > > > > > > > > > > > > > > > > > > > > > > > > > This frequency is highly system specific, and in many cases only a certain > > > > > > > > > > > > > > frequency is usable, for a few reasons: On many SoCs, not all common > > > > > > > > > > > > > > frequencies can be used (e.g. 9,6 MHz, 19,2 MHz and 24 MHz; while others > > > > > > > > > > > > > > are being used as well), and then that frequency affects the usable CSI-2 > > > > > > > > > > > > > > bus frequencies directly --- and of those, only safe, known-good ones > > > > > > > > > > > > > > should be used. IOW, getting the external clock frequency wrong typically > > > > > > > > > > > > > > has an effect that that none of the known-good CSI-2 bus clock frequencies > > > > > > > > > > > > > > are available. > > > > > > > > > > > > > > > > > > > > > > > > > > So clock-frequency is not about the "Frequency of the xvclk clock in > > > > > > > > > > > > > Hertz", but the frequency at which that clock must run on this > > > > > > > > > > > > > particular SoC / board to be functional? > > > > > > > > > > > > > > > > > > > > > > > > > > If so, then yeah, we should definitely keep it, but the documentation > > > > > > > > > > > > > of the binding should be made clearer as well. > > > > > > > > > > > > > > > > > > > > > > > > Alright so, let me summarise the desired approach then. > > > > > > > > > > > > > > > > > > > > > > There's a separate discussion on the same topic here: > > > > > > > > > > > https://lore.kernel.org/linux-media/20200407122106.GD4751@pendragon.ideasonboard.com/ > > > > > > > > > > > > > > > > > > > > Thanks for the link. > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > ACPI: > > > > > > > > > > > > - Fetch the "clock-frequency" property > > > > > > > > > > > > - Verify it to be 19.2Mhz > > > > > > > > > > > > > > > > > > > > > > > > DT: > > > > > > > > > > > > - Fetch the "clock-frequency" property > > > > > > > > > > > > - Verify it to be 19.2Mhz > > > > > > > > > > > > - Get xvclk clock > > > > > > > > > > > > - Get xvclk clock rate > > > > > > > > > > > > - Verify xvclk clock rate to be 19.2Mhz > > > > > > > > > > > > > > > > > > > > > > The current status is that you should > > > > > > > > > > > 's/clock-frequency/link-frequencies/', and in order to replace > > > > > > > > > > > assigned-clock-rates, you'll want to have a clk_set_rate to 19.2MHz > > > > > > > > > > > between steps 3 and 4 > > > > > > > > > > > > > > > > > > > > Would we want to 's/clock-frequency/link-frequencies/' for ACPI too? > > > > > > > > > > I imagine that would cause some breakage. > > > > > > > > > > > > > > > > > > It would, yes, and it would be no more correct on DT either. > > > > > > > > > > > > > > > > > > There are basically two possibilities here; either use the clock-frequency > > > > > > > > > property and set the frequency, or rely on assigned-clock-rates, and get > > > > > > > > > the frequency instead. > > > > > > > > > > > > > > > > > > The latter, while I understand it is generally preferred, comes with having > > > > > > > > > to figure out the register list set that closest matches the frequency > > > > > > > > > obtained. The former generally gets around this silently by the clock > > > > > > > > > driver setting the closest frequency it can support. > > > > > > > > > > > > > > > > Wouldn't the former actually cause problems, because the closest > > > > > > > > frequency the clock driver can support could be pretty far from the > > > > > > > > one requested? (E.g. 19.2 MHz vs 24 MHz) The driver needs to check the > > > > > > > > resulting frequency anyway. > > > > > > > > > > > > > > That's possible, yes; in this case there wouldn't be a guarantee the > > > > > > > frequency wouldn't be far off. > > > > > > > > > > > > assigned-clock-rates is really fragile... There's zero guarantee on > > > > > > how far the actual rate is going to be from the asked one, but more > > > > > > importantly you have zero guarantee on the time frame that rate is > > > > > > going to be enforced for. > > > > > > > > > > Is there such a guarantee if clk_set_rate() is called? > > > > > > > > with clk_set_rate itself, no, but... > > > > > > > > > > It's simply going to change the rate as a one-off thing, and if > > > > > > there's the next millisecond someone else is going to change its rate > > > > > > one way or another, it's going to do so and you won't have any > > > > > > notification. > > > > > > > > You can get notified, and you can use clk_set_rate_exclusive if you > > > > *really* want to enforce it. > > > > > > Is the conclusion then we should go back to relying on the clock-frequency > > > property? > > clock-frequency or link-frequencies. link-frequencies seems to be a > better fit here, but we don't really have the choice for older > bindings. Alright, so since this is a new binding, let's aim for link-frequencies then. I don't think I understand what they look like on the driver side. Do you know an example of what a link-frequencies based driver would look like? > > > > This has been discussed multiple times over the years, and I don't really > > > disagree with the above. The frequency is typically indeed hand-picked for > > > the hardware, and no other frequency should be used in any circumstances. > > > > > > No sensor driver I've seen has used clk_set_rate_exclusive() but I guess > > > they should. The absence of practical problems has been probably because of > > > two factors; firstly, these are typically clocks dedicated to the sensors > > > and secondly, good luck. > > My point was that at least with handling the clock rate within the > driver (as opposed to assigned-clock-rates) you have multiple options > in dealing with changing colck rates / parents (Modelling the sensor > clock as a clock itself, using clk_set_rate_exclusive, using a > notifier, etc).. Some are more intrusive to the rest of the system > than others (especially clk_set_rate_exclusive), so I'm not really > advocating for any here, but we should make sure we have them in the > first place. > > Maxime