Received: by 2002:a89:413:0:b0:1fd:dba5:e537 with SMTP id m19csp162541lqs; Thu, 13 Jun 2024 06:58:27 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUA80n9EtOHZVpHmU9MJp03MwBNVuCplgS4dc54q02YwmAf9jBlXwaeI9elLEaTdjFhh/NW8Vv/vBceAhtvWdTz2U47ruoUiFg3UMM1XA== X-Google-Smtp-Source: AGHT+IHZjcvOHa3G2hdRhs2IuB25Fgo9dSBRcRZiadyanrZhnOcdIqiIBaEWPUS1N4lxM2lfv/+u X-Received: by 2002:a05:620a:43a9:b0:796:a28d:e821 with SMTP id af79cd13be357-797f611fdb2mr469522485a.75.1718287107156; Thu, 13 Jun 2024 06:58:27 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718287107; cv=pass; d=google.com; s=arc-20160816; b=DoNgZiDOS1bvNJiMDDReDeOK9CqeMwRgWz37QVRaGcwR4ek+512BssVKRIYGvXcz1N /MVGz/Ad+qGDBM7MtfPmDgYVy+ks3oaD38cyFpReWYYPgkm3pICJB9xUk4PhIph8le2i yiSw7CZFt6gdEcNH4JxGOqRwe2KVRpL26vlDIb8XyE2RM6OZ+1uAstBrvbSrW/nqkolW 764/GMDSOi8RNXYWZ9NI+o6qKI9dKMSbcUykN8pUTl+dhj/yJW8x1Z2ntIgrcJF8Tgg0 PyyRhK36lU64oWoMVBh9GnMsa8anv9WYkzVeH+CQkd1XI+h29NX6FX6UJXn7q+GyYQ5i s5NQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=nqSvFFIr3ik/VFsK+PMs57XSdXINXBWaO4gEaSHXQ5Y=; fh=VPgpxCaKiJjXMWilsjx4Byi35eNyIPhXdFRePKxzC3U=; b=SuHBiiccYak32UDCmMGfLZRNHbGRB4fTWuxpxqEDd0OzcUrYVwQ+2O9K+wZvGxwR6Y avOSjpup6TVJya+NbVelGIenKKnRBB0LqoZrOfXTeNO/01qT/RrnL+A4SJ37TH5AX2bp fx7+1/TPtjugiQAPoD42/TVtyyVGuAI1rwUdfCMCpK5lXpYdI+flvig3zsTDN9GX1McK iWzhUZsxKNxvv31KbMCGHLm/+bjbHtRWu/fia1iqv5y1stGm3nhhsbZrv4AtxnQptds5 WDaNuJvBgKkJTecA0j+r1IswV8q3r6uasPi1hnX9kILAmVvF9TfFACOiH8HBz0Wb+Hug +4jw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="lK/pp4Fw"; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-213060-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-213060-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id af79cd13be357-798abd1d326si142321485a.428.2024.06.13.06.58.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Jun 2024 06:58:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-213060-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="lK/pp4Fw"; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-213060-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-213060-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com 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 96E3D1C22A7F for ; Thu, 13 Jun 2024 10:53:26 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D81301428F5; Thu, 13 Jun 2024 10:53:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="lK/pp4Fw" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.17]) (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 EDBF013D534; Thu, 13 Jun 2024 10:53:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.17 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718275996; cv=none; b=KZ3bLhInkcfuzzXFf57N7hltYsv4dSAnmnDuzG4DUS3jkqRcdsnPJVv+iBr1P6nwXVliwvYyPZlyBNsHIn8LOjigQpJ8hrJd3903/9zUUVit571lc1911GB8ZDwmYsdiOIcfBMCBGinHrQbV5ey7Srnrv7e+9vY5gEkMCQb5ehE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718275996; c=relaxed/simple; bh=NURTeOxOgiogS3ms0vWEjmPgApMszd6tWnaLFNteF5g=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=FsDYPX7VoTYUwd32RiuF22nwMecQhxX33MwtA0rxA/k4OttOc9tb46xK4hhmejMlaeEW8HzTnTRmjgD/cm6Bi/2mSaaAsqLcNyrrt+Zv6iy6FuhtS4dZ6NfK0tFhWtbe9L/6D98MlLkCjwarr3I8RSItTT/z/Vw0/BhNowdg/4M= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=lK/pp4Fw; arc=none smtp.client-ip=198.175.65.17 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1718275994; x=1749811994; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=NURTeOxOgiogS3ms0vWEjmPgApMszd6tWnaLFNteF5g=; b=lK/pp4FwKooB+7B9HjV2HafKxwTj+8EjaJ6j1HnMDLA0Qdn8wNtz78EM 5ZEkePTSrY+uTNMVgzy2j4MjVPuptxxv7XEKhVfWNDaPmBBhMpmIE1C5O fXhL9I9NJaytwE0kZ32NcY4eVw8e8sl1U6+w1z1yXDkxQKDiIYetppYsJ MWvPpruDqGFuGOSz36WYIJqJbI6PFFFrK/ojMf8mb9OcQvaX/GOYOMm2k e0ldJ393ERCk5l9wvX3KsVcIc67dbr1RZOIuh0DlprIocQE57Hz62AdyJ 7oXP3QZED13WCgvJtDfzN4beaJwHgfKkQDoRouUUEHNnkELtPe+MkfIYi g==; X-CSE-ConnectionGUID: iF9oWI/4Rsew8+kMMgBjPg== X-CSE-MsgGUID: xfyABvLkRQu1csOQ+XfaOA== X-IronPort-AV: E=McAfee;i="6700,10204,11101"; a="15214139" X-IronPort-AV: E=Sophos;i="6.08,234,1712646000"; d="scan'208";a="15214139" Received: from fmviesa001.fm.intel.com ([10.60.135.141]) by orvoesa109.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Jun 2024 03:53:14 -0700 X-CSE-ConnectionGUID: jG4G3uKzTPG3cO0HGCT8oQ== X-CSE-MsgGUID: A1Gjxz5gQOmKVwDUw6GKUQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,234,1712646000"; d="scan'208";a="71315684" Received: from kuha.fi.intel.com ([10.237.72.185]) by fmviesa001.fm.intel.com with SMTP; 13 Jun 2024 03:53:11 -0700 Received: by kuha.fi.intel.com (sSMTP sendmail emulation); Thu, 13 Jun 2024 13:53:10 +0300 Date: Thu, 13 Jun 2024 13:53:10 +0300 From: Heikki Krogerus To: Diogo Ivo Cc: Greg Kroah-Hartman , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] usb: typec: ucsi_acpi: Add LG Gram quirk Message-ID: References: <20240612-gram_quirk-v1-1-52b0ff0e1546@tecnico.ulisboa.pt> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240612-gram_quirk-v1-1-52b0ff0e1546@tecnico.ulisboa.pt> On Wed, Jun 12, 2024 at 02:13:10PM +0100, Diogo Ivo wrote: > Some LG Gram laptops report a bogus connector change event after a > GET_PDOS command for the partner's source PDOs, which disappears from > the CCI after acknowledging the command. However, the subsequent > GET_CONNECTOR_STATUS in ucsi_handle_connector_change() still reports > this bogus change in bits 5 and 6, leading to the UCSI core re-checking > the partner's source PDOs and thus to an infinite loop. > > Fix this by adding a quirk that signals when a potentially buggy GET_PDOS > command is used, checks the status change report and clears it if it is a > bogus event before sending it to the UCSI core. > > Signed-off-by: Diogo Ivo Reviewed-by: Heikki Krogerus > --- > The models affected by this bug have been reported to be of several forms: > 1xZ90Q, 1xZD90Q, 1xZB90Q, x = {5, 6, 7}, and as such this patch matches > only on the final 90Q as well as the product family since the "90Q" string > may collide with other LG models by being too short. If there are other > better ways of achieving this match I would be happy to hear about them. > --- > drivers/usb/typec/ucsi/ucsi_acpi.c | 61 ++++++++++++++++++++++++++++++++++++++ > 1 file changed, 61 insertions(+) > > diff --git a/drivers/usb/typec/ucsi/ucsi_acpi.c b/drivers/usb/typec/ucsi/ucsi_acpi.c > index 8d112c3edae5..adf32ca0f761 100644 > --- a/drivers/usb/typec/ucsi/ucsi_acpi.c > +++ b/drivers/usb/typec/ucsi/ucsi_acpi.c > @@ -25,6 +25,7 @@ struct ucsi_acpi { > unsigned long flags; > #define UCSI_ACPI_COMMAND_PENDING 1 > #define UCSI_ACPI_ACK_PENDING 2 > +#define UCSI_ACPI_CHECK_BOGUS_EVENT 3 > guid_t guid; > u64 cmd; > }; > @@ -128,6 +129,58 @@ static const struct ucsi_operations ucsi_zenbook_ops = { > .async_write = ucsi_acpi_async_write > }; > > +static int ucsi_gram_read(struct ucsi *ucsi, unsigned int offset, > + void *val, size_t val_len) > +{ > + u16 bogus_change = UCSI_CONSTAT_POWER_LEVEL_CHANGE | > + UCSI_CONSTAT_PDOS_CHANGE; > + struct ucsi_acpi *ua = ucsi_get_drvdata(ucsi); > + struct ucsi_connector_status *status; > + int ret; > + > + ret = ucsi_acpi_read(ucsi, offset, val, val_len); > + if (ret < 0) > + return ret; > + > + if (UCSI_COMMAND(ua->cmd) == UCSI_GET_CONNECTOR_STATUS && > + test_bit(UCSI_ACPI_CHECK_BOGUS_EVENT, &ua->flags) && > + offset == UCSI_MESSAGE_IN) { > + status = (struct ucsi_connector_status *)val; > + > + /* Clear the bogus change */ > + if (status->change == bogus_change) > + status->change = 0; > + > + clear_bit(UCSI_ACPI_CHECK_BOGUS_EVENT, &ua->flags); > + } > + > + return ret; > +} > + > +static int ucsi_gram_sync_write(struct ucsi *ucsi, unsigned int offset, > + const void *val, size_t val_len) > +{ > + struct ucsi_acpi *ua = ucsi_get_drvdata(ucsi); > + int ret; > + > + ret = ucsi_acpi_sync_write(ucsi, offset, val, val_len); > + if (ret < 0) > + return ret; > + > + if (UCSI_COMMAND(ua->cmd) == UCSI_GET_PDOS && > + ua->cmd & UCSI_GET_PDOS_PARTNER_PDO(1) && > + ua->cmd & UCSI_GET_PDOS_SRC_PDOS) > + set_bit(UCSI_ACPI_CHECK_BOGUS_EVENT, &ua->flags); > + > + return ret; > +} > + > +static const struct ucsi_operations ucsi_gram_ops = { > + .read = ucsi_gram_read, > + .sync_write = ucsi_gram_sync_write, > + .async_write = ucsi_acpi_async_write > +}; > + > static const struct dmi_system_id ucsi_acpi_quirks[] = { > { > .matches = { > @@ -136,6 +189,14 @@ static const struct dmi_system_id ucsi_acpi_quirks[] = { > }, > .driver_data = (void *)&ucsi_zenbook_ops, > }, > + { > + .matches = { > + DMI_MATCH(DMI_SYS_VENDOR, "LG Electronics"), > + DMI_MATCH(DMI_PRODUCT_FAMILY, "LG gram PC"), > + DMI_MATCH(DMI_PRODUCT_NAME, "90Q"), > + }, > + .driver_data = (void *)&ucsi_gram_ops, > + }, > { } > }; > > > --- > base-commit: 5821bf2dffbe18fe1f097dbb027415fa15a38e9a > change-id: 20240612-gram_quirk-ac150257c415 > > Best regards, > -- > Diogo Ivo -- heikki