From patchwork Wed Apr 12 17:43:41 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sumit Semwal X-Patchwork-Id: 97329 Delivered-To: patch@linaro.org Received: by 10.140.109.52 with SMTP id k49csp374340qgf; Wed, 12 Apr 2017 10:44:27 -0700 (PDT) X-Received: by 10.99.125.27 with SMTP id y27mr68971383pgc.79.1492019067408; Wed, 12 Apr 2017 10:44:27 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j29si17209540pfj.125.2017.04.12.10.44.27; Wed, 12 Apr 2017 10:44:27 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754042AbdDLRo0 (ORCPT + 6 others); Wed, 12 Apr 2017 13:44:26 -0400 Received: from mail-pg0-f45.google.com ([74.125.83.45]:35862 "EHLO mail-pg0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755318AbdDLRoV (ORCPT ); Wed, 12 Apr 2017 13:44:21 -0400 Received: by mail-pg0-f45.google.com with SMTP id g2so17970967pge.3 for ; Wed, 12 Apr 2017 10:44:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=LGgqYQfwZzthFOxg27vzhErvV+HFGso5CO2q5oFQM0o=; b=Y99pDq9D/AgSw73X8IhA2bi+pYT5SiL9ed0IK2xaM4gLbmWCuSgQGtFaH51YCHjl0n rsAyGIKg/Zq4evLe057OLQK1W4ot/KNAb64cdl074GW7VsRZLy8C4H6kRyhT2j007nI2 JtDsQ+x86o/7+KCOkooegNGA3/wM59e5Ti+vg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=LGgqYQfwZzthFOxg27vzhErvV+HFGso5CO2q5oFQM0o=; b=n59XWHn337r2nkX9nIeLG3rCDk/OuuXEziPweWt0td8QkeVOAOvcDHpAtCW6H6kzTm MD7FjtGFRB3wXLDfQ+PYOn55OO7Ljkavc/hmmvq4X/I//e1Y+/VtRyZWNVZi0c1ZbwQ8 4SCgWdTbeh0eRxIXSjwwXlyXiEc92YumpcBaUhJIZX69W8Y3s2RCT5VW/j+25MLGKa3F tGOHxszIKOfh1Ql9eoBGnlVPDLRPqfExyDQ0hjx1a/y1SE0DE6A3prLHnEGprTrHQjJp Dv4OZjg8PR7XKjouK9TfdJuzhSb/z88sQwEJrLiV/V0VciKAr6DHLDosKo6niWvmK6rp RWpA== X-Gm-Message-State: AN3rC/4jKc52aUZfVL3VXOgMlqYkJxFcJoJEc8ilaQVt489S+GqvSFzlKHztVqV63gJf8Joz X-Received: by 10.84.139.67 with SMTP id 61mr30057043plq.106.1492019061001; Wed, 12 Apr 2017 10:44:21 -0700 (PDT) Received: from phantom.lan ([106.51.225.38]) by smtp.gmail.com with ESMTPSA id r17sm37750019pfa.13.2017.04.12.10.44.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 12 Apr 2017 10:44:20 -0700 (PDT) From: Sumit Semwal To: stable@vger.kernel.org Cc: Vitaly Kuznetsov , "K . Y . Srinivasan" , Greg Kroah-Hartman , Sumit Semwal Subject: [v2 PATCH for-4.4 07/16] Drivers: hv: get rid of redundant messagecount in create_gpadl_header() Date: Wed, 12 Apr 2017 23:13:41 +0530 Message-Id: <1492019030-13567-8-git-send-email-sumit.semwal@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1492019030-13567-1-git-send-email-sumit.semwal@linaro.org> References: <1492019030-13567-1-git-send-email-sumit.semwal@linaro.org> Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Vitaly Kuznetsov [ Upstream commit 4d63763296ab7865a98bc29cc7d77145815ef89f ] We use messagecount only once in vmbus_establish_gpadl() to check if it is safe to iterate through the submsglist. We can just initialize the list header in all cases in create_gpadl_header() instead. Signed-off-by: Vitaly Kuznetsov Signed-off-by: K. Y. Srinivasan Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sumit Semwal --- drivers/hv/channel.c | 38 ++++++++++++++++---------------------- 1 file changed, 16 insertions(+), 22 deletions(-) -- 2.7.4 diff --git a/drivers/hv/channel.c b/drivers/hv/channel.c index 1ef37c7..fb1e3df 100644 --- a/drivers/hv/channel.c +++ b/drivers/hv/channel.c @@ -223,8 +223,7 @@ EXPORT_SYMBOL_GPL(vmbus_open); * create_gpadl_header - Creates a gpadl for the specified buffer */ static int create_gpadl_header(void *kbuffer, u32 size, - struct vmbus_channel_msginfo **msginfo, - u32 *messagecount) + struct vmbus_channel_msginfo **msginfo) { int i; int pagecount; @@ -268,7 +267,6 @@ static int create_gpadl_header(void *kbuffer, u32 size, gpadl_header->range[0].pfn_array[i] = slow_virt_to_phys( kbuffer + PAGE_SIZE * i) >> PAGE_SHIFT; *msginfo = msgheader; - *messagecount = 1; pfnsum = pfncount; pfnleft = pagecount - pfncount; @@ -308,7 +306,6 @@ static int create_gpadl_header(void *kbuffer, u32 size, } msgbody->msgsize = msgsize; - (*messagecount)++; gpadl_body = (struct vmbus_channel_gpadl_body *)msgbody->msg; @@ -337,6 +334,8 @@ static int create_gpadl_header(void *kbuffer, u32 size, msgheader = kzalloc(msgsize, GFP_KERNEL); if (msgheader == NULL) goto nomem; + + INIT_LIST_HEAD(&msgheader->submsglist); msgheader->msgsize = msgsize; gpadl_header = (struct vmbus_channel_gpadl_header *) @@ -351,7 +350,6 @@ static int create_gpadl_header(void *kbuffer, u32 size, kbuffer + PAGE_SIZE * i) >> PAGE_SHIFT; *msginfo = msgheader; - *messagecount = 1; } return 0; @@ -376,7 +374,6 @@ int vmbus_establish_gpadl(struct vmbus_channel *channel, void *kbuffer, struct vmbus_channel_gpadl_body *gpadl_body; struct vmbus_channel_msginfo *msginfo = NULL; struct vmbus_channel_msginfo *submsginfo; - u32 msgcount; struct list_head *curr; u32 next_gpadl_handle; unsigned long flags; @@ -385,7 +382,7 @@ int vmbus_establish_gpadl(struct vmbus_channel *channel, void *kbuffer, next_gpadl_handle = (atomic_inc_return(&vmbus_connection.next_gpadl_handle) - 1); - ret = create_gpadl_header(kbuffer, size, &msginfo, &msgcount); + ret = create_gpadl_header(kbuffer, size, &msginfo); if (ret) return ret; @@ -408,24 +405,21 @@ int vmbus_establish_gpadl(struct vmbus_channel *channel, void *kbuffer, if (ret != 0) goto cleanup; - if (msgcount > 1) { - list_for_each(curr, &msginfo->submsglist) { + list_for_each(curr, &msginfo->submsglist) { + submsginfo = (struct vmbus_channel_msginfo *)curr; + gpadl_body = + (struct vmbus_channel_gpadl_body *)submsginfo->msg; - submsginfo = (struct vmbus_channel_msginfo *)curr; - gpadl_body = - (struct vmbus_channel_gpadl_body *)submsginfo->msg; + gpadl_body->header.msgtype = + CHANNELMSG_GPADL_BODY; + gpadl_body->gpadl = next_gpadl_handle; - gpadl_body->header.msgtype = - CHANNELMSG_GPADL_BODY; - gpadl_body->gpadl = next_gpadl_handle; + ret = vmbus_post_msg(gpadl_body, + submsginfo->msgsize - + sizeof(*submsginfo)); + if (ret != 0) + goto cleanup; - ret = vmbus_post_msg(gpadl_body, - submsginfo->msgsize - - sizeof(*submsginfo)); - if (ret != 0) - goto cleanup; - - } } wait_for_completion(&msginfo->waitevent);