Received: by 2002:a89:2d5:0:b0:1ef:f8eb:5d24 with SMTP id d21csp68516lqs; Sun, 17 Mar 2024 10:52:20 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXVa9fx4/iXsNLh23T90eibFe6WwTxc2T+b9N1iX7VLbe27QE+A9JBXlb1G5WEHQsVV3wshwQ9ayRRLuSUku1zoWUlLxesji6jzcNYQOg== X-Google-Smtp-Source: AGHT+IEyGMQAh+LM6inflpm9y20zH43NEW3NaPlli2OSKKUmlReAMVfqViuTBJhdlmQfHViuDPsY X-Received: by 2002:a05:6808:6509:b0:3c2:39b0:e534 with SMTP id fm9-20020a056808650900b003c239b0e534mr13286468oib.1.1710697940387; Sun, 17 Mar 2024 10:52:20 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710697940; cv=pass; d=google.com; s=arc-20160816; b=u1jy7TdS76KyDCBnN6oNuCMdPjcZ9I83UXnexsUUNMXIyFS6m6dqB/6CsRXUrWAT59 whfXzt/iB2Rmqv7jXIzaHAQuP/KsSV1VLbxdWPLiasWyJAUDZtE4WXawzVZtUHdhn/M1 BSms0vldiuS54uZLZjQHo0mw7Rw5OWIGWPyXJVbgvau24JTJPlGDkEu3WORb0CCypXHP ckeQeSMuEYqxOW1G+WgtcQpSsBycSymxTamsc7+Au9SZg6Bc34Rq9ymr5G8j1m1Pjqng 4Ry1gUve0stPy3yZQ1r2P90aDnxG/0GB7VpCtpA0l62fWrMI83D6ZApeYJXGkdyHdaD7 VP2A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=E7j8mQvMMQfMZFz1qf2xhA4dyWrWUCrZPdqVXHb31Ig=; fh=YRoZq/JxQFNrioGvdV/VrZQiCObAa/SyXhXj85xQbYM=; b=rhSu10Uu1bJbVHpK849Vvl6HHGmZJy5zpZBCHY9MnHqWQsJHrd7gtuvCH65LzuC9Zr 7NQXGF4sH0QAzpHihKxWSYZND6otIGCWDp0xoKQAtbWM6fawjB/Y+uMcNgTcs4+3ThR5 1UkFhQew7SmN4jYKAFF7lA5Xl5ZL3UEZXyE8t0r2Jkmr1tkSE1zmhHvONqgy7I6KmfDJ 7v7TrxnnbIY06dHwAu1reMTME6zM1qAK7+XzgZh9ki6XzfmRZJD6yxVJ1kwpUe2MRk/3 xV4PrJNsNi98v/ugb4myxUvlWHHv0HLKkC1J6JpCFT8o8cJH+Yvh1IX586J96dPfwsAI 99mQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=fail header.i=@igalia.com header.s=20170329 header.b=jN7nloTI; arc=pass (i=1 spf=pass spfdomain=igalia.com dkim=pass dkdomain=igalia.com); spf=pass (google.com: domain of linux-kernel+bounces-105487-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-105487-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id z7-20020ae9f447000000b00789db8e7058si6839089qkl.54.2024.03.17.10.52.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Mar 2024 10:52:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-105487-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=fail header.i=@igalia.com header.s=20170329 header.b=jN7nloTI; arc=pass (i=1 spf=pass spfdomain=igalia.com dkim=pass dkdomain=igalia.com); spf=pass (google.com: domain of linux-kernel+bounces-105487-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-105487-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 2027A1C20BD8 for ; Sun, 17 Mar 2024 17:52:20 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4B2661CF9A; Sun, 17 Mar 2024 17:52:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=igalia.com header.i=@igalia.com header.b="jN7nloTI" Received: from fanzine2.igalia.com (fanzine2.igalia.com [213.97.179.56]) (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 CA1971CF80 for ; Sun, 17 Mar 2024 17:52:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=213.97.179.56 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710697933; cv=none; b=cvd2Ic9UaySGkvXSgEteRKG8hzuy0yPmcHHmGuxwh4toNGcCpDTdH18hibRFxZjS/JGojFSiGik7G/QDBLBQcgPv6da3oSAfLpZbczBdSwG6Vh9pJs8x5vAosL5M7YA++SluOJ0me6nKeHGDDm2A6ZKlrGDpvMbeXHuruy/Em9Q= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710697933; c=relaxed/simple; bh=v5b5MqaWU+N+lEYv9lQSgXWsCv5YZJEI5sWSdpWP8HQ=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=NltUaxhGuqjf+BKNlFMJXaeH1sLtmbf2uX/UPC0mw/qK5s9TyWIr8KaNjYJDm9KYyubVS2TTrnsXe5MWW2eEK6yWr6QSBD6maULbi/O/emYKmPTR37gUKXVvHdej9glCgBdbgUkdN4RdlJGB4CjE74pcHzARV/fwN34CFYHFS6c= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=igalia.com; spf=pass smtp.mailfrom=igalia.com; dkim=pass (2048-bit key) header.d=igalia.com header.i=@igalia.com header.b=jN7nloTI; arc=none smtp.client-ip=213.97.179.56 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=igalia.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=igalia.com DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=In-Reply-To:Content-Type:MIME-Version:References:Message-ID: Subject:Cc:To:From:Date:Sender:Reply-To:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=E7j8mQvMMQfMZFz1qf2xhA4dyWrWUCrZPdqVXHb31Ig=; b=jN7nloTIP2HuE1/7CqeC+f9LWf c0lXNW3Gua/H+0C10CroABooPqwmASMaLhOuK8WfW+z6hzXAb3AlqN90n2wJYopjSI4AMu9BuFlTj aQmeZ8FDuX5xKMx23dpYVSwWLfnMxWfrnTxE0lC+C5mySv6rWIonLEKRnNq8RYo10ofpC+j4Jb/Mz jM/YBj/eWx5iL3otaOyAigyt+MEIaF9grGy+kXCAMB8/ASkSKUSiqMV2Au4Y6GkW0pF31lmmM0Mnl 6AhSVoGz5cl+MTYCZmK+JntycuwhzRpG7ZB6Qrc6tUN4LFsn5hqZbkH0NiZJAJfj4mt4asV68Ja00 V9Ufkoeg==; Received: from [189.6.17.125] (helo=mail.igalia.com) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_SECP256R1__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1rlufY-00Bgjy-8g; Sun, 17 Mar 2024 18:51:36 +0100 Date: Sun, 17 Mar 2024 14:50:42 -0300 From: Melissa Wen To: Arthur Grillo Cc: Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , =?utf-8?B?TWHDrXJh?= Canal , Pekka Paalanen , Harry Wentland , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] drm: Fix drm_fixp2int_round() making it add 0.5 Message-ID: <7636b3tjifajvw63ux7xfjz4hjzhgjrf37mqgulneqzb7eukph@i6nnyietvxji> References: <20240316-drm_fixed-v2-1-c1bc2665b5ed@riseup.net> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240316-drm_fixed-v2-1-c1bc2665b5ed@riseup.net> On 03/16, Arthur Grillo wrote: > As well noted by Pekka[1], the rounding of drm_fixp2int_round is wrong. > To round a number, you need to add 0.5 to the number and floor that, > drm_fixp2int_round() is adding 0.0000076. Make it add 0.5. > > [1]: https://lore.kernel.org/all/20240301135327.22efe0dd.pekka.paalanen@collabora.com/ > > Fixes: 8b25320887d7 ("drm: Add fixed-point helper to get rounded integer values") > Suggested-by: Pekka Paalanen > Reviewed-by: Harry Wentland > Signed-off-by: Arthur Grillo Great, thanks! Reviewed-by: Melissa Wen I'll apply to drm-misc-next. Melissa > --- > Changes in v2: > - Add Fixes tag (Melissa Wen) > - Remove DRM_FIXED_POINT_HALF (Melissa Wen) > - Link to v1: https://lore.kernel.org/all/20240306-louis-vkms-conv-v1-1-5bfe7d129fdd@riseup.net/ > --- > include/drm/drm_fixed.h | 3 +-- > 1 file changed, 1 insertion(+), 2 deletions(-) > > diff --git a/include/drm/drm_fixed.h b/include/drm/drm_fixed.h > index 0c9f917a4d4b..81572d32db0c 100644 > --- a/include/drm/drm_fixed.h > +++ b/include/drm/drm_fixed.h > @@ -71,7 +71,6 @@ static inline u32 dfixed_div(fixed20_12 A, fixed20_12 B) > } > > #define DRM_FIXED_POINT 32 > -#define DRM_FIXED_POINT_HALF 16 > #define DRM_FIXED_ONE (1ULL << DRM_FIXED_POINT) > #define DRM_FIXED_DECIMAL_MASK (DRM_FIXED_ONE - 1) > #define DRM_FIXED_DIGITS_MASK (~DRM_FIXED_DECIMAL_MASK) > @@ -90,7 +89,7 @@ static inline int drm_fixp2int(s64 a) > > static inline int drm_fixp2int_round(s64 a) > { > - return drm_fixp2int(a + (1 << (DRM_FIXED_POINT_HALF - 1))); > + return drm_fixp2int(a + DRM_FIXED_ONE / 2); > } > > static inline int drm_fixp2int_ceil(s64 a) > > --- > base-commit: f89632a9e5fa6c4787c14458cd42a9ef42025434 > change-id: 20240315-drm_fixed-c680ba078ecb > > Best regards, > -- > Arthur Grillo >