drm/amdgpu: add amdgpu <--> amdkfd gfx7 interface

2015-07-29 Thread Oded Gabbay
On Tue, Jul 28, 2015 at 6:56 PM, Dan Carpenter 
wrote:

> Hello Oded Gabbay,
>
> The patch 32c22e994f44: "drm/amdgpu: add amdgpu <--> amdkfd gfx7
> interface" from Jun 12, 2015, leads to the following static checker
> warning:
>
> drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v7.c:453
> kgd_hqd_destroy()
> warn: bitwise AND condition is false here
>
> drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v7.c
>439  static int kgd_hqd_destroy(struct kgd_dev *kgd, uint32_t
> reset_type,
>440  unsigned int timeout, uint32_t
> pipe_id,
>441  uint32_t queue_id)
>442  {
>443  struct amdgpu_device *adev = get_amdgpu_device(kgd);
>444  uint32_t temp;
>445
>446  acquire_queue(kgd, pipe_id, queue_id);
>447  WREG32(mmCP_HQD_PQ_DOORBELL_CONTROL, 0);
>448
>449  WREG32(mmCP_HQD_DEQUEUE_REQUEST, reset_type);
>450
>451  while (true) {
>452  temp = RREG32(mmCP_HQD_ACTIVE);
>453  if (temp & CP_HQD_ACTIVE__ACTIVE__SHIFT)
> ^^^
> Never true.  ANDing against a shift is weird.  A zero shift is sort of
> pointless, also.
>
>454  break;
>455  if (timeout == 0) {
>456  pr_err("kfd: cp queue preemption time out
> (%dms)\n",
>457  temp);
>458  release_queue(kgd);
>459  return -ETIME;
>460  }
>461  msleep(20);
>462  timeout -= 20;
>463  }
>464
>465  release_queue(kgd);
>466  return 0;
>467  }
>
> regards,
> dan carpenter
>

​Dan, thanks for catching that!
Will send a fix shortly.

​  Oded
-- next part --
An HTML attachment was scrubbed...
URL: 
<http://lists.freedesktop.org/archives/dri-devel/attachments/20150729/a75626ab/attachment-0001.html>


drm/amdgpu: add amdgpu <--> amdkfd gfx7 interface

2015-07-28 Thread Dan Carpenter
Hello Oded Gabbay,

The patch 32c22e994f44: "drm/amdgpu: add amdgpu <--> amdkfd gfx7
interface" from Jun 12, 2015, leads to the following static checker
warning:

drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v7.c:453 kgd_hqd_destroy()
warn: bitwise AND condition is false here

drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v7.c
   439  static int kgd_hqd_destroy(struct kgd_dev *kgd, uint32_t reset_type,
   440  unsigned int timeout, uint32_t pipe_id,
   441  uint32_t queue_id)
   442  {
   443  struct amdgpu_device *adev = get_amdgpu_device(kgd);
   444  uint32_t temp;
   445  
   446  acquire_queue(kgd, pipe_id, queue_id);
   447  WREG32(mmCP_HQD_PQ_DOORBELL_CONTROL, 0);
   448  
   449  WREG32(mmCP_HQD_DEQUEUE_REQUEST, reset_type);
   450  
   451  while (true) {
   452  temp = RREG32(mmCP_HQD_ACTIVE);
   453  if (temp & CP_HQD_ACTIVE__ACTIVE__SHIFT)
^^^
Never true.  ANDing against a shift is weird.  A zero shift is sort of
pointless, also.

   454  break;
   455  if (timeout == 0) {
   456  pr_err("kfd: cp queue preemption time out 
(%dms)\n",
   457  temp);
   458  release_queue(kgd);
   459  return -ETIME;
   460  }
   461  msleep(20);
   462  timeout -= 20;
   463  }
   464  
   465  release_queue(kgd);
   466  return 0;
   467  }

regards,
dan carpenter


[PATCH 03/13] drm/amdgpu: add amdgpu <--> amdkfd gfx7 interface

2015-06-12 Thread Oded Gabbay
This patch adds the gfx7 interface file between amdgpu and amdkfd. This
interface file mirrors (some) of the functions in radeon_kfd.c
(the interface file between radeon and amdkfd).

The gfx7 interface is used when it is run on a Kaveri-based system.

