From patchwork Tue Nov 20 18:58:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Ho, Kenny" X-Patchwork-Id: 10691503 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 00C9F1926 for ; Wed, 21 Nov 2018 01:09:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E27A72B019 for ; Wed, 21 Nov 2018 01:09:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D6EC62AFCF; Wed, 21 Nov 2018 01:09:39 +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=-5.2 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 259322AF79 for ; Wed, 21 Nov 2018 01:09:38 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8E93A6E4E9; Wed, 21 Nov 2018 01:09:33 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from NAM01-BN3-obe.outbound.protection.outlook.com (mail-eopbgr740075.outbound.protection.outlook.com [40.107.74.75]) by gabe.freedesktop.org (Postfix) with ESMTPS id 9BB496E3EA; Tue, 20 Nov 2018 18:59:01 +0000 (UTC) Received: from CY4PR1201CA0018.namprd12.prod.outlook.com (2603:10b6:910:16::28) by CY1PR12MB0742.namprd12.prod.outlook.com (2a01:111:e400:59d1::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1339.28; Tue, 20 Nov 2018 18:58:59 +0000 Received: from BY2NAM03FT025.eop-NAM03.prod.protection.outlook.com (2a01:111:f400:7e4a::201) by CY4PR1201CA0018.outlook.office365.com (2603:10b6:910:16::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.1361.14 via Frontend Transport; Tue, 20 Nov 2018 18:58:59 +0000 Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) Received: from SATLEXCHOV02.amd.com (165.204.84.17) by BY2NAM03FT025.mail.protection.outlook.com (10.152.84.232) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.1339.10 via Frontend Transport; Tue, 20 Nov 2018 18:58:59 +0000 Received: from kho-5039A.amd.com (10.180.168.240) by SATLEXCHOV02.amd.com (10.181.40.72) with Microsoft SMTP Server id 14.3.389.1; Tue, 20 Nov 2018 12:58:57 -0600 From: Kenny Ho To: , , , , , Date: Tue, 20 Nov 2018 13:58:12 -0500 Message-ID: <20181120185814.13362-4-Kenny.Ho@amd.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181120185814.13362-1-Kenny.Ho@amd.com> References: <20181120185814.13362-1-Kenny.Ho@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:165.204.84.17; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(396003)(39860400002)(376002)(136003)(346002)(2980300002)(428003)(199004)(189003)(2201001)(7696005)(51416003)(47776003)(72206003)(86362001)(478600001)(76176011)(48376002)(5660300001)(476003)(104016004)(2616005)(426003)(486006)(36756003)(336012)(97736004)(11346002)(446003)(217873002)(39060400002)(126002)(356004)(14444005)(6666004)(2906002)(110136005)(8936002)(316002)(8676002)(68736007)(81166006)(81156014)(53936002)(305945005)(2870700001)(50226002)(77096007)(26005)(53416004)(105586002)(1076002)(50466002)(186003)(106466001); DIR:OUT; SFP:1101; SCL:1; SRVR:CY1PR12MB0742; H:SATLEXCHOV02.amd.com; FPR:; SPF:None; LANG:en; PTR:InfoDomainNonexistent; A:1; MX:1; X-Microsoft-Exchange-Diagnostics: 1; BY2NAM03FT025; 1:8BwZnQjt2Udsv7e33r2+nf9GxbumHU2lANJyHf/J1mqVkyiSCnFo+7sO6qNgAN7wD1lbDZ8v99/1j3ke1wg4aBCmuwSMfKtIoGK+k+32qFK76/rF0bgnq6v/tYQ/Rxs4 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 08c88c83-8711-4dad-e659-08d64f1a3adb X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(2390098)(7020095)(4652040)(8989299)(5600074)(711020)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7153060); SRVR:CY1PR12MB0742; X-Microsoft-Exchange-Diagnostics: 1; CY1PR12MB0742; 3:jUqGc5mzsb7LAm9EtSrK08GZDNratMZm+Eo5qOgjaFyGaH79HBpSfQ5MY2C8SzIlScQ0ZdKMDDd8mIQwsUbq9JUmKM//Vsx02PYyvnzD4/slKOIDy+urej2GDzL97y+kdCdUQntB6tJyolyI3RODG5uuZZSh1JYFFRq1Ngx2kByS6EHtqjdruStNcQvZCHp0vHRujNEUb+YPyIgDYtj5nKfK40nBextVUKCekpEih0IrvreUmo5pcTpUuDJPDGDzBZfi9BR30Z+bO69RSk8PLA7MLUHxSO2Wvf1OCkui2yxrLWDxV0eHDhW0NWvXnk1NzS6Qnj4nI7yj3HdY8JaUEwVwsCGBbNlK8OD4ELnig1o=; 25:cMrIJRJAX2GcP4WtxX70KfwGs8SMYs290EwtL2Mn+ObaYgZxFqttD0Ar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11xGeEcBXZQ7Y85n64xKmOIHJkTiTpPoA4HzZv3LqCKniVP9Yc X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(3231442)(944501410)(52105112)(3002001)(10201501046)(93006095)(93003095)(6055026)(148016)(149066)(150057)(6041310)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123562045)(20161123564045)(201708071742011)(7699051)(76991095); SRVR:CY1PR12MB0742; BCL:0; PCL:0; RULEID:; SRVR:CY1PR12MB0742; X-Microsoft-Exchange-Diagnostics: 1; CY1PR12MB0742; 4:B5bcMPf0t16vcuy63nM2/igZKxeN7HKVUmIiD4RYhXW7tYMSkpWT/YZS/bw/Xn7LSRD+xkU4LnqalhsKyoeAcsFtUJTbURIQcARkN+ab952Mp8IRC4uQry+/LpJMD1SqCaDmPcWJzHd8z4NttXs1i4KP0o6hxvuYzaNUzYtt+Px0NkRmIuQqIPTWrdcmyhXyNYBC61wc82YUhIHeo4oNjGtHWgKfaQawHiWOLM7P8GWfmfqVniui0Mic+sVipoKQCwdrMuPz8Rrito6Tz5M5NA== X-Forefront-PRVS: 08626BE3A5 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; CY1PR12MB0742; 23:BKVkVGhH0dDU99t1XDEhMNBsrIIyqUQOXg9j4hf5A?= FdAS3d2F7xxDyf8OLj2VfuDK0UtZGkmwTeT7n8UXBeajDRQHLk5omxvrq8nr0XU0fqesI8KKXfLfCaTZJZKHZvd6ekv/JM/RIPktAAqYjnM5dpnDV/B0m6OpRbxUMVpD8JDEHLguYpq9vhCcXILbpCVrP7745aozqDXtb8LmgME7H/aG5ad6FG6QOnaFBMlbX5u6BiGcPVpexToBDcU5yK0OhrD88icggmXSDkIylsD8/IwOORwFE35dVKOJkh6cpTdyLcchMeHllo0gkHo2S4c511Pp0iK18BPH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T90NFt3dlgguwoRXd6KE5cDZDuRL+ksq6GWkYIlpSFQs7O/G9e7NgqqaqCjXXVOOX4MNWzv/yKG8mQh20+dfsnIr01kc5aNTs7hlXa7IhN9QWPRl8UuNWvuEosuC1PWZfXleJ2jceRIvOyKo6kAYAbZRQ8NFUXpURJr0QVZNsV/vw6447SePgNkNwCAA1yWlm1m60wsh+0= X-Microsoft-Exchange-Diagnostics: 1; CY1PR12MB0742; 6:d1KNXBSWLrDzE7b29fnda7j6C4avPF10KrAqwGtwsCovPn+oJ/lebS36tLG1Ho1+Is2348MWrMTJlKuDAWmByIH0WtuEXBd72OtbUf81ZgxifeRFNd6OAn0kewBGUs8uKkYF0B/9bU6QsClwK79ZSjDtyY/91SqWHqAqYYvJBs8XvX8DkkZT7TnVo1GvSZPKInk5q3uzbV8ISx2JeyksKVBWJHgBrlwoLuI87T0O8d5CcmCY+I4s4gB5//9l8acoUl3Th1UanbpquQWer0tD8XGzVMLbO0sKcw89AMkxOO5FUk5nb+2g4cugWc4eOac17JwODTEa2BVufi2/9yd9187WIyghIohBwq5UbtDWHIBDPyAdh9CmyrOIruRrGEw5cRmJ3eclBHb3hr4vEcDIl5Cg/EYG8U1ED7kCjpeD9gLKjvzG37YGlaylENCdWQlytVdAkzTZlv0JZii+l6ajMw==; 5:3+DNc2GDmjaUurdI8gu7XIQF0rTQ8/TSidu1I3OwCqaF7dWpeQ26Vd1QSBTaJmnUoJdYbIUZ+AIhLDtkqFbKVTZyjYQgINvJ5Sc7PiUxdJKCO1fHzGfBgSFJnS6HB6HpKrV7t2mFBZp2QxXdzErbgEdPygsr91lCweyoK5gYSi4=; 7:Kem91/GkGrE5BramZIb1su14rO3D1t53SUiGXRJaz+esWKZIh09Q40vBAKyA9q+i1Dve7n5GdWDTkt59qbhyVW7jIcyEDKqMxM+JJYs/2VjkdKe/e/FY+1/UmBw0a097Trw5h+MsWPzwZCAGKYI3KA== SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; CY1PR12MB0742; 20:VCFgr1uxloGwP0HmJjGfg0eu2PerBmiiA4b2bKVhZFaxcPWzQiiSUcSqV2V+LWWXFzmk8v1aOeDA834dvvMHTRG4EifyfHn4k/dltqhuMbaV0zYUvBa0EwhNotGNq1Cn4otF96vUUQS12EjEqjhOrGfKQESH6sj1FRjmDatAqH6ZTI6N1EBGFVEWBer7qc9tCipPSR7bCNHRK3gxE2gnGzoJv8r6ncEP2u/VM8MCljcv+T5Ta1pp5GAKya4xI9vX X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Nov 2018 18:58:59.2862 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 08c88c83-8711-4dad-e659-08d64f1a3adb X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXCHOV02.amd.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR12MB0742 X-Mailman-Approved-At: Wed, 21 Nov 2018 01:09:32 +0000 Subject: [Intel-gfx] [PATCH RFC 3/5] drm/amdgpu: Add DRM cgroup support for AMD devices X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP Change-Id: Ib66c44ac1b1c367659e362a2fc05b6fbb3805876 Signed-off-by: Kenny Ho --- drivers/gpu/drm/amd/amdgpu/Makefile | 3 ++ drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 7 ++++ drivers/gpu/drm/amd/amdgpu/amdgpu_drmcgrp.c | 37 +++++++++++++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_drmcgrp.h | 19 +++++++++++ include/drm/drmcgrp_vendors.h | 1 + 5 files changed, 67 insertions(+) create mode 100644 drivers/gpu/drm/amd/amdgpu/amdgpu_drmcgrp.c create mode 100644 drivers/gpu/drm/amd/amdgpu/amdgpu_drmcgrp.h diff --git a/drivers/gpu/drm/amd/amdgpu/Makefile b/drivers/gpu/drm/amd/amdgpu/Makefile index 138cb787d27e..5cf8048f2d75 100644 --- a/drivers/gpu/drm/amd/amdgpu/Makefile +++ b/drivers/gpu/drm/amd/amdgpu/Makefile @@ -186,4 +186,7 @@ amdgpu-y += $(AMD_DISPLAY_FILES) endif +#DRM cgroup controller +amdgpu-y += amdgpu_drmcgrp.o + obj-$(CONFIG_DRM_AMDGPU)+= amdgpu.o diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c index 30bc345d6fdf..ad0373f83ed3 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c @@ -33,6 +33,7 @@ #include #include #include +#include #include #include #include @@ -2645,6 +2646,12 @@ int amdgpu_device_init(struct amdgpu_device *adev, goto failed; } + /* TODO:docs */ + if (drmcgrp_vendors[amd_drmcgrp_vendor_id] == NULL) + drmcgrp_register_vendor(&amd_drmcgrp_vendor, amd_drmcgrp_vendor_id); + + drmcgrp_register_device(adev->ddev, amd_drmcgrp_vendor_id); + return 0; failed: diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drmcgrp.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_drmcgrp.c new file mode 100644 index 000000000000..ed8aac17769c --- /dev/null +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drmcgrp.c @@ -0,0 +1,37 @@ +// SPDX-License-Identifier: MIT +// Copyright 2018 Advanced Micro Devices, Inc. +#include +#include +#include +#include "amdgpu_drmcgrp.h" + +struct cftype files[] = { + { } /* terminate */ +}; + +struct cftype *drmcgrp_amd_get_cftypes(void) +{ + return files; +} + +struct drmcgrp_device_resource *amd_drmcgrp_alloc_dev_resource(void) +{ + struct amd_drmcgrp_dev_resource *a_ddr; + + a_ddr = kzalloc(sizeof(struct amd_drmcgrp_dev_resource), GFP_KERNEL); + if (!a_ddr) + return ERR_PTR(-ENOMEM); + + return &a_ddr->ddr; +} + +void amd_drmcgrp_free_dev_resource(struct drmcgrp_device_resource *ddr) +{ + kfree(ddr_amdddr(ddr)); +} + +struct drmcgrp_vendor amd_drmcgrp_vendor = { + .get_cftypes = drmcgrp_amd_get_cftypes, + .alloc_dev_resource = amd_drmcgrp_alloc_dev_resource, + .free_dev_resource = amd_drmcgrp_free_dev_resource, +}; diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drmcgrp.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_drmcgrp.h new file mode 100644 index 000000000000..e2934b7a49f5 --- /dev/null +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drmcgrp.h @@ -0,0 +1,19 @@ +/* SPDX-License-Identifier: MIT + * Copyright 2018 Advanced Micro Devices, Inc. + */ +#ifndef _AMDGPU_DRMCGRP_H +#define _AMDGPU_DRMCGRP_H + +#include + +/* for AMD specific DRM resources */ +struct amd_drmcgrp_dev_resource { + struct drmcgrp_device_resource ddr; +}; + +static inline struct amd_drmcgrp_dev_resource *ddr_amdddr(struct drmcgrp_device_resource *ddr) +{ + return ddr ? container_of(ddr, struct amd_drmcgrp_dev_resource, ddr) : NULL; +} + +#endif /* _AMDGPU_DRMCGRP_H */ diff --git a/include/drm/drmcgrp_vendors.h b/include/drm/drmcgrp_vendors.h index b04d8649851b..6cfbf1825344 100644 --- a/include/drm/drmcgrp_vendors.h +++ b/include/drm/drmcgrp_vendors.h @@ -3,5 +3,6 @@ */ #if IS_ENABLED(CONFIG_CGROUP_DRM) +DRMCGRP_VENDOR(amd) #endif