Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp972934ybb; Sat, 28 Mar 2020 15:00:06 -0700 (PDT) X-Google-Smtp-Source: ADFU+vuZWsWxj7oMEETTKJlidt0QBVobktnVQj47SEU89qIX3CwgQWcZO0AB4AHuuK/lvn3V9Skb X-Received: by 2002:a05:6830:239b:: with SMTP id l27mr4043339ots.278.1585432805889; Sat, 28 Mar 2020 15:00:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585432805; cv=none; d=google.com; s=arc-20160816; b=TPrG+sRrzaxB9ZWDwXEHlRjfpYntq7U2ZSSKGhXjZE+23Pl4BJ6jnJImduPdptMt2B tiPQthr3f8G8cBHKQ6EhW7kXZRyVSLa6vDIuJVBVTsVM74nHA+B6IzYxhsVNThJDYEMx kni4U7QF97ukmJN77K9RyBg4r2TPXGnpwZ2bt+KIrYSmvCF6lbQ4xqb/bHi8IRzDC2Mq RiTf2pywmnT8ftYs0Eb2Fh4eAq8Y/4JFodWjg4tsrQoHT2DwvjQBY4RrTRPoQ6FIWliJ OfLQTdmbVX2NOiB1wXWwa9fpDYa1jnFaNuStOEpdQ7dnsW2E64CEB7srrBfUJTprM1Di ieJQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:message-id:subject:cc:to:from:date :dkim-signature; bh=3Qc03ka51XYqXP6aAsSbGKgYl8pJnWCSVsNnT62FPFI=; b=ITXWTb+yy3USNR4k3ih3hmnvVvCNu/OQc0Bhw/wMfMOUQ3X3S83TqetbACAq55eHMZ uP3OrOStInnXhbq+fao6/Q3gn55CVv0sD5dn0jLzhmdniDbvAukJCNjDLZ63Y41GiyyE OWtqdYIC9MOiPoDGlfC/CaX+QoPJwhpzo8Q5Qa5Lq/I9MWMCO/byG82OfCfkNzEV1+ZE Sby9hCRBhZWTxsib41gXXEpNrD5pvJwpOtLTq8/ZNvFyJ3BV5HxoAIcQIU9VCPE/XrD4 bTkxqkfdD1opStC2tr2AD66IsK2etMhCm3qrxeOG90vXMmBWzaiq3dOyP9TnJtHD74f3 47mg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=LOC7m60E; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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. [209.132.180.67]) by mx.google.com with ESMTP id h6si4050743oib.246.2020.03.28.14.59.53; Sat, 28 Mar 2020 15:00:05 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=LOC7m60E; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1727725AbgC1Vny (ORCPT + 99 others); Sat, 28 Mar 2020 17:43:54 -0400 Received: from mail.kernel.org ([198.145.29.99]:58350 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726604AbgC1Vny (ORCPT ); Sat, 28 Mar 2020 17:43:54 -0400 Received: from localhost (mobile-166-175-186-165.mycingular.net [166.175.186.165]) (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 BF6AA20714; Sat, 28 Mar 2020 21:43:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1585431833; bh=QaY36iHTP79UXqax0r/o+p3Tdr+Do9OjGBasmRH9CJQ=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=LOC7m60ErlmVKIHpqS6IGVg09QIRI+KWlV23XfdE/LDM/AVIzeMQQEtkewcu0w8+K 9LbrEFqgaK9RJHLEAoVlr/EpRSf4KY5Rjxnij0DxcLrSlubxckNVqB0QJZr6TXuO1v Lji//GS8YpneAyl9c7FkuaEVu7wHHSbnrQSF9QBw= Date: Sat, 28 Mar 2020 16:43:51 -0500 From: Bjorn Helgaas To: Jon Derrick Cc: linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, Andy Shevchenko , Mika Westerberg , Pawel Baldysiak , Sinan Kaya , Lorenzo Pieralisi , Keith Busch , Alexandru Gagniuc , Christoph Hellwig , Thomas Petazzoni , Russell King Subject: Re: [RFC 2/9] PCI: pci-bridge-emul: Eliminate reserved member Message-ID: <20200328214351.GA129854@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1581120007-5280-3-git-send-email-jonathan.derrick@intel.com> User-Agent: Mutt/1.12.2 (2019-09-21) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [+cc Thomas, Russell] On Fri, Feb 07, 2020 at 05:00:00PM -0700, Jon Derrick wrote: > Assume any bit not in the Read-Only, Read-Write, or Write-1-to-Clear > behavior masks is a Reserved bit and should return 0 on reads. This also seems like it makes sense on its own, especially if you can include a spec citation. > Signed-off-by: Jon Derrick > --- > drivers/pci/pci-bridge-emul.c | 28 +++++++++++----------------- > 1 file changed, 11 insertions(+), 17 deletions(-) > > diff --git a/drivers/pci/pci-bridge-emul.c b/drivers/pci/pci-bridge-emul.c > index d065c2a..e0567ca 100644 > --- a/drivers/pci/pci-bridge-emul.c > +++ b/drivers/pci/pci-bridge-emul.c > @@ -24,6 +24,15 @@ > #define PCI_CAP_PCIE_START PCI_BRIDGE_CONF_END > #define PCI_CAP_PCIE_END (PCI_CAP_PCIE_START + PCI_EXP_SLTSTA2 + 2) > > +/** > + * struct pci_bridge_reg_behavior - register bits behaviors > + * @ro: Read-Only bits > + * @rw: Read-Write bits > + * @w1c: Write-1-to-Clear bits > + * > + * Reads and Writes will be filtered by specified behavior. All other bits not > + * declared are assumed 'Reserved' and will return 0 on reads. > + */ > struct pci_bridge_reg_behavior { > /* Read-only bits */ > u32 ro; > @@ -33,9 +42,6 @@ struct pci_bridge_reg_behavior { > > /* Write-1-to-clear bits */ > u32 w1c; > - > - /* Reserved bits (hardwired to 0) */ > - u32 rsvd; > }; > > static const struct pci_bridge_reg_behavior pci_regs_behavior[] = { > @@ -49,7 +55,6 @@ struct pci_bridge_reg_behavior { > PCI_COMMAND_FAST_BACK) | > (PCI_STATUS_CAP_LIST | PCI_STATUS_66MHZ | > PCI_STATUS_FAST_BACK | PCI_STATUS_DEVSEL_MASK) << 16), > - .rsvd = GENMASK(15, 10) | ((BIT(6) | GENMASK(3, 0)) << 16), > .w1c = (PCI_STATUS_PARITY | > PCI_STATUS_SIG_TARGET_ABORT | > PCI_STATUS_REC_TARGET_ABORT | > @@ -106,8 +111,6 @@ struct pci_bridge_reg_behavior { > PCI_STATUS_REC_MASTER_ABORT | > PCI_STATUS_SIG_SYSTEM_ERROR | > PCI_STATUS_DETECTED_PARITY) << 16, > - > - .rsvd = ((BIT(6) | GENMASK(4, 0)) << 16), > }, > > [PCI_MEMORY_BASE / 4] = { > @@ -140,12 +143,10 @@ struct pci_bridge_reg_behavior { > > [PCI_CAPABILITY_LIST / 4] = { > .ro = GENMASK(7, 0), > - .rsvd = GENMASK(31, 8), > }, > > [PCI_ROM_ADDRESS1 / 4] = { > .rw = GENMASK(31, 11) | BIT(0), > - .rsvd = GENMASK(10, 1), > }, > > /* > @@ -168,8 +169,6 @@ struct pci_bridge_reg_behavior { > .ro = (GENMASK(15, 8) | ((PCI_BRIDGE_CTL_FAST_BACK) << 16)), > > .w1c = BIT(10) << 16, > - > - .rsvd = (GENMASK(15, 12) | BIT(4)) << 16, > }, > }; > > @@ -196,13 +195,11 @@ struct pci_bridge_reg_behavior { > */ > .w1c = (BIT(6) | GENMASK(3, 0)) << 16, > .ro = GENMASK(5, 4) << 16, > - .rsvd = GENMASK(15, 7) << 16, > }, > > [PCI_EXP_LNKCAP / 4] = { > /* All bits are RO, except bit 23 which is reserved */ > .ro = lower_32_bits(~BIT(23)), > - .rsvd = BIT(23), > }, > > [PCI_EXP_LNKCTL / 4] = { > @@ -216,7 +213,6 @@ struct pci_bridge_reg_behavior { > .rw = GENMASK(15, 14) | GENMASK(11, 3) | GENMASK(1, 0), > .ro = GENMASK(13, 0) << 16, > .w1c = GENMASK(15, 14) << 16, > - .rsvd = GENMASK(13, 12) | BIT(2), > }, > > [PCI_EXP_SLTCAP / 4] = { > @@ -234,7 +230,6 @@ struct pci_bridge_reg_behavior { > .rw = GENMASK(14, 0), > .w1c = (BIT(8) | GENMASK(4, 0)) << 16, > .ro = GENMASK(7, 5) << 16, > - .rsvd = BIT(15) | (GENMASK(15, 9) << 16), > }, > > [PCI_EXP_RTCTL / 4] = { > @@ -246,7 +241,6 @@ struct pci_bridge_reg_behavior { > */ > .rw = GENMASK(4, 0), > .ro = BIT(0) << 16, > - .rsvd = GENMASK(15, 5) | (GENMASK(15, 1) << 16), > }, > > [PCI_EXP_RTSTA / 4] = { > @@ -256,7 +250,6 @@ struct pci_bridge_reg_behavior { > */ > .ro = BIT(17) | GENMASK(15, 0), > .w1c = BIT(16), > - .rsvd = GENMASK(31, 18), > }, > }; > > @@ -364,7 +357,8 @@ int pci_bridge_emul_conf_read(struct pci_bridge_emul *bridge, int where, > * Make sure we never return any reserved bit with a value > * different from 0. > */ > - *value &= ~behavior[reg / 4].rsvd; > + *value &= behavior[reg / 4].ro | behavior[reg / 4].rw | > + behavior[reg / 4].w1c; > > if (size == 1) > *value = (*value >> (8 * (where & 3))) & 0xff; > -- > 1.8.3.1 >