lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <DM6PR04MB6575D3CFDC51760EFF511F09FC349@DM6PR04MB6575.namprd04.prod.outlook.com>
Date:   Sun, 30 Oct 2022 12:28:33 +0000
From:   Avri Altman <Avri.Altman@....com>
To:     Asutosh Das <quic_asutoshd@...cinc.com>,
        "quic_cang@...cinc.com" <quic_cang@...cinc.com>,
        "martin.petersen@...cle.com" <martin.petersen@...cle.com>,
        "linux-scsi@...r.kernel.org" <linux-scsi@...r.kernel.org>
CC:     "quic_nguyenb@...cinc.com" <quic_nguyenb@...cinc.com>,
        "quic_xiaosenh@...cinc.com" <quic_xiaosenh@...cinc.com>,
        "stanley.chu@...iatek.com" <stanley.chu@...iatek.com>,
        "eddie.huang@...iatek.com" <eddie.huang@...iatek.com>,
        "daejun7.park@...sung.com" <daejun7.park@...sung.com>,
        "bvanassche@....org" <bvanassche@....org>,
        "mani@...nel.org" <mani@...nel.org>,
        "beanhuo@...ron.com" <beanhuo@...ron.com>,
        "quic_richardp@...cinc.com" <quic_richardp@...cinc.com>,
        "linux-arm-msm@...r.kernel.org" <linux-arm-msm@...r.kernel.org>,
        Alim Akhtar <alim.akhtar@...sung.com>,
        "James E.J. Bottomley" <jejb@...ux.ibm.com>,
        Krzysztof Kozlowski <krzysztof.kozlowski@...aro.org>,
        Kiwoong Kim <kwmad.kim@...sung.com>,
        open list <linux-kernel@...r.kernel.org>
Subject: RE: [PATCH v3 08/17] ufs: core: mcq: Allocate memory for mcq mode

>  #define SD_ASCII_STD true
>  #define SD_RAW false
> diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c
> index b928ed8..e32396e 100644
> --- a/drivers/ufs/core/ufshcd.c
> +++ b/drivers/ufs/core/ufshcd.c
> @@ -3686,6 +3686,12 @@ static int ufshcd_memory_alloc(struct ufs_hba
> *hba)
>         }
> 
>         /*
> +        * Not freed if MCQ is configured see ufshcd_release_sdb_queue() and
> +        * ufshcd_config_mcq()
> +        */
> +       if (hba->utmrdl_base_addr)
> +               goto skip_utmrdl;
> +       /*
>          * Allocate memory for UTP Task Management descriptors
>          * UFSHCI requires 1024 byte alignment of UTMRD
>          */
> @@ -3701,6 +3707,7 @@ static int ufshcd_memory_alloc(struct ufs_hba
> *hba)
>                 goto out;
>         }
> 
> +skip_utmrdl:
>         /* Allocate memory for local reference block */
>         hba->lrb = devm_kcalloc(hba->dev,
>                                 hba->nutrs, sizeof(struct ufshcd_lrb),
> @@ -8176,6 +8183,22 @@ static int ufshcd_add_lus(struct ufs_hba *hba)
>         return ret;
>  }
> 
> +/* SDB - Single Doorbell */
> +static void ufshcd_release_sdb_queue(struct ufs_hba *hba, int nutrs)
> +{
> +       size_t ucdl_size, utrdl_size;
> +
> +       ucdl_size = sizeof(struct utp_transfer_cmd_desc) * nutrs;
> +       dmam_free_coherent(hba->dev, ucdl_size, hba->ucdl_base_addr,
> +                          hba->ucdl_dma_addr);
> +
> +       utrdl_size = sizeof(struct utp_transfer_req_desc) * nutrs;
> +       dmam_free_coherent(hba->dev, utrdl_size, hba->utrdl_base_addr,
> +                          hba->utrdl_dma_addr);
> +
> +       devm_kfree(hba->dev, hba->lrb);
Is it possible not to release the lrb here?
and then you won't be needing to call ufshcd_memory_alloc again?

Thanks,
Avri

> +}
> +
>  static int ufshcd_alloc_mcq(struct ufs_hba *hba)
>  {
>         int ret;
> @@ -8183,12 +8206,25 @@ static int ufshcd_alloc_mcq(struct ufs_hba
> *hba)
> 
>         hba->nutrs = ufshcd_mcq_decide_queue_depth(hba);
>         ret = ufshcd_mcq_init(hba);
> -       if (ret) {
> -               hba->nutrs = old_nutrs;
> -               return ret;
> +       if (ret)
> +               goto err;
> +
> +       if (hba->nutrs != old_nutrs) {
> +               ufshcd_release_sdb_queue(hba, old_nutrs);
> +               ret = ufshcd_memory_alloc(hba);
> +               if (ret)
> +                       goto err;
> +               ufshcd_host_memory_configure(hba);
>         }
> 
> +       ret = ufshcd_mcq_memory_alloc(hba);
> +       if (ret)
> +               goto err;
> +
>         return 0;
> +err:
> +       hba->nutrs = old_nutrs;
> +       return ret;
>  }

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