Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp5627173pxb; Mon, 28 Mar 2022 15:09:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwTXh96AuLB2azH/KhWjeSp/rM1eb6wQAtaOmI0vNMMkJRAYydDBHEEfvgMnpLrwiHGbMFS X-Received: by 2002:aa7:86c6:0:b0:4fa:46d:6005 with SMTP id h6-20020aa786c6000000b004fa046d6005mr25477079pfo.86.1648505397803; Mon, 28 Mar 2022 15:09:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648505397; cv=none; d=google.com; s=arc-20160816; b=W6C+HhNa3peWovcbVdq54pJB++6nPWVCUmN+Ce1lJupnVmdDw/sD9QqsqZHFV9kQUc cc4PJuh1P0zUra1W9u9E/GtaGGNPMEmIEswnVx5+yv/6LgsKliY362U1vMyUUKrpih4z HyXDJVZ/zHYMJb5jyFZLteuNwOMIPloi/Rs8CFYrIDbeZcxArNIVaUb3R8jvWNFHtiY3 DkPcZXMPsuhGc6zRp0fUsZ6n8Mw3RMMf9vgUP+CGfojLdEppRkBEK/T9r5DlCFM7mACF qWIpfV6tl2HD2Zwd8sXx8G96OJmevCEL3/CLT2dopjgGvftG2Lx5KZj8qvZihUcEOdzg 5W+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from :dkim-signature; bh=Ytf29vkQGqk3VAiF+3NE6AlQuwIBgsFUm6vI7f8A9qs=; b=Zx3rHdFG2HWROvEwbj8fMS/QLlkNpDTnP1muUC4A6uvXQXmRfjhIhZPZGhMFI8yME4 g1g3MA+T7X5Nkjqak+z4BaRLVj1CKfijfmw2Q2rIBiNH2MCDH5aoTssVl0B3UTxd6MD7 BGFDrOWZoVtHztkm8xl+izj9trlpOFD4ZyVrYAOCO8BUW/PvhYDtnYigIdXFonxOuK+Y JFpOznzTWrZoJU+f9Q9LWTTS4oO38hqr59lOUFnW0FvLS9rSzfE1TEKa+xu0g1PQg0PU 7vz4uHXyw5SWzDAqKFhako2tIRRaaICmt3tNeG25gtsDheYn5B5eC3gBk21KKlUYZ4Ss ZqIg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=HLZIX6NV; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id s12-20020a170902ea0c00b00153b7db62ecsi16318688plg.179.2022.03.28.15.09.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Mar 2022 15:09:57 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=HLZIX6NV; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 1DFAE1637E4; Mon, 28 Mar 2022 14:30:49 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240071AbiC1KsW (ORCPT + 99 others); Mon, 28 Mar 2022 06:48:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60466 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240329AbiC1KsU (ORCPT ); Mon, 28 Mar 2022 06:48:20 -0400 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5F9864ECEA; Mon, 28 Mar 2022 03:46:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1648464400; x=1680000400; h=from:to:cc:subject:date:message-id; bh=y5Ta5faJZepUriOYafytGSAos/omF5AAyV8E9eFTQcg=; b=HLZIX6NVMzaZuTgby5J/L0fG1ahKa89r6wB7rH8qj+v7hvfV9waBn0A9 7Sz00m7G/ejw+1kx2wtYgLrM7A49Qu3rs3xXaWO925xOnsndRv1YlXo72 4rsMctEo+zVwW1eLdy7GKi++9kCR+yCFVe0sbVlBmWPlL2ALSfSNP3DPI mroTQSaxbJXvFPM42ROIOPAbikYYR3i5VUpDl0RDX005Up9Pe9QdhJDyj X4xQIPEtXkn7Ze4A0l54mB0uoEbvSZF5kO0Q/XD6HOwLBxj+/XSkuONvp +0PjpYOG/kRz0emu13w9ZsdJrWTZSp7BoHpP4jd+qjvXbr5tb/gN8n6Ju Q==; X-IronPort-AV: E=McAfee;i="6200,9189,10299"; a="258937800" X-IronPort-AV: E=Sophos;i="5.90,217,1643702400"; d="scan'208";a="258937800" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Mar 2022 03:46:39 -0700 X-IronPort-AV: E=Sophos;i="5.90,217,1643702400"; d="scan'208";a="545910074" Received: from unknown (HELO localhost.localdomain) ([10.223.165.89]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Mar 2022 03:46:37 -0700 From: tanveer1.alam@intel.com To: heikki.krogerus@linux.intel.com, gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org Cc: abhijeet.rao@intel.com, Tanveer Alam Subject: [PATCH] usb: typec: mux: intel_pmc_mux: Add retry logic to a PMC command Date: Mon, 28 Mar 2022 16:14:37 +0530 Message-Id: <20220328104437.5626-1-tanveer1.alam@intel.com> X-Mailer: git-send-email 2.17.1 X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 From: Tanveer Alam There are few scenerio when PMC reports 'busy condition' and command fail. If PMC receives a high priority command while servicing a low priority command then it discards the low priority command and start servicing the high priority command. The lower priority command fail and driver returns error. If the same command resend to the PMC then PMC latches the command and service it accordingly. Thus adds the retry logic for the PMC command. Signed-off-by: Tanveer Alam --- drivers/usb/typec/mux/intel_pmc_mux.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/drivers/usb/typec/mux/intel_pmc_mux.c b/drivers/usb/typec/mux/intel_pmc_mux.c index 2cdd22130834..da6b381ddf00 100644 --- a/drivers/usb/typec/mux/intel_pmc_mux.c +++ b/drivers/usb/typec/mux/intel_pmc_mux.c @@ -173,7 +173,7 @@ static int hsl_orientation(struct pmc_usb_port *port) return port->orientation - 1; } -static int pmc_usb_command(struct pmc_usb_port *port, u8 *msg, u32 len) +static int pmc_usb_send_command(struct intel_scu_ipc_dev *ipc, u8 *msg, u32 len) { u8 response[4]; u8 status_res; @@ -184,7 +184,7 @@ static int pmc_usb_command(struct pmc_usb_port *port, u8 *msg, u32 len) * Status can be checked from the response message if the * function intel_scu_ipc_dev_command succeeds. */ - ret = intel_scu_ipc_dev_command(port->pmc->ipc, PMC_USBC_CMD, 0, msg, + ret = intel_scu_ipc_dev_command(ipc, PMC_USBC_CMD, 0, msg, len, response, sizeof(response)); if (ret) @@ -203,6 +203,23 @@ static int pmc_usb_command(struct pmc_usb_port *port, u8 *msg, u32 len) return 0; } +static int pmc_usb_command(struct pmc_usb_port *port, u8 *msg, u32 len) +{ + int retry_count = 3; + int ret; + + /* + * If PMC is busy then retry the command once again + */ + while (retry_count--) { + ret = pmc_usb_send_command(port->pmc->ipc, msg, len); + if (ret != -EBUSY) + break; + } + + return ret; +} + static int pmc_usb_mux_dp_hpd(struct pmc_usb_port *port, struct typec_displayport_data *dp) { -- 2.17.1