Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp15405pxv; Wed, 21 Jul 2021 14:08:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJybCRmW3pqAunire0pBaN9MH9xzQIj1TDKk1mueiw5YOgPE0QTqqGMcx4dF0DZA70AoAX9f X-Received: by 2002:a92:a005:: with SMTP id e5mr24866679ili.22.1626901733336; Wed, 21 Jul 2021 14:08:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626901733; cv=none; d=google.com; s=arc-20160816; b=cTC0B0iRr4hWp4CbK7qLY4fBlpRV1EHSlRjIRPwfzxWeATkbQcad5MSy0HaLm2xOr6 BaX1L4pCZfLrqN9lPUhbvrVcL3J6t0RlYI7AI2S4rVCAPsA57YzT+kN2JfYDh7+pcJxI doehK/aaWHJWK6gI8EahJ2/fxR3m5TA3+pX/kPWGa2904FKKgm6F3yC4Bt9pGkaAtSi4 XL9PrkMqlHP4Emxzsv6+cnxW8bT8BGabOwNiMol1WthQk8btxAhEZxYzNr5fgwWHM9qK 21ZHi672mDgY5BJLErYxlikecfJ+lgPwo4Dn9pxoqKVMHuykNG7jb7JIe1lIh32iNh2Q AZ5A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:message-id:subject:cc:to:from:date :dkim-signature; bh=13w6qxR3Ss7lQyxBN7IuqurD9NQs2ZRmWOAduj2u5UE=; b=SM42QppLj/Hl0k6qpcVkRLOSZQN4pUvftTRe+2YIZLWsfLR4cYhjOOgY8OofXsKMCE Iga/ZcM1avV9fhYmDt/o3pcHLZJi0fJWbVk0mNz/3/engrBLlzgbNj8Ezs859fi07Q4s JbuApBi5YINuJtMjVq4YVFlrhpD9qHcm/YhSe9Wh4bPrVVCTyOZcz8enL6NzZtIlkxKG 4ZgoXdmjTrUWh569gZ6+qvDpNEHmA5CgGLBksyOv8PujKxhnbtZ90VPLk0OBLbO8Gy1Y Ya+dTOLG3LHAPWxOtuOV72RCwMvq10FElIOhPmfivpGQ0vOhvwIGywUVaT0y2YOREvlm n9zw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=l7LN4F5A; 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 j25si16384674jaj.93.2021.07.21.14.08.30; Wed, 21 Jul 2021 14:08:53 -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=k20201202 header.b=l7LN4F5A; 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 S229981AbhGUUZE (ORCPT + 99 others); Wed, 21 Jul 2021 16:25:04 -0400 Received: from mail.kernel.org ([198.145.29.99]:35282 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229553AbhGUUZE (ORCPT ); Wed, 21 Jul 2021 16:25:04 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 0054B613CF; Wed, 21 Jul 2021 21:05:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1626901540; bh=tj/psHZVOLlDkwuiz1uuoYF+xeG3Zg+lxZvapxYfkpI=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=l7LN4F5AMUXzx0HjrWRoUkDi6oNjl+za5SCJ/CMWfTesN1H3FK83CIn5sl/dWj+cf jjOWUtiUiGWFwPFa1gDtYm1hemWSb5aaQ3g9cNhcoPzfT+0uOE9xul5OXWoLpjNCZn CEcZMdki6MMLDefpIk+ewP0mVVaSQARa2J347D22ukn24Bbzg869y6oyAofjrpSC7s 1HAs211kisbI4tgdcnsMTtJtSJVya/TvUaYTZvYVK2s0FC5kdPOVXcDEPgTQ2Lodr8 rL7TnMj2f/0dkeBgM1P4mnNKPnW1EQLVSMdktFcXV2gxLWFbZmcox7iLdmQHcFIMbH PiRc0gHB4E4rw== Date: Wed, 21 Jul 2021 16:05:38 -0500 From: Bjorn Helgaas To: Pali =?iso-8859-1?Q?Roh=E1r?= Cc: Lorenzo Pieralisi , Bjorn Helgaas , Thomas Petazzoni , Marek =?iso-8859-1?Q?Beh=FAn?= , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [RESEND PATCH 2/3] PCI: aardvark: Fix checking for PIO status Message-ID: <20210721210538.GA209436@bjorn-Precision-5520> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20210720181155.lhmbrcvlnkhdj32o@pali> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jul 20, 2021 at 08:11:55PM +0200, Pali Roh?r wrote: > On Tuesday 20 July 2021 11:34:51 Bjorn Helgaas wrote: > > On Tue, Jul 20, 2021 at 04:49:55PM +0200, Pali Roh?r wrote: > > > On Monday 19 July 2021 18:12:27 Bjorn Helgaas wrote: > > > > On Fri, Jun 25, 2021 at 12:04:29PM +0100, Lorenzo Pieralisi wrote: > > > > > On Thu, Jun 24, 2021 at 11:33:44PM +0200, Pali Roh?r wrote: > > > > > > > > > > [...] > > > > > > > > > > > -static void advk_pcie_check_pio_status(struct advk_pcie *pcie) > > > > > > +static int advk_pcie_check_pio_status(struct advk_pcie *pcie, u32 *val) > > > > > > { > > > > > > struct device *dev = &pcie->pdev->dev; > > > > > > u32 reg; > > > > > > @@ -472,15 +476,50 @@ static void advk_pcie_check_pio_status(struct advk_pcie *pcie) > > > > > > status = (reg & PIO_COMPLETION_STATUS_MASK) >> > > > > > > PIO_COMPLETION_STATUS_SHIFT; > > > > > > > > > > > > - if (!status) > > > > > > - return; > > > > > > - > > > > > > + /* > > > > > > + * According to HW spec, the PIO status check sequence as below: > > > > > > + * 1) even if COMPLETION_STATUS(bit9:7) indicates successful, > > > > > > + * it still needs to check Error Status(bit11), only when this bit > > > > > > + * indicates no error happen, the operation is successful. > > > > > > + * 2) value Unsupported Request(1) of COMPLETION_STATUS(bit9:7) only > > > > > > + * means a PIO write error, and for PIO read it is successful with > > > > > > + * a read value of 0xFFFFFFFF. > > > > > > + * 3) value Completion Retry Status(CRS) of COMPLETION_STATUS(bit9:7) > > > > > > + * only means a PIO write error, and for PIO read it is successful > > > > > > + * with a read value of 0xFFFF0001. > > > > > > + * 4) value Completer Abort (CA) of COMPLETION_STATUS(bit9:7) means > > > > > > + * error for both PIO read and PIO write operation. > > > > > > + * 5) other errors are indicated as 'unknown'. > > > > > > + */ > > > > > > switch (status) { > > > > > > + case PIO_COMPLETION_STATUS_OK: > > > > > > + if (reg & PIO_ERR_STATUS) { > > > > > > + strcomp_status = "COMP_ERR"; > > > > > > + break; > > > > > > + } > > > > > > + /* Get the read result */ > > > > > > + if (val) > > > > > > + *val = advk_readl(pcie, PIO_RD_DATA); > > > > > > + /* No error */ > > > > > > + strcomp_status = NULL; > > > > > > + break; > > > > > > case PIO_COMPLETION_STATUS_UR: > > > > > > - strcomp_status = "UR"; > > > > > > + if (val) { > > > > > > + /* For reading, UR is not an error status */ > > > > > > + *val = CFG_RD_UR_VAL; > > > > > > > > I think the comment is incorrect. Unsupported Request *is* an error > > > > status. But most platforms log it and fabricate ~0 data > > > > (CFG_RD_UR_VAL) to return to the CPU, and I think that's what you're > > > > doing here. So I think the code is fine, but the "not an error > > > > status" comment is wrong. > > > > > > Ok, and what we should driver set as return value for pci_ops.read > > > callback in this case? > > > > On most platforms, pci_ops.read() does not check for failure, so it > > returns PCIBIOS_SUCCESSFUL in this case. > > Ok. Most platforms do not check for failure. But it is generally > correct? Probably more platforms do not provide error flag and only > return value. But aardvark hw provides this kind error information, so > should pci-aardvark's pci_ops.read() on error returns PCIBIOS_SUCCESSFUL > on some other return value? By all means, if you have the error information handy, return PCIBIOS_DEVICE_NOT_FOUND or whatever you think is appropriate. Of course, most callers of pci_read_config_word() et al don't check. I think you should set the returned data to ~0 in this case, too.