Message ID | 20240205133450.5222-4-ilpo.jarvinen@linux.intel.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-52725-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:168b:b0:106:860b:bbdd with SMTP id ma11csp925526dyb; Mon, 5 Feb 2024 06:55:14 -0800 (PST) X-Google-Smtp-Source: AGHT+IFrvOWJ+N++/SWXSvtCpY3FKRHYHwbEVJpMc+nBanUqyYA10966wjy+CxVEW+14nRKYA3Gl X-Received: by 2002:a05:6122:a1b:b0:4c0:25db:3618 with SMTP id 27-20020a0561220a1b00b004c025db3618mr2508839vkn.0.1707144909786; Mon, 05 Feb 2024 06:55:09 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707144909; cv=pass; d=google.com; s=arc-20160816; b=ghhf7lMA1RS+QEK9+Em/MsmhO5/l7XShvRhJwHJSa0QLZOr7Zm5qVDYHDfSd43JFPa wCyhEsSrH7q9FhRGD/9gFG2PGbS74jqYDvmiYSVYOECmsw8uVlgOIyrWzYb0Ee/p6/Tz OwPIeCHolRIypkD2SZ8IochS5G/YG0ouXXH/SHBJsqPbWrkLTgLzJgh7t3h/KblAOsP4 f+DMqjBOPg52KTraDg6vULBydlL4R7P7eVjIb6jal0i7iTrEqckL1S3wyJKXimqVsVFc Jf3OS0DAQubSxxU5Ra5I/+xn2QbznVS3Cnb9UNNyJe/97cO8IiEr/E5yOXKMqj3hQdiP VDzA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=sY8tjdT0LtWh1q8qqSFPRl+XyvQW6iZ+u+W+ZjcBNvo=; fh=TTsGqUb/cvSZh/P11HnWOIqkdkAij41Y64u7GLmOWCA=; b=nbPBEUrNgN2fSPHCGb9uBVakOXov+PP2gGXfekjMNbk3wSIVTP5Ju4hAkpYoTEjN1B UBtIIsyZ9hcdpsm7JCZC/cLLFGPMAk5OF1+SIpOp5t4JSAyxOYLHjxGboB1SZsiR0Atv lZyAYnCZ5CBbLv/RQdEQNGQ5yB0QfRcJO5/fbtTt9UpqJzG2hUR1e5T9oF+Of2D7ZzYF eTcbCcZNlYVv0VayuNUXZZG1Ku9jApl51qv0ozCqsaiXhFoaSTnhqtZd8bSI9R6a42Wf W6qvdFnLe65clOWxHg62MUYBxqNYk5+xJ+mwPdDoq3VAHvNjrEpYVCdzQ94jWe1veN4v Oybg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=RcUITd3Q; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-52725-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-52725-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Forwarded-Encrypted: i=1; AJvYcCUloXETGHDLy9t/0hDgYSZAc9cDkYI+RhLz2uDzQMc0uou6DoDdFrztrFOlQQivUtqRM34QAFGRV9I0lWKuQpYWdLsGOA== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id ea11-20020ad458ab000000b0068c51eb0a95si69686qvb.83.2024.02.05.06.55.09 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Feb 2024 06:55:09 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-52725-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=RcUITd3Q; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-52725-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-52725-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 42FAA1C23707 for <ouuuleilei@gmail.com>; Mon, 5 Feb 2024 13:36:03 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E138724A0F; Mon, 5 Feb 2024 13:35:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="RcUITd3Q" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.16]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BA4022260A; Mon, 5 Feb 2024 13:35:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.16 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707140129; cv=none; b=Fz2C6BcTUfEeKrBqN2DOkyU3On4g3eeGzHagTLVoAv1pst5nPCSud+a3C8XvXgXUoL30COiAOfboMNxuKQmhDO4bPY9+bEQ33frv0dTvjY0pw1EyrK0vhQ6QG2e8LYwyrEnpvak9gnWx3MKShpie0vOF83DI7VqwpB444HZCW7Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707140129; c=relaxed/simple; bh=Q3+800fhd/fwWAp0F7nWO/Ih5K1cq1Tqdf0ZT226Bzg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=VbwOxQRJ2+zi7NvXDdxPfDQNSx4GbyGd0aHUMsSxzWU5WQcDhOklomCRcPlvwrjtdUA7vF82KUZDlDmz9foXyipSjNE8HNc4bVmiC5XfQ8ur+I+NUCBJauyQprksXj4CB43J4RGV7cFwuhEq96pEDV4UW1eI35xVEimyKeKmY4w= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=RcUITd3Q; arc=none smtp.client-ip=198.175.65.16 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1707140128; x=1738676128; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Q3+800fhd/fwWAp0F7nWO/Ih5K1cq1Tqdf0ZT226Bzg=; b=RcUITd3QMEvhfE9bwSJwnvNIVikJeqzeg6S0BGkUEuXmM0I3+vJgOGGY /zKgfrSPlZ2adJel2Lhxt/n5w/Ins7HkMr7k0mL/THR+q48IniqVfzHgP eu38ospjuK791rZwodxB2dkhhgZM2ryDKfqS5O1lGCMMGRdAgQyh8YpeQ 8cUNjjIwTsL2EJvNHKq3KGs3c2JPfFgKpPW85cl/Rp8tqmXUU7hpvgAcT T99xRZ3jFfAgsaBkOtr6wSnP02GrhpJfmvK5Coe+/VYJ6wjWPut7gq5JP 5gAZiTijsiBfbdeMlAgdv3ByiKydRu+m1UHxIJCbPKHl3w0mV8SwDB7ZG g==; X-IronPort-AV: E=McAfee;i="6600,9927,10974"; a="690079" X-IronPort-AV: E=Sophos;i="6.05,245,1701158400"; d="scan'208";a="690079" Received: from fmviesa008.fm.intel.com ([10.60.135.148]) by orvoesa108.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Feb 2024 05:35:27 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.05,245,1701158400"; d="scan'208";a="923292" Received: from ijarvine-desk1.ger.corp.intel.com (HELO localhost) ([10.246.35.237]) by fmviesa008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Feb 2024 05:35:23 -0800 From: =?utf-8?q?Ilpo_J=C3=A4rvinen?= <ilpo.jarvinen@linux.intel.com> To: Thomas Bogendoerfer <tsbogend@alpha.franken.de>, linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org Cc: =?utf-8?q?Ilpo_J=C3=A4rvinen?= <ilpo.jarvinen@linux.intel.com> Subject: [PATCH 3/4] MIPS: PCI: Return PCIBIOS_* from tx4927_pci_config_read/write() Date: Mon, 5 Feb 2024 15:34:49 +0200 Message-Id: <20240205133450.5222-4-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240205133450.5222-1-ilpo.jarvinen@linux.intel.com> References: <20240205133450.5222-1-ilpo.jarvinen@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790071180477709811 X-GMAIL-MSGID: 1790071180477709811 |
Series |
MIPS: Cleanups to PCI related code
|
|
Commit Message
Ilpo Järvinen
Feb. 5, 2024, 1:34 p.m. UTC
pci_ops .read/.write must return PCIBIOS_* codes but
tx4927_pci_config_read/write() return -1 when mkaddr() cannot find
devfn from the root bus. Return PCIBIOS_DEVICE_NOT_FOUND instead and
pass that onward in the call chain instead of overwriting the return
value.
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
---
arch/mips/pci/ops-tx4927.c | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)
Comments
Hi, On Mon, Feb 5, 2024 at 3:35 PM Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> wrote: > > pci_ops .read/.write must return PCIBIOS_* codes but > tx4927_pci_config_read/write() return -1 when mkaddr() cannot find > devfn from the root bus. Return PCIBIOS_DEVICE_NOT_FOUND instead and > pass that onward in the call chain instead of overwriting the return > value. > > Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> > --- > arch/mips/pci/ops-tx4927.c | 14 +++++++++----- > 1 file changed, 9 insertions(+), 5 deletions(-) > > diff --git a/arch/mips/pci/ops-tx4927.c b/arch/mips/pci/ops-tx4927.c > index f7802f100401..4dd8b93985fb 100644 > --- a/arch/mips/pci/ops-tx4927.c > +++ b/arch/mips/pci/ops-tx4927.c > @@ -60,7 +60,7 @@ static int mkaddr(struct pci_bus *bus, unsigned int devfn, int where, > { > if (bus->parent == NULL && > devfn >= PCI_DEVFN(TX4927_PCIC_MAX_DEVNU, 0)) > - return -1; > + return PCIBIOS_DEVICE_NOT_FOUND; > __raw_writel(((bus->number & 0xff) << 0x10) > | ((devfn & 0xff) << 0x08) | (where & 0xfc) > | (bus->parent ? 1 : 0), Should we also return PCIBIOS_SUCCESSFUL instead of 'return 0' in 'mkaddr' for coherency? Other than that, changes look good to me. Reviewed-by: Sergio Paracuellos <sergio.paracuellos@gmail.com> Thanks, Sergio Paracuellos > @@ -140,10 +140,12 @@ static int tx4927_pci_config_read(struct pci_bus *bus, unsigned int devfn, > int where, int size, u32 *val) > { > struct tx4927_pcic_reg __iomem *pcicptr = pci_bus_to_pcicptr(bus); > + int ret; > > - if (mkaddr(bus, devfn, where, pcicptr)) { > + ret = mkaddr(bus, devfn, where, pcicptr); > + if (ret != PCIBIOS_SUCCESSFUL) { > *val = 0xffffffff; > - return -1; > + return ret; > } > switch (size) { > case 1: > @@ -162,9 +164,11 @@ static int tx4927_pci_config_write(struct pci_bus *bus, unsigned int devfn, > int where, int size, u32 val) > { > struct tx4927_pcic_reg __iomem *pcicptr = pci_bus_to_pcicptr(bus); > + int ret; > > - if (mkaddr(bus, devfn, where, pcicptr)) > - return -1; > + ret = mkaddr(bus, devfn, where, pcicptr); > + if (ret != PCIBIOS_SUCCESSFUL) > + return ret; > switch (size) { > case 1: > icd_writeb(val, where & 3, pcicptr); > -- > 2.39.2 > >
On Mon, 5 Feb 2024, Sergio Paracuellos wrote: > On Mon, Feb 5, 2024 at 3:35 PM Ilpo Järvinen > <ilpo.jarvinen@linux.intel.com> wrote: > > > > pci_ops .read/.write must return PCIBIOS_* codes but > > tx4927_pci_config_read/write() return -1 when mkaddr() cannot find > > devfn from the root bus. Return PCIBIOS_DEVICE_NOT_FOUND instead and > > pass that onward in the call chain instead of overwriting the return > > value. > > > > Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> > > --- > > arch/mips/pci/ops-tx4927.c | 14 +++++++++----- > > 1 file changed, 9 insertions(+), 5 deletions(-) > > > > diff --git a/arch/mips/pci/ops-tx4927.c b/arch/mips/pci/ops-tx4927.c > > index f7802f100401..4dd8b93985fb 100644 > > --- a/arch/mips/pci/ops-tx4927.c > > +++ b/arch/mips/pci/ops-tx4927.c > > @@ -60,7 +60,7 @@ static int mkaddr(struct pci_bus *bus, unsigned int devfn, int where, > > { > > if (bus->parent == NULL && > > devfn >= PCI_DEVFN(TX4927_PCIC_MAX_DEVNU, 0)) > > - return -1; > > + return PCIBIOS_DEVICE_NOT_FOUND; > > __raw_writel(((bus->number & 0xff) << 0x10) > > | ((devfn & 0xff) << 0x08) | (where & 0xfc) > > | (bus->parent ? 1 : 0), > > Should we also return PCIBIOS_SUCCESSFUL instead of 'return 0' in > 'mkaddr' for coherency? Yeah right, I'll change it too. I didn't take notice of that because the reason for all this is that I intend to convert these functions to return generic errno and push the PCIBIOS error code -> errno conversion into where it's really needed (real PCIBIOS access functions in arch/x86/pci/pcbios.c). Returning 0 as literal is very common cosmetic "error" in these functions. While calculating the error rate in return values of these functions (I'm able to do that because of the audit), those were not even included to 15% returning -Esomething instead of PCIBIOS_*. It would be way above that if I'd count return 0 also as an error. > Other than that, changes look good to me. > > Reviewed-by: Sergio Paracuellos <sergio.paracuellos@gmail.com> Thanks for the review.
diff --git a/arch/mips/pci/ops-tx4927.c b/arch/mips/pci/ops-tx4927.c index f7802f100401..4dd8b93985fb 100644 --- a/arch/mips/pci/ops-tx4927.c +++ b/arch/mips/pci/ops-tx4927.c @@ -60,7 +60,7 @@ static int mkaddr(struct pci_bus *bus, unsigned int devfn, int where, { if (bus->parent == NULL && devfn >= PCI_DEVFN(TX4927_PCIC_MAX_DEVNU, 0)) - return -1; + return PCIBIOS_DEVICE_NOT_FOUND; __raw_writel(((bus->number & 0xff) << 0x10) | ((devfn & 0xff) << 0x08) | (where & 0xfc) | (bus->parent ? 1 : 0), @@ -140,10 +140,12 @@ static int tx4927_pci_config_read(struct pci_bus *bus, unsigned int devfn, int where, int size, u32 *val) { struct tx4927_pcic_reg __iomem *pcicptr = pci_bus_to_pcicptr(bus); + int ret; - if (mkaddr(bus, devfn, where, pcicptr)) { + ret = mkaddr(bus, devfn, where, pcicptr); + if (ret != PCIBIOS_SUCCESSFUL) { *val = 0xffffffff; - return -1; + return ret; } switch (size) { case 1: @@ -162,9 +164,11 @@ static int tx4927_pci_config_write(struct pci_bus *bus, unsigned int devfn, int where, int size, u32 val) { struct tx4927_pcic_reg __iomem *pcicptr = pci_bus_to_pcicptr(bus); + int ret; - if (mkaddr(bus, devfn, where, pcicptr)) - return -1; + ret = mkaddr(bus, devfn, where, pcicptr); + if (ret != PCIBIOS_SUCCESSFUL) + return ret; switch (size) { case 1: icd_writeb(val, where & 3, pcicptr);