From patchwork Thu Jul 10 21:50:21 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oded Gabbay X-Patchwork-Id: 4528771 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 A9A1ABEECB for ; Thu, 10 Jul 2014 23:34:28 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C25B4201D5 for ; Thu, 10 Jul 2014 23:34:27 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id DE7BC201DE for ; Thu, 10 Jul 2014 23:34:26 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id EF43E6E7C9; Thu, 10 Jul 2014 16:33:26 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-we0-f182.google.com (mail-we0-f182.google.com [74.125.82.182]) by gabe.freedesktop.org (Postfix) with ESMTP id 3CDFD6E0B0 for ; Thu, 10 Jul 2014 14:52:12 -0700 (PDT) Received: by mail-we0-f182.google.com with SMTP id q59so202469wes.13 for ; Thu, 10 Jul 2014 14:52:11 -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=tjvp4QfC3B+EDAL89fOdujAPhXvJplkKmYzJPL8jslU=; b=tbUPD2IvVW+9wc8ljmKIfZxPBTbQH/6u4Yi+1Qo993x/EHcbr7mMfSw3EZ+tsuHI1q 0qzNhLZIltKGZHwomCdp6tpfqpASxIGXJU33Rk3puDCoLaxdLKD9AQXsbG9lFMuWPPAm ZGR6sgQn8GrWMdSS4P/TXu/iT7S5DIAKJuVqj2xAZNRW6a0KNMkcHohjntkpnB2NwzWw 7WTwXoWHMfPBXilMIQ1TqZeo6FHWpn4PxN9gD25Ng/fUFawEuBEOI7t1mjpnbXBqKuhU EOsHw6KnD61BzAVyFGcdzemqWTj3CVhodcOpCGwAErK5a+1dzirAZK9YHfoxU578jsyN PF1A== X-Received: by 10.180.182.131 with SMTP id ee3mr21735371wic.37.1405029131430; Thu, 10 Jul 2014 14:52:11 -0700 (PDT) Received: from localhost.localdomain ([77.127.59.49]) by mx.google.com with ESMTPSA id n2sm805353wjf.40.2014.07.10.14.52.08 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 10 Jul 2014 14:52:09 -0700 (PDT) From: Oded Gabbay X-Google-Original-From: Oded Gabbay To: David Airlie , Alex Deucher , Jerome Glisse Subject: [PATCH 21/83] hsa/radeon: Add kgd-->kfd interfaces for suspend and resume Date: Fri, 11 Jul 2014 00:50:21 +0300 Message-Id: <1405029027-6085-20-git-send-email-oded.gabbay@amd.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1405029027-6085-1-git-send-email-oded.gabbay@amd.com> References: <1405029027-6085-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 adds two new interfaces to the kgd2kfd structure. Those interfaces are for doing suspend and resume of a kfd device, when its matching radeon device does suspend and resume. Signed-off-by: Oded Gabbay --- drivers/gpu/hsa/radeon/Makefile | 2 +- drivers/gpu/hsa/radeon/kfd_module.c | 2 ++ drivers/gpu/hsa/radeon/kfd_pm.c | 43 +++++++++++++++++++++++++++++++++++++ drivers/gpu/hsa/radeon/kfd_priv.h | 4 ++++ include/linux/radeon_kfd.h | 2 ++ 5 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 drivers/gpu/hsa/radeon/kfd_pm.c diff --git a/drivers/gpu/hsa/radeon/Makefile b/drivers/gpu/hsa/radeon/Makefile index 5422e6a..935f9b7 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_vidmem.o kfd_interrupt.o kfd_pm.o obj-$(CONFIG_HSA_RADEON) += radeon_kfd.o diff --git a/drivers/gpu/hsa/radeon/kfd_module.c b/drivers/gpu/hsa/radeon/kfd_module.c index ad21c6d..a03743a 100644 --- a/drivers/gpu/hsa/radeon/kfd_module.c +++ b/drivers/gpu/hsa/radeon/kfd_module.c @@ -39,6 +39,8 @@ static const struct kgd2kfd_calls kgd2kfd = { .device_init = kgd2kfd_device_init, .device_exit = kgd2kfd_device_exit, .interrupt = kgd2kfd_interrupt, + .suspend = kgd2kfd_suspend, + .resume = kgd2kfd_resume, }; bool kgd2kfd_init(unsigned interface_version, diff --git a/drivers/gpu/hsa/radeon/kfd_pm.c b/drivers/gpu/hsa/radeon/kfd_pm.c new file mode 100644 index 0000000..783311f --- /dev/null +++ b/drivers/gpu/hsa/radeon/kfd_pm.c @@ -0,0 +1,43 @@ +/* + * 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 5b6611f..630d690 100644 --- a/drivers/gpu/hsa/radeon/kfd_priv.h +++ b/drivers/gpu/hsa/radeon/kfd_priv.h @@ -247,4 +247,8 @@ int radeon_kfd_interrupt_init(struct kfd_dev *dev); void radeon_kfd_interrupt_exit(struct kfd_dev *dev); void kgd2kfd_interrupt(struct kfd_dev *dev, const void *ih_ring_entry); +/* Power Management */ +void kgd2kfd_suspend(struct kfd_dev *dev); +int kgd2kfd_resume(struct kfd_dev *dev); + #endif diff --git a/include/linux/radeon_kfd.h b/include/linux/radeon_kfd.h index 2f4f7c0..63b7bac 100644 --- a/include/linux/radeon_kfd.h +++ b/include/linux/radeon_kfd.h @@ -63,6 +63,8 @@ struct kgd2kfd_calls { bool (*device_init)(struct kfd_dev *kfd, const struct kgd2kfd_shared_resources *gpu_resources); void (*device_exit)(struct kfd_dev *kfd); void (*interrupt)(struct kfd_dev *kfd, const void *ih_ring_entry); + void (*suspend)(struct kfd_dev *kfd); + int (*resume)(struct kfd_dev *kfd); }; struct kfd2kgd_calls {