From patchwork Mon Apr 10 17:44:23 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sumit Semwal X-Patchwork-Id: 97200 Delivered-To: patch@linaro.org Received: by 10.182.246.10 with SMTP id xs10csp1456374obc; Mon, 10 Apr 2017 10:45:34 -0700 (PDT) X-Received: by 10.99.60.77 with SMTP id i13mr58386577pgn.185.1491846334409; Mon, 10 Apr 2017 10:45:34 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n3si14186684pfk.174.2017.04.10.10.45.34; Mon, 10 Apr 2017 10:45:34 -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 S1752648AbdDJRpc (ORCPT + 5 others); Mon, 10 Apr 2017 13:45:32 -0400 Received: from mail-pg0-f46.google.com ([74.125.83.46]:36781 "EHLO mail-pg0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752473AbdDJRp3 (ORCPT ); Mon, 10 Apr 2017 13:45:29 -0400 Received: by mail-pg0-f46.google.com with SMTP id g2so107975356pge.3 for ; Mon, 10 Apr 2017 10:45:29 -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=7FD9eYeUC7RqCtVBVw4fTdZIa94y753MIJivS7QoN5w=; b=Dp9dhMXwiMEPSsqOpnS01Hiwa7AkuwlMUfqF7s10dJHwXWscYOi5gvq5KOq8De6bFF 8aHPkXYdxnkjpR/lNzpkwADFD2T9OfLyTiNT8CHZ3Mc2CjagziRsdS8G28VCRPxscL9O gGtlTeWNQZIV9QBWv7eE9BX7HSdCAbTLGOaNg= 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=7FD9eYeUC7RqCtVBVw4fTdZIa94y753MIJivS7QoN5w=; b=mSrF7MmnGZIR7n66ReOsR/Ildn4ao3B+KTjoe4qascqnlUia+LM4dgjBWamrG++cTd rjWDu73reM+FVq4Enebd8I6JJ+7YKz58eJoF7K6WuXfUn8yp+x382ZGD/BXDo1RZJmO0 VQFzTh370OW025c+rkJUomunlCeunZN2GUj0UG7KHZ5GWb53juehg1TouwJ64+/dV2Wm zxlOa+p9Hnjy+NbAxjfCf3crApF94OX3NkeD4BzndXJs8B6euoan6ggTFja4JnbF9U7J 86RAaQQ7eiyHyACYAd+lAcLol/wejskKsOfS5O031nJAEI/40AFmbYWhU8rK0vILkjIH 2hPw== X-Gm-Message-State: AFeK/H1VvM0/yrhcda+/hDkXIrrOweaw82hOPO311JW3EcjAKDeWUXkX0iVnSWdweTQ/bajp X-Received: by 10.84.209.167 with SMTP id y36mr31615124plh.78.1491846328858; Mon, 10 Apr 2017 10:45:28 -0700 (PDT) Received: from phantom.lan ([106.51.225.38]) by smtp.gmail.com with ESMTPSA id y6sm768833pfa.83.2017.04.10.10.45.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 10 Apr 2017 10:45:27 -0700 (PDT) From: Sumit Semwal To: stable@vger.kernel.org Cc: Vitaly Kuznetsov , "K . Y . Srinivasan" , Greg Kroah-Hartman , Sumit Semwal Subject: [PATCH for-4.4 07/16] Drivers: hv: get rid of redundant messagecount in create_gpadl_header() Date: Mon, 10 Apr 2017 23:14:23 +0530 Message-Id: <1491846272-14882-8-git-send-email-sumit.semwal@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1491846272-14882-1-git-send-email-sumit.semwal@linaro.org> References: <1491846272-14882-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 [sumits: cherry picked for 4.4.y] --- 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);