Re: [Intel-gfx] ✗ Fi.CI.BAT: warning for i2c: refactor core and break out blocks

2017-05-27 Thread Wolfram Sang

> For more details see: https://intel-gfx-ci.01.org/CI/Patchwork_4827/

As far as I can read the above page, all non-green blocks are caused by
non-I2C issues. So, I'd assume my patch set doesn't break things. Good!



signature.asc
Description: PGP signature
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] ✗ Fi.CI.BAT: warning for i2c: refactor core and break out blocks

2017-05-27 Thread Patchwork
== Series Details ==

Series: i2c: refactor core and break out blocks
URL   : https://patchwork.freedesktop.org/series/24985/
State : warning

== Summary ==

Series 24985v1 i2c: refactor core and break out blocks
https://patchwork.freedesktop.org/api/1.0/series/24985/revisions/1/mbox/

Test gem_exec_flush:
Subgroup basic-batch-kernel-default-uc:
pass   -> FAIL   (fi-snb-2600) fdo#17
Test kms_busy:
Subgroup basic-flip-default-a:
pass   -> DMESG-WARN (fi-skl-6700hq) fdo#101144 +3
Test kms_cursor_legacy:
Subgroup basic-busy-flip-before-cursor-atomic:
pass   -> FAIL   (fi-skl-6700hq) fdo#101154 +24
Test kms_flip:
Subgroup basic-flip-vs-modeset:
pass   -> SKIP   (fi-skl-6700hq) fdo#100867
Subgroup basic-flip-vs-wf_vblank:
pass   -> SKIP   (fi-skl-6700hq) fdo#99739
Subgroup basic-plain-flip:
pass   -> SKIP   (fi-skl-6700hq)
Test kms_frontbuffer_tracking:
Subgroup basic:
pass   -> SKIP   (fi-skl-6700hq)

fdo#17 https://bugs.freedesktop.org/show_bug.cgi?id=17
fdo#101144 https://bugs.freedesktop.org/show_bug.cgi?id=101144
fdo#101154 https://bugs.freedesktop.org/show_bug.cgi?id=101154
fdo#100867 https://bugs.freedesktop.org/show_bug.cgi?id=100867
fdo#99739 https://bugs.freedesktop.org/show_bug.cgi?id=99739

fi-bdw-5557u total:278  pass:267  dwarn:0   dfail:0   fail:0   skip:11  
time:442s
fi-bdw-gvtdvmtotal:278  pass:256  dwarn:8   dfail:0   fail:0   skip:14  
time:434s
fi-bsw-n3050 total:278  pass:242  dwarn:0   dfail:0   fail:0   skip:36  
time:581s
fi-bxt-j4205 total:278  pass:259  dwarn:0   dfail:0   fail:0   skip:19  
time:506s
fi-byt-j1900 total:278  pass:254  dwarn:0   dfail:0   fail:0   skip:24  
time:488s
fi-byt-n2820 total:278  pass:250  dwarn:0   dfail:0   fail:0   skip:28  
time:478s
fi-hsw-4770  total:278  pass:262  dwarn:0   dfail:0   fail:0   skip:16  
time:431s
fi-hsw-4770r total:278  pass:262  dwarn:0   dfail:0   fail:0   skip:16  
time:412s
fi-ilk-650   total:278  pass:228  dwarn:0   dfail:0   fail:0   skip:50  
time:415s
fi-ivb-3520m total:278  pass:260  dwarn:0   dfail:0   fail:0   skip:18  
time:487s
fi-ivb-3770  total:278  pass:260  dwarn:0   dfail:0   fail:0   skip:18  
time:462s
fi-kbl-7500u total:278  pass:255  dwarn:5   dfail:0   fail:0   skip:18  
time:463s
fi-kbl-7560u total:278  pass:263  dwarn:5   dfail:0   fail:0   skip:10  
time:576s
fi-skl-6260u total:278  pass:268  dwarn:0   dfail:0   fail:0   skip:10  
time:458s
fi-skl-6700hqtotal:278  pass:228  dwarn:1   dfail:0   fail:27  skip:22  
time:401s
fi-skl-6700k total:278  pass:256  dwarn:4   dfail:0   fail:0   skip:18  
time:468s
fi-skl-6770hqtotal:278  pass:268  dwarn:0   dfail:0   fail:0   skip:10  
time:496s
fi-skl-gvtdvmtotal:278  pass:265  dwarn:0   dfail:0   fail:0   skip:13  
time:438s
fi-snb-2520m total:278  pass:250  dwarn:0   dfail:0   fail:0   skip:28  
time:529s
fi-snb-2600  total:278  pass:248  dwarn:0   dfail:0   fail:1   skip:29  
time:405s

bf9722dc7ed767dd56571e82950e533f69d9318e drm-tip: 2017y-05m-26d-23h-15m-13s UTC 
integration manifest
73d7232 i2c: reformat core-base file header
cdd68eb i2c: remove unneeded includes from core
36af742 docs: i2c: dev-interface: adapt to new filenames of the i2c core
f30d59f i2c: break out ACPI support into seperate file
5db770f i2c: break out OF support into seperate file
e78125c i2c: break out smbus support into seperate file
8240296 i2c: break out slave support into seperate file
dd736829 i2c: rename core source file to allow refactorization

== Logs ==

For more details see: https://intel-gfx-ci.01.org/CI/Patchwork_4827/
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [RFT 1/8] i2c: rename core source file to allow refactorization

2017-05-27 Thread Wolfram Sang
The I2C core became quite huge and its monolithic structure makes
maintenance hard. So, prepare to break out some functionality into
seperate files by renaming the source file. Note that we keep the
resulting object name constant to avoid regressions.

Signed-off-by: Wolfram Sang 
---
 Documentation/driver-api/i2c.rst| 2 +-
 drivers/i2c/Makefile| 4 +++-
 drivers/i2c/busses/i2c-designware-core.c| 2 +-
 drivers/i2c/{i2c-core.c => i2c-core-base.c} | 0
 4 files changed, 5 insertions(+), 3 deletions(-)
 rename drivers/i2c/{i2c-core.c => i2c-core-base.c} (100%)

diff --git a/Documentation/driver-api/i2c.rst b/Documentation/driver-api/i2c.rst
index 0bf86a445d0135..67366d9ff7303f 100644
--- a/Documentation/driver-api/i2c.rst
+++ b/Documentation/driver-api/i2c.rst
@@ -41,5 +41,5 @@ i2c_adapter devices which don't support those I2C operations.
 .. kernel-doc:: drivers/i2c/i2c-boardinfo.c
:functions: i2c_register_board_info
 
-.. kernel-doc:: drivers/i2c/i2c-core.c
+.. kernel-doc:: drivers/i2c/i2c-core-base.c
:export:
diff --git a/drivers/i2c/Makefile b/drivers/i2c/Makefile
index 45095b3d16a914..d459c7e5907607 100644
--- a/drivers/i2c/Makefile
+++ b/drivers/i2c/Makefile
@@ -4,6 +4,8 @@
 
 obj-$(CONFIG_I2C_BOARDINFO)+= i2c-boardinfo.o
 obj-$(CONFIG_I2C)  += i2c-core.o
+i2c-core-objs  := i2c-core-base.o
+
 obj-$(CONFIG_I2C_SMBUS)+= i2c-smbus.o
 obj-$(CONFIG_I2C_CHARDEV)  += i2c-dev.o
 obj-$(CONFIG_I2C_MUX)  += i2c-mux.o
@@ -12,4 +14,4 @@ obj-$(CONFIG_I2C_STUB)+= i2c-stub.o
 obj-$(CONFIG_I2C_SLAVE_EEPROM) += i2c-slave-eeprom.o
 
 ccflags-$(CONFIG_I2C_DEBUG_CORE) := -DDEBUG
-CFLAGS_i2c-core.o := -Wno-deprecated-declarations
+CFLAGS_i2c-core-base.o := -Wno-deprecated-declarations
diff --git a/drivers/i2c/busses/i2c-designware-core.c 
b/drivers/i2c/busses/i2c-designware-core.c
index c453717b753b72..3c41995634c2f9 100644
--- a/drivers/i2c/busses/i2c-designware-core.c
+++ b/drivers/i2c/busses/i2c-designware-core.c
@@ -583,7 +583,7 @@ i2c_dw_xfer_msg(struct dw_i2c_dev *dev)
 */
 