This interface file was used for bring-up of amdkfd on amdgpu and for
debugging purposes. For users who would like to run HSA on Kaveri, please
use the radeon graphic driver.

Note: CONFIG_DRM_AMDGPU_CIK must be selected for amdgpu to handle Kaveri.

Signed-off-by: Oded Gabbay 
---
 MAINTAINERS   |   1 +
 drivers/gpu/drm/amd/amdgpu/Makefile   |   3 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c|   2 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v7.c | 670 ++
 drivers/gpu/drm/amd/amdgpu/cikd.h |  12 +
 5 files changed, 687 insertions(+), 1 deletion(-)
 create mode 100644 drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v7.c

diff --git a/MAINTAINERS b/MAINTAINERS
index 581c8d4..324bc2d 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -637,6 +637,7 @@ T:  git git://people.freedesktop.org/~gabbayo/linux.git
 S: Supported
 F: drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c
 F: drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h
+F: drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v7.c
 F: drivers/gpu/drm/amd/amdkfd/
 F: drivers/gpu/drm/amd/include/cik_structs.h
 F: drivers/gpu/drm/amd/include/kgd_kfd_interface.h
diff --git a/drivers/gpu/drm/amd/amdgpu/Makefile 
b/drivers/gpu/drm/amd/amdgpu/Makefile
index 891f02c..af5397c 100644
--- a/drivers/gpu/drm/amd/amdgpu/Makefile
+++ b/drivers/gpu/drm/amd/amdgpu/Makefile
@@ -73,7 +73,8 @@ amdgpu-y += \

 # add amdkfd interfaces
 amdgpu-y += \
-amdgpu_amdkfd.o
+amdgpu_amdkfd.o \
+amdgpu_amdkfd_gfx_v7.o

 amdgpu-$(CONFIG_COMPAT) += amdgpu_ioc32.o
 amdgpu-$(CONFIG_VGA_SWITCHEROO) += amdgpu_atpx_handler.o
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c
index 2071a9b..7aa5ab0 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c
@@ -51,6 +51,8 @@ bool amdgpu_amdkfd_load_interface(struct amdgpu_device *rdev)

switch (rdev->asic_type) {
case CHIP_KAVERI:
+   kfd2kgd = amdgpu_amdkfd_gfx_7_get_functions();
+   break;
default:
return false;
}
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v7.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v7.c
new file mode 100644
index 000..2daad33
--- /dev/null
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v7.c
@@ -0,0 +1,670 @@
+/*
+ * Copyright 2014 Advanced Micro Devices, Inc.
+ *
+ * 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 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 COPYRIGHT HOLDER(S) OR AUTHOR(S) 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.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include "amdgpu.h"
+#include "amdgpu_amdkfd.h"
+#include "cikd.h"
+#include "cik_sdma.h"
+#include "amdgpu_ucode.h"
+#include "gca/gfx_7_2_d.h"
+#include "gca/gfx_7_2_enum.h"
+#include "gca/gfx_7_2_sh_mask.h"
+#include "oss/oss_2_0_d.h"
+#include "oss/oss_2_0_sh_mask.h"
+#include "gmc/gmc_7_1_d.h"
+#include "gmc/gmc_7_1_sh_mask.h"
+#include "cik_structs.h"
+
+#define CIK_PIPE_PER_MEC   (4)
+
+enum {
+   MAX_TRAPID = 8, /* 3 bits in the bitfield. */
+   MAX_WATCH_ADDRESSES = 4
+};
+
+enum {
+   ADDRESS_WATCH_REG_ADDR_HI = 0,
+   ADDRESS_WATCH_REG_ADDR_LO,
+   ADDRESS_WATCH_REG_CNTL,
+   ADDRESS_WATCH_REG_MAX
+};
+
+/*  not defined in the CI/KV reg file  */
+enum {
+   ADDRESS_WATCH_REG_CNTL_ATC_BIT = 0x1000UL,
+   ADDRESS_WATCH_REG_CNTL_DEFAULT_MASK = 0x00FF,
+   ADDRESS_WATCH_REG_ADDLOW_MASK_EXTENSION = 0x0300,
+   /* extend the mask to 26 bits to match the low address field */
+   ADDRESS_WATCH_REG_ADDLOW_SHIFT = 6,
+   ADDRESS_WATCH_REG_ADDHIGH_MASK = 0x
+};
+
+static const uint32_t