Received: by 2002:a05:7412:2a91:b0:fc:a2b0:25d7 with SMTP id u17csp85859rdh; Tue, 13 Feb 2024 10:06:11 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVvOI160KKL9ecAGkNv8zcZ/sdohx9wJs228CQQsP5lBpERUNllXnM6JRNMe3K5hFsKflx8Pz3SBvVHuwdaQDn2Z9tv8B6kGW9K0o1mTA== X-Google-Smtp-Source: AGHT+IFT2rDyXfJsF2Ic9exT9xXE06PlhIsW8qy/ZgwHAoFIUEjyfIkfUzqEUICw3GMIuZVqXF9o X-Received: by 2002:a05:6a20:3c8d:b0:19e:9d92:2999 with SMTP id b13-20020a056a203c8d00b0019e9d922999mr466401pzj.23.1707847570708; Tue, 13 Feb 2024 10:06:10 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707847570; cv=pass; d=google.com; s=arc-20160816; b=NqwED3kHKrNFb95PXn+gDQTK3yjUZ3jClCsfMSI4d2SOkxxoqdr+5YlwYFtZ4fgbf9 Z8jkPe9yA2XXR61VlWPUIZkKfzhi50VVfZXyQ2ddUgKOaanZERDZsQDG3VitSOKfvwIv LpPhfb8HQ/bKHU/UZIXAkp8sj+9SPU/fgsQkJunHy8hD9vAvcOw4UXk8MBPYmIXJUT/H zgzYWbiXYkKYSZZ9e/sR/w7+2/PWU7mM7MKIEocnqsEAJpGeP7Qs3s3qq8nZqjih5Y6c 8BaCEXIp52CtQWfx2F8ky+e+zmVYL7kurlQi7AdKItpBXZTYz5rhwYJoWqTjtqzgv82r w7ig== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=rzig/WZJx9Zbb9kDwaJpSQ2qxYpOvGxmsBdofeOh1Pw=; fh=LurQ7vmRt8aXi+o3CZnOe2vHmJGgP7u6TC1li/pRicw=; b=0zkBXXEqXbEwTjNOKepHtlCPYYlrA5nVeDB+Gd8fG5HHlrCL01qzoCHE6/Bhm7I0kB 2geDRDfJTXFxbzpCeltqMzhnXIoBLytOwpnYoe48B1ngIgA3kPqXgD0PzbwWlN7x+IgT WTKzLh+x0R5uoOGT8RPE4AUINCn7Tl+LddI+0Ux8++hrHJRyW2a/pzy0a4UNyL8VsoVi +zT31/krylLMrDO+Tv/gGH/I2ylYZXLBMM1ZZ+4t7mrH7ilL2DS4QqAIsKi7wo64T+wh aq1GnfbC4YlUc+vBZwMdb+RByK6FgzW6XcexS9cPRSWp759vySxD6xHIcsyH8DOdyzCw b2Sg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=KAFheBoj; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-64052-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-64052-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=2; AJvYcCW9BfkpDtvMBgNt2X88PjbI6X4SJgYTGtkGfeQzYWmYo/ljzUkXN1RDpgSP6YnKShyky0pfcso3QPMtoVBLUl7a6qnJpWRmbBDE9e8nLw== Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id m192-20020a633fc9000000b005d8b5aace85si2279549pga.310.2024.02.13.10.06.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Feb 2024 10:06:10 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-64052-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=KAFheBoj; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-64052-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-64052-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org 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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 6188928A742 for ; Tue, 13 Feb 2024 18:06:10 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CC572605AC; Tue, 13 Feb 2024 18:05:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="KAFheBoj" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 F247E604DC; Tue, 13 Feb 2024 18:05:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707847543; cv=none; b=KnlmYKlYkgEoLO3sCHknN5PZoLBM6T95aDXiD/lr/BBUl5bBC4mAY37Ocnb9J5J4uowz9xwmAmiqFDpMhrgonFH/fSevYIlVqu82uPrjsx3/t9YONv5ZmU1nMfViofUIJTmVkxVCEUZa3ME2wJ+5RXdz83NaqH93p6mZpAxTrg0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707847543; c=relaxed/simple; bh=HecSXPlQazpI+9KpIYoNGJ1ZcXO0NHDiFgEImC6uQ2M=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=TYSq6wPvYFsq8csxIU4a8qcsEeo5SbW3lX5tPCNNuaUyFP3QIqfTL1XxnrZmp+QzmvIQNVX2fUpgqqQnP8bYH+N/JyZosRwfhFMuGSqPsWcenGprULdO4naoTZUfWtDautA/dPk7POL6+I9nwQ9YuFGvcddPuV/EiKoRShSyi7U= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=KAFheBoj; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0CE02C433C7; Tue, 13 Feb 2024 18:05:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1707847542; bh=HecSXPlQazpI+9KpIYoNGJ1ZcXO0NHDiFgEImC6uQ2M=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=KAFheBoj/bKBHs+d5nKtlNnbX/F+Igl4YMdrKR8fk3GLrIwe/Gep4mdlOLQUz5ElE BJGSBW7He4mRVX5nKqjh+IFiWFde5QGSSReElAQuLLH67ge3eZ1c3aJVn1Wwdm6fxA HIrfqCcOpG+i8iQJETlO2aGFr7KLJISHDBOWTPmkylUx71GR0BwUN9Q1OImHR+JOk5 lklOMu8Jrm8mAOnpXB6jcjmJOA3AmguWMUnWlgno6MpmqXHfNo4EJ2xggReAblqbSK ATLJO5iyLtpv+j+caroAUgitrVfYoy6ZE8gBjazY1JdPtw2+DcDiUuHxCXKQx6S4en 1cYCYg+EA4QkQ== Date: Tue, 13 Feb 2024 19:05:35 +0100 From: Niklas Cassel To: Andrey Melnikov Cc: Sergei Shtylyov , linux-ide@vger.kernel.org, linux-kernel@vger.kernel.org, dlemoal@kernel.org, hdegoede@redhat.com Subject: Re: [PATCH] ahci: asm1064: correct count of reported ports Message-ID: References: <7559d940-f191-4fe0-e147-17ffa6c1dfc4@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: On Tue, Feb 13, 2024 at 06:19:10PM +0100, Niklas Cassel wrote: > On Thu, Feb 08, 2024 at 10:27:11AM +0300, Andrey Melnikov wrote: > > > On 2/7/24 12:58 PM, Andrey Jr. Melnikov wrote: > > > > > > > The ASM1064 SATA host controller always reports wrongly, > > > > that it has 24 ports. But in reality, it only has four ports. > > > > > > > > before: > > > > ahci 0000:04:00.0: SSS flag set, parallel bus scan disabled > > > > ahci 0000:04:00.0: AHCI 0001.0301 32 slots 24 ports 6 Gbps 0xffff0f impl SATA mode > > > > ahci 0000:04:00.0: flags: 64bit ncq sntf stag pm led only pio sxs deso sadm sds apst > > > > > > > > after: > > > > ahci 0000:04:00.0: ASM1064 has only four ports > > > > ahci 0000:04:00.0: forcing port_map 0xffff0f -> 0xf > > > > ahci 0000:04:00.0: SSS flag set, parallel bus scan disabled > > > > ahci 0000:04:00.0: AHCI 0001.0301 32 slots 24 ports 6 Gbps 0xf impl SATA mode > > > > ahci 0000:04:00.0: flags: 64bit ncq sntf stag pm led only pio sxs deso sadm sds apst > > > > > > > > > > > > Signed-off-by: Andrey Jr. Melnikov > > > > > > > > diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c > > > > index da2e74fce2d9..ec30d8330d16 100644 > > > > --- a/drivers/ata/ahci.c > > > > +++ b/drivers/ata/ahci.c > > > > @@ -671,9 +671,14 @@ MODULE_PARM_DESC(mobile_lpm_policy, "Default LPM policy for mobile chipsets"); > > > > static void ahci_pci_save_initial_config(struct pci_dev *pdev, > > > > struct ahci_host_priv *hpriv) > > > > { > > > > - if (pdev->vendor == PCI_VENDOR_ID_ASMEDIA && pdev->device == 0x1166) { > > > > - dev_info(&pdev->dev, "ASM1166 has only six ports\n"); > > > > - hpriv->saved_port_map = 0x3f; > > > > + if (pdev->vendor == PCI_VENDOR_ID_ASMEDIA) { > > > > + if (pdev->device == 0x1166) { > > > > > > Maybe *switch* instead? > > > > Ok. > > Hello Andrey, > > do you intend to send out a v2 that uses a switch instead? > > And perhaps take Damien's patch as patch 1/2 > (with Suggested-by: Damien ... of course), > so that the before/after print in your commit message shows > the override value. On second thought, just go ahead and respin your patch using a switch, as I don't think Damien's patch is fully correct. He suggested to use hpriv->saved_port_map. However, that will show the wrong result for platforms using hpriv->mask_port_map. As when hpriv->mask_port_map is used, saved_port_map is not set: https://github.com/torvalds/linux/blob/v6.8-rc4/drivers/ata/libahci.c#L536-L548 However, the local variable "port_map" is updated for both saved_port_map and mask_port_map cases. And then at the end: hpriv->port_map = port_map; https://github.com/torvalds/linux/blob/v6.8-rc4/drivers/ata/libahci.c#L597 So I think we should print hpriv->port_map, and not hpriv->saved_port_map. However.. hpriv->port_map is already printed: https://github.com/torvalds/linux/blob/v6.8-rc4/drivers/ata/libahci.c#L2617 in the "0x%x impl" print. So > before: > ahci 0000:04:00.0: AHCI 0001.0301 32 slots 24 ports 6 Gbps 0xffff0f impl SATA mode > after: > ahci 0000:04:00.0: AHCI 0001.0301 32 slots 24 ports 6 Gbps 0xf impl SATA mode Actually prints the number of *implemented* ports. I have to admit that this is a bit confusing. Personally I would have preferred if we simply printed "%u ports", hpriv->port_map, and simply dropped the "0x%x impl" part of the print, but I'm a bit worried that someone parses this print from user space, but I guess we must be allowed to improve prints if they are confusing. Damien, what do you think? Kind regards, Niklas