/*
-* i2c-core.c always sets the buffer length of
+* i2c-core always sets the buffer length of
 * I2C_FUNC_SMBUS_BLOCK_DATA to 1. The length will
 * be adjusted when receiving the first byte.
 * Thus we can't stop the transaction here.
diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core-base.c
similarity index 100%
rename from drivers/i2c/i2c-core.c
rename to drivers/i2c/i2c-core-base.c
-- 
2.11.0

___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [RFT 6/8] docs: i2c: dev-interface: adapt to new filenames of the i2c core

2017-05-27 Thread Wolfram Sang
The I2C core files were renamed, adapt the textfile to it.

Signed-off-by: Wolfram Sang 
---
 Documentation/i2c/dev-interface | 14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/Documentation/i2c/dev-interface b/Documentation/i2c/dev-interface
index bcf919d8625ceb..5ff19447ac4420 100644
--- a/Documentation/i2c/dev-interface
+++ b/Documentation/i2c/dev-interface
@@ -191,7 +191,7 @@ checking on future transactions.)
 4* Other ioctl() calls are converted to in-kernel function calls by
 i2c-dev. Examples include I2C_FUNCS, which queries the I2C adapter
 functionality using i2c.h:i2c_get_functionality(), and I2C_SMBUS, which
-performs an SMBus transaction using i2c-core.c:i2c_smbus_xfer().
+performs an SMBus transaction using i2c-core-smbus.c:i2c_smbus_xfer().
 
 The i2c-dev driver is responsible for checking all the parameters that
 come from user-space for validity. After this point, there is no
@@ -200,13 +200,13 @@ and calls that would have been performed by kernel I2C 
chip drivers
 directly. This means that I2C bus drivers don't need to implement
 anything special to support access from user-space.
 
-5* These i2c-core.c/i2c.h functions are wrappers to the actual
-implementation of your I2C bus driver. Each adapter must declare
-callback functions implementing these standard calls.
-i2c.h:i2c_get_functionality() calls i2c_adapter.algo->functionality(),
-while i2c-core.c:i2c_smbus_xfer() calls either
+5* These i2c.h functions are wrappers to the actual implementation of
+your I2C bus driver. Each adapter must declare callback functions
+implementing these standard calls. i2c.h:i2c_get_functionality() calls
+i2c_adapter.algo->functionality(), while
+i2c-core-smbus.c:i2c_smbus_xfer() calls either
 adapter.algo->smbus_xfer() if it is implemented, or if not,
-i2c-core.c:i2c_smbus_xfer_emulated() which in turn calls
+i2c-core-smbus.c:i2c_smbus_xfer_emulated() which in turn calls
 i2c_adapter.algo->master_xfer().
 
 After your I2C bus driver has processed these requests, execution runs
-- 
2.11.0

___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [RFT 5/8] i2c: break out ACPI support into seperate file

2017-05-27 Thread Wolfram Sang
Removes some ifdeffery. Also add the new file to the relevant
MAINTAINERS section.

Signed-off-by: Wolfram Sang 
---
 MAINTAINERS |   1 +
 drivers/i2c/Makefile|   1 +
 drivers/i2c/i2c-core-acpi.c | 653 
 drivers/i2c/i2c-core-base.c | 648 ---
 drivers/i2c/i2c-core.h  |  15 +
 5 files changed, 670 insertions(+), 648 deletions(-)
 create mode 100644 drivers/i2c/i2c-core-acpi.c

diff --git a/MAINTAINERS b/MAINTAINERS
index 9e984645c4b08b..3ce38e77f96e6b 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -6273,6 +6273,7 @@ M:Mika Westerberg 

 L: linux-...@vger.kernel.org
 L: linux-a...@vger.kernel.org
 S: Maintained
+F: drivers/i2c/i2c-core-acpi.c
 
 I2C-TAOS-EVM DRIVER
 M: Jean Delvare 
diff --git a/drivers/i2c/Makefile b/drivers/i2c/Makefile
index 189e0e6476f0a6..7bb65a4369e1e1 100644
--- a/drivers/i2c/Makefile
+++ b/drivers/i2c/Makefile
@@ -5,6 +5,7 @@
 obj-$(CONFIG_I2C_BOARDINFO)+= i2c-boardinfo.o
 obj-$(CONFIG_I2C)  += i2c-core.o
 i2c-core-objs  := i2c-core-base.o i2c-core-smbus.o
+i2c-core-$(CONFIG_ACPI)+= i2c-core-acpi.o
 i2c-core-$(CONFIG_I2C_SLAVE)   += i2c-core-slave.o
 i2c-core-$(CONFIG_OF)  += i2c-core-of.o
 
diff --git a/drivers/i2c/i2c-core-acpi.c b/drivers/i2c/i2c-core-acpi.c
new file mode 100644
index 00..052005579ed626
--- /dev/null
+++ b/drivers/i2c/i2c-core-acpi.c
@@ -0,0 +1,653 @@
+/*
+ * Linux I2C core ACPI support code
+ *
+ * Copyright (C) 2014 Intel Corp, Author: Lan Tianyu 
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; either version 2 of the License, or (at your option)
+ * any later version.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "i2c-core.h"
+
+struct i2c_acpi_handler_data {
+   struct acpi_connection_info info;
+   struct i2c_adapter *adapter;
+};
+
+struct gsb_buffer {
+   u8  status;
+   u8  len;
+   union {
+   u16 wdata;
+   u8  bdata;
+   u8  data[0];
+   };
+} __packed;
+
+struct i2c_acpi_lookup {
+   struct i2c_board_info *info;
+   acpi_handle adapter_handle;
+   acpi_handle device_handle;
+   acpi_handle search_handle;
+   int n;
+   int index;
+   u32 speed;
+   u32 min_speed;
+};
+
+static int i2c_acpi_fill_info(struct acpi_resource *ares, void *data)
+{
+   struct i2c_acpi_lookup *lookup = data;
+   struct i2c_board_info *info = lookup->info;
+   struct acpi_resource_i2c_serialbus *sb;
+   acpi_status status;
+
+   if (info->addr || ares->type != ACPI_RESOURCE_TYPE_SERIAL_BUS)
+   return 1;
+
+   sb = &ares->data.i2c_serial_bus;
+   if (sb->type != ACPI_RESOURCE_SERIAL_TYPE_I2C)
+   return 1;
+
+   if (lookup->index != -1 && lookup->n++ != lookup->index)
+   return 1;
+
+   status = acpi_get_handle(lookup->device_handle,
+sb->resource_source.string_ptr,
+&lookup->adapter_handle);
+   if (!ACPI_SUCCESS(status))
+   return 1;
+
+   info->addr = sb->slave_address;
+   lookup->speed = sb->connection_speed;
+   if (sb->access_mode == ACPI_I2C_10BIT_MODE)
+   info->flags |= I2C_CLIENT_TEN;
+
+   return 1;
+}
+
+static int i2c_acpi_do_lookup(struct acpi_device *adev,
+ struct i2c_acpi_lookup *lookup)
+{
+   struct i2c_board_info *info = lookup->info;
+   struct list_head resource_list;
+   int ret;
+
+   if (acpi_bus_get_status(adev) || !adev->status.present ||
+   acpi_device_enumerated(adev))
+   return -EINVAL;
+
+   memset(info, 0, sizeof(*info));
+   lookup->device_handle = acpi_device_handle(adev);
+
+   /* Look up for I2cSerialBus resource */
+   INIT_LIST_HEAD(&resource_list);
+   ret = acpi_dev_get_resources(adev, &resource_list,
+i2c_acpi_fill_info, lookup);
+   acpi_dev_free_resource_list(&resource_list);
+
+   if (ret < 0 || !info->addr)
+   return -EINVAL;
+
+   return 0;
+}
+
+static int i2c_acpi_get_info(struct acpi_device *adev,
+struct i2c_board_info *info,
+struct i2c_adapter *adapter,
+acpi_handle *adapter_handle)
+{
+   struct list_head resource_list;
+   struct resource_entry *entry;
+   struct i2c_acpi_lookup lookup;
+   int ret;
+
+   memset(&lookup, 0, sizeof(lookup));
+   lookup.info = info;
+   lookup.index = -1;
+
+   ret = i2c_acpi_do_lookup(adev, &lookup);
+   if (ret)
+   return ret;
+
+   if (ad

[Intel-gfx] [RFT 3/8] i2c: break out smbus support into seperate file

2017-05-27 Thread Wolfram Sang
Break out the exported SMBus functions and the emulation layer into a
seperate file. This also involved splitting up the tracing header into
an I2C and an SMBus part.

Signed-off-by: Wolfram Sang 
---
 Documentation/driver-api/i2c.rst |   3 +
 drivers/i2c/Makefile |   2 +-
 drivers/i2c/i2c-core-base.c  | 574 -
 drivers/i2c/i2c-core-smbus.c | 594 +++
 include/trace/events/i2c.h   | 226 +--
 include/trace/events/smbus.h | 249 
 6 files changed, 849 insertions(+), 799 deletions(-)
 create mode 100644 drivers/i2c/i2c-core-smbus.c
 create mode 100644 include/trace/events/smbus.h

diff --git a/Documentation/driver-api/i2c.rst b/Documentation/driver-api/i2c.rst
index 67366d9ff7303f..7582c079d74795 100644
--- a/Documentation/driver-api/i2c.rst
+++ b/Documentation/driver-api/i2c.rst
@@ -43,3 +43,6 @@ i2c_adapter devices which don't support those I2C operations.
 
 .. kernel-doc:: drivers/i2c/i2c-core-base.c
:export:
+
+.. kernel-doc:: drivers/i2c/i2c-core-smbus.c
+   :export:
diff --git a/drivers/i2c/Makefile b/drivers/i2c/Makefile
index 6c54716e7f28ca..a6a90fe2db887a 100644
--- a/drivers/i2c/Makefile
+++ b/drivers/i2c/Makefile
@@ -4,7 +4,7 @@
 
 obj-$(CONFIG_I2C_BOARDINFO)+= i2c-boardinfo.o
 obj-$(CONFIG_I2C)  += i2c-core.o
-i2c-core-objs  := i2c-core-base.o
+i2c-core-objs  := i2c-core-base.o i2c-core-smbus.o
 i2c-core-$(CONFIG_I2C_SLAVE)   += i2c-core-slave.o
 
 obj-$(CONFIG_I2C_SMBUS)+= i2c-smbus.o
diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c
index 88c0ca664a7b8f..70fc4624c69c25 100644
--- a/drivers/i2c/i2c-core-base.c
+++ b/drivers/i2c/i2c-core-base.c
@@ -14,9 +14,6 @@
 /* - */
 
 /* With some changes from Kyösti Mälkki .
-   All SMBus-related things are written by Frodo Looijaard 
-   SMBus 2.0 support by Mark Studebaker  and
-   Jean Delvare 
Mux support by Rodolfo Giometti  and
Michael Lawnick 
OF support is copyright (c) 2008 Jochen Friedrich 
@@ -3155,577 +3152,6 @@ void i2c_put_adapter(struct i2c_adapter *adap)
 }
 EXPORT_SYMBOL(i2c_put_adapter);
 
-/* The SMBus parts */
-
-#define POLY(0x1070U << 3)
-static u8 crc8(u16 data)
-{
-   int i;
-
-   for (i = 0; i < 8; i++) {
-   if (data & 0x8000)
-   data = data ^ POLY;
-   data = data << 1;
-   }
-   return (u8)(data >> 8);
-}
-
-/* Incremental CRC8 over count bytes in the array pointed to by p */
-static u8 i2c_smbus_pec(u8 crc, u8 *p, size_t count)
-{
-   int i;
-
-   for (i = 0; i < count; i++)
-   crc = crc8((crc ^ p[i]) << 8);
-   return crc;
-}
-
-/* Assume a 7-bit address, which is reasonable for SMBus */
-static u8 i2c_smbus_msg_pec(u8 pec, struct i2c_msg *msg)
-{
-   /* The address will be sent first */
-   u8 addr = i2c_8bit_addr_from_msg(msg);
-   pec = i2c_smbus_pec(pec, &addr, 1);
-
-   /* The data buffer follows */
-   return i2c_smbus_pec(pec, msg->buf, msg->len);
-}
-
-/* Used for write only transactions */
-static inline void i2c_smbus_add_pec(struct i2c_msg *msg)
-{
-   msg->buf[msg->len] = i2c_smbus_msg_pec(0, msg);
-   msg->len++;
-}
-
-/* Return <0 on CRC error
-   If there was a write before this read (most cases) we need to take the
-   partial CRC from the write part into account.
-   Note that this function does modify the message (we need to decrease the
-   message length to hide the CRC byte from the caller). */
-static int i2c_smbus_check_pec(u8 cpec, struct i2c_msg *msg)
-{
-   u8 rpec = msg->buf[--msg->len];
-   cpec = i2c_smbus_msg_pec(cpec, msg);
-
-   if (rpec != cpec) {
-   pr_debug("Bad PEC 0x%02x vs. 0x%02x\n",
-   rpec, cpec);
-   return -EBADMSG;
-   }
-   return 0;
-}
-
-/**
- * i2c_smbus_read_byte - SMBus "receive byte" protocol
- * @client: Handle to slave device
- *
- * This executes the SMBus "receive byte" protocol, returning negative errno
- * else the byte received from the device.
- */
-s32 i2c_smbus_read_byte(const struct i2c_client *client)
-{
-   union i2c_smbus_data data;
-   int status;
-
-   status = i2c_smbus_xfer(client->adapter, client->addr, client->flags,
-   I2C_SMBUS_READ, 0,
-   I2C_SMBUS_BYTE, &data);
-   return (status < 0) ? status : data.byte;
-}
-EXPORT_SYMBOL(i2c_smbus_read_byte);
-
-/**
- * i2c_smbus_write_byte - SMBus "send byte" protocol
- * @client: Handle to slave device
- * @value: Byte to be sent
- *
- * This executes the SMBus "send byte" protocol, returning negative errno
- * else zero on success.
- */
-s32 i2c_smbus_write_byte(const struct i2c_client *client, u8 value)
-{
-   return i2c_smbus_xfer(client->adapter, client->addr, c

[Intel-gfx] [RFT 7/8] i2c: remove unneeded includes from core

2017-05-27 Thread Wolfram Sang
They seem like cruft to me. I couldn't find any evidence that something
included from there is actually used.

Signed-off-by: Wolfram Sang 
---
 drivers/i2c/i2c-core-base.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c
index ac7b95e4cda75d..78135c1deaab59 100644
--- a/drivers/i2c/i2c-core-base.c
+++ b/drivers/i2c/i2c-core-base.c
@@ -21,7 +21,6 @@
 #define pr_fmt(fmt) "i2c-core: " fmt
 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -29,7 +28,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
-- 
2.11.0

___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [RFT 4/8] i2c: break out OF support into seperate file

2017-05-27 Thread Wolfram Sang
Also removes some ifdeffery.

Signed-off-by: Wolfram Sang 
---
 drivers/i2c/Makefile|   1 +
 drivers/i2c/i2c-core-base.c | 265 +-
 drivers/i2c/i2c-core-of.c   | 276 
 drivers/i2c/i2c-core.h  |   8 ++
 4 files changed, 286 insertions(+), 264 deletions(-)
 create mode 100644 drivers/i2c/i2c-core-of.c

diff --git a/drivers/i2c/Makefile b/drivers/i2c/Makefile
index a6a90fe2db887a..189e0e6476f0a6 100644
--- a/drivers/i2c/Makefile
+++ b/drivers/i2c/Makefile
@@ -6,6 +6,7 @@ obj-$(CONFIG_I2C_BOARDINFO) += i2c-boardinfo.o
 obj-$(CONFIG_I2C)  += i2c-core.o
 i2c-core-objs  := i2c-core-base.o i2c-core-smbus.o
 i2c-core-$(CONFIG_I2C_SLAVE)   += i2c-core-slave.o
+i2c-core-$(CONFIG_OF)  += i2c-core-of.o
 
 obj-$(CONFIG_I2C_SMBUS)+= i2c-smbus.o
 obj-$(CONFIG_I2C_CHARDEV)  += i2c-dev.o
diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c
index 70fc4624c69c25..461451da106504 100644
--- a/drivers/i2c/i2c-core-base.c
+++ b/drivers/i2c/i2c-core-base.c
@@ -16,9 +16,6 @@
 /* With some changes from Kyösti Mälkki .
Mux support by Rodolfo Giometti  and
Michael Lawnick 
-   OF support is copyright (c) 2008 Jochen Friedrich 
-   (based on a previous patch from Jon Smirl ) and
-   (c) 2013  Wolfram Sang 
I2C ACPI code Copyright (C) 2014 Intel Corp
Author: Lan Tianyu 
  */
@@ -1191,7 +1188,7 @@ static unsigned short i2c_encode_flags_to_addr(struct 
i2c_client *client)
 
 /* This is a permissive address validity check, I2C address map constraints
  * are purposely not enforced, except for the general call address. */
-static int i2c_check_addr_validity(unsigned addr, unsigned short flags)
+int i2c_check_addr_validity(unsigned addr, unsigned short flags)
 {
if (flags & I2C_CLIENT_TEN) {
/* 10-bit address, all values are valid */
@@ -1760,210 +1757,6 @@ static void i2c_scan_static_board_info(struct 
i2c_adapter *adapter)
up_read(&__i2c_board_lock);
 }
 
-/* OF support code */
-
-#if IS_ENABLED(CONFIG_OF)
-static struct i2c_client *of_i2c_register_device(struct i2c_adapter *adap,
-struct device_node *node)
-{
-   struct i2c_client *result;
-   struct i2c_board_info info = {};
-   struct dev_archdata dev_ad = {};
-   const __be32 *addr_be;
-   u32 addr;
-   int len;
-
-   dev_dbg(&adap->dev, "of_i2c: register %s\n", node->full_name);
-
-   if (of_modalias_node(node, info.type, sizeof(info.type)) < 0) {
-   dev_err(&adap->dev, "of_i2c: modalias failure on %s\n",
-   node->full_name);
-   return ERR_PTR(-EINVAL);
-   }
-
-   addr_be = of_get_property(node, "reg", &len);
-   if (!addr_be || (len < sizeof(*addr_be))) {
-   dev_err(&adap->dev, "of_i2c: invalid reg on %s\n",
-   node->full_name);
-   return ERR_PTR(-EINVAL);
-   }
-
-   addr = be32_to_cpup(addr_be);
-   if (addr & I2C_TEN_BIT_ADDRESS) {
-   addr &= ~I2C_TEN_BIT_ADDRESS;
-   info.flags |= I2C_CLIENT_TEN;
-   }
-
-   if (addr & I2C_OWN_SLAVE_ADDRESS) {
-   addr &= ~I2C_OWN_SLAVE_ADDRESS;
-   info.flags |= I2C_CLIENT_SLAVE;
-   }
-
-   if (i2c_check_addr_validity(addr, info.flags)) {
-   dev_err(&adap->dev, "of_i2c: invalid addr=%x on %s\n",
-   addr, node->full_name);
-   return ERR_PTR(-EINVAL);
-   }
-
-   info.addr = addr;
-   info.of_node = of_node_get(node);
-   info.archdata = &dev_ad;
-
-   if (of_property_read_bool(node, "host-notify"))
-   info.flags |= I2C_CLIENT_HOST_NOTIFY;
-
-   if (of_get_property(node, "wakeup-source", NULL))
-   info.flags |= I2C_CLIENT_WAKE;
-
-   result = i2c_new_device(adap, &info);
-   if (result == NULL) {
-   dev_err(&adap->dev, "of_i2c: Failure registering %s\n",
-   node->full_name);
-   of_node_put(node);
-   return ERR_PTR(-EINVAL);
-   }
-   return result;
-}
-
-static void of_i2c_register_devices(struct i2c_adapter *adap)
-{
-   struct device_node *bus, *node;
-   struct i2c_client *client;
-
-   /* Only register child devices if the adapter has a node pointer set */
-   if (!adap->dev.of_node)
-   return;
-
-   dev_dbg(&adap->dev, "of_i2c: walking child nodes\n");
-
-   bus = of_get_child_by_name(adap->dev.of_node, "i2c-bus");
-   if (!bus)
-   bus = of_node_get(adap->dev.of_node);
-
-   for_each_available_child_of_node(bus, node) {
-   if (of_node_test_and_set_flag(node, OF_POPULATED))
-   continue;
-
-   client = of_i2c_register_device(adap, node);
-   if (IS_ERR(client)) {
-

[Intel-gfx] [RFT 2/8] i2c: break out slave support into seperate file

2017-05-27 Thread Wolfram Sang
Also removes some ifdeffery.

Signed-off-by: Wolfram Sang 
---
 drivers/i2c/Makefile |   1 +
 drivers/i2c/i2c-core-base.c  | 102 +-
 drivers/i2c/i2c-core-slave.c | 115 +++
 drivers/i2c/i2c-core.h   |   1 +
 4 files changed, 118 insertions(+), 101 deletions(-)
 create mode 100644 drivers/i2c/i2c-core-slave.c

diff --git a/drivers/i2c/Makefile b/drivers/i2c/Makefile
index d459c7e5907607..6c54716e7f28ca 100644
--- a/drivers/i2c/Makefile
+++ b/drivers/i2c/Makefile
@@ -5,6 +5,7 @@
 obj-$(CONFIG_I2C_BOARDINFO)+= i2c-boardinfo.o
 obj-$(CONFIG_I2C)  += i2c-core.o
 i2c-core-objs  := i2c-core-base.o
+i2c-core-$(CONFIG_I2C_SLAVE)   += i2c-core-slave.o
 
 obj-$(CONFIG_I2C_SMBUS)+= i2c-smbus.o
 obj-$(CONFIG_I2C_CHARDEV)  += i2c-dev.o
diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c
index 82576aaccc909b..88c0ca664a7b8f 100644
--- a/drivers/i2c/i2c-core-base.c
+++ b/drivers/i2c/i2c-core-base.c
@@ -24,7 +24,6 @@
(c) 2013  Wolfram Sang 
I2C ACPI code Copyright (C) 2014 Intel Corp
Author: Lan Tianyu 
-   I2C slave support (c) 2014 by Wolfram Sang 
  */
 
 #define pr_fmt(fmt) "i2c-core: " fmt
@@ -1213,7 +1212,7 @@ static int i2c_check_addr_validity(unsigned addr, 
unsigned short flags)
  * device uses a reserved address, then it shouldn't be probed. 7-bit
  * addressing is assumed, 10-bit address devices are rare and should be
  * explicitly enumerated. */
-static int i2c_check_7bit_addr_validity_strict(unsigned short addr)
+int i2c_check_7bit_addr_validity_strict(unsigned short addr)
 {
/*
 * Reserved addresses per I2C specification:
@@ -3727,105 +3726,6 @@ s32 i2c_smbus_read_i2c_block_data_or_emulated(const 
struct i2c_client *client,
 }
 EXPORT_SYMBOL(i2c_smbus_read_i2c_block_data_or_emulated);
 
-#if IS_ENABLED(CONFIG_I2C_SLAVE)
-int i2c_slave_register(struct i2c_client *client, i2c_slave_cb_t slave_cb)
-{
-   int ret;
-
-   if (!client || !slave_cb) {
-   WARN(1, "insufficient data\n");
-   return -EINVAL;
-   }
-
-   if (!(client->flags & I2C_CLIENT_SLAVE))
-   dev_warn(&client->dev, "%s: client slave flag not set. You 
might see address collisions\n",
-__func__);
-
-   if (!(client->flags & I2C_CLIENT_TEN)) {
-   /* Enforce stricter address checking */
-   ret = i2c_check_7bit_addr_validity_strict(client->addr);
-   if (ret) {
-   dev_err(&client->dev, "%s: invalid address\n", 
__func__);
-   return ret;
-   }
-   }
-
-   if (!client->adapter->algo->reg_slave) {
-   dev_err(&client->dev, "%s: not supported by adapter\n", 
__func__);
-   return -EOPNOTSUPP;
-   }
-
-   client->slave_cb = slave_cb;
-
-   i2c_lock_adapter(client->adapter);
-   ret = client->adapter->algo->reg_slave(client);
-   i2c_unlock_adapter(client->adapter);
-
-   if (ret) {
-   client->slave_cb = NULL;
-   dev_err(&client->dev, "%s: adapter returned error %d\n", 
__func__, ret);
-   }
-
-   return ret;
-}
-EXPORT_SYMBOL_GPL(i2c_slave_register);
-
-int i2c_slave_unregister(struct i2c_client *client)
-{
-   int ret;
-
-   if (!client->adapter->algo->unreg_slave) {
-   dev_err(&client->dev, "%s: not supported by adapter\n", 
__func__);
-   return -EOPNOTSUPP;
-   }
-
-   i2c_lock_adapter(client->adapter);
-   ret = client->adapter->algo->unreg_slave(client);
-   i2c_unlock_adapter(client->adapter);
-
-   if (ret == 0)
-   client->slave_cb = NULL;
-   else
-   dev_err(&client->dev, "%s: adapter returned error %d\n", 
__func__, ret);
-
-   return ret;
-}
-EXPORT_SYMBOL_GPL(i2c_slave_unregister);
-
-/**
- * i2c_detect_slave_mode - detect operation mode
- * @dev: The device owning the bus
- *
- * This checks the device nodes for an I2C slave by checking the address
- * used in the reg property. If the address match the I2C_OWN_SLAVE_ADDRESS
- * flag this means the device is configured to act as a I2C slave and it will
- * be listening at that address.
- *
- * Returns true if an I2C own slave address is detected, otherwise returns
- * false.
- */
-bool i2c_detect_slave_mode(struct device *dev)
-{
-   if (IS_BUILTIN(CONFIG_OF) && dev->of_node) {
-   struct device_node *child;
-   u32 reg;
-
-   for_each_child_of_node(dev->of_node, child) {
-   of_property_read_u32(child, "reg", ®);
-   if (reg & I2C_OWN_SLAVE_ADDRESS) {
-   of_node_put(child);
-   return true;
-   }
-   }
-   } else if (IS_BUILTIN(CONFIG_ACPI) && ACPI_HANDLE(dev)) {
-   dev_dbg(dev, "ACPI 

[Intel-gfx] [RFT 8/8] i2c: reformat core-base file header

2017-05-27 Thread Wolfram Sang
Finally, apply modern comment rules to the file header. The old style
looked very non-Linuxish and challenged my eyes for some time now.

I took the liberty to a) drop the two credits for the multiplexing
support here in this file because there is no significant code in the
base file and the two guys are fully credited in the i2c-mux file and b)
add my own copyright for the period of me being the maintainer.

Signed-off-by: Wolfram Sang 
---
 drivers/i2c/i2c-core-base.c | 40 +++-
 1 file changed, 19 insertions(+), 21 deletions(-)

diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c
index 78135c1deaab59..2f742ffac8754c 100644
--- a/drivers/i2c/i2c-core-base.c
+++ b/drivers/i2c/i2c-core-base.c
@@ -1,21 +1,18 @@
-/* i2c-core.c - a device driver for the iic-bus interface   */
-/* - */
-/*   Copyright (C) 1995-99 Simon G. Vogl
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-GNU General Public License for more details.*/
-/* - */
-
-/* With some changes from Kyösti Mälkki .
-   Mux support by Rodolfo Giometti  and
-   Michael Lawnick 
+/*
+ * Linux I2C core
+ *
+ * Copyright (C) 1995-99 Simon G. Vogl
+ *   With some changes from Kyösti Mälkki 
+ * Copyright (C) 2013-2017 Wolfram Sang 
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; either version 2 of the License, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 
FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 
details.
  */
 
 #define pr_fmt(fmt) "i2c-core: " fmt
@@ -57,9 +54,10 @@
 #define I2C_ADDR_7BITS_MAX 0x77
 #define I2C_ADDR_7BITS_COUNT   (I2C_ADDR_7BITS_MAX + 1)
 
-/* core_lock protects i2c_adapter_idr, and guarantees
-   that device detection, deletion of detected devices, and attach_adapter
-   calls are serialized */
+/*
+ * core_lock protects i2c_adapter_idr, and guarantees that device detection,
+ * deletion of detected devices, and attach_adapter calls are serialized
+ */
 static DEFINE_MUTEX(core_lock);
 static DEFINE_IDR(i2c_adapter_idr);
 
-- 
2.11.0

___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [RFT 0/8] i2c: refactor core and break out blocks

2017-05-27 Thread Wolfram Sang
This series was originally posted as [1] to the i2c list. There, Jani suggested
to resend the series here, so it could benefit from the CI tests seeing if I2C
still works after this huge restructuring (it did for my local tests). Thank
you very much, this is very helpful. So, I resend here as RFT. As a reference,
here is the old cover-letter:

===

Yes, I wanted to do this for years now... The I2C core became a huge monolithic
blob getting harder and harder to maintain. This series breaks out some
functional parts into seperate files. This makes the code easier to handle
because of the smaller chunks. It reduces ifdeffery because we can now handle
compilation at the Makefile level. And it helps to spread responsibility, e.g.
the ACPI maintainers do now have a dedicated file listed in MAINTAINERS.

This series was tested with a Renesas Lager board (R-Car H2 SoC). It booted
normally and all device drivers for I2C clients seem to work normally. I wired
two I2C busses together and used i2c-slave-eeprom to let one I2C IP core read
out data from the other. That all worked fine. Buildbot is also happy, it found
two issues of the first (non public) iteration. Thanks!

I did not test ACPI and hope for some assistance here :) I'd also be happy if
people could check the includes of the newly created files, there might be
missing some.

As a result, the main i2c-core file goes down from ~3600 lines to ~2000 lines.
I think this is pretty helpful. I plan to apply this for v4.13 to not block
other core changes. Let's see if we are there yet and the series is ready.
Looking forward to comments.

A branch can be found here:
git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux.git i2c/core-refactor

===

Kind regards,

   Wolfram

[1] https://lkml.org/lkml/2017/5/26/90


Wolfram Sang (8):
  i2c: rename core source file to allow refactorization
  i2c: break out slave support into seperate file
  i2c: break out smbus support into seperate file
  i2c: break out OF support into seperate file
  i2c: break out ACPI support into seperate file
  docs: i2c: dev-interface: adapt to new filenames of the i2c core
  i2c: remove unneeded includes from core
  i2c: reformat core-base file header

 Documentation/driver-api/i2c.rst|5 +-
 Documentation/i2c/dev-interface |   14 +-
 MAINTAINERS |1 +
 drivers/i2c/Makefile|7 +-
 drivers/i2c/busses/i2c-designware-core.c|2 +-
 drivers/i2c/i2c-core-acpi.c |  653 +++
 drivers/i2c/{i2c-core.c => i2c-core-base.c} | 1681 +--
 drivers/i2c/i2c-core-of.c   |  276 +
 drivers/i2c/i2c-core-slave.c|  115 ++
 drivers/i2c/i2c-core-smbus.c|  594 ++
 drivers/i2c/i2c-core.h  |   24 +
 include/trace/events/i2c.h  |  226 +---
 include/trace/events/smbus.h|  249 
 13 files changed, 1978 insertions(+), 1869 deletions(-)
 create mode 100644 drivers/i2c/i2c-core-acpi.c
 rename drivers/i2c/{i2c-core.c => i2c-core-base.c} (58%)
 create mode 100644 drivers/i2c/i2c-core-of.c
 create mode 100644 drivers/i2c/i2c-core-slave.c
 create mode 100644 drivers/i2c/i2c-core-smbus.c
 create mode 100644 include/trace/events/smbus.h

-- 
2.11.0

___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


Re: [Intel-gfx] [PATCH 0/8] i2c: refactor core and break out blocks

2017-05-27 Thread Wolfram Sang

> If you don't mind sending the whole series to the intel-gfx list (Cc'd),
> our CI will run a bunch of tests on it, exercising our use of the I2C
> adapter interfaces for display data channel and I2C over Display Port
> native aux.

Cool, that sounds very helpful! Thanks for the offer, I'll resend the
series there as RFT.



signature.asc
Description: PGP signature
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] ✓ Fi.CI.BAT: success for series starting with [v2,1/3] drm/i915/gvt: Add gvt options sanitize function

2017-05-27 Thread Patchwork
== Series Details ==

Series: series starting with [v2,1/3] drm/i915/gvt: Add gvt options sanitize 
function
URL   : https://patchwork.freedesktop.org/series/24982/
State : success

== Summary ==

Series 24982v1 Series without cover letter
https://patchwork.freedesktop.org/api/1.0/series/24982/revisions/1/mbox/

Test gem_exec_flush:
Subgroup basic-batch-kernel-default-uc:
pass   -> FAIL   (fi-snb-2600) fdo#17
Test kms_flip:
Subgroup basic-flip-vs-dpms:
dmesg-warn -> PASS   (fi-skl-6700hq) fdo#101144
Test kms_force_connector_basic:
Subgroup force-connector-state:
pass   -> SKIP   (fi-ivb-3520m) fdo#101048 +3

fdo#17 https://bugs.freedesktop.org/show_bug.cgi?id=17
fdo#101144 https://bugs.freedesktop.org/show_bug.cgi?id=101144
fdo#101048 https://bugs.freedesktop.org/show_bug.cgi?id=101048

fi-bdw-5557u total:278  pass:267  dwarn:0   dfail:0   fail:0   skip:11  
time:445s
fi-bdw-gvtdvmtotal:278  pass:256  dwarn:8   dfail:0   fail:0   skip:14  
time:440s
fi-bsw-n3050 total:278  pass:242  dwarn:0   dfail:0   fail:0   skip:36  
time:567s
fi-bxt-j4205 total:278  pass:259  dwarn:0   dfail:0   fail:0   skip:19  
time:514s
fi-byt-j1900 total:278  pass:254  dwarn:0   dfail:0   fail:0   skip:24  
time:485s
fi-byt-n2820 total:278  pass:250  dwarn:0   dfail:0   fail:0   skip:28  
time:479s
fi-hsw-4770  total:278  pass:262  dwarn:0   dfail:0   fail:0   skip:16  
time:434s
fi-hsw-4770r total:278  pass:262  dwarn:0   dfail:0   fail:0   skip:16  
time:415s
fi-ilk-650   total:278  pass:228  dwarn:0   dfail:0   fail:0   skip:50  
time:417s
fi-ivb-3520m total:278  pass:256  dwarn:0   dfail:0   fail:0   skip:22  
time:482s
fi-ivb-3770  total:278  pass:260  dwarn:0   dfail:0   fail:0   skip:18  
time:461s
fi-kbl-7500u total:278  pass:255  dwarn:5   dfail:0   fail:0   skip:18  
time:464s
fi-kbl-7560u total:278  pass:263  dwarn:5   dfail:0   fail:0   skip:10  
time:571s
fi-skl-6260u total:278  pass:268  dwarn:0   dfail:0   fail:0   skip:10  
time:466s
fi-skl-6700hqtotal:278  pass:261  dwarn:0   dfail:0   fail:0   skip:17  
time:577s
fi-skl-6700k total:278  pass:256  dwarn:4   dfail:0   fail:0   skip:18  
time:465s
fi-skl-6770hqtotal:278  pass:268  dwarn:0   dfail:0   fail:0   skip:10  
time:493s
fi-skl-gvtdvmtotal:278  pass:265  dwarn:0   dfail:0   fail:0   skip:13  
time:437s
fi-snb-2520m total:278  pass:250  dwarn:0   dfail:0   fail:0   skip:28  
time:531s
fi-snb-2600  total:278  pass:248  dwarn:0   dfail:0   fail:1   skip:29  
time:396s

bf9722dc7ed767dd56571e82950e533f69d9318e drm-tip: 2017y-05m-26d-23h-15m-13s UTC 
integration manifest
09af61c drm/i915/gvt: Return -EIO if host GuC submission is enabled when 
loading GVT-g
b87c881 drm/i915/gvt: Return -EIO if host enable_execlists not enabled when 
loading GVT-g
2913387 drm/i915/gvt: Add gvt options sanitize function

== Logs ==

For more details see: https://intel-gfx-ci.01.org/CI/Patchwork_4826/
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [PATCH v2 2/3] drm/i915/gvt: Return -EIO if host enable_execlists not enabled when loading GVT-g

2017-05-27 Thread Chuanxiao Dong
GVT-g relies on the enable_execlists parameter in i915. If this option
is not enabled for GVT-g, should return -EIO to make i915 driver loading
failed.

v2:
- Use DMR_ERROR as it is a fatal message. (Chris)

Cc: Chris Wilson 
Suggested-by: Joonas Lahtinen 
Cc: Joonas Lahtinen 
Signed-off-by: Chuanxiao Dong 
---
 drivers/gpu/drm/i915/intel_gvt.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_gvt.c b/drivers/gpu/drm/i915/intel_gvt.c
index dde9c78..e2a3f0a 100644
--- a/drivers/gpu/drm/i915/intel_gvt.c
+++ b/drivers/gpu/drm/i915/intel_gvt.c
@@ -96,8 +96,8 @@ int intel_gvt_init(struct drm_i915_private *dev_priv)
}
 
if (!i915.enable_execlists) {
-   DRM_INFO("GPU guest virtualisation [GVT-g] disabled due to 
disabled execlist submission [i915.enable_execlists module parameter]\n");
-   goto bail;
+   DRM_ERROR("i915 GVT-g loading failed due to disabled execlists 
mode\n");
+   return -EIO;
}
 
/*
-- 
2.7.4

___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [PATCH v2 1/3] drm/i915/gvt: Add gvt options sanitize function

2017-05-27 Thread Chuanxiao Dong
The intel_gvt_sanitize_options will sanitize the GVT related
options before doing initialize the GVT.

Suggested-by: Joonas Lahtinen 
Cc: Joonas Lahtinen 
Reviewed-by: Chris Wilson 
Cc: Chris Wilson 
Signed-off-by: Chuanxiao Dong 
---
 drivers/gpu/drm/i915/i915_drv.c  |  2 ++
 drivers/gpu/drm/i915/intel_gvt.c | 36 ++--
 drivers/gpu/drm/i915/intel_gvt.h |  5 +
 3 files changed, 33 insertions(+), 10 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c
index 72fb47a..9c59b22 100644
--- a/drivers/gpu/drm/i915/i915_drv.c
+++ b/drivers/gpu/drm/i915/i915_drv.c
@@ -997,6 +997,8 @@ static void intel_sanitize_options(struct drm_i915_private 
*dev_priv)
DRM_DEBUG_DRIVER("use GPU semaphores? %s\n", yesno(i915.semaphores));
 
intel_uc_sanitize_options(dev_priv);
+
+   intel_gvt_sanitize_options(dev_priv);
 }
 
 /**
diff --git a/drivers/gpu/drm/i915/intel_gvt.c b/drivers/gpu/drm/i915/intel_gvt.c
index e1ab643..dde9c78 100644
--- a/drivers/gpu/drm/i915/intel_gvt.c
+++ b/drivers/gpu/drm/i915/intel_gvt.c
@@ -51,6 +51,32 @@ static bool is_supported_device(struct drm_i915_private 
*dev_priv)
 }
 
 /**
+ * intel_gvt_sanitize_options - sanitize GVT related options
+ * @dev_priv: drm i915 private data
+ *
+ * This function is called at the i915 options sanitize stage.
+ */
+void intel_gvt_sanitize_options(struct drm_i915_private *dev_priv)
+{
+   if (!i915.enable_gvt)
+   return;
+
+   if (intel_vgpu_active(dev_priv)) {
+   DRM_INFO("GVT-g is disabled for guest\n");
+   goto bail;
+   }
+
+   if (!is_supported_device(dev_priv)) {
+   DRM_INFO("Unsupported device. GVT-g is disabled\n");
+   goto bail;
+   }
+
+   return;
+bail:
+   i915.enable_gvt = 0;
+}
+
+/**
  * intel_gvt_init - initialize GVT components
  * @dev_priv: drm i915 private data
  *
@@ -69,16 +95,6 @@ int intel_gvt_init(struct drm_i915_private *dev_priv)
return 0;
}
 
-   if (intel_vgpu_active(dev_priv)) {
-   DRM_DEBUG_DRIVER("GVT-g is disabled for guest\n");
-   goto bail;
-   }
-
-   if (!is_supported_device(dev_priv)) {
-   DRM_DEBUG_DRIVER("Unsupported device. GVT-g is disabled\n");
-   goto bail;
-   }
-
if (!i915.enable_execlists) {
DRM_INFO("GPU guest virtualisation [GVT-g] disabled due to 
disabled execlist submission [i915.enable_execlists module parameter]\n");
goto bail;
diff --git a/drivers/gpu/drm/i915/intel_gvt.h b/drivers/gpu/drm/i915/intel_gvt.h
index 25df2d6..61b2464 100644
--- a/drivers/gpu/drm/i915/intel_gvt.h
+++ b/drivers/gpu/drm/i915/intel_gvt.h
@@ -32,6 +32,7 @@ void intel_gvt_cleanup(struct drm_i915_private *dev_priv);
 int intel_gvt_init_device(struct drm_i915_private *dev_priv);
 void intel_gvt_clean_device(struct drm_i915_private *dev_priv);
 int intel_gvt_init_host(void);
+void intel_gvt_sanitize_options(struct drm_i915_private *dev_priv);
 #else
 static inline int intel_gvt_init(struct drm_i915_private *dev_priv)
 {
@@ -40,6 +41,10 @@ static inline int intel_gvt_init(struct drm_i915_private 
*dev_priv)
 static inline void intel_gvt_cleanup(struct drm_i915_private *dev_priv)
 {
 }
+
+static inline void intel_gvt_sanitize_options(struct drm_i915_private 
*dev_priv)
+{
+}
 #endif
 
 #endif /* _INTEL_GVT_H_ */
-- 
2.7.4

___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [PATCH v2 3/3] drm/i915/gvt: Return -EIO if host GuC submission is enabled when loading GVT-g

2017-05-27 Thread Chuanxiao Dong
Currently GVT-g cannot work properly when host GuC submission is
enabled, so make the driver loading failed in this case.

v2:
- use DRM_ERROR as it is a fatal message. (Chris)

Suggested-by: Joonas Lahtinen 
Suggested-by: Chris Wilson 
Cc: Joonas Lahtinen 
Cc: Chris Wilson 
Cc: Zhenyu Wang 
Signed-off-by: Chuanxiao Dong 
---
 drivers/gpu/drm/i915/intel_gvt.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/drivers/gpu/drm/i915/intel_gvt.c b/drivers/gpu/drm/i915/intel_gvt.c
index e2a3f0a..52d5b82 100644
--- a/drivers/gpu/drm/i915/intel_gvt.c
+++ b/drivers/gpu/drm/i915/intel_gvt.c
@@ -100,6 +100,11 @@ int intel_gvt_init(struct drm_i915_private *dev_priv)
return -EIO;
}
 
+   if (i915.enable_guc_submission) {
+   DRM_ERROR("i915 GVT-g loading failed due to Graphics 
virtualization is not yet supported with GuC submission\n");
+   return -EIO;
+   }
+
/*
 * We're not in host or fail to find a MPT module, disable GVT-g
 */
-- 
2.7.4

___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [PATCH v2 0/3] drm/i915/gvt: GVT-g options sanitize series

2017-05-27 Thread Chuanxiao Dong
In this series, options sanitize API is added for GVT-g, and GVT-g init
will fail with -EIO if detected incompatible i915 parameters.

Chuanxiao Dong (3):
  drm/i915/gvt: Add gvt options sanitize function
  drm/i915/gvt: Return -EIO if host enable_execlists not enabled when
loading GVT-g
  drm/i915/gvt: Return -EIO if host GuC submission is enabled when
loading GVT-g

 drivers/gpu/drm/i915/i915_drv.c  |  2 ++
 drivers/gpu/drm/i915/intel_gvt.c | 43 ++--
 drivers/gpu/drm/i915/intel_gvt.h |  5 +
 3 files changed, 39 insertions(+), 11 deletions(-)

-- 
2.7.4

___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


Re: [Intel-gfx] [PATCH 1/3] drm/i915/gvt: Add gvt options sanitize function

2017-05-27 Thread Dong, Chuanxiao
> -Original Message-
> From: intel-gvt-dev [mailto:intel-gvt-dev-boun...@lists.freedesktop.org] On
> Behalf Of Chris Wilson
> Sent: Friday, May 26, 2017 7:09 PM
> To: Dong, Chuanxiao 
> Cc: intel-gfx@lists.freedesktop.org; intel-gvt-...@lists.freedesktop.org
> Subject: Re: [Intel-gfx] [PATCH 1/3] drm/i915/gvt: Add gvt options sanitize
> function
> 
> On Fri, May 26, 2017 at 11:04:17AM +0800, Chuanxiao Dong wrote:
> > The intel_gvt_sanitize_options will sanitize the GVT-g related options
> > before doing GVT-g init.
> >
> > Suggested-by: Joonas Lahtinen 
> > Cc: Joonas Lahtinen 
> > Signed-off-by: Chuanxiao Dong 
> > ---
> >  drivers/gpu/drm/i915/i915_drv.c  |  2 ++
> > drivers/gpu/drm/i915/intel_gvt.c | 36
> > ++--
> >  drivers/gpu/drm/i915/intel_gvt.h |  5 +
> >  3 files changed, 33 insertions(+), 10 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/i915/i915_drv.c
> > b/drivers/gpu/drm/i915/i915_drv.c index 72fb47a..9c59b22 100644
> > --- a/drivers/gpu/drm/i915/i915_drv.c
> > +++ b/drivers/gpu/drm/i915/i915_drv.c
> > @@ -997,6 +997,8 @@ static void intel_sanitize_options(struct
> drm_i915_private *dev_priv)
> > DRM_DEBUG_DRIVER("use GPU semaphores? %s\n",
> > yesno(i915.semaphores));
> >
> > intel_uc_sanitize_options(dev_priv);
> > +
> > +   intel_gvt_sanitize_options(dev_priv);
> >  }
> >
> >  /**
> > diff --git a/drivers/gpu/drm/i915/intel_gvt.c
> > b/drivers/gpu/drm/i915/intel_gvt.c
> > index e1ab643..dde9c78 100644
> > --- a/drivers/gpu/drm/i915/intel_gvt.c
> > +++ b/drivers/gpu/drm/i915/intel_gvt.c
> > @@ -51,6 +51,32 @@ static bool is_supported_device(struct
> > drm_i915_private *dev_priv)  }
> >
> >  /**
> > + * intel_gvt_sanitize_options - sanitize GVT related options
> > + * @dev_priv: drm i915 private data
> > + *
> > + * This function is called at the i915 options sanitize stage.
> > + */
> > +void intel_gvt_sanitize_options(struct drm_i915_private *dev_priv) {
> > +   if (!i915.enable_gvt)
> > +   return;
> > +
> > +   if (intel_vgpu_active(dev_priv)) {
> > +   DRM_INFO("GVT-g is disabled for guest\n");
> > +   goto bail;
> > +   }
> > +
> > +   if (!is_supported_device(dev_priv)) {
> > +   DRM_INFO("Unsupported device. GVT-g is disabled\n");
> > +   goto bail;
> > +   }
> 
> Good. I came back to check that we didn't trigger an EIO if the device wasn't
> supported (and only an EIO if the user gave conflicting params).
> 
> Reviewed-by: Chris Wilson  -Chris
> 
Thanks Chris. Patch 2/3 and 3/3 will be updated in v2 to use DRM_ERROR.

Thanks
Chuanxiao
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] ✗ Fi.CI.BAT: failure for drm/i915/gvt: dma-buf support for GVT-g (rev6)

2017-05-27 Thread Patchwork
== Series Details ==

Series: drm/i915/gvt: dma-buf support for GVT-g (rev6)
URL   : https://patchwork.freedesktop.org/series/23686/
State : failure

== Summary ==

  CHK include/config/kernel.release
  CHK include/generated/uapi/linux/version.h
  CHK include/generated/utsrelease.h
  CHK include/generated/bounds.h
  CHK include/generated/timeconst.h
  CHK include/generated/asm-offsets.h
  CALLscripts/checksyscalls.sh
  CHK scripts/mod/devicetable-offsets.h
  CHK include/generated/compile.h
  CHK kernel/config_data.h
  CC [M]  drivers/gpu/drm/i915/i915_drv.o
In file included from drivers/gpu/drm/i915/i915_vma.h:34:0,
 from drivers/gpu/drm/i915/intel_uc.h:31,
 from drivers/gpu/drm/i915/i915_drv.h:61,
 from drivers/gpu/drm/i915/i915_drv.c:49:
drivers/gpu/drm/i915/i915_gem_object.h:40:1: error: expected 
specifier-qualifier-list before ‘<<’ token
 <<< 391b5aa3660577581466b0d4594e1a61fae843bd
 ^
drivers/gpu/drm/i915/i915_gem_object.h:40:9: error: invalid suffix 
"b5aa3660577581466b0d4594e1a61fae843bd" on integer constant
 <<< 391b5aa3660577581466b0d4594e1a61fae843bd
 ^
drivers/gpu/drm/i915/i915_gem_object.h:44:0: error: 
"I915_GEM_OBJECT_HAS_STRUCT_PAGE" redefined [-Werror]
 #define I915_GEM_OBJECT_HAS_STRUCT_PAGE 0x1
 ^
drivers/gpu/drm/i915/i915_gem_object.h:41:0: note: this is the location of the 
previous definition
 #define I915_GEM_OBJECT_HAS_STRUCT_PAGE BIT(0)
 ^
drivers/gpu/drm/i915/i915_gem_object.h:45:0: error: 
"I915_GEM_OBJECT_IS_SHRINKABLE" redefined [-Werror]
 #define I915_GEM_OBJECT_IS_SHRINKABLE   0x2
 ^
drivers/gpu/drm/i915/i915_gem_object.h:42:0: note: this is the location of the 
previous definition
 #define I915_GEM_OBJECT_IS_SHRINKABLE   BIT(1)
 ^
cc1: all warnings being treated as errors
scripts/Makefile.build:302: recipe for target 'drivers/gpu/drm/i915/i915_drv.o' 
failed
make[4]: *** [drivers/gpu/drm/i915/i915_drv.o] Error 1
scripts/Makefile.build:561: recipe for target 'drivers/gpu/drm/i915' failed
make[3]: *** [drivers/gpu/drm/i915] Error 2
scripts/Makefile.build:561: recipe for target 'drivers/gpu/drm' failed
make[2]: *** [drivers/gpu/drm] Error 2
scripts/Makefile.build:561: recipe for target 'drivers/gpu' failed
make[1]: *** [drivers/gpu] Error 2
Makefile:1016: recipe for target 'drivers' failed
make: *** [drivers] Error 2

___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [PATCH v6 2/6] drm/i915/gvt: OpRegion support for GVT-g

2017-05-27 Thread Xiaoguang Chen
OpRegion is needed to support display related operation for
intel vgpu.

A vfio device region is added to intel vgpu to deliver the
host OpRegion information to user space so user space can
construct the OpRegion for vgpu.

Signed-off-by: Bing Niu 
Signed-off-by: Xiaoguang Chen 
---
 drivers/gpu/drm/i915/gvt/kvmgt.c| 97 +
 drivers/gpu/drm/i915/gvt/opregion.c |  8 ++-
 2 files changed, 104 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/i915/gvt/kvmgt.c b/drivers/gpu/drm/i915/gvt/kvmgt.c
index 3c6a02b..389f072 100644
--- a/drivers/gpu/drm/i915/gvt/kvmgt.c
+++ b/drivers/gpu/drm/i915/gvt/kvmgt.c
@@ -53,6 +53,8 @@ static const struct intel_gvt_ops *intel_gvt_ops;
 #define VFIO_PCI_INDEX_TO_OFFSET(index) ((u64)(index) << VFIO_PCI_OFFSET_SHIFT)
 #define VFIO_PCI_OFFSET_MASK(((u64)(1) << VFIO_PCI_OFFSET_SHIFT) - 1)
 
+#define OPREGION_SIGNATURE "IntelGraphicsMem"
+
 struct vfio_region;
 struct intel_vgpu_regops {
size_t (*rw)(struct intel_vgpu *vgpu, char *buf,
@@ -436,6 +438,92 @@ static void kvmgt_protect_table_del(struct 
kvmgt_guest_info *info,
}
 }
 
+static size_t intel_vgpu_reg_rw_opregion(struct intel_vgpu *vgpu, char *buf,
+   size_t count, loff_t *ppos, bool iswrite)
+{
+   unsigned int i = VFIO_PCI_OFFSET_TO_INDEX(*ppos) -
+   VFIO_PCI_NUM_REGIONS;
+   void *base = vgpu->vdev.region[i].data;
+   loff_t pos = *ppos & VFIO_PCI_OFFSET_MASK;
+
+   if (pos >= vgpu->vdev.region[i].size || iswrite) {
+   gvt_vgpu_err("invalid op or offset for Intel vgpu OpRegion\n");
+   return -EINVAL;
+   }
+   count = min(count, (size_t)(vgpu->vdev.region[i].size - pos));
+   memcpy(buf, base + pos, count);
+
+   return count;
+}
+
+static void intel_vgpu_reg_release_opregion(struct intel_vgpu *vgpu,
+   struct vfio_region *region)
+{
+   memunmap(region->data);
+}
+
+static const struct intel_vgpu_regops intel_vgpu_regops_opregion = {
+   .rw = intel_vgpu_reg_rw_opregion,
+   .release = intel_vgpu_reg_release_opregion,
+};
+
+static int intel_vgpu_register_reg(struct intel_vgpu *vgpu,
+   unsigned int type, unsigned int subtype,
+   const struct intel_vgpu_regops *ops,
+   size_t size, u32 flags, void *data)
+{
+   struct vfio_region *region;
+
+   region = krealloc(vgpu->vdev.region,
+   (vgpu->vdev.num_regions + 1) * sizeof(*region),
+   GFP_KERNEL);
+   if (!region)
+   return -ENOMEM;
+
+   vgpu->vdev.region = region;
+   vgpu->vdev.region[vgpu->vdev.num_regions].type = type;
+   vgpu->vdev.region[vgpu->vdev.num_regions].subtype = subtype;
+   vgpu->vdev.region[vgpu->vdev.num_regions].ops = ops;
+   vgpu->vdev.region[vgpu->vdev.num_regions].size = size;
+   vgpu->vdev.region[vgpu->vdev.num_regions].flags = flags;
+   vgpu->vdev.region[vgpu->vdev.num_regions].data = data;
+   vgpu->vdev.num_regions++;
+
+   return 0;
+}
+
+static int intel_vgpu_reg_init_opregion(struct intel_vgpu *vgpu)
+{
+   unsigned int addr;
+   void *base;
+   int ret;
+
+   addr = vgpu->gvt->opregion.opregion_pa;
+   if (!addr || !(~addr))
+   return -ENODEV;
+
+   base = memremap(addr, OPREGION_SIZE, MEMREMAP_WB);
+   if (!base)
+   return -ENOMEM;
+
+   if (memcmp(base, OPREGION_SIGNATURE, 16)) {
+   memunmap(base);
+   return -EINVAL;
+   }
+
+   ret = intel_vgpu_register_reg(vgpu,
+   PCI_VENDOR_ID_INTEL | VFIO_REGION_TYPE_PCI_VENDOR_TYPE,
+   VFIO_REGION_SUBTYPE_INTEL_IGD_OPREGION,
+   &intel_vgpu_regops_opregion, OPREGION_SIZE,
+   VFIO_REGION_INFO_FLAG_READ, base);
+   if (ret) {
+   memunmap(base);
+   return ret;
+   }
+
+   return ret;
+}
+
 static int intel_vgpu_create(struct kobject *kobj, struct mdev_device *mdev)
 {
struct intel_vgpu *vgpu = NULL;
@@ -467,6 +555,15 @@ static int intel_vgpu_create(struct kobject *kobj, struct 
mdev_device *mdev)
vgpu->vdev.mdev = mdev;
mdev_set_drvdata(mdev, vgpu);
 
+   ret = intel_vgpu_reg_init_opregion(vgpu);
+   if (ret) {
+   gvt_vgpu_err("create OpRegion failed\n");
+   goto out;
+   }
+
+   gvt_dbg_core("create OpRegion succeeded for mdev:%s\n",
+   dev_name(mdev_dev(mdev)));
+
gvt_dbg_core("intel_vgpu_create succeeded for mdev: %s\n",
 dev_name(mdev_dev(mdev)));
ret = 0;
diff --git a/drivers/gpu/drm/i915/gvt/opregion.c 
b/drivers/gpu/drm/i915/gvt/opregion.c
index 3117991..5c7496d 100644
--- a/drivers/gpu/drm/i915/gvt/opregion.c
+++ b/drivers/gpu/drm/i915/gvt/opregion.c
@@ -114,6 +114,7 @@ void intel_vgpu_clean_opregion(struct intel_vgpu *vgpu)
 int intel_vgpu_in

[Intel-gfx] [PATCH v6 5/6] drm/i915/gvt: Dmabuf support for GVT-g

2017-05-27 Thread Xiaoguang Chen
dmabuf for GVT-g can be exported to users who can use the dmabuf to show
the desktop of vm which use intel vgpu.

Currently we provide query and create new dmabuf operations.

Users of dmabuf can cache some created dmabufs and related information
such as the framebuffer's address, size, tiling mode, width, height etc.
When refresh the screen first query the currnet vgpu's frambuffer and
compare with the cached ones(address, size, tiling, width, height etc)
if found one then reuse the found dmabuf to gain performance improvment.

If there is no dmabuf created yet or not found in the cached dmabufs then
need to create a new dmabuf. To create a dmabuf first a gem object will
be created and the backing storage of this gem object is the vgpu's
framebuffer(primary/cursor).
Set caching mode, change tiling mode and set domains of this gem object
is not supported.
Then associate this gem object to a dmabuf and export this dmabuf.
A file descriptor will be generated for this dmabuf and this file
descriptor can be sent to user space to do display.

Signed-off-by: Xiaoguang Chen 
---
 drivers/gpu/drm/i915/gvt/Makefile  |   2 +-
 drivers/gpu/drm/i915/gvt/dmabuf.c  | 269 +
 drivers/gpu/drm/i915/gvt/dmabuf.h  |  37 +
 drivers/gpu/drm/i915/gvt/gvt.h |   1 +
 drivers/gpu/drm/i915/i915_gem.c|  26 +++-
 drivers/gpu/drm/i915/i915_gem_object.h |   9 ++
 6 files changed, 342 insertions(+), 2 deletions(-)
 create mode 100644 drivers/gpu/drm/i915/gvt/dmabuf.c
 create mode 100644 drivers/gpu/drm/i915/gvt/dmabuf.h

diff --git a/drivers/gpu/drm/i915/gvt/Makefile 
b/drivers/gpu/drm/i915/gvt/Makefile
index 192ca26..e480f7d 100644
--- a/drivers/gpu/drm/i915/gvt/Makefile
+++ b/drivers/gpu/drm/i915/gvt/Makefile
@@ -2,7 +2,7 @@ GVT_DIR := gvt
 GVT_SOURCE := gvt.o aperture_gm.o handlers.o vgpu.o trace_points.o firmware.o \
interrupt.o gtt.o cfg_space.o opregion.o mmio.o display.o edid.o \
execlist.o scheduler.o sched_policy.o render.o cmd_parser.o \
-   fb_decoder.o
+   fb_decoder.o dmabuf.o
 
 ccflags-y  += -I$(src) -I$(src)/$(GVT_DIR) -Wall
 i915-y += $(addprefix $(GVT_DIR)/, 
$(GVT_SOURCE))
diff --git a/drivers/gpu/drm/i915/gvt/dmabuf.c 
b/drivers/gpu/drm/i915/gvt/dmabuf.c
new file mode 100644
index 000..c831e91
--- /dev/null
+++ b/drivers/gpu/drm/i915/gvt/dmabuf.c
@@ -0,0 +1,269 @@
+/*
+ * Copyright 2017 Intel Corporation. All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Authors:
+ *Zhiyuan Lv 
+ *
+ * Contributors:
+ *Xiaoguang Chen 
+ */
+
+#include 
+#include 
+#include 
+
+#include "i915_drv.h"
+#include "gvt.h"
+
+#define GEN8_DECODE_PTE(pte) (pte & GENMASK_ULL(63, 12))
+
+static struct sg_table *intel_vgpu_gem_get_pages(
+   struct drm_i915_gem_object *obj)
+{
+   struct drm_i915_private *dev_priv = to_i915(obj->base.dev);
+   struct sg_table *st;
+   struct scatterlist *sg;
+   int i, ret;
+   gen8_pte_t __iomem *gtt_entries;
+   struct intel_vgpu_fb_info *fb_info;
+
+   fb_info = (struct intel_vgpu_fb_info *)obj->gvt_info;
+   if (WARN_ON(!fb_info))
+   return ERR_PTR(-ENODEV);
+
+   st = kmalloc(sizeof(*st), GFP_KERNEL);
+   if (!st) {
+   ret = -ENOMEM;
+   return ERR_PTR(ret);
+   }
+
+   ret = sg_alloc_table(st, fb_info->fb_size, GFP_KERNEL);
+   if (ret) {
+   kfree(st);
+   return ERR_PTR(ret);
+   }
+   gtt_entries = (gen8_pte_t __iomem *)dev_priv->ggtt.gsm +
+   (fb_info->fb_addr >> PAGE_SHIFT);
+   for_each_sg(st->sgl, sg, fb_info->fb_size, i) {
+   sg->offset = 0;
+   sg->length = PAGE_SIZE;
+   sg_dma_address(sg) =
+   GEN8_DECODE_PTE(readq(>t_entries[i]));
+  

[Intel-gfx] [PATCH v6 6/6] drm/i915/gvt: Adding interface so user space can get the dma-buf

2017-05-27 Thread Xiaoguang Chen
User space should create the management fd for the dma-buf operation first.
Then user can query the plane information and create dma-buf if necessary
using the management fd.

Signed-off-by: Xiaoguang Chen 
---
 drivers/gpu/drm/i915/gvt/dmabuf.c |  12 
 drivers/gpu/drm/i915/gvt/dmabuf.h |   5 ++
 drivers/gpu/drm/i915/gvt/gvt.c|   2 +
 drivers/gpu/drm/i915/gvt/gvt.h|   5 ++
 drivers/gpu/drm/i915/gvt/kvmgt.c  | 144 ++
 drivers/gpu/drm/i915/gvt/vgpu.c   |   1 +
 6 files changed, 169 insertions(+)

diff --git a/drivers/gpu/drm/i915/gvt/dmabuf.c 
b/drivers/gpu/drm/i915/gvt/dmabuf.c
index c831e91..9759e9a 100644
--- a/drivers/gpu/drm/i915/gvt/dmabuf.c
+++ b/drivers/gpu/drm/i915/gvt/dmabuf.c
@@ -226,6 +226,7 @@ int intel_vgpu_create_dmabuf(struct intel_vgpu *vgpu, void 
*args)
struct vfio_vgpu_dmabuf_info *gvt_dmabuf = args;
struct intel_vgpu_fb_info *fb_info;
int ret;
+   struct intel_vgpu_dmabuf_obj *dmabuf_obj;
 
ret = intel_vgpu_get_plane_info(dev, vgpu, &gvt_dmabuf->plane_info);
if (ret != 0)
@@ -263,6 +264,17 @@ int intel_vgpu_create_dmabuf(struct intel_vgpu *vgpu, void 
*args)
gvt_vgpu_err("create dma-buf fd failed ret:%d\n", ret);
return ret;
}
+   dmabuf_obj = kmalloc(sizeof(*dmabuf_obj), GFP_KERNEL);
+   if (dmabuf_obj == NULL) {
+   kfree(fb_info);
+   i915_gem_object_put(obj);
+   gvt_vgpu_err("alloc dmabuf_obj failed\n");
+   return -ENOMEM;
+   }
+   dmabuf_obj->obj = obj;
+   INIT_LIST_HEAD(&dmabuf_obj->list);
+   list_add_tail(&dmabuf_obj->list, &vgpu->dmabuf_obj_list_head);
+
gvt_dmabuf->fd = ret;
 
return 0;
diff --git a/drivers/gpu/drm/i915/gvt/dmabuf.h 
b/drivers/gpu/drm/i915/gvt/dmabuf.h
index 8be9979..cafa781 100644
--- a/drivers/gpu/drm/i915/gvt/dmabuf.h
+++ b/drivers/gpu/drm/i915/gvt/dmabuf.h
@@ -31,6 +31,11 @@ struct intel_vgpu_fb_info {
uint32_t fb_size;
 };
 
+struct intel_vgpu_dmabuf_obj {
+   struct drm_i915_gem_object *obj;
+   struct list_head list;
+};
+
 int intel_vgpu_query_plane(struct intel_vgpu *vgpu, void *args);
 int intel_vgpu_create_dmabuf(struct intel_vgpu *vgpu, void *args);
 
diff --git a/drivers/gpu/drm/i915/gvt/gvt.c b/drivers/gpu/drm/i915/gvt/gvt.c
index 2032917..dbc3f86 100644
--- a/drivers/gpu/drm/i915/gvt/gvt.c
+++ b/drivers/gpu/drm/i915/gvt/gvt.c
@@ -54,6 +54,8 @@ static const struct intel_gvt_ops intel_gvt_ops = {
.vgpu_reset = intel_gvt_reset_vgpu,
.vgpu_activate = intel_gvt_activate_vgpu,
.vgpu_deactivate = intel_gvt_deactivate_vgpu,
+   .vgpu_query_plane = intel_vgpu_query_plane,
+   .vgpu_create_dmabuf = intel_vgpu_create_dmabuf,
 };
 
 /**
diff --git a/drivers/gpu/drm/i915/gvt/gvt.h b/drivers/gpu/drm/i915/gvt/gvt.h
index 763a8c5..a855797 100644
--- a/drivers/gpu/drm/i915/gvt/gvt.h
+++ b/drivers/gpu/drm/i915/gvt/gvt.h
@@ -185,8 +185,11 @@ struct intel_vgpu {
struct kvm *kvm;
struct work_struct release_work;
atomic_t released;
+   struct vfio_device *vfio_device;
} vdev;
 #endif
+   int dmabuf_mgr_fd;
+   struct list_head dmabuf_obj_list_head;
 };
 
 struct intel_gvt_gm {
@@ -467,6 +470,8 @@ struct intel_gvt_ops {
void (*vgpu_reset)(struct intel_vgpu *);
void (*vgpu_activate)(struct intel_vgpu *);
void (*vgpu_deactivate)(struct intel_vgpu *);
+   int (*vgpu_query_plane)(struct intel_vgpu *vgpu, void *);
+   int (*vgpu_create_dmabuf)(struct intel_vgpu *vgpu, void *);
 };
 
 
diff --git a/drivers/gpu/drm/i915/gvt/kvmgt.c b/drivers/gpu/drm/i915/gvt/kvmgt.c
index 389f072..a079080 100644
--- a/drivers/gpu/drm/i915/gvt/kvmgt.c
+++ b/drivers/gpu/drm/i915/gvt/kvmgt.c
@@ -41,6 +41,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "i915_drv.h"
 #include "gvt.h"
@@ -524,6 +525,125 @@ static int intel_vgpu_reg_init_opregion(struct intel_vgpu 
*vgpu)
return ret;
 }
 
+static int kvmgt_get_vfio_device(struct intel_vgpu *vgpu)
+{
+   struct vfio_device *device;
+
+   device = vfio_device_get_from_dev(mdev_dev(vgpu->vdev.mdev));
+   if (device == NULL)
+   return -ENODEV;
+   vgpu->vdev.vfio_device = device;
+
+   return 0;
+}
+
+static void kvmgt_put_vfio_device(struct intel_vgpu *vgpu)
+{
+   vfio_device_put(vgpu->vdev.vfio_device);
+}
+
+static int intel_vgpu_dmabuf_mgr_fd_mmap(struct file *file,
+   struct vm_area_struct *vma)
+{
+   return -EPERM;
+}
+
+static int intel_vgpu_dmabuf_mgr_fd_release(struct inode *inode,
+   struct file *filp)
+{
+   struct intel_vgpu *vgpu = filp->private_data;
+   struct intel_vgpu_dmabuf_obj *obj;
+   struct list_head *pos;
+
+   if (WARN_ON(!vgpu->vdev.vfio_device))
+   return -ENODEV;
+
+   list_for_each(pos, &vgpu->dmabuf_obj_list_head) {
+ 

[Intel-gfx] [PATCH v6 3/6] drm/i915/gvt: Frame buffer decoder support for GVT-g

2017-05-27 Thread Xiaoguang Chen
decode frambuffer attributes of primary, cursor and sprite plane

Signed-off-by: Xiaoguang Chen 
---
 drivers/gpu/drm/i915/gvt/Makefile |   3 +-
 drivers/gpu/drm/i915/gvt/display.c|   2 +-
 drivers/gpu/drm/i915/gvt/display.h|   2 +
 drivers/gpu/drm/i915/gvt/fb_decoder.c | 479 ++
 drivers/gpu/drm/i915/gvt/fb_decoder.h | 166 
 drivers/gpu/drm/i915/gvt/gvt.h|   1 +
 6 files changed, 651 insertions(+), 2 deletions(-)
 create mode 100644 drivers/gpu/drm/i915/gvt/fb_decoder.c
 create mode 100644 drivers/gpu/drm/i915/gvt/fb_decoder.h

diff --git a/drivers/gpu/drm/i915/gvt/Makefile 
b/drivers/gpu/drm/i915/gvt/Makefile
index b123c20..192ca26 100644
--- a/drivers/gpu/drm/i915/gvt/Makefile
+++ b/drivers/gpu/drm/i915/gvt/Makefile
@@ -1,7 +1,8 @@
 GVT_DIR := gvt
 GVT_SOURCE := gvt.o aperture_gm.o handlers.o vgpu.o trace_points.o firmware.o \
interrupt.o gtt.o cfg_space.o opregion.o mmio.o display.o edid.o \
-   execlist.o scheduler.o sched_policy.o render.o cmd_parser.o
+   execlist.o scheduler.o sched_policy.o render.o cmd_parser.o \
+   fb_decoder.o
 
 ccflags-y  += -I$(src) -I$(src)/$(GVT_DIR) -Wall
 i915-y += $(addprefix $(GVT_DIR)/, 
$(GVT_SOURCE))
diff --git a/drivers/gpu/drm/i915/gvt/display.c 
b/drivers/gpu/drm/i915/gvt/display.c
index e0261fc..f5f63c5 100644
--- a/drivers/gpu/drm/i915/gvt/display.c
+++ b/drivers/gpu/drm/i915/gvt/display.c
@@ -67,7 +67,7 @@ static int edp_pipe_is_enabled(struct intel_vgpu *vgpu)
return 1;
 }
 
-static int pipe_is_enabled(struct intel_vgpu *vgpu, int pipe)
+int pipe_is_enabled(struct intel_vgpu *vgpu, int pipe)
 {
struct drm_i915_private *dev_priv = vgpu->gvt->dev_priv;
 
diff --git a/drivers/gpu/drm/i915/gvt/display.h 
b/drivers/gpu/drm/i915/gvt/display.h
index d73de22..b46b868 100644
--- a/drivers/gpu/drm/i915/gvt/display.h
+++ b/drivers/gpu/drm/i915/gvt/display.h
@@ -179,4 +179,6 @@ int intel_vgpu_init_display(struct intel_vgpu *vgpu, u64 
resolution);
 void intel_vgpu_reset_display(struct intel_vgpu *vgpu);
 void intel_vgpu_clean_display(struct intel_vgpu *vgpu);
 
+int pipe_is_enabled(struct intel_vgpu *vgpu, int pipe);
+
 #endif
diff --git a/drivers/gpu/drm/i915/gvt/fb_decoder.c 
b/drivers/gpu/drm/i915/gvt/fb_decoder.c
new file mode 100644
index 000..d4404fd
--- /dev/null
+++ b/drivers/gpu/drm/i915/gvt/fb_decoder.c
@@ -0,0 +1,479 @@
+/*
+ * Copyright(c) 2011-2016 Intel Corporation. All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 
THE
+ * SOFTWARE.
+ *
+ * Authors:
+ *Kevin Tian 
+ *
+ * Contributors:
+ *Bing Niu 
+ *Xu Han 
+ *Ping Gao 
+ *Xiaoguang Chen 
+ *Yang Liu 
+ *
+ */
+
+#include 
+#include "i915_drv.h"
+#include "gvt.h"
+
+/* The below definitions are required by guest. */
+// [63:0] x:R:G:B 16:16:16:16 little endian
+#define DRM_FORMAT_XRGB161616_GVT  fourcc_code('X', 'R', '4', '8')
+// [63:0] x:B:G:R 16:16:16:16 little endian
+#define DRM_FORMAT_XBGR161616_GVT  fourcc_code('X', 'B', '4', '8')
+
+#define FORMAT_NUM 16
+struct pixel_format {
+   int drm_format; /* Pixel format in DRM definition */
+   int bpp;/* Bits per pixel, 0 indicates invalid */
+   char *desc; /* The description */
+};
+
+/* non-supported format has bpp default to 0 */
+static struct pixel_format primary_pixel_formats[FORMAT_NUM] = {
+   [0x2] = {DRM_FORMAT_C8, 8, "8-bit Indexed"},
+   [0x5] = {DRM_FORMAT_RGB565, 16, "16-bit BGRX (5:6:5 MSB-R:G:B)"},
+   [0x6] = {DRM_FORMAT_XRGB, 32,
+   "32-bit BGRX (8:8:8:8 MSB-X:R:G:B)"},
+   [0x8] = {DRM_FORMAT_XBGR2101010, 32,
+   "32-bit RGBX (2:10:10:10 MSB-X:B:G:R)"},
+   [0xa] = {DRM_FORMAT_XRGB2101010, 32,
+   "32-bit BGRX (2:10:10:10 MSB-X:R:G:B)"},
+   [0xc] = {DRM_FORMAT_XRGB161616_

[Intel-gfx] [PATCH v6 0/6] drm/i915/gvt: Dma-buf support for GVT-g

2017-05-27 Thread Xiaoguang Chen
v5->v6:
1) align the dma-buf life cycle with the vfio device.
2) add the dma-buf releated operations in a separate patch.
3) i915 releated changes.

v4->v5:
1) fix bug while checking whether the gem obj is gvt's dma-buf when user
change caching mode or domains. Add a helper function to do it.
2) add definition for the query plane and create dma-buf.

v3->v4:
1) fix bug while checking whether the gem obj is gvt's dma-buf when set
caching mode or doamins.

v2->v3:
1) add a field gvt_plane_info in the drm_i915_gem_obj structure to save
the decoded plane information to avoid look up while need the plane info.
2) declare a new flag I915_GEM_OBJECT_IS_GVT_DMABUF in drm_i915_gem_object
to represent the gem obj for gvt's dma-buf. The tiling mode, caching mode
and domains can not be changed for this kind of gem object.
3) change dma-buf related information to be more generic. So other vendor
can use the same interface.

v1->v2:
1) create a management fd for dma-buf operations.
2) alloc gem object's backing storage in gem obj's get_pages() callback.

