From patchwork Mon Dec 28 12:51:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 353544 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 F16AFC43331 for ; Mon, 28 Dec 2020 14:38:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D653520728 for ; Mon, 28 Dec 2020 14:38:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2505653AbgL1Oij (ORCPT ); Mon, 28 Dec 2020 09:38:39 -0500 Received: from mail.kernel.org ([198.145.29.99]:39410 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2392098AbgL1Obt (ORCPT ); Mon, 28 Dec 2020 09:31:49 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 3D19320739; Mon, 28 Dec 2020 14:31:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1609165893; bh=DKMCf1vF635AK2N9p/BqQ9Rel0Li6bF80vN4i84En7w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZAruYKr4NacivC+N+lXA4QJy0Q0BQ4TlKObTju9/M0Adr/lHP0/zN8gz85oPgn2iV m23vxE/VV89AiU72LNCawQO1wzGmRHQJs1O8gKFm3NZIlQOc/cR669sMk/w2C4tt9O AAzAmkcAG2nYesvHmqfnSn71pKj8k0yJrucKLloI= 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_Hellstr=C3=B6m?= Subject: [PATCH 5.10 693/717] dma-buf/dma-resv: Respect num_fences when initializing the shared fence list. Date: Mon, 28 Dec 2020 13:51:31 +0100 Message-Id: <20201228125054.183148246@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201228125020.963311703@linuxfoundation.org> References: <20201228125020.963311703@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 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 @@ -200,7 +200,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);