Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1088947ybt; Wed, 1 Jul 2020 18:37:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzm8LSoLSoez0xDfE6xMQnXLVCibvMJtUn0AW4DcIOt190xk/ik3r582qU/ll74CAOStjDD X-Received: by 2002:a50:d302:: with SMTP id g2mr32570196edh.312.1593653826353; Wed, 01 Jul 2020 18:37:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593653826; cv=none; d=google.com; s=arc-20160816; b=YqAw1PyEY9A1xC3lpWOlyU2Sk2qjzaswGCYbATh/9ZnDQ3TVurjKkTyEPR4IepZrMG q4MsEB+g4WLwUzOz6hx36/73xnKKOPpXFmWK6T+S9rdc5aeLhEQ3bjOvdU1du3quFjGN +OvmkH8x+YD9RrjGB/WMJ36DCrifAOzSIq1Ub1uTC711H3LRRHXVbv6ff9ajgr60O/Nu wu8SDdfQ84CMb6U+Upw2/ybc2i7UbHfwGYGV9Y9cZuDR/Scq+TeNsfJVTFxlEW4PPlM3 MeVAHgsx0L+sYSmem7I+tMncqb/uvYm3+0FhfEXkj/17rnM9Ko1fmw58WIH5FvHD0+xz 4d+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=qeSv3rp3+XKxSUzCwW9hHhLyG2oQDwkksvSWVMT6wsM=; b=k5Ze5U3FvxKP1R6DRlz4yg5s+myzIh1gQgITPyKlSK7FmzmseX2toLvpXjwTcBKWSr Rxh98Jk09PyQiA2Q0F97qAvM5EzXm4WtsC659vXBQP/AuvU/wqKDMqX+iVCKAMkDWGok 63VN8Iw/AibGc7PFxaQhXCiR/dapPrAHICeRtnH/BzZFnWDRE1HVb+VR4L1Q/8uN0mRl kWByCRqfhYQP5X9o2skRh5Dvmd/Rw3NEazetKUTglAdP7GDesE0b6f81LiNTKZpEnRqd mK0ihosr9nvVV/goP2qKyqlqFeFzPpAZ7VyTJ6KXP7CWltqaPIOVphUSYG5peLhDf3vD TQng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=vJLICc+F; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id mc14si4847016ejb.282.2020.07.01.18.36.43; Wed, 01 Jul 2020 18:37:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=vJLICc+F; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729159AbgGBBgi (ORCPT + 99 others); Wed, 1 Jul 2020 21:36:38 -0400 Received: from mail.kernel.org ([198.145.29.99]:53456 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728208AbgGBBXI (ORCPT ); Wed, 1 Jul 2020 21:23:08 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A965C2082F; Thu, 2 Jul 2020 01:23:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1593652987; bh=G+uS8SYJDr3PJrz8oRLSBFYFdFUlrst1MS89HE8KMjQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vJLICc+F0Q4daxgC+loBR0x4GrTUP9FLFU1q9vkjcM/tTUPd8BzHwOTzDedffTpjI 1hnAXvZZniPPSTjXbCuj3tPV5CPbDgf6jKkI6jWHhOJVRC0uKYCv+olCz6jfxijT3I AsmJMasR74oNGgNbzLcOo4SbZJYEdMwDgyT9HBKA= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Thierry Reding , Sowjanya Komatineni , Sasha Levin , dri-devel@lists.freedesktop.org, linux-tegra@vger.kernel.org Subject: [PATCH AUTOSEL 5.7 10/53] gpu: host1x: Detach driver on unregister Date: Wed, 1 Jul 2020 21:21:19 -0400 Message-Id: <20200702012202.2700645-10-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200702012202.2700645-1-sashal@kernel.org> References: <20200702012202.2700645-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Thierry Reding [ Upstream commit d9a0a05bf8c76e6dc79230669a8b5d685b168c30 ] Currently when a host1x device driver is unregistered, it is not detached from the host1x controller, which means that the device will stay around and when the driver is registered again, it may bind to the old, stale device rather than the new one that was created from scratch upon driver registration. This in turn can cause various weird crashes within the driver core because it is confronted with a device that was already deleted. Fix this by detaching the driver from the host1x controller when it is unregistered. This ensures that the deleted device also is no longer present in the device list that drivers will bind to. Reported-by: Sowjanya Komatineni Signed-off-by: Thierry Reding Tested-by: Sowjanya Komatineni Signed-off-by: Thierry Reding Signed-off-by: Sasha Levin --- drivers/gpu/host1x/bus.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/gpu/host1x/bus.c b/drivers/gpu/host1x/bus.c index 6a995db51d6d8..e201f62d62c0c 100644 --- a/drivers/gpu/host1x/bus.c +++ b/drivers/gpu/host1x/bus.c @@ -686,8 +686,17 @@ EXPORT_SYMBOL(host1x_driver_register_full); */ void host1x_driver_unregister(struct host1x_driver *driver) { + struct host1x *host1x; + driver_unregister(&driver->driver); + mutex_lock(&devices_lock); + + list_for_each_entry(host1x, &devices, list) + host1x_detach_driver(host1x, driver); + + mutex_unlock(&devices_lock); + mutex_lock(&drivers_lock); list_del_init(&driver->list); mutex_unlock(&drivers_lock); -- 2.25.1