This patch set adds the dma-buf support for intel GVT-g.
dma-buf is a uniform mechanism to share DMA buffers across different
devices and sub-systems.
dma-buf for intel GVT-g is mainly used to share the vgpu's framebuffer
to other users or sub-systems so they can use the dma-buf to show the
desktop of a vm which uses intel vgpu.

The main idea is we create a gem object and set vgpu's framebuffer as
the backing storage of this gem object. And associate this gem obj
to a dma-buf object then export this dma-buf at the meantime
generate a file descriptor for this dma-buf. Finally deliver this file
descriptor to user space. And user can use this dma-buf fd to do render
or other operations.
User need to create a fd(for intel GVT-g dma-buf support it is a:dma-buf
management fd) then user can use this fd to query the plane information
or create a dma-buf. The life cycle of this fd is managed by GVT-g user
do not need to care about that.

We have an example program on how to use the dma-buf. You can download
the program to have a try. Good luck :)
git repo: https://github.com/01org/igvtg-qemu branch:kvmgt_dmabuf_example

Xiaoguang Chen (6):
  drm/i915/gvt: Extend the GVT-g architecture to support vfio device
region
  drm/i915/gvt: OpRegion support for GVT-g
  drm/i915/gvt: Frame buffer decoder support for GVT-g
  vfio: Define vfio based vgpu's dma-buf operations
  drm/i915/gvt: Dmabuf support for GVT-g
  drm/i915/gvt: Adding interface so user space can get the dma-buf

 drivers/gpu/drm/i915/gvt/Makefile  |   3 +-
 drivers/gpu/drm/i915/gvt/display.c |   2 +-
 drivers/gpu/drm/i915/gvt/display.h |   2 +
 drivers/gpu/drm/i915/gvt/dmabuf.c  | 281 +++
 drivers/gpu/drm/i915/gvt/dmabuf.h  |  42 +++
 drivers/gpu/drm/i915/gvt/fb_decoder.c  | 479 +
 drivers/gpu/drm/i915/gvt/fb_decoder.h  | 166 
 drivers/gpu/drm/i915/gvt/gvt.c |   2 +
 drivers/gpu/drm/i915/gvt/gvt.h |   7 +
 drivers/gpu/drm/i915/gvt/kvmgt.c   | 262 +-
 drivers/gpu/drm/i915/gvt/opregion.c|   8 +-
 drivers/gpu/drm/i915/gvt/vgpu.c|   1 +
 drivers/gpu/drm/i915/i915_gem.c|  26 +-
 drivers/gpu/drm/i915/i915_gem_object.h |   9 +
 include/uapi/linux/vfio.h  |  50 
 15 files changed, 1333 insertions(+), 7 deletions(-)
 create mode 100644 drivers/gpu/drm/i915/gvt/dmabuf.c
 create mode 100644 drivers/gpu/drm/i915/gvt/dmabuf.h
 create mode 100644 drivers/gpu/drm/i915/gvt/fb_decoder.c
 create mode 100644 drivers/gpu/drm/i915/gvt/fb_decoder.h

