layerscape: fix VFIO driver build issue since linux-4.14.99
[openwrt/openwrt.git] / target / linux / layerscape / patches-4.14 / 825-vfio-fsl-mc-Improve-send-mc-command-and-read-respons.patch
1 From 703b2ca94467a029942fa478a38f0a14c8109766 Mon Sep 17 00:00:00 2001
2 From: Bharat Bhushan <bharat.bhushan@nxp.com>
3 Date: Fri, 1 Mar 2019 13:33:58 +0800
4 Subject: [PATCH] vfio/fsl-mc: Improve send mc-command and read response
5
6 Actually there is no ordering need when reading response
7 from mc-portal. Similarly when writing the mc-command,
8 ordering needed before command is submitted.
9
10 This patch removes un-necessary barriers, response is read
11 relaxed and maintain ordering when submit command. This also
12 fixes compilation issue with newer kernel.
13
14 Signed-off-by: Bharat Bhushan <Bharat.Bhushan@nxp.com>
15 Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
16 ---
17 drivers/vfio/fsl-mc/vfio_fsl_mc.c | 13 +++++++------
18 1 file changed, 7 insertions(+), 6 deletions(-)
19
20 --- a/drivers/vfio/fsl-mc/vfio_fsl_mc.c
21 +++ b/drivers/vfio/fsl-mc/vfio_fsl_mc.c
22 @@ -331,9 +331,7 @@ static int vfio_fsl_mc_dprc_wait_for_res
23 u64 header;
24 struct mc_cmd_header *resp_hdr;
25
26 - __iormb();
27 - header = readq(ioaddr);
28 - __iormb();
29 + header = cpu_to_le64(readq_relaxed(ioaddr));
30
31 resp_hdr = (struct mc_cmd_header *)&header;
32 status = (enum mc_cmd_status)resp_hdr->status;
33 @@ -353,9 +351,12 @@ static int vfio_fsl_mc_send_command(void
34 {
35 int i;
36
37 - /* Write at command header in the end */
38 - for (i = 7; i >= 0; i--)
39 - writeq(cmd_data[i], ioaddr + i * sizeof(uint64_t));
40 + /* Write at command parameter into portal */
41 + for (i = 7; i >= 1; i--)
42 + writeq_relaxed(cmd_data[i], ioaddr + i * sizeof(uint64_t));
43 +
44 + /* Write command header in the end */
45 + writeq(cmd_data[0], ioaddr);
46
47 /* Wait for response before returning to user-space
48 * This can be optimized in future to even prepare response