Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp3289830pxk; Mon, 21 Sep 2020 09:48:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwlItfKJIOxIPmQKlOki3VD0L3cshEK8L+1nY1gL7YuPI9vpgfQMS8ajZ60rwkUfRHJbEGh X-Received: by 2002:a17:906:4b18:: with SMTP id y24mr297157eju.471.1600706911802; Mon, 21 Sep 2020 09:48:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600706911; cv=none; d=google.com; s=arc-20160816; b=GImILm+jNIF7PKIjs2+hGw+Li07C/KhVfdG/212BJnmgJBcnyjQifFRbNWQxNv4IYr e2oIdV8ma9KC+1LBk160paXfncjA1mDqpU+gI2pDqqJbKwk+S6ffjHq8wMbz24+dCxkH T2xattdMGsxvcsEqBpVAeM9bQT7rGhypESaw4KMibAbqWnw3IjNZvX+bhWipHT4QZwGs 3DyXMk3Q7vfbQYcIIvU9x+NM+F3wyMAkC9Boky/aom5EatP/r8/nXbRIJ1zxrP0taF61 tA9HKVJZyfKN+2C3UEIn11fdmcgn8e3Aggd97NUOqifdKkyxYP7ADkAKfjqXj9gNLCZe plmw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=aIqVy8z5OBSJvD957Dufi9XjiNRaLDuOVKUjhncAwDk=; b=bhV8c6G9PlEbfxqh++FhDD5tIZWUrax5qfjXtWs69hTdSHXAKiM6JhO2LaTRYF8td+ 4mbwG65pxi+8AKJ28K17xmfVGpaxSizj3Eor250+KcT9SCruXaK65NP22+BDKCMM3QG1 TWm+4hpejdKAD5CnDjxqOQa+5b6TmaHx2OPuxxuMR+AXa1udfNB+a2+RqfWCABbGUBLa dW5d0PwBGElcqW80zg9RkdrVtpvi69y519ajhVIvZaoVx7OLVESJr+mhISJBWD89cT9L HKeUwGX/d6RDXvEEOGTsW3nvUw5xhxlyy25Gg20nxusdI1Ki2zz2+rN58Afbo8/ET5vA VDGg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=rEJM1ndZ; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b43si9858840edf.15.2020.09.21.09.48.07; Mon, 21 Sep 2020 09:48:31 -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=rEJM1ndZ; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729590AbgIUQrM (ORCPT + 99 others); Mon, 21 Sep 2020 12:47:12 -0400 Received: from mail.kernel.org ([198.145.29.99]:53646 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727412AbgIUQrC (ORCPT ); Mon, 21 Sep 2020 12:47:02 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id DB6F82389F; Mon, 21 Sep 2020 16:47:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600706821; bh=WiWAqd2NFS/VpEVznbbvD9dZ0N0TpPY0Rh6YenjeuCM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rEJM1ndZH5PIUppsqCELyOCFa/gn44fd/xWCTKm3+Xw7+HYVyeAuyNaV23F9vtoLW USHQuzzvBi0xTUDF2flTfZw8xUEjT45EuagEhFplVTJw4dPCpUjod7+NECI3DlybkJ 0IADndU3AEmrntaQe60kTMsBSyijiurKa4db3FJM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Niklas Schnelle , Vasily Gorbik Subject: [PATCH 5.8 107/118] s390/pci: fix leak of DMA tables on hard unplug Date: Mon, 21 Sep 2020 18:28:39 +0200 Message-Id: <20200921162041.346347826@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200921162036.324813383@linuxfoundation.org> References: <20200921162036.324813383@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Niklas Schnelle commit afdf9550e54627fcf4dd609bdc1153059378cdf5 upstream. commit f606b3ef47c9 ("s390/pci: adapt events for zbus") removed the zpci_disable_device() call for a zPCI event with PEC 0x0304 because the device is already deconfigured by the platform. This however skips the Linux side of the disable in particular it leads to leaking the DMA tables and bitmaps because zpci_dma_exit_device() is never called on the device. If the device transitions to the Reserved state we call zpci_zdev_put() but zpci_release_device() will not call zpci_disable_device() because the state of the zPCI function is already ZPCI_FN_STATE_STANDBY. If the device is put into the Standby state, zpci_disable_device() is not called and the device is assumed to have been put in Standby through platform action. At this point the device may be removed by a subsequent event with PEC 0x0308 or 0x0306 which calls zpci_zdev_put() with the same problem as above or the device may be configured again in which case zpci_disable_device() is also not called. Fix this by calling zpci_disable_device() explicitly for PEC 0x0304 as before. To make it more clear that zpci_disable_device() may be called, even if the lower level device has already been disabled by the platform, add a comment to zpci_disable_device(). Cc: # 5.8 Fixes: f606b3ef47c9 ("s390/pci: adapt events for zbus") Signed-off-by: Niklas Schnelle Signed-off-by: Vasily Gorbik Signed-off-by: Greg Kroah-Hartman --- arch/s390/pci/pci.c | 4 ++++ arch/s390/pci/pci_event.c | 2 ++ 2 files changed, 6 insertions(+) --- a/arch/s390/pci/pci.c +++ b/arch/s390/pci/pci.c @@ -668,6 +668,10 @@ EXPORT_SYMBOL_GPL(zpci_enable_device); int zpci_disable_device(struct zpci_dev *zdev) { zpci_dma_exit_device(zdev); + /* + * The zPCI function may already be disabled by the platform, this is + * detected in clp_disable_fh() which becomes a no-op. + */ return clp_disable_fh(zdev); } EXPORT_SYMBOL_GPL(zpci_disable_device); --- a/arch/s390/pci/pci_event.c +++ b/arch/s390/pci/pci_event.c @@ -143,6 +143,8 @@ static void __zpci_event_availability(st zpci_remove_device(zdev); } + zdev->fh = ccdf->fh; + zpci_disable_device(zdev); zdev->state = ZPCI_FN_STATE_STANDBY; if (!clp_get_state(ccdf->fid, &state) && state == ZPCI_FN_STATE_RESERVED) {