-- 
2.7.4

___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [PATCH v6 1/6] drm/i915/gvt: Extend the GVT-g architecture to support vfio device region

2017-05-27 Thread Xiaoguang Chen
Signed-off-by: Xiaoguang Chen 
---
 drivers/gpu/drm/i915/gvt/kvmgt.c | 21 ++---
 1 file changed, 18 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/i915/gvt/kvmgt.c b/drivers/gpu/drm/i915/gvt/kvmgt.c
index 1ae0b40..3c6a02b 100644
--- a/drivers/gpu/drm/i915/gvt/kvmgt.c
+++ b/drivers/gpu/drm/i915/gvt/kvmgt.c
@@ -53,11 +53,21 @@ static const struct intel_gvt_ops *intel_gvt_ops;
 #define VFIO_PCI_INDEX_TO_OFFSET(index) ((u64)(index) << VFIO_PCI_OFFSET_SHIFT)
 #define VFIO_PCI_OFFSET_MASK(((u64)(1) << VFIO_PCI_OFFSET_SHIFT) - 1)
 
+struct vfio_region;
+struct intel_vgpu_regops {
+   size_t (*rw)(struct intel_vgpu *vgpu, char *buf,
+   size_t count, loff_t *ppos, bool iswrite);
+   void (*release)(struct intel_vgpu *vgpu,
+   struct vfio_region *region);
+};
+
 struct vfio_region {
u32 type;
u32 subtype;
size_t  size;
u32 flags;
+   const struct intel_vgpu_regops  *ops;
+   void*data;
 };
 
 struct kvmgt_pgfn {
@@ -642,7 +652,7 @@ static ssize_t intel_vgpu_rw(struct mdev_device *mdev, char 
*buf,
int ret = -EINVAL;
 
 
-   if (index >= VFIO_PCI_NUM_REGIONS) {
+   if (index >= VFIO_PCI_NUM_REGIONS + vgpu->vdev.num_regions) {
gvt_vgpu_err("invalid index: %u\n", index);
return -EINVAL;
}
@@ -676,8 +686,11 @@ static ssize_t intel_vgpu_rw(struct mdev_device *mdev, 
char *buf,
case VFIO_PCI_BAR5_REGION_INDEX:
case VFIO_PCI_VGA_REGION_INDEX:
case VFIO_PCI_ROM_REGION_INDEX:
+   break;
default:
-   gvt_vgpu_err("unsupported region: %u\n", index);
+   index -= VFIO_PCI_NUM_REGIONS;
+   return vgpu->vdev.region[index].ops->rw(vgpu, buf, count,
+   ppos, is_write);
}
 
return ret == 0 ? count : ret;
@@ -940,7 +953,8 @@ static long intel_vgpu_ioctl(struct mdev_device *mdev, 
unsigned int cmd,
 
info.flags = VFIO_DEVICE_FLAGS_PCI;
info.flags |= VFIO_DEVICE_FLAGS_RESET;
-   info.num_regions = VFIO_PCI_NUM_REGIONS;
+   info.num_regions = VFIO_PCI_NUM_REGIONS +
+   vgpu->vdev.num_regions;
info.num_irqs = VFIO_PCI_NUM_IRQS;
 
return copy_to_user((void __user *)arg, &info, minsz) ?
@@ -1061,6 +1075,7 @@ static long intel_vgpu_ioctl(struct mdev_device *mdev, 
unsigned int cmd,
}
 
if (caps.size) {
+   info.flags |= VFIO_REGION_INFO_FLAG_CAPS;
if (info.argsz < sizeof(info) + caps.size) {
info.argsz = sizeof(info) + caps.size;
info.cap_offset = 0;
-- 
2.7.4

___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [PATCH v6 4/6] vfio: Define vfio based vgpu's dma-buf operations

2017-05-27 Thread Xiaoguang Chen
Here we defined a new ioctl to create a fd for a vfio device based on
the input type. Now only one type is supported that is a dma-buf
management fd.
Two ioctls are defined for the dma-buf management fd: query the vfio
vgpu's plane information and create a dma-buf for a plane.

Signed-off-by: Xiaoguang Chen 
---
 include/uapi/linux/vfio.h | 50 +++
 1 file changed, 50 insertions(+)

diff --git a/include/uapi/linux/vfio.h b/include/uapi/linux/vfio.h
index ae46105..308e7a2 100644
--- a/include/uapi/linux/vfio.h
+++ b/include/uapi/linux/vfio.h
@@ -502,6 +502,56 @@ struct vfio_pci_hot_reset {
 
 #define VFIO_DEVICE_PCI_HOT_RESET  _IO(VFIO_TYPE, VFIO_BASE + 13)
 
+/**
+ * VFIO_DEVICE_GET_FD - _IO(VFIO_TYPE, VFIO_BASE + 14, __u32)
+ *
+ * Create a fd for a vfio device based on the input type
+ * Vendor driver should handle this ioctl to create a fd and manage the
+ * life cycle of this fd.
+ *
+ * Return: a fd if vendor support that type, -errno if not supported
+ */
+
+#define VFIO_DEVICE_GET_FD _IO(VFIO_TYPE, VFIO_BASE + 14)
+
+#define VFIO_DEVICE_DMABUF_MGR_FD  0 /* Supported fd types */
+
+/*
+ * VFIO_DEVICE_QUERY_PLANE - _IO(VFIO_TYPE, VFIO_BASE + 15, struct plane_info)
+ * Query plane information for a plane
+ */
+struct vfio_vgpu_plane_info {
+   __u32 argsz;
+   __u32 flags;
+   __u32 plane_id;
+   __u32 drm_format;
+   __u32 width;
+   __u32 height;
+   __u32 stride;
+   __u32 start;
+   __u32 x_pos;
+   __u32 y_pos;
+   __u64 drm_format_mod;
+   __u32 size;
+   __u32 pad;
+};
+
+#define VFIO_DEVICE_QUERY_PLANE _IO(VFIO_TYPE, VFIO_BASE + 15)
+
+/*
+ * VFIO_DEVICE_CREATE_DMABUF - _IO(VFIO, VFIO_BASE + 16, struct dmabuf_info)
+ *
+ * Create a dma-buf for a plane
+ */
+struct vfio_vgpu_dmabuf_info {
+   __u32 argsz;
+   __u32 flags;
+   struct vfio_vgpu_plane_info plane_info;
+   __s32 fd;
+   __u32 pad;
+};
+#define VFIO_DEVICE_CREATE_DMABUF _IO(VFIO_TYPE, VFIO_BASE + 16)
+
 /*  API for Type1 VFIO IOMMU  */
 
 /**
-- 
2.7.4

___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx