From patchwork Sun Jan 7 00:16:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Christian A. Ehrhardt" X-Patchwork-Id: 185698 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:37c1:b0:101:2151:f287 with SMTP id y1csp333658dyq; Sat, 6 Jan 2024 16:18:43 -0800 (PST) X-Google-Smtp-Source: AGHT+IHVE870RDsy5vpFvaz7WmezziQJwxtfX4HkWwkquB2r1H1XL6pcXwG3soS1Apv8yHSRxgSV X-Received: by 2002:a05:6359:4590:b0:175:858c:a213 with SMTP id no16-20020a056359459000b00175858ca213mr1411769rwb.50.1704586723643; Sat, 06 Jan 2024 16:18:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704586723; cv=none; d=google.com; s=arc-20160816; b=xQnf8NrjDZmypA6x+RosZ4aCpn9zE4TpxHf+37w/juz4TiYzr6vJWJDdVubCCfKnfG PBD0yk1wTsQS9XmKNmOD6W4mBEPb3bWxGBoR4E0zVZ6w/YmoD2D5yuiovaZhGr9SDV7t 8io4XfYg7zW2wvKDQqBE/CL+tcZfm4YvSMXTijt9Y3oOvc02yE9Q3rSHwC34oFHbdTc4 wzVLvFOTYcn59q5QfPksBFIVnHevlAmy+atn4I5RCH6kBVGUjxQQPzrBKt3U4aigbwJ0 sLQvN/ViawVyRkNFmJB/Y9s8oSf/WoMlrDBuxuuPtymrV/nuwHf2mRJJq4Fcw6T6DPkg LC2g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=+cEEA7SXYfMEEfhWUAmy+Fu/GqUmV6QAerX8o+PQUMI=; fh=PBT+T+L/Wk7fQyAuF/ivTwxWqTQzcP6BniPDJctp9Xs=; b=LVnDKH81ZWSX0D6A9ClEDtV0F4Q+ibs5PzgXa1cGcZolXmG/zeWeLT9mte9GvW6JZG aefafykKUdJe/jFn0MjnByY9A9zFPfWs4IW2QwEV7MUwvZLgr3IQ/1XmKOUKy1629gfD s+6STMyIBIdWrPbv84Tusa1rsa+PnO+5eVuoRVpjPr5CBmun4fjq91VxDjeD33L5nIKt Zr1i2+Qr5DhuT9jUpR6a5/vtoXiVee5QKHQsMC7/e0Rk+DNWWGyTP3zqU0YZbqaFLg2F KPkPgllMF7vMOSSRPqiHE8QzHV7cYCV+hz/grRqBvgm1v2+0e4ahjsPGPismja1fLu2z qDQw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-18743-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-18743-ouuuleilei=gmail.com@vger.kernel.org" Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id t17-20020a170902e85100b001d40ca98b6esi3652709plg.8.2024.01.06.16.18.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 06 Jan 2024 16:18:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-18743-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-18743-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-18743-ouuuleilei=gmail.com@vger.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 sy.mirrors.kernel.org (Postfix) with ESMTPS id F3715B21F3F for ; Sun, 7 Jan 2024 00:18:36 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BA9DF567D; Sun, 7 Jan 2024 00:17:54 +0000 (UTC) X-Original-To: linux-kernel@vger.kernel.org Received: from cae.in-ulm.de (cae.in-ulm.de [217.10.14.231]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0B96623B5; Sun, 7 Jan 2024 00:17:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=c--e.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=c--e.de Received: by cae.in-ulm.de (Postfix, from userid 1000) id B726414033C; Sun, 7 Jan 2024 01:17:48 +0100 (CET) From: "Christian A. Ehrhardt" To: Heikki Krogerus , linux-usb@vger.kernel.org Cc: "Christian A. Ehrhardt" , Dell.Client.Kernel@dell.com, Greg Kroah-Hartman , Neil Armstrong , Hans de Goede , Jack Pham , Fabrice Gasnier , =?utf-8?q?Samuel_=C4=8Cavoj?= , linux-kernel@vger.kernel.org Subject: [PATCH 1/4] usb: ucsi: Add missing ppm_lock Date: Sun, 7 Jan 2024 01:16:58 +0100 Message-Id: <20240107001701.130535-2-lk@c--e.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20240107001701.130535-1-lk@c--e.de> References: <20240107001701.130535-1-lk@c--e.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1787388728209389072 X-GMAIL-MSGID: 1787388728209389072 Calling ->sync_write must be done while holding the PPM lock as the mailbox logic does not support concurrent commands. Add a missing lock around the only call to ucsi_acknowledge_connector_change. Additionally, warn in ucsi_acpi.c if a command is started while the COMMAND_PENDING bit is already set. Signed-off-by: Christian A. Ehrhardt --- drivers/usb/typec/ucsi/ucsi.c | 2 ++ drivers/usb/typec/ucsi/ucsi_acpi.c | 2 ++ 2 files changed, 4 insertions(+) diff --git a/drivers/usb/typec/ucsi/ucsi.c b/drivers/usb/typec/ucsi/ucsi.c index 61b64558f96c..8f9dff993b3d 100644 --- a/drivers/usb/typec/ucsi/ucsi.c +++ b/drivers/usb/typec/ucsi/ucsi.c @@ -935,7 +935,9 @@ static void ucsi_handle_connector_change(struct work_struct *work) clear_bit(EVENT_PENDING, &con->ucsi->flags); + mutex_lock(&ucsi->ppm_lock); ret = ucsi_acknowledge_connector_change(ucsi); + mutex_unlock(&ucsi->ppm_lock); if (ret) dev_err(ucsi->dev, "%s: ACK failed (%d)", __func__, ret); diff --git a/drivers/usb/typec/ucsi/ucsi_acpi.c b/drivers/usb/typec/ucsi/ucsi_acpi.c index 6bbf490ac401..8062d0a4b523 100644 --- a/drivers/usb/typec/ucsi/ucsi_acpi.c +++ b/drivers/usb/typec/ucsi/ucsi_acpi.c @@ -75,6 +75,8 @@ static int ucsi_acpi_sync_write(struct ucsi *ucsi, unsigned int offset, struct ucsi_acpi *ua = ucsi_get_drvdata(ucsi); int ret; + WARN_ON(test_bit(COMMAND_PENDING, &ua->flags)); + set_bit(COMMAND_PENDING, &ua->flags); ret = ucsi_acpi_async_write(ucsi, offset, val, val_len); From patchwork Sun Jan 7 00:16:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Christian A. Ehrhardt" X-Patchwork-Id: 185701 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:37c1:b0:101:2151:f287 with SMTP id y1csp335375dyq; Sat, 6 Jan 2024 16:26:24 -0800 (PST) X-Google-Smtp-Source: AGHT+IEpXmECTZ28+ekGkTk4Wwz4qQHKOEIrKBgOBXoSCjGMHwsdu/e7uqXZo7vpIZoiQjlvc+VD X-Received: by 2002:a05:6402:1ada:b0:557:1aa5:3b89 with SMTP id ba26-20020a0564021ada00b005571aa53b89mr900811edb.48.1704587184432; Sat, 06 Jan 2024 16:26:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704587184; cv=none; d=google.com; s=arc-20160816; b=rYthJwEPuHXjIdYnWsCQq7NYEszbsFQHXgt12Bj18RggHq1MlKe/NkyQyCg53GVpGO 8kzTx5WRpORs2JPAlZz86eHkTWCkJSS2TLVL4E4a6skKOTtzGkjpXzkGSxzu3TyEQayv lBUI+a7USWD/IPVDqJCQCZYN534EPbZOiB+e46pG6Sy3buk9YE6UEiHURBDteY03SuAD 4yrrRatmPSWI24Pcfyb5IXJqt1nGvChSMukJ0U+H5CL+CavLIk3CEXOFbNSbaBr5BIdC UB1M0zyCeC13eZxC1ghdu3Qfevj3JhSEzmh5aoYDuCAiq6iwi0+EhKBiJVyhYmsR/4sj 7xGw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=Z3UoC9RP2K1SjNROulm2tbB2VjJNU4LKSyuRFz3/Ny0=; fh=PBT+T+L/Wk7fQyAuF/ivTwxWqTQzcP6BniPDJctp9Xs=; b=aMKN0TQF9dAkoZ7Yi6ieRKroGcpZpWlM3NYX/VzfxC74dkVsOuAtEYBWKfumzURyMJ YcPvtqxWx9jVI3RAD8QMftSeurmFV01F1UiNt9/e64EbK6Yf/kokYuU27BEEq3qSTQiB zktcTXLN1EfbOME16Y0+p4JQj62ZdjM4nIF9jdrD/Pceh5gq/Y0bRBWt1VjyePLtsdEY CgK1ghMJyHB/9ZDf4dCmaRFlWQYoQ4OEVyz9VdRc490gssthYijnGvvhFl1SDJvSVxfz lMiFhgE4xXGfityAFnerjU/UsxCZg0S48tjhzZCBIn6lA913blYqWNAwRWcQP35HOUNU 9u7w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-18744-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-18744-ouuuleilei=gmail.com@vger.kernel.org" Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id g17-20020a0564021ed100b0055703da55aasi1857574edg.225.2024.01.06.16.26.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 06 Jan 2024 16:26:24 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-18744-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-18744-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-18744-ouuuleilei=gmail.com@vger.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 am.mirrors.kernel.org (Postfix) with ESMTPS id 054D81F22FE7 for ; Sun, 7 Jan 2024 00:18:47 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4B8F07EC; Sun, 7 Jan 2024 00:17:55 +0000 (UTC) X-Original-To: linux-kernel@vger.kernel.org Received: from cae.in-ulm.de (cae.in-ulm.de [217.10.14.231]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6875423B4; Sun, 7 Jan 2024 00:17:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=c--e.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=c--e.de Received: by cae.in-ulm.de (Postfix, from userid 1000) id 2388F140346; Sun, 7 Jan 2024 01:17:50 +0100 (CET) From: "Christian A. Ehrhardt" To: Heikki Krogerus , linux-usb@vger.kernel.org Cc: "Christian A. Ehrhardt" , Dell.Client.Kernel@dell.com, Greg Kroah-Hartman , Neil Armstrong , Hans de Goede , Jack Pham , Fabrice Gasnier , =?utf-8?q?Samuel_=C4=8Cavoj?= , linux-kernel@vger.kernel.org Subject: [PATCH 2/4] usb: ucsi: Add quirk infrastructure Date: Sun, 7 Jan 2024 01:16:59 +0100 Message-Id: <20240107001701.130535-3-lk@c--e.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20240107001701.130535-1-lk@c--e.de> References: <20240107001701.130535-1-lk@c--e.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1787389211532368431 X-GMAIL-MSGID: 1787389211532368431 Allow bus drivers to specify quirks for the UCSI core on attach. Allow the user to override the quirks on the command line. Signed-off-by: Christian A. Ehrhardt --- Documentation/admin-guide/kernel-parameters.txt | 5 +++++ drivers/usb/typec/ucsi/ucsi.c | 12 +++++++++++- drivers/usb/typec/ucsi/ucsi.h | 6 +++++- drivers/usb/typec/ucsi/ucsi_acpi.c | 2 +- drivers/usb/typec/ucsi/ucsi_ccg.c | 2 +- drivers/usb/typec/ucsi/ucsi_glink.c | 2 +- drivers/usb/typec/ucsi/ucsi_stm32g0.c | 2 +- 7 files changed, 25 insertions(+), 6 deletions(-) diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt index 0a6a4b7f7a3b..fd8152dd4450 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt @@ -6783,6 +6783,11 @@ ,,,,,,, See also Documentation/input/devices/joystick-parport.rst + typec_ucsi.quirks= [USB] + A hex value specifying the quirks to enable for + the USB Type-C connector system software interface + driver. This overrides auto detected quirks. + udbg-immortal [PPC] When debugging early kernel crashes that happen after console_init() and before a proper console driver takes over, this boot options might diff --git a/drivers/usb/typec/ucsi/ucsi.c b/drivers/usb/typec/ucsi/ucsi.c index 8f9dff993b3d..00b23292f46f 100644 --- a/drivers/usb/typec/ucsi/ucsi.c +++ b/drivers/usb/typec/ucsi/ucsi.c @@ -36,6 +36,11 @@ */ #define UCSI_SWAP_TIMEOUT_MS 5000 +/* Override for auto detected quirks. */ +static unsigned int quirk_override = ~0U; +module_param_named(quirks, quirk_override, uint, S_IRUGO); +MODULE_PARM_DESC(quirks, "Override quirks for UCSI"); + static int ucsi_acknowledge_command(struct ucsi *ucsi) { u64 ctrl; @@ -1507,7 +1512,8 @@ EXPORT_SYMBOL_GPL(ucsi_set_drvdata); * @dev: Device interface to the PPM (Platform Policy Manager) * @ops: I/O routines */ -struct ucsi *ucsi_create(struct device *dev, const struct ucsi_operations *ops) +struct ucsi *ucsi_create(struct device *dev, const struct ucsi_operations *ops, + unsigned int quirks) { struct ucsi *ucsi; @@ -1523,6 +1529,10 @@ struct ucsi *ucsi_create(struct device *dev, const struct ucsi_operations *ops) mutex_init(&ucsi->ppm_lock); ucsi->dev = dev; ucsi->ops = ops; + if (quirk_override != ~0U) + ucsi->quirks = quirk_override; + else + ucsi->quirks = quirks; return ucsi; } diff --git a/drivers/usb/typec/ucsi/ucsi.h b/drivers/usb/typec/ucsi/ucsi.h index 474315a72c77..5e6d2225c9c8 100644 --- a/drivers/usb/typec/ucsi/ucsi.h +++ b/drivers/usb/typec/ucsi/ucsi.h @@ -57,7 +57,8 @@ struct ucsi_operations { struct ucsi_altmode *updated); }; -struct ucsi *ucsi_create(struct device *dev, const struct ucsi_operations *ops); +struct ucsi *ucsi_create(struct device *dev, const struct ucsi_operations *ops, + unsigned int quirks); void ucsi_destroy(struct ucsi *ucsi); int ucsi_register(struct ucsi *ucsi); void ucsi_unregister(struct ucsi *ucsi); @@ -317,6 +318,9 @@ struct ucsi { #define EVENT_PENDING 0 #define COMMAND_PENDING 1 #define ACK_PENDING 2 + + /* Enabled quirks. */ + unsigned int quirks; }; #define UCSI_MAX_SVID 5 diff --git a/drivers/usb/typec/ucsi/ucsi_acpi.c b/drivers/usb/typec/ucsi/ucsi_acpi.c index 8062d0a4b523..78a0d13584ad 100644 --- a/drivers/usb/typec/ucsi/ucsi_acpi.c +++ b/drivers/usb/typec/ucsi/ucsi_acpi.c @@ -185,7 +185,7 @@ static int ucsi_acpi_probe(struct platform_device *pdev) if (dmi_check_system(zenbook_dmi_id)) ops = &ucsi_zenbook_ops; - ua->ucsi = ucsi_create(&pdev->dev, ops); + ua->ucsi = ucsi_create(&pdev->dev, ops, 0); if (IS_ERR(ua->ucsi)) return PTR_ERR(ua->ucsi); diff --git a/drivers/usb/typec/ucsi/ucsi_ccg.c b/drivers/usb/typec/ucsi/ucsi_ccg.c index 449c125f6f87..d491b6547fc3 100644 --- a/drivers/usb/typec/ucsi/ucsi_ccg.c +++ b/drivers/usb/typec/ucsi/ucsi_ccg.c @@ -1387,7 +1387,7 @@ static int ucsi_ccg_probe(struct i2c_client *client) if (uc->info.mode & CCG_DEVINFO_PDPORTS_MASK) uc->port_num++; - uc->ucsi = ucsi_create(dev, &ucsi_ccg_ops); + uc->ucsi = ucsi_create(dev, &ucsi_ccg_ops, 0); if (IS_ERR(uc->ucsi)) return PTR_ERR(uc->ucsi); diff --git a/drivers/usb/typec/ucsi/ucsi_glink.c b/drivers/usb/typec/ucsi/ucsi_glink.c index db6e248f8208..49587960b6a3 100644 --- a/drivers/usb/typec/ucsi/ucsi_glink.c +++ b/drivers/usb/typec/ucsi/ucsi_glink.c @@ -318,7 +318,7 @@ static int pmic_glink_ucsi_probe(struct auxiliary_device *adev, init_completion(&ucsi->sync_ack); mutex_init(&ucsi->lock); - ucsi->ucsi = ucsi_create(dev, &pmic_glink_ucsi_ops); + ucsi->ucsi = ucsi_create(dev, &pmic_glink_ucsi_ops, 0); if (IS_ERR(ucsi->ucsi)) return PTR_ERR(ucsi->ucsi); diff --git a/drivers/usb/typec/ucsi/ucsi_stm32g0.c b/drivers/usb/typec/ucsi/ucsi_stm32g0.c index 93d7806681cf..269caa3b4e84 100644 --- a/drivers/usb/typec/ucsi/ucsi_stm32g0.c +++ b/drivers/usb/typec/ucsi/ucsi_stm32g0.c @@ -641,7 +641,7 @@ static int ucsi_stm32g0_probe(struct i2c_client *client) init_completion(&g0->complete); i2c_set_clientdata(client, g0); - g0->ucsi = ucsi_create(dev, &ucsi_stm32g0_ops); + g0->ucsi = ucsi_create(dev, &ucsi_stm32g0_ops, 0); if (IS_ERR(g0->ucsi)) return PTR_ERR(g0->ucsi); From patchwork Sun Jan 7 00:17:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Christian A. Ehrhardt" X-Patchwork-Id: 185699 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:37c1:b0:101:2151:f287 with SMTP id y1csp333736dyq; Sat, 6 Jan 2024 16:19:01 -0800 (PST) X-Google-Smtp-Source: AGHT+IEYJ/b6+mPQY4atF7WaiINf7xLg1AduCcYn9L6ZabrwO8UOqbxTIxR5qkEIcLrQB4xUWWV2 X-Received: by 2002:a17:903:2305:b0:1d4:42f:d39b with SMTP id d5-20020a170903230500b001d4042fd39bmr2212859plh.3.1704586740664; Sat, 06 Jan 2024 16:19:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704586740; cv=none; d=google.com; s=arc-20160816; b=tV/ySdF2aL2UwP9Lqi8HWhLFq4wWPiB5Z0XspT880BGfBDWlXdWqxHR02d9sSRY94k 2ajL3hvplYsjrRRpy3kkyyF87dEKdqZhALmhvm+oRLVTcczOXGL0g5QsyaXZhIrAxe6+ b+tFJxeVaataRtO3FuTebKFy46qEjV++ZSpjfb8QRj3ZksJoeoYSAHHtCwgaeymiDaSg TWeOQGzMXsyD+sPbP3SmbVjakMxWPr78GwhbB8dwkij4yFmhm5EPVEF99WJTjVgkRdWM yBQ1XH5Jxz2KcjHIWPz2H59a+9v+VVr+lyH8dTsN7LHK5dNrdtEmXYPeQ/3bu8c1FZDs Na1g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=u/twq7oEWzvQ/7mfPMJVHHnr+GLtOTTKaAsZVrSqFds=; fh=PBT+T+L/Wk7fQyAuF/ivTwxWqTQzcP6BniPDJctp9Xs=; b=oCG7d2pR+pZswbyjQkBiXFa12sl5wZffl+q9II6qLxRABHTTaVljzIGtfectvcegvj F70+OvWww3YFkETPLAxzAlL7WE5675X1qEPVsQ40vyEja0UUNkIlWLU5DLz1rU926pCZ RjdZgZmr6PhMZsHJMrTtCeru5a7MS75sCc6jJSIKOr11H0vo8IBypDr87iP7kK1W01qz N3o5ADDn9X4DkwKAkwckS8IOTcYSo8FqvV5XYYNFFKPFIc9ZA+ZwUsCvjoNuy3QGuvPf QeTF+4mPnYBiijvgQugWLxl8uKGcsJ4n9HrmJtaEvhCfi6ZKKmvcYQwA0oSZAu0dD+f5 UqzQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-18745-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-18745-ouuuleilei=gmail.com@vger.kernel.org" Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id v20-20020a17090a899400b0028c99453374si3311861pjn.176.2024.01.06.16.19.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 06 Jan 2024 16:19:00 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-18745-ouuuleilei=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; spf=pass (google.com: domain of linux-kernel+bounces-18745-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-18745-ouuuleilei=gmail.com@vger.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 724E3282DAB for ; Sun, 7 Jan 2024 00:19:00 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 85BDB748C; Sun, 7 Jan 2024 00:17:56 +0000 (UTC) X-Original-To: linux-kernel@vger.kernel.org Received: from cae.in-ulm.de (cae.in-ulm.de [217.10.14.231]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B588323DD; Sun, 7 Jan 2024 00:17:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=c--e.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=c--e.de Received: by cae.in-ulm.de (Postfix, from userid 1000) id 2D28014042E; Sun, 7 Jan 2024 01:17:51 +0100 (CET) From: "Christian A. Ehrhardt" To: Heikki Krogerus , linux-usb@vger.kernel.org Cc: "Christian A. Ehrhardt" , Dell.Client.Kernel@dell.com, Greg Kroah-Hartman , Neil Armstrong , Hans de Goede , Jack Pham , Fabrice Gasnier , =?utf-8?q?Samuel_=C4=8Cavoj?= , linux-kernel@vger.kernel.org Subject: [PATCH 3/4] usb: ucsi: Quirk to ack a connector change ack cmd Date: Sun, 7 Jan 2024 01:17:00 +0100 Message-Id: <20240107001701.130535-4-lk@c--e.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20240107001701.130535-1-lk@c--e.de> References: <20240107001701.130535-1-lk@c--e.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1787388746153047535 X-GMAIL-MSGID: 1787388746153047535 The PPM on some Dell laptops seems to expect that the ACK_CC_CI command to clear the connector change notification is in turn followed by another ACK_CC_CI to acknowledge the ACK_CC_CI command itself. This is in violation of the UCSI spec that states: "The only notification that is not acknowledged by the OPM is the command completion notification for the ACK_CC_CI or the PPM_RESET command." Add a quirk to send this ack anyway. Signed-off-by: Christian A. Ehrhardt --- drivers/usb/typec/ucsi/ucsi.c | 7 ++++++- drivers/usb/typec/ucsi/ucsi.h | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/usb/typec/ucsi/ucsi.c b/drivers/usb/typec/ucsi/ucsi.c index 00b23292f46f..8718836b6aba 100644 --- a/drivers/usb/typec/ucsi/ucsi.c +++ b/drivers/usb/typec/ucsi/ucsi.c @@ -54,11 +54,16 @@ static int ucsi_acknowledge_command(struct ucsi *ucsi) static int ucsi_acknowledge_connector_change(struct ucsi *ucsi) { u64 ctrl; + int ret; ctrl = UCSI_ACK_CC_CI; ctrl |= UCSI_ACK_CONNECTOR_CHANGE; - return ucsi->ops->sync_write(ucsi, UCSI_CONTROL, &ctrl, sizeof(ctrl)); + ret = ucsi->ops->sync_write(ucsi, UCSI_CONTROL, &ctrl, sizeof(ctrl)); + if (ret == 0 && ucsi->quirks & UCSI_ACK_CONNECTOR_CHANGE_ACK_CMD) + ret = ucsi_acknowledge_command(ucsi); + + return ret; } static int ucsi_exec_command(struct ucsi *ucsi, u64 command); diff --git a/drivers/usb/typec/ucsi/ucsi.h b/drivers/usb/typec/ucsi/ucsi.h index 5e6d2225c9c8..9ea2143776cf 100644 --- a/drivers/usb/typec/ucsi/ucsi.h +++ b/drivers/usb/typec/ucsi/ucsi.h @@ -321,6 +321,7 @@ struct ucsi { /* Enabled quirks. */ unsigned int quirks; +#define UCSI_ACK_CONNECTOR_CHANGE_ACK_CMD BIT(0) }; #define UCSI_MAX_SVID 5 From patchwork Sun Jan 7 00:17:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Christian A. Ehrhardt" X-Patchwork-Id: 185700 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:37c1:b0:101:2151:f287 with SMTP id y1csp333805dyq; Sat, 6 Jan 2024 16:19:18 -0800 (PST) X-Google-Smtp-Source: AGHT+IELWx0SurAZ/0GfgZ9ECUqAegLAXA8il2ZWISvRrDCORW/xFn+EDtekWx2p622jujLEwR/v X-Received: by 2002:a17:903:1210:b0:1cf:c9c3:e79d with SMTP id l16-20020a170903121000b001cfc9c3e79dmr607990plh.59.1704586758316; Sat, 06 Jan 2024 16:19:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704586758; cv=none; d=google.com; s=arc-20160816; b=aloi4uTfEA2rQQi2qR2yy96Z8wmgJPYJdQQxk5Oo+Qs9IPXD5kgcnyV+LWGOY4l+su nQKxmWuSPrVVmZLGzlTeIsiFJ7rj6iDj8lvkxXpIu3sAPiJuW/1hLjcKT3uw9zA7jAcu jHqIlZxd6pc1YlWtfNoT/vBGUGDfuAGCQRV5WfjekXe94Nwrfs941GK63dAdqTTCW27r TmOtvo6V+OgHVMvG2fX8ngLGfwfs/7nXxvU/UEKRrk5AWU+dOhsw6UfPKA0Qsdlh6sqj Up01vjo3VaRRY3KpgimTfecjQykV9KrXLilYqrx7RYw7P7aSYq9y5Wmf13LkjVsJ+0kX rfMQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=HPNivEu9K9n9OQCBvXZdRYlj8dyw2R9Xk3RGkbxdXKo=; fh=PBT+T+L/Wk7fQyAuF/ivTwxWqTQzcP6BniPDJctp9Xs=; b=cp+YXKXJxzge8+S87mTY4l/3QO15bSlwY9m1hX5rFhkJdtEEbzYkUu12HyriC8s/TV AzeoOM/sA00FLvxig+YpG6z7K48rzH+ot/YJm8DqTlnE18eryuWM7dRoMYNFUSSB9ceD QxSTp7jHKPidqGx8sYG5Yq5gLWWfSFGhl65oRVIe4jj80tSJ6cTQRoEAd6xbKiHAyNc3 vOgON1TXbyQ5p0CQmNVVNGngnN05rDE9MGx3Jfgk/bW5IY5yQFGKI+/jX/L0jalfRyzf 1z0yO80/Fp0RTtu5ypiYxeifk/hqlvqfYOrPpSloJhcxXw/hgSu8+QCX7STPjzT61uiR Vnjw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-18746-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-18746-ouuuleilei=gmail.com@vger.kernel.org" Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id d4-20020a170902854400b001d483d5a0a9si3630208plo.153.2024.01.06.16.19.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 06 Jan 2024 16:19:18 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-18746-ouuuleilei=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; spf=pass (google.com: domain of linux-kernel+bounces-18746-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-18746-ouuuleilei=gmail.com@vger.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 1CC06282DAB for ; Sun, 7 Jan 2024 00:19:18 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6700FBE64; Sun, 7 Jan 2024 00:17:58 +0000 (UTC) X-Original-To: linux-kernel@vger.kernel.org Received: from cae.in-ulm.de (cae.in-ulm.de [217.10.14.231]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 42EE346A9; Sun, 7 Jan 2024 00:17:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=c--e.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=c--e.de Received: by cae.in-ulm.de (Postfix, from userid 1000) id 32AEA14056A; Sun, 7 Jan 2024 01:17:53 +0100 (CET) From: "Christian A. Ehrhardt" To: Heikki Krogerus , linux-usb@vger.kernel.org Cc: "Christian A. Ehrhardt" , Dell.Client.Kernel@dell.com, Greg Kroah-Hartman , Neil Armstrong , Hans de Goede , Jack Pham , Fabrice Gasnier , =?utf-8?q?Samuel_=C4=8Cavoj?= , linux-kernel@vger.kernel.org Subject: [PATCH 4/4] usb: ucsi: Apply UCSI_ACK_CONNECTOR_CHANGE_ACK_CMD to Dell systems Date: Sun, 7 Jan 2024 01:17:01 +0100 Message-Id: <20240107001701.130535-5-lk@c--e.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20240107001701.130535-1-lk@c--e.de> References: <20240107001701.130535-1-lk@c--e.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1787388764539232538 X-GMAIL-MSGID: 1787388764539232538 Apply the UCSI_ACK_CONNECTOR_CHANGE_ACK_CMD to all Dell systems. There are various reports that ucsi does not work on Dell systems with "GET_CONNECTOR_STATUS failed". At least some of these are most likely due to the need for this quirk. If the logic is wrong users can still use the new quirk override for the typec_ucsi module to disable the quirk. Signed-off-by: Christian A. Ehrhardt --- drivers/usb/typec/ucsi/ucsi_acpi.c | 36 +++++++++++++++++++++++++----- 1 file changed, 31 insertions(+), 5 deletions(-) diff --git a/drivers/usb/typec/ucsi/ucsi_acpi.c b/drivers/usb/typec/ucsi/ucsi_acpi.c index 78a0d13584ad..690d5e55bdc4 100644 --- a/drivers/usb/typec/ucsi/ucsi_acpi.c +++ b/drivers/usb/typec/ucsi/ucsi_acpi.c @@ -27,6 +27,11 @@ struct ucsi_acpi { u64 cmd; }; +struct ucsi_acpi_attach_data { + const struct ucsi_operations *ops; + unsigned int quirks; +}; + static int ucsi_acpi_dsm(struct ucsi_acpi *ua, int func) { union acpi_object *obj; @@ -121,12 +126,30 @@ static const struct ucsi_operations ucsi_zenbook_ops = { .async_write = ucsi_acpi_async_write }; -static const struct dmi_system_id zenbook_dmi_id[] = { +static const struct ucsi_acpi_attach_data ucsi_acpi_default_attach_data = { + .ops = &ucsi_acpi_ops, + .quirks = 0 +}; + +static const struct dmi_system_id ucsi_acpi_quirks[] = { { .matches = { DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."), DMI_MATCH(DMI_PRODUCT_NAME, "ZenBook UX325UA_UM325UA"), }, + .driver_data = &(struct ucsi_acpi_attach_data) { + .ops = &ucsi_zenbook_ops, + .quirks = 0 + }, + }, + { + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), + }, + .driver_data = &(struct ucsi_acpi_attach_data) { + .ops = &ucsi_acpi_ops, + .quirks = UCSI_ACK_CONNECTOR_CHANGE_ACK_CMD + }, }, { } }; @@ -152,7 +175,8 @@ static void ucsi_acpi_notify(acpi_handle handle, u32 event, void *data) static int ucsi_acpi_probe(struct platform_device *pdev) { struct acpi_device *adev = ACPI_COMPANION(&pdev->dev); - const struct ucsi_operations *ops = &ucsi_acpi_ops; + const struct dmi_system_id *id; + const struct ucsi_acpi_attach_data *attach; struct ucsi_acpi *ua; struct resource *res; acpi_status status; @@ -182,10 +206,12 @@ static int ucsi_acpi_probe(struct platform_device *pdev) init_completion(&ua->complete); ua->dev = &pdev->dev; - if (dmi_check_system(zenbook_dmi_id)) - ops = &ucsi_zenbook_ops; + attach = &ucsi_acpi_default_attach_data; + id = dmi_first_match(ucsi_acpi_quirks); + if (id) + attach = id->driver_data; - ua->ucsi = ucsi_create(&pdev->dev, ops, 0); + ua->ucsi = ucsi_create(&pdev->dev, attach->ops, attach->quirks); if (IS_ERR(ua->ucsi)) return PTR_ERR(ua->ucsi);