Received: by 2002:a89:413:0:b0:1fd:dba5:e537 with SMTP id m19csp241109lqs; Thu, 13 Jun 2024 08:51:43 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUaEM+ms69PS9rbpV22OLJwvf0hIlWUR5Fvian77RTliQjoym97MtEMls2ChgI1Tf7pafcASC+DFhZvN7dsRWqp35GtcQIwdsxZLKxNLg== X-Google-Smtp-Source: AGHT+IGNV4ylqc0trBYoV7oat1o1Shkbx2uSDWOissU25ylAHn6LtgIH1vfez/79TsFLaK8+XSIz X-Received: by 2002:a50:9f8c:0:b0:57c:73ff:d13e with SMTP id 4fb4d7f45d1cf-57cbd8b9c60mr131275a12.31.1718293903373; Thu, 13 Jun 2024 08:51:43 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718293903; cv=pass; d=google.com; s=arc-20160816; b=OBayG6Mrna3jAUpb6gwIW1vN/U/rQlOMptjJ0mHSVZjDKqtqudYH1MHAEBu24UfsPm bbWnVhgC23L/gwGsV1jQIc5ut4Iyge4Gtx3YTsDFQ7G0eLkeoTHgOYzRB4psI5p2IrnW ZPYliv1lE4k9bjTYi++8g6Xpuj7tfpgVkxJdJV7qb6XZjU0aNSmaSZ05H+ktdIa3bgIt NSoI0yiiIyON0x7mQxt1gdwZbLsW0PQN6rAY13yd3aCRB+lWK3pKys2YAOfV+nVwhj5x eiWK1go8+0588XGo/UCUHqy0Qr2GWZ5nV1dgzlwrangT1MLHdsfGOuQoez+pq3m1WGCQ qV4A== 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:message-id:subject:cc:to:from :date:dkim-signature; bh=Mncnb3keYAVGDmAJhzQTe6smi1VTAcmGupK58+nteXU=; fh=BP1tXpj1t8ELcx+EQxQoxCXqoKG1j2H5/RXDxNscJiw=; b=CZBnFM2LV1zxKeD5MFIHJZ8eRTbpNBwIxH2LiYy2tZkWYMW0Hqgm0HwwGSHqOc7as+ FZ5du1KXcG085Q/pY1mbZX+uKB44g3ID7AmLcgqJb9nb8G26oS6pZDCKBREBUTqS7Ggk AoHLXzH5kbfyRFdThzpWjbHxctclpGcU4n403iOw6aRxot/XyaW0+Mw4qrZkrbeqm0c1 p+HPuS6ooW0v0WG/Cg0rHGUXSiaPQUTBadno2H8k37r3SnPH6Gpvj12M9nOz26z83qeq q9VFLg++De37ZYAhIBMSALL204kJTCeLtKxng4hER8D79Yntm45NX7JaKKlj3CCiCM5K ngRA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=jc+oLWI4; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-213604-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-213604-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id 4fb4d7f45d1cf-57cb72e271asi841399a12.167.2024.06.13.08.51.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Jun 2024 08:51:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-213604-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=jc+oLWI4; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-213604-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-213604-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=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 C4CDA1F24EFD for ; Thu, 13 Jun 2024 15:51:42 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A3F0012F386; Thu, 13 Jun 2024 15:51:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="jc+oLWI4" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 C70B526AE4; Thu, 13 Jun 2024 15:51:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718293896; cv=none; b=FdspVhcK+bnjWeE3PqmB3HXNlVPAERCUHjMLFkvJrIMb0jpscN0OISjkQYOfp+LLWHg0b/eZd9BUJO2/a94eQDYWYq7MtdecPO0s24g1yyikwFm7ogkkDLEpryq7M2ff8tDoo+sTl51QrR7UOyf9lHNNNLKq5lZMLK3BfsL0BJ0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718293896; c=relaxed/simple; bh=+Y5pdWBck8MRqEy7e3HpK1hthc5Zhr8DhE0bYidHEog=; h=Date:From:To:Cc:Subject:Message-ID:MIME-Version:Content-Type: Content-Disposition:In-Reply-To; b=XmcJbXTTdsoglK63iT6hc8e6Yx+dBbLmDVarBXksrUWr6RREyqfevRNDAfe/2djqV4xUyd8gOguixVRJAMTbmdNXBnxKg2AZo+4kxcD0D+E9CS2Fcrgaqh/m1AZI/Srd1z35Qh+5+PaB0IA4J3f+eJ77o/K7zmMH+OIvp1nnAYg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=jc+oLWI4; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 23DF6C32786; Thu, 13 Jun 2024 15:51:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1718293896; bh=+Y5pdWBck8MRqEy7e3HpK1hthc5Zhr8DhE0bYidHEog=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=jc+oLWI45ECpvEtwv0CnM45spaX+HyHOIsJk4LBa2/Do3lfnehbqtiMFsiyAcGnph wcrW18kD2CB6IHDFKounxKICJSD1T76uGbf1yABGm6M9a2Bga9h1kKxnG1I0maSKfV RQQ3erzAjuSHolNGOybphwd1ZC/SfHZn6xDBg0dL9KJY5NNh/gOEFO/5mqRDshlesX E+NkXIgJymIVEWAoIHHidBY4Jhci/oFsFECoa8iqb2084G2e5h/PsSi2z4ZtRtPoHe 1fiRSbxulKeSnlyAaemc5hbMqyaVQULnnqFi2airSKpwXpqw7t72ffpthNBPMDyUwx EJVNiKFCN5jzA== Date: Thu, 13 Jun 2024 10:51:34 -0500 From: Bjorn Helgaas To: Uros Bizjak Cc: linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, Bjorn Helgaas , Lukas Wunner , Ilpo =?utf-8?B?SsOkcnZpbmVu?= Subject: Re: [PATCH] PCI: hotplug: Use atomic_{fetch_}andnot() where appropriate Message-ID: <20240613155134.GA1062951@bhelgaas> 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: <20240613082449.197397-1-ubizjak@gmail.com> [+cc Lukas, Ilpo] On Thu, Jun 13, 2024 at 10:24:24AM +0200, Uros Bizjak wrote: > Use atomic_{fetch_}andnot(i, v) instead of atomic_{fetch_}and(~i, v). If the purpose is to improve readability, let's mention that here. Since this only touches pciehp, make the subject line "PCI: pciehp: ..." as was done in the past. It looks like every use of atomic_and() uses a ~value and is hence a candidate for a similar change, but I'm not sure that converting to "andnot" and removing the explicit bitwise NOT is really a readability benefit. If it were named something like "atomic_clear_bits", I'd be totally in favor since that's a little higher-level description, but that ship has long since sailed. But I don't really care and if this is the trend, I'm fine with this if Lukas and Ilpo agree. > No functional changes intended. > > Cc: Bjorn Helgaas > Signed-off-by: Uros Bizjak > --- > drivers/pci/hotplug/pciehp_ctrl.c | 4 ++-- > drivers/pci/hotplug/pciehp_hpc.c | 8 ++++---- > 2 files changed, 6 insertions(+), 6 deletions(-) > > diff --git a/drivers/pci/hotplug/pciehp_ctrl.c b/drivers/pci/hotplug/pciehp_ctrl.c > index dcdbfcf404dd..7c775d9a6599 100644 > --- a/drivers/pci/hotplug/pciehp_ctrl.c > +++ b/drivers/pci/hotplug/pciehp_ctrl.c > @@ -121,8 +121,8 @@ static void remove_board(struct controller *ctrl, bool safe_removal) > msleep(1000); > > /* Ignore link or presence changes caused by power off */ > - atomic_and(~(PCI_EXP_SLTSTA_DLLSC | PCI_EXP_SLTSTA_PDC), > - &ctrl->pending_events); > + atomic_andnot(PCI_EXP_SLTSTA_DLLSC | PCI_EXP_SLTSTA_PDC, > + &ctrl->pending_events); > } > > pciehp_set_indicators(ctrl, PCI_EXP_SLTCTL_PWR_IND_OFF, > diff --git a/drivers/pci/hotplug/pciehp_hpc.c b/drivers/pci/hotplug/pciehp_hpc.c > index b1d0a1b3917d..6d192f64ea19 100644 > --- a/drivers/pci/hotplug/pciehp_hpc.c > +++ b/drivers/pci/hotplug/pciehp_hpc.c > @@ -307,8 +307,8 @@ int pciehp_check_link_status(struct controller *ctrl) > > /* ignore link or presence changes up to this point */ > if (found) > - atomic_and(~(PCI_EXP_SLTSTA_DLLSC | PCI_EXP_SLTSTA_PDC), > - &ctrl->pending_events); > + atomic_andnot(PCI_EXP_SLTSTA_DLLSC | PCI_EXP_SLTSTA_PDC, > + &ctrl->pending_events); > > pcie_capability_read_word(pdev, PCI_EXP_LNKSTA, &lnk_status); > ctrl_dbg(ctrl, "%s: lnk_status = %x\n", __func__, lnk_status); > @@ -568,7 +568,7 @@ static void pciehp_ignore_dpc_link_change(struct controller *ctrl, > * Could be several if DPC triggered multiple times consecutively. > */ > synchronize_hardirq(irq); > - atomic_and(~PCI_EXP_SLTSTA_DLLSC, &ctrl->pending_events); > + atomic_andnot(PCI_EXP_SLTSTA_DLLSC, &ctrl->pending_events); > if (pciehp_poll_mode) > pcie_capability_write_word(pdev, PCI_EXP_SLTSTA, > PCI_EXP_SLTSTA_DLLSC); > @@ -702,7 +702,7 @@ static irqreturn_t pciehp_ist(int irq, void *dev_id) > pci_config_pm_runtime_get(pdev); > > /* rerun pciehp_isr() if the port was inaccessible on interrupt */ > - if (atomic_fetch_and(~RERUN_ISR, &ctrl->pending_events) & RERUN_ISR) { > + if (atomic_fetch_andnot(RERUN_ISR, &ctrl->pending_events) & RERUN_ISR) { > ret = pciehp_isr(irq, dev_id); > enable_irq(irq); > if (ret != IRQ_WAKE_THREAD) > -- > 2.45.2 >