Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp2837415rwr; Fri, 21 Apr 2023 15:14:47 -0700 (PDT) X-Google-Smtp-Source: AKy350bv4q1arr/X71LXiKKAd+qQlpvX9Ql8BXnvn57CkRr5pujMcB3FmZ5wvTpBmsgHrXRPxXzM X-Received: by 2002:a17:90a:1d0:b0:240:cf04:c997 with SMTP id 16-20020a17090a01d000b00240cf04c997mr5991558pjd.2.1682115287456; Fri, 21 Apr 2023 15:14:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682115287; cv=none; d=google.com; s=arc-20160816; b=E5fjeAtzc4XLhx2aKQksbA0xo1Wz0TdVoa4J1ESUx3nfKGsP8vApCzjXNQEiUZCGZO Xs+Z2MAwQuRzaByxOxco0cqlQWAGnnJffICbfBoquEBGkcVI/rsDafDec0rAOsGe8Nxg 4R/LzrPYkuKrI4ca8gdwxewdXomVi0CSTGbvYE1QGf+LOE++IovD99t/VfkiY7MIO2mR pLgN1Jqk2yNQoqLMhNGTjRkIeCSxFGwpxXPDVJMGE6399lQ2VFnWZq4yGoi5EiNSEIS0 MoGzyq1mLS2aWGl+1NGFyftMqShuwUlcGKg/c8CDTkfJ7ksCzY5S1RO/3x6viRIvIwey VijA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to :organization:from:content-language:references:cc:to:subject :user-agent:mime-version:date:message-id:dkim-signature; bh=e1UzU90A1OOu9vqnH/jcpeiEFaAQtJeVb27Fy4zrE1Y=; b=FJnM3irI2AG6vy5aPoB724OD1vTQM5+78mGl6IJx0B+TZCJzBtUl9eZyMisW8QxIW7 huELuC09EuP/Aft4Ld+6/zO+zZa7isN9YIFKGeg1w9pQCTSrzTPb3+HHT4r2f60VNKM5 ewadAw7OjFM5Ynsw8bQvYlRX5l44CTS2gEdXGF3AMzFx2+QT7+gksQM9ErN9b0nR0KE6 xpJVaczecIQAwkGgpYPrr2ogXBW5oE920bkvIT93jMbEVAV5ZJbOxLLaLmD25I5ma9dL AS3ToKTbApBfEIx4TCqhDG3FWxMXu0KfrKOipTjHOVLtYoiAHR1muEBeV1Z+3cdOQHYz UCvQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=gxZ0nicr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id pg8-20020a17090b1e0800b0023312fad927si8614857pjb.100.2023.04.21.15.14.35; Fri, 21 Apr 2023 15:14:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=gxZ0nicr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S233348AbjDUWHt (ORCPT + 99 others); Fri, 21 Apr 2023 18:07:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50808 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229656AbjDUWHr (ORCPT ); Fri, 21 Apr 2023 18:07:47 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BF0F4172A; Fri, 21 Apr 2023 15:07:44 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 48F216183D; Fri, 21 Apr 2023 22:07:44 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DF7B6C433D2; Fri, 21 Apr 2023 22:07:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1682114863; bh=pDVibJhWt9LWG5jQ982Dyc+TkQMXFvLmet6bPhbcktY=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=gxZ0nicrjFY6j9AYM+POfkfJscGG0Y6W8XNTVuGvspBoH4cgv68pEXcvDlNCw8otO Hk/QhQ8L2jeiflF0k7ZW8yIWQBj4dP+s2sFbbV+jHg5qmRnGuj6j+BC3NBo23WjX5E JSECn+/0hSHjpUSAInyNoaXSOxJTUPs/RqHZNTIw5k5wvWgeU7u9l28Mkby1B6ZZGo hTcRqxYlRQsOyQYcNW15GdYKVQPoeDicdqGlugn1VW/b+TgJ75FIslyO7OZ7URsywb IxoUKpNxdWFxk0Z4d+lenNwXa90YBIuA92gE5OtxVaDNGP2Vh0aniz1jptqJVpd0er w9nd5/qYhRbIQ== Message-ID: Date: Sat, 22 Apr 2023 07:07:41 +0900 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.10.0 Subject: Re: [PATCH] drivers/ata: Improve performance and readability To: Yahu Gao Cc: linux-ide@vger.kernel.org, linux-kernel@vger.kernel.org, Yahu Gao , Jiwei Sun References: Content-Language: en-US From: Damien Le Moal Organization: Western Digital Research In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 4/21/23 21:54, Yahu Gao wrote: > From: Yahu Gao > The patch title should start with: ata: libata-core: ... And let's be honest here: this is not the hot path and you are optimizing a single "if" condition for a series of commands that will take 10s of ms to execute. So this is *not* about performance. So update the patch title please. > Replace conditions of avoid issuing [P]IDENTIFY to PMP. > > Reviewed-by: Jiwei Sun > Signed-off-by: Yahu Gao > > diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c > index 14c17c3bda4e..53f65d751189 100644 > --- a/drivers/ata/libata-core.c > +++ b/drivers/ata/libata-core.c > @@ -3802,11 +3802,7 @@ int ata_dev_revalidate(struct ata_device *dev, unsigned int new_class, > return -ENODEV; > > /* fail early if !ATA && !ATAPI to avoid issuing [P]IDENTIFY to PMP */ > - if (ata_class_enabled(new_class) && > - new_class != ATA_DEV_ATA && > - new_class != ATA_DEV_ATAPI && > - new_class != ATA_DEV_ZAC && > - new_class != ATA_DEV_SEMB) { > + if (new_class == ATA_DEV_PMP) { Using a switch-case here may actually make things even more readable. > ata_dev_info(dev, "class mismatch %u != %u\n", > dev->class, new_class); > rc = -ENODEV;