Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AC971C43381 for ; Wed, 27 Mar 2019 21:38:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 776B32075E for ; Wed, 27 Mar 2019 21:38:33 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="nTTNRl4A" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727576AbfC0Vic (ORCPT ); Wed, 27 Mar 2019 17:38:32 -0400 Received: from mail-wr1-f68.google.com ([209.85.221.68]:44995 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726059AbfC0Vib (ORCPT ); Wed, 27 Mar 2019 17:38:31 -0400 Received: by mail-wr1-f68.google.com with SMTP id y7so16205777wrn.11 for ; Wed, 27 Mar 2019 14:38:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=L8+YP/vtTr6vE8ZBXBfHau4ZqZ/x8b8vFUh1jeL6KEM=; b=nTTNRl4AuXJ28NSAWPn3vgOk6+OQfCvx4NQs4ouOJwD6WdqYjNu7P7M1uYsBnSRwwF JhYkAW80p7hHYZq78/6/qqOm/f6CY8aXSUCAl59Fjq6nNtahUqznrEP2etfv9P6bI8mR P2ypIGyIyvGGMaEKWoNfj0SEPTOKx6bqwVt7+DYpfgw6gLt9HZEh9JCI7PTK/NtsOUij 6ffKuznMOo0BwxPgz3BQiiLVFIKsPo652P3NCxM2kBW9AJ2BhLc0yCIYCje2ah9lU40w y8EUY2cBwwOCOnotgJy2NuowoAh59HOS7m3qWTyhGo4XcfqGuYXpUe9eaABCVrzvILt5 rlXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=L8+YP/vtTr6vE8ZBXBfHau4ZqZ/x8b8vFUh1jeL6KEM=; b=l3UcVssfcumGP8QAzhFpeI1ItHjkpHpuKLblGAMKVWm42csSUfEatlYt90XF03pPIB PzLZX1+EJF/QKhvfPBk+CwkMStriW9ri5CPitXbl1G5gb79lNtdafAeN4utl4a25Hx2q hQP33sDJSBCG6xM9N6AJKMy7JcBivabA8G0jQeAVqIHANN5BwSgoPGWeG1Smg3btzLgJ 6jWC/zQzwpgA6FWO8yZM31WSnPOKiPc+wjOqRmqqq+ytON3OovCR2A/5ENiW969e2o8Q Sb3Hp1CDqfKws3QMjPfk5mgC5X1fQThb/1CJxtYrwSnscb7ARaVtU8lkkE+EORTuXxbF bReg== X-Gm-Message-State: APjAAAUkCuyKqIw0rR+WhbCFIgx5uWLkVSJKtDsjpnXXDOwzzYhG9dMN gYUqRv2v5KGAq3y1U0OJ/qHla7ZU X-Google-Smtp-Source: APXvYqy6S+XDmb1wEPPfrOn7ZFRTZWp/P+FPusFjVuB6THg/pABZqBl4Fq8bx4WgOZMT/spUU2/0Kg== X-Received: by 2002:adf:ed86:: with SMTP id c6mr25384531wro.146.1553722710033; Wed, 27 Mar 2019 14:38:30 -0700 (PDT) Received: from ?IPv6:2003:ea:8bc4:dc00:ccf1:55bc:aa83:b190? (p200300EA8BC4DC00CCF155BCAA83B190.dip0.t-ipconnect.de. [2003:ea:8bc4:dc00:ccf1:55bc:aa83:b190]) by smtp.googlemail.com with ESMTPSA id 204sm1882203wmc.1.2019.03.27.14.38.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 27 Mar 2019 14:38:29 -0700 (PDT) Subject: Re: [PATCH net] net: dsa: mv88e6xxx: fix few issues in mv88e6390x_port_set_cmode To: Florian Fainelli , Vivien Didelot , Andrew Lunn , David Miller Cc: "netdev@vger.kernel.org" References: <95edb9b6-d779-a1b9-77cd-7e86cb41f73d@gmail.com> <44e84b46-4c05-6ff1-f7e2-24288f780294@gmail.com> From: Heiner Kallweit Message-ID: Date: Wed, 27 Mar 2019 22:38:24 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: <44e84b46-4c05-6ff1-f7e2-24288f780294@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On 27.03.2019 22:22, Florian Fainelli wrote: > On 3/23/19 11:41 AM, Heiner Kallweit wrote: >> This patches fixes few issues in mv88e6390x_port_set_cmode(). >> >> 1. When entering the function the old cmode may be 0, in this case >> mv88e6390x_serdes_get_lane() returns -ENODEV. As result we bail >> out and have no chance to set a new mode. Therefore deal properly >> with -ENODEV. >> >> 2. Once we have disabled power and irq, let's set the cached cmode to 0. >> This reflects the actual status and is cleaner if we bail out with an >> error in the following function calls. >> >> 3. The cached cmode is used by mv88e6390x_serdes_get_lane(), >> mv88e6390_serdes_power_lane() and mv88e6390_serdes_irq_enable(). >> Currently we set the cached mode to the new one at the very end of >> the function only, means until then we use the old one what may be >> wrong. >> >> 4. When calling mv88e6390_serdes_irq_enable() we use the lane value >> belonging to the old cmode. Get the lane belonging to the new cmode >> before calling this function. >> >> It's hard to provide a good "Fixes" tag because quite a few smaller >> changes have been done to the code in question recently. >> >> Fixes: d235c48b40d3 ("net: dsa: mv88e6xxx: power serdes on/off for 10G interfaces on 6390X") >> Signed-off-by: Heiner Kallweit >> --- >> drivers/net/dsa/mv88e6xxx/port.c | 24 ++++++++++++++++-------- >> 1 file changed, 16 insertions(+), 8 deletions(-) >> >> diff --git a/drivers/net/dsa/mv88e6xxx/port.c b/drivers/net/dsa/mv88e6xxx/port.c >> index dce84a2a6..c44b2822e 100644 >> --- a/drivers/net/dsa/mv88e6xxx/port.c >> +++ b/drivers/net/dsa/mv88e6xxx/port.c >> @@ -427,18 +427,22 @@ int mv88e6390x_port_set_cmode(struct mv88e6xxx_chip *chip, int port, >> return 0; >> >> lane = mv88e6390x_serdes_get_lane(chip, port); >> - if (lane < 0) >> + if (lane < 0 && lane != -ENODEV) >> return lane; > > It does not look like you can return a negative error code from > mv88e6390x_serdes_get_lane() that is not -ENODEV? > Thanks for reviewing, Florian. Right, at least for now mv88e6390x_serdes_get_lane() doesn't return any other errno. But that's not carved in stone, and if somebody comes and adds a check that returns -EINVAL to this function, then this person most likely won't update mv88e6390x_port_set_cmode(). > Other than that: > > Reviewed-by: Florian Fainelli >