Received: by 2002:a05:6358:701b:b0:131:369:b2a3 with SMTP id 27csp4556831rwo; Tue, 25 Jul 2023 07:47:34 -0700 (PDT) X-Google-Smtp-Source: APBJJlH0SE3HzjlQDlH11TieFsRsHyHXAHi/BvwFvQJF0I3ydMcVc6v/Z3Czav/qqE5TPlvrSP0b X-Received: by 2002:a17:906:3147:b0:975:63f4:46 with SMTP id e7-20020a170906314700b0097563f40046mr12341300eje.57.1690296454201; Tue, 25 Jul 2023 07:47:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690296454; cv=none; d=google.com; s=arc-20160816; b=rBIxc8j6GeBv1K0ntUr7i4dcJ3ZhOQWTPsB4lvpmTAEe/dLkOFBtOKqglKjJVv1H6R 55847xrUmyiBaXgU2VbnZKo8h/x9BJLJnB3czr1wWRzaKRPOnKMrxBCWjdPOp4VT5oJo U3LS8LXIemh4lZxpLznGwi8QVT5GfnlCKB2Lt0y1tgJezmQPVF0yo7whbRa95A1YyeUq VFHxvi/r2bErDylkfqFXPoZyd/A/yvEpD7rN9kfL1X9m2egK8JxDaOb7t/nLtVHVHyai iRw5CbkIxWpRN3rQjPKC8aO8nC+RFC3P2L+2QljaUTPKQ3VQlWZOk2ECPxpatG70oE3N TqVg== 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:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=GlLyTOX+0T4BQUjuuprKNGe/wk35wQO5DAolXb81K+Q=; fh=ll0dGwWUgw9CSWv3jaQscRUvp/u08QP2ro2tjhbjDMQ=; b=pEHydLCBJqolbwJ8lndXprhNGDYAfQslsowgrrCn2NVE6RQMe6WSsSWL5NGgAJGC3H 1kFdwKlDQ9VGYc67GuXrucpg9IgZxMqjHW+hU7e5c/BkB1H3iJx+EVYVP/LLApxv8Q8j ob5F31xskrpuKv/rZZoxNIEvOrDgdEU0EJywYsW6CC9vQ3xBvIKbaa1x+9y2+1yz2PYv M/5ih+1oF9m3w8V8crnifwcsAifxVp5EVj82oZ8jK0GXw0DPHP+KVnnHEtmAp/jAiyuZ SgChdWYZqoa203k9/o4/XuaLYyZoWITzAaNqfKvBUND9ws5LqJoQ6LlSD1OQFCzXMnW8 IlFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=bwyYVHtU; 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=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b27-20020a170906039b00b0098730845081si8385496eja.599.2023.07.25.07.47.10; Tue, 25 Jul 2023 07:47:34 -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=@redhat.com header.s=mimecast20190719 header.b=bwyYVHtU; 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233147AbjGYOjM (ORCPT + 99 others); Tue, 25 Jul 2023 10:39:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49240 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233102AbjGYOjK (ORCPT ); Tue, 25 Jul 2023 10:39:10 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4AC9FE5 for ; Tue, 25 Jul 2023 07:38:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1690295906; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=GlLyTOX+0T4BQUjuuprKNGe/wk35wQO5DAolXb81K+Q=; b=bwyYVHtUN7L1F6LHQ4lZkzIj1KK6b35FZqmPTgrPjMxIF9dr3tSKA7oH0rCEHzcwDZj4z3 yS8GLVI6qBURr8bB36tozRE2V7vFm5a0WVLINNxPKLjoC49aUtKfLvjNpuGuOE764JOTk1 ekVj01xOj9dy6JhrJ6gFxs2ecYM9+Lc= Received: from mail-ej1-f72.google.com (mail-ej1-f72.google.com [209.85.218.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-684-auVce64ANqu_7lRPRoLZvA-1; Tue, 25 Jul 2023 10:37:24 -0400 X-MC-Unique: auVce64ANqu_7lRPRoLZvA-1 Received: by mail-ej1-f72.google.com with SMTP id a640c23a62f3a-997d069a914so380932566b.1 for ; Tue, 25 Jul 2023 07:37:24 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690295843; x=1690900643; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=GlLyTOX+0T4BQUjuuprKNGe/wk35wQO5DAolXb81K+Q=; b=KtZEELKTkL1CuBMnw8KD5q4LJEsQe7oAhQuoDfCFCLebi+s6ruWxGnmDzvbN9DU7sU KBmcOiElH2RmEfp9G2sexE2wqsNfNthG1L/W0ilqwcguPYamg3TnLnvaP8/RHja1NMIA kYM9AHBsYWKn6fTImbhDtDM90lxP+WvWFSJpQR7fgSqz4H7FrRhnIGRB2URJENGKny8F iiw8VWVYP462X0MnMbc1SR0xeSr/sMJ8896Ua5068YBRD/WJnVsW4xomPIflTeGtENoE mlp83/fA+d73F+lPH6u7tAtotZXU1nYcY5ALvzLmS3on37OuBTylVUyJ6C5tI1JY4CUe +gZQ== X-Gm-Message-State: ABy/qLb9X5nm7Y9dtYbdF37pkWMnPfFpMvbVeW2xWdsBHwH9i1n81qMP cJbVAOB5GU4dVQdg5yh5qgiXB8igw2zJz/Jq2XoLpRBcdl9hwpKbgfEx+tDcFO1aMutmuLpEV42 jHXqTBIdbXgNcnugxqFsYK3aL X-Received: by 2002:a17:906:3059:b0:994:673:8afa with SMTP id d25-20020a170906305900b0099406738afamr12186712ejd.28.1690295843572; Tue, 25 Jul 2023 07:37:23 -0700 (PDT) X-Received: by 2002:a17:906:3059:b0:994:673:8afa with SMTP id d25-20020a170906305900b0099406738afamr12186701ejd.28.1690295843297; Tue, 25 Jul 2023 07:37:23 -0700 (PDT) Received: from ?IPV6:2001:1c00:c32:7800:5bfa:a036:83f0:f9ec? (2001-1c00-0c32-7800-5bfa-a036-83f0-f9ec.cable.dynamic.v6.ziggo.nl. [2001:1c00:c32:7800:5bfa:a036:83f0:f9ec]) by smtp.gmail.com with ESMTPSA id qx26-20020a170906fcda00b00982cfe1fe5dsm8320354ejb.65.2023.07.25.07.37.22 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 25 Jul 2023 07:37:22 -0700 (PDT) Message-ID: <8ceb0052-f402-0217-2889-f9ef48a5f11f@redhat.com> Date: Tue, 25 Jul 2023 16:37:21 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.12.0 Subject: Re: [PATCH] platform/x86: msi-laptop: Fix rfkill out-of-sync on MSI Wind U100 Content-Language: en-US, nl To: Maxim Mikityanskiy , "Lee, Chun-Yi" , Mark Gross Cc: Matthew Garrett , Matthew Garrett , platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org References: <20230721145423.161057-1-maxtram95@gmail.com> From: Hans de Goede In-Reply-To: <20230721145423.161057-1-maxtram95@gmail.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.2 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_NONE,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 Hi, On 7/21/23 16:54, Maxim Mikityanskiy wrote: > Only the HW rfkill state is toggled on laptops with quirks->ec_read_only > (so far only MSI Wind U90/U100). There are, however, a few issues with > the implementation: > > 1. The initial HW state is always unblocked, regardless of the actual > state on boot, because msi_init_rfkill only sets the SW state, > regardless of ec_read_only. > > 2. The initial SW state corresponds to the actual state on boot, but it > can't be changed afterwards, because set_device_state returns > -EOPNOTSUPP. It confuses the userspace, making Wi-Fi and/or Bluetooth > unusable if it was blocked on boot, and breaking the airplane mode if > the rfkill was unblocked on boot. > > Address the above issues by properly initializing the HW state on > ec_read_only laptops and by allowing the userspace to toggle the SW > state. Don't set the SW state ourselves and let the userspace fully > control it. Toggling the SW state is a no-op, however, it allows the > userspace to properly toggle the airplane mode. The actual SW radio > disablement is handled by the corresponding rtl818x_pci and btusb > drivers that have their own rfkills. > > Tested on MSI Wind U100 Plus, BIOS ver 1.0G, EC ver 130. > > Fixes: 0816392b97d4 ("msi-laptop: merge quirk tables to one") > Fixes: 0de6575ad0a8 ("msi-laptop: Add MSI Wind U90/U100 support") > Signed-off-by: Maxim Mikityanskiy Thank you for your patch, I've applied this patch to my fixes branch: https://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86.git/log/?h=fixes Note it will show up in my fixes branch once I've pushed my local branch there, which might take a while. I will include this patch in my next fixes pull-req to Linus for the current kernel development cycle. Regards, Hans > --- > drivers/platform/x86/msi-laptop.c | 8 ++++---- > 1 file changed, 4 insertions(+), 4 deletions(-) > > diff --git a/drivers/platform/x86/msi-laptop.c b/drivers/platform/x86/msi-laptop.c > index 6b18ec543ac3..f4c6c36e05a5 100644 > --- a/drivers/platform/x86/msi-laptop.c > +++ b/drivers/platform/x86/msi-laptop.c > @@ -208,7 +208,7 @@ static ssize_t set_device_state(const char *buf, size_t count, u8 mask) > return -EINVAL; > > if (quirks->ec_read_only) > - return -EOPNOTSUPP; > + return 0; > > /* read current device state */ > result = ec_read(MSI_STANDARD_EC_COMMAND_ADDRESS, &rdata); > @@ -838,15 +838,15 @@ static bool msi_laptop_i8042_filter(unsigned char data, unsigned char str, > static void msi_init_rfkill(struct work_struct *ignored) > { > if (rfk_wlan) { > - rfkill_set_sw_state(rfk_wlan, !wlan_s); > + msi_rfkill_set_state(rfk_wlan, !wlan_s); > rfkill_wlan_set(NULL, !wlan_s); > } > if (rfk_bluetooth) { > - rfkill_set_sw_state(rfk_bluetooth, !bluetooth_s); > + msi_rfkill_set_state(rfk_bluetooth, !bluetooth_s); > rfkill_bluetooth_set(NULL, !bluetooth_s); > } > if (rfk_threeg) { > - rfkill_set_sw_state(rfk_threeg, !threeg_s); > + msi_rfkill_set_state(rfk_threeg, !threeg_s); > rfkill_threeg_set(NULL, !threeg_s); > } > }