Received: by 2002:a05:7412:251c:b0:e2:908c:2ebd with SMTP id w28csp2749787rda; Wed, 25 Oct 2023 11:08:08 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEV9GGbGL5GP5wt6/cxolytuNZg3VQRq/yTgl+4w3oFR1Ryausr4aj4Dm1ESQUkK5aktx4r X-Received: by 2002:a81:a090:0:b0:5a7:baac:7b34 with SMTP id x138-20020a81a090000000b005a7baac7b34mr16337457ywg.28.1698257288196; Wed, 25 Oct 2023 11:08:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698257288; cv=none; d=google.com; s=arc-20160816; b=p2db3XRO4D6vxqO0YaKa5T3EkS50NkOcV70L5ryHEYxdb/y6VbLFMoM+ZRD5uHYLmM 7L8FMujgI/QBDclIxWze8Tn2/mGvfJkPTzu1Au5/xwCax1FaHppjznh24Xizkh1qKLLj Fb5ztzi+fVUDIv9EZG7LlCLgr8U5BVZ7kfxpXKC9AAQXSL6+n3MBI9TJ1YDbXsGRa9Mx 61NGcO6sGVTF5IT6aET5acL0w0/STlA1XMQ++bkry9f4UtCABfOrRN6fLJgeiktPdTie MI3jeiRsXV8zP7bEiQi6zi/3Ou1b1s6fTDlkqcQ7OGUtWK3T3iIXp1BOclBi4oDWUHmx iN9g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :message-id:subject:cc:to:from:date:dkim-signature; bh=AVjrE5+l092A24ZUp1o/OUGLffHI3Yj+gaDHrKi7324=; fh=+RZWHnNwArDh5DQkB7S+gjDUDQDsfRebTy/1SA46fcI=; b=hfrVQn+A8AiTQg+NUmNsWkRo5pthBhmVZDRo4ZmZqdVWlnsfxosY+vn3d4g0wybr5G ZjWycfMcXWVUKrxBNlyx4j1auRIXzKdGOjUG5x851X4gmM+gncXN1ACiSX13dapT67zw +3TuIf7j+7U0e8A6UI5DH4di+pbbUyWP63b/PKGD+XDu/k1zi4FHsnxxm1DXM5epQeYl AlDTrVtdsbC3V0TfQ92BNdwVjGbWQdwtdKEonwy1EjCuVLJ2RESWfK+u5Fwzgz0Cps0r gv17OatEu6PU3TT8VXT0TBBooNE0MAmfCZirZFdHfqrkDv8eLgulP3TYTL4A1p+RzmwW 54pQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=FA1auGb6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id v190-20020a8185c7000000b0058d229b05c5si12603205ywf.32.2023.10.25.11.08.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Oct 2023 11:08:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=FA1auGb6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 99125802AA30; Wed, 25 Oct 2023 11:07:59 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234955AbjJYSHk (ORCPT + 99 others); Wed, 25 Oct 2023 14:07:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41320 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234958AbjJYSH0 (ORCPT ); Wed, 25 Oct 2023 14:07:26 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9BAE71FED; Wed, 25 Oct 2023 11:06:30 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 76765C433C9; Wed, 25 Oct 2023 18:06:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1698257189; bh=TjPM4IUHZFeN5SC8qO/PKZAR4LKbys4t4FhjaQKNlpo=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=FA1auGb6vfdKd2ep3peuFgkHN25Eck/KxDbmTJ5LHvEf9WcUm9E8+xlbzj15MML4m sbrbseIezz0rt/qX458xFvQSmew0cCpKAKlFy0sAAQIoOTvalyjz0DXAuPGwPOS3sU nZIA/8s5NwrwsNrN1p1KKW2FfwEvvyIzhM9q5JLpioTpNlE4EP8ATBRphOMcR6WQRD Ux2Mf+CctvmMGYMbEiZIuO+UZRhwMO+qerXVHVDh+J4NqCUNXPAvHocZBzNpC0lTWY vCOVAXItEj32o8Cbl7CNEju4R3MwlGTPhBmRu1pYTqH+u/YlR7750KMzZOgVw4gyrL XSvKpTWsDUqAg== Date: Wed, 25 Oct 2023 13:06:27 -0500 From: Bjorn Helgaas To: D Scott Phillips Cc: linux-acpi@vger.kernel.org, linux-pci@vger.kernel.org, "Rafael J. Wysocki" , linux-kernel@vger.kernel.org, Len Brown , Darren Hart , patches@amperecomputing.com Subject: Re: [PATCH v2 2/2] PCI: hotplug: Add extension driver for Ampere Altra hotplug LED control Message-ID: <20231025180627.GA1756475@bhelgaas> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <86ttqe4n1h.fsf@scott-ph-mail.amperecomputing.com> X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Wed, 25 Oct 2023 11:07:59 -0700 (PDT) On Wed, Oct 25, 2023 at 10:41:46AM -0700, D Scott Phillips wrote: > Bjorn Helgaas writes: > > > On Fri, Sep 29, 2023 at 05:20:36PM -0700, D Scott Phillips wrote: > >> On Ampere Altra, PCIe hotplug is handled through ACPI. A side interface is > >> also present to request system firmware control of attention LEDs. Add an > >> ACPI PCI Hotplug companion driver to support attention LED control. > >> ... > > > >> + arm_smccc_smc(REQUEST, LED_CMD, led_status(status), LED_ATTENTION, > >> + pci_domain_nr(bus) | (PCI_SLOT(root_port->devfn) << 4), 0, 0, > > > > pci_domain_nr() returns "int" (normally 32 bits), but since this is an > > ACPI system, the domain comes from _SEG, which is defined to be 16 > > bits (ACPI r6.5, sec 6.5.6). > > > > So it looks like ORing in the "slot << 4" clobbers the upper 12 bits > > of _SEG. > > > > Is this code doing the right thing? > > Hi Bjorn, > > on these Altra platforms _SEG is limited within 0-11. I can add an `& > 0xf` to pci_domain_nr() to make it clear that the segment number is > encoded down into 4 bits in the smc request. If the following looks OK, we're all set. I put these on pci/hotplug for v6.7, thanks! +static int set_attention_status(struct hotplug_slot *slot, u8 status) +{ + struct arm_smccc_res res; + struct pci_bus *bus; + struct pci_dev *root_port; + unsigned long flags; + u32 handle; + int ret = 0; + + bus = slot->pci_slot->bus; + root_port = pcie_find_root_port(bus->self); + if (!root_port) + return -ENODEV; + + local_irq_save(flags); + arm_smccc_smc(HANDLE_OPEN, led_service_id[0], led_service_id[1], + led_service_id[2], led_service_id[3], 0, 0, 0, &res); + if (res.a0) { + ret = -ENODEV; + goto out; + } + handle = res.a1 & 0xffff0000; + + arm_smccc_smc(REQUEST, LED_CMD, led_status(status), LED_ATTENTION, + PCI_SLOT(root_port->devfn) << 4 | pci_domain_nr(bus) & 0xf, + 0, 0, handle, &res); + if (res.a0) + ret = -ENODEV; + + arm_smccc_smc(HANDLE_CLOSE, handle, 0, 0, 0, 0, 0, 0, &res); + + out: + local_irq_restore(flags); + return ret; +}