From patchwork Thu Jul 10 21:53:54 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oded Gabbay X-Patchwork-Id: 4528861 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id DFB42BEEAA for ; Thu, 10 Jul 2014 23:34:39 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E4480201F5 for ; Thu, 10 Jul 2014 23:34:38 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 966C5201F4 for ; Thu, 10 Jul 2014 23:34:37 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3B3DF6E7D2; Thu, 10 Jul 2014 16:33:30 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wi0-f178.google.com (mail-wi0-f178.google.com [209.85.212.178]) by gabe.freedesktop.org (Postfix) with ESMTP id 144DA6E0B0 for ; Thu, 10 Jul 2014 14:55:17 -0700 (PDT) Received: by mail-wi0-f178.google.com with SMTP id f8so411492wiw.17 for ; Thu, 10 Jul 2014 14:55:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=7ggGoSNmpxstlM+DxsgrHA5qZwgyHvR4TnONeE6s6Qg=; b=pB7ZdTFXLMbkYFOFcq3z+OiN4xYpxMGUwrhuWOgFIiXdI6ddQ2yGFzNwf2mdt3msOK 2XsSCbQ5dP0mA1S7MVkWPt9UGDR5OOXJbHZxlYzwI8ePwj1v3MtguiUsDnhFZCS3tqX4 94lRtTLXewVcrnjPrZfGjmm4sdCaXB5mFd+U2hW5l696L33EneHWviK5DqsIgR7ag9AR w9mn9PQ3VUWtcNUD6o9MaUXWc51MZzstFr++DB1qjWyev0J4IZGTRGVgYu39j2Pxy94f HZiKd1qOioVAV9BrrWdQGadFWWoTNcXFEY4yygxmAecmfae/zdTSGZ4e8WhCYHp0FciU OOwg== X-Received: by 10.180.90.132 with SMTP id bw4mr21963100wib.42.1405029317330; Thu, 10 Jul 2014 14:55:17 -0700 (PDT) Received: from localhost.localdomain ([77.127.59.49]) by mx.google.com with ESMTPSA id pq9sm831097wjc.35.2014.07.10.14.55.15 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 10 Jul 2014 14:55:16 -0700 (PDT) From: Oded Gabbay X-Google-Original-From: Oded Gabbay To: David Airlie , Alex Deucher , Jerome Glisse Subject: [PATCH 38/83] hsa/radeon: Workaround for a bug in amd_iommu Date: Fri, 11 Jul 2014 00:53:54 +0300 Message-Id: <1405029279-6894-10-git-send-email-oded.gabbay@amd.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1405029279-6894-1-git-send-email-oded.gabbay@amd.com> References: <1405029279-6894-1-git-send-email-oded.gabbay@amd.com> X-Mailman-Approved-At: Thu, 10 Jul 2014 16:33:12 -0700 Cc: Andrew Lewycky , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Spam-Status: No, score=-4.0 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RCVD_IN_SORBS_WEB, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch creates a workaround for a bug in amd_iommu driver, where the driver doesn't save all necessary information when going to suspend. The workaround removes a device from the IOMMU device list on suspend and register a resumed device in the IOMMU device list. Signed-off-by: Oded Gabbay --- drivers/gpu/hsa/radeon/Makefile | 2 +- drivers/gpu/hsa/radeon/kfd_device.c | 30 ++++++++++++++++++++++++++ drivers/gpu/hsa/radeon/kfd_pasid.c | 5 +++++ drivers/gpu/hsa/radeon/kfd_pm.c | 43 ------------------------------------- drivers/gpu/hsa/radeon/kfd_priv.h | 1 + 5 files changed, 37 insertions(+), 44 deletions(-) delete mode 100644 drivers/gpu/hsa/radeon/kfd_pm.c diff --git a/drivers/gpu/hsa/radeon/Makefile b/drivers/gpu/hsa/radeon/Makefile index 935f9b7..5422e6a 100644 --- a/drivers/gpu/hsa/radeon/Makefile +++ b/drivers/gpu/hsa/radeon/Makefile @@ -5,6 +5,6 @@ radeon_kfd-y := kfd_module.o kfd_device.o kfd_chardev.o \ kfd_pasid.o kfd_topology.o kfd_process.o \ kfd_doorbell.o kfd_sched_cik_static.o kfd_registers.o \ - kfd_vidmem.o kfd_interrupt.o kfd_pm.o + kfd_vidmem.o kfd_interrupt.o obj-$(CONFIG_HSA_RADEON) += radeon_kfd.o diff --git a/drivers/gpu/hsa/radeon/kfd_device.c b/drivers/gpu/hsa/radeon/kfd_device.c index a21c095..2e7d50d 100644 --- a/drivers/gpu/hsa/radeon/kfd_device.c +++ b/drivers/gpu/hsa/radeon/kfd_device.c @@ -188,3 +188,33 @@ void kgd2kfd_device_exit(struct kfd_dev *kfd) kfree(kfd); } + +void kgd2kfd_suspend(struct kfd_dev *kfd) +{ + BUG_ON(kfd == NULL); + + if (kfd->init_complete) { + kfd->device_info->scheduler_class->stop(kfd->scheduler); + amd_iommu_free_device(kfd->pdev); + } +} + +int kgd2kfd_resume(struct kfd_dev *kfd) +{ + pasid_t pasid_limit; + int err; + + BUG_ON(kfd == NULL); + + pasid_limit = radeon_kfd_get_pasid_limit(); + + if (kfd->init_complete) { + err = amd_iommu_init_device(kfd->pdev, pasid_limit); + if (err < 0) + return -ENXIO; + amd_iommu_set_invalidate_ctx_cb(kfd->pdev, iommu_pasid_shutdown_callback); + kfd->device_info->scheduler_class->start(kfd->scheduler); + } + + return 0; +} diff --git a/drivers/gpu/hsa/radeon/kfd_pasid.c b/drivers/gpu/hsa/radeon/kfd_pasid.c index d78bd00..8bd1562 100644 --- a/drivers/gpu/hsa/radeon/kfd_pasid.c +++ b/drivers/gpu/hsa/radeon/kfd_pasid.c @@ -68,6 +68,11 @@ bool radeon_kfd_set_pasid_limit(pasid_t new_limit) return true; } +inline pasid_t radeon_kfd_get_pasid_limit(void) +{ + return pasid_limit; +} + pasid_t radeon_kfd_pasid_alloc(void) { pasid_t found; diff --git a/drivers/gpu/hsa/radeon/kfd_pm.c b/drivers/gpu/hsa/radeon/kfd_pm.c deleted file mode 100644 index 783311f..0000000 --- a/drivers/gpu/hsa/radeon/kfd_pm.c +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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. - * - * Author: Oded Gabbay - */ - -#include -#include "kfd_priv.h" -#include "kfd_scheduler.h" - -void kgd2kfd_suspend(struct kfd_dev *kfd) -{ - BUG_ON(kfd == NULL); - - kfd->device_info->scheduler_class->stop(kfd->scheduler); -} - -int kgd2kfd_resume(struct kfd_dev *kfd) -{ - BUG_ON(kfd == NULL); - - kfd->device_info->scheduler_class->start(kfd->scheduler); - - return 0; -} diff --git a/drivers/gpu/hsa/radeon/kfd_priv.h b/drivers/gpu/hsa/radeon/kfd_priv.h index bca9cce..8b877ca 100644 --- a/drivers/gpu/hsa/radeon/kfd_priv.h +++ b/drivers/gpu/hsa/radeon/kfd_priv.h @@ -213,6 +213,7 @@ struct kfd_queue *radeon_kfd_get_queue(struct kfd_process *p, unsigned int queue int radeon_kfd_pasid_init(void); void radeon_kfd_pasid_exit(void); bool radeon_kfd_set_pasid_limit(pasid_t new_limit); +pasid_t radeon_kfd_get_pasid_limit(void); pasid_t radeon_kfd_pasid_alloc(void); void radeon_kfd_pasid_free(pasid_t pasid);