Received: by 2002:a05:6a10:6006:0:0:0:0 with SMTP id w6csp1615453pxa; Fri, 28 Aug 2020 19:12:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxe05kHi6wlAHaTa6gUGAIUJYPo5F9MAf4ixF4k7FOyc5DotH5IBzNdaUGgS9U4YTA1Ftji X-Received: by 2002:a17:906:bb06:: with SMTP id jz6mr1682385ejb.248.1598667142491; Fri, 28 Aug 2020 19:12:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598667142; cv=none; d=google.com; s=arc-20160816; b=ahbPmL1y2ycguCV0f/KAOhOTLJOjkISCws/mEaw3Ao5mByNppYJJkW8QblaRigHyRz MeCF0Fxc8P/9OuboYufk7gzayAyy3zY1K2K/bGD8T5rM5LZsjsbRmr39cqXcFbnhzHNB 0zwBHy3r0k0NXN0Rb5tNaIjHkzzevrqqT2P3uE5iYd/FZBbOMybytPNyA1sKm62b2u9k xQKmEMbO3SRkLXTLJzoDW56fyoxPkKYeq7Ra+vy+BfTb7/PnxgSxMEelWxr/UL9Pb76l iDZ+LojGtqa1xaoGmp5dzQZ3YUjzIWsLn9uMMJ4sPGZUjD3TkzO2AVA5LUbKhqRWUbpe HHLg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=QssOrOfSXFZohHWBF3tmAc5aWHNi6zP1saZgfiiU9ho=; b=vJw5EQnrozK281gXCQCsH70wCxaVkC6dgCpvivocmDCUAk+R/rxOd7V7AaHsplALVG 0JWg8iroJgpcN2yuqg83hQIHU6/v14sDxo9bzzwoG4p1ufwY/uf0l8ml3qh6h5CJVYSw v8p/RtafC44ouXbWXbUpTo29s6igBXi6rVTZxLmlW4Cq6CBIJiw4cRKX3RYnzkX/xODn Om2tG+L6eezjqS0JQTyd+zFTUVX9DKrUJ9ttKFzUZc6qZxBcUokJoKT8SISehmW2FmhB Poy8j5q1Kkvy/mPIa7jbbNtA7LNDAOjPRRWWKPsQfv9difmHrMje4neKWz961VLmqwag Z5/g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p26si634644edt.197.2020.08.28.19.11.57; Fri, 28 Aug 2020 19:12:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726460AbgH2CIS (ORCPT + 99 others); Fri, 28 Aug 2020 22:08:18 -0400 Received: from mail-m17613.qiye.163.com ([59.111.176.13]:32043 "EHLO mail-m17613.qiye.163.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726392AbgH2CIR (ORCPT ); Fri, 28 Aug 2020 22:08:17 -0400 Received: from ubuntu.localdomain (unknown [157.0.31.125]) by mail-m17613.qiye.163.com (Hmail) with ESMTPA id 4B918481954; Sat, 29 Aug 2020 10:08:14 +0800 (CST) From: Bernard Zhao To: Philipp Zabel , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Cc: opensource.kernel@vivo.com, Bernard Zhao Subject: [PATCH] gpu/ipu-v3:reduce protected code area in ipu idmac get/put Date: Fri, 28 Aug 2020 19:08:07 -0700 Message-Id: <20200829020807.6568-1-bernard@vivo.com> X-Mailer: git-send-email 2.28.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-HM-Spam-Status: e1kfGhgUHx5ZQUpXWQgYFAkeWUFZS1VLWVdZKFlBSE83V1ktWUFJV1kPCR oVCBIfWUFZTBkfQx1OSx9CTEhOVkpOQkNNTU1DQk9PSE1VEwETFhoSFyQUDg9ZV1kWGg8SFR0UWU FZT0tIVUpKS0hKTFVKS0tZBg++ X-HM-Sender-Digest: e1kMHhlZQR0aFwgeV1kSHx4VD1lBWUc6MzY6Fio5Gj8qEipDGQkXEixJ GglPFBdVSlVKTkJDTU1NQ0JPQ0hDVTMWGhIXVRkeCRUaCR87DRINFFUYFBZFWVdZEgtZQVlKTkxV S1VISlVKSU5ZV1kIAVlBSU5CSzcG X-HM-Tid: 0a7437f8ec2f93bakuws4b918481954 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This change will speed-up a bit these ipu_idmac_get & ipu_idmac_put processing and there is no need to protect kzalloc & kfree. Signed-off-by: Bernard Zhao --- drivers/gpu/ipu-v3/ipu-common.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/drivers/gpu/ipu-v3/ipu-common.c b/drivers/gpu/ipu-v3/ipu-common.c index b3dae9ec1a38..8b3a57864c2e 100644 --- a/drivers/gpu/ipu-v3/ipu-common.c +++ b/drivers/gpu/ipu-v3/ipu-common.c @@ -267,29 +267,30 @@ EXPORT_SYMBOL_GPL(ipu_rot_mode_to_degrees); struct ipuv3_channel *ipu_idmac_get(struct ipu_soc *ipu, unsigned num) { struct ipuv3_channel *channel; + struct ipuv3_channel *entry; dev_dbg(ipu->dev, "%s %d\n", __func__, num); if (num > 63) return ERR_PTR(-ENODEV); + channel = kzalloc(sizeof(*channel), GFP_KERNEL); + if (!channel) + return ERR_PTR(-ENOMEM); + + channel->num = num; + channel->ipu = ipu; + mutex_lock(&ipu->channel_lock); - list_for_each_entry(channel, &ipu->channels, list) { - if (channel->num == num) { + list_for_each_entry(entry, &ipu->channels, list) { + if (entry->num == num) { + kfree(channel); channel = ERR_PTR(-EBUSY); goto out; } } - channel = kzalloc(sizeof(*channel), GFP_KERNEL); - if (!channel) { - channel = ERR_PTR(-ENOMEM); - goto out; - } - - channel->num = num; - channel->ipu = ipu; list_add(&channel->list, &ipu->channels); out: @@ -308,9 +309,10 @@ void ipu_idmac_put(struct ipuv3_channel *channel) mutex_lock(&ipu->channel_lock); list_del(&channel->list); - kfree(channel); mutex_unlock(&ipu->channel_lock); + + kfree(channel); } EXPORT_SYMBOL_GPL(ipu_idmac_put); -- 2.28.0