Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp6092856imu; Wed, 30 Jan 2019 08:40:59 -0800 (PST) X-Google-Smtp-Source: ALg8bN5LGaVp5RSitb/7Nl8RgXc9u7aQJ6rdd8sOgtONflazlAzy1YS3rJedR1vcSOHTDNWb80aR X-Received: by 2002:a17:902:aa82:: with SMTP id d2mr31158703plr.153.1548866459793; Wed, 30 Jan 2019 08:40:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548866459; cv=none; d=google.com; s=arc-20160816; b=b9aDZul+ECufd+wdAsTFI0ayllY1pYqOidjqOhG1EIB6SO2rOjN6dIPV+tzfA6aJRh qinL6JxUgwzt8el4T3lcE6S7vXFh07PTTgZsVcXayCgrAJBbzwIvpz3JFboDqyIU2ElK 6PaOsGMPOqWKXgdOOwcxIc1SRXbXR3tfVM4DpuNFVzFuw5Mm2g11XML73NHZ+WFpl0HJ iGuY3bHVXgfwb3JGmQ0WTsDLJVY/3AnDkSA878gZSP65XxddwJ8zvwJsDKPqciWec3ly JGgUzbRvUygyN7jt1ZE2SG98UydMkC+CKSK17dOeeUY5/JQHXpURjjP2s9To0dNpr/3b FqGQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=nTi8Ac51Udfo/hBZGppXr5wXwGI3PPCXUlqZBtt7YvY=; b=vfnrUB3OfWcji/z6xegdZYajZuikji7IX6d5SwLhtms7/mec9nwmjMbdG8e8SlVwmn 1ziqeCM6KusO69KIn5deiIwsglaYlBhnPJmtGju+gXmfIe9juDgJoiZW5Ful844ph1bG NX0kOkAuK/G6bEiaikbbZRKTdLu5sMVIm8OCItLjd1siREFW2BosxWDFFTUJkdPRlWvu nRXjrNC40pka2gG1Gz9M0TMxNvE3czzfZSwJBWsZM25sgp6SlTW+oqerMRghWgdj3nV+ qK8sAMkiP9IVEs+bMdsll28b11mlBzu4+62ON7duWOsaWHhFgcFCwdhWAjo2Fr+yRDG4 0lzA== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=8bytes.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t4si1748132pga.83.2019.01.30.08.40.44; Wed, 30 Jan 2019 08:40:59 -0800 (PST) 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=8bytes.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732247AbfA3QkM (ORCPT + 99 others); Wed, 30 Jan 2019 11:40:12 -0500 Received: from 8bytes.org ([81.169.241.247]:36076 "EHLO theia.8bytes.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732083AbfA3QkL (ORCPT ); Wed, 30 Jan 2019 11:40:11 -0500 Received: by theia.8bytes.org (Postfix, from userid 1000) id 835537F2; Wed, 30 Jan 2019 17:40:09 +0100 (CET) From: Joerg Roedel To: "Michael S . Tsirkin" , Jason Wang , Konrad Rzeszutek Wilk , Christoph Hellwig Cc: Jens Axboe , virtualization@lists.linux-foundation.org, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, iommu@lists.linux-foundation.org, jfehlig@suse.com, jon.grimm@amd.com, brijesh.singh@amd.com, joro@8bytes.org, jroedel@suse.de, Thomas.Lendacky@amd.com Subject: [PATCH 5/5] virtio-blk: Consider virtio_max_dma_size() for maximum segment size Date: Wed, 30 Jan 2019 17:40:07 +0100 Message-Id: <20190130164007.26497-6-joro@8bytes.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190130164007.26497-1-joro@8bytes.org> References: <20190130164007.26497-1-joro@8bytes.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Joerg Roedel Segments can't be larger than the maximum DMA mapping size supported on the platform. Take that into account when setting the maximum segment size for a block device. Reviewed-by: Konrad Rzeszutek Wilk Reviewed-by: Christoph Hellwig Signed-off-by: Joerg Roedel --- drivers/block/virtio_blk.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c index b16a887bbd02..4bc083b7c9b5 100644 --- a/drivers/block/virtio_blk.c +++ b/drivers/block/virtio_blk.c @@ -723,7 +723,7 @@ static int virtblk_probe(struct virtio_device *vdev) struct request_queue *q; int err, index; - u32 v, blk_size, sg_elems, opt_io_size; + u32 v, blk_size, max_size, sg_elems, opt_io_size; u16 min_io_size; u8 physical_block_exp, alignment_offset; @@ -826,14 +826,16 @@ static int virtblk_probe(struct virtio_device *vdev) /* No real sector limit. */ blk_queue_max_hw_sectors(q, -1U); + max_size = virtio_max_dma_size(vdev); + /* Host can optionally specify maximum segment size and number of * segments. */ err = virtio_cread_feature(vdev, VIRTIO_BLK_F_SIZE_MAX, struct virtio_blk_config, size_max, &v); if (!err) - blk_queue_max_segment_size(q, v); - else - blk_queue_max_segment_size(q, -1U); + max_size = min(max_size, v); + + blk_queue_max_segment_size(q, max_size); /* Host can optionally specify the block size of the device */ err = virtio_cread_feature(vdev, VIRTIO_BLK_F_BLK_SIZE, -- 2.17.1