From patchwork Wed Sep 29 12:40:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sumit Saxena X-Patchwork-Id: 12525467 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 93607C433F5 for ; Wed, 29 Sep 2021 12:41:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7C9BD613D1 for ; Wed, 29 Sep 2021 12:41:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343880AbhI2MnG (ORCPT ); Wed, 29 Sep 2021 08:43:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46530 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343839AbhI2MnG (ORCPT ); Wed, 29 Sep 2021 08:43:06 -0400 Received: from mail-pf1-x436.google.com (mail-pf1-x436.google.com [IPv6:2607:f8b0:4864:20::436]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 73F03C06161C for ; Wed, 29 Sep 2021 05:41:25 -0700 (PDT) Received: by mail-pf1-x436.google.com with SMTP id s16so1893384pfk.0 for ; Wed, 29 Sep 2021 05:41:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=w9Yxno8c8gn3xl2N8/8Ixm88LaQVWYiq59oo9nElJ3s=; b=Rq/Vg8C2o/ZpJFKpECO29wC8sxwJqwueBQuceNBhLo11pxJNO0udIMLRk6taKuNQDQ VyU/8R2wHHBN/kyF8dnnhEZJIdwfxLD9bhAUOKs+6rm8Zvc2KdtvePUw3H/ThYDE0om1 kw0lH7N+nIWkp5BZH9ISRZGdQpEPbG5n7uong= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=w9Yxno8c8gn3xl2N8/8Ixm88LaQVWYiq59oo9nElJ3s=; b=LQEpxiN5lc1I+/7q02hriQuIh5yu3tN8vGRrUWXxSuKtgEnQ197Luklq7s1J/w5nZY pomGuy4nywui8IIz4RO+kP5S31Y3WzUTgdcdNwUU8f2oFp6Oop39C3vrJCvrbMbt/zNT B/lqixe7rjcVvkQxdlSEPh89469b1LGioP+WMQcr5OAmiiyT+A1nMb8NY5YLUvn3PsrF gTHDTZvy8lmpIdfqaDhkzX+c2g4kplO6VdiL7StXcYCbGCf8lkEQVrL+OVr7RmFhCDEW KXS9t9ce8BBl3KS7/Zkg5VMuoqnUXWQOCz77stQrGmSxeGRwsC1RfuArfGteq/qE0ODe 4rXw== X-Gm-Message-State: AOAM532NENOcDbvqF5h3wlfcWzOjfQhGmQkvopFlxDf+HeOMe3NSMCba 6BxclrOKfNVm1UisSiUKFcanYsbJaFEa0bWMXpUUqbFbvQkweRVOxLQ2hehd6MNuWZtCcJyQAuX cb78fhS2XJXct3XV/5jGtVqyYXGJpVKsw3/aYKI+ynbRSUYVjIO/vUxCCCGbYHRckfOJ0mBWKfN E/e0RTLHs= X-Google-Smtp-Source: ABdhPJxXeVkJ6V/Ptt25PJOgWJq9HoF373csyjUJskd6xzfQIzVDli6iESGZPdt5foxm8Us2q77chQ== X-Received: by 2002:a05:6a00:1481:b0:43d:275b:7ba4 with SMTP id v1-20020a056a00148100b0043d275b7ba4mr10998854pfu.63.1632919284484; Wed, 29 Sep 2021 05:41:24 -0700 (PDT) Received: from dhcp-10-123-20-83.dhcp.broadcom.net ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id g9sm2528080pfh.13.2021.09.29.05.41.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Sep 2021 05:41:24 -0700 (PDT) From: Sumit Saxena To: linux-scsi@vger.kernel.org, martin.petersen@oracle.com, jejb@linux.vnet.ibm.com Cc: chandrakanth.patil@broadcom.com, kashyap.desai@broadcom.com, Sumit Saxena Subject: [PATCH 2/3] megaraid_sas: Add helper functions- {access/release}_irq_context Date: Wed, 29 Sep 2021 18:10:21 +0530 Message-Id: <20210929124022.24605-3-sumit.saxena@broadcom.com> X-Mailer: git-send-email 2.18.1 In-Reply-To: <20210929124022.24605-1-sumit.saxena@broadcom.com> References: <20210929124022.24605-1-sumit.saxena@broadcom.com> Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Adding helper functions for ISR access and release to improve the readability. Signed-off-by: Sumit Saxena --- drivers/scsi/megaraid/megaraid_sas_fusion.c | 45 ++++++++++++++++++--- 1 file changed, 39 insertions(+), 6 deletions(-) diff --git a/drivers/scsi/megaraid/megaraid_sas_fusion.c b/drivers/scsi/megaraid/megaraid_sas_fusion.c index eb5ceb75a15e..109782e3ec44 100644 --- a/drivers/scsi/megaraid/megaraid_sas_fusion.c +++ b/drivers/scsi/megaraid/megaraid_sas_fusion.c @@ -3497,6 +3497,41 @@ megasas_complete_r1_command(struct megasas_instance *instance, } } +/** + * access_irq_context: Access to reply processing + * @irq_context: IRQ context + * + * Synchronize access to reply processing. + * + * Return: true on success, false on failure. + */ +static inline +bool access_irq_context(struct megasas_irq_context *irq_context) +{ + if (!irq_context) + return true; + + if (atomic_add_unless(&irq_context->in_used, 1, 1)) + return true; + + return false; +} + +/** + * release_irq_context: Release reply processing + * @irq_context: IRQ context + * + * Release access of reply processing. + * + * Return: Nothing. + */ +static inline +void release_irq_context(struct megasas_irq_context *irq_context) +{ + if (irq_context) + atomic_dec(&irq_context->in_used); +} + /** * complete_cmd_fusion - Completes command * @instance: Adapter soft state @@ -3530,7 +3565,7 @@ complete_cmd_fusion(struct megasas_instance *instance, u32 MSIxIndex, if (atomic_read(&instance->adprecovery) == MEGASAS_HW_CRITICAL_ERROR) return IRQ_HANDLED; - if (irq_context && !atomic_add_unless(&irq_context->in_used, 1, 1)) + if (!access_irq_context(irq_context)) return 0; desc = fusion->reply_frames_desc[MSIxIndex] + @@ -3544,8 +3579,7 @@ complete_cmd_fusion(struct megasas_instance *instance, u32 MSIxIndex, MPI2_RPY_DESCRIPT_FLAGS_TYPE_MASK; if (reply_descript_type == MPI2_RPY_DESCRIPT_FLAGS_UNUSED) { - if (irq_context) - atomic_dec(&irq_context->in_used); + release_irq_context(irq_context); return IRQ_NONE; } @@ -3663,7 +3697,7 @@ complete_cmd_fusion(struct megasas_instance *instance, u32 MSIxIndex, irq_context->irq_line_enable = true; irq_poll_sched(&irq_context->irqpoll); } - atomic_dec(&irq_context->in_used); + release_irq_context(irq_context); return num_completed; } } @@ -3682,8 +3716,7 @@ complete_cmd_fusion(struct megasas_instance *instance, u32 MSIxIndex, megasas_check_and_restore_queue_depth(instance); } - if (irq_context) - atomic_dec(&irq_context->in_used); + release_irq_context(irq_context); return num_completed; }