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=-12.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham 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 21D75C4363A for ; Mon, 26 Oct 2020 13:27:22 +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 C77C4207DE for ; Mon, 26 Oct 2020 13:27:21 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=codeweavers.com header.i=@codeweavers.com header.b="vlUwfTOq" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C77C4207DE Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=codeweavers.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 3C8EF6E133; Mon, 26 Oct 2020 13:27:21 +0000 (UTC) X-Greylist: delayed 942 seconds by postgrey-1.36 at gabe; Mon, 26 Oct 2020 13:27:20 UTC Received: from mail.codeweavers.com (mail.codeweavers.com [50.203.203.244]) by gabe.freedesktop.org (Postfix) with ESMTPS id 1E7D26E133 for ; Mon, 26 Oct 2020 13:27:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=codeweavers.com; s=6377696661; h=Content-Transfer-Encoding:MIME-Version: Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=kOGBy83gPfRHwJKiQK/8YJ1+92SKsGK1ZFtpod1fVoA=; b=vlUwfTOqJOEl0oKVSd2d6fcAk8 ZFuofD9eh4kAY3F4mO4AslIAtQVMeTtU9Pc66SLpilynqtL999dvup36EiykUl0KMcIYt5qoJdgiT bAC6T5Z4YG2rxq9gxKxsTDAqdtgqKiui1hrzk81S7cvEh6v0Lp0PF8GLA7SFqmyYkCyY=; Received: from [10.69.141.123] (helo=dell.localdomain) by mail.codeweavers.com with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kX2Hg-0004zW-10; Mon, 26 Oct 2020 08:11:37 -0500 From: Paul Gofman To: dri-devel@lists.freedesktop.org Subject: [PATCH libdrm] xf86drm.c: Use integer logarithm. Date: Mon, 26 Oct 2020 16:11:20 +0300 Message-Id: <20201026131120.1068959-1-pgofman@codeweavers.com> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 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: Paul Gofman Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" log() is affected by FP control word and can provide inaccurate result. Fixes Killer Instinct under Wine not being able to find AMD vulkan device. Signed-off-by: Paul Gofman --- With the rounding mode the application sets (unsigned int)log2(4) is 1. The log2_int() implemetation is copied from radeon/radeon_surface.c. xf86drm.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/xf86drm.c b/xf86drm.c index 50a6f092..dbb7c14b 100644 --- a/xf86drm.c +++ b/xf86drm.c @@ -124,6 +124,22 @@ static drmServerInfoPtr drm_server_info; static bool drmNodeIsDRM(int maj, int min); static char *drmGetMinorNameForFD(int fd, int type); +static unsigned log2_int(unsigned x) +{ + unsigned l; + + if (x < 2) { + return 0; + } + for (l = 2; ; l++) { + if ((unsigned)(1 << l) > x) { + return l - 1; + } + } + return 0; +} + + drm_public void drmSetServerInfo(drmServerInfoPtr info) { drm_server_info = info; @@ -4001,7 +4017,7 @@ static void drmFoldDuplicatedDevices(drmDevicePtr local_devices[], int count) for (j = i + 1; j < count; j++) { if (drmDevicesEqual(local_devices[i], local_devices[j])) { local_devices[i]->available_nodes |= local_devices[j]->available_nodes; - node_type = log2(local_devices[j]->available_nodes); + node_type = log2_int(local_devices[j]->available_nodes); memcpy(local_devices[i]->nodes[node_type], local_devices[j]->nodes[node_type], drmGetMaxNodeName()); drmFreeDevice(&local_devices[j]); -- 2.26.2 _______________________________________________ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel