Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp1000587ybl; Wed, 14 Aug 2019 09:10:39 -0700 (PDT) X-Google-Smtp-Source: APXvYqxi+W6jCcLUtTqO/fsI6FaKBNkRjo1VnbAzd5CyulskE59fAB2bKbaE/TVE4lGLaI9lGsAr X-Received: by 2002:a17:902:7c05:: with SMTP id x5mr141600pll.321.1565799039819; Wed, 14 Aug 2019 09:10:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565799039; cv=none; d=google.com; s=arc-20160816; b=vOnWnYCCJQULHz+z+TDvp/KI2EAqyZ8FhVBnawMPtm6FgVPwccCT/wEIOABsi7S4uJ Fja7SltP6PLpFnAF6K3OclPMoPHPdMYhNcCxweOXiFEVWNESCAK4z0YZl5TjIKE5LB/X V3O3M9gAj1YZxp+fVRcRrcAm8qVJ0nQKshIb8keaFW9xmkbrcl/rpW2pC2pemPL4EaUc 1QhCTorN1rJN72CwPnOmNxjvxxJNtcRhZoaqlU/Hy39FWfpxeXg6/02qI14zCxM1IzOJ Jjwwy6dqsMYxYCNXI94zsQ1mt8fPPazYA8PQvBEV4QKhQ4tcQwDl3n8SHzFKSHYR70P1 a+ng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=pwEcHH9UXdU1fXXFDvnaYZ/QstlJxWFiAYonmCkc7s4=; b=PQ9NJuYqdfFM2v6Usj6luugaNNqNcDCyB/o58qVPGmxEXU/vRUZXrx1bShGdW4l24A sQomiyXIhueGJVEN6mwL+J2JNZf+ga8HTuBPsc5uO+d2dzTtT3y0fZdQg5LJl41SNfJb eVp3KjsjvKL2VFhjWFs32Ua1QIKo5MKu5XbdM3+5jOAHMIpKsDEIkCsVpFFjuFnaWwsr 7bCablEw1pVxoFYEPAgP7j4380u/tSnL1jVAOM9aJMWydQ4D/YBcgtA2LA2/9AU7Y/SJ Cw6k8Q1nFVN9Z8Hhxdtg7vOfvf1bg7sAsrz07Dx91E1c0VJpwkAZMGYQMUh1WxkrsWMu zZGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel-com.20150623.gappssmtp.com header.s=20150623 header.b=oXMn6VeZ; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ds19si111369pjb.81.2019.08.14.09.10.21; Wed, 14 Aug 2019 09:10:39 -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=@intel-com.20150623.gappssmtp.com header.s=20150623 header.b=oXMn6VeZ; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728014AbfHNQJO (ORCPT + 99 others); Wed, 14 Aug 2019 12:09:14 -0400 Received: from mail-oi1-f194.google.com ([209.85.167.194]:34680 "EHLO mail-oi1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726951AbfHNQJN (ORCPT ); Wed, 14 Aug 2019 12:09:13 -0400 Received: by mail-oi1-f194.google.com with SMTP id l12so12982202oil.1 for ; Wed, 14 Aug 2019 09:09:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=pwEcHH9UXdU1fXXFDvnaYZ/QstlJxWFiAYonmCkc7s4=; b=oXMn6VeZmUplJ9AJjI73fg5Ol5bdgZLWYd5b7qf5eXqDzrUVh+dDTPLAp9zVNJCUWr H4TZnBs9Pd32gBeKSi+C3dmCoyDO8qDvpzsRncd87MbkxWoDBRHnATZgFEDT4uz8Klcf OAq4UtQgUfaWq/q86N50NdAY3kn/33QR+ZvAtM4xfNKCqIe0X5YynaPigWo5lvurwhF6 9k1zFVPKVJOamgslpHSpldlFvzMWFJySz5eHxjqtJb/rz2kSfhBQr0770m0lOkYiWXqF 9lGt2kBcjVKHZKwvotF6RHswDCo3XelrgWXuqBXCBz0di+Ud3c3ruD9RvS7LvQMUljyF Cn5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=pwEcHH9UXdU1fXXFDvnaYZ/QstlJxWFiAYonmCkc7s4=; b=RSdp8nIczjwx84ojmlTHSQlyev5C8BGGs11WW3WA4tCr6YWhm+i3N490WJ2c98T7dl tHo8JLRQ8xV6sc2uDHhv10ozpryDma+pMygzjBS+vHfr+ahIHLMexVLUubaQSrN6fG6U rBbqtVIIcEAuemFF5pglZPIDWhPlKo8S5c36hXGLmJ/17reoFyy4PmO5pgSaUsDP6S25 rK3vZRdCoNf7IQCY/j9D4KX7BLWYaRBiLpLg/GtNvH+tOQo8AlSgCYbQU4a5/Vvd6dfD xZfk3Hg12DOIKP3dBEno4eEdrMiKKgdfaqEs6PXGlOGs0RHQroTwi9/Y6dUzUSv/9cET TFTA== X-Gm-Message-State: APjAAAXfH9VgDL2kQ3UUfS2EfbqGdlG6nC24VliKGspKxk/8jFckiYlD 64kvN4rLpuZqg3Fv6o2JNohpQuAzWpkdqEpriOcr0g== X-Received: by 2002:aca:d558:: with SMTP id m85mr524632oig.0.1565798952523; Wed, 14 Aug 2019 09:09:12 -0700 (PDT) MIME-Version: 1.0 References: <20190808202415.25166-1-stephend@silicom-usa.com> <20190810074317.GA18582@infradead.org> <051cb164-19d5-9241-2941-0d866e565339@silicom-usa.com> <20190812180613.GA18377@infradead.org> <20190813072954.GA23417@infradead.org> In-Reply-To: From: Dan Williams Date: Wed, 14 Aug 2019 09:09:01 -0700 Message-ID: Subject: Re: [PATCH] ata: ahci: Lookup PCS register offset based on PCI device ID To: Stephen Douthit Cc: Christoph Hellwig , Jens Axboe , "linux-ide@vger.kernel.org" , "linux-kernel@vger.kernel.org" Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Aug 14, 2019 at 7:34 AM Stephen Douthit wrote: > > On 8/13/19 6:07 PM, Dan Williams wrote: > > On Tue, Aug 13, 2019 at 12:31 AM Christoph Hellwig wrote: > >> > >> On Mon, Aug 12, 2019 at 12:31:35PM -0700, Dan Williams wrote: > >>> It seems platforms / controllers that fail to run the option-rom > >>> should be quirked by device-id, but the PCS register twiddling be > >>> removed for everyone else. "Card BIOS" to me implies devices with an > >>> Option-ROM BAR which I don't think modern devices have, so that might > >>> be a simple way to try to phase out this quirk going forward without > >>> regressing working setups that might be relying on this. > >>> > >>> Then again the driver is already depending on the number of enabled > >>> ports to be reliable before PCS is written, and the current driver > >>> does not attempt to enable ports that were not enabled previously. > >>> That tells me that if the PCS quirk ever mattered it would have > >>> already regressed when the driver switched from blindly writing 0xf to > >>> only setting the bits that were already set in ->port_map. > >> > >> But how do we find that out? > > > > We can layer another assumption on top of Tejun's assumptions from > > commit 49f290903935 "ahci: update PCS programming". The kernel > > community has not received any regression reports from that change > > which says: > > > > " > > port_map is determined from PORTS_IMPL PCI register which is > > implemented as write or write-once register. If the register isn't > > programmed, ahci automatically generates it from number of ports, > > which is good enough for PCS programming. ICH6/7M are probably the > > only ones where non-contiguous enable bits are necessary && PORTS_IMPL > > isn't programmed properly but they're proven to work reliably with 0xf > > anyway. > > " > > > > So the potential options I see are: > > > > 1/ Keep the current scheme, but limit it to cases where PORTS_IMPL is > > less than 8 and assume this need to set the bits is unnecessary legacy > > to carry forward > > > > 2/ Option1 + additionally use PORTS_IMPL as a gate to guess when the > > PCS format might be different for values >= 8. > > > > I think the driver does not need to consider Option2 unless / until it > > encounters a platform where firmware does not "do the right thing", > > and given Denverton has been in the wild with the wrong PCS twiddling > > it seems to suggest nothing needs to be done there. > > > >> A compromise to me seems that we just do the PCS quirk for all Intel > >> devices explicitly listed in the PCI Ids based on new board_* values > >> as long as they have the old PCS location, and assume anything new > >> enough to have the new location won't need to quirk, given that it > >> never properly worked. This might miss some intel devices that were > >> supported with the class based catchall, though. > > > > I'd be more comfortable with PORT_IMPL as the deciding factor. > > Unfortunately we can't use CAP.NP or PORTS_IMPL for this heuristic. > > The problem is that BIOS should be setting the PORTS_IMPL bitmask to > match which lanes have actually been connected on the board. So > PORTS_IMPL can be < 8 even if the controller is new enough to > potentially support > 8 and has the new config space layout. > > As proof here's the relevant ahci_print_info() output booting on a > Denverton based box with 5 ports implemented: > > ahci 0000:00:14.0: AHCI 0001.0301 32 slots 5 ports 6 Gbps 0x7a impl SATA mode > | \-PORTS_IMPL > \-CAP.NP Ugh, ok, thanks for clarifying and my mistake for not realizing Denverton already violates that heuristic. So now I'm trying to grok Christoph's suggestion. Are you saying that all existing board-ids would assume old PCS format? That would mean that Denverton gets the wrong format via board_ahci via the class code matching? Maybe I'm not understanding the suggestion... Another option might be that controllers >= 1.3.1 will stop using the PCS twiddling, and then we go add a new board id where / if it happens to matter in practice.