Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp2215398imm; Thu, 7 Jun 2018 07:12:03 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIh15qnvJSom4QBwAG1B9SA+zMEghe0Dn9lQDGRlmXIhQuYNwnQ9RmC1zZ1TqJQqlBaLQ4F X-Received: by 2002:a65:5106:: with SMTP id f6-v6mr1731757pgq.122.1528380723892; Thu, 07 Jun 2018 07:12:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528380723; cv=none; d=google.com; s=arc-20160816; b=I4IHRrJlDSKrqp1NAimdQZn8R36c0tDdSW7S646tcC6VrZXTTsAFKLkUWcU0gEAtPQ YJNe062p6QDMo+BCWi/A3S7B8yGWx3VN6HdkFT5eQ8Xq1+2C7s8HXi1S5cdJSI2xgWsJ TEM7/GGRZAtxanMu4GUtcrYOY1cu4hcsJEVYaaE9lH5FNtZ3aTjHmejLEQeB4/fojlQL jfo0Dyi0wSH12fSSIBnbpC+ylB9tUQpx0fAnjNB+q8p1oq6DlMvPvVsYVl0fy4X6ihaR 5s45if0MSDGaiPsqXmeevCbREsAANIAUbjv+M2nFW4ztYdRvMypdcdaO67scrPYaBACx iN7g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:subject:message-id:date:cc:to :from:mime-version:content-transfer-encoding:content-disposition :arc-authentication-results; bh=e8ZwaVuoXGvhxXQ4wZOpVt6b6aVQjA33k6VLW016DL4=; b=zAt9by3CvzebM6J2oxhdL1WKmE0h2wEWN5S1d2QxAlk3wV9cmf4VIMiGkzewy5RphM XHrzN4adL6eTK6CuP8yWLvzqidVDsvf2DQOqnenvmi0KFWqhtbI8mjAlp6NtLgX0bPi/ wHqeXkg7Op7i8j7rZxJpgYZa3DCmONPwB2mqhHf+GaLDhcg+E2fySXycNHGlaLVH5wm+ ttG1ZmUP+yXvmagcRk8lOWD6sVKilZbdxK6t7en1roRf2wKMbK6TrrCUIkWi2lY53TSl g5B5uxpMUNgTeFxDwh2eyaws7Sh5E4j48mPo6EMhg77ojFg7iN2Oqw0WnxdAQFk+4Ek3 eUTA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s3-v6si54015359plb.394.2018.06.07.07.11.47; Thu, 07 Jun 2018 07:12:03 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933290AbeFGOJ4 (ORCPT + 99 others); Thu, 7 Jun 2018 10:09:56 -0400 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:39345 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933143AbeFGOJ2 (ORCPT ); Thu, 7 Jun 2018 10:09:28 -0400 Received: from [148.252.241.226] (helo=deadeye) by shadbolt.decadent.org.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1fQvbQ-0005Zk-BB; Thu, 07 Jun 2018 15:09:24 +0100 Received: from ben by deadeye with local (Exim 4.91) (envelope-from ) id 1fQvbC-0003DZ-Cs; Thu, 07 Jun 2018 15:09:10 +0100 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, "Takashi Iwai" Date: Thu, 07 Jun 2018 15:05:21 +0100 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) Subject: [PATCH 3.16 343/410] ALSA: seq: Clear client entry before deleting else at closing In-Reply-To: X-SA-Exim-Connect-IP: 148.252.241.226 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on shadbolt.decadent.org.uk); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.16.57-rc1 review patch. If anyone has any objections, please let me know. ------------------ From: Takashi Iwai commit a2ff19f7b70118ced291a28d5313469914de451b upstream. When releasing a client, we need to clear the clienttab[] entry at first, then call snd_seq_queue_client_leave(). Otherwise, the in-flight cell in the queue might be picked up by the timer interrupt via snd_seq_check_queue() before calling snd_seq_queue_client_leave(), and it's delivered to another queue while the client is clearing queues. This may eventually result in an uncleared cell remaining in a queue, and the later snd_seq_pool_delete() may need to wait for a long time until the event gets really processed. By moving the clienttab[] clearance at the beginning of release, any event delivery of a cell belonging to this client will fail at a later point, since snd_seq_client_ptr() returns NULL. Thus the cell that was picked up by the timer interrupt will be returned immediately without further delivery, and the long stall of snd_seq_delete_pool() can be avoided, too. Signed-off-by: Takashi Iwai Signed-off-by: Ben Hutchings --- sound/core/seq/seq_clientmgr.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/sound/core/seq/seq_clientmgr.c +++ b/sound/core/seq/seq_clientmgr.c @@ -270,12 +270,12 @@ static int seq_free_client1(struct snd_s if (!client) return 0; - snd_seq_delete_all_ports(client); - snd_seq_queue_client_leave(client->number); spin_lock_irqsave(&clients_lock, flags); clienttablock[client->number] = 1; clienttab[client->number] = NULL; spin_unlock_irqrestore(&clients_lock, flags); + snd_seq_delete_all_ports(client); + snd_seq_queue_client_leave(client->number); snd_use_lock_sync(&client->use_lock); snd_seq_queue_client_termination(client->number); if (client->pool)