Received: by 2002:a05:6a10:6d25:0:0:0:0 with SMTP id gq37csp1853880pxb; Mon, 13 Sep 2021 06:59:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyw3tMJHeTF0PV+23G3P9AITo9BA0Un1cB0/mrXPPeP8bX7SwYWTinguj8zBrbEY6dmRcCE X-Received: by 2002:a17:906:9aca:: with SMTP id ah10mr5484281ejc.471.1631541599651; Mon, 13 Sep 2021 06:59:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631541599; cv=none; d=google.com; s=arc-20160816; b=OZX88/XFNocTeNVfP8YXelXLO/Sc7CtfhfiWQTsbA6+NFfm3ioEX/HhSuwR5E1jThT hvw0q5zyJjyW9KD3F/3HfDtuBxmxZn0Qs1Ma6MSmAFqNFKBHgrgHeAGI9t33Ah17Zngg 5R9PgxKVhjtGcMhLUI9mBWFXG/ocvNEiVv0OwOYxMVmhFDmvzXIRXivFDJYuT4Oe7Ywx TbXBwfaGmwq0OXp66SB7vkzBhyzSNRfl3rqRNmX36IjQhQJCjV0t+L9vTMJhju080UFZ tPmAbwht2nMPIe5Hns3+5Ddt6ngumgoTnDDPzQUrCv1hovCnGJFd9PqpkRP8zwEBuZ1p zuJQ== 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=mKQ2/HETyfLPMvrmxFhgCtdABS9PHsAoQ32A0hh9Lug=; b=jSsfUqbap5iIivL41PxxJXpebtpw+otW4HCCwRzTqRlQf2dJsQvdQprQA8c/UYj05d /Y5k9WMdnncNR9FuK+kmHJqEVnHtwmKs/dUiqkx7rUg6Ne1JjwNNdHp2LwZvLQcxp59N GOzviqZgowmNCZ3+hEvY+sZJgnMPkkBqGS2fCyZOKnn/pCULTxEP0XBadOm/rlgwH+00 zMqX4upV9qYdJKEv6chPuPSXzgHuiIK3kSHkn69hAszqzA1llN3dt+tVkL5ppeIsVJAx SQNdcBI5elLzp+1G4lqPbpsXFAA1e6IOtCsNlrkgpsWky6WpRwHj285YGU076MTUqElJ tPtg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=faJ+HbRf; 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=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bf15si456975edb.235.2021.09.13.06.59.35; Mon, 13 Sep 2021 06:59:59 -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=@linuxfoundation.org header.s=korg header.b=faJ+HbRf; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243063AbhIMN5O (ORCPT + 99 others); Mon, 13 Sep 2021 09:57:14 -0400 Received: from mail.kernel.org ([198.145.29.99]:34858 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244505AbhIMNw5 (ORCPT ); Mon, 13 Sep 2021 09:52:57 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 3B3EE61989; Mon, 13 Sep 2021 13:34:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1631540082; bh=nxQOD2cSaX5Eq3Hfl2thhKveroqfSWH++lJ0x1IcsRw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=faJ+HbRfwS4l8VishPjcpanitPB21Z1kcJvEhKkRqtB8sJT7Or6bg0SSR88tlw4ZT 2kWncqeXbRSjsFJ7AW/tVuRN4VHRYB1PnOvvvPsXvdSKTSPrjz2gY3yptyvwx4tbUV C0wacRpnrwAyazQlDPTkIZpA6In4Bho9+UnXrOiQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Matthew Rosato , Niklas Schnelle , Heiko Carstens , Sasha Levin Subject: [PATCH 5.13 043/300] s390/pci: fix misleading rc in clp_set_pci_fn() Date: Mon, 13 Sep 2021 15:11:44 +0200 Message-Id: <20210913131110.792099844@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210913131109.253835823@linuxfoundation.org> References: <20210913131109.253835823@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 [ Upstream commit f7addcdd527a6dddfebe20c358b87bdb95624612 ] Currently clp_set_pci_fn() always returns 0 as long as the CLP request itself succeeds even if the operation itself returns a response code other than CLP_RC_OK or CLP_RC_SETPCIFN_ALRDY. This is highly misleading because calling code assumes that a zero rc means that the operation was successful. Fix this by returning the response code or cc on failure with the exception of the special handling for CLP_RC_SETPCIFN_ALRDY. Also let's not assume that the returned function handle for CLP_RC_SETPCIFN_ALRDY is 0, we don't need it anyway. Reviewed-by: Matthew Rosato Signed-off-by: Niklas Schnelle Signed-off-by: Heiko Carstens Signed-off-by: Sasha Levin --- arch/s390/pci/pci.c | 7 ++++--- arch/s390/pci/pci_clp.c | 33 ++++++++++++++++----------------- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/arch/s390/pci/pci.c b/arch/s390/pci/pci.c index 8fcb7ecb7225..77cd965cffef 100644 --- a/arch/s390/pci/pci.c +++ b/arch/s390/pci/pci.c @@ -661,9 +661,10 @@ int zpci_enable_device(struct zpci_dev *zdev) { int rc; - rc = clp_enable_fh(zdev, ZPCI_NR_DMA_SPACES); - if (rc) + if (clp_enable_fh(zdev, ZPCI_NR_DMA_SPACES)) { + rc = -EIO; goto out; + } rc = zpci_dma_init_device(zdev); if (rc) @@ -684,7 +685,7 @@ int zpci_disable_device(struct zpci_dev *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); + return clp_disable_fh(zdev) ? -EIO : 0; } /** diff --git a/arch/s390/pci/pci_clp.c b/arch/s390/pci/pci_clp.c index d3331596ddbe..0a0e8b8293be 100644 --- a/arch/s390/pci/pci_clp.c +++ b/arch/s390/pci/pci_clp.c @@ -213,15 +213,19 @@ out: } static int clp_refresh_fh(u32 fid); -/* - * Enable/Disable a given PCI function and update its function handle if - * necessary +/** + * clp_set_pci_fn() - Execute a command on a PCI function + * @zdev: Function that will be affected + * @nr_dma_as: DMA address space number + * @command: The command code to execute + * + * Returns: 0 on success, < 0 for Linux errors (e.g. -ENOMEM), and + * > 0 for non-success platform responses */ static int clp_set_pci_fn(struct zpci_dev *zdev, u8 nr_dma_as, u8 command) { struct clp_req_rsp_set_pci *rrb; int rc, retries = 100; - u32 fid = zdev->fid; rrb = clp_alloc_block(GFP_KERNEL); if (!rrb) @@ -245,17 +249,16 @@ static int clp_set_pci_fn(struct zpci_dev *zdev, u8 nr_dma_as, u8 command) } } while (rrb->response.hdr.rsp == CLP_RC_SETPCIFN_BUSY); - if (rc || rrb->response.hdr.rsp != CLP_RC_OK) { - zpci_err("Set PCI FN:\n"); - zpci_err_clp(rrb->response.hdr.rsp, rc); - } - if (!rc && rrb->response.hdr.rsp == CLP_RC_OK) { zdev->fh = rrb->response.fh; - } else if (!rc && rrb->response.hdr.rsp == CLP_RC_SETPCIFN_ALRDY && - rrb->response.fh == 0) { + } else if (!rc && rrb->response.hdr.rsp == CLP_RC_SETPCIFN_ALRDY) { /* Function is already in desired state - update handle */ - rc = clp_refresh_fh(fid); + rc = clp_refresh_fh(zdev->fid); + } else { + zpci_err("Set PCI FN:\n"); + zpci_err_clp(rrb->response.hdr.rsp, rc); + if (!rc) + rc = rrb->response.hdr.rsp; } clp_free_block(rrb); return rc; @@ -301,17 +304,13 @@ int clp_enable_fh(struct zpci_dev *zdev, u8 nr_dma_as) rc = clp_set_pci_fn(zdev, nr_dma_as, CLP_SET_ENABLE_PCI_FN); zpci_dbg(3, "ena fid:%x, fh:%x, rc:%d\n", zdev->fid, zdev->fh, rc); - if (rc) - goto out; - - if (zpci_use_mio(zdev)) { + if (!rc && zpci_use_mio(zdev)) { rc = clp_set_pci_fn(zdev, nr_dma_as, CLP_SET_ENABLE_MIO); zpci_dbg(3, "ena mio fid:%x, fh:%x, rc:%d\n", zdev->fid, zdev->fh, rc); if (rc) clp_disable_fh(zdev); } -out: return rc; } -- 2.30.2