Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751641AbdFIVbL (ORCPT ); Fri, 9 Jun 2017 17:31:11 -0400 Received: from mail-by2nam01on0059.outbound.protection.outlook.com ([104.47.34.59]:60388 "EHLO NAM01-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751545AbdFIVbJ (ORCPT ); Fri, 9 Jun 2017 17:31:09 -0400 Authentication-Results: spf=none (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; lists.freedesktop.org; dkim=none (message not signed) header.d=none;lists.freedesktop.org; dmarc=permerror action=none header.from=amd.com; From: Andrey Grodzovsky To: , , , CC: , , "Andrey Grodzovsky" Subject: [PATCH] drm/core: Fail atomic IOCTL with no CRTC state but with signaling. Date: Fri, 9 Jun 2017 17:30:19 -0400 Message-ID: <1497043819-28591-1-git-send-email-Andrey.Grodzovsky@amd.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 Content-Type: text/plain 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)(6009001)(39860400002)(39450400003)(39400400002)(39410400002)(39850400002)(39840400002)(2980300002)(428002)(199003)(189002)(9170700003)(8676002)(53936002)(2201001)(8936002)(54906002)(356003)(48376002)(50226002)(86362001)(53416004)(77096006)(81166006)(305945005)(47776003)(36756003)(189998001)(6666003)(105586002)(5890100001)(5660300001)(2906002)(5003940100001)(50986999)(4326008)(478600001)(38730400002)(101416001)(72206003);DIR:OUT;SFP:1101;SCL:1;SRVR:DM2PR12MB0204;H:SATLEXCHOV02.amd.com;FPR:;SPF:None;MLV:sfv;A:1;MX:1;LANG:en; X-Microsoft-Exchange-Diagnostics: 1;BY2NAM03FT008;1:fzSpISzxi6MqqO/jTPJ4llkhmjV4Z0371PhksWF0c2g+tm3fwKl070/AZksz7jOxyG82GA+DUK0vWeFojamqJghQlVh0C0gyZcByPNCNQ4k2dF5tFpmR9oJ5aGFJ1uCc6vgU4wcLtrK+LP45FROSmvycVASIAjF1tPpxuRqrJOkAlcml5nBW5YVF1DqGflDtHrYzvUfTb6ktAK2xI+Q/5i5tdb73kQyAEvTsRrc5EFtt8h3DQclSLVxjc+hbNunWkDVWqX/gt6+ugVYjhng1iY1uFqo36ldKd2xd2t5/kUkdFnt078tUYEQ7Y+fwA+klcadbz66JvqLVWF5ZeKHNN35SMkq8+46r6N2gv6cVKLo+zvSa8ESOg7MfZy4wA4g5PGVADuPFRyBFRZMSKiin69qUmeAAVVrZWNQ82vsOGKWcFdh+TZdxW5b2h9BnNSRZ/wNbkp0ZPVl8MBQhID3b9G9N6RK3h02bHY8DU81rM2Nbd5luFac3PKXq/AppWG5JANx5RhuasyaqT4feH974VPn2844jQYB8nh2JrxHnR++mvxjdpap81bzFxNcM5XaR X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM2PR12MB0204: X-MS-Office365-Filtering-Correlation-Id: a062675c-02da-4b37-8386-08d4af7ed6b8 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001)(2017030254075)(201703131423075)(201703031133081);SRVR:DM2PR12MB0204; X-Microsoft-Exchange-Diagnostics: 1;DM2PR12MB0204;3:rBUXwztSu+3yNH76ENkoTDqH+SAUnwTY+uiY2N0yuU9zRHv4nEngy/9SRu0b8evs6rMf2nlscS5IXmJj8CLDReOVU/4f9cidp3r9bKUFRYKeghz9SK/Lj3NlDIrnGzgTUMnN44sgrnVjOBL97EPuTjy4bfZPAwZGINIpHG+jMJgRixbCpjjgNHAIYZq4DlXmtb1x1UMEPLyHKVDb2Mm6ZLTeGa3krRbXDsII10g6t/gurzDt/BLcJbSidb+cVJUzFYO8sb9fJKzP26oxs3PBulMpSjp+C/xS1gF376qkX/7I4/Tjxgk/Qs639KFMGf3k6Lr39r79r648l/SL+C43DjgLAVHk76iaQ0u2BnCPKdjV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/NgRqOjd+0vr+DMhVDl0pWy1R9Q91256xvfgMwj5u9PcrqbQRoP0EY9J4XYGfx6JPbhqbMi1ij9jf1QFQi6aMu12ljGieZvf6ITodxALNrfnE31XCMGj1k+X29n3tzx5Nc+3nmcZxCaJDpmVnrWne5BuERcwGlSFyuOuVxcXn3Bzg4G5nHuCxUU1u9OvgUrOKhBm5GmjgGRN+Q2Ypbae+3NpVKowchWqG4mvUXYkOoyz/CZZdBNvtclhj11AhidV8rANvn7KCSS4CbEtX/tyAB7GOal9Hekzrb4zE0QzvS9mH4bARzrGOxP9+kldan7eac9gVmoEKhOagAqVZBTF3morlHRTWfGWvZNMv+vcOB4n5qMu6+ X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(767451399110); X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(601004)(2401047)(5005006)(13016025)(8121501046)(13018025)(3002001)(10201501046)(100000703101)(100105400095)(93006095)(93003095)(6055026)(6041248)(20161123558100)(20161123564025)(20161123555025)(20161123560025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123562025)(6072148)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:DM2PR12MB0204;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:DM2PR12MB0204; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;DM2PR12MB0204;4:o45xfAQhe5srXcGQ931GpZ5cbyCyeSwxT+uwVAqZZi?= =?us-ascii?Q?myLYRW1ywu0CQz3dCH2L/EaVTGvYsUsWrmfbu4aXprPoHu4VWGLQpMdEdjaP?= =?us-ascii?Q?inMkDOP0zigvC36vCZcg/SvBlRpGsxN/oyu/xlDoMp0CECivWkUbxQtS+ObM?= =?us-ascii?Q?bg6c4SaYJMlT3gL57TvH+dso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?Q?Lq+tFmlRfeQ8PtwNBlEifqK4OjKnfOWl4Jz4+qVi204St3Mdr2RAD6qddrnN?= =?us-ascii?Q?Aj/w2jVrZ9sd3k8gVNsiJpDtK0zGDcI53FbfiMXJO3g35zbtgFZdwQDv/pat?= =?us-ascii?Q?1Xw8cM3Moj6S0ZUTtt3qGsrvajPg98hmjdtBpH9C6HRwNRXrYA9OtcckC67O?= =?us-ascii?Q?rWvhmeJAfHdZLlIjU=3D?= X-Forefront-PRVS: 03333C607F X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;DM2PR12MB0204;23:4q9kys/tmOpJ0MWL/fCldzM3nvPfHy05w2eVKESH5?= =?us-ascii?Q?WiRM8BQ7WYO8CPlSAOCCr5f4FvpPrfHd4/ECuVLYtNnyMSpioHBgQ8JGDLOc?= =?us-ascii?Q?Co69Qk6wNXZou1HYesVZt6J0mzv2d7pSiEnyAU+ureqRb/i51sGmyik7CLvv?= =?us-ascii?Q?bI+k0HhubFmzLIDPAYd2JXZuLUKPVXmpUitBr8dHdY/IEXt4m1jyT0k+j3Ns?= =?us-ascii?Q?7RXT9+qPCHm02qRFlKhqOsxR1ZiBTz5cxyKtAofonfPRdtZKmgSYsdSscwC+?= =?us-ascii?Q?n1rdHjyqqRQG6r70+A8JfMbbUX/r7t8PYpcCA/O4NNoFdM+hjVPwElnU57Oq?= =?us-ascii?Q?gbVAJNiCq7sxPorlyNPeUWY8qcIZcNcXiCQlag540HA4CXXI9J+JCb60LT8j?= =?us-ascii?Q?GHbU8QqEsUT20s9M/TQKpjJqNJXJaOu5LVYD9+woqIgz0OTa9D8mgqIpB7pO?= =?us-ascii?Q?Ci60HSof0qVX4LTsuw+VlmVYngEAmPtHMDANRWPEevFWs6SILwQzHDJqCSf4?= =?us-ascii?Q?9beRNofycnhu7ih1rxNyMzkYiZONmUptGbBOWEcglSfYj/CZAFMWQApS95I8?= =?us-ascii?Q?n9g4eRgjkkHYhXuWfYry0b+DxR9hGJry8nEzCfW1//cF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ReGGSY3/6FuzjjKjl2RAFLOdQTWGIAwHoEc/3yYJy6F4= X-Microsoft-Exchange-Diagnostics: 1;DM2PR12MB0204;5:7ONCFEWALxhBtcJHQm09SAAvcbc+hDdMedGxis3h4CQT9AmBOmuRnItVoD2n5BOJT+wVV3ii3UFXdKp3wrpik4rxib8QewnxDaC1gEKydGU7reykca/HlGgk1s66QLWD6A1g+t1s/P5YK8L38pdyBDjld4hxBI9mK+5MIeNfISGONF4BrLpaeomvSgryZ+92vfvsGJnOo2diht6TigS8rTjYkAjCZLdGlTCOUpT9hMKGfRbQmB/S8QKnPQx4sNVLmk6bQjQlTH51x9bit5/Wyev6UklE8kaHq+V9z4Msy89lylYgWabeGABk+FLMVb2taOcUiBI/MLkZ4JsCadIo+lOz3kRM/asmgXX0OijN9jWBJxCH3hsyessLAL8b7P7/43hANn5dm5WeMZ7gHppCP1SDS78wIjDQv4At9g2mthfAzWvCKHOZJa0Lo93By+Jyqag7HbxajkuNLBFTwL4fSulvGIgQGVJhYINiaWgTtztIN1qDDzml3Kk0/6PcWtIk;24:7DZSfH0aAvLvuQvrYtC1Gbtu69StAYxuBZ7mvxzZu03ScBJb/BD6q0rKuo8UQbisg1jGuKIIiL3Gj3SrU7DARto+JBiJal3XEwg7GvRaJDQ= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;DM2PR12MB0204;7:CjpbobcxSzsFqECk41DE4zpJkY/xd3/xLPUHvIgeHjxnhWErk5h2raj9QEK4FY5IcV/pao1mjjRtX87ps2c6EE1ESBf+Ki+ZNkP/1d/5wT9oVPh8BAvQf+K5yr49JJG8HITfKYbb/bJ3kOXkYK6b+9Z48dPrDg35AGfki3WMyNiEL2QgyAV72olzSklpDrra0Mpvj8cNqePyx8i36hSYHZOyLTP0M8QX806At0VFWCUoDOm3FZVdfwXygB+58iJTa6tps+jdgwxFsz6PqfJERwvOz60HjlRw/f1hb4UAbegdClGJVSkm4bWQ0ZSXPb4YQMCNJF351+xAZNukwGhcQQ==;20:sNwmbAUz79G7N3Xfd7W41YxFrjLwDbIcaq9Xxlyrs2v7TM5ssm90gNsodwvHbPGCH3gYNr/j+ERAFVZ50/+ZC5SWXntv4VUqyXWJ46yH45XHyOi+MBzcrkkdgFZYZmHuNGL+d6T1ipWhF9YQXoM5qzzZmWQqVVOp1K9mX8ePr0VAMPMEwzK2SvEV5WnD8KwjNmd8eUw7Cxywa7cKOvUuHKF+2Y55/FRIyO0433u1bWrgjScuYC3SXpERJvgIaG7q X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Jun 2017 21:31:06.7364 (UTC) 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: DM2PR12MB0204 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1934 Lines: 63 Problem: While running IGT kms_atomic_transition test suite i encountered a hang in drmHandleEvent immidietly follwoing an atomic_commit. After dumping the atomic state I relized that in this case there was not even one CRTC attached to the state and only disabled planes. This probably due to a commit which hadn't changed any property which would require attaching crtc state. This means drmHandleEvent will never wake up from read since without CRTC in atomic state the event fd will not be singnaled. This point to a bug in IGT but also DRM should gracefully fail such scenario so no hang on user side will happen. Fix: Explicitly fail by failing atomic_commit early in drm_mode_atomic_commit where such problem can be identified. Signed-off-by: Andrey Grodzovsky --- drivers/gpu/drm/drm_atomic.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c index a567310..32eae1c 100644 --- a/drivers/gpu/drm/drm_atomic.c +++ b/drivers/gpu/drm/drm_atomic.c @@ -1933,7 +1933,7 @@ static int prepare_crtc_signaling(struct drm_device *dev, { struct drm_crtc *crtc; struct drm_crtc_state *crtc_state; - int i, ret; + int i, c = 0, ret; if (arg->flags & DRM_MODE_ATOMIC_TEST_ONLY) return 0; @@ -1994,8 +1994,17 @@ static int prepare_crtc_signaling(struct drm_device *dev, crtc_state->event->base.fence = fence; } + + c++; } + /* + * Having this flag means user mode pends on event which will never + * reach due to lack of at least one CRTC for signaling + */ + if (c == 0 && (arg->flags & DRM_MODE_PAGE_FLIP_EVENT)) + return -EINVAL; + return 0; } @@ -2179,6 +2188,8 @@ int drm_mode_atomic_ioctl(struct drm_device *dev, drm_mode_object_unreference(obj); } + + ret = prepare_crtc_signaling(dev, state, arg, file_priv, &fence_state, &num_fences); if (ret) -- 2.7.4