Received: by 2002:a05:6358:f14:b0:e5:3b68:ec04 with SMTP id b20csp156503rwj; Thu, 22 Dec 2022 06:12:52 -0800 (PST) X-Google-Smtp-Source: AMrXdXuvWa+BTinsNUywl6Jw1PImdoHkqQpa7OCmOX+pQORCXPOJGqzYuZDZtTrS23CVmz5d0xVn X-Received: by 2002:a17:906:9255:b0:7c0:d4fa:3151 with SMTP id c21-20020a170906925500b007c0d4fa3151mr8044223ejx.17.1671718372567; Thu, 22 Dec 2022 06:12:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671718372; cv=none; d=google.com; s=arc-20160816; b=Tqpgoh+1FsTCbOwCAJYAcs3CiRDXfn9Nrnky1dAidlf2uDh7lwTF9CjoWKIgVW8y7b lw3T3nv/uAmWSOeVkl8xeVcvzmXSkdlCkWOPsk4hfGq49LWGeVuH6raldRtd4A2Q5p8q d5OLqcHq8XHWhh1N+uv4S4D4YI07rwIc/fnXqG+QxTe+FaBB0MAYLDWo7b7zHSZFXSbw NR0Uu3vJAEx6lj064Y48scQz9ObK4i/g/d9wglfe1eOwgVzILaUFMBeYO2LU4GTrpmDL Vd8aqlrpQUjKfo0YszCqEK3SeB+KoiCqK4oDVZsqPb2AEB5GvQwtHkyH/SdrRpNhO3UE o7HQ== 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 :references:message-id:subject:cc:to:from:date:dkim-signature; bh=BTzVuH98qbK5XjIDM40jlZrlY2JW2gWjCPIbZlOXwMw=; b=zBe2+xF62s7HtET5xqqdlncwCii3qESX0WSojyzDqwv0ywNAJ17iT+UenO1JkCEzzG wIJn1ifpfRc3xImZa57vbp6pbKRTxRdQViRAp9qxnkuLJZmP4HEYnBIJ0RDC0HMuEdwV n2hORpuZpEwVZ+sjfAgXJMKRDdu/8wD/banGWX+3GvEVXpC6nna12RpEGRirb/P9TXi4 sp6rHft6MnAnf2YIHH/alrADt7XdF4MmErfc6aaHu5++DpupEtvYeYqu24SsIpbzN0IW 10LfZnhxiocS+h2Q8MGJDQOQij3ZxxRfkQH0or2zYE08pG4DSHJ+KAdexzRYASMdzLdC sUFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@mailo.com header.s=mailo header.b=i6BFp7rK; 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=fail (p=NONE sp=NONE dis=NONE) header.from=mailo.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h3-20020a056402280300b0045731196587si957304ede.64.2022.12.22.06.12.28; Thu, 22 Dec 2022 06:12:52 -0800 (PST) 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=fail header.i=@mailo.com header.s=mailo header.b=i6BFp7rK; 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=fail (p=NONE sp=NONE dis=NONE) header.from=mailo.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235361AbiLVODB (ORCPT + 67 others); Thu, 22 Dec 2022 09:03:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42782 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230299AbiLVOC6 (ORCPT ); Thu, 22 Dec 2022 09:02:58 -0500 X-Greylist: delayed 65088 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Thu, 22 Dec 2022 06:02:56 PST Received: from msg-1.mailo.com (msg-1.mailo.com [213.182.54.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1E5C86466; Thu, 22 Dec 2022 06:02:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=mailo.com; s=mailo; t=1671717757; bh=rAiXl+mdpdCyxLsqZQpH6KekvLvHUkV0B51Cjb53HRA=; h=X-EA-Auth:Date:From:To:Cc:Subject:Message-ID:References: MIME-Version:Content-Type:In-Reply-To; b=i6BFp7rKXpgwTRO40SFxqhfrW02mMUMoJLjZTI+qZzI5AB/lStix1/QLLR5e80x3b rXfO3HCVxI1+sCYIX4j+Avg2DgqyxuBH9tegUoiJTNaEN/5KunUeMb1udV/C/D6wgE YgwnYM90DYx11Oobo7OSH2rmoiGHcjuvvi5F1s2s= Received: by b-6.in.mailobj.net [192.168.90.16] with ESMTP via ip-206.mailobj.net [213.182.55.206] Thu, 22 Dec 2022 15:02:37 +0100 (CET) X-EA-Auth: /Rb/X7L8cN/nRl02EkrqvOrn+ZbhNwuoCLwLDamRCNY6fwRTz1VkrjOc32l1B8MUotKGCIay5XAUGENZzl1xxEq2AY99KDTC Date: Thu, 22 Dec 2022 19:32:32 +0530 From: Deepak R Varma To: Greg Kroah-Hartman Cc: "Maciej W. Rozycki" , Jiri Slaby , linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, Saurabh Singh Sengar , Praveen Kumar , drv@mailo.com Subject: Re: [PATCH] tty: serial: convert atomic_* to refcount_* APIs Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham 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 On Thu, Dec 22, 2022 at 06:55:01AM +0100, Greg Kroah-Hartman wrote: > On Thu, Dec 22, 2022 at 01:27:40AM +0530, Deepak R Varma wrote: > > The refcount_* APIs are designed to address known issues with the > > atomic_t APIs for reference counting. They protect the reference > > counters from overflow/underflow, use-after-free errors, provide > > improved memory ordering guarantee schemes, are neater and safer. > > Hence, replace the atomic_* APIs by their equivalent refcount_t > > API functions. > > > > This patch proposal address the following warnings generated by > > the atomic_as_refcounter.cocci coccinelle script > > atomic_add_return(-1, ...) > > > > > > Signed-off-by: Deepak R Varma > > --- > > Note: The patch is compile tested using dec_station.defconfig for > > MIPS architecture. > > Do you have this hardware? If not, please just do > one-variable-at-a-time so that if there are real problems, we can revert > the offending change easier. And it makes it simpler to review. Hi Greg, I do not have the hardware. I will make a one variable per patch change as suggest and send in a patch set. > > But, are you sure this is correct: > > > - irq_guard = atomic_add_return(1, &mux->irq_guard); > > - if (irq_guard != 1) > > + refcount_inc(&mux->irq_guard); > > + if (refcount_read(&mux->irq_guard) != 1) > > That is now different logic than before, why? Are you sure this is ok? This is not correct. I read it wrong. I will correct this in the patch set. > > I stopped reviewing here... Thanks. I will review the rest of the changes per your advise and make the corrections. regards, ./drv > > thanks, > > greg k-h