From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 088FFB67E for ; Fri, 31 Jul 2026 15:27:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.168.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785511645; cv=none; b=QbOkiBy8lD9dLsDVWjTjSNrMaVKFM5/Okin5FJELQsar8vvch5/1RlHB1XZoO70AOF24xc98PHGopMHNxgKJlspcRe0bP+H/ICnIMHkEroT5dFncGhdLEjBrCJP94WLjSEQPro1hZveE1Ji2XYu5xwByDnxt44v1RHnf2Qcu/bw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785511645; c=relaxed/simple; bh=7klZEho0H83j8ylpjNW4TH0V0nFQueKsAusCKPgOKBY=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=ew977f+WdJLCjFyCwtUV0JQnY68y8p91al8pJpehFevATnYVmkfDWL70qPqxZtKV/cwDtj4OtRV2IbpWB4E/ZXLPKUQytceDsPXoOF7BQAOu+HBUjyTkeVMgRCoOq7htGhHr+ALZsg6lQ3hCydX/F3Ygdhb6YyrcmM8tBFNIChU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com; spf=pass smtp.mailfrom=oss.qualcomm.com; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b=ot8syubV; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=RELFfAQu; arc=none smtp.client-ip=205.220.168.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b="ot8syubV"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="RELFfAQu" Received: from pps.filterd (m0279866.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 66VFNwpa019782 for ; Fri, 31 Jul 2026 15:27:23 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= 7uFsYuCwq0Qx2h2L72I1/1dKPl18cLwGQgBX9DoqR+E=; b=ot8syubVxIKhBaXY GbPyChFT7d9PiDexEP7CrEwOpsRi04eXQ0sXIz0aj+UnJtEDIRMWEafWe4EZENP9 fiwNniIZ+8HMU8SdoY2NEi4wIruZDsnkqBu+tOgNgQ5HClFzpZII4DHoN5rRyweP wPAhFj3UaBiAMiuTzjVN79DhDzL50NrehJvU0Czkr/q4drmt4rDAxdRI1wiiodeH JptdpRGBAaRcMEHsL5PUbyioKRf/4kjA9DoUCfwYftiYjlcHd2G3eowN47I7gtXO soJKm1+8HJWAGTb+N5Ly1C/dWOnYiJzZeosHZifZA+DyP54z6pG88hoV8qgrJSCd lhA56g== Received: from mail-qt1-f197.google.com (mail-qt1-f197.google.com [209.85.160.197]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4frugh0u21-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Fri, 31 Jul 2026 15:27:23 +0000 (GMT) Received: by mail-qt1-f197.google.com with SMTP id d75a77b69052e-51bfa45b280so1758061cf.3 for ; Fri, 31 Jul 2026 08:27:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1785511642; x=1786116442; darn=vger.kernel.org; h=content-transfer-encoding:content-type:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:from:to:cc:subject:date:message-id:reply-to :content-type; bh=7uFsYuCwq0Qx2h2L72I1/1dKPl18cLwGQgBX9DoqR+E=; b=RELFfAQuGwVTMoPjQW0CkpzoY3qZ5rAD64tfmeYLQ7YmAQquRNDOgV4H/mIVgHpL5J kK7EnFyrjfDrrWa7Xt6YnBxCKDJt2SHrUPhz3mXYA1ZEVNWPhjc7PTkZ92k8x8z6Eprn HComGYtsU7AfvEkbz7SJ5q/qQh+FB1i/gcNkd5J1RptyFc1zMAJ1B9RsbDDBE8F+St7p kJmcWRsW1iA+E8R6oL92NjteY/Jhmqyrotn/Tiba1W9RFET7IoMYq+HlzJbygr1ERF1E hEhsyiELJ5N+6lk0URri/JKVTif4v4svjL4y9uNcqorKlPbnvXfjHACFm1VfiT0gkzPn 4pNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785511642; x=1786116442; h=content-transfer-encoding:content-type:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=7uFsYuCwq0Qx2h2L72I1/1dKPl18cLwGQgBX9DoqR+E=; b=q+Wpvo8Sb74/RiIPcAMlU8fduPyPqMK9GscR4Q7xLUy0iskpRf9MEdOV7h8UgkgQgf F5WVTcAfioyK9z83gh6GnKvoRJe2z1ykaN8VsLyvFb1eBOfDJLnb3DtYLR1MW9kxs0Dg c3dGogBiPSSZFPTp///gPZhHpSMBP/hzneggXoeTy9DuG8tgmL+v8McAfJG7YfN7K7Bl YvModnVqeWZL+mtmtbN60yKcxdBuRtTsQIVCQllAU1yUZp5jZvpOFtx333KuBfSPsY8J g9Yg/MrH8xxf8rVHz83lB01MJhAQJ8FEygYPVsqoEcnAsHq+fibVDZJA09Hq7g8tDFyP fc5Q== X-Forwarded-Encrypted: i=1; AHgh+RpLXaPWc5nQKjYWuL2Rlbzcx0k8miMfo8DtyAwQ9HXdKdNpz5lUo5RRenI/43/YNhwxOjOncSB/vWGFIlo=@vger.kernel.org X-Gm-Message-State: AOJu0YyTMKpJ/SlGiSTXBK/vW/AY3PXHOLJyDhRmxDUmpkQls69C8MAw 2tVC41qewz0lB4bUqSAxTasEJqO7COt39i8JQbITNgXBqaxT0QJ8+7YLhiyphW7PbWLbN8R+ZIu QDCO0mL2O6nAHiDjka1WK5d8CxtylolEm2t2XeV2+hyD1dCurg39Us9SV8nPjQiPQFHc= X-Gm-Gg: AR+sD10DGdMJ28I9MbAbuBPpxkYqRpzNXu9o7SRg+sa9rLJxB3sA9rZpEcl2IKSI4S9 OvWi2ZsPI1uzUmg3385arftjpp4HSgAL/CQIPtap7Lw3v9ZlMWJxVZMsFuUiDOu019Qp0Kyu2dG MXDXylv5gexyIhS+/VEQ2+XoBMa2Ngv1oiwmZZWXpzDbt0fTbfPTiz1pm+BZQe1GhJKPiyYHXdO 4BsuW4XkYbcKiGZx8tdXpqljNyb9HnZwlC4f1mKqHaMVO9LMixHZiiMTzAu8G05UOstVKQRcHJV BNJeoRffshF9tCRKdhxAZB+lhr/cEA0k9IylhoT5XSunSwEZLxcX+5YoltMWVRcnPr1eHZtYz8f UU9gmeNZwhCiHavWu+VEsSsVU X-Received: by 2002:a05:622a:e198:10b0:51b:eab3:4ef1 with SMTP id d75a77b69052e-52b567b3aafmr5993591cf.4.1785511642001; Fri, 31 Jul 2026 08:27:22 -0700 (PDT) X-Received: by 2002:a05:622a:e198:10b0:51b:eab3:4ef1 with SMTP id d75a77b69052e-52b567b3aafmr5993261cf.4.1785511641664; Fri, 31 Jul 2026 08:27:21 -0700 (PDT) Received: from [192.168.120.193] ([178.235.128.140]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-6a09c655446sm1975608a12.21.2026.07.31.08.27.20 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 31 Jul 2026 08:27:20 -0700 (PDT) Message-ID: Date: Fri, 31 Jul 2026 17:27:19 +0200 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] pwm: ipq: fix period calculation To: Stephane Lepain , =?UTF-8?Q?Uwe_Kleine-K=C3=B6nig?= Cc: linux-pwm@vger.kernel.org, Kenneth Kasilag , George Moussalem , Devi Priya , Baruch Siach , linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org References: <20260731070542.155398-1-stephanelepain@gmail.com> Content-Language: en-US From: Konrad Dybcio In-Reply-To: <20260731070542.155398-1-stephanelepain@gmail.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNzMxMDExNyBTYWx0ZWRfXxK2GD/3DyMUf R0vcDL8u1auPJNfm7Dg7OjssQOnubUvCPAMh4K4s1qjB6hYja2UHNvBPlgVWTVzUmazCRjHg5L3 evCyaoabkcuoRJPq2FkbQJ15BJpktx+oSgRnxbKpUH7WchaLoMEQ2ricCBwjy+SOGwYIbtDTAZx BF7JhlAMSkyv0Br8HD9Vq7soVGm4umN+fjVPjQ2T/33Ioz3idJqfDCJRn/GDTom/EaIVLC1umZH XJGgc2KEZOKdshkh//JGR39RdT3GktmeZR7/oGG05yaZXtzZutJ7wWsz0TNYqLRf9g3RqTmdtL0 NXFabrcB8Qj289zGZn3XJYXAznWWiga+GDapE8xKyErvjNkD6DVP/91qdK2ASheV37aY3+cbx5+ tn87xy74IBFHo6t/QJCDi8ClKbN0nm03vDNnlXJjGMNXbjSSWtq1ZkVKmQxQYDN5adYHvz+O+9e 7trfhBY2BULaR+jaBig== X-Proofpoint-Spam-Info: AW1haW4tMjYwNzMxMDExNyBTYWx0ZWRfX5433EhcTqxu2 PXr1HQ6zctTG1liSAoJ8h/g8brM7LuiqmIMdK+SEvXJSWTEltXUmiT0AT1XMkEwrWezo3jwZpiv PwpZA/HtlfVIOH0qQkMkBEcf3FKDDuA= X-Authority-Analysis: v=2.4 cv=U+iiy+ru c=1 sm=1 tr=0 ts=6a6cbedb cx=c_pps a=EVbN6Ke/fEF3bsl7X48z0g==:117 a=PRfkaYvzSr8QmIIGAkY2Sg==:17 a=IkcTkHD0fZMA:10 a=RAioF0-LDSMA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=YMgV9FUhrdKAYTUUvYB2:22 a=nVPmijOAcTPNv26JQuwA:9 a=QEXdDO2ut3YA:10 a=a_PwQJl-kcHnX1M80qC6:22 X-Proofpoint-ORIG-GUID: XM8OLvWWNxp0zl3oAP3r0GmAh7Y6JPUu X-Proofpoint-GUID: XM8OLvWWNxp0zl3oAP3r0GmAh7Y6JPUu X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-07-31_05,2026-07-30_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 malwarescore=0 spamscore=0 lowpriorityscore=0 adultscore=0 impostorscore=0 suspectscore=0 bulkscore=0 clxscore=1015 priorityscore=1501 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2607310117 On 7/31/26 9:05 AM, Stephane Lepain wrote: > From: Kenneth Kasilag > > ipq_pwm_apply() fixes pwm_div at its maximum and derives only pre_div > from the requested period. Since the period spans > (pre_div + 1) * (pwm_div + 1) input clocks, pinning pwm_div near its > maximum forces pre_div towards zero for short periods: once pre_div > rounds to 0 the shortest representable period is (pwm_div + 1) / clk_rate, > and any shorter request is rejected outright: [...] > /* > - * Pick the maximal value for PWM_DIV that still allows a > - * 100% relative duty cycle. This allows a fine grained > - * selection of duty cycles. > + * The period spans (pre_div + 1) * (pwm_div + 1) input clocks. Rather > + * than fixing pwm_div at its maximum (which gives usable duty > + * resolution only for long periods and collapses to ~0% for short > + * periods) search for the (pre_div, pwm_div) split whose period best > + * approximates the request while leaving pwm_div large enough to > + * resolve the duty cycle. > */ I think the comment can just go > - pwm_div = IPQ_PWM_MAX_DIV - 1; > + if (ipq_chip->clk_rate > 16ULL * GIGA) > + return -EINVAL; That's a very fast clock.. [...] > - hi_div = hi_dur * (pre_div + 1); > + hi_div = (u64)hi_dur * (pre_div + 1); This looks like a separate fix Konrad