Received: by 10.213.65.68 with SMTP id h4csp1627303imn; Thu, 15 Mar 2018 05:22:23 -0700 (PDT) X-Google-Smtp-Source: AG47ELuKapuN0lkzU7gOJp9k0hBLONu87QjKhj3wrpaTIDM9z4LogJLGiXe4Z7Rejy39V77iB+GH X-Received: by 2002:a17:902:6ac2:: with SMTP id i2-v6mr7731066plt.368.1521116543139; Thu, 15 Mar 2018 05:22:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521116543; cv=none; d=google.com; s=arc-20160816; b=C6pn3lbyadZZnHIN/qDV+tDDSmPr57XR14V9BrjwWDi3vF4SzAhne207b02kPfVyOv Xcyk42jFE6TFym9vnWo0NCBt21URWU2LaKHjF8vpOUrMA4WwZXQYjoT+9302JkCJNYUa oV1VLQZeDEzmRq9h2EsxHSc+7UYll8gDVImwEvT02Wb33WzVfscwUVjplMTVeHNbtA22 gLW3Qp/p1YSePsuLMIrCkg4z++78KWecUl+tAfKRcKbxgti7oW4ZKkYJP1qwfbAC1rHQ cqVL5dmzL7g/YG7krbkQkXNEnVOQYJwswCRHUBSfjDGCpHkbIkl5ExnyOSIUwUp3YnRu gcGQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=9ltkSQxxgDf9lWT1vv7K2W4ttKG9R9W07VN9sjpWjo8=; b=MzDS7FeIKLHIyE1M0URY8wfjtPF+Gi2UQ76WPIyM58l1hpTnLCv8ROYSZZNOMIYnzf /PXd3l3It4GfByorKFN7v4c/3SdYbufEAJO0OivwE1ADUG+mL+SrLEhL7Chx49tvFnaD a8Wi07VSoTxJ4yWli2npe6ewvNCAjr6osKWH/9Ypay/yLSu/meCfkS8aPZs2EEd6D7Uq IbplkaVTFJBK9KOV2ZZdNSQmcZy48bnCW9WMJu9f18a6Zz66IQLPr1bh5jaP+mfY/3s7 k6zaHIlrvlPATpqF8B//rUrLktppLYNcJpFu1ARulvzrQJSj3Kh7tCZQU2TZ7G0Ox77+ DG2w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c13-v6si4045767plz.564.2018.03.15.05.22.06; Thu, 15 Mar 2018 05:22:23 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751680AbeCOMUE (ORCPT + 99 others); Thu, 15 Mar 2018 08:20:04 -0400 Received: from mga05.intel.com ([192.55.52.43]:11680 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750731AbeCOMUD (ORCPT ); Thu, 15 Mar 2018 08:20:03 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 15 Mar 2018 05:20:02 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.48,310,1517904000"; d="scan'208";a="24749073" Received: from build0101.sh.intel.com ([10.239.164.138]) by fmsmga008.fm.intel.com with ESMTP; 15 Mar 2018 05:20:02 -0700 From: Haiyue Wang To: minyard@acm.org, openipmi-developer@lists.sourceforge.net, linux-kernel@vger.kernel.org Cc: Haiyue Wang Subject: [PATCH ipmi/kcs_bmc v1] ipmi: kcs_bmc: optimize the data buffers allocation Date: Thu, 15 Mar 2018 20:20:52 +0800 Message-Id: <1521116452-4993-1-git-send-email-haiyue.wang@linux.intel.com> X-Mailer: git-send-email 2.7.4 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Allocate a continuous memory block for the three KCS data buffers with related index assignment. Signed-off-by: Haiyue Wang --- drivers/char/ipmi/kcs_bmc.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/char/ipmi/kcs_bmc.c b/drivers/char/ipmi/kcs_bmc.c index fbfc05e..dc19c0d 100644 --- a/drivers/char/ipmi/kcs_bmc.c +++ b/drivers/char/ipmi/kcs_bmc.c @@ -435,6 +435,7 @@ static const struct file_operations kcs_bmc_fops = { struct kcs_bmc *kcs_bmc_alloc(struct device *dev, int sizeof_priv, u32 channel) { struct kcs_bmc *kcs_bmc; + void *buf; kcs_bmc = devm_kzalloc(dev, sizeof(*kcs_bmc) + sizeof_priv, GFP_KERNEL); if (!kcs_bmc) @@ -448,11 +449,12 @@ struct kcs_bmc *kcs_bmc_alloc(struct device *dev, int sizeof_priv, u32 channel) mutex_init(&kcs_bmc->mutex); init_waitqueue_head(&kcs_bmc->queue); - kcs_bmc->data_in = devm_kmalloc(dev, KCS_MSG_BUFSIZ, GFP_KERNEL); - kcs_bmc->data_out = devm_kmalloc(dev, KCS_MSG_BUFSIZ, GFP_KERNEL); - kcs_bmc->kbuffer = devm_kmalloc(dev, KCS_MSG_BUFSIZ, GFP_KERNEL); - if (!kcs_bmc->data_in || !kcs_bmc->data_out || !kcs_bmc->kbuffer) + buf = devm_kmalloc_array(dev, 3, KCS_MSG_BUFSIZ, GFP_KERNEL); + if (!buf) return NULL; + kcs_bmc->data_in = buf; + kcs_bmc->data_out = buf + KCS_MSG_BUFSIZ; + kcs_bmc->kbuffer = buf + KCS_MSG_BUFSIZ * 2; kcs_bmc->miscdev.minor = MISC_DYNAMIC_MINOR; kcs_bmc->miscdev.name = dev_name(dev); -- 2.7.4