From patchwork Wed Jul 24 05:45:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Damien Le Moal X-Patchwork-Id: 1964123 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=Wc/77/su; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=2604:1380:45d1:ec00::1; helo=ny.mirrors.kernel.org; envelope-from=linux-ide+bounces-1948-incoming=patchwork.ozlabs.org@vger.kernel.org; receiver=patchwork.ozlabs.org) Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org [IPv6:2604:1380:45d1:ec00::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WTNKS60sYz20FG for ; Wed, 24 Jul 2024 15:45:48 +1000 (AEST) 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 E7D921C21E7B for ; Wed, 24 Jul 2024 05:45:45 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6A838364BE; Wed, 24 Jul 2024 05:45:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Wc/77/su" X-Original-To: linux-ide@vger.kernel.org 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 2B3B75695 for ; Wed, 24 Jul 2024 05:45:41 +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=1721799942; cv=none; b=OtV9Wil05HbikKMNOuS0rWeVFZVMIxCYycLKMLIFLgRCXdbpX7agR6Ebi0pX1r0eOez4p4i/66ew/6WU4kBidy3pjSWRNALGylR4iR2EYpYWDFhAPobTNWprnKWG8EYnBKBnuhuTO9HIxZSbm8lJ8+tyZcY4zUArMRgVYEvvt34= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721799942; c=relaxed/simple; bh=Ni/7m6ZN+sYMnOonIpgkMgG0NtgBM9pRE6mJdzZgU7I=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=bvQVNO9WYiUt6iNdkfX1fCOk7jRBm6SwIDHqpBiEuoOvOFhN6582yo9kXX0X+OgN173BtjTg5SYCjDSpslnTc37lv9Vq+e7/PDvlJgpSGVmPloN0AYJDMHkvdx+9CQ1Ano6w2ZEE0Eng7z9+b294oVfVp2qwxAwf36xy149Q5DI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Wc/77/su; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 486FBC4AF09; Wed, 24 Jul 2024 05:45:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1721799941; bh=Ni/7m6ZN+sYMnOonIpgkMgG0NtgBM9pRE6mJdzZgU7I=; h=From:To:Subject:Date:In-Reply-To:References:From; b=Wc/77/su7g2yhAOaBp0EBAiM4H/Gs+fRXrpOmtzBztEtYpOF1B0216YDpKmEEMHgI I25YAiRGFYuKsI00e0Vty6QGuChj58R0u5aRrZ+KU4Qj0WeeH/IglbmoyUzch3/rq7 ujjASZAU72JvoqVXahG3a0C4l1Z/Vtqsgnj4YbAYLUwYi1ucRTp8g+1Zo9kiKImHNm g1LJd6xKtyF3jDKawr0IdjOOTbTR9dcfm2KMYAVDXGTsrLznUxf94Z8yAXcBhIB9Wb Qb4lItMR59FfZr+l5JT69JDic2oMMMRjXxK3VBx7dS4dR4wO+Ir5wxz4Q+ogWVuDur 8po621sfVrv4g== From: Damien Le Moal To: linux-ide@vger.kernel.org, Niklas Cassel Subject: [PATCH v5 1/4] ata: libata: Rename ata_dma_blacklisted() Date: Wed, 24 Jul 2024 14:45:36 +0900 Message-ID: <20240724054539.182655-2-dlemoal@kernel.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240724054539.182655-1-dlemoal@kernel.org> References: <20240724054539.182655-1-dlemoal@kernel.org> Precedence: bulk X-Mailing-List: linux-ide@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Rename the function ata_dma_blacklisted() to ata_dev_nodma() as this new name is more neutral. The function signature is also changed to return a boolean instead of an int. Signed-off-by: Damien Le Moal Reviewed-by: Igor Pylypiv Reviewed-by: Niklas Cassel --- drivers/ata/libata-core.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c index c7752dc80028..a35bce4236d3 100644 --- a/drivers/ata/libata-core.c +++ b/drivers/ata/libata-core.c @@ -4287,16 +4287,17 @@ static unsigned long ata_dev_blacklisted(const struct ata_device *dev) return 0; } -static int ata_dma_blacklisted(const struct ata_device *dev) +static bool ata_dev_nodma(const struct ata_device *dev) { - /* We don't support polling DMA. - * DMA blacklist those ATAPI devices with CDB-intr (and use PIO) - * if the LLDD handles only interrupts in the HSM_ST_LAST state. + /* + * We do not support polling DMA. Deny DMA for those ATAPI devices + * with CDB-intr (and use PIO) if the LLDD handles only interrupts in + * the HSM_ST_LAST state. */ if ((dev->link->ap->flags & ATA_FLAG_PIO_POLLING) && (dev->flags & ATA_DFLAG_CDB_INTR)) - return 1; - return (dev->horkage & ATA_HORKAGE_NODMA) ? 1 : 0; + return true; + return dev->horkage & ATA_HORKAGE_NODMA; } /** @@ -4404,7 +4405,7 @@ static void ata_dev_xfermask(struct ata_device *dev) xfer_mask &= ~(0x03 << (ATA_SHIFT_MWDMA + 3)); } - if (ata_dma_blacklisted(dev)) { + if (ata_dev_nodma(dev)) { xfer_mask &= ~(ATA_MASK_MWDMA | ATA_MASK_UDMA); ata_dev_warn(dev, "device is on DMA blacklist, disabling DMA\n"); From patchwork Wed Jul 24 05:45:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Damien Le Moal X-Patchwork-Id: 1964124 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=nUnbTbqi; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=2604:1380:4601:e00::3; helo=am.mirrors.kernel.org; envelope-from=linux-ide+bounces-1949-incoming=patchwork.ozlabs.org@vger.kernel.org; receiver=patchwork.ozlabs.org) Received: from am.mirrors.kernel.org (am.mirrors.kernel.org [IPv6:2604:1380:4601:e00::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WTNKV0PQGz1yXp for ; Wed, 24 Jul 2024 15:45:49 +1000 (AEST) 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 am.mirrors.kernel.org (Postfix) with ESMTPS id 67E931F2405C for ; Wed, 24 Jul 2024 05:45:47 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1BDB63D982; Wed, 24 Jul 2024 05:45:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="nUnbTbqi" X-Original-To: linux-ide@vger.kernel.org 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 D06815695 for ; Wed, 24 Jul 2024 05:45: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=1721799942; cv=none; b=sFgTz7fPBec4dd+RVq7nOJmEoVRgZh0MjzLbF29rMghQmbFP3LX6kOVd6XLv3gNsvBL25MrPgUh+AZ05VDpxzS6ktgBw7pDWpC2zUH0OukoVjctmHz/sPgt2xrYKqWThSbBjMVuH/nxR0tOt6G4YGyn77vmZo1/UtF3HnTLm1CA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721799942; c=relaxed/simple; bh=qAo6DmgOz6INe7lueGb9cEF9x97gqqXvYI5WgiwmC84=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=UmRDKP9JjBTXC3Fi3vqkAjtklepS39cbkfxeKAp4gRo1ECKYPoq6+tM3gMxs5aqjvBLgXO0RQS96TFutqyUq4ILv/0aIoUNoQPqSQ1xTTB3ZSJP55Lph3GwzN2R5KVx8VM4WZK5KQQK8lv9kZRJJoPM/Bu5dFlTYAu9T3y7huok= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=nUnbTbqi; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1205BC32782; Wed, 24 Jul 2024 05:45:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1721799942; bh=qAo6DmgOz6INe7lueGb9cEF9x97gqqXvYI5WgiwmC84=; h=From:To:Subject:Date:In-Reply-To:References:From; b=nUnbTbqioaFcLpyK9mZE5ggEpxRn2Q3T5W75T9B3qAwdoqhuw3ezk63glErHiWS7F /4E8MZYzGIrhlsE3JzeTAJsMaiXl6keI7EVKSj4WIPPcwHsK7/pyBry+4ZFklYE4Hl h8AzkZfm+De6xvRhEpZaoj+0K0i0dC3Ja5W43MpIxTIbydCbuq1J3K3EQNIVZLIGS/ nmHhpb3t+hC9DJuCL2H090xrub59WaNyzYKQpq70J+og2rhojyd/RJNFInyCqUIWmB 5dSaiXxhCgtM8hjVyGlJM4BlLIgWRMT8ICtzxNkkE0p1jLNSzbLgVlwSS0wZpKXez4 XkDyLjaH0qyHA== From: Damien Le Moal To: linux-ide@vger.kernel.org, Niklas Cassel Subject: [PATCH v5 2/4] ata: libata: Rename ata_dev_blacklisted() Date: Wed, 24 Jul 2024 14:45:37 +0900 Message-ID: <20240724054539.182655-3-dlemoal@kernel.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240724054539.182655-1-dlemoal@kernel.org> References: <20240724054539.182655-1-dlemoal@kernel.org> Precedence: bulk X-Mailing-List: linux-ide@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Rename the function ata_dev_blacklisted() to ata_dev_horkage() as this new name: 1) Does not use an expression that can be considered as negatively loaded. 2) The name does not reflect what the function actually does, which is returning a set of horkage flag for the device, of which only one flag will completely disable the device. Signed-off-by: Damien Le Moal Reviewed-by: Igor Pylypiv --- drivers/ata/libata-core.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c index a35bce4236d3..272770f09609 100644 --- a/drivers/ata/libata-core.c +++ b/drivers/ata/libata-core.c @@ -84,7 +84,7 @@ static unsigned int ata_dev_init_params(struct ata_device *dev, u16 heads, u16 sectors); static unsigned int ata_dev_set_xfermode(struct ata_device *dev); static void ata_dev_xfermask(struct ata_device *dev); -static unsigned long ata_dev_blacklisted(const struct ata_device *dev); +static unsigned long ata_dev_horkage(const struct ata_device *dev); static DEFINE_IDA(ata_ida); @@ -2223,7 +2223,7 @@ static inline u8 ata_dev_knobble(struct ata_device *dev) { struct ata_port *ap = dev->link->ap; - if (ata_dev_blacklisted(dev) & ATA_HORKAGE_BRIDGE_OK) + if (ata_dev_horkage(dev) & ATA_HORKAGE_BRIDGE_OK) return 0; return ((ap->cbl == ATA_CBL_SATA) && (!ata_id_is_sata(dev->id))); @@ -2830,7 +2830,7 @@ int ata_dev_configure(struct ata_device *dev) } /* set horkage */ - dev->horkage |= ata_dev_blacklisted(dev); + dev->horkage |= ata_dev_horkage(dev); ata_force_horkage(dev); if (dev->horkage & ATA_HORKAGE_DISABLE) { @@ -3987,13 +3987,13 @@ int ata_dev_revalidate(struct ata_device *dev, unsigned int new_class, return rc; } -struct ata_blacklist_entry { +struct ata_dev_horkage_entry { const char *model_num; const char *model_rev; unsigned long horkage; }; -static const struct ata_blacklist_entry ata_device_blacklist [] = { +static const struct ata_dev_horkage_entry ata_dev_horkages[] = { /* Devices with DMA related problems under Linux */ { "WDC AC11000H", NULL, ATA_HORKAGE_NODMA }, { "WDC AC22100H", NULL, ATA_HORKAGE_NODMA }, @@ -4111,7 +4111,7 @@ static const struct ata_blacklist_entry ata_device_blacklist [] = { /* Devices which get the IVB wrong */ { "QUANTUM FIREBALLlct10 05", "A03.0900", ATA_HORKAGE_IVB }, - /* Maybe we should just blacklist TSSTcorp... */ + /* Maybe we should just add all TSSTcorp devices... */ { "TSSTcorp CDDVDW SH-S202[HJN]", "SB0[01]", ATA_HORKAGE_IVB }, /* Devices that do not need bridging limits applied */ @@ -4266,11 +4266,11 @@ static const struct ata_blacklist_entry ata_device_blacklist [] = { { } }; -static unsigned long ata_dev_blacklisted(const struct ata_device *dev) +static unsigned long ata_dev_horkage(const struct ata_device *dev) { unsigned char model_num[ATA_ID_PROD_LEN + 1]; unsigned char model_rev[ATA_ID_FW_REV_LEN + 1]; - const struct ata_blacklist_entry *ad = ata_device_blacklist; + const struct ata_dev_horkage_entry *ad = ata_dev_horkages; ata_id_c_string(dev->id, model_num, ATA_ID_PROD, sizeof(model_num)); ata_id_c_string(dev->id, model_rev, ATA_ID_FW_REV, sizeof(model_rev)); @@ -4372,8 +4372,7 @@ static int cable_is_40wire(struct ata_port *ap) * * Compute supported xfermask of @dev and store it in * dev->*_mask. This function is responsible for applying all - * known limits including host controller limits, device - * blacklist, etc... + * known limits including host controller limits, device horkages, etc... * * LOCKING: * None. From patchwork Wed Jul 24 05:45:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Damien Le Moal X-Patchwork-Id: 1964121 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=oNIKfgAW; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=139.178.88.99; helo=sv.mirrors.kernel.org; envelope-from=linux-ide+bounces-1950-incoming=patchwork.ozlabs.org@vger.kernel.org; receiver=patchwork.ozlabs.org) Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org [139.178.88.99]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WTNKS1cXhz1yXp for ; Wed, 24 Jul 2024 15:45:48 +1000 (AEST) 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 C1411285228 for ; Wed, 24 Jul 2024 05:45:46 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 969E043AA1; Wed, 24 Jul 2024 05:45:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="oNIKfgAW" X-Original-To: linux-ide@vger.kernel.org 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 543FC5695 for ; Wed, 24 Jul 2024 05:45:43 +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=1721799943; cv=none; b=hSdkR0GqZDB6fyLV99omkLXfPeCY2X1WglbE3ESocYOrndo1mnCFaSmrpgT3odjTq9aEhAt7PIlardHSpdTBeVxtf9g3ViJLS1PEnva1cL/83KrLc/Wm/CL6wyKdedUzryO6v4RPc0qisvSgcgdW/7pelGtjbBhV/OqDvUFG7K0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721799943; c=relaxed/simple; bh=VBD3L08DqUTOZP6+dpG2TPZsqxTNifZatECQXdup8kQ=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=YaR0f/wH1e3MLE6V9gUz7Wknnen+uvXGhxO9yU+fqjJmb+Gyzt5eTAAXqyRdEJwXQGDqv6DzET2WQSjo3vpycmhG9EXr15dAtNrQKh8TuW1fMIPeBJ2cf7uSVMQ1flpxyJbnU4qH5xipRzWvmwoxcAQ+X6y2Do44l1svL6rBeyE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=oNIKfgAW; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id AD1DCC4AF09; Wed, 24 Jul 2024 05:45:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1721799943; bh=VBD3L08DqUTOZP6+dpG2TPZsqxTNifZatECQXdup8kQ=; h=From:To:Subject:Date:In-Reply-To:References:From; b=oNIKfgAWDD/Gchy18LVlQzdst5i8VXCs4YGUlYONIrhnzvalBzSp6G+qatqdr4opE pNmt5vMh9vyMU2BNhTTZTjvajkUqyD5vOY6pMoRhnXsagXYyYw8M0T9Fu0ejvkHZQy 3p+mMV1vu15co6I9tVBjXpqZsZOa331ZY2a55IRL6l1SHCSdmYWMLumS+81hSj7HuK NywjocbY455gMSX4ak1n8nuquA23wnXzWGHP26mc/HvW5Nj8acdvLNCMh+w8wmFwAV hkG+dqwlPWKYbHhfqXMANDeLnoFvHD0xqp/37MBUWWAfERBPWe0eWAHHQ5kghOyumR 2MoTbwuHub91g== From: Damien Le Moal To: linux-ide@vger.kernel.org, Niklas Cassel Subject: [PATCH v5 3/4] ata: libata: Change ata_dev_knobble() to return a bool Date: Wed, 24 Jul 2024 14:45:38 +0900 Message-ID: <20240724054539.182655-4-dlemoal@kernel.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240724054539.182655-1-dlemoal@kernel.org> References: <20240724054539.182655-1-dlemoal@kernel.org> Precedence: bulk X-Mailing-List: linux-ide@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Change the function ata_dev_knobble() to return a boolean instead of a u8. Signed-off-by: Damien Le Moal Reviewed-by: Igor Pylypiv Reviewed-by: Niklas Cassel --- drivers/ata/libata-core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c index 272770f09609..4ef1d14aba1e 100644 --- a/drivers/ata/libata-core.c +++ b/drivers/ata/libata-core.c @@ -2219,12 +2219,12 @@ static int ata_do_link_spd_horkage(struct ata_device *dev) return 0; } -static inline u8 ata_dev_knobble(struct ata_device *dev) +static inline bool ata_dev_knobble(struct ata_device *dev) { struct ata_port *ap = dev->link->ap; if (ata_dev_horkage(dev) & ATA_HORKAGE_BRIDGE_OK) - return 0; + return false; return ((ap->cbl == ATA_CBL_SATA) && (!ata_id_is_sata(dev->id))); } From patchwork Wed Jul 24 05:45:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Damien Le Moal X-Patchwork-Id: 1964122 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=n63gDJc5; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=139.178.88.99; helo=sv.mirrors.kernel.org; envelope-from=linux-ide+bounces-1951-incoming=patchwork.ozlabs.org@vger.kernel.org; receiver=patchwork.ozlabs.org) Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org [139.178.88.99]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WTNKS6f7bz20FW for ; Wed, 24 Jul 2024 15:45:48 +1000 (AEST) 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 9CC59285247 for ; Wed, 24 Jul 2024 05:45:47 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4209A46B91; Wed, 24 Jul 2024 05:45:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="n63gDJc5" X-Original-To: linux-ide@vger.kernel.org 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 F2D135695 for ; Wed, 24 Jul 2024 05:45:43 +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=1721799944; cv=none; b=K1Z/j3Z+GwlqzkFOp+aCi99SEze5GKFNAhmbhGXqrh5hz5vZTgfXtR+hbSd+pJcvQnmueGV2Z/ZjJliDBV79v2W/Ffq75o8anegx763hLD3j3voPepcR7ydatQSsQnjralyPMeN95Qc5TwDowtunG0DAOwpuvB96jwbbhET2zfI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721799944; c=relaxed/simple; bh=1dOR5Q9JS9II/0GANAVkW3jImwTV/m59pSVPHn1o2Ek=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=sHHnCdL1P9t13173nJHtSzX7kVnatFfMD2qD08iymykfb1Td1RrDySlO312nyUvtBXhdcdPPDDjhPNa/OxH63hyN4o1TW1mSenEnfm0eWPGoz5BFHvmvrI6VHYtY8D+pmn+D43XcuQcfxSs/L/mb2p77aQ9KCNQyjCIdxEDDbNo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=n63gDJc5; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 50A78C4AF10; Wed, 24 Jul 2024 05:45:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1721799943; bh=1dOR5Q9JS9II/0GANAVkW3jImwTV/m59pSVPHn1o2Ek=; h=From:To:Subject:Date:In-Reply-To:References:From; b=n63gDJc5AElJnrCfnWJqdEZEDoN34YYTApBDl/xWBliB2crdnG5AsflfYKD1AVoXr 1dH3zluBFg92G6+3MYA5/HdnubPUWP8SBq+SUdjstyNGgqrlsAN/Q55r763AxyqxbY D7C2KdW+smo5JRV/7rPCVHIg3Dwaz+IpD6Bu3nFvykjeKTsA0ch/JUNIV+AAJyxcaR IIshciGsJWmZhDNk+o742GZzOMp2UsADWof86Xojxq0H0anmyYeOWB2nguzJkuQXKt fUb1DWVrOo2h+oK46tWM9M6k3eg6cHmFushSQviq+ndZ0LThXusLGZhlVzT9kSk61D Rq7ZbNUqNBCAQ== From: Damien Le Moal To: linux-ide@vger.kernel.org, Niklas Cassel Subject: [PATCH v5 4/4] ata: libata: Print horkages applied to devices Date: Wed, 24 Jul 2024 14:45:39 +0900 Message-ID: <20240724054539.182655-5-dlemoal@kernel.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240724054539.182655-1-dlemoal@kernel.org> References: <20240724054539.182655-1-dlemoal@kernel.org> Precedence: bulk X-Mailing-List: linux-ide@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Introduce the function ata_dev_print_horkage() to print the horkage flags that will be used for a device. This new function is called from ata_dev_horkage() when a match on a device model or device model and revision is found for a device in the ata_dev_horkages array. To implement this function, the ATA_HORKAGE_ flags are redefined using the new enum ata_horkage which defines the bit shift for each horkage flag. The array of strings ata_horkage_names is used to define the name of each flag, which are printed by ata_dev_print_horkage(). Example output for a device listed in the ata_dev_horkages array and which has the ATA_HORKAGE_DISABLE flag applied: [10193.461270] ata1: SATA link up 6.0 Gbps (SStatus 133 SControl 300) [10193.469190] ata1.00: Model 'ASMT109x- Config', rev '2143 5', applying horkages: disable [10193.469195] ata1.00: unsupported device, disabling [10193.481564] ata1.00: disable device And while at it, make sure to use the unsigned int type for horkage flags as struct ata_device->horkage is an unsigned int. Signed-off-by: Damien Le Moal Reviewed-by: Igor Pylypiv --- drivers/ata/libata-core.c | 82 +++++++++++++++++++++++++--- include/linux/libata.h | 112 +++++++++++++++++++++++++------------- 2 files changed, 149 insertions(+), 45 deletions(-) diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c index 4ef1d14aba1e..b29c798c6834 100644 --- a/drivers/ata/libata-core.c +++ b/drivers/ata/libata-core.c @@ -84,7 +84,7 @@ static unsigned int ata_dev_init_params(struct ata_device *dev, u16 heads, u16 sectors); static unsigned int ata_dev_set_xfermode(struct ata_device *dev); static void ata_dev_xfermask(struct ata_device *dev); -static unsigned long ata_dev_horkage(const struct ata_device *dev); +static unsigned int ata_dev_horkage(const struct ata_device *dev); static DEFINE_IDA(ata_ida); @@ -3987,10 +3987,73 @@ int ata_dev_revalidate(struct ata_device *dev, unsigned int new_class, return rc; } +static const char * const ata_horkage_names[] = { + [__ATA_HORKAGE_DIAGNOSTIC] = "diagnostic", + [__ATA_HORKAGE_NODMA] = "nodma", + [__ATA_HORKAGE_NONCQ] = "noncq", + [__ATA_HORKAGE_MAX_SEC_128] = "maxsec128", + [__ATA_HORKAGE_BROKEN_HPA] = "brokenhpa", + [__ATA_HORKAGE_DISABLE] = "disable", + [__ATA_HORKAGE_HPA_SIZE] = "hpasize", + [__ATA_HORKAGE_IVB] = "ivb", + [__ATA_HORKAGE_STUCK_ERR] = "stuckerr", + [__ATA_HORKAGE_BRIDGE_OK] = "bridgeok", + [__ATA_HORKAGE_ATAPI_MOD16_DMA] = "atapimod16dma", + [__ATA_HORKAGE_FIRMWARE_WARN] = "firmwarewarn", + [__ATA_HORKAGE_1_5_GBPS] = "1.5gbps", + [__ATA_HORKAGE_NOSETXFER] = "nosetxfer", + [__ATA_HORKAGE_BROKEN_FPDMA_AA] = "brokenfpdmaaa", + [__ATA_HORKAGE_DUMP_ID] = "dumpid", + [__ATA_HORKAGE_MAX_SEC_LBA48] = "maxseclba48", + [__ATA_HORKAGE_ATAPI_DMADIR] = "atapidmadir", + [__ATA_HORKAGE_NO_NCQ_TRIM] = "noncqtrim", + [__ATA_HORKAGE_NOLPM] = "nolpm", + [__ATA_HORKAGE_WD_BROKEN_LPM] = "wdbrokenlpm", + [__ATA_HORKAGE_ZERO_AFTER_TRIM] = "zeroaftertrim", + [__ATA_HORKAGE_NO_DMA_LOG] = "nodmalog", + [__ATA_HORKAGE_NOTRIM] = "notrim", + [__ATA_HORKAGE_MAX_SEC_1024] = "maxsec1024", + [__ATA_HORKAGE_MAX_TRIM_128M] = "maxtrim128m", + [__ATA_HORKAGE_NO_NCQ_ON_ATI] = "noncqonati", + [__ATA_HORKAGE_NO_ID_DEV_LOG] = "noiddevlog", + [__ATA_HORKAGE_NO_LOG_DIR] = "nologdir", + [__ATA_HORKAGE_NO_FUA] = "nofua", +}; + +static void ata_dev_print_horkage(const struct ata_device *dev, + const char *model, const char *rev, + unsigned int horkage) +{ + int n = 0, i; + size_t sz; + char *str; + + if (!horkage) + return; + + sz = 64 + ARRAY_SIZE(ata_horkage_names) * 16; + str = kmalloc(sz, GFP_KERNEL); + if (!str) + return; + + n = snprintf(str, sz, "Model '%s', rev '%s', applying horkages:", + model, rev); + + for (i = 0; i < ARRAY_SIZE(ata_horkage_names); i++) { + if (horkage & (1U << i)) + n += snprintf(str + n, sz - n, + " %s", ata_horkage_names[i]); + } + + ata_dev_warn(dev, "%s\n", str); + + kfree(str); +} + struct ata_dev_horkage_entry { const char *model_num; const char *model_rev; - unsigned long horkage; + unsigned int horkage; }; static const struct ata_dev_horkage_entry ata_dev_horkages[] = { @@ -4266,21 +4329,24 @@ static const struct ata_dev_horkage_entry ata_dev_horkages[] = { { } }; -static unsigned long ata_dev_horkage(const struct ata_device *dev) +static unsigned int ata_dev_horkage(const struct ata_device *dev) { unsigned char model_num[ATA_ID_PROD_LEN + 1]; unsigned char model_rev[ATA_ID_FW_REV_LEN + 1]; const struct ata_dev_horkage_entry *ad = ata_dev_horkages; + /* dev->horkage is an unsigned int. */ + BUILD_BUG_ON(__ATA_HORKAGE_MAX > 32); + ata_id_c_string(dev->id, model_num, ATA_ID_PROD, sizeof(model_num)); ata_id_c_string(dev->id, model_rev, ATA_ID_FW_REV, sizeof(model_rev)); while (ad->model_num) { - if (glob_match(ad->model_num, model_num)) { - if (ad->model_rev == NULL) - return ad->horkage; - if (glob_match(ad->model_rev, model_rev)) - return ad->horkage; + if (glob_match(ad->model_num, model_num) && + (!ad->model_rev || glob_match(ad->model_rev, model_rev))) { + ata_dev_print_horkage(dev, model_num, model_rev, + ad->horkage); + return ad->horkage; } ad++; } diff --git a/include/linux/libata.h b/include/linux/libata.h index 17394098bee9..b1768db0089b 100644 --- a/include/linux/libata.h +++ b/include/linux/libata.h @@ -55,6 +55,48 @@ /* defines only for the constants which don't work well as enums */ #define ATA_TAG_POISON 0xfafbfcfdU +/* + * Horkage types. May be set by libata or controller on drives. + * Some horkage may be drive/controller pair dependent. + * ata_device->horkage is an unsigned int, so __ATA_HORKAGE_MAX must not + * exceed 32. + */ +enum ata_horkage { + __ATA_HORKAGE_DIAGNOSTIC, /* Failed boot diag */ + __ATA_HORKAGE_NODMA, /* DMA problems */ + __ATA_HORKAGE_NONCQ, /* Don't use NCQ */ + __ATA_HORKAGE_MAX_SEC_128, /* Limit max sects to 128 */ + __ATA_HORKAGE_BROKEN_HPA, /* Broken HPA */ + __ATA_HORKAGE_DISABLE, /* Disable it */ + __ATA_HORKAGE_HPA_SIZE, /* Native size off by one */ + __ATA_HORKAGE_IVB, /* cbl det validity bit bugs */ + __ATA_HORKAGE_STUCK_ERR, /* Stuck ERR on next PACKET */ + __ATA_HORKAGE_BRIDGE_OK, /* No bridge limits */ + __ATA_HORKAGE_ATAPI_MOD16_DMA, /* Use ATAPI DMA for commands that are + * not a multiple of 16 bytes */ + __ATA_HORKAGE_FIRMWARE_WARN, /* Firmware update warning */ + __ATA_HORKAGE_1_5_GBPS, /* Force 1.5 Gbps */ + __ATA_HORKAGE_NOSETXFER, /* Skip SETXFER, SATA only */ + __ATA_HORKAGE_BROKEN_FPDMA_AA, /* Skip AA */ + __ATA_HORKAGE_DUMP_ID, /* Dump IDENTIFY data */ + __ATA_HORKAGE_MAX_SEC_LBA48, /* Set max sects to 65535 */ + __ATA_HORKAGE_ATAPI_DMADIR, /* Device requires dmadir */ + __ATA_HORKAGE_NO_NCQ_TRIM, /* Do not use queued TRIM */ + __ATA_HORKAGE_NOLPM, /* Do not use LPM */ + __ATA_HORKAGE_WD_BROKEN_LPM, /* Some WDs have broken LPM */ + __ATA_HORKAGE_ZERO_AFTER_TRIM, /* Guarantees zero after trim */ + __ATA_HORKAGE_NO_DMA_LOG, /* Do not use DMA for log read */ + __ATA_HORKAGE_NOTRIM, /* Do not use TRIM */ + __ATA_HORKAGE_MAX_SEC_1024, /* Limit max sects to 1024 */ + __ATA_HORKAGE_MAX_TRIM_128M, /* Limit max trim size to 128M */ + __ATA_HORKAGE_NO_NCQ_ON_ATI, /* Disable NCQ on ATI chipset */ + __ATA_HORKAGE_NO_ID_DEV_LOG, /* Identify device log missing */ + __ATA_HORKAGE_NO_LOG_DIR, /* Do not read log directory */ + __ATA_HORKAGE_NO_FUA, /* Do not use FUA */ + + __ATA_HORKAGE_MAX, +}; + enum { /* various global constants */ LIBATA_MAX_PRD = ATA_MAX_PRD / 2, @@ -362,43 +404,39 @@ enum { */ ATA_EH_CMD_TIMEOUT_TABLE_SIZE = 8, - /* Horkage types. May be set by libata or controller on drives - (some horkage may be drive/controller pair dependent */ - - ATA_HORKAGE_DIAGNOSTIC = (1 << 0), /* Failed boot diag */ - ATA_HORKAGE_NODMA = (1 << 1), /* DMA problems */ - ATA_HORKAGE_NONCQ = (1 << 2), /* Don't use NCQ */ - ATA_HORKAGE_MAX_SEC_128 = (1 << 3), /* Limit max sects to 128 */ - ATA_HORKAGE_BROKEN_HPA = (1 << 4), /* Broken HPA */ - ATA_HORKAGE_DISABLE = (1 << 5), /* Disable it */ - ATA_HORKAGE_HPA_SIZE = (1 << 6), /* native size off by one */ - ATA_HORKAGE_IVB = (1 << 8), /* cbl det validity bit bugs */ - ATA_HORKAGE_STUCK_ERR = (1 << 9), /* stuck ERR on next PACKET */ - ATA_HORKAGE_BRIDGE_OK = (1 << 10), /* no bridge limits */ - ATA_HORKAGE_ATAPI_MOD16_DMA = (1 << 11), /* use ATAPI DMA for commands - not multiple of 16 bytes */ - ATA_HORKAGE_FIRMWARE_WARN = (1 << 12), /* firmware update warning */ - ATA_HORKAGE_1_5_GBPS = (1 << 13), /* force 1.5 Gbps */ - ATA_HORKAGE_NOSETXFER = (1 << 14), /* skip SETXFER, SATA only */ - ATA_HORKAGE_BROKEN_FPDMA_AA = (1 << 15), /* skip AA */ - ATA_HORKAGE_DUMP_ID = (1 << 16), /* dump IDENTIFY data */ - ATA_HORKAGE_MAX_SEC_LBA48 = (1 << 17), /* Set max sects to 65535 */ - ATA_HORKAGE_ATAPI_DMADIR = (1 << 18), /* device requires dmadir */ - ATA_HORKAGE_NO_NCQ_TRIM = (1 << 19), /* don't use queued TRIM */ - ATA_HORKAGE_NOLPM = (1 << 20), /* don't use LPM */ - ATA_HORKAGE_WD_BROKEN_LPM = (1 << 21), /* some WDs have broken LPM */ - ATA_HORKAGE_ZERO_AFTER_TRIM = (1 << 22),/* guarantees zero after trim */ - ATA_HORKAGE_NO_DMA_LOG = (1 << 23), /* don't use DMA for log read */ - ATA_HORKAGE_NOTRIM = (1 << 24), /* don't use TRIM */ - ATA_HORKAGE_MAX_SEC_1024 = (1 << 25), /* Limit max sects to 1024 */ - ATA_HORKAGE_MAX_TRIM_128M = (1 << 26), /* Limit max trim size to 128M */ - ATA_HORKAGE_NO_NCQ_ON_ATI = (1 << 27), /* Disable NCQ on ATI chipset */ - ATA_HORKAGE_NO_ID_DEV_LOG = (1 << 28), /* Identify device log missing */ - ATA_HORKAGE_NO_LOG_DIR = (1 << 29), /* Do not read log directory */ - ATA_HORKAGE_NO_FUA = (1 << 30), /* Do not use FUA */ - - /* DMA mask for user DMA control: User visible values; DO NOT - renumber */ + /* Horkage flags */ + ATA_HORKAGE_DIAGNOSTIC = (1U << __ATA_HORKAGE_DIAGNOSTIC), + ATA_HORKAGE_NODMA = (1U << __ATA_HORKAGE_NODMA), + ATA_HORKAGE_NONCQ = (1U << __ATA_HORKAGE_NONCQ), + ATA_HORKAGE_MAX_SEC_128 = (1U << __ATA_HORKAGE_MAX_SEC_128), + ATA_HORKAGE_BROKEN_HPA = (1U << __ATA_HORKAGE_BROKEN_HPA), + ATA_HORKAGE_DISABLE = (1U << __ATA_HORKAGE_DISABLE), + ATA_HORKAGE_HPA_SIZE = (1U << __ATA_HORKAGE_HPA_SIZE), + ATA_HORKAGE_IVB = (1U << __ATA_HORKAGE_IVB), + ATA_HORKAGE_STUCK_ERR = (1U << __ATA_HORKAGE_STUCK_ERR), + ATA_HORKAGE_BRIDGE_OK = (1U << __ATA_HORKAGE_BRIDGE_OK), + ATA_HORKAGE_ATAPI_MOD16_DMA = (1U << __ATA_HORKAGE_ATAPI_MOD16_DMA), + ATA_HORKAGE_FIRMWARE_WARN = (1U << __ATA_HORKAGE_FIRMWARE_WARN), + ATA_HORKAGE_1_5_GBPS = (1U << __ATA_HORKAGE_1_5_GBPS), + ATA_HORKAGE_NOSETXFER = (1U << __ATA_HORKAGE_NOSETXFER), + ATA_HORKAGE_BROKEN_FPDMA_AA = (1U << __ATA_HORKAGE_BROKEN_FPDMA_AA), + ATA_HORKAGE_DUMP_ID = (1U << __ATA_HORKAGE_DUMP_ID), + ATA_HORKAGE_MAX_SEC_LBA48 = (1U << __ATA_HORKAGE_MAX_SEC_LBA48), + ATA_HORKAGE_ATAPI_DMADIR = (1U << __ATA_HORKAGE_ATAPI_DMADIR), + ATA_HORKAGE_NO_NCQ_TRIM = (1U << __ATA_HORKAGE_NO_NCQ_TRIM), + ATA_HORKAGE_NOLPM = (1U << __ATA_HORKAGE_NOLPM), + ATA_HORKAGE_WD_BROKEN_LPM = (1U << __ATA_HORKAGE_WD_BROKEN_LPM), + ATA_HORKAGE_ZERO_AFTER_TRIM = (1U << __ATA_HORKAGE_ZERO_AFTER_TRIM), + ATA_HORKAGE_NO_DMA_LOG = (1U << __ATA_HORKAGE_NO_DMA_LOG), + ATA_HORKAGE_NOTRIM = (1U << __ATA_HORKAGE_NOTRIM), + ATA_HORKAGE_MAX_SEC_1024 = (1U << __ATA_HORKAGE_MAX_SEC_1024), + ATA_HORKAGE_MAX_TRIM_128M = (1U << __ATA_HORKAGE_MAX_TRIM_128M), + ATA_HORKAGE_NO_NCQ_ON_ATI = (1U << __ATA_HORKAGE_NO_NCQ_ON_ATI), + ATA_HORKAGE_NO_ID_DEV_LOG = (1U << __ATA_HORKAGE_NO_ID_DEV_LOG), + ATA_HORKAGE_NO_LOG_DIR = (1U << __ATA_HORKAGE_NO_LOG_DIR), + ATA_HORKAGE_NO_FUA = (1U << __ATA_HORKAGE_NO_FUA), + + /* User visible DMA mask for DMA control. DO NOT renumber. */ ATA_DMA_MASK_ATA = (1 << 0), /* DMA on ATA Disk */ ATA_DMA_MASK_ATAPI = (1 << 1), /* DMA on ATAPI */ ATA_DMA_MASK_CFA = (1 << 2), /* DMA on CF Card */