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=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_RED, 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 0311EC433DB for ; Mon, 28 Dec 2020 15:24:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D28BD22472 for ; Mon, 28 Dec 2020 15:24:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729548AbgL1PYS (ORCPT ); Mon, 28 Dec 2020 10:24:18 -0500 Received: from mail.kernel.org ([198.145.29.99]:33280 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2407613AbgL1N71 (ORCPT ); Mon, 28 Dec 2020 08:59:27 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 36290207B2; Mon, 28 Dec 2020 13:58:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1609163926; bh=W0L6kL1OSxKoJDIBmCbwWyQB3weWlp3Og+PBPNAjtCM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FfdS6km2KDVbUKqpFZJU3iu6hnu1cy4hWE874ogF/EJvdC9bZL37sA4vC0s6yOwyj 4r5aHUJRGO0Vyoe5Kvm0ptT1urQhOdGzBUVqHfo4ZYZz3HjvI65nMkU1v5QZHn+yNv ZEbTERv81+aUMhZQng/nNkMCDwtu7aAuycMdM7uY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Niranjana Vishwanathapura , Maarten Lankhorst , =?UTF-8?q?Thomas=20Hellstr=C3=B6m?= Subject: [PATCH 5.4 441/453] dma-buf/dma-resv: Respect num_fences when initializing the shared fence list. Date: Mon, 28 Dec 2020 13:51:17 +0100 Message-Id: <20201228124958.440896210@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201228124937.240114599@linuxfoundation.org> References: <20201228124937.240114599@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Maarten Lankhorst commit bf8975837dac156c33a4d15d46602700998cb6dd upstream. We hardcode the maximum number of shared fences to 4, instead of respecting num_fences. Use a minimum of 4, but more if num_fences is higher. This seems to have been an oversight when first implementing the api. Fixes: 04a5faa8cbe5 ("reservation: update api and add some helpers") Cc: # v3.17+ Reported-by: Niranjana Vishwanathapura Signed-off-by: Maarten Lankhorst Reviewed-by: Thomas Hellström Link: https://patchwork.freedesktop.org/patch/msgid/20201124115707.406917-1-maarten.lankhorst@linux.intel.com Signed-off-by: Greg Kroah-Hartman --- drivers/dma-buf/dma-resv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/dma-buf/dma-resv.c +++ b/drivers/dma-buf/dma-resv.c @@ -161,7 +161,7 @@ int dma_resv_reserve_shared(struct dma_r max = max(old->shared_count + num_fences, old->shared_max * 2); } else { - max = 4; + max = max(4ul, roundup_pow_of_two(num_fences)); } new = dma_resv_list_alloc(max);