From nobody Tue Apr 23 15:32:07 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of seabios.org designates 78.46.105.101 as permitted sender) client-ip=78.46.105.101; envelope-from=seabios-bounces@seabios.org; helo=coreboot.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of seabios.org designates 78.46.105.101 as permitted sender) smtp.mailfrom=seabios-bounces@seabios.org; dmarc=fail(p=none dis=none) header.from=intel.com Return-Path: Received: from coreboot.org (coreboot.org [78.46.105.101]) by mx.zohomail.com with SMTPS id 1638373471165167.4513890508614; Wed, 1 Dec 2021 07:44:31 -0800 (PST) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by coreboot.org (Postfix) with ESMTPA id 9169816E3D71; Wed, 1 Dec 2021 15:44:27 +0000 (UTC) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by coreboot.org (Postfix) with ESMTP id 81ECB16E3D69 for ; Wed, 1 Dec 2021 15:44:12 +0000 (UTC) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Dec 2021 07:44:10 -0800 Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by fmsmga008.fm.intel.com with ESMTP; 01 Dec 2021 06:05:50 -0800 Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) fmsmsx604.amr.corp.intel.com (10.18.126.84) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.20; Wed, 1 Dec 2021 06:05:50 -0800 Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) SHSMSX606.ccr.corp.intel.com (10.109.6.216) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.20; Wed, 1 Dec 2021 22:05:48 +0800 Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) SHSMSX601.ccr.corp.intel.com ([10.109.6.141]) with mapi id 15.01.2308.020; Wed, 1 Dec 2021 22:05:47 +0800 X-IronPort-AV: E=McAfee;i="6200,9189,10185"; a="223711843" X-IronPort-AV: E=Sophos;i="5.87,278,1631602800"; d="scan'208";a="223711843" X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.87,278,1631602800"; d="scan'208";a="560506567" From: "Pei, Andy" To: "seabios@seabios.org" Thread-Topic: [PATCH] virtio-blk: segment large IO to 4K IO. Thread-Index: AQHX5rsR9vSqdhVJdEGCw+2vKnAhHqwdqy6w Date: Wed, 1 Dec 2021 14:05:47 +0000 Message-ID: References: <1638364244-270270-1-git-send-email-andy.pei@intel.com> <1638364244-270270-2-git-send-email-andy.pei@intel.com> In-Reply-To: <1638364244-270270-2-git-send-email-andy.pei@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-version: 11.6.200.16 dlp-reaction: no-action MIME-Version: 1.0 Message-ID-Hash: NGYS7MO3T7PWV4RXMUXRITJX67NQZYEK X-Message-ID-Hash: NGYS7MO3T7PWV4RXMUXRITJX67NQZYEK X-MailFrom: andy.pei@intel.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-seabios.seabios.org-0; header-match-seabios.seabios.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: "kraxel@redhat.com" X-Mailman-Version: 3.3.5rc1 Precedence: list Subject: [SeaBIOS] Re: [PATCH] virtio-blk: segment large IO to 4K IO. List-Id: SeaBIOS mailing list Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Content-Transfer-Encoding: quoted-printable Authentication-Results: coreboot.org; auth=pass smtp.auth=mailman@coreboot.org smtp.mailfrom=seabios-bounces@seabios.org X-Spamd-Bar: ------ X-ZM-MESSAGEID: 1638373473334100001 Content-Type: text/plain; charset="utf-8" Hi, Terribly sorry for sending out a wrong patch. A V2 series will be sent, please ignore this patch set. Sorry for confusing. -----Original Message----- From: Pei, Andy =20 Sent: Wednesday, December 1, 2021 9:11 PM To: seabios@seabios.org Cc: kraxel@redhat.com; kevin@koconnor.net; Pei, Andy Subject: [PATCH] virtio-blk: segment large IO to 4K IO. Signed-off-by: Andy Pei --- src/hw/virtio-blk.c | 71 +++++++++++++++++++++++++++++++++++++++++++++++++= +++- 1 file changed, 70 insertions(+), 1 deletion(-) diff --git a/src/hw/virtio-blk.c b/src/hw/virtio-blk.c index 3b19896..4f9b1= e7 100644 --- a/src/hw/virtio-blk.c +++ b/src/hw/virtio-blk.c @@ -30,6 +30,44 @@ struct virtiodrive_s { struct vp_device vp; }; =20 +#define BLK_NUM_MAX 8 + +void dump(unsigned char *buf, int len) +{ + int i; + for (i =3D 0; i < len;) { + printf(" %2x", 0xff & buf[i++]); + if (i % 32 =3D=3D 0) + printf("\n"); + } + printf("\n"); +} + +void +segment(struct virtiodrive_s *vdrive, int write, struct vring_list=20 +sg[]) { + struct vring_virtqueue *vq =3D vdrive->vq; +=09 + /* Add to virtqueue and kick host */ + if (write) + vring_add_buf(vq, sg, 2, 1, 0, 0); + else + vring_add_buf(vq, sg, 1, 2, 0, 0); + vring_kick(&vdrive->vp, vq, 1); +=09 + /* Wait for reply */ + while (!vring_more_used(vq)) + usleep(5); +=09 + /* Reclaim virtqueue element */ + vring_get_buf(vq, NULL); +=09 + /* Clear interrupt status register. Avoid leaving interrupts stuck if + * VRING_AVAIL_F_NO_INTERRUPT was ignored and interrupts were raised. + */ + vp_get_isr(&vdrive->vp); +} + static int virtio_blk_op(struct disk_op_s *op, int write) { @@ -57,6 +95,7 @@ virtio= _blk_op(struct disk_op_s *op, int write) }, }; =20 + if (op->count <=3D BLK_NUM_MAX) {/* added by andy */ /* Add to virtqueue and kick host */ if (write) vring_add_buf(vq, sg, 2, 1, 0, 0); @@ -75,7 +114,37 @@ virtio_blk_= op(struct disk_op_s *op, int write) * VRING_AVAIL_F_NO_INTERRUPT was ignored and interrupts were raised. */ vp_get_isr(&vdrive->vp); - + } else {/* added by Andy */ + struct vring_list *p_sg =3D &sg[1]; + void *p =3D op->buf_fl; + u16 count =3D op->count; + + while (count > BLK_NUM_MAX) { + p_sg->addr =3D p; + p_sg->length =3D vdrive->drive.blksize * BLK_NUM_MAX; + segment(vdrive, write, sg); + //dump(p, p_sg->length); + if (status =3D=3D VIRTIO_BLK_S_OK) { + hdr.sector +=3D BLK_NUM_MAX; + p +=3D p_sg->length; + count -=3D BLK_NUM_MAX; + } else { + break; + } + } + + if (status !=3D VIRTIO_BLK_S_OK) { + return DISK_RET_EBADTRACK; + } + + if(count > 0) { + p_sg->addr =3D p; + p_sg->length =3D vdrive->drive.blksize * count; + segment(vdrive, write, sg); + //dump(p, p_sg->length); + } + + }/* end of modification from Andy */ return status =3D=3D VIRTIO_BLK_S_OK ? DISK_RET_SUCCESS : DISK_RET_EBA= DTRACK; } =20 -- 1.8.3.1 _______________________________________________ SeaBIOS mailing list -- seabios@seabios.org To unsubscribe send an email to seabios-leave@seabios.org