From: Namhyung Kim Subject: [PATCH 5/7] virtio-pstore: Support PSTORE_TYPE_CONSOLE Date: Thu, 28 Jul 2016 00:08:29 +0900 Message-ID: <1469632111-23260-6-git-send-email-namhyung@kernel.org> References: <1469632111-23260-1-git-send-email-namhyung@kernel.org> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: QUOTED-PRINTABLE Cc: LKML , Paolo Bonzini , =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= , "Michael S. Tsirkin" , Anthony Liguori , Anton Vorontsov , Colin Cross , Kees Cook , Tony Luck , Steven Rostedt , Ingo Molnar , Minchan Kim To: kvm@vger.kernel.org, qemu-devel@nongnu.org, virtualization@lists.linux-foundation.org Return-path: In-Reply-To: <1469632111-23260-1-git-send-email-namhyung@kernel.org> Sender: linux-kernel-owner@vger.kernel.org List-Id: kvm.vger.kernel.org With help of buffer management functions, it now supports CONSOLE type pstore write. The config space has flags field which defines the VIRTIO_PSTORE_CONFIG_FL_CONSOLE. When it's set, the virtio-pstore driver also sets PSTORE_FLAGS_ASYNC so that the buffer management is enabled. Cc: Paolo Bonzini Cc: Radim Kr=C4=8Dm=C3=A1=C5=99 Cc: "Michael S. Tsirkin" Cc: Anthony Liguori Cc: Anton Vorontsov Cc: Colin Cross Cc: Kees Cook Cc: Tony Luck Cc: Steven Rostedt Cc: Ingo Molnar Cc: Minchan Kim Cc: kvm@vger.kernel.org Cc: qemu-devel@nongnu.org Cc: virtualization@lists.linux-foundation.org Signed-off-by: Namhyung Kim --- drivers/virtio/virtio_pstore.c | 9 ++++++++- include/uapi/linux/virtio_pstore.h | 4 ++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/drivers/virtio/virtio_pstore.c b/drivers/virtio/virtio_pst= ore.c index 4ee1c186f582..458c4d3ccbb1 100644 --- a/drivers/virtio/virtio_pstore.c +++ b/drivers/virtio/virtio_pstore.c @@ -33,6 +33,7 @@ struct type_table { u16 virtio; } type_table[] =3D { TYPE_TABLE_ENTRY(DMESG), + TYPE_TABLE_ENTRY(CONSOLE), }; =20 #undef TYPE_TABLE_ENTRY @@ -276,7 +277,8 @@ static int virt_pstore_init(struct virtio_pstore *v= ps) psinfo->read =3D virt_pstore_read; psinfo->erase =3D virt_pstore_erase; psinfo->write =3D virt_pstore_write; - psinfo->flags =3D PSTORE_FLAGS_DMESG; + /* preserve flags from config */ + psinfo->flags |=3D PSTORE_FLAGS_DMESG; =20 psinfo->data =3D vps; spin_lock_init(&psinfo->buf_lock); @@ -313,10 +315,15 @@ static int virtpstore_init_vqs(struct virtio_psto= re *vps) static void virtpstore_init_config(struct virtio_pstore *vps) { u32 bufsize; + u32 flags; =20 virtio_cread(vps->vdev, struct virtio_pstore_config, bufsize, &bufsiz= e); + virtio_cread(vps->vdev, struct virtio_pstore_config, flags, &flags); =20 vps->pstore.bufsize =3D PAGE_ALIGN(bufsize); + + if (flags & VIRTIO_PSTORE_CONFIG_FL_CONSOLE) + vps->pstore.flags |=3D PSTORE_FLAGS_CONSOLE | PSTORE_FLAGS_ASYNC; } =20 static void virtpstore_confirm_config(struct virtio_pstore *vps) diff --git a/include/uapi/linux/virtio_pstore.h b/include/uapi/linux/vi= rtio_pstore.h index f4b0d204d8ae..56d0b1554231 100644 --- a/include/uapi/linux/virtio_pstore.h +++ b/include/uapi/linux/virtio_pstore.h @@ -37,9 +37,12 @@ =20 #define VIRTIO_PSTORE_TYPE_UNKNOWN 0 #define VIRTIO_PSTORE_TYPE_DMESG 1 +#define VIRTIO_PSTORE_TYPE_CONSOLE 2 =20 #define VIRTIO_PSTORE_FL_COMPRESSED 1 =20 +#define VIRTIO_PSTORE_CONFIG_FL_CONSOLE (1 << 0) + struct virtio_pstore_req { __virtio16 cmd; __virtio16 type; @@ -69,6 +72,7 @@ struct virtio_pstore_fileinfo { =20 struct virtio_pstore_config { __virtio32 bufsize; + __virtio32 flags; }; =20 #endif /* _LINUX_VIRTIO_PSTORE_H */ --=20 2.8.0