From patchwork Fri Dec 18 22:14:42 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harry Wentland X-Patchwork-Id: 7888831 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.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id DDD7EBEEE5 for ; Fri, 18 Dec 2015 22:15:07 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D894A2051F for ; Fri, 18 Dec 2015 22:15:06 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id DCABA2035E for ; Fri, 18 Dec 2015 22:15:05 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 1A4C56EB0A; Fri, 18 Dec 2015 14:15:05 -0800 (PST) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from na01-bl2-obe.outbound.protection.outlook.com (mail-bl2on0098.outbound.protection.outlook.com [65.55.169.98]) by gabe.freedesktop.org (Postfix) with ESMTPS id 8874D6EB0A for ; Fri, 18 Dec 2015 14:15:03 -0800 (PST) Received: from BN4PR12MB0849.namprd12.prod.outlook.com (10.164.59.11) by BN4PR12MB0867.namprd12.prod.outlook.com (10.164.59.17) with Microsoft SMTP Server (TLS) id 15.1.361.13; Fri, 18 Dec 2015 22:15:01 +0000 Received: from CY1PR1201CA0029.namprd12.prod.outlook.com (10.169.17.167) by BN4PR12MB0849.namprd12.prod.outlook.com (10.164.59.11) with Microsoft SMTP Server (TLS) id 15.1.361.13; Fri, 18 Dec 2015 22:14:59 +0000 Received: from CO1NAM03FT008.eop-NAM03.prod.protection.outlook.com (2a01:111:f400:7e48::202) by CY1PR1201CA0029.outlook.office365.com (2a01:111:e400:5b9a::39) with Microsoft SMTP Server (TLS) id 15.1.361.13 via Frontend Transport; Fri, 18 Dec 2015 22:14:59 +0000 Authentication-Results: spf=none (sender IP is 165.204.84.221) 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; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) Received: from atltwp01.amd.com (165.204.84.221) by CO1NAM03FT008.mail.protection.outlook.com (10.152.80.81) with Microsoft SMTP Server id 15.1.355.15 via Frontend Transport; Fri, 18 Dec 2015 22:14:58 +0000 X-WSS-ID: 0NZKR4W-07-35Z-02 X-M-MSG: Received: from satlvexedge02.amd.com (satlvexedge02.amd.com [10.177.96.29]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by atltwp01.amd.com (Axway MailGate 5.3.1) with ESMTPS id 22442CAFA98 for ; Fri, 18 Dec 2015 17:14:56 -0500 (EST) Received: from SATLEXDAG04.amd.com (10.181.40.9) by SATLVEXEDGE02.amd.com (10.177.96.29) with Microsoft SMTP Server (TLS) id 14.3.195.1; Fri, 18 Dec 2015 16:15:25 -0600 Received: from STOREXDAG02.amd.com (10.1.13.11) by satlexdag04.amd.com (10.181.40.9) with Microsoft SMTP Server (TLS) id 14.3.266.1; Fri, 18 Dec 2015 17:14:55 -0500 Received: from cnhwentlanub.amd.com (172.29.225.36) by storexdag02.amd.com (10.1.13.11) with Microsoft SMTP Server id 14.3.266.1; Fri, 18 Dec 2015 17:14:55 -0500 From: Harry Wentland To: Subject: [PATCH 1/2] drm/dp/mst: process broadcast messages correctly Date: Fri, 18 Dec 2015 17:14:42 -0500 Message-ID: <1450476883-1586-2-git-send-email-harry.wentland@amd.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1450476883-1586-1-git-send-email-harry.wentland@amd.com> References: <1450476883-1586-1-git-send-email-harry.wentland@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-Forefront-Antispam-Report: CIP:165.204.84.221; CTRY:US; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(2980300002)(428002)(199003)(189002)(19580405001)(33646002)(47776003)(19580395003)(5008740100001)(105586002)(106466001)(48376002)(450100001)(53416004)(5003940100001)(50466002)(87936001)(5003600100002)(86362001)(2351001)(92566002)(229853001)(97736004)(110136002)(77096005)(36756003)(586003)(189998001)(1096002)(101416001)(76176999)(50986999)(2950100001)(11100500001)(1220700001)(50226001); DIR:OUT; SFP:1101; SCL:1; SRVR:BN4PR12MB0849; H:atltwp01.amd.com; FPR:; SPF:None; PTR:InfoDomainNonexistent; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BN4PR12MB0849; 2:jEkTlpwguBCm561mKfkwUBIie3gDmqf3GCAwJNmPTjkjk2fG1C+OXa/N45cu24BQr1BcfLICRn9lOux4FMZv922nKjy8BnGx0cRvdd8L06kGQ1LgmDv8f6KM2HZ/4whk15Hc4SEmsF3joSHLae7Yiw==; 3:cnSSpXT+pCF0vzQ7YXwlABbnzNTY1t6yLzpSvHWT+wZRQYNlugwhk6BXSY0LMuaV9h6+n3IL0f65nPJtGBhLecxDT5YuduRPFlcZYWoBj4xy0hlNqpFLmWBzJ4YIOW7+M3LJ+3OkUihg8w1B2yLR893Bj8jSH+43S/rINYiiqOkOhyzrhPCOnWueTQc+gAUZTzs3v/6hfQGc+qABNfvyrfcKsFBSuYj00QWomHSD4Ls=; 25:ElJcC1dNMvbYVBMtbOr4J0pGRMot/WCQ4uIj3lY8aEWFZJQ6qyvhL+Bkf01Up79GMpmTca6lICUpG/phQs/+8PkkNje1TgkHte6ahw4YSCAjufZwckkCd63Bx2WXsp29i/XcaD5Sh+qiPftyg93vgaJOmmlXFgGeCcjrgKS5hcqnJCkY9MSk0iAjpFw0c/R0xRXhd0L1pEUHPq6ZOY7lTK8QQA+vgcFDE4/vNE0FRVxCm7s4n529Kfyo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= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(767451399110); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(5005006)(520078)(8121501046)(10201501046)(3002001); SRVR:BN4PR12MB0849; BCL:0; PCL:0; RULEID:; SRVR:BN4PR12MB0849; X-Forefront-PRVS: 07943272E1 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BN4PR12MB0849; 23:BJxpJ7Dg3U6Jhn1u0lSeKsljfIyCcrkF2FJ1geB2m?= =?us-ascii?Q?zKMrveCcD1JUJBotqv4kVk4vF+G/h/9F8lpAlr/TptUwzfIT633syMQ4WXGj?= =?us-ascii?Q?pnRwL2q0ocjiFQ8xrPHiM6bubMsY966CX4E+yFveQqrrkW/qQxJw0Fq4aRqf?= =?us-ascii?Q?bGLWviln6ZFGXEKUgE/3RhY9V9EciR7PuvdnptZR6b1tNsi6h38s7XgTgl7U?= =?us-ascii?Q?5aoUwonzlor0MwzYW2nXIWVo+xDrOVRYEPMroyGrDTNBBIrAIA1ExwAd+hAo?= =?us-ascii?Q?U4H4CBQuDejk8ratNAnxBgMj3wW7JI66okKcX8+bAwKKHGaSlq5dYAYx4eYE?= =?us-ascii?Q?kAHGP4WMMfdabsQx8N32Ivb6NyGXL4WGNfJOUPAbCtfjVupAS8sqcNUovmp9?= =?us-ascii?Q?bNLVutvnUule4U6FP1oequWGwomMJDzr87TRezoyvww6Dp0HG8VxJHMwAZkc?= =?us-ascii?Q?OSHNqtIppSO8uF8reWLfCSitpHIyUO2fCRQLHbMGSG1W1k8dpBuBvD9vYybi?= =?us-ascii?Q?gY/nNCUkhhC/bVOqaqa+bnYR2aAGOsumBSXeBNQewQELYW5Rnv1B2GiPN+h1?= =?us-ascii?Q?Z4hU6ALqB1HXfawG3VMeKaGmkyREvK04EvBTiWxGkECiNP2zRs+cXtvyKwst?= =?us-ascii?Q?Fw3msGfZecporZhb4E52i+Ng5AlrJZ2r+j3+qKmqmTrZg8WjAYPFPlXQyILJ?= =?us-ascii?Q?kpmjCQNKnoMfV5yd4Dyd4WAvA+mJKrpNtb40lK7mhSubpjK0GC2RzpbQzzRr?= =?us-ascii?Q?aADHwT0Op7pv9+e+B7nqGXkAD1ce/X9lqxXh12JPu8juZTX+2irX6Aj+S9b8?= =?us-ascii?Q?wSxdpk16pAm7Ju1RbTY5hQlNvkAFo5BQWdj5yX/H9GTolm42D+JIDNHz9FVZ?= =?us-ascii?Q?rbZZ1LwIoCodkclM4OtGIs/vjDQTrftKJ5rrZEtgqChm1CYuiHewxPSyYkqa?= =?us-ascii?Q?UUq++6fo0UfbxB0ivn2wnMsVpbU3/UwbDh5VonhfZm91ZiZV4fMLNz+i8cmc?= =?us-ascii?Q?d8=3D?= X-Microsoft-Exchange-Diagnostics: 1; BN4PR12MB0849; 5:K2kaFb7iaV/z7RSWf0PCHMvr9TlximgcBZEJR7hM+sDDv8xufAFjksJ4Y0K0BZtNeDDGSwWPZ+RLIo1kJvBYzcdS+KOo9a6XDb0d2dbR27EDcoreJiVpsFdSB/c9kSt/N0MSenhLUNGwOKLEpeYaEQ==; 24:HtzijN7RFVAw9WOUtAkz4MM/QL5Dou9gL/aihdf1LFEz5VA6tHal2pW1/cjQFE8AUXiUWwFt/qzCaLQCxqdRO4/sfp2LxQxX960+uk7chS4=; 20:W1jjewkjownzqkT6EZEP5zbH/NS0QhOOKC6LFEz4lZb0IohmORDxqUVzhNEc1j/l/4HabQ4AZAA50Rr6PyYKlBV054PVBjpOLk1trWlud0RKyzKfaOe4ZZzigte6OIj9GE/+YMEPZQuxcCJU6a8hDe6ZBjiKmBMdTlyriE3Nmft+arqD51yLPL/RnJIQQ4hgbe4aqTM7ekyxH/6DScuWwDEKseM+zLmaE511vlze2Y8X1rIcCet5blFl+MQAoxuj SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Dec 2015 22:14:58.6644 (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.221]; Helo=[atltwp01.amd.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN4PR12MB0849 X-Microsoft-Exchange-Diagnostics: 1; BN4PR12MB0867; 2:GT5EI7zTsGPQcfAXVTSnU145SBYpnO4I7Loswqa8yr7ByZ7ukdzxgajOitFjBhBA9OYcQ5AA686ffYtrHAWspCHIxAIeDbmLYzjyNsW9k0ex5zhq/5RMGqL5Uq1V6FAxpSZlFzi3ucE9DdxwOQ0gjg==; 23:vactWEcEYTkJhVKR6HwD26EY7A53mgJoRKsOBgu744icXdW4WlDC8KV/C4W4Vmj1si6goJLk46/LwhICtSvp02pe51dzWg6kiwZZrwG0F0DW3XJEqBBjOWEbHoAWb9guuITuvjGkXqkhypltaaLK3g0LKc2G/s8NdR4pf0Fvr36o0WIpgOYIIJ83iGuzoLKc X-OriginatorOrg: amd.com Cc: Mykola Lysenko 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: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Spam-Status: No, score=-4.2 required=5.0 tests=BAD_ENC_HEADER,BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, 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 From: Mykola Lysenko In case broadcast message received in UP request, RAD cannot be used to identify message originator. Message should be parsed, originator should be found by GUID from parsed message. Also reply with broadcast in case broadcast message received (for now it is always broadcast) Signed-off-by: Mykola Lysenko --- drivers/gpu/drm/drm_dp_mst_topology.c | 95 +++++++++++++++++++++++++++++++---- 1 file changed, 84 insertions(+), 11 deletions(-) diff --git a/drivers/gpu/drm/drm_dp_mst_topology.c b/drivers/gpu/drm/drm_dp_mst_topology.c index 809959d56d78..3baa95c1b14b 100644 --- a/drivers/gpu/drm/drm_dp_mst_topology.c +++ b/drivers/gpu/drm/drm_dp_mst_topology.c @@ -1210,6 +1210,50 @@ out: return mstb; } +static struct drm_dp_mst_branch *get_mst_branch_device_by_guid_helper( + struct drm_dp_mst_branch *mstb, + uint8_t *guid) +{ + struct drm_dp_mst_branch *found_mstb; + struct drm_dp_mst_port *port; + + list_for_each_entry(port, &mstb->ports, next) { + if (!port->mstb) + continue; + + if (port->guid_valid && memcmp(port->guid, guid, 16) == 0) + return port->mstb; + + found_mstb = get_mst_branch_device_by_guid_helper(port->mstb, guid); + + if (found_mstb) + return found_mstb; + } + + return NULL; +} + +static struct drm_dp_mst_branch *drm_dp_get_mst_branch_device_by_guid( + struct drm_dp_mst_topology_mgr *mgr, + uint8_t *guid) +{ + struct drm_dp_mst_branch *mstb; + + /* find the port by iterating down */ + mutex_lock(&mgr->lock); + + if (mgr->guid_valid && memcmp(mgr->guid, guid, 16) == 0) + mstb = mgr->mst_primary; + else + mstb = get_mst_branch_device_by_guid_helper(mgr->mst_primary, guid); + + if (mstb) + kref_get(&mstb->kref); + + mutex_unlock(&mgr->lock); + return mstb; +} + static void drm_dp_check_and_send_link_address(struct drm_dp_mst_topology_mgr *mgr, struct drm_dp_mst_branch *mstb) { @@ -1320,6 +1364,7 @@ static int set_hdr_from_dst_qlock(struct drm_dp_sideband_msg_hdr *hdr, struct drm_dp_sideband_msg_tx *txmsg) { struct drm_dp_mst_branch *mstb = txmsg->dst; + u8 req_type; /* both msg slots are full */ if (txmsg->seqno == -1) { @@ -1336,7 +1381,13 @@ static int set_hdr_from_dst_qlock(struct drm_dp_sideband_msg_hdr *hdr, txmsg->seqno = 1; mstb->tx_slots[txmsg->seqno] = txmsg; } - hdr->broadcast = 0; + + req_type = txmsg->msg[0] & 0x7f; + if (req_type == DP_CONNECTION_STATUS_NOTIFY || + req_type == DP_RESOURCE_STATUS_NOTIFY) + hdr->broadcast = 1; + else + hdr->broadcast = 0; hdr->path_msg = txmsg->path_msg; hdr->lct = mstb->lct; hdr->lcr = mstb->lct - 1; @@ -2145,28 +2196,50 @@ static int drm_dp_mst_handle_up_req(struct drm_dp_mst_topology_mgr *mgr) if (mgr->up_req_recv.have_eomt) { struct drm_dp_sideband_msg_req_body msg; - struct drm_dp_mst_branch *mstb; + struct drm_dp_mst_branch *mstb = NULL; bool seqno; - mstb = drm_dp_get_mst_branch_device(mgr, - mgr->up_req_recv.initial_hdr.lct, - mgr->up_req_recv.initial_hdr.rad); - if (!mstb) { - DRM_DEBUG_KMS("Got MST reply from unknown device %d\n", mgr->up_req_recv.initial_hdr.lct); - memset(&mgr->up_req_recv, 0, sizeof(struct drm_dp_sideband_msg_rx)); - return 0; + + if (!mgr->up_req_recv.initial_hdr.broadcast) { + mstb = drm_dp_get_mst_branch_device(mgr, + mgr->up_req_recv.initial_hdr.lct, + mgr->up_req_recv.initial_hdr.rad); + if (!mstb) { + DRM_DEBUG_KMS("Got MST reply from unknown device %d\n", mgr->up_req_recv.initial_hdr.lct); + memset(&mgr->up_req_recv, 0, sizeof(struct drm_dp_sideband_msg_rx)); + return 0; + } } seqno = mgr->up_req_recv.initial_hdr.seqno; drm_dp_sideband_parse_req(&mgr->up_req_recv, &msg); if (msg.req_type == DP_CONNECTION_STATUS_NOTIFY) { - drm_dp_send_up_ack_reply(mgr, mstb, msg.req_type, seqno, false); + drm_dp_send_up_ack_reply(mgr, mgr->mst_primary, msg.req_type, seqno, false); + + if (!mstb) + mstb = drm_dp_get_mst_branch_device_by_guid(mgr, msg.u.conn_stat.guid); + + if (!mstb) { + DRM_DEBUG_KMS("Got MST reply from unknown device %d\n", mgr->up_req_recv.initial_hdr.lct); + memset(&mgr->up_req_recv, 0, sizeof(struct drm_dp_sideband_msg_rx)); + return 0; + } + drm_dp_update_port(mstb, &msg.u.conn_stat); DRM_DEBUG_KMS("Got CSN: pn: %d ldps:%d ddps: %d mcs: %d ip: %d pdt: %d\n", msg.u.conn_stat.port_number, msg.u.conn_stat.legacy_device_plug_status, msg.u.conn_stat.displayport_device_plug_status, msg.u.conn_stat.message_capability_status, msg.u.conn_stat.input_port, msg.u.conn_stat.peer_device_type); (*mgr->cbs->hotplug)(mgr); } else if (msg.req_type == DP_RESOURCE_STATUS_NOTIFY) { - drm_dp_send_up_ack_reply(mgr, mstb, msg.req_type, seqno, false); + drm_dp_send_up_ack_reply(mgr, mgr->mst_primary, msg.req_type, seqno, false); + if (!mstb) + mstb = drm_dp_get_mst_branch_device_by_guid(mgr, msg.u.resource_stat.guid); + + if (!mstb) { + DRM_DEBUG_KMS("Got MST reply from unknown device %d\n", mgr->up_req_recv.initial_hdr.lct); + memset(&mgr->up_req_recv, 0, sizeof(struct drm_dp_sideband_msg_rx)); + return 0; + } + DRM_DEBUG_KMS("Got RSN: pn: %d avail_pbn %d\n", msg.u.resource_stat.port_number, msg.u.resource_stat.available_pbn); }