Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp3057114pxu; Tue, 8 Dec 2020 02:16:37 -0800 (PST) X-Google-Smtp-Source: ABdhPJwXNCnEXfVOE47hwsvkaIuvGgvB1wu+YCOIfVl6zTIeM2VfYU/fdwoIb1NM/hLYwMAasMac X-Received: by 2002:a17:907:444f:: with SMTP id on23mr23012035ejb.300.1607422597578; Tue, 08 Dec 2020 02:16:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607422597; cv=none; d=google.com; s=arc-20160816; b=bdVuBLKnvTHZY1wd8X3lrMQlum+VGYtXqEc6b9fEbBzjpEOjrRPuYIiMqK5/keLxcX cPYf2A/oWJanmxmGkml/zjPVPZzyxYzzBst3YiFJcHZsNiOSaepB0+jtoQseBu/+7rIZ sDUs9HO9YoEVnLP1d5/pIyaVRxhQDvK2brddqW0QtvGybQunVmj4P2htVxnOcKdDc71X WMFWZyxg/sSmZCCT1dbpRjuE1fWhQFvvOCVuhC7itHLnsybQCaW+xzSGj5TGqKvLTHh+ 8uLG4w7ZIAvmDzM3IN7IflddO0XxEiXdzKHsgQJ5vDoUlonrUhttw2PF0etfRrJH43fW bfsA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=9sTNjQjtWbr4N0B4GN2Kw1dncJZBpW6+Za2GoBgyLO0=; b=JlO9N+4fMA+vTRkzN3eMunf1YXn/KKDtj7NeekmpyAQXTtbkBs5ua1DiHiNffs5wZm QZ5A9/HWyHI1nUPHt/40poVUrqHTAQIHhcA5R3l6/hvX5+9Pk8/YjCZIETUKnKnLBm19 VC2WFOdERBlzwYG2sFNRL2/pc2TSuQZq9d9TH7AAuXcy8CyDxdZGGEaAKZ7Wvs0yF5kl RFfvlJwZbPxsU5/mBQ5T3PY6N9c0RhRJymbKGlzPbNqK9oKwNjNr47eoVrEhvQ7w5hBO svFzhLzRrTOs3hZHe8Y6gLbjSyO9csWyOpX8354Ckxsk2WAAlJ9MkrcghyT1GzbBi7Mm 0KtA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@pqgruber.com header.s=mail header.b=dZBEcD4E; 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=QUARANTINE sp=NONE dis=NONE) header.from=pqgruber.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v28si980033edx.392.2020.12.08.02.16.14; Tue, 08 Dec 2020 02:16:37 -0800 (PST) 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=@pqgruber.com header.s=mail header.b=dZBEcD4E; 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=QUARANTINE sp=NONE dis=NONE) header.from=pqgruber.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729085AbgLHKND (ORCPT + 99 others); Tue, 8 Dec 2020 05:13:03 -0500 Received: from mail.pqgruber.com ([52.59.78.55]:42064 "EHLO mail.pqgruber.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728623AbgLHKNC (ORCPT ); Tue, 8 Dec 2020 05:13:02 -0500 Received: from workstation.tuxnet (213-47-165-233.cable.dynamic.surfer.at [213.47.165.233]) by mail.pqgruber.com (Postfix) with ESMTPSA id 10EDCC81EEA; Tue, 8 Dec 2020 11:12:20 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pqgruber.com; s=mail; t=1607422340; bh=9sTNjQjtWbr4N0B4GN2Kw1dncJZBpW6+Za2GoBgyLO0=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=dZBEcD4EV639kI/UJ0mgGuObYNkkXGo0Vh8H385stpao1hF8YQwmOb7XRJ5ON6uSU OKVhRY8A+80zui50EoLUObG5KGFo0iwHApWg9w21xiD1GiKr1wIKpjgc5kDT+wZgQs 7P/Zut6rhZPXeKOGhtNbKeRzJKjij00HuB1o8ZrE= Date: Tue, 8 Dec 2020 11:12:18 +0100 From: Clemens Gruber To: Uwe =?iso-8859-1?Q?Kleine-K=F6nig?= Cc: linux-pwm@vger.kernel.org, Thierry Reding , Lee Jones , linux-kernel@vger.kernel.org, Sven Van Asbroeck , Mika Westerberg , David Jander Subject: Re: [PATCH v4 1/4] pwm: pca9685: Switch to atomic API Message-ID: References: <20201207193629.493241-1-clemens.gruber@pqgruber.com> <20201207220025.42b6g76wq7ph5nvb@pengutronix.de> <20201208091033.bxzrlad7mjbe3dsp@pengutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20201208091033.bxzrlad7mjbe3dsp@pengutronix.de> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello Uwe, On Tue, Dec 08, 2020 at 10:10:33AM +0100, Uwe Kleine-K?nig wrote: > Hello Clemens, > > On Tue, Dec 08, 2020 at 12:13:44AM +0100, Clemens Gruber wrote: > > On Mon, Dec 07, 2020 at 11:00:25PM +0100, Uwe Kleine-K?nig wrote: > > > On Mon, Dec 07, 2020 at 08:36:27PM +0100, Clemens Gruber wrote: > > > > The hardware readout may return slightly different values than those > > > > that were set in apply due to the limited range of possible prescale and > > > > counter register values. If one channel is reconfigured with new duty > > > > cycle and period, the others will keep the same relative duty cycle to > > > > period ratio as they had before, even though the per-chip / global > > > > frequency changed. (The PCA9685 has only one prescaler!) > > > > > > This is not acceptable, if you have two PWM outputs and a consumer > > > modifies one of them the other must change. So if this chip only > > > supports a single period length of all channels, the first consumer > > > enabling a channel defines the period to be used. All later consumers > > > must live with that. (Also the first must be denied modifying the period > > > if a second consumer has enabled its PWM.) > > > > Good idea, but is it OK to potentially break users relying on the old > > behavior ("the last one who changes the period wins") ? > > If this is already in the old code, this probably warrants a separate > fix, and yes, I consider this a severe bug. (Consider one channel > driving a motor and reconfiguring an LED modifies the motor's speed.) Yes, but a user could also be relying on the old behavior as follows: 1. Requests & enables pwm 0 for a backlight, using a period of 5000000ns (does not care about the frequency as long as it does not flicker) 2. Requests & enables pwm 1 for a motor, using a period of 1000000ns (does care about the frequency) In the previous kernel versions, this would work, but with your suggested change, (2) would fail and the motor would no longer work. We are basically changing "the last one to set the period wins" to "the first one to set the period wins". If we do it like this, I'll split it out so we can at least revert it if someone complains that it breaks his application, without reverting the whole series. Thanks, Clemens