Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2614617pxb; Sun, 28 Feb 2021 07:12:45 -0800 (PST) X-Google-Smtp-Source: ABdhPJxRguuOTW/83w8yWFaPdu0OZDIxDsQJ6vkXty5MRQjVceQWcT8bHHWxV3ewdmIEi4TB3UD5 X-Received: by 2002:a17:906:543:: with SMTP id k3mr9622463eja.139.1614525165581; Sun, 28 Feb 2021 07:12:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614525165; cv=none; d=google.com; s=arc-20160816; b=Ki9oAu1OjZsJMfmE/qZZeTD+dvE3qeDX34KgpLSIK2MnpVa0HCHnupq/nO3C26PMD/ N29BbH7Y9sLqKzzM048l5aNUY1uJYQn5BWMwHYM2kA4t1TRSOcJQ1UAFYa+XpJAuxoX6 LE0cgAjwQugzTQ4ryJTs8eJY/FeAfuvoS7yZQMw9BPEwfbootnwCaNKDoMPKkfKTlukF O3pBXeUF8G/f0MzM+fyzIegVTEr52yO+E1BfEsv/OZ/b4FsStHXHcywJ2Zw495MqHcsX x9246USeCGKGG1XW7nYUim0jFFXslG3gvVaQZcTJUIeNzRwsHWmKt0o4nsdYSq4JPjQL iCzg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=yOO4CxJRTj0ILG6kUCTIHN05nkW/mARc3jk1rfoAu18=; b=QC4vRDq65fmczxRya/sUjN9+tLcUg7fSysAQnGMQGzNOgllszi1cRKhv3EO0O6YkfY JJyOr1++9TVffogqnEpAzuAkD5VNQeiuBGB/bkSzqwKI4UkFtKuauSTYAAIIOp5WlYEx 31TTgJhYKFTWnGJafE4W0/pDlyt7xPbEcGw32VBmh3NSQVmX2q3Pcwyri7hz67fDEGqI GvPj7jzk3s7DmX6KckBW25CHrT1ehMu7nEOZBAwfBR9eEhqMgf3WV+T/LE6yausWjZOD BoGlX9iQwMt5ZIo9HNU+I0QDkBEtHPvot4VWMX7rrZUafqztbc/YwnljWevDbXLmCWKg Q+kg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=K2lcx9nM; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d26si9257896edu.160.2021.02.28.07.12.23; Sun, 28 Feb 2021 07:12:45 -0800 (PST) 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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=K2lcx9nM; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231200AbhB1PKS (ORCPT + 99 others); Sun, 28 Feb 2021 10:10:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50218 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230496AbhB1PFj (ORCPT ); Sun, 28 Feb 2021 10:05:39 -0500 Received: from mail-pf1-x42c.google.com (mail-pf1-x42c.google.com [IPv6:2607:f8b0:4864:20::42c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D25B5C0617AA; Sun, 28 Feb 2021 07:04:21 -0800 (PST) Received: by mail-pf1-x42c.google.com with SMTP id o188so3025539pfg.2; Sun, 28 Feb 2021 07:04:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=yOO4CxJRTj0ILG6kUCTIHN05nkW/mARc3jk1rfoAu18=; b=K2lcx9nM7T2VHEIAbyzeDQJpMtgyBf3IYLAYs03/EGTZOuFiONpMdarScgMXi6TJF8 IM4/gElwbzjKBqoGmNjjMSNt01/C8TQzf8LghIzkBmpSDXsxqon4koI8TIET9GppicR4 y760uZvE4+8/N7iFxm75lwFs0XNXd3GE+/a3T8wylj+gJtdrDTiM0+TuJHTcbvvgpL23 sAI5q3FH508nLAWjUs+QlwPVIgAEeaB9pGKkYRupWzf+XILldMseMTs3GpPv4oTuIYaX rcmH1zhZiu0ijoaoOuAagOtXRCcWEZ8WuElHgya6YTFZLW/C3BEV/VMXptKmxmDh+Pw9 qENA== 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:mime-version:content-transfer-encoding; bh=yOO4CxJRTj0ILG6kUCTIHN05nkW/mARc3jk1rfoAu18=; b=tlFaFU5kqKNSklLN/oFBHiOZB/0SfelgiJEQ9lySOzyPAXxfXxu4ZddZQhRYN06OGV 0XTgZFiCIB2wDUVRL5m1NwL1Cdneud7cNxEuhvR36lpVp4KS+gu+DTmrV30k7T6aMBWZ DcPSlR3ucbra+LZ/j3AJLeanBqy/n2Du+LCtHt4q6mhMr0JN3yC2kx9brYuL0pj4MnMz FqKd89qGzvAHEPP9jZfytYpxBfczwlfr7mjVdo6oCN0ZM/RN1E69x61kile8fx1M6rna LE/ysRISXj9xQrPtS6kzlwvT0VzcDSatHKaSgZCa+/zVv5hcqR0qY3FGNnz3Y8FKH4J7 h0Mw== X-Gm-Message-State: AOAM533/mOjUXGkySSNUWVhjjM/t/qLIbAS6ER4VNTQP+MRTnLsVW1Gx 9s6MDCoQpX5BnrF4IrcQ+SEKkENfJcFA8g== X-Received: by 2002:a63:2254:: with SMTP id t20mr10040743pgm.230.1614524661481; Sun, 28 Feb 2021 07:04:21 -0800 (PST) Received: from ubuntu-Virtual-Machine.corp.microsoft.com ([2001:4898:80e8:0:561f:afde:af07:8820]) by smtp.gmail.com with ESMTPSA id 142sm8391331pfz.196.2021.02.28.07.04.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 28 Feb 2021 07:04:21 -0800 (PST) From: Tianyu Lan To: kys@microsoft.com, haiyangz@microsoft.com, sthemmin@microsoft.com, wei.liu@kernel.org, jejb@linux.ibm.com, martin.petersen@oracle.com Cc: Tianyu Lan , linux-hyperv@vger.kernel.org, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, vkuznets@redhat.com, thomas.lendacky@amd.com, brijesh.singh@amd.com, sunilmut@microsoft.com Subject: [RFC PATCH 12/12] HV/Storvsc: Add bounce buffer support for Storvsc Date: Sun, 28 Feb 2021 10:03:15 -0500 Message-Id: <20210228150315.2552437-13-ltykernel@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210228150315.2552437-1-ltykernel@gmail.com> References: <20210228150315.2552437-1-ltykernel@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Tianyu Lan Storvsc driver needs to reverse additional bounce buffers to receive multipagebuffer packet and copy data from brounce buffer when get response messge from message. Signed-off-by: Sunil Muthuswamy Co-Developed-by: Sunil Muthuswamy Signed-off-by: Tianyu Lan --- drivers/scsi/storvsc_drv.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/drivers/scsi/storvsc_drv.c b/drivers/scsi/storvsc_drv.c index c5b4974eb41f..4ae8e2a427e4 100644 --- a/drivers/scsi/storvsc_drv.c +++ b/drivers/scsi/storvsc_drv.c @@ -33,6 +33,8 @@ #include #include +#include "../hv/hyperv_vmbus.h" + /* * All wire protocol details (storage protocol between the guest and the host) * are consolidated here. @@ -725,6 +727,10 @@ static void handle_sc_creation(struct vmbus_channel *new_sc) /* Add the sub-channel to the array of available channels. */ stor_device->stor_chns[new_sc->target_cpu] = new_sc; cpumask_set_cpu(new_sc->target_cpu, &stor_device->alloced_cpus); + + if (hv_bounce_resources_reserve(device->channel, + stor_device->max_transfer_bytes)) + pr_warn("Fail to reserve bounce buffer\n"); } static void handle_multichannel_storage(struct hv_device *device, int max_chns) @@ -964,6 +970,18 @@ static int storvsc_channel_init(struct hv_device *device, bool is_fc) stor_device->max_transfer_bytes = vstor_packet->storage_channel_properties.max_transfer_bytes; + /* + * Reserve enough bounce resources to be able to support paging + * operations under low memory conditions, that cannot rely on + * additional resources to be allocated. + */ + ret = hv_bounce_resources_reserve(device->channel, + stor_device->max_transfer_bytes); + if (ret < 0) { + pr_warn("Fail to reserve bounce buffer\n"); + goto done; + } + if (!is_fc) goto done; @@ -1263,6 +1281,11 @@ static void storvsc_on_channel_callback(void *context) request = (struct storvsc_cmd_request *)(unsigned long)cmd_rqst; + if (desc->type == VM_PKT_COMP && request->bounce_pkt) { + hv_pkt_bounce(channel, request->bounce_pkt); + request->bounce_pkt = NULL; + } + if (request == &stor_device->init_request || request == &stor_device->reset_request) { memcpy(&request->vstor_packet, packet, -- 2.25.1