From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.0 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C60CFC433E2 for ; Sat, 11 Jul 2020 13:58:11 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 993032075F for ; Sat, 11 Jul 2020 13:58:11 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="O05jpGWI" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 993032075F Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D2B666E064; Sat, 11 Jul 2020 13:58:10 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by gabe.freedesktop.org (Postfix) with ESMTPS id 240F96E2D6 for ; Sat, 11 Jul 2020 13:58:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1594475889; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=GorC7H2mPyM9HiYSVOpaQ0GOSuzksYAJjMkiJ77nsns=; b=O05jpGWIohPxax5cHL+PTzOtrlmMzZXzoB93iGhOKnt/0yQzgIEByJra9rSYdPWte71Jle PCOv50R6Q+hKfrL5WMvROqqWzxpvsrwmgPpmyye+k/5h7fXCBKszqzhHCCPckbm5JB9lVg VgRddnM1opxdVrkbSoZLSCijWyQjDwg= Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-353-UsIEgRSxN2epq29vHbRxFA-1; Sat, 11 Jul 2020 09:58:05 -0400 X-MC-Unique: UsIEgRSxN2epq29vHbRxFA-1 Received: by mail-ed1-f71.google.com with SMTP id u25so11525345edq.1 for ; Sat, 11 Jul 2020 06:58:05 -0700 (PDT) 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=m6J6T6hNE9yvLEROStKfnmk4k6OpGMdc4beepe1jo0w=; b=QCNrOcn9xEHtRSRfSChMIvjpxRDG8HYNCj3y8IICNu1GyffNAz+4AalDEyZyvMYm5I kcjoYsKs9MpCpSwiNxXrp76WSFjwtjWSUpGwH3qXHOnOVDQcTKi4qVg2Eab4ncYcze2Y yHrtcvloc1KYb6WYkDZheEBFTdOusLXmH/EwnKDe0Ksm+TvvxU218M8qLeGrHh/t32yb /JYthKk4Rd26OPwsO8oQFDx5GQW6y+KsSakenT24ORHGjUBLCA7xa1qffn3pAfnlSQN1 kcRXSIAoD/8HzSK0p+SRFUJfrVaDyt3lv+Wiog25cOorrDRCA1k/gZ7AotygQoBOYNri H69g== X-Gm-Message-State: AOAM533zDlKBDij5kM7gzRtakSPaP6mdVTPudN769stHz4XIEa8k2L89 UHxnSVGqb0T9rXnfQancfsx9kW/yNumcemHMxc8XdT7K6UwHzVuRfkJ/QGUSkU/eXCG+G4VaVZs hXjfGph7BQlFtd90hLykixqExJlNw X-Received: by 2002:a17:906:1a59:: with SMTP id j25mr62206006ejf.398.1594475884052; Sat, 11 Jul 2020 06:58:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyV4+j4+MFepvD2IOQF0qSRfySKoiQJW2DpkPXYqNJOhV5/QUkfGAppFHknge4Oh4ffuHn1Aw== X-Received: by 2002:a17:906:1a59:: with SMTP id j25mr62205990ejf.398.1594475883843; Sat, 11 Jul 2020 06:58:03 -0700 (PDT) Received: from x1.localdomain (2001-1c00-0c0c-fe00-d2ea-f29d-118b-24dc.cable.dynamic.v6.ziggo.nl. [2001:1c00:c0c:fe00:d2ea:f29d:118b:24dc]) by smtp.gmail.com with ESMTPSA id g21sm6868328edr.45.2020.07.11.06.58.02 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 11 Jul 2020 06:58:03 -0700 (PDT) Subject: Re: [PATCH v4 06/16] pwm: lpss: Correct get_state result for base_unit == 0 To: =?UTF-8?Q?Uwe_Kleine-K=c3=b6nig?= References: <20200708211432.28612-1-hdegoede@redhat.com> <20200708211432.28612-7-hdegoede@redhat.com> <20200709145013.GA3703480@smile.fi.intel.com> <20200711061120.di53sk5utjerb72q@pengutronix.de> From: Hans de Goede Message-ID: Date: Sat, 11 Jul 2020 15:58:02 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.9.0 MIME-Version: 1.0 In-Reply-To: <20200711061120.di53sk5utjerb72q@pengutronix.de> Content-Language: en-US X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-pwm@vger.kernel.org, intel-gfx , "Rafael J . Wysocki" , linux-acpi@vger.kernel.org, Thierry Reding , dri-devel@lists.freedesktop.org, Rodrigo Vivi , Andy Shevchenko , Mika Westerberg , Len Brown Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="windows-1252"; Format="flowed" Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Hi, On 7/11/20 8:11 AM, Uwe Kleine-K=C3=B6nig wrote: > On Thu, Jul 09, 2020 at 05:47:59PM +0200, Hans de Goede wrote: >> Hi, >> >> On 7/9/20 4:50 PM, Andy Shevchenko wrote: >>> On Wed, Jul 08, 2020 at 11:14:22PM +0200, Hans de Goede wrote: >>>> The datasheet specifies that programming the base_unit part of the >>>> ctrl register to 0 results in a contineous low signal. >>>> >>>> Adjust the get_state method to reflect this by setting pwm_state.period >>>> to 1 and duty_cycle to 0. >>> >>> ... >>> >>>> + if (freq =3D=3D 0) { >>>> + /* In this case the PWM outputs a continous low signal */ >>> >>>> + state->period =3D 1; >>> >>> I guess this should be something like half of the range (so base unit c= alc >>> will give 128). Because with period =3D 1 (too small) it will give too = small >>> base unit (if apply) and as a result we get high frequency pulses. >> >> You are right, that if after this the user only changes the duty-cycle >> things will work very poorly, we will end up with a base_unit value of >> e.g 65535 and then have almost no duty-cycle resolution at all. > = > Is this a problem of the consumer that we don't need to solve? Are there > known consumers running into this problem? AFAICT we never ever actually see freq =3D=3D 0 here, this is just a code-p= ath to avoid a divide by 0 in case we somehow mysteriously do get freq =3D=3D 0 here. On boot the PWM controller is either not used and then the default freq =3D input-clock / 256, or it is used and programmed to same sane value. > pwm_lpss_prepare() is buggy here, a request for a too low period should be > refused. So instead of clamping as is done in an earlier patch, we should return -EINVAL ? Only for too low periods, or also for too high periods ? I must say this does worry me a bit, the VBT may request 200Hz output frequency and some revisions of the PWM controller can do 283Hz as lowest output freq. ATM we just give the i915 code the 283 Hz if it request 200, that seems more sane then to give it -EINVAL, since -EINVAL would require the i915 driver to know the exact limits of each PWM controller and then to clamp the VBT value before passing it to the PWM driver, that means moving knowledge out of the PWM driver into the i915 code. I believe that without first amending the PWM API too allow a consumer to query the period min/max values, returning -EINVAL is not the right thing to do here. Regards, Hans _______________________________________________ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel