From patchwork Fri Jun 3 22:54:35 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Deucher X-Patchwork-Id: 9154215 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id A0A836082E for ; Fri, 3 Jun 2016 22:54:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9296226E5D for ; Fri, 3 Jun 2016 22:54:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8745F28340; Fri, 3 Jun 2016 22:54:48 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RCVD_IN_SORBS_WEB, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0F09B26E5D for ; Fri, 3 Jun 2016 22:54:47 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C4BA06E599; Fri, 3 Jun 2016 22:54:45 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-io0-x241.google.com (mail-io0-x241.google.com [IPv6:2607:f8b0:4001:c06::241]) by gabe.freedesktop.org (Postfix) with ESMTPS id 2CFCB6E1D5 for ; Fri, 3 Jun 2016 22:54:44 +0000 (UTC) Received: by mail-io0-x241.google.com with SMTP id l9so12678092ioe.1 for ; Fri, 03 Jun 2016 15:54:44 -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; bh=O7v6p1w5Fj/rU5ZGheM6CPMv+yB9XHH3fk0kNfLk6Z8=; b=aiDju+WK2xs7CYUjN2o82VpC8+e9Uia6U1UMHE2Y4v1FVEy8uy6v7lJ86I6rXJI2to omr1jO5RW8wYi9FACzZ2QTU68GbRPONqAdBRZDjTQX7ja8HA1LKITEPp+wWXxFX3tKIv xmFMzPW86fZWqjy19/FC+sz+US4ydkQV4wRPDdY+jW2BF/Vwd6Anv983Fmsx9babg1eU rNNDxDV84XV7TDgrCMaZaRHCS6EyyHzjMnPLRvHw6yQf6oruGjH1oKyBDpMJ17dOL0lk tW4/bLMy22HILxYqVrIzrHuia8hEcIjZBr0dLfm0II59dtnlgwHKjiPcV88ugyO17L+b UbgA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=O7v6p1w5Fj/rU5ZGheM6CPMv+yB9XHH3fk0kNfLk6Z8=; b=X7cSeuOVsexPi77uceyazqKDFaiIaKA3rFpTYuDZ/cRILNzgvVWCfi5MOrn5lxtc36 2RQI9SMxmz78i+2jGbPC2s92qZiK0EENF86G7dfw9NzlP3Fpb9mo3WkgX6dF37Uw+qqa gyknGafR6xegSSnj6VS3sslqIAQLT6IxejDU4ylQWBgY6jJ+Ie+3YU68bSwE/W3zLF0h a/oan/3LzN0qYYCa8PiNOg9YBnsQJmISsYu38veHqmMUELs3ly8htxljCEDyeZKgVezB 2m8nNUKSuKM53G2mfifSk9/rdY/yzZmGg8HF9mVDiFdIZKNlBdKdrPYkM/zQh8cWmh8G wcjg== X-Gm-Message-State: ALyK8tIx5Aa0grmFQ1EpyUqhqcFJcvaHX87KSLuKqPABllFdiuvE2JQy2OW5re6bOb8z6g== X-Received: by 10.107.11.18 with SMTP id v18mr9097219ioi.184.1464994483122; Fri, 03 Jun 2016 15:54:43 -0700 (PDT) Received: from cm.amd.com ([165.204.55.251]) by smtp.gmail.com with ESMTPSA id l123sm804543ita.1.2016.06.03.15.54.41 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 03 Jun 2016 15:54:41 -0700 (PDT) From: Alex Deucher X-Google-Original-From: Alex Deucher To: dri-devel@lists.freedesktop.org Subject: [PATCH 1/2] drm/amdgpu: add release firmware for cgs Date: Fri, 3 Jun 2016 18:54:35 -0400 Message-Id: <1464994476-27756-1-git-send-email-alexander.deucher@amd.com> X-Mailer: git-send-email 2.5.5 Cc: Alex Deucher , Monk Liu X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 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-Virus-Scanned: ClamAV using ClamSMTP From: Monk Liu Powerplay uses cgs to load the firmware so add a function to release it as well to avoid leaking it on driver unload. Signed-off-by: Monk Liu Reviewed-by: Alex Deucher Signed-off-by: Alex Deucher --- drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c | 12 ++++++++++++ drivers/gpu/drm/amd/include/cgs_common.h | 6 ++++++ 2 files changed, 18 insertions(+) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c index 199f76b..8943099 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c @@ -696,6 +696,17 @@ static uint32_t fw_type_convert(struct cgs_device *cgs_device, uint32_t fw_type) return result; } +static int amdgpu_cgs_rel_firmware(struct cgs_device *cgs_device, enum cgs_ucode_id type) +{ + CGS_FUNC_ADEV; + if ((CGS_UCODE_ID_SMU == type) || (CGS_UCODE_ID_SMU_SK == type)) { + release_firmware(adev->pm.fw); + return 0; + } + /* cannot release other firmware because they are not created by cgs */ + return -EINVAL; +} + static int amdgpu_cgs_get_firmware_info(struct cgs_device *cgs_device, enum cgs_ucode_id type, struct cgs_firmware_info *info) @@ -1125,6 +1136,7 @@ static const struct cgs_ops amdgpu_cgs_ops = { amdgpu_cgs_pm_query_clock_limits, amdgpu_cgs_set_camera_voltages, amdgpu_cgs_get_firmware_info, + amdgpu_cgs_rel_firmware, amdgpu_cgs_set_powergating_state, amdgpu_cgs_set_clockgating_state, amdgpu_cgs_get_active_displays_info, diff --git a/drivers/gpu/drm/amd/include/cgs_common.h b/drivers/gpu/drm/amd/include/cgs_common.h index a461e15..7464daf 100644 --- a/drivers/gpu/drm/amd/include/cgs_common.h +++ b/drivers/gpu/drm/amd/include/cgs_common.h @@ -581,6 +581,9 @@ typedef int (*cgs_get_firmware_info)(struct cgs_device *cgs_device, enum cgs_ucode_id type, struct cgs_firmware_info *info); +typedef int (*cgs_rel_firmware)(struct cgs_device *cgs_device, + enum cgs_ucode_id type); + typedef int(*cgs_set_powergating_state)(struct cgs_device *cgs_device, enum amd_ip_block_type block_type, enum amd_powergating_state state); @@ -645,6 +648,7 @@ struct cgs_ops { cgs_set_camera_voltages_t set_camera_voltages; /* Firmware Info */ cgs_get_firmware_info get_firmware_info; + cgs_rel_firmware rel_firmware; /* cg pg interface*/ cgs_set_powergating_state set_powergating_state; cgs_set_clockgating_state set_clockgating_state; @@ -738,6 +742,8 @@ struct cgs_device CGS_CALL(set_camera_voltages,dev,mask,voltages) #define cgs_get_firmware_info(dev, type, info) \ CGS_CALL(get_firmware_info, dev, type, info) +#define cgs_rel_firmware(dev, type) \ + CGS_CALL(rel_firmware, dev, type) #define cgs_set_powergating_state(dev, block_type, state) \ CGS_CALL(set_powergating_state, dev, block_type, state) #define cgs_set_clockgating_state(dev, block_type, state